@flowgram.ai/form-materials 0.1.30 → 0.2.0
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/bin/materials.js +21 -5
- package/dist/esm/index.js +463 -57
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +171 -28
- package/dist/index.d.ts +171 -28
- package/dist/index.js +472 -60
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/components/batch-variable-selector/config.json +5 -0
- package/src/components/batch-variable-selector/index.tsx +18 -0
- package/src/components/constant-input/config.json +6 -0
- package/src/components/constant-input/index.tsx +81 -0
- package/src/components/constant-input/types.ts +18 -0
- package/src/components/dynamic-value-input/config.json +5 -0
- package/src/components/dynamic-value-input/index.tsx +77 -0
- package/src/components/dynamic-value-input/styles.tsx +19 -0
- package/src/components/index.ts +6 -3
- package/src/components/json-schema-editor/hooks.tsx +33 -22
- package/src/components/json-schema-editor/index.tsx +11 -7
- package/src/components/json-schema-editor/types.ts +7 -0
- package/src/components/type-selector/index.tsx +5 -2
- package/src/components/type-selector/types.ts +4 -18
- package/src/components/variable-selector/config.json +1 -1
- package/src/components/variable-selector/index.tsx +80 -16
- package/src/components/variable-selector/styles.tsx +43 -0
- package/src/components/variable-selector/use-variable-tree.tsx +29 -7
- package/src/effects/index.ts +2 -0
- package/src/effects/provide-batch-input/config.json +5 -0
- package/src/effects/provide-batch-input/index.ts +38 -0
- package/src/effects/provide-batch-outputs/config.json +5 -0
- package/src/effects/provide-batch-outputs/index.ts +34 -0
- package/src/index.ts +3 -0
- package/src/typings/flow-value/config.json +5 -0
- package/src/typings/flow-value/index.ts +27 -0
- package/src/typings/index.ts +1 -0
- package/src/utils/format-legacy-refs/config.json +5 -0
- package/src/utils/format-legacy-refs/index.ts +153 -0
- package/src/utils/format-legacy-refs/readme.md +38 -0
- package/src/utils/index.ts +1 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,48 +1,191 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React$1 from 'react';
|
|
2
|
+
import { VarJSONSchema, EffectOptions } from '@flowgram.ai/editor';
|
|
3
|
+
import { TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
|
|
2
4
|
|
|
3
5
|
interface PropTypes$1 {
|
|
4
|
-
value?: string;
|
|
5
|
-
|
|
6
|
+
value?: string[];
|
|
7
|
+
config?: {
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
notFoundContent?: string;
|
|
10
|
+
};
|
|
11
|
+
onChange: (value?: string[]) => void;
|
|
12
|
+
includeSchema?: VarJSONSchema.ISchema | VarJSONSchema.ISchema[];
|
|
13
|
+
excludeSchema?: VarJSONSchema.ISchema | VarJSONSchema.ISchema[];
|
|
6
14
|
readonly?: boolean;
|
|
7
15
|
hasError?: boolean;
|
|
8
|
-
style?: React.CSSProperties;
|
|
9
|
-
|
|
10
|
-
declare const VariableSelector: ({ value, onChange, style, readonly, hasError, }: PropTypes$1) => React.JSX.Element;
|
|
11
|
-
|
|
12
|
-
interface JsonSchema<T = string> {
|
|
13
|
-
type?: T;
|
|
14
|
-
default?: any;
|
|
15
|
-
title?: string;
|
|
16
|
-
description?: string;
|
|
17
|
-
enum?: (string | number)[];
|
|
18
|
-
properties?: Record<string, JsonSchema>;
|
|
19
|
-
additionalProperties?: JsonSchema;
|
|
20
|
-
items?: JsonSchema;
|
|
21
|
-
required?: string[];
|
|
22
|
-
$ref?: string;
|
|
23
|
-
extra?: {
|
|
24
|
-
order?: number;
|
|
25
|
-
literal?: boolean;
|
|
26
|
-
formComponent?: string;
|
|
27
|
-
};
|
|
16
|
+
style?: React$1.CSSProperties;
|
|
17
|
+
triggerRender?: (props: TriggerRenderProps) => React$1.ReactNode;
|
|
28
18
|
}
|
|
19
|
+
type VariableSelectorProps = PropTypes$1;
|
|
20
|
+
declare const VariableSelector: ({ value, config, onChange, style, readonly, includeSchema, excludeSchema, hasError, triggerRender, }: PropTypes$1) => React$1.JSX.Element;
|
|
21
|
+
|
|
22
|
+
type JsonSchema = VarJSONSchema.ISchema;
|
|
29
23
|
|
|
30
24
|
declare const VariableTypeIcons: {
|
|
31
|
-
[key: string]: React.ReactNode;
|
|
25
|
+
[key: string]: React$1.ReactNode;
|
|
32
26
|
};
|
|
33
27
|
declare const ArrayIcons: {
|
|
34
|
-
[key: string]: React.ReactNode;
|
|
28
|
+
[key: string]: React$1.ReactNode;
|
|
35
29
|
};
|
|
30
|
+
declare const getSchemaIcon: (value?: Partial<JsonSchema>) => React$1.ReactNode;
|
|
36
31
|
|
|
37
32
|
interface PropTypes {
|
|
38
33
|
value?: Partial<JsonSchema>;
|
|
39
34
|
onChange: (value?: Partial<JsonSchema>) => void;
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
style?: React$1.CSSProperties;
|
|
37
|
+
}
|
|
38
|
+
declare const getTypeSelectValue: (value?: Partial<JsonSchema>) => string[] | undefined;
|
|
39
|
+
declare const parseTypeSelectValue: (value?: string[]) => Partial<JsonSchema> | undefined;
|
|
40
|
+
declare function TypeSelector(props: PropTypes): React$1.JSX.Element;
|
|
41
|
+
|
|
42
|
+
interface ConfigType {
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
descTitle?: string;
|
|
45
|
+
descPlaceholder?: string;
|
|
46
|
+
addButtonText?: string;
|
|
40
47
|
}
|
|
41
|
-
declare function TypeSelector(props: PropTypes): React.JSX.Element;
|
|
42
48
|
|
|
43
49
|
declare function JsonSchemaEditor(props: {
|
|
44
50
|
value?: JsonSchema;
|
|
45
51
|
onChange?: (value: JsonSchema) => void;
|
|
46
|
-
|
|
52
|
+
config?: ConfigType;
|
|
53
|
+
}): React$1.JSX.Element;
|
|
54
|
+
|
|
55
|
+
declare function BatchVariableSelector(props: VariableSelectorProps): React$1.JSX.Element;
|
|
56
|
+
|
|
57
|
+
interface Strategy<Value = any> {
|
|
58
|
+
hit: (schema: VarJSONSchema.ISchema) => boolean;
|
|
59
|
+
Renderer: React.FC<RendererProps<Value>>;
|
|
60
|
+
}
|
|
61
|
+
interface RendererProps<Value = any> {
|
|
62
|
+
value?: Value;
|
|
63
|
+
onChange?: (value: Value) => void;
|
|
64
|
+
readonly?: boolean;
|
|
65
|
+
}
|
|
66
|
+
interface PropsType$1 extends RendererProps {
|
|
67
|
+
schema: VarJSONSchema.ISchema;
|
|
68
|
+
strategies?: Strategy[];
|
|
69
|
+
[key: string]: any;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
declare function ConstantInput(props: PropsType$1): React$1.JSX.Element;
|
|
73
|
+
|
|
74
|
+
interface IFlowConstantValue {
|
|
75
|
+
type: 'constant';
|
|
76
|
+
content?: string | number | boolean;
|
|
77
|
+
}
|
|
78
|
+
interface IFlowRefValue {
|
|
79
|
+
type: 'ref';
|
|
80
|
+
content?: string[];
|
|
81
|
+
}
|
|
82
|
+
interface IFlowExpressionValue {
|
|
83
|
+
type: 'expression';
|
|
84
|
+
content?: string;
|
|
85
|
+
}
|
|
86
|
+
interface IFlowTemplateValue {
|
|
87
|
+
type: 'template';
|
|
88
|
+
content?: string;
|
|
89
|
+
}
|
|
90
|
+
type IFlowValue = IFlowConstantValue | IFlowRefValue | IFlowExpressionValue | IFlowTemplateValue;
|
|
91
|
+
type IFlowConstantRefValue = IFlowConstantValue | IFlowRefValue;
|
|
92
|
+
|
|
93
|
+
interface PropsType {
|
|
94
|
+
value?: IFlowConstantRefValue;
|
|
95
|
+
onChange: (value?: IFlowConstantRefValue) => void;
|
|
96
|
+
readonly?: boolean;
|
|
97
|
+
hasError?: boolean;
|
|
98
|
+
style?: React$1.CSSProperties;
|
|
99
|
+
schema?: VarJSONSchema.ISchema;
|
|
100
|
+
constantProps?: {
|
|
101
|
+
strategies?: Strategy[];
|
|
102
|
+
[key: string]: any;
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
declare function DynamicValueInput({ value, onChange, readonly, style, schema, constantProps, }: PropsType): React$1.JSX.Element;
|
|
106
|
+
|
|
107
|
+
declare const provideBatchInputEffect: EffectOptions[];
|
|
108
|
+
|
|
109
|
+
declare const provideBatchOutputsEffect: EffectOptions[];
|
|
110
|
+
|
|
111
|
+
interface LegacyFlowRefValueSchema {
|
|
112
|
+
type: 'ref';
|
|
113
|
+
content: string;
|
|
114
|
+
}
|
|
115
|
+
interface NewFlowRefValueSchema {
|
|
116
|
+
type: 'ref';
|
|
117
|
+
content: string[];
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* In flowgram 0.2.0, for introducing Loop variable functionality,
|
|
121
|
+
* the FlowRefValueSchema type definition is updated:
|
|
122
|
+
*
|
|
123
|
+
* interface LegacyFlowRefValueSchema {
|
|
124
|
+
* type: 'ref';
|
|
125
|
+
* content: string;
|
|
126
|
+
* }
|
|
127
|
+
*
|
|
128
|
+
* interface NewFlowRefValueSchema {
|
|
129
|
+
* type: 'ref';
|
|
130
|
+
* content: string[];
|
|
131
|
+
* }
|
|
132
|
+
*
|
|
133
|
+
*
|
|
134
|
+
* For making sure backend json will not be changed, we provide format legacy ref utils for updating the formData
|
|
135
|
+
*
|
|
136
|
+
* How to use:
|
|
137
|
+
*
|
|
138
|
+
* 1. Call formatLegacyRefOnSubmit on the formData before submitting
|
|
139
|
+
* 2. Call formatLegacyRefOnInit on the formData after submitting
|
|
140
|
+
*
|
|
141
|
+
* Example:
|
|
142
|
+
* import { formatLegacyRefOnSubmit, formatLegacyRefOnInit } from '@flowgram.ai/form-materials';
|
|
143
|
+
* formMeta: {
|
|
144
|
+
* formatOnSubmit: (data) => formatLegacyRefOnSubmit(data),
|
|
145
|
+
* formatOnInit: (data) => formatLegacyRefOnInit(data),
|
|
146
|
+
* }
|
|
147
|
+
*/
|
|
148
|
+
declare function formatLegacyRefOnSubmit(value: any): any;
|
|
149
|
+
/**
|
|
150
|
+
* In flowgram 0.2.0, for introducing Loop variable functionality,
|
|
151
|
+
* the FlowRefValueSchema type definition is updated:
|
|
152
|
+
*
|
|
153
|
+
* interface LegacyFlowRefValueSchema {
|
|
154
|
+
* type: 'ref';
|
|
155
|
+
* content: string;
|
|
156
|
+
* }
|
|
157
|
+
*
|
|
158
|
+
* interface NewFlowRefValueSchema {
|
|
159
|
+
* type: 'ref';
|
|
160
|
+
* content: string[];
|
|
161
|
+
* }
|
|
162
|
+
*
|
|
163
|
+
*
|
|
164
|
+
* For making sure backend json will not be changed, we provide format legacy ref utils for updating the formData
|
|
165
|
+
*
|
|
166
|
+
* How to use:
|
|
167
|
+
*
|
|
168
|
+
* 1. Call formatLegacyRefOnSubmit on the formData before submitting
|
|
169
|
+
* 2. Call formatLegacyRefOnInit on the formData after submitting
|
|
170
|
+
*
|
|
171
|
+
* Example:
|
|
172
|
+
* import { formatLegacyRefOnSubmit, formatLegacyRefOnInit } from '@flowgram.ai/form-materials';
|
|
173
|
+
*
|
|
174
|
+
* formMeta: {
|
|
175
|
+
* formatOnSubmit: (data) => formatLegacyRefOnSubmit(data),
|
|
176
|
+
* formatOnInit: (data) => formatLegacyRefOnInit(data),
|
|
177
|
+
* }
|
|
178
|
+
*/
|
|
179
|
+
declare function formatLegacyRefOnInit(value: any): any;
|
|
180
|
+
declare function isLegacyFlowRefValueSchema(value: any): value is LegacyFlowRefValueSchema;
|
|
181
|
+
declare function isNewFlowRefValueSchema(value: any): value is NewFlowRefValueSchema;
|
|
182
|
+
declare function formatLegacyRefToNewRef(value: LegacyFlowRefValueSchema): {
|
|
183
|
+
type: string;
|
|
184
|
+
content: string[];
|
|
185
|
+
};
|
|
186
|
+
declare function formatNewRefToLegacyRef(value: NewFlowRefValueSchema): {
|
|
187
|
+
type: string;
|
|
188
|
+
content: string;
|
|
189
|
+
};
|
|
47
190
|
|
|
48
|
-
export { ArrayIcons, type JsonSchema, JsonSchemaEditor, TypeSelector, VariableSelector, VariableTypeIcons };
|
|
191
|
+
export { ArrayIcons, BatchVariableSelector, ConstantInput, DynamicValueInput, type IFlowConstantRefValue, type IFlowConstantValue, type IFlowExpressionValue, type IFlowRefValue, type IFlowTemplateValue, type IFlowValue, type JsonSchema, JsonSchemaEditor, TypeSelector, VariableSelector, type VariableSelectorProps, VariableTypeIcons, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getSchemaIcon, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, parseTypeSelectValue, provideBatchInputEffect, provideBatchOutputsEffect };
|