Skip to content

Commit 7c16bb1

Browse files
liujupingJackLian
authored andcommitted
feat: fix prop module issue and ts type definition
1 parent 7c2ebf3 commit 7c16bb1

4 files changed

Lines changed: 22 additions & 7 deletions

File tree

packages/designer/src/designer/setting/setting-field.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
5858
constructor(
5959
parent: SettingEntry,
6060
config: IPublicTypeFieldConfig,
61-
settingFieldCollector?: (name: string | number, field: SettingField) => void,
61+
private settingFieldCollector?: (name: string | number, field: SettingField) => void,
6262
) {
6363
super(parent, config.name, config.type);
6464
makeObservable(this);
@@ -137,7 +137,8 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
137137

138138
// 创建子配置项,通常用于 object/array 类型数据
139139
createField(config: IPublicTypeFieldConfig): SettingField {
140-
return new SettingField(this, config);
140+
this.settingFieldCollector?.(getSettingFieldCollectorKey(this.parent, config), this);
141+
return new SettingField(this, config, this.settingFieldCollector);
141142
}
142143

143144
purge() {

packages/designer/src/designer/setting/setting-prop-entry.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { obx, computed, makeObservable, runInAction, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
22
import { GlobalEvent, IPublicModelEditor, IPublicTypeSetValueOptions } from '@alilc/lowcode-types';
33
import { uniqueId, isJSExpression, isSettingField } from '@alilc/lowcode-utils';
4+
import { Setters } from '@alilc/lowcode-shell';
45
import { SettingEntry } from './setting-entry';
56
import { INode } from '../../document';
67
import { IComponentMeta } from '../../component-meta';
78
import { Designer } from '../designer';
8-
import { Setters } from '@alilc/lowcode-shell';
9+
import { SettingField } from './setting-field';
910

1011
export class SettingPropEntry implements SettingEntry {
1112
// === static properties ===
@@ -52,7 +53,7 @@ export class SettingPropEntry implements SettingEntry {
5253

5354
extraProps: any = {};
5455

55-
constructor(readonly parent: SettingEntry, name: string | number, type?: 'field' | 'group') {
56+
constructor(readonly parent: SettingEntry | SettingField, name: string | number, type?: 'field' | 'group') {
5657
makeObservable(this);
5758
if (type == null) {
5859
const c = typeof name === 'string' ? name.slice(0, 1) : '';

packages/designer/src/document/node/props/prop.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ export class Prop implements IProp, IPropParent {
303303
return this._value;
304304
}
305305
const values = this.items!.map((prop) => {
306-
return prop.export(stage);
306+
return prop?.export(stage);
307307
});
308308
if (values.every((val) => val === undefined)) {
309309
return undefined;

packages/types/src/shell/type/field-extra-props.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,72 @@
1-
import { IPublicModelSettingTarget } from '../model';
1+
import { IPublicModelSettingPropEntry, IPublicModelSettingTarget } from '../model';
22
import { IPublicTypeLiveTextEditingConfig } from './';
33

44
/**
55
* extra props for field
66
*/
77
export interface IPublicTypeFieldExtraProps {
8+
89
/**
910
* 是否必填参数
1011
*/
1112
isRequired?: boolean;
13+
1214
/**
1315
* default value of target prop for setter use
1416
*/
1517
defaultValue?: any;
18+
1619
/**
1720
* get value for field
1821
*/
1922
getValue?: (target: IPublicModelSettingTarget, fieldValue: any) => any;
23+
2024
/**
2125
* set value for field
2226
*/
2327
setValue?: (target: IPublicModelSettingTarget, value: any) => void;
28+
2429
/**
2530
* the field conditional show, is not set always true
2631
* @default undefined
2732
*/
28-
condition?: (target: IPublicModelSettingTarget) => boolean;
33+
condition?: (target: IPublicModelSettingPropEntry) => boolean;
34+
2935
/**
3036
* autorun when something change
3137
*/
3238
autorun?: (target: IPublicModelSettingTarget) => void;
39+
3340
/**
3441
* is this field is a virtual field that not save to schema
3542
*/
3643
virtual?: (target: IPublicModelSettingTarget) => boolean;
44+
3745
/**
3846
* default collapsed when display accordion
3947
*/
4048
defaultCollapsed?: boolean;
49+
4150
/**
4251
* important field
4352
*/
4453
important?: boolean;
54+
4555
/**
4656
* internal use
4757
*/
4858
forceInline?: number;
59+
4960
/**
5061
* 是否支持变量配置
5162
*/
5263
supportVariable?: boolean;
64+
5365
/**
5466
* compatiable vision display
5567
*/
5668
display?: 'accordion' | 'inline' | 'block' | 'plain' | 'popup' | 'entry';
69+
5770
// @todo 这个 omit 是否合理?
5871
/**
5972
* @todo 待补充文档

0 commit comments

Comments
 (0)