mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 19:52:51 +00:00
feat: fix prop module issue and ts type definition
This commit is contained in:
parent
7c2ebf3c02
commit
7c16bb1f9c
@ -58,7 +58,7 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
|
||||
constructor(
|
||||
parent: SettingEntry,
|
||||
config: IPublicTypeFieldConfig,
|
||||
settingFieldCollector?: (name: string | number, field: SettingField) => void,
|
||||
private settingFieldCollector?: (name: string | number, field: SettingField) => void,
|
||||
) {
|
||||
super(parent, config.name, config.type);
|
||||
makeObservable(this);
|
||||
@ -137,7 +137,8 @@ export class SettingField extends SettingPropEntry implements SettingEntry {
|
||||
|
||||
// 创建子配置项,通常用于 object/array 类型数据
|
||||
createField(config: IPublicTypeFieldConfig): SettingField {
|
||||
return new SettingField(this, config);
|
||||
this.settingFieldCollector?.(getSettingFieldCollectorKey(this.parent, config), this);
|
||||
return new SettingField(this, config, this.settingFieldCollector);
|
||||
}
|
||||
|
||||
purge() {
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { obx, computed, makeObservable, runInAction, IEventBus, createModuleEventBus } from '@alilc/lowcode-editor-core';
|
||||
import { GlobalEvent, IPublicModelEditor, IPublicTypeSetValueOptions } from '@alilc/lowcode-types';
|
||||
import { uniqueId, isJSExpression, isSettingField } from '@alilc/lowcode-utils';
|
||||
import { Setters } from '@alilc/lowcode-shell';
|
||||
import { SettingEntry } from './setting-entry';
|
||||
import { INode } from '../../document';
|
||||
import { IComponentMeta } from '../../component-meta';
|
||||
import { Designer } from '../designer';
|
||||
import { Setters } from '@alilc/lowcode-shell';
|
||||
import { SettingField } from './setting-field';
|
||||
|
||||
export class SettingPropEntry implements SettingEntry {
|
||||
// === static properties ===
|
||||
@ -52,7 +53,7 @@ export class SettingPropEntry implements SettingEntry {
|
||||
|
||||
extraProps: any = {};
|
||||
|
||||
constructor(readonly parent: SettingEntry, name: string | number, type?: 'field' | 'group') {
|
||||
constructor(readonly parent: SettingEntry | SettingField, name: string | number, type?: 'field' | 'group') {
|
||||
makeObservable(this);
|
||||
if (type == null) {
|
||||
const c = typeof name === 'string' ? name.slice(0, 1) : '';
|
||||
|
||||
@ -303,7 +303,7 @@ export class Prop implements IProp, IPropParent {
|
||||
return this._value;
|
||||
}
|
||||
const values = this.items!.map((prop) => {
|
||||
return prop.export(stage);
|
||||
return prop?.export(stage);
|
||||
});
|
||||
if (values.every((val) => val === undefined)) {
|
||||
return undefined;
|
||||
|
||||
@ -1,59 +1,72 @@
|
||||
import { IPublicModelSettingTarget } from '../model';
|
||||
import { IPublicModelSettingPropEntry, IPublicModelSettingTarget } from '../model';
|
||||
import { IPublicTypeLiveTextEditingConfig } from './';
|
||||
|
||||
/**
|
||||
* extra props for field
|
||||
*/
|
||||
export interface IPublicTypeFieldExtraProps {
|
||||
|
||||
/**
|
||||
* 是否必填参数
|
||||
*/
|
||||
isRequired?: boolean;
|
||||
|
||||
/**
|
||||
* default value of target prop for setter use
|
||||
*/
|
||||
defaultValue?: any;
|
||||
|
||||
/**
|
||||
* get value for field
|
||||
*/
|
||||
getValue?: (target: IPublicModelSettingTarget, fieldValue: any) => any;
|
||||
|
||||
/**
|
||||
* set value for field
|
||||
*/
|
||||
setValue?: (target: IPublicModelSettingTarget, value: any) => void;
|
||||
|
||||
/**
|
||||
* the field conditional show, is not set always true
|
||||
* @default undefined
|
||||
*/
|
||||
condition?: (target: IPublicModelSettingTarget) => boolean;
|
||||
condition?: (target: IPublicModelSettingPropEntry) => boolean;
|
||||
|
||||
/**
|
||||
* autorun when something change
|
||||
*/
|
||||
autorun?: (target: IPublicModelSettingTarget) => void;
|
||||
|
||||
/**
|
||||
* is this field is a virtual field that not save to schema
|
||||
*/
|
||||
virtual?: (target: IPublicModelSettingTarget) => boolean;
|
||||
|
||||
/**
|
||||
* default collapsed when display accordion
|
||||
*/
|
||||
defaultCollapsed?: boolean;
|
||||
|
||||
/**
|
||||
* important field
|
||||
*/
|
||||
important?: boolean;
|
||||
|
||||
/**
|
||||
* internal use
|
||||
*/
|
||||
forceInline?: number;
|
||||
|
||||
/**
|
||||
* 是否支持变量配置
|
||||
*/
|
||||
supportVariable?: boolean;
|
||||
|
||||
/**
|
||||
* compatiable vision display
|
||||
*/
|
||||
display?: 'accordion' | 'inline' | 'block' | 'plain' | 'popup' | 'entry';
|
||||
|
||||
// @todo 这个 omit 是否合理?
|
||||
/**
|
||||
* @todo 待补充文档
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user