@flowgram.ai/form-materials 0.2.28 → 0.2.30

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.
package/dist/index.d.ts DELETED
@@ -1,540 +0,0 @@
1
- import React$1 from 'react';
2
- import { TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
3
- import { InferValues } from '@coze-editor/editor/react';
4
- import preset from '@coze-editor/editor/preset-code';
5
- import { EffectOptions, ASTNodeJSON, ASTNode, BaseType, FormPluginCreator } from '@flowgram.ai/editor';
6
- import * as _flowgram_ai_node from '@flowgram.ai/node';
7
- import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
8
-
9
- /**
10
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
11
- * SPDX-License-Identifier: MIT
12
- */
13
- type JsonSchemaBasicType = 'boolean' | 'string' | 'integer' | 'number' | 'object' | 'array' | 'map';
14
- interface IJsonSchema<T = string> {
15
- type?: T;
16
- default?: any;
17
- title?: string;
18
- description?: string;
19
- enum?: (string | number)[];
20
- properties?: Record<string, IJsonSchema<T>>;
21
- additionalProperties?: IJsonSchema<T>;
22
- items?: IJsonSchema<T>;
23
- required?: string[];
24
- $ref?: string;
25
- extra?: {
26
- index?: number;
27
- weak?: boolean;
28
- formComponent?: string;
29
- [key: string]: any;
30
- };
31
- }
32
- type IBasicJsonSchema = IJsonSchema<JsonSchemaBasicType>;
33
-
34
- /**
35
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
36
- * SPDX-License-Identifier: MIT
37
- */
38
-
39
- declare function useVariableTree(params: {
40
- includeSchema?: IJsonSchema | IJsonSchema[];
41
- excludeSchema?: IJsonSchema | IJsonSchema[];
42
- }): TreeNodeData[];
43
-
44
- /**
45
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
46
- * SPDX-License-Identifier: MIT
47
- */
48
-
49
- interface PropTypes$2 {
50
- value?: string[];
51
- config?: {
52
- placeholder?: string;
53
- notFoundContent?: string;
54
- };
55
- onChange: (value?: string[]) => void;
56
- includeSchema?: IJsonSchema | IJsonSchema[];
57
- excludeSchema?: IJsonSchema | IJsonSchema[];
58
- readonly?: boolean;
59
- hasError?: boolean;
60
- style?: React$1.CSSProperties;
61
- triggerRender?: (props: TriggerRenderProps) => React$1.ReactNode;
62
- }
63
- type VariableSelectorProps = PropTypes$2;
64
-
65
- declare const VariableSelector: ({ value, config, onChange, style, readonly, includeSchema, excludeSchema, hasError, triggerRender, }: PropTypes$2) => React$1.JSX.Element;
66
-
67
- /**
68
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
69
- * SPDX-License-Identifier: MIT
70
- */
71
-
72
- interface IFlowConstantValue {
73
- type: 'constant';
74
- content?: string | number | boolean;
75
- schema?: IJsonSchema;
76
- }
77
- interface IFlowRefValue {
78
- type: 'ref';
79
- content?: string[];
80
- }
81
- interface IFlowExpressionValue {
82
- type: 'expression';
83
- content?: string;
84
- }
85
- interface IFlowTemplateValue {
86
- type: 'template';
87
- content?: string;
88
- }
89
- type IFlowValue = IFlowConstantValue | IFlowRefValue | IFlowExpressionValue | IFlowTemplateValue;
90
- type IFlowConstantRefValue = IFlowConstantValue | IFlowRefValue;
91
-
92
- /**
93
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
94
- * SPDX-License-Identifier: MIT
95
- */
96
-
97
- declare const VariableTypeIcons: {
98
- [key: string]: React$1.ReactNode;
99
- };
100
- declare const ArrayIcons: {
101
- [key: string]: React$1.ReactNode;
102
- };
103
- declare const getSchemaIcon: (value?: Partial<IJsonSchema>) => React$1.ReactNode;
104
-
105
- /**
106
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
107
- * SPDX-License-Identifier: MIT
108
- */
109
-
110
- interface PropTypes$1 {
111
- value?: Partial<IJsonSchema>;
112
- onChange?: (value?: Partial<IJsonSchema>) => void;
113
- readonly?: boolean;
114
- /**
115
- * @deprecated use readonly instead
116
- */
117
- disabled?: boolean;
118
- style?: React$1.CSSProperties;
119
- }
120
- declare const getTypeSelectValue: (value?: Partial<IJsonSchema>) => string[] | undefined;
121
- declare const parseTypeSelectValue: (value?: string[]) => Partial<IJsonSchema> | undefined;
122
- declare function TypeSelector(props: PropTypes$1): React$1.JSX.Element;
123
-
124
- /**
125
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
126
- * SPDX-License-Identifier: MIT
127
- */
128
-
129
- interface ConfigType {
130
- placeholder?: string;
131
- descTitle?: string;
132
- descPlaceholder?: string;
133
- defaultValueTitle?: string;
134
- defaultValuePlaceholder?: string;
135
- addButtonText?: string;
136
- jsonFormatText?: string;
137
- }
138
-
139
- /**
140
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
141
- * SPDX-License-Identifier: MIT
142
- */
143
-
144
- declare function JsonSchemaEditor(props: {
145
- value?: IJsonSchema;
146
- onChange?: (value: IJsonSchema) => void;
147
- config?: ConfigType;
148
- className?: string;
149
- readonly?: boolean;
150
- }): React$1.JSX.Element;
151
-
152
- /**
153
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
154
- * SPDX-License-Identifier: MIT
155
- */
156
-
157
- declare function BatchVariableSelector(props: VariableSelectorProps): React$1.JSX.Element;
158
-
159
- /**
160
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
161
- * SPDX-License-Identifier: MIT
162
- */
163
-
164
- interface Strategy<Value = any> {
165
- hit: (schema: IJsonSchema) => boolean;
166
- Renderer: React.FC<RendererProps<Value>>;
167
- }
168
- interface RendererProps<Value = any> {
169
- value?: Value;
170
- onChange?: (value: Value) => void;
171
- readonly?: boolean;
172
- }
173
- interface PropsType$5 extends RendererProps {
174
- schema: IJsonSchema;
175
- strategies?: Strategy[];
176
- fallbackRenderer?: React.FC<RendererProps>;
177
- [key: string]: any;
178
- }
179
-
180
- /**
181
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
182
- * SPDX-License-Identifier: MIT
183
- */
184
-
185
- declare function ConstantInput(props: PropsType$5): React$1.JSX.Element;
186
-
187
- /**
188
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
189
- * SPDX-License-Identifier: MIT
190
- */
191
-
192
- interface PropsType$4 {
193
- value?: IFlowConstantRefValue;
194
- onChange: (value?: IFlowConstantRefValue) => void;
195
- readonly?: boolean;
196
- hasError?: boolean;
197
- style?: React$1.CSSProperties;
198
- schema?: IJsonSchema;
199
- constantProps?: {
200
- strategies?: Strategy[];
201
- schema?: IJsonSchema;
202
- [key: string]: any;
203
- };
204
- }
205
- declare function DynamicValueInput({ value, onChange, readonly, style, schema: schemaFromProps, constantProps, }: PropsType$4): React$1.JSX.Element;
206
-
207
- /**
208
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
209
- * SPDX-License-Identifier: MIT
210
- */
211
-
212
- declare enum Op {
213
- EQ = "eq",
214
- NEQ = "neq",
215
- GT = "gt",
216
- GTE = "gte",
217
- LT = "lt",
218
- LTE = "lte",
219
- IN = "in",
220
- NIN = "nin",
221
- CONTAINS = "contains",
222
- NOT_CONTAINS = "not_contains",
223
- IS_EMPTY = "is_empty",
224
- IS_NOT_EMPTY = "is_not_empty",
225
- IS_TRUE = "is_true",
226
- IS_FALSE = "is_false"
227
- }
228
- interface ConditionRowValueType {
229
- left?: IFlowRefValue;
230
- operator?: Op;
231
- right?: IFlowConstantRefValue;
232
- }
233
-
234
- /**
235
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
236
- * SPDX-License-Identifier: MIT
237
- */
238
-
239
- interface PropTypes {
240
- value?: ConditionRowValueType;
241
- onChange: (value?: ConditionRowValueType) => void;
242
- style?: React$1.CSSProperties;
243
- readonly?: boolean;
244
- }
245
- declare function ConditionRow({ style, value, onChange, readonly }: PropTypes): React$1.JSX.Element;
246
-
247
- /**
248
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
249
- * SPDX-License-Identifier: MIT
250
- */
251
-
252
- type ValueType = Record<string, IFlowRefValue | undefined>;
253
- interface PropsType$3 {
254
- value?: ValueType;
255
- onChange: (value?: ValueType) => void;
256
- readonly?: boolean;
257
- hasError?: boolean;
258
- style?: React.CSSProperties;
259
- }
260
-
261
- /**
262
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
263
- * SPDX-License-Identifier: MIT
264
- */
265
-
266
- declare function BatchOutputs(props: PropsType$3): React$1.JSX.Element;
267
-
268
- /**
269
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
270
- * SPDX-License-Identifier: MIT
271
- */
272
-
273
- type PropsType$2 = React$1.PropsWithChildren<{
274
- value?: IFlowTemplateValue;
275
- onChange: (value?: IFlowTemplateValue) => void;
276
- readonly?: boolean;
277
- hasError?: boolean;
278
- placeholder?: string;
279
- activeLinePlaceholder?: string;
280
- disableMarkdownHighlight?: boolean;
281
- style?: React$1.CSSProperties;
282
- }>;
283
-
284
- /**
285
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
286
- * SPDX-License-Identifier: MIT
287
- */
288
-
289
- type PromptEditorPropsType = PropsType$2;
290
- declare function PromptEditor(props: PropsType$2): React$1.JSX.Element;
291
-
292
- /**
293
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
294
- * SPDX-License-Identifier: MIT
295
- */
296
-
297
- declare function PromptEditorWithVariables(props: PromptEditorPropsType): React$1.JSX.Element;
298
-
299
- /**
300
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
301
- * SPDX-License-Identifier: MIT
302
- */
303
-
304
- interface PropsType$1 extends PromptEditorPropsType {
305
- inputsValues: Record<string, IFlowValue>;
306
- }
307
- declare function PromptEditorWithInputs({ inputsValues, ...restProps }: PropsType$1): React$1.JSX.Element;
308
-
309
- /**
310
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
311
- * SPDX-License-Identifier: MIT
312
- */
313
-
314
- type Preset = typeof preset;
315
- type Options = Partial<InferValues<Preset[number]>>;
316
- interface CodeEditorPropsType extends React$1.PropsWithChildren<{}> {
317
- value?: string;
318
- onChange?: (value: string) => void;
319
- languageId: 'python' | 'typescript' | 'shell' | 'json';
320
- theme?: 'dark' | 'light';
321
- placeholder?: string;
322
- activeLinePlaceholder?: string;
323
- readonly?: boolean;
324
- options?: Options;
325
- }
326
- declare function CodeEditor({ value, onChange, languageId, theme, children, placeholder, activeLinePlaceholder, options, readonly, }: CodeEditorPropsType): React$1.JSX.Element;
327
-
328
- /**
329
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
330
- * SPDX-License-Identifier: MIT
331
- */
332
-
333
- declare function JsonEditorWithVariables(props: Omit<CodeEditorPropsType, 'languageId'>): React$1.JSX.Element;
334
-
335
- /**
336
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
337
- * SPDX-License-Identifier: MIT
338
- */
339
-
340
- interface PropsType {
341
- value?: Record<string, IFlowValue | undefined>;
342
- onChange: (value?: Record<string, IFlowValue | undefined>) => void;
343
- readonly?: boolean;
344
- hasError?: boolean;
345
- style?: React.CSSProperties;
346
- constantProps?: {
347
- strategies?: Strategy[];
348
- [key: string]: any;
349
- };
350
- }
351
-
352
- /**
353
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
354
- * SPDX-License-Identifier: MIT
355
- */
356
-
357
- declare function InputsValues({ value, onChange, style, readonly, constantProps }: PropsType): React$1.JSX.Element;
358
-
359
- /**
360
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
361
- * SPDX-License-Identifier: MIT
362
- */
363
-
364
- declare const provideBatchInputEffect: EffectOptions[];
365
-
366
- /**
367
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
368
- * SPDX-License-Identifier: MIT
369
- */
370
-
371
- /**
372
- * Auto rename ref when form item's key is renamed
373
- *
374
- * Example:
375
- *
376
- * formMeta: {
377
- * effects: {
378
- * "inputsValues": autoRenameRefEffect,
379
- * }
380
- * }
381
- */
382
- declare const autoRenameRefEffect: EffectOptions[];
383
-
384
- /**
385
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
386
- * SPDX-License-Identifier: MIT
387
- */
388
-
389
- declare const provideJsonSchemaOutputs: EffectOptions[];
390
-
391
- /**
392
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
393
- * SPDX-License-Identifier: MIT
394
- */
395
-
396
- declare const syncVariableTitle: EffectOptions[];
397
-
398
- /**
399
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
400
- * SPDX-License-Identifier: MIT
401
- */
402
- interface LegacyFlowRefValueSchema {
403
- type: 'ref';
404
- content: string;
405
- }
406
- interface NewFlowRefValueSchema {
407
- type: 'ref';
408
- content: string[];
409
- }
410
- /**
411
- * In flowgram 0.2.0, for introducing Loop variable functionality,
412
- * the FlowRefValueSchema type definition is updated:
413
- *
414
- * interface LegacyFlowRefValueSchema {
415
- * type: 'ref';
416
- * content: string;
417
- * }
418
- *
419
- * interface NewFlowRefValueSchema {
420
- * type: 'ref';
421
- * content: string[];
422
- * }
423
- *
424
- *
425
- * For making sure backend json will not be changed, we provide format legacy ref utils for updating the formData
426
- *
427
- * How to use:
428
- *
429
- * 1. Call formatLegacyRefOnSubmit on the formData before submitting
430
- * 2. Call formatLegacyRefOnInit on the formData after submitting
431
- *
432
- * Example:
433
- * import { formatLegacyRefOnSubmit, formatLegacyRefOnInit } from '@flowgram.ai/form-materials';
434
- * formMeta: {
435
- * formatOnSubmit: (data) => formatLegacyRefOnSubmit(data),
436
- * formatOnInit: (data) => formatLegacyRefOnInit(data),
437
- * }
438
- */
439
- declare function formatLegacyRefOnSubmit(value: any): any;
440
- /**
441
- * In flowgram 0.2.0, for introducing Loop variable functionality,
442
- * the FlowRefValueSchema type definition is updated:
443
- *
444
- * interface LegacyFlowRefValueSchema {
445
- * type: 'ref';
446
- * content: string;
447
- * }
448
- *
449
- * interface NewFlowRefValueSchema {
450
- * type: 'ref';
451
- * content: string[];
452
- * }
453
- *
454
- *
455
- * For making sure backend json will not be changed, we provide format legacy ref utils for updating the formData
456
- *
457
- * How to use:
458
- *
459
- * 1. Call formatLegacyRefOnSubmit on the formData before submitting
460
- * 2. Call formatLegacyRefOnInit on the formData after submitting
461
- *
462
- * Example:
463
- * import { formatLegacyRefOnSubmit, formatLegacyRefOnInit } from '@flowgram.ai/form-materials';
464
- *
465
- * formMeta: {
466
- * formatOnSubmit: (data) => formatLegacyRefOnSubmit(data),
467
- * formatOnInit: (data) => formatLegacyRefOnInit(data),
468
- * }
469
- */
470
- declare function formatLegacyRefOnInit(value: any): any;
471
- declare function isLegacyFlowRefValueSchema(value: any): value is LegacyFlowRefValueSchema;
472
- declare function isNewFlowRefValueSchema(value: any): value is NewFlowRefValueSchema;
473
- declare function formatLegacyRefToNewRef(value: LegacyFlowRefValueSchema): {
474
- type: string;
475
- content: string[];
476
- };
477
- declare function formatNewRefToLegacyRef(value: NewFlowRefValueSchema): {
478
- type: string;
479
- content: string;
480
- };
481
-
482
- /**
483
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
484
- * SPDX-License-Identifier: MIT
485
- */
486
-
487
- declare namespace JsonSchemaUtils {
488
- /**
489
- * Converts a JSON schema to an Abstract Syntax Tree (AST) representation.
490
- * This function recursively processes the JSON schema and creates corresponding AST nodes.
491
- *
492
- * For more information on JSON Schema, refer to the official documentation:
493
- * https://json-schema.org/
494
- *
495
- * @param jsonSchema - The JSON schema to convert.
496
- * @returns An AST node representing the JSON schema, or undefined if the schema type is not recognized.
497
- */
498
- function schemaToAST(jsonSchema: IJsonSchema): ASTNodeJSON | undefined;
499
- /**
500
- * Convert AST To JSON Schema
501
- * @param typeAST
502
- * @returns
503
- */
504
- function astToSchema(typeAST: ASTNode, options?: {
505
- drilldown?: boolean;
506
- }): IJsonSchema | undefined;
507
- /**
508
- * Check if the AST type is match the JSON Schema
509
- * @param typeAST
510
- * @param schema
511
- * @returns
512
- */
513
- function isASTMatchSchema(typeAST: BaseType, schema: IJsonSchema | IJsonSchema[]): boolean;
514
- }
515
-
516
- /**
517
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
518
- * SPDX-License-Identifier: MIT
519
- */
520
-
521
- declare const provideBatchOutputsEffect: EffectOptions[];
522
- /**
523
- * Free Layout only right now
524
- */
525
- declare const createBatchOutputsFormPlugin: FormPluginCreator<{
526
- outputKey: string;
527
- }>;
528
-
529
- /**
530
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
531
- * SPDX-License-Identifier: MIT
532
- */
533
- interface InputConfig {
534
- sourceKey: string;
535
- targetKey: string;
536
- scope?: 'private' | 'public';
537
- }
538
- declare const createInferInputsPlugin: _flowgram_ai_node.FormPluginCreator<InputConfig>;
539
-
540
- export { ArrayIcons, BatchOutputs, BatchVariableSelector, CodeEditor, type CodeEditorPropsType, ConditionRow, type ConditionRowValueType, ConstantInput, DynamicValueInput, type IBasicJsonSchema, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type IJsonSchema, InputsValues, JsonEditorWithVariables, type JsonSchemaBasicType, JsonSchemaEditor, JsonSchemaUtils, PromptEditor, type PromptEditorPropsType, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, type VariableSelectorProps, VariableTypeIcons, autoRenameRefEffect, createBatchOutputsFormPlugin, createInferInputsPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getSchemaIcon, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, useVariableTree };