diff --git a/package-lock.json b/package-lock.json index ab514d9..05bccc2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "uiconfig.js", - "version": "0.0.4", + "version": "0.0.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "uiconfig.js", - "version": "0.0.4", + "version": "0.0.5", "license": "MIT", "devDependencies": { "@rollup/plugin-commonjs": "^24.0.1", diff --git a/package.json b/package.json index 9b2ffcf..17c68f2 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/UiConfigMethods.ts b/src/UiConfigMethods.ts index a81239f..4d2e85f 100644 --- a/src/UiConfigMethods.ts +++ b/src/UiConfigMethods.ts @@ -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 diff --git a/src/decorator_utils.ts b/src/decorator_utils.ts index 0614612..57e9e8d 100644 --- a/src/decorator_utils.ts +++ b/src/decorator_utils.ts @@ -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() @@ -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) } } @@ -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 = { @@ -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 = config + config = ()=>Object.assign(c1(), {...params, ...extraParams}) + } Object.assign(config, {...params, ...extraParams}) } result.push(config)