11import MetaBindTableComponent from 'packages/core/src/fields/metaBindTable/MetaBindTableComponent.svelte' ;
22import { BindTargetScope } from 'packages/core/src/metadata/BindTargetScope' ;
3- import {
4- type InputFieldDeclaration ,
5- type UnvalidatedInputFieldDeclaration ,
6- } from 'packages/core/src/parsers/inputFieldParser/InputFieldDeclaration' ;
7- import {
8- type UnvalidatedViewFieldDeclaration ,
9- type ViewFieldDeclaration ,
10- } from 'packages/core/src/parsers/viewFieldParser/ViewFieldDeclaration' ;
3+ import { type SimpleInputFieldDeclaration } from 'packages/core/src/parsers/inputFieldParser/InputFieldDeclaration' ;
4+ import { type SimpleViewFieldDeclaration } from 'packages/core/src/parsers/viewFieldParser/ViewFieldDeclaration' ;
115import { type Listener , Signal } from 'packages/core/src/utils/Signal' ;
12-
136import { type IPlugin } from 'packages/core/src/IPlugin' ;
147import { RenderChildType } from 'packages/core/src/config/FieldConfigs' ;
158import { FieldMountable } from 'packages/core/src/fields/FieldMountable' ;
16- import { InputFieldMountable } from 'packages/core/src/fields/inputFields/InputFieldMountable' ;
17- import { ViewFieldMountable } from 'packages/core/src/fields/viewFields/ViewFieldMountable' ;
189import { type MetadataSubscription } from 'packages/core/src/metadata/MetadataSubscription' ;
1910import { type BindTargetDeclaration } from 'packages/core/src/parsers/bindTargetParser/BindTargetDeclaration' ;
2011import { type MBExtendedLiteral } from 'packages/core/src/utils/Literal' ;
21- import { getUUID , showUnloadedMessage } from 'packages/core/src/utils/Utils' ;
12+ import { showUnloadedMessage } from 'packages/core/src/utils/Utils' ;
2213import { parsePropPath } from 'packages/core/src/utils/prop/PropParser' ;
2314
24- export type MetaBindTableCell = InputFieldDeclaration | ViewFieldDeclaration ;
15+ // export type MetaBindTableCell =
16+ // | {
17+ // type: FieldType.INPUT;
18+ // declaration: InputFieldDeclaration;
19+ // scope: BindTargetScope;
20+ // }
21+ // | {
22+ // type: FieldType.VIEW;
23+ // declaration: ViewFieldDeclaration;
24+ // scope: BindTargetScope;
25+ // };
26+
27+ export type MetaBindTableCell = FieldMountable ;
2528
26- export type MetaBindColumnDeclaration = UnvalidatedInputFieldDeclaration | UnvalidatedViewFieldDeclaration ;
29+ export type MetaBindColumnDeclaration = SimpleInputFieldDeclaration | SimpleViewFieldDeclaration | string ;
2730
2831export interface MetaBindTableRow {
2932 cells : MetaBindTableCell [ ] ;
@@ -112,16 +115,29 @@ export class TableMountable extends FieldMountable {
112115 listenToChildren : false ,
113116 } ) ;
114117
115- const cells = this . columns . map ( x => {
116- if ( 'inputFieldType' in x ) {
117- return this . plugin . api . inputFieldParser . validate ( x , this . getFilePath ( ) , scope ) ;
118- } else {
119- return this . plugin . api . viewFieldParser . validate (
120- x as UnvalidatedViewFieldDeclaration ,
118+ const cells : MetaBindTableCell [ ] = this . columns . map ( x => {
119+ if ( typeof x === 'string' ) {
120+ return this . plugin . api . createInlineFieldFromString (
121+ x ,
121122 this . getFilePath ( ) ,
122123 scope ,
124+ RenderChildType . INLINE ,
123125 ) ;
124126 }
127+
128+ if ( 'inputFieldType' in x ) {
129+ return this . plugin . api . createInputFieldMountable ( this . getFilePath ( ) , {
130+ declaration : x ,
131+ scope : scope ,
132+ renderChildType : RenderChildType . INLINE ,
133+ } ) ;
134+ } else {
135+ return this . plugin . api . createViewFieldMountable ( this . getFilePath ( ) , {
136+ declaration : x as SimpleViewFieldDeclaration ,
137+ scope : scope ,
138+ renderChildType : RenderChildType . INLINE ,
139+ } ) ;
140+ }
125141 } ) ;
126142
127143 tableRows . push ( {
@@ -145,17 +161,8 @@ export class TableMountable extends FieldMountable {
145161 }
146162
147163 createCell ( cell : MetaBindTableCell , element : HTMLElement ) : ( ) => void {
148- const uuid = getUUID ( ) ;
149- let field : FieldMountable ;
150-
151- if ( 'inputFieldType' in cell ) {
152- field = new InputFieldMountable ( this . plugin , uuid , this . getFilePath ( ) , RenderChildType . INLINE , cell ) ;
153- } else {
154- field = new ViewFieldMountable ( this . plugin , uuid , this . getFilePath ( ) , RenderChildType . INLINE , cell ) ;
155- }
156-
157- field . mount ( element ) ;
158- return ( ) => field . unmount ( ) ;
164+ cell . mount ( element ) ;
165+ return ( ) => cell . unmount ( ) ;
159166 }
160167
161168 removeColumn ( index : number ) : void {
0 commit comments