11import { obx , computed , makeObservable , runInAction , IEventBus , createModuleEventBus } from '@alilc/lowcode-editor-core' ;
2- import { GlobalEvent , IPublicApiSetters , IPublicModelEditor , IPublicTypeSetValueOptions } from '@alilc/lowcode-types' ;
3- import { uniqueId , isJSExpression , isSettingField } from '@alilc/lowcode-utils' ;
4- import { ISettingEntry } from './setting-entry' ;
2+ import { GlobalEvent , IPublicApiSetters , IPublicModelEditor , IPublicModelSettingField , IPublicTypeFieldExtraProps , IPublicTypeSetValueOptions } from '@alilc/lowcode-types' ;
3+ import { uniqueId , isJSExpression } from '@alilc/lowcode-utils' ;
4+ import { ISettingEntry } from './setting-entry-type ' ;
55import { INode } from '../../document' ;
66import { IComponentMeta } from '../../component-meta' ;
77import { IDesigner } from '../designer' ;
8- import { ISettingField } from './setting-field' ;
8+ import { ISettingTopEntry } from './setting-top-entry' ;
9+ import { ISettingField , isSettingField } from './setting-field' ;
910
10- export class SettingPropEntry implements ISettingEntry {
11+ export interface ISettingPropEntry extends ISettingEntry {
12+ get props ( ) : ISettingTopEntry ;
13+
14+ readonly isGroup : boolean ;
15+
16+ get name ( ) : string | number | undefined ;
17+
18+ valueChange ( options : IPublicTypeSetValueOptions ) : void ;
19+
20+ getKey ( ) : string | number | undefined ;
21+
22+ setKey ( key : string | number ) : void ;
23+
24+ getDefaultValue ( ) : any ;
25+
26+ setUseVariable ( flag : boolean ) : void ;
27+
28+ getProps ( ) : ISettingTopEntry ;
29+
30+ isUseVariable ( ) : boolean ;
31+
32+ getMockOrValue ( ) : any ;
33+
34+ remove ( ) : void ;
35+
36+ setValue ( val : any , isHotValue ?: boolean , force ?: boolean , extraOptions ?: IPublicTypeSetValueOptions ) : void ;
37+
38+ internalToShell ( ) : IPublicModelSettingField ;
39+ }
40+
41+ export class SettingPropEntry implements ISettingPropEntry {
1142 // === static properties ===
1243 readonly editor : IPublicModelEditor ;
1344
@@ -23,9 +54,9 @@ export class SettingPropEntry implements ISettingEntry {
2354
2455 readonly componentMeta : IComponentMeta | null ;
2556
26- readonly designer : IDesigner ;
57+ readonly designer : IDesigner | undefined ;
2758
28- readonly top : ISettingEntry ;
59+ readonly top : ISettingTopEntry ;
2960
3061 readonly isGroup : boolean ;
3162
@@ -50,9 +81,9 @@ export class SettingPropEntry implements ISettingEntry {
5081 return path ;
5182 }
5283
53- extraProps : any = { } ;
84+ extraProps : IPublicTypeFieldExtraProps = { } ;
5485
55- constructor ( readonly parent : ISettingEntry | ISettingField , name : string | number | undefined , type ?: 'field' | 'group' ) {
86+ constructor ( readonly parent : ISettingTopEntry | ISettingField , name : string | number | undefined , type ?: 'field' | 'group' ) {
5687 makeObservable ( this ) ;
5788 if ( type == null ) {
5889 const c = typeof name === 'string' ? name . slice ( 0 , 1 ) : '' ;
@@ -126,7 +157,7 @@ export class SettingPropEntry implements ISettingEntry {
126157 if ( this . type !== 'field' ) {
127158 const { getValue } = this . extraProps ;
128159 return getValue
129- ? getValue ( this . internalToShellPropEntry ( ) , undefined ) === undefined
160+ ? getValue ( this . internalToShell ( ) ! , undefined ) === undefined
130161 ? 0
131162 : 1
132163 : 0 ;
@@ -165,7 +196,7 @@ export class SettingPropEntry implements ISettingEntry {
165196 }
166197 const { getValue } = this . extraProps ;
167198 try {
168- return getValue ? getValue ( this . internalToShellPropEntry ( ) , val ) : val ;
199+ return getValue ? getValue ( this . internalToShell ( ) ! , val ) : val ;
169200 } catch ( e ) {
170201 console . warn ( e ) ;
171202 return val ;
@@ -184,7 +215,7 @@ export class SettingPropEntry implements ISettingEntry {
184215 const { setValue } = this . extraProps ;
185216 if ( setValue && ! extraOptions ?. disableMutator ) {
186217 try {
187- setValue ( this . internalToShellPropEntry ( ) , val ) ;
218+ setValue ( this . internalToShell ( ) ! , val ) ;
188219 } catch ( e ) {
189220 /* istanbul ignore next */
190221 console . warn ( e ) ;
@@ -207,7 +238,7 @@ export class SettingPropEntry implements ISettingEntry {
207238 const { setValue } = this . extraProps ;
208239 if ( setValue ) {
209240 try {
210- setValue ( this . internalToShellPropEntry ( ) , undefined ) ;
241+ setValue ( this . internalToShell ( ) ! , undefined ) ;
211242 } catch ( e ) {
212243 /* istanbul ignore next */
213244 console . warn ( e ) ;
@@ -363,7 +394,7 @@ export class SettingPropEntry implements ISettingEntry {
363394 return v ;
364395 }
365396
366- internalToShellPropEntry ( ) {
367- return this . designer . shellModelFactory . createSettingPropEntry ( this ) ;
397+ internalToShell ( ) : IPublicModelSettingField {
398+ return this . designer ! . shellModelFactory . createSettingField ( this ) ; ;
368399 }
369400}
0 commit comments