11import { untracked , computed , obx , engineConfig , action , makeObservable , mobx , runInAction } from '@alilc/lowcode-editor-core' ;
2- import { IPublicTypeCompositeValue , GlobalEvent , IPublicTypeJSSlot , IPublicTypeSlotSchema , IPublicEnumTransformStage } from '@alilc/lowcode-types' ;
2+ import { IPublicTypeCompositeValue , GlobalEvent , IPublicTypeJSSlot , IPublicTypeSlotSchema , IPublicEnumTransformStage , IPublicModelProp } from '@alilc/lowcode-types' ;
33import { uniqueId , isPlainObject , hasOwnProperty , compatStage , isJSExpression , isJSSlot } from '@alilc/lowcode-utils' ;
44import { valueToSource } from './value-to-source' ;
55import { Props } from './props' ;
6- import { SlotNode , Node } from '../node' ;
6+ import { SlotNode , INode } from '../node' ;
77// import { TransformStage } from '../transform-stage';
88
99const { set : mobxSet , isObservableArray } = mobx ;
1010export const UNSET = Symbol . for ( 'unset' ) ;
1111// eslint-disable-next-line no-redeclare
1212export type UNSET = typeof UNSET ;
1313
14- export interface IPropParent {
14+ export interface IProp extends Omit < IPublicModelProp , 'exportSchema' | 'node' > {
15+
1516 delete ( prop : Prop ) : void ;
17+
1618 readonly props : Props ;
17- readonly owner : Node ;
18- readonly path : string [ ] ;
19+
20+ readonly owner : INode ;
21+
22+ export ( stage : IPublicEnumTransformStage ) : IPublicTypeCompositeValue ;
23+
24+ getNode ( ) : INode ;
1925}
2026
2127export type ValueTypes = 'unset' | 'literal' | 'map' | 'list' | 'expression' | 'slot' ;
2228
23- export class Prop implements IPropParent {
29+ export class Prop implements IProp {
2430 readonly isProp = true ;
2531
26- readonly owner : Node ;
32+ readonly owner : INode ;
2733
2834 /**
2935 * 键值
@@ -40,7 +46,7 @@ export class Prop implements IPropParent {
4046 readonly options : any ;
4147
4248 constructor (
43- public parent : IPropParent ,
49+ public parent : IProp ,
4450 value : IPublicTypeCompositeValue | UNSET = UNSET ,
4551 key ?: string | number ,
4652 spread = false ,
@@ -305,9 +311,9 @@ export class Prop implements IPropParent {
305311 }
306312 }
307313
308- private _slotNode ?: SlotNode ;
314+ private _slotNode ?: INode ;
309315
310- get slotNode ( ) {
316+ get slotNode ( ) : INode | undefined | null {
311317 return this . _slotNode ;
312318 }
313319
@@ -342,8 +348,10 @@ export class Prop implements IPropParent {
342348 } else {
343349 const { owner } = this . props ;
344350 this . _slotNode = owner . document . createNode < SlotNode > ( slotSchema ) ;
345- owner . addSlot ( this . _slotNode ) ;
346- this . _slotNode . internalSetSlotFor ( this ) ;
351+ if ( this . _slotNode ) {
352+ owner . addSlot ( this . _slotNode ) ;
353+ this . _slotNode . internalSetSlotFor ( this ) ;
354+ }
347355 }
348356 }
349357
0 commit comments