Skip to content

Commit

Permalink
Update unknown type object and arrays on refresh in generateUiConfig.
Browse files Browse the repository at this point in the history
  • Loading branch information
repalash committed Aug 11, 2023
1 parent 7484253 commit a4c5d2d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uiconfig.js",
"version": "0.0.4",
"version": "0.0.5",
"description": "A framework for building user interface layouts with JSON configuration.",
"main": "src/index.ts",
"module": "dist/index.mjs",
Expand Down
2 changes: 1 addition & 1 deletion src/UiConfigMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export class UiConfigMethods {
return this.runAtEvent(config, () => {
const [tar, key] = this.getBinding(config)
if (!tar || value === tar[key] || !safeSetProperty(tar, key, value, true, true)) {
if(!forceOnChange) return false
if (!forceOnChange) return false
}
this.dispatchOnChangeSync(config, props)
return true
Expand Down
9 changes: 7 additions & 2 deletions src/decorator_utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {UiObjectConfig} from './types'
import {v4} from 'uuid'
import {Fof} from 'ts-browser-helpers'

export class UiConfigTypeMap {
static Map = new Map<ObjectConstructor, any[]>()
Expand Down Expand Up @@ -44,7 +45,7 @@ export function generateUiConfig(obj: any): UiObjectConfig[] {
const val = obj[key]
if (val === undefined || val === null) continue
// if (Array.isArray(obj)) debugger
const c = generateValueConfig(obj, key, key + '', val)
const c = ()=>generateValueConfig(obj, key, key + '', val)
if (c) result.push(c)
}
}
Expand All @@ -53,7 +54,7 @@ export function generateUiConfig(obj: any): UiObjectConfig[] {
UiConfigTypeMap.Map.get(t)?.forEach(({params, propKey, uiType}: any) => {
let config: any
if (!uiType) {
config = generateValueConfig(obj, propKey)
config = ()=>generateValueConfig(obj, propKey)
}
if (!config) {
config = {
Expand All @@ -66,6 +67,10 @@ export function generateUiConfig(obj: any): UiObjectConfig[] {
if (params) {
const extraParams = typeof params.params === 'function' ? params.params(obj) : params.params || {}
delete params.params
if (typeof config === 'function') {
const c1: Fof<any, any> = config
config = ()=>Object.assign(c1(), {...params, ...extraParams})
}
Object.assign(config, {...params, ...extraParams})
}
result.push(config)
Expand Down

0 comments on commit a4c5d2d

Please sign in to comment.