@@ -12,26 +12,27 @@ import {
12
12
type JsViewFieldOptions ,
13
13
type NotePosition ,
14
14
RenderChildType ,
15
+ type TableFieldOptions ,
15
16
type ViewFieldOptions ,
16
17
} from 'packages/core/src/config/FieldConfigs' ;
17
- import { type FieldBase } from 'packages/core/src/fields/FieldBase ' ;
18
+ import { type FieldMountable } from 'packages/core/src/fields/FieldMountable ' ;
18
19
import { ButtonActionRunner } from 'packages/core/src/fields/button/ButtonActionRunner' ;
19
- import { ButtonBase } from 'packages/core/src/fields/button/ButtonBase ' ;
20
+ import { ButtonMountable } from 'packages/core/src/fields/button/ButtonMountable ' ;
20
21
import { ButtonManager } from 'packages/core/src/fields/button/ButtonManager' ;
21
- import { ButtonGroupBase } from 'packages/core/src/fields/button/ButtonGroupBase ' ;
22
- import { InputFieldBase } from 'packages/core/src/fields/inputFields/InputFieldBase ' ;
22
+ import { ButtonGroupMountable } from 'packages/core/src/fields/button/ButtonGroupMountable ' ;
23
+ import { InputFieldMountable } from 'packages/core/src/fields/inputFields/InputFieldMountable ' ;
23
24
import { InputFieldFactory } from 'packages/core/src/fields/inputFields/InputFieldFactory' ;
24
- import { JsViewField } from 'packages/core/src/fields/viewFields/JsViewField ' ;
25
- import { ViewFieldBase } from 'packages/core/src/fields/viewFields/ViewFieldBase ' ;
25
+ import { JsViewFieldMountable } from 'packages/core/src/fields/viewFields/JsViewFieldMountable ' ;
26
+ import { ViewFieldMountable } from 'packages/core/src/fields/viewFields/ViewFieldMountable ' ;
26
27
import { ViewFieldFactory } from 'packages/core/src/fields/viewFields/ViewFieldFactory' ;
27
28
import type { BindTargetScope } from 'packages/core/src/metadata/BindTargetScope' ;
28
29
import { BindTargetParser } from 'packages/core/src/parsers/bindTargetParser/BindTargetParser' ;
29
30
import { InputFieldParser } from 'packages/core/src/parsers/inputFieldParser/InputFieldParser' ;
30
31
import { ViewFieldParser } from 'packages/core/src/parsers/viewFieldParser/ViewFieldParser' ;
31
32
import { expectType , getUUID } from 'packages/core/src/utils/Utils' ;
32
33
import { ErrorLevel , MetaBindInternalError } from 'packages/core/src/utils/errors/MetaBindErrors' ;
33
- import { EmbedBase } from 'packages/core/src/fields/embed/EmbedBase ' ;
34
- import { ExcludedBase } from 'packages/core/src/fields/excluded/ExcludedBase ' ;
34
+ import { EmbedMountable } from 'packages/core/src/fields/embed/EmbedMountable ' ;
35
+ import { ExcludedMountable } from 'packages/core/src/fields/excluded/ExcludedMountable ' ;
35
36
import { type InputFieldDeclaration } from 'packages/core/src/parsers/inputFieldParser/InputFieldDeclaration' ;
36
37
import {
37
38
type JsViewFieldDeclaration ,
@@ -57,10 +58,12 @@ import {
57
58
V_InputFieldOptions ,
58
59
V_JsViewFieldOptions ,
59
60
V_RenderChildType ,
61
+ V_TableFieldOptions ,
60
62
V_ViewFieldOptions ,
61
63
} from 'packages/core/src/api/Validators' ;
62
64
import { validate } from 'packages/core/src/utils/ZodUtils' ;
63
65
import { z } from 'zod' ;
66
+ import { TableMountable } from 'packages/core/src/fields/metaBindTable/TableMountable' ;
64
67
65
68
export interface LifecycleHook {
66
69
register ( cb : ( ) => void ) : void ;
@@ -127,7 +130,7 @@ export abstract class API<Plugin extends IPlugin> {
127
130
filePath : string ,
128
131
options : FieldOptionMap [ Type ] ,
129
132
honorExcludedSetting : boolean = true ,
130
- ) : FieldBase {
133
+ ) : FieldMountable {
131
134
validate (
132
135
z . object ( {
133
136
type : V_FieldType ,
@@ -144,23 +147,25 @@ export abstract class API<Plugin extends IPlugin> {
144
147
) ;
145
148
146
149
if ( this . plugin . internal . isFilePathExcluded ( filePath ) && honorExcludedSetting ) {
147
- return this . createExcludedBase ( filePath ) ;
150
+ return this . createExcludedMountable ( filePath ) ;
148
151
}
149
152
150
- if ( type === FieldType . INPUT_FIELD ) {
151
- return this . createInputFieldBase ( filePath , options as FieldOptionMap [ FieldType . INPUT_FIELD ] ) ;
152
- } else if ( type === FieldType . VIEW_FIELD ) {
153
- return this . createViewFieldBase ( filePath , options as FieldOptionMap [ FieldType . VIEW_FIELD ] ) ;
154
- } else if ( type === FieldType . JS_VIEW_FIELD ) {
155
- return this . createJsViewFieldBase ( filePath , options as FieldOptionMap [ FieldType . JS_VIEW_FIELD ] ) ;
153
+ if ( type === FieldType . INPUT ) {
154
+ return this . createInputFieldMountable ( filePath , options as FieldOptionMap [ FieldType . INPUT ] ) ;
155
+ } else if ( type === FieldType . VIEW ) {
156
+ return this . createViewFieldMountable ( filePath , options as FieldOptionMap [ FieldType . VIEW ] ) ;
157
+ } else if ( type === FieldType . JS_VIEW ) {
158
+ return this . createJsViewFieldMountable ( filePath , options as FieldOptionMap [ FieldType . JS_VIEW ] ) ;
159
+ } else if ( type === FieldType . TABLE ) {
160
+ return this . createTableFieldMountable ( filePath , options as FieldOptionMap [ FieldType . TABLE ] ) ;
156
161
} else if ( type === FieldType . BUTTON_GROUP ) {
157
- return this . createButtonGroupBase ( filePath , options as FieldOptionMap [ FieldType . BUTTON_GROUP ] ) ;
162
+ return this . createButtonGroupMountable ( filePath , options as FieldOptionMap [ FieldType . BUTTON_GROUP ] ) ;
158
163
} else if ( type === FieldType . BUTTON ) {
159
- return this . createButtonBase ( filePath , options as FieldOptionMap [ FieldType . BUTTON ] ) ;
164
+ return this . createButtonMountable ( filePath , options as FieldOptionMap [ FieldType . BUTTON ] ) ;
160
165
} else if ( type === FieldType . EMBED ) {
161
- return this . createEmbedBase ( filePath , options as FieldOptionMap [ FieldType . EMBED ] ) ;
166
+ return this . createEmbedMountable ( filePath , options as FieldOptionMap [ FieldType . EMBED ] ) ;
162
167
} else if ( type === FieldType . EXCLUDED ) {
163
- return this . createExcludedBase ( filePath ) ;
168
+ return this . createExcludedMountable ( filePath ) ;
164
169
}
165
170
166
171
expectType < never > ( type ) ;
@@ -187,7 +192,7 @@ export abstract class API<Plugin extends IPlugin> {
187
192
renderChildType : RenderChildType = RenderChildType . INLINE ,
188
193
position ?: NotePosition | undefined ,
189
194
honorExcludedSetting : boolean = true ,
190
- ) : FieldBase {
195
+ ) : FieldMountable {
191
196
validate (
192
197
z . object ( {
193
198
fieldString : z . string ( ) ,
@@ -245,7 +250,7 @@ export abstract class API<Plugin extends IPlugin> {
245
250
renderChildType : RenderChildType = RenderChildType . INLINE ,
246
251
position ?: NotePosition | undefined ,
247
252
honorExcludedSetting : boolean = true ,
248
- ) : FieldBase {
253
+ ) : FieldMountable {
249
254
validate (
250
255
z . object ( {
251
256
type : V_FieldType ,
@@ -266,27 +271,27 @@ export abstract class API<Plugin extends IPlugin> {
266
271
) ;
267
272
268
273
if ( this . plugin . internal . isFilePathExcluded ( filePath ) && honorExcludedSetting ) {
269
- return this . createExcludedBase ( filePath ) ;
274
+ return this . createExcludedMountable ( filePath ) ;
270
275
}
271
276
272
- if ( type === FieldType . INPUT_FIELD ) {
273
- return this . createInputFieldBase ( filePath , {
277
+ if ( type === FieldType . INPUT ) {
278
+ return this . createInputFieldMountable ( filePath , {
274
279
renderChildType : renderChildType ,
275
280
declaration : declaration ,
276
281
scope : scope ,
277
282
} ) ;
278
283
}
279
284
280
- if ( type === FieldType . VIEW_FIELD ) {
281
- return this . createViewFieldBase ( filePath , {
285
+ if ( type === FieldType . VIEW ) {
286
+ return this . createViewFieldMountable ( filePath , {
282
287
renderChildType : renderChildType ,
283
288
declaration : declaration ,
284
289
scope : scope ,
285
290
} ) ;
286
291
}
287
292
288
293
if ( type === FieldType . BUTTON_GROUP ) {
289
- return this . createButtonGroupBase ( filePath , {
294
+ return this . createButtonGroupMountable ( filePath , {
290
295
renderChildType : renderChildType ,
291
296
declaration : declaration ,
292
297
position : position ,
@@ -302,7 +307,7 @@ export abstract class API<Plugin extends IPlugin> {
302
307
} ) ;
303
308
}
304
309
305
- public createInputFieldBase ( filePath : string , options : InputFieldOptions ) : InputFieldBase {
310
+ public createInputFieldMountable ( filePath : string , options : InputFieldOptions ) : InputFieldMountable {
306
311
validate (
307
312
z . object ( {
308
313
filePath : V_FilePath ,
@@ -327,10 +332,10 @@ export abstract class API<Plugin extends IPlugin> {
327
332
) ;
328
333
}
329
334
330
- return new InputFieldBase ( this . plugin , uuid , filePath , options . renderChildType , declaration ) ;
335
+ return new InputFieldMountable ( this . plugin , uuid , filePath , options . renderChildType , declaration ) ;
331
336
}
332
337
333
- public createViewFieldBase ( filePath : string , options : ViewFieldOptions ) : ViewFieldBase {
338
+ public createViewFieldMountable ( filePath : string , options : ViewFieldOptions ) : ViewFieldMountable {
334
339
validate (
335
340
z . object ( {
336
341
filePath : V_FilePath ,
@@ -355,10 +360,10 @@ export abstract class API<Plugin extends IPlugin> {
355
360
) ;
356
361
}
357
362
358
- return new ViewFieldBase ( this . plugin , uuid , filePath , options . renderChildType , declaration ) ;
363
+ return new ViewFieldMountable ( this . plugin , uuid , filePath , options . renderChildType , declaration ) ;
359
364
}
360
365
361
- public createJsViewFieldBase ( filePath : string , options : JsViewFieldOptions ) : JsViewField {
366
+ public createJsViewFieldMountable ( filePath : string , options : JsViewFieldOptions ) : JsViewFieldMountable {
362
367
validate (
363
368
z . object ( {
364
369
filePath : V_FilePath ,
@@ -379,10 +384,27 @@ export abstract class API<Plugin extends IPlugin> {
379
384
declaration = this . jsViewFieldParser . fromSimpleDeclarationAndValidate ( options . declaration , filePath ) ;
380
385
}
381
386
382
- return new JsViewField ( this . plugin , uuid , filePath , declaration ) ;
387
+ return new JsViewFieldMountable ( this . plugin , uuid , filePath , declaration ) ;
383
388
}
384
389
385
- public createButtonGroupBase ( filePath : string , options : ButtonGroupOptions ) : ButtonGroupBase {
390
+ public createTableFieldMountable ( filePath : string , options : TableFieldOptions ) : TableMountable {
391
+ validate (
392
+ z . object ( {
393
+ filePath : V_FilePath ,
394
+ options : V_TableFieldOptions ,
395
+ } ) ,
396
+ {
397
+ filePath : filePath ,
398
+ options : options ,
399
+ } ,
400
+ ) ;
401
+
402
+ const uuid = getUUID ( ) ;
403
+
404
+ return new TableMountable ( this . plugin , uuid , filePath , options . bindTarget , options . tableHead , options . columns ) ;
405
+ }
406
+
407
+ public createButtonGroupMountable ( filePath : string , options : ButtonGroupOptions ) : ButtonGroupMountable {
386
408
validate (
387
409
z . object ( {
388
410
filePath : V_FilePath ,
@@ -403,10 +425,17 @@ export abstract class API<Plugin extends IPlugin> {
403
425
declaration = this . buttonParser . validateGroup ( options . declaration ) ;
404
426
}
405
427
406
- return new ButtonGroupBase ( this . plugin , uuid , filePath , declaration , options . renderChildType , options . position ) ;
428
+ return new ButtonGroupMountable (
429
+ this . plugin ,
430
+ uuid ,
431
+ filePath ,
432
+ declaration ,
433
+ options . renderChildType ,
434
+ options . position ,
435
+ ) ;
407
436
}
408
437
409
- public createButtonBase ( filePath : string , options : ButtonOptions ) : ButtonBase {
438
+ public createButtonMountable ( filePath : string , options : ButtonOptions ) : ButtonMountable {
410
439
validate (
411
440
z . object ( {
412
441
filePath : V_FilePath ,
@@ -427,10 +456,10 @@ export abstract class API<Plugin extends IPlugin> {
427
456
declaration = this . buttonParser . validate ( options . declaration ) ;
428
457
}
429
458
430
- return new ButtonBase ( this . plugin , uuid , filePath , declaration , options . position , options . isPreview ) ;
459
+ return new ButtonMountable ( this . plugin , uuid , filePath , declaration , options . position , options . isPreview ) ;
431
460
}
432
461
433
- public createEmbedBase ( filePath : string , options : EmbedOptions ) : EmbedBase {
462
+ public createEmbedMountable ( filePath : string , options : EmbedOptions ) : EmbedMountable {
434
463
validate (
435
464
z . object ( {
436
465
filePath : V_FilePath ,
@@ -443,10 +472,10 @@ export abstract class API<Plugin extends IPlugin> {
443
472
) ;
444
473
445
474
const uuid = getUUID ( ) ;
446
- return new EmbedBase ( this . plugin , uuid , filePath , options . depth , options . content ) ;
475
+ return new EmbedMountable ( this . plugin , uuid , filePath , options . depth , options . content ) ;
447
476
}
448
477
449
- public createExcludedBase ( filePath : string ) : ExcludedBase {
478
+ public createExcludedMountable ( filePath : string ) : ExcludedMountable {
450
479
validate (
451
480
z . object ( {
452
481
filePath : V_FilePath ,
@@ -457,7 +486,7 @@ export abstract class API<Plugin extends IPlugin> {
457
486
) ;
458
487
459
488
const uuid = getUUID ( ) ;
460
- return new ExcludedBase ( this . plugin , uuid , filePath ) ;
489
+ return new ExcludedMountable ( this . plugin , uuid , filePath ) ;
461
490
}
462
491
463
492
/**
@@ -475,9 +504,9 @@ export abstract class API<Plugin extends IPlugin> {
475
504
} ,
476
505
) ;
477
506
478
- if ( fieldType === FieldType . INPUT_FIELD ) {
507
+ if ( fieldType === FieldType . INPUT ) {
479
508
return 'INPUT' ;
480
- } else if ( fieldType === FieldType . VIEW_FIELD ) {
509
+ } else if ( fieldType === FieldType . VIEW ) {
481
510
return 'VIEW' ;
482
511
} else if ( fieldType === FieldType . BUTTON_GROUP ) {
483
512
return 'BUTTON' ;
0 commit comments