@flowgram.ai/type-editor 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,767 @@
1
+ import React, { Ref, FC } from 'react';
2
+ import * as _flowgram_ai_json_schema from '@flowgram.ai/json-schema';
3
+ import { IJsonSchema, JsonSchemaTypeManager, JsonSchemaTypeRegistryCreator, JsonSchemaTypeRegistry } from '@flowgram.ai/json-schema';
4
+ export * from '@flowgram.ai/json-schema';
5
+ import { Emitter, Event } from '@flowgram.ai/utils';
6
+ import { CascaderProps } from '@douyinfe/semi-ui/lib/es/cascader';
7
+
8
+ /**
9
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
10
+ * SPDX-License-Identifier: MIT
11
+ */
12
+
13
+ declare class TypeEditorRegistryManager<TypeSchema extends Partial<IJsonSchema>> extends JsonSchemaTypeManager<TypeSchema, TypeEditorRegistry<TypeSchema>> {
14
+ }
15
+
16
+ /**
17
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
18
+ * SPDX-License-Identifier: MIT
19
+ */
20
+
21
+ /**
22
+ * 定义用于在 service 的一些需要被监听 onChange 的 data
23
+ * 搭配 useMonitorData 使用
24
+ */
25
+ declare class MonitorData<Type> {
26
+ private _data;
27
+ protected readonly onDataChangeEmitter: Emitter<{
28
+ prev: Type;
29
+ next: Type;
30
+ }>;
31
+ readonly onDataChange: Event<{
32
+ prev: Type;
33
+ next: Type;
34
+ }>;
35
+ get data(): Type;
36
+ constructor(initialValue?: Type);
37
+ update(data: Type): void;
38
+ }
39
+
40
+ interface ITypeDefinitionManager<TypeSchema extends Partial<IJsonSchema>> {
41
+ getDefinitionByIJsonSchema: (typeSchema?: TypeSchema) => TypeEditorRegistry<TypeSchema> | undefined;
42
+ getAllTypeDefinitions: () => TypeEditorRegistry<TypeSchema>[];
43
+ getDefinitionByType: (type: string) => TypeEditorRegistry<TypeSchema> | undefined;
44
+ getUndefinedIJsonSchema: () => TypeSchema;
45
+ }
46
+ interface ITypeDefinitionAdapter<TypeSchema extends Partial<IJsonSchema>> {
47
+ /**
48
+ * @deprecated 兼容旧接口,已废弃,请使用 typeRegistryManager
49
+ */
50
+ typeDefinitionManager: ITypeDefinitionManager<TypeSchema>;
51
+ /**
52
+ * @deprecated 兼容旧接口,已废弃,请使用 typeRegistryManager 的 getComplexText 方法
53
+ */
54
+ utils: {
55
+ getComposedLabel: (type: TypeSchema) => string;
56
+ };
57
+ }
58
+
59
+ /**
60
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
61
+ * SPDX-License-Identifier: MIT
62
+ */
63
+
64
+ type TypeRegistryCreatorsAdapter<TypeSchema extends Partial<IJsonSchema>> = (param: Parameters<JsonSchemaTypeRegistryCreator<TypeSchema, TypeEditorRegistry<TypeSchema>>>[0] & ITypeDefinitionAdapter<TypeSchema>) => ReturnType<JsonSchemaTypeRegistryCreator<TypeSchema, TypeEditorRegistry<TypeSchema>>>;
65
+ declare const TypeEditorContext: React.Context<{
66
+ /**
67
+ * @deprecated
68
+ */
69
+ typeRegistryCreators?: TypeRegistryCreatorsAdapter<IJsonSchema>[];
70
+ }>;
71
+
72
+ /**
73
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
74
+ * SPDX-License-Identifier: MIT
75
+ */
76
+
77
+ declare class ClipboardService {
78
+ readonly onClipboardChangedEmitter: Emitter<string>;
79
+ readonly onClipboardChanged: Event<string>;
80
+ /**
81
+ * 读取浏览器数据
82
+ */
83
+ private get data();
84
+ private saveReadData;
85
+ /**
86
+ * 设置剪切板数据
87
+ */
88
+ writeData(newStrData: string): Promise<void>;
89
+ /**
90
+ * 获取剪切板数据
91
+ */
92
+ readData(): Promise<string>;
93
+ clearData(): void;
94
+ }
95
+
96
+ /**
97
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
98
+ * SPDX-License-Identifier: MIT
99
+ */
100
+
101
+ declare class TypeEditorService<TypeSchema extends Partial<IJsonSchema>> {
102
+ private _configs;
103
+ private _activePos;
104
+ private _dropInfo;
105
+ errorMsgs: MonitorData<{
106
+ pos: TypeEditorPos;
107
+ msg?: string;
108
+ }[]>;
109
+ editValue: unknown;
110
+ onChange: (typeSchema?: TypeSchema, ctx?: {
111
+ storeState?: boolean;
112
+ }) => void;
113
+ onRemoveEmptyLine: (id: string) => void;
114
+ onGlobalAdd: ((id: string) => void) | undefined;
115
+ typeRegistryCreators?: TypeRegistryCreatorsAdapter<TypeSchema>[];
116
+ private dataSource;
117
+ dataSourceMap: Record<string, TypeEditorRowData<TypeSchema>>;
118
+ dataSourceTouchedMap: Record<string, boolean>;
119
+ blink: MonitorData<boolean>;
120
+ columnViewConfig: TypeEditorColumnViewConfig[];
121
+ onActivePosChange: Emitter<TypeEditorPos>;
122
+ onDropInfoChange: Emitter<TypeEditorDropInfo>;
123
+ clipboard: ClipboardService;
124
+ typeDefinition: TypeEditorRegistryManager<TypeSchema>;
125
+ rootTypeSchema: TypeSchema;
126
+ setErrorMsg: (pos: TypeEditorPos, msg?: string) => void;
127
+ refreshErrorMsgAfterRemove: (index: number) => void;
128
+ checkActivePosError: () => boolean;
129
+ setEditValue: (val: unknown) => void;
130
+ registerConfigs(config: TypeEditorColumnConfig<TypeSchema> | TypeEditorColumnConfig<TypeSchema>[]): void;
131
+ addConfigProps(type: TypeEditorColumnType, config: Partial<Omit<TypeEditorColumnConfig<TypeSchema>, 'type'>>): void;
132
+ getConfigs: () => TypeEditorColumnConfig<TypeSchema>[];
133
+ getConfigByType(type: TypeEditorColumnType): TypeEditorColumnConfig<TypeSchema> | undefined;
134
+ triggerShortcutEvent(event: 'enter' | 'tab' | 'left' | 'right' | 'up' | 'down' | 'copy' | 'paste' | 'delete'): void;
135
+ get activePos(): TypeEditorPos;
136
+ private checkRowDataColumnCanEdit;
137
+ /**
138
+ * 获取可编辑的下一列/上一列
139
+ */
140
+ private getCanEditColumn;
141
+ /**
142
+ * 获取可编辑的下一行/上一行
143
+ */
144
+ private getCanEditLine;
145
+ /**
146
+ * 获取下一个可编辑的
147
+ */
148
+ private getNextEditItem;
149
+ moveActivePosToNextLine(): void;
150
+ moveActivePosToNextLineWithAddLine(rowData: TypeEditorRowData<TypeSchema>): void;
151
+ moveActivePosToLastLine(): void;
152
+ moveActivePosToLastColumn(): void;
153
+ moveActivePosToNextColumn(): void;
154
+ moveActivePosToNextItem(): void;
155
+ setActivePos(pos: TypeEditorPos): void;
156
+ clearActivePos(): void;
157
+ setDataSource(newData: TypeEditorRowData<TypeSchema>[]): void;
158
+ getDataSource(): TypeEditorRowData<TypeSchema>[];
159
+ setColumnViewConfig(config: TypeEditorColumnViewConfig[]): void;
160
+ get dropInfo(): TypeEditorDropInfo;
161
+ setDropInfo(dropInfo: TypeEditorDropInfo): void;
162
+ clearDropInfo(): void;
163
+ }
164
+
165
+ /**
166
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
167
+ * SPDX-License-Identifier: MIT
168
+ */
169
+ declare class ShortcutsService {
170
+ }
171
+
172
+ /**
173
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
174
+ * SPDX-License-Identifier: MIT
175
+ */
176
+
177
+ interface StackItem {
178
+ id: string;
179
+ value: string;
180
+ }
181
+ declare class TypeEditorOperationService<TypeSchema extends Partial<IJsonSchema>> {
182
+ undoStack: StackItem[];
183
+ redoStack: StackItem[];
184
+ private _id_idx;
185
+ private _getNewId;
186
+ _storeState: (value: TypeSchema) => void;
187
+ canUndo: MonitorData<boolean>;
188
+ canRedo: MonitorData<boolean>;
189
+ constructor();
190
+ refreshUndoRedoStatus(): void;
191
+ getCurrentState(): TypeSchema | undefined;
192
+ clear(): void;
193
+ storeState(value: TypeSchema): void;
194
+ undo(): Promise<void>;
195
+ redo(): Promise<void>;
196
+ debugger(): void;
197
+ }
198
+
199
+ /**
200
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
201
+ * SPDX-License-Identifier: MIT
202
+ */
203
+
204
+ interface TypeEditorPos {
205
+ x: number;
206
+ y: number;
207
+ }
208
+ interface TypeEditorDropInfo {
209
+ rowDataId: string;
210
+ indent: number;
211
+ index: number;
212
+ }
213
+ interface TypeChangeContext {
214
+ type: TypeEditorColumnType;
215
+ oldValue: unknown;
216
+ newValue: unknown;
217
+ }
218
+ interface EditorProps {
219
+ keyCheck: boolean;
220
+ }
221
+ interface RenderProps<TypeSchema extends Partial<IJsonSchema>> {
222
+ rowData: TypeEditorRowData<TypeSchema>;
223
+ readonly?: boolean;
224
+ onViewMode: () => void;
225
+ typeEditor: TypeEditorService<TypeSchema>;
226
+ onChildrenVisibleChange: (rowDataKey: string, newVal: boolean) => void;
227
+ onChange: () => void;
228
+ onPaste?: (typeSchema?: TypeSchema) => TypeSchema | undefined;
229
+ onFieldChange?: (ctx: TypeChangeContext) => void;
230
+ onEditMode: () => void;
231
+ dragSource?: Ref<HTMLSpanElement>;
232
+ error: boolean;
233
+ onError?: (msg: string[]) => void;
234
+ unOpenKeys: Record<string, boolean>;
235
+ config: Omit<TypeEditorColumnViewConfig, 'type' | 'visible'>;
236
+ }
237
+ interface ShortcutContext<TypeSchema extends Partial<IJsonSchema>> {
238
+ value: any;
239
+ rowData: TypeEditorRowData<TypeSchema>;
240
+ onChange: () => void;
241
+ onRemoveEmptyLine: (id: string) => void;
242
+ typeEditor: TypeEditorService<TypeSchema>;
243
+ onError?: (msg?: string) => void;
244
+ typeDefinitionService: TypeEditorRegistryManager<TypeSchema>;
245
+ }
246
+ interface InfoContext {
247
+ shortcuts: ShortcutsService;
248
+ }
249
+ interface TypeEditorColumnConfig<TypeSchema extends Partial<IJsonSchema>> {
250
+ /**
251
+ * type
252
+ */
253
+ type: TypeEditorColumnType;
254
+ /**
255
+ * 标题
256
+ */
257
+ label: string;
258
+ /**
259
+ * 百分比
260
+ */
261
+ width?: number;
262
+ /**
263
+ * 是否可 focus
264
+ */
265
+ focusable?: boolean;
266
+ /**
267
+ * label ❓ 提示
268
+ */
269
+ info?: () => string;
270
+ /**
271
+ * 只读态 render
272
+ */
273
+ viewRender?: FC<RenderProps<TypeSchema>>;
274
+ /**
275
+ * 编辑态 render
276
+ */
277
+ editRender?: FC<RenderProps<TypeSchema>>;
278
+ /**
279
+ * 是否自定义拖拽
280
+ */
281
+ customDrop?: boolean;
282
+ /**
283
+ * 校验该行是否存在错误
284
+ */
285
+ validateCell?: (rowData: TypeEditorRowData<TypeSchema>, extra: TypeEditorSpecialConfig<TypeSchema>) => {
286
+ level: 'error' | 'warning';
287
+ msg?: string;
288
+ } | undefined;
289
+ /**
290
+ * 快捷键响应
291
+ */
292
+ shortcuts?: {
293
+ onEnter?: (ctx: ShortcutContext<TypeSchema>) => void;
294
+ onTab?: (ctx: ShortcutContext<TypeSchema>) => void;
295
+ onUp?: (ctx: ShortcutContext<TypeSchema>) => void;
296
+ onDown?: (ctx: ShortcutContext<TypeSchema>) => void;
297
+ onLeft?: (ctx: ShortcutContext<TypeSchema>) => void;
298
+ onRight?: (ctx: ShortcutContext<TypeSchema>) => void;
299
+ onCopy?: (ctx: ShortcutContext<TypeSchema>) => void;
300
+ onPaste?: (ctx: ShortcutContext<TypeSchema>) => void;
301
+ onDelete?: (ctx: ShortcutContext<TypeSchema>) => void;
302
+ };
303
+ }
304
+ interface DisableTypeInfo {
305
+ type: string;
306
+ reason: string;
307
+ }
308
+ interface TypeEditorColumnViewConfig {
309
+ /**
310
+ * 类型
311
+ */
312
+ type: TypeEditorColumnType;
313
+ /**
314
+ * 是否可见
315
+ */
316
+ visible: boolean;
317
+ }
318
+ interface TypeEditorColumnViewConfig {
319
+ /**
320
+ * 类型
321
+ */
322
+ type: TypeEditorColumnType;
323
+ /**
324
+ * 是否可见
325
+ */
326
+ visible: boolean;
327
+ }
328
+ declare enum TypeEditorColumnType {
329
+ /**
330
+ *
331
+ */
332
+ Key = "key",
333
+ Type = "type",
334
+ Required = "required",
335
+ Description = "description",
336
+ Default = "default",
337
+ Operate = "operate",
338
+ Value = "value",
339
+ Private = "private"
340
+ }
341
+ interface TypeEditorExtraInfo {
342
+ value?: any;
343
+ }
344
+ type TypeEditorSchema<TypeSchema extends Partial<IJsonSchema>> = TypeSchema & {
345
+ extra?: TypeEditorExtraInfo;
346
+ };
347
+ interface TypeEditorSpecialConfig<TypeSchema extends Partial<IJsonSchema>> {
348
+ /**
349
+ * 默认值展示模式
350
+ *
351
+ * default 默认编辑模式
352
+ * server 为展示后端兜底默认值
353
+ */
354
+ defaultMode?: 'default' | 'server';
355
+ /**
356
+ * 支持自定义校验 Name 函数
357
+ */
358
+ customValidateName?: (name: string) => string;
359
+ /**
360
+ * 关闭自动修复 index
361
+ */
362
+ disableFixIndex?: boolean;
363
+ /**
364
+ * 是否可以编辑 key 的可见
365
+ */
366
+ editorVisible?: boolean | string;
367
+ /**
368
+ * 隐藏拖拽
369
+ */
370
+ hiddenDrag?: boolean;
371
+ /**
372
+ * 使用 extra 字段,而非 flow 字段
373
+ */
374
+ useExtra?: boolean;
375
+ /**
376
+ * type-selector 禁用类型
377
+ */
378
+ customDisabledTypes?: Array<DisableTypeInfo>;
379
+ /**
380
+ * 是否禁用 add
381
+ */
382
+ disabledAdd?: (rowData: TypeEditorRowData<TypeSchema>) => string;
383
+ /**
384
+ * 自定义默认值展示
385
+ */
386
+ customDefaultView?: (ctx: {
387
+ rowData: TypeEditorRowData<TypeSchema>;
388
+ value: unknown;
389
+ disabled?: string;
390
+ onChange: (value: unknown) => void;
391
+ onSubmit: (value: unknown) => void;
392
+ }) => JSX.Element;
393
+ /**
394
+ * 自定义 default 禁用规则
395
+ */
396
+ customDefaultEditable?: (rowData: TypeEditorRowData<TypeSchema>) => true | string;
397
+ }
398
+ type TypeEditorRowData<TypeSchema extends Partial<IJsonSchema>> = TypeSchema & {
399
+ /**
400
+ * 当前行的唯一值
401
+ */
402
+ id: string;
403
+ /**
404
+ * key 值
405
+ */
406
+ key: string;
407
+ /**
408
+ * 是否必填
409
+ */
410
+ isRequired: boolean;
411
+ /**
412
+ * 层数
413
+ */
414
+ level: number;
415
+ /**
416
+ * rowData 关联的 IJsonSchema
417
+ */
418
+ self: TypeEditorSchema<TypeSchema>;
419
+ /**
420
+ * 父节点 IJsonSchema
421
+ */
422
+ parent?: TypeEditorSchema<TypeSchema>;
423
+ /**
424
+ * 子节点个数,只包括子类型
425
+ */
426
+ childrenCount: number;
427
+ /**
428
+ * 子节点个数,包括子类型嵌套类型
429
+ */
430
+ deepChildrenCount: number;
431
+ /**
432
+ * 不能编辑的列
433
+ * 和 IJsonSchema 中 editable 的关系
434
+ * editable 为 false,会将 disableEditColumn 每个 column 都填上
435
+ */
436
+ disableEditColumn?: Array<{
437
+ column: TypeEditorColumnType;
438
+ reason: string;
439
+ }>;
440
+ /**
441
+ * 是否不能拖拽
442
+ */
443
+ cannotDrag?: boolean;
444
+ /**
445
+ * 行
446
+ */
447
+ index: number;
448
+ /**
449
+ *
450
+ */
451
+ extraConfig: TypeEditorSpecialConfig<TypeSchema>;
452
+ /**
453
+ * 父节点 rowId
454
+ */
455
+ parentId?: string;
456
+ /**
457
+ * path
458
+ */
459
+ path: string[];
460
+ };
461
+
462
+ /**
463
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
464
+ * SPDX-License-Identifier: MIT
465
+ */
466
+
467
+ interface TypeInputConfig<TypeSchema extends Partial<IJsonSchema>> {
468
+ canEnter?: boolean;
469
+ getProps?: (typeSchema: TypeSchema) => Record<string, unknown>;
470
+ }
471
+ interface FlowSchemaInitCtx {
472
+ enum?: string[];
473
+ }
474
+ interface TypeInputContext<TypeSchema extends Partial<IJsonSchema>> {
475
+ value?: any;
476
+ onChange: (newVal: any) => void;
477
+ type: TypeSchema;
478
+ onSubmit: () => void;
479
+ }
480
+ interface TypeCascaderConfig<TypeSchema extends Partial<IJsonSchema>> {
481
+ /**
482
+ * 自定义 CascaderPanel
483
+ */
484
+ customCascaderPanel?: (ctx: {
485
+ typeSchema: TypeSchema;
486
+ onChange: (typeSchema: TypeSchema) => void;
487
+ onFocus?: () => void;
488
+ onBlur?: () => void;
489
+ }) => JSX.Element;
490
+ /**
491
+ * 选中后是否不关闭面板
492
+ */
493
+ unClosePanelAfterSelect?: boolean;
494
+ /**
495
+ * 获取生成 schema 的 ctx
496
+ */
497
+ generateInitCtx?: (typeSchema: TypeSchema) => FlowSchemaInitCtx;
498
+ }
499
+ interface TypeEditorRegistry<TypeSchema extends Partial<IJsonSchema>> extends JsonSchemaTypeRegistry<TypeSchema> {
500
+ /**
501
+ * 当前字段是否支持 default
502
+ */
503
+ defaultEditable?: true | string;
504
+ /**
505
+ * 自定义 disabled
506
+ */
507
+ customDisabled?: (ctx: {
508
+ level: number;
509
+ parentType: string;
510
+ parentTypes: string[];
511
+ }) => string;
512
+ /**
513
+ * typeInput 设置
514
+ */
515
+ typeInputConfig?: TypeInputConfig<TypeSchema>;
516
+ /**
517
+ * typeCascader 设置
518
+ */
519
+ typeCascaderConfig?: TypeCascaderConfig<TypeSchema>;
520
+ /**
521
+ * 从默认值上下文
522
+ */
523
+ formatDefault?: (val: any, type: IJsonSchema) => IJsonSchema;
524
+ /**
525
+ *
526
+ */
527
+ deFormatDefault?: (val: any) => any;
528
+ /**
529
+ * 子字段是否可以编辑 default
530
+ */
531
+ childrenDefaultEditable?: (type: TypeSchema) => true | string;
532
+ /**
533
+ * 子字段是否可以编辑 default
534
+ */
535
+ childrenValueEditable?: (type: TypeSchema) => true | string;
536
+ getInputNode?: (ctx: TypeInputContext<TypeSchema>) => JSX.Element;
537
+ /**
538
+ * 自定义生成子类型的 optionValue
539
+ */
540
+ customChildOptionValue?: () => string[];
541
+ /**
542
+ * @deprecated api 已废弃,能力仍保留,请优先使用或定义 getSupportedItemTypes
543
+ */
544
+ getItemTypes?: (ctx: {
545
+ level: number;
546
+ parentTypes?: string[];
547
+ }) => Array<{
548
+ type: string;
549
+ disabled?: string;
550
+ }>;
551
+ }
552
+
553
+ /**
554
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
555
+ * SPDX-License-Identifier: MIT
556
+ */
557
+ declare const columnConfigs: TypeEditorColumnConfig<_flowgram_ai_json_schema.IJsonSchema<string>>[];
558
+
559
+ /**
560
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
561
+ * SPDX-License-Identifier: MIT
562
+ */
563
+
564
+ type TypeEditorMode = 'type-definition' | 'declare-assign';
565
+ interface DeclareAssignValueType<TypeSchema extends Partial<IJsonSchema>> {
566
+ data: any;
567
+ definition: {
568
+ schema: TypeSchema;
569
+ };
570
+ }
571
+ type TypeEditorValue<Mode extends TypeEditorMode, TypeSchema extends Partial<IJsonSchema>> = Mode extends 'type-definition' ? TypeEditorSchema<TypeSchema> : DeclareAssignValueType<TypeSchema>;
572
+ declare enum ToolbarKey {
573
+ Import = "Import",
574
+ UndoRedo = "UndoRedo"
575
+ }
576
+ type ToolbarConfig = {
577
+ /**
578
+ * 工具栏配置
579
+ */
580
+ type: ToolbarKey;
581
+ /**
582
+ * 是否禁用
583
+ */
584
+ disabled?: string;
585
+ /**
586
+ * 自定义输入渲染,仅 Import 使用
587
+ */
588
+ customInputRender?: FC<{
589
+ value: string;
590
+ onChange: (newVal: string) => void;
591
+ }>;
592
+ };
593
+ interface TypeEditorProp<Mode extends TypeEditorMode, TypeSchema extends Partial<IJsonSchema>> {
594
+ /**
595
+ * 菜单栏配置
596
+ */
597
+ toolbarConfig?: (ToolbarKey | ToolbarConfig)[];
598
+ /**
599
+ * type editor 模式类型
600
+ */
601
+ mode: Mode;
602
+ /**
603
+ * 只读态
604
+ */
605
+ readonly?: boolean;
606
+ /**
607
+ *
608
+ */
609
+ tableClassName?: string;
610
+ /**
611
+ * 各个 cell 的特化配置
612
+ */
613
+ extraConfig?: TypeEditorSpecialConfig<TypeSchema>;
614
+ /**
615
+ * 根节点层级
616
+ */
617
+ rootLevel?: number;
618
+ /**
619
+ * 获取全局 add 的 root schema
620
+ */
621
+ getRootSchema?: (schema: TypeSchema) => TypeSchema;
622
+ /**
623
+ *
624
+ */
625
+ typeRegistryCreators?: TypeRegistryCreatorsAdapter<IJsonSchema>[];
626
+ /**
627
+ * 每个列的配置
628
+ */
629
+ viewConfigs: (TypeEditorColumnViewConfig & {
630
+ config?: Partial<Omit<TypeEditorColumnConfig<TypeSchema>, 'type'>>;
631
+ })[];
632
+ /**
633
+ * 每次设置 DataSource 前调用,最后修改值的钩子
634
+ */
635
+ onEditRowDataSource?: (data: TypeEditorRowData<TypeSchema>[]) => TypeEditorRowData<TypeSchema>[];
636
+ /**
637
+ * 忽略报错强制更新
638
+ */
639
+ forceUpdate?: boolean;
640
+ /**
641
+ * onError
642
+ */
643
+ onError?: (msg?: string[]) => void;
644
+ /**
645
+ * value
646
+ */
647
+ value?: TypeEditorValue<Mode, TypeSchema>;
648
+ /**
649
+ * onChange
650
+ */
651
+ onChange?: (newValue: TypeEditorValue<Mode, TypeSchema>) => void;
652
+ /**
653
+ * onPaste
654
+ */
655
+ onPaste?: (typeSchema?: TypeSchema) => TypeSchema | undefined;
656
+ /**
657
+ * onInit
658
+ */
659
+ onInit?: (editor: React.MutableRefObject<TypeEditorRef<Mode, TypeSchema> | undefined>) => void;
660
+ /**
661
+ * 当具体某个 field change
662
+ */
663
+ onFieldChange?: (ctx: TypeChangeContext) => void;
664
+ /**
665
+ * 当执行 setValue
666
+ */
667
+ onCustomSetValue?: (newValue: TypeEditorValue<Mode, TypeSchema>) => TypeEditorValue<Mode, TypeSchema>;
668
+ /**
669
+ * 自定义空状态
670
+ */
671
+ customEmptyNode?: React.ReactElement;
672
+ /**
673
+ * 不能编辑的列
674
+ * 和 TypeSchema 中 editable 的关系
675
+ * editable 为 false,会将 disableEditColumn 每个 column 都填上
676
+ */
677
+ disableEditColumn?: Array<{
678
+ column: TypeEditorColumnType;
679
+ reason: string;
680
+ }>;
681
+ }
682
+ interface TypeEditorRef<Mode extends TypeEditorMode, TypeSchema extends Partial<IJsonSchema>> {
683
+ setValue: (newVal: TypeEditorValue<Mode, TypeSchema>) => void;
684
+ getValue: () => TypeEditorValue<Mode, TypeSchema> | undefined;
685
+ undo: () => void;
686
+ redo: () => void;
687
+ getService: () => TypeEditorService<TypeSchema> | undefined;
688
+ getOperator: () => TypeEditorOperationService<TypeSchema> | undefined;
689
+ getContainer: () => HTMLDivElement | undefined;
690
+ }
691
+ interface ModeValueConfig<Mode extends TypeEditorMode, TypeSchema extends Partial<IJsonSchema>> {
692
+ mode: Mode;
693
+ /**
694
+ * 提交值到 typeSchema
695
+ */
696
+ convertValueToSchema: (val: TypeEditorValue<Mode, TypeSchema>) => TypeSchema;
697
+ /**
698
+ * typeSchema 到提交值
699
+ */
700
+ convertSchemaToValue: (val: TypeSchema) => TypeEditorValue<Mode, TypeSchema>;
701
+ /**
702
+ * 常量值生成提交值
703
+ */
704
+ commonValueToSubmitValue: (val: Record<string, unknown> | undefined) => TypeEditorValue<Mode, TypeSchema>;
705
+ toolConfig: {
706
+ createByData: {
707
+ viewConfig: TypeEditorColumnViewConfig[];
708
+ genDefaultValue: () => TypeEditorValue<Mode, TypeSchema>;
709
+ };
710
+ };
711
+ }
712
+
713
+ /**
714
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
715
+ * SPDX-License-Identifier: MIT
716
+ */
717
+
718
+ declare const TypeEditor: <Mode extends TypeEditorMode, TypeSchema extends Partial<IJsonSchema>>(props: TypeEditorProp<Mode, TypeSchema> & React.RefAttributes<TypeEditorRef<Mode, TypeSchema>>) => JSX.Element;
719
+
720
+ /**
721
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
722
+ * SPDX-License-Identifier: MIT
723
+ */
724
+
725
+ interface Props<TypeSchema extends Partial<IJsonSchema>> extends Omit<CascaderProps, 'value' | 'onChange' | 'triggerRender'> {
726
+ /**
727
+ *
728
+ */
729
+ value?: TypeSchema;
730
+ /**
731
+ * 禁用类型
732
+ */
733
+ disableTypes?: Array<DisableTypeInfo>;
734
+ onChange?: (val: TypeSchema | undefined, ctx: {
735
+ source: 'type-selector' | 'custom-panel';
736
+ }) => void;
737
+ triggerRender?: () => JSX.Element;
738
+ /**
739
+ *
740
+ */
741
+ typeRegistryCreators?: TypeRegistryCreatorsAdapter<TypeSchema>[];
742
+ }
743
+
744
+ /**
745
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
746
+ * SPDX-License-Identifier: MIT
747
+ */
748
+
749
+ declare const TypeSelector: <TypeSchema extends Partial<IJsonSchema>>(props: Props<TypeSchema>) => React.JSX.Element;
750
+
751
+ /**
752
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
753
+ * SPDX-License-Identifier: MIT
754
+ */
755
+
756
+ interface PropsType {
757
+ value?: IJsonSchema;
758
+ onChange?: (value?: IJsonSchema) => void;
759
+ readonly?: boolean;
760
+ config?: {
761
+ rootKey?: string;
762
+ viewConfigs?: TypeEditorColumnViewConfig[];
763
+ };
764
+ }
765
+ declare function ObjectTypeEditor(props: PropsType): React.JSX.Element;
766
+
767
+ export { type DeclareAssignValueType, type DisableTypeInfo, type EditorProps, type FlowSchemaInitCtx, type InfoContext, type ModeValueConfig, ObjectTypeEditor, type RenderProps, type ShortcutContext, type ToolbarConfig, ToolbarKey, type TypeCascaderConfig, type TypeChangeContext, TypeEditor, type TypeEditorColumnConfig, columnConfigs as TypeEditorColumnConfigs, TypeEditorColumnType, type TypeEditorColumnViewConfig, TypeEditorContext, type TypeEditorDropInfo, type TypeEditorExtraInfo, type TypeEditorMode, type TypeEditorPos, type TypeEditorProp, type TypeEditorRef, type TypeEditorRegistry, TypeEditorRegistryManager, type TypeEditorRowData, type TypeEditorSchema, TypeEditorService, type TypeEditorSpecialConfig, type TypeEditorValue, type TypeInputConfig, type TypeInputContext, TypeSelector, columnConfigs as typeEditorColumnConfigs };