From bf79e6381f24d06785603b8651d9047ab8a220df Mon Sep 17 00:00:00 2001 From: "mario.gk" Date: Tue, 21 Jul 2020 17:50:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20initial=20=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E3=80=81type=20=3D=20'composite'=20=E6=97=B6=20items?= =?UTF-8?q?=20=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/bundle/upgrade-metadata.ts | 51 ++++++++++--------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/packages/editor-preset-vision/src/bundle/upgrade-metadata.ts b/packages/editor-preset-vision/src/bundle/upgrade-metadata.ts index 0f00fe94f..cf7ef1ff9 100644 --- a/packages/editor-preset-vision/src/bundle/upgrade-metadata.ts +++ b/packages/editor-preset-vision/src/bundle/upgrade-metadata.ts @@ -268,9 +268,8 @@ export function upgradePropConfig(config: OldPropConfig, collector: ConfigCollec extraProps.condition = (field: Field) => !(isHidden(field) || isDisabled(field)); } - newConfig.items = items ? upgradeConfigure(items, collector) : []; - if (type === 'group') { + newConfig.items = items ? upgradeConfigure(items, collector) : []; return newConfig; } @@ -333,27 +332,29 @@ export function upgradePropConfig(config: OldPropConfig, collector: ConfigCollec const setterInitial = getInitialFromSetter(setter); - collector.addInitial({ - // FIXME! name could be "xxx.xxx" - name: slotName || name, - initial: (field: Field, currentValue: any) => { - // FIXME! read from prototype.defaultProps - const defaults = extraProps.defaultValue; - - if (typeof initialFn !== 'function') { - initialFn = defaultInitial; - } - - const v = initialFn.call(field, currentValue, defaults); - - if (setterInitial) { - return setterInitial.call(field, v, defaults); - } - - return v; - }, - }); - + if (type !== 'composite') { + collector.addInitial({ + // FIXME! name could be "xxx.xxx" + name: slotName || name, + initial: (field: Field, currentValue: any) => { + // FIXME! read from prototype.defaultProps + const defaults = extraProps.defaultValue; + + if (typeof initialFn !== 'function') { + initialFn = defaultInitial; + } + + const v = initialFn.call(field, currentValue, defaults); + + if (setterInitial) { + return setterInitial.call(field, v, defaults); + } + + return v; + }, + }); + } + if (ignore != null || disabled != null) { collector.addFilter({ // FIXME! name should be "xxx.xxx" @@ -432,9 +433,11 @@ export function upgradePropConfig(config: OldPropConfig, collector: ConfigCollec autorun: item.autorun, }); }, - } + }, ) : []; + newConfig.items = objItems; + const initial = (target: SettingTarget, value?: any) => { // TODO: const defaults = extraProps.defaultValue;