@flowgram.ai/form-materials 1.0.10 → 1.0.12
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/cjs/components/code-editor/editor.js +4 -0
- package/dist/cjs/components/code-editor/styles.css +17 -1
- package/dist/cjs/components/code-editor-mini/index.js +1 -0
- package/dist/cjs/components/constant-input/index.js +4 -1
- package/dist/cjs/components/json-schema-editor/index.js +10 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +2 -2
- package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +17 -7
- package/dist/cjs/plugins/json-schema-preset/type-definition/enum.js +75 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +2 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +3 -3
- package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +3 -3
- package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +5 -5
- package/dist/esm/components/code-editor/editor.mjs +4 -0
- package/dist/esm/components/code-editor/styles.css +17 -1
- package/dist/esm/components/code-editor-mini/index.mjs +1 -0
- package/dist/esm/components/constant-input/index.mjs +4 -1
- package/dist/esm/components/json-schema-editor/index.mjs +10 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +2 -2
- package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +17 -7
- package/dist/esm/plugins/json-schema-preset/type-definition/enum.mjs +41 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +2 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +3 -3
- package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +3 -3
- package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +5 -5
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/enum.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/types.d.ts +6 -1
- package/package.json +6 -6
- package/src/components/code-editor/editor.tsx +3 -0
- package/src/components/code-editor/styles.css +16 -1
- package/src/components/code-editor-mini/index.tsx +1 -0
- package/src/components/constant-input/index.tsx +5 -3
- package/src/components/json-schema-editor/index.tsx +20 -2
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +2 -3
- package/src/plugins/json-schema-preset/type-definition/date-time.tsx +40 -16
- package/src/plugins/json-schema-preset/type-definition/enum.tsx +46 -0
- package/src/plugins/json-schema-preset/type-definition/index.tsx +2 -0
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +3 -4
- package/src/plugins/json-schema-preset/type-definition/number.tsx +3 -4
- package/src/plugins/json-schema-preset/type-definition/string.tsx +6 -7
- package/src/plugins/json-schema-preset/types.ts +10 -1
|
@@ -50,6 +50,9 @@ const OriginCodeEditor = (0, react_namespaceObject.createRenderer)(preset_code_d
|
|
|
50
50
|
}
|
|
51
51
|
})
|
|
52
52
|
]);
|
|
53
|
+
const MINI_EXTENSIONS = [
|
|
54
|
+
view_namespaceObject.EditorView.lineWrapping
|
|
55
|
+
];
|
|
53
56
|
function BaseCodeEditor({ value, onChange, languageId = 'python', theme = 'light', children, placeholder, activeLinePlaceholder, options, readonly, mini }) {
|
|
54
57
|
const editorRef = (0, external_react_namespaceObject.useRef)(null);
|
|
55
58
|
const editorValue = String(value || '');
|
|
@@ -72,6 +75,7 @@ function BaseCodeEditor({ value, onChange, languageId = 'python', theme = 'light
|
|
|
72
75
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.EditorProvider, {
|
|
73
76
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(OriginCodeEditor, {
|
|
74
77
|
defaultValue: editorValue,
|
|
78
|
+
extensions: mini ? MINI_EXTENSIONS : void 0,
|
|
75
79
|
options: {
|
|
76
80
|
uri: `file:///untitled${(0, external_utils_js_namespaceObject.getSuffixByLanguageId)(languageId)}`,
|
|
77
81
|
languageId,
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
.gedit-m-code-editor-container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
min-width: 0;
|
|
4
|
+
max-width: 100%;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
}
|
|
7
|
+
|
|
1
8
|
.gedit-m-code-editor-container.mini {
|
|
2
|
-
height: 24px;
|
|
9
|
+
min-height: 24px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.gedit-m-code-editor-container.mini .cm-editor, .gedit-m-code-editor-container.mini .cm-scroller, .gedit-m-code-editor-container.mini .cm-content {
|
|
13
|
+
min-width: 0;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.gedit-m-code-editor-container.mini .cm-scroller {
|
|
18
|
+
overflow-x: hidden;
|
|
3
19
|
}
|
|
4
20
|
|
|
@@ -34,6 +34,7 @@ function CodeEditorMini(props) {
|
|
|
34
34
|
className: "gedit-m-code-editor-mini",
|
|
35
35
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.CodeEditor, {
|
|
36
36
|
...props,
|
|
37
|
+
mini: true,
|
|
37
38
|
options: {
|
|
38
39
|
lineNumbersGutter: false,
|
|
39
40
|
foldGutter: false,
|
|
@@ -49,13 +49,15 @@ function ConstantInput(props) {
|
|
|
49
49
|
return strategy?.Renderer;
|
|
50
50
|
}, [
|
|
51
51
|
strategies,
|
|
52
|
-
schema
|
|
52
|
+
schema,
|
|
53
|
+
typeManager
|
|
53
54
|
]);
|
|
54
55
|
if (!Renderer) {
|
|
55
56
|
if (fallbackRenderer) return /*#__PURE__*/ external_react_default().createElement(fallbackRenderer, {
|
|
56
57
|
value,
|
|
57
58
|
onChange,
|
|
58
59
|
readonly,
|
|
60
|
+
schema,
|
|
59
61
|
...rest
|
|
60
62
|
});
|
|
61
63
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Input, {
|
|
@@ -68,6 +70,7 @@ function ConstantInput(props) {
|
|
|
68
70
|
value: value,
|
|
69
71
|
onChange: onChange,
|
|
70
72
|
readonly: readonly,
|
|
73
|
+
schema: schema,
|
|
71
74
|
...rest
|
|
72
75
|
});
|
|
73
76
|
}
|
|
@@ -28,6 +28,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
28
28
|
});
|
|
29
29
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
30
|
const external_react_namespaceObject = require("react");
|
|
31
|
+
const json_schema_namespaceObject = require("@flowgram.ai/json-schema");
|
|
31
32
|
const editor_namespaceObject = require("@flowgram.ai/editor");
|
|
32
33
|
const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
33
34
|
const semi_icons_namespaceObject = require("@douyinfe/semi-icons");
|
|
@@ -40,6 +41,11 @@ require("./styles.css");
|
|
|
40
41
|
const DEFAULT = {
|
|
41
42
|
type: 'object'
|
|
42
43
|
};
|
|
44
|
+
function getSchemaDefaultValue(typeManager, schema) {
|
|
45
|
+
if (schema?.type === 'object') return '{}';
|
|
46
|
+
if (schema?.type === 'array') return '[]';
|
|
47
|
+
return typeManager.getDefaultValue(schema || {});
|
|
48
|
+
}
|
|
43
49
|
function JsonSchemaEditor(props) {
|
|
44
50
|
const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
|
|
45
51
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = (0, external_hooks_js_namespaceObject.usePropertiesEdit)(value, onChangeProps);
|
|
@@ -78,6 +84,7 @@ function PropertyEdit(props) {
|
|
|
78
84
|
const { value, config, readonly, $level = 0, onChange: onChangeProps, onRemove, $isLast } = props;
|
|
79
85
|
const [expand, setExpand] = (0, external_react_namespaceObject.useState)(false);
|
|
80
86
|
const [collapse, setCollapse] = (0, external_react_namespaceObject.useState)(false);
|
|
87
|
+
const typeManager = (0, json_schema_namespaceObject.useTypeManager)();
|
|
81
88
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
82
89
|
const typeSelectorValue = (0, external_react_namespaceObject.useMemo)(()=>({
|
|
83
90
|
type,
|
|
@@ -133,9 +140,11 @@ function PropertyEdit(props) {
|
|
|
133
140
|
value: typeSelectorValue,
|
|
134
141
|
readonly: readonly,
|
|
135
142
|
onChange: (_value)=>{
|
|
143
|
+
const nextTypeSchema = _value || {};
|
|
136
144
|
onChangeProps?.({
|
|
137
145
|
...value || {},
|
|
138
|
-
...
|
|
146
|
+
...nextTypeSchema,
|
|
147
|
+
default: getSchemaDefaultValue(typeManager, nextTypeSchema)
|
|
139
148
|
});
|
|
140
149
|
}
|
|
141
150
|
})
|
|
@@ -34,11 +34,11 @@ const op_js_namespaceObject = require("../../../components/condition-context/op.
|
|
|
34
34
|
const booleanRegistry = {
|
|
35
35
|
type: 'boolean',
|
|
36
36
|
ConstantRenderer: (props)=>{
|
|
37
|
-
const { value, onChange, ...rest } = props;
|
|
37
|
+
const { value, onChange, readonly, schema, ...rest } = props;
|
|
38
38
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Select, {
|
|
39
39
|
placeholder: editor_namespaceObject.I18n.t('Please Select Boolean'),
|
|
40
40
|
size: "small",
|
|
41
|
-
disabled:
|
|
41
|
+
disabled: readonly,
|
|
42
42
|
optionList: [
|
|
43
43
|
{
|
|
44
44
|
label: editor_namespaceObject.I18n.t('True'),
|
|
@@ -31,24 +31,34 @@ require("react");
|
|
|
31
31
|
const external_date_fns_namespaceObject = require("date-fns");
|
|
32
32
|
const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
33
33
|
const op_js_namespaceObject = require("../../../components/condition-context/op.js");
|
|
34
|
+
const DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
|
35
|
+
const stringifyDateTime = (value)=>{
|
|
36
|
+
if (null == value || '' === value) return '';
|
|
37
|
+
const date = value instanceof Date ? value : 'number' == typeof value ? new Date(value) : new Date(String(value));
|
|
38
|
+
if (Number.isNaN(date.getTime())) return '';
|
|
39
|
+
return (0, external_date_fns_namespaceObject.format)(date, DATE_TIME_FORMAT);
|
|
40
|
+
};
|
|
34
41
|
const dateTimeRegistry = {
|
|
35
42
|
type: 'date-time',
|
|
36
|
-
ConstantRenderer: (props)
|
|
43
|
+
ConstantRenderer: (props)=>{
|
|
44
|
+
const { readonly, schema, ...rest } = props;
|
|
45
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.DatePicker, {
|
|
37
46
|
size: "small",
|
|
38
47
|
type: "dateTime",
|
|
39
48
|
density: "compact",
|
|
40
49
|
defaultValue: Date.now(),
|
|
41
50
|
style: {
|
|
42
51
|
width: '100%',
|
|
43
|
-
...
|
|
52
|
+
...rest.style || {}
|
|
44
53
|
},
|
|
45
|
-
disabled:
|
|
46
|
-
...
|
|
54
|
+
disabled: readonly,
|
|
55
|
+
...rest,
|
|
47
56
|
onChange: (date)=>{
|
|
48
|
-
|
|
57
|
+
rest.onChange?.(stringifyDateTime(date));
|
|
49
58
|
},
|
|
50
|
-
value:
|
|
51
|
-
})
|
|
59
|
+
value: rest.value
|
|
60
|
+
});
|
|
61
|
+
},
|
|
52
62
|
conditionRule: {
|
|
53
63
|
[op_js_namespaceObject.ConditionPresetOp.EQ]: {
|
|
54
64
|
type: 'date-time'
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
enumRegistry: ()=>enumRegistry
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
require("react");
|
|
31
|
+
const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
32
|
+
const enumRegistry = {
|
|
33
|
+
type: 'enum',
|
|
34
|
+
parentType: [],
|
|
35
|
+
arrayIcon: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("svg", {
|
|
36
|
+
width: "16",
|
|
37
|
+
height: "16",
|
|
38
|
+
viewBox: "0 0 16 16",
|
|
39
|
+
fill: "none",
|
|
40
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
41
|
+
children: [
|
|
42
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("path", {
|
|
43
|
+
fillRule: "evenodd",
|
|
44
|
+
clipRule: "evenodd",
|
|
45
|
+
d: "M3.6139 1.58105H0V14.4186H3.6139V13.1264H1.36702V2.87326H3.6139V1.58105ZM3.41656 13.3266V13.3264H1.16987V13.3266H3.41656ZM0.197537 14.2186H0.197344V1.78105H3.41656V1.78125H0.197537V14.2186ZM16 1.58105H12.3861V2.87326H14.633V13.1264H12.3861V14.4186H16V1.58105ZM12.5834 1.78105V2.67326H12.5836V1.78125H15.8027V1.78105H12.5834ZM12.5836 14.2186V13.3266H14.8305V2.67345H14.8303V13.3264H12.5834V14.2186H12.5836Z",
|
|
46
|
+
fill: "currentColor"
|
|
47
|
+
}),
|
|
48
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("path", {
|
|
49
|
+
d: "M6.01442 7.34421C5.89401 7.46462 5.89401 7.65985 6.01442 7.78026L7.78218 9.54802C7.9026 9.66844 8.09782 9.66844 8.21823 9.54802L9.986 7.78026C10.1064 7.65985 10.1064 7.46462 9.986 7.34421L9.69137 7.04958C9.57096 6.92917 9.37573 6.92917 9.25532 7.04958L8.00021 8.3047L6.74509 7.04958C6.62468 6.92917 6.42946 6.92917 6.30904 7.04958L6.01442 7.34421ZM3.31699 7.99984C3.31699 10.5864 5.41379 12.6832 8.00033 12.6832C10.5869 12.6832 12.6837 10.5864 12.6837 7.99984C12.6837 5.4133 10.5869 3.3165 8.00033 3.3165C5.41379 3.3165 3.31699 5.4133 3.31699 7.99984ZM11.6503 7.99984C11.6503 10.0157 10.0162 11.6498 8.00033 11.6498C5.98449 11.6498 4.35033 10.0157 4.35033 7.99984C4.35033 5.984 5.98449 4.34984 8.00033 4.34984C10.0162 4.34984 11.6503 5.984 11.6503 7.99984Z",
|
|
50
|
+
fill: "currentColor",
|
|
51
|
+
stroke: "currentColor",
|
|
52
|
+
strokeWidth: "0.2"
|
|
53
|
+
})
|
|
54
|
+
]
|
|
55
|
+
}),
|
|
56
|
+
ConstantRenderer: (props)=>{
|
|
57
|
+
const { schema, readonly, enableMultiLineStr, ...rest } = props;
|
|
58
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Select, {
|
|
59
|
+
size: "small",
|
|
60
|
+
disabled: readonly,
|
|
61
|
+
optionList: (schema?.enum || []).map((value)=>({
|
|
62
|
+
label: `${value}`,
|
|
63
|
+
value
|
|
64
|
+
})),
|
|
65
|
+
...rest
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
exports.enumRegistry = __webpack_exports__.enumRegistry;
|
|
70
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
71
|
+
"enumRegistry"
|
|
72
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
73
|
+
Object.defineProperty(exports, '__esModule', {
|
|
74
|
+
value: true
|
|
75
|
+
});
|
|
@@ -33,6 +33,7 @@ const external_object_js_namespaceObject = require("./object.js");
|
|
|
33
33
|
const external_number_js_namespaceObject = require("./number.js");
|
|
34
34
|
const external_map_js_namespaceObject = require("./map.js");
|
|
35
35
|
const external_integer_js_namespaceObject = require("./integer.js");
|
|
36
|
+
const external_enum_js_namespaceObject = require("./enum.js");
|
|
36
37
|
const external_date_time_js_namespaceObject = require("./date-time.js");
|
|
37
38
|
const external_boolean_js_namespaceObject = require("./boolean.js");
|
|
38
39
|
const external_array_js_namespaceObject = require("./array.js");
|
|
@@ -44,6 +45,7 @@ const jsonSchemaTypePreset = [
|
|
|
44
45
|
external_boolean_js_namespaceObject.booleanRegistry,
|
|
45
46
|
external_array_js_namespaceObject.arrayRegistry,
|
|
46
47
|
external_map_js_namespaceObject.mapRegistry,
|
|
48
|
+
external_enum_js_namespaceObject.enumRegistry,
|
|
47
49
|
external_date_time_js_namespaceObject.dateTimeRegistry
|
|
48
50
|
];
|
|
49
51
|
const initRegistries = ()=>{
|
|
@@ -33,12 +33,12 @@ const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
|
33
33
|
const op_js_namespaceObject = require("../../../components/condition-context/op.js");
|
|
34
34
|
const integerRegistry = {
|
|
35
35
|
type: 'integer',
|
|
36
|
-
ConstantRenderer: (
|
|
36
|
+
ConstantRenderer: ({ readonly, schema, ...rest })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.InputNumber, {
|
|
37
37
|
placeholder: editor_namespaceObject.I18n.t('Please Input Integer'),
|
|
38
38
|
size: "small",
|
|
39
|
-
disabled:
|
|
39
|
+
disabled: readonly,
|
|
40
40
|
precision: 0,
|
|
41
|
-
...
|
|
41
|
+
...rest
|
|
42
42
|
}),
|
|
43
43
|
conditionRule: {
|
|
44
44
|
[op_js_namespaceObject.ConditionPresetOp.EQ]: {
|
|
@@ -33,12 +33,12 @@ const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
|
33
33
|
const op_js_namespaceObject = require("../../../components/condition-context/op.js");
|
|
34
34
|
const numberRegistry = {
|
|
35
35
|
type: 'number',
|
|
36
|
-
ConstantRenderer: (
|
|
36
|
+
ConstantRenderer: ({ readonly, schema, ...rest })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.InputNumber, {
|
|
37
37
|
placeholder: editor_namespaceObject.I18n.t('Please Input Number'),
|
|
38
38
|
size: "small",
|
|
39
|
-
disabled:
|
|
39
|
+
disabled: readonly,
|
|
40
40
|
hideButtons: true,
|
|
41
|
-
...
|
|
41
|
+
...rest
|
|
42
42
|
}),
|
|
43
43
|
conditionRule: {
|
|
44
44
|
[op_js_namespaceObject.ConditionPresetOp.EQ]: {
|
|
@@ -33,17 +33,17 @@ const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
|
33
33
|
const op_js_namespaceObject = require("../../../components/condition-context/op.js");
|
|
34
34
|
const stringRegistry = {
|
|
35
35
|
type: 'string',
|
|
36
|
-
ConstantRenderer: (
|
|
36
|
+
ConstantRenderer: ({ readonly, schema, enableMultiLineStr, ...rest })=>enableMultiLineStr ? /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.TextArea, {
|
|
37
37
|
autosize: true,
|
|
38
38
|
rows: 1,
|
|
39
39
|
placeholder: editor_namespaceObject.I18n.t('Please Input String'),
|
|
40
|
-
disabled:
|
|
41
|
-
...
|
|
40
|
+
disabled: readonly,
|
|
41
|
+
...rest
|
|
42
42
|
}) : /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Input, {
|
|
43
43
|
size: "small",
|
|
44
44
|
placeholder: editor_namespaceObject.I18n.t('Please Input String'),
|
|
45
|
-
disabled:
|
|
46
|
-
...
|
|
45
|
+
disabled: readonly,
|
|
46
|
+
...rest
|
|
47
47
|
}),
|
|
48
48
|
conditionRule: {
|
|
49
49
|
[op_js_namespaceObject.ConditionPresetOp.EQ]: {
|
|
@@ -12,6 +12,9 @@ const OriginCodeEditor = createRenderer(preset_code, [
|
|
|
12
12
|
}
|
|
13
13
|
})
|
|
14
14
|
]);
|
|
15
|
+
const MINI_EXTENSIONS = [
|
|
16
|
+
EditorView.lineWrapping
|
|
17
|
+
];
|
|
15
18
|
function BaseCodeEditor({ value, onChange, languageId = 'python', theme = 'light', children, placeholder, activeLinePlaceholder, options, readonly, mini }) {
|
|
16
19
|
const editorRef = useRef(null);
|
|
17
20
|
const editorValue = String(value || '');
|
|
@@ -34,6 +37,7 @@ function BaseCodeEditor({ value, onChange, languageId = 'python', theme = 'light
|
|
|
34
37
|
children: /*#__PURE__*/ jsx(EditorProvider, {
|
|
35
38
|
children: /*#__PURE__*/ jsxs(OriginCodeEditor, {
|
|
36
39
|
defaultValue: editorValue,
|
|
40
|
+
extensions: mini ? MINI_EXTENSIONS : void 0,
|
|
37
41
|
options: {
|
|
38
42
|
uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
|
|
39
43
|
languageId,
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
+
.gedit-m-code-editor-container {
|
|
2
|
+
width: 100%;
|
|
3
|
+
min-width: 0;
|
|
4
|
+
max-width: 100%;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
}
|
|
7
|
+
|
|
1
8
|
.gedit-m-code-editor-container.mini {
|
|
2
|
-
height: 24px;
|
|
9
|
+
min-height: 24px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.gedit-m-code-editor-container.mini .cm-editor, .gedit-m-code-editor-container.mini .cm-scroller, .gedit-m-code-editor-container.mini .cm-content {
|
|
13
|
+
min-width: 0;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.gedit-m-code-editor-container.mini .cm-scroller {
|
|
18
|
+
overflow-x: hidden;
|
|
3
19
|
}
|
|
4
20
|
|
|
@@ -11,13 +11,15 @@ function ConstantInput(props) {
|
|
|
11
11
|
return strategy?.Renderer;
|
|
12
12
|
}, [
|
|
13
13
|
strategies,
|
|
14
|
-
schema
|
|
14
|
+
schema,
|
|
15
|
+
typeManager
|
|
15
16
|
]);
|
|
16
17
|
if (!Renderer) {
|
|
17
18
|
if (fallbackRenderer) return /*#__PURE__*/ react.createElement(fallbackRenderer, {
|
|
18
19
|
value,
|
|
19
20
|
onChange,
|
|
20
21
|
readonly,
|
|
22
|
+
schema,
|
|
21
23
|
...rest
|
|
22
24
|
});
|
|
23
25
|
return /*#__PURE__*/ jsx(Input, {
|
|
@@ -30,6 +32,7 @@ function ConstantInput(props) {
|
|
|
30
32
|
value: value,
|
|
31
33
|
onChange: onChange,
|
|
32
34
|
readonly: readonly,
|
|
35
|
+
schema: schema,
|
|
33
36
|
...rest
|
|
34
37
|
});
|
|
35
38
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useMemo, useState } from "react";
|
|
3
|
+
import { useTypeManager } from "@flowgram.ai/json-schema";
|
|
3
4
|
import { I18n } from "@flowgram.ai/editor";
|
|
4
5
|
import { Button, Checkbox, IconButton } from "@douyinfe/semi-ui";
|
|
5
6
|
import { IconChevronDown, IconChevronRight, IconExpand, IconMinus, IconPlus, IconShrink } from "@douyinfe/semi-icons";
|
|
@@ -12,6 +13,11 @@ import "./styles.css";
|
|
|
12
13
|
const DEFAULT = {
|
|
13
14
|
type: 'object'
|
|
14
15
|
};
|
|
16
|
+
function getSchemaDefaultValue(typeManager, schema) {
|
|
17
|
+
if (schema?.type === 'object') return '{}';
|
|
18
|
+
if (schema?.type === 'array') return '[]';
|
|
19
|
+
return typeManager.getDefaultValue(schema || {});
|
|
20
|
+
}
|
|
15
21
|
function JsonSchemaEditor(props) {
|
|
16
22
|
const { value = DEFAULT, config = {}, onChange: onChangeProps, readonly } = props;
|
|
17
23
|
const { propertyList, onAddProperty, onRemoveProperty, onEditProperty } = usePropertiesEdit(value, onChangeProps);
|
|
@@ -50,6 +56,7 @@ function PropertyEdit(props) {
|
|
|
50
56
|
const { value, config, readonly, $level = 0, onChange: onChangeProps, onRemove, $isLast } = props;
|
|
51
57
|
const [expand, setExpand] = useState(false);
|
|
52
58
|
const [collapse, setCollapse] = useState(false);
|
|
59
|
+
const typeManager = useTypeManager();
|
|
53
60
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
54
61
|
const typeSelectorValue = useMemo(()=>({
|
|
55
62
|
type,
|
|
@@ -105,9 +112,11 @@ function PropertyEdit(props) {
|
|
|
105
112
|
value: typeSelectorValue,
|
|
106
113
|
readonly: readonly,
|
|
107
114
|
onChange: (_value)=>{
|
|
115
|
+
const nextTypeSchema = _value || {};
|
|
108
116
|
onChangeProps?.({
|
|
109
117
|
...value || {},
|
|
110
|
-
...
|
|
118
|
+
...nextTypeSchema,
|
|
119
|
+
default: getSchemaDefaultValue(typeManager, nextTypeSchema)
|
|
111
120
|
});
|
|
112
121
|
}
|
|
113
122
|
})
|
|
@@ -6,11 +6,11 @@ import { ConditionPresetOp } from "../../../components/condition-context/op.mjs"
|
|
|
6
6
|
const booleanRegistry = {
|
|
7
7
|
type: 'boolean',
|
|
8
8
|
ConstantRenderer: (props)=>{
|
|
9
|
-
const { value, onChange, ...rest } = props;
|
|
9
|
+
const { value, onChange, readonly, schema, ...rest } = props;
|
|
10
10
|
return /*#__PURE__*/ jsx(Select, {
|
|
11
11
|
placeholder: I18n.t('Please Select Boolean'),
|
|
12
12
|
size: "small",
|
|
13
|
-
disabled:
|
|
13
|
+
disabled: readonly,
|
|
14
14
|
optionList: [
|
|
15
15
|
{
|
|
16
16
|
label: I18n.t('True'),
|
|
@@ -3,24 +3,34 @@ import "react";
|
|
|
3
3
|
import { format } from "date-fns";
|
|
4
4
|
import { DatePicker } from "@douyinfe/semi-ui";
|
|
5
5
|
import { ConditionPresetOp } from "../../../components/condition-context/op.mjs";
|
|
6
|
+
const DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
|
7
|
+
const stringifyDateTime = (value)=>{
|
|
8
|
+
if (null == value || '' === value) return '';
|
|
9
|
+
const date = value instanceof Date ? value : 'number' == typeof value ? new Date(value) : new Date(String(value));
|
|
10
|
+
if (Number.isNaN(date.getTime())) return '';
|
|
11
|
+
return format(date, DATE_TIME_FORMAT);
|
|
12
|
+
};
|
|
6
13
|
const dateTimeRegistry = {
|
|
7
14
|
type: 'date-time',
|
|
8
|
-
ConstantRenderer: (props)
|
|
15
|
+
ConstantRenderer: (props)=>{
|
|
16
|
+
const { readonly, schema, ...rest } = props;
|
|
17
|
+
return /*#__PURE__*/ jsx(DatePicker, {
|
|
9
18
|
size: "small",
|
|
10
19
|
type: "dateTime",
|
|
11
20
|
density: "compact",
|
|
12
21
|
defaultValue: Date.now(),
|
|
13
22
|
style: {
|
|
14
23
|
width: '100%',
|
|
15
|
-
...
|
|
24
|
+
...rest.style || {}
|
|
16
25
|
},
|
|
17
|
-
disabled:
|
|
18
|
-
...
|
|
26
|
+
disabled: readonly,
|
|
27
|
+
...rest,
|
|
19
28
|
onChange: (date)=>{
|
|
20
|
-
|
|
29
|
+
rest.onChange?.(stringifyDateTime(date));
|
|
21
30
|
},
|
|
22
|
-
value:
|
|
23
|
-
})
|
|
31
|
+
value: rest.value
|
|
32
|
+
});
|
|
33
|
+
},
|
|
24
34
|
conditionRule: {
|
|
25
35
|
[ConditionPresetOp.EQ]: {
|
|
26
36
|
type: 'date-time'
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Select } from "@douyinfe/semi-ui";
|
|
4
|
+
const enumRegistry = {
|
|
5
|
+
type: 'enum',
|
|
6
|
+
parentType: [],
|
|
7
|
+
arrayIcon: /*#__PURE__*/ jsxs("svg", {
|
|
8
|
+
width: "16",
|
|
9
|
+
height: "16",
|
|
10
|
+
viewBox: "0 0 16 16",
|
|
11
|
+
fill: "none",
|
|
12
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
13
|
+
children: [
|
|
14
|
+
/*#__PURE__*/ jsx("path", {
|
|
15
|
+
fillRule: "evenodd",
|
|
16
|
+
clipRule: "evenodd",
|
|
17
|
+
d: "M3.6139 1.58105H0V14.4186H3.6139V13.1264H1.36702V2.87326H3.6139V1.58105ZM3.41656 13.3266V13.3264H1.16987V13.3266H3.41656ZM0.197537 14.2186H0.197344V1.78105H3.41656V1.78125H0.197537V14.2186ZM16 1.58105H12.3861V2.87326H14.633V13.1264H12.3861V14.4186H16V1.58105ZM12.5834 1.78105V2.67326H12.5836V1.78125H15.8027V1.78105H12.5834ZM12.5836 14.2186V13.3266H14.8305V2.67345H14.8303V13.3264H12.5834V14.2186H12.5836Z",
|
|
18
|
+
fill: "currentColor"
|
|
19
|
+
}),
|
|
20
|
+
/*#__PURE__*/ jsx("path", {
|
|
21
|
+
d: "M6.01442 7.34421C5.89401 7.46462 5.89401 7.65985 6.01442 7.78026L7.78218 9.54802C7.9026 9.66844 8.09782 9.66844 8.21823 9.54802L9.986 7.78026C10.1064 7.65985 10.1064 7.46462 9.986 7.34421L9.69137 7.04958C9.57096 6.92917 9.37573 6.92917 9.25532 7.04958L8.00021 8.3047L6.74509 7.04958C6.62468 6.92917 6.42946 6.92917 6.30904 7.04958L6.01442 7.34421ZM3.31699 7.99984C3.31699 10.5864 5.41379 12.6832 8.00033 12.6832C10.5869 12.6832 12.6837 10.5864 12.6837 7.99984C12.6837 5.4133 10.5869 3.3165 8.00033 3.3165C5.41379 3.3165 3.31699 5.4133 3.31699 7.99984ZM11.6503 7.99984C11.6503 10.0157 10.0162 11.6498 8.00033 11.6498C5.98449 11.6498 4.35033 10.0157 4.35033 7.99984C4.35033 5.984 5.98449 4.34984 8.00033 4.34984C10.0162 4.34984 11.6503 5.984 11.6503 7.99984Z",
|
|
22
|
+
fill: "currentColor",
|
|
23
|
+
stroke: "currentColor",
|
|
24
|
+
strokeWidth: "0.2"
|
|
25
|
+
})
|
|
26
|
+
]
|
|
27
|
+
}),
|
|
28
|
+
ConstantRenderer: (props)=>{
|
|
29
|
+
const { schema, readonly, enableMultiLineStr, ...rest } = props;
|
|
30
|
+
return /*#__PURE__*/ jsx(Select, {
|
|
31
|
+
size: "small",
|
|
32
|
+
disabled: readonly,
|
|
33
|
+
optionList: (schema?.enum || []).map((value)=>({
|
|
34
|
+
label: `${value}`,
|
|
35
|
+
value
|
|
36
|
+
})),
|
|
37
|
+
...rest
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export { enumRegistry };
|
|
@@ -4,6 +4,7 @@ import { objectRegistry } from "./object.mjs";
|
|
|
4
4
|
import { numberRegistry } from "./number.mjs";
|
|
5
5
|
import { mapRegistry } from "./map.mjs";
|
|
6
6
|
import { integerRegistry } from "./integer.mjs";
|
|
7
|
+
import { enumRegistry } from "./enum.mjs";
|
|
7
8
|
import { dateTimeRegistry } from "./date-time.mjs";
|
|
8
9
|
import { booleanRegistry } from "./boolean.mjs";
|
|
9
10
|
import { arrayRegistry } from "./array.mjs";
|
|
@@ -15,6 +16,7 @@ const jsonSchemaTypePreset = [
|
|
|
15
16
|
booleanRegistry,
|
|
16
17
|
arrayRegistry,
|
|
17
18
|
mapRegistry,
|
|
19
|
+
enumRegistry,
|
|
18
20
|
dateTimeRegistry
|
|
19
21
|
];
|
|
20
22
|
const initRegistries = ()=>{
|
|
@@ -5,12 +5,12 @@ import { InputNumber } from "@douyinfe/semi-ui";
|
|
|
5
5
|
import { ConditionPresetOp } from "../../../components/condition-context/op.mjs";
|
|
6
6
|
const integerRegistry = {
|
|
7
7
|
type: 'integer',
|
|
8
|
-
ConstantRenderer: (
|
|
8
|
+
ConstantRenderer: ({ readonly, schema, ...rest })=>/*#__PURE__*/ jsx(InputNumber, {
|
|
9
9
|
placeholder: I18n.t('Please Input Integer'),
|
|
10
10
|
size: "small",
|
|
11
|
-
disabled:
|
|
11
|
+
disabled: readonly,
|
|
12
12
|
precision: 0,
|
|
13
|
-
...
|
|
13
|
+
...rest
|
|
14
14
|
}),
|
|
15
15
|
conditionRule: {
|
|
16
16
|
[ConditionPresetOp.EQ]: {
|
|
@@ -5,12 +5,12 @@ import { InputNumber } from "@douyinfe/semi-ui";
|
|
|
5
5
|
import { ConditionPresetOp } from "../../../components/condition-context/op.mjs";
|
|
6
6
|
const numberRegistry = {
|
|
7
7
|
type: 'number',
|
|
8
|
-
ConstantRenderer: (
|
|
8
|
+
ConstantRenderer: ({ readonly, schema, ...rest })=>/*#__PURE__*/ jsx(InputNumber, {
|
|
9
9
|
placeholder: I18n.t('Please Input Number'),
|
|
10
10
|
size: "small",
|
|
11
|
-
disabled:
|
|
11
|
+
disabled: readonly,
|
|
12
12
|
hideButtons: true,
|
|
13
|
-
...
|
|
13
|
+
...rest
|
|
14
14
|
}),
|
|
15
15
|
conditionRule: {
|
|
16
16
|
[ConditionPresetOp.EQ]: {
|
|
@@ -5,17 +5,17 @@ import { Input, TextArea } from "@douyinfe/semi-ui";
|
|
|
5
5
|
import { ConditionPresetOp } from "../../../components/condition-context/op.mjs";
|
|
6
6
|
const stringRegistry = {
|
|
7
7
|
type: 'string',
|
|
8
|
-
ConstantRenderer: (
|
|
8
|
+
ConstantRenderer: ({ readonly, schema, enableMultiLineStr, ...rest })=>enableMultiLineStr ? /*#__PURE__*/ jsx(TextArea, {
|
|
9
9
|
autosize: true,
|
|
10
10
|
rows: 1,
|
|
11
11
|
placeholder: I18n.t('Please Input String'),
|
|
12
|
-
disabled:
|
|
13
|
-
...
|
|
12
|
+
disabled: readonly,
|
|
13
|
+
...rest
|
|
14
14
|
}) : /*#__PURE__*/ jsx(Input, {
|
|
15
15
|
size: "small",
|
|
16
16
|
placeholder: I18n.t('Please Input String'),
|
|
17
|
-
disabled:
|
|
18
|
-
...
|
|
17
|
+
disabled: readonly,
|
|
18
|
+
...rest
|
|
19
19
|
}),
|
|
20
20
|
conditionRule: {
|
|
21
21
|
[ConditionPresetOp.EQ]: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/index.ts","../src/components/index.ts","../src/components/assign-row/index.tsx","../src/components/assign-row/types.ts","../src/components/assign-rows/index.tsx","../src/components/batch-outputs/index.tsx","../src/components/batch-outputs/types.ts","../src/components/batch-variable-selector/index.tsx","../src/components/blur-input/index.tsx","../src/components/code-editor/editor-all.tsx","../src/components/code-editor/editor-json.tsx","../src/components/code-editor/editor-python.tsx","../src/components/code-editor/editor-shell.tsx","../src/components/code-editor/editor-sql.tsx","../src/components/code-editor/editor-ts.tsx","../src/components/code-editor/editor.tsx","../src/components/code-editor/factory.tsx","../src/components/code-editor/index.tsx","../src/components/code-editor/utils.ts","../src/components/code-editor/theme/dark.ts","../src/components/code-editor/theme/index.ts","../src/components/code-editor/theme/light.ts","../src/components/code-editor-mini/index.tsx","../src/components/condition-context/context.tsx","../src/components/condition-context/index.tsx","../src/components/condition-context/op.ts","../src/components/condition-context/types.ts","../src/components/condition-context/hooks/use-condition.tsx","../src/components/condition-row/index.tsx","../src/components/condition-row/types.ts","../src/components/constant-input/index.tsx","../src/components/constant-input/types.ts","../src/components/coze-editor-extensions/index.tsx","../src/components/coze-editor-extensions/extensions/inputs-tree.tsx","../src/components/coze-editor-extensions/extensions/variable-tag.tsx","../src/components/coze-editor-extensions/extensions/variable-tree.tsx","../src/components/db-condition-row/index.tsx","../src/components/db-condition-row/types.ts","../src/components/display-flow-value/index.tsx","../src/components/display-inputs-values/index.tsx","../src/components/display-outputs/index.tsx","../src/components/display-schema-tag/index.tsx","../src/components/display-schema-tree/index.tsx","../src/components/dynamic-value-input/hooks.ts","../src/components/dynamic-value-input/index.tsx","../src/components/inputs-values/index.tsx","../src/components/inputs-values/types.ts","../src/components/inputs-values-tree/icon.tsx","../src/components/inputs-values-tree/index.tsx","../src/components/inputs-values-tree/row.tsx","../src/components/inputs-values-tree/types.ts","../src/components/inputs-values-tree/hooks/use-child-list.tsx","../src/components/json-editor-with-variables/editor.tsx","../src/components/json-editor-with-variables/index.tsx","../src/components/json-schema-creator/index.tsx","../src/components/json-schema-creator/json-input-modal.tsx","../src/components/json-schema-creator/json-schema-creator.tsx","../src/components/json-schema-creator/utils/json-to-schema.ts","../src/components/json-schema-editor/default-value.tsx","../src/components/json-schema-editor/hooks.tsx","../src/components/json-schema-editor/icon.tsx","../src/components/json-schema-editor/index.tsx","../src/components/json-schema-editor/types.ts","../src/components/prompt-editor/editor.tsx","../src/components/prompt-editor/index.tsx","../src/components/prompt-editor/types.tsx","../src/components/prompt-editor/extensions/jinja.tsx","../src/components/prompt-editor/extensions/language-support.tsx","../src/components/prompt-editor/extensions/markdown.tsx","../src/components/prompt-editor-with-inputs/index.tsx","../src/components/prompt-editor-with-variables/index.tsx","../src/components/sql-editor-with-variables/editor.tsx","../src/components/sql-editor-with-variables/index.tsx","../src/components/type-selector/index.tsx","../src/components/variable-selector/context.tsx","../src/components/variable-selector/index.tsx","../src/components/variable-selector/use-variable-tree.tsx","../src/effects/index.ts","../src/effects/auto-rename-ref/index.ts","../src/effects/listen-ref-schema-change/index.ts","../src/effects/listen-ref-value-change/index.ts","../src/effects/provide-batch-input/index.ts","../src/effects/provide-json-schema-outputs/index.ts","../src/effects/sync-variable-title/index.ts","../src/effects/validate-when-variable-sync/index.ts","../src/form-plugins/index.ts","../src/form-plugins/batch-outputs-plugin/index.ts","../src/form-plugins/infer-assign-plugin/index.ts","../src/form-plugins/infer-inputs-plugin/index.ts","../src/hooks/index.ts","../src/hooks/use-object-list/index.tsx","../src/plugins/index.ts","../src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts","../src/plugins/disable-declaration-plugin/index.tsx","../src/plugins/json-schema-preset/create-type-preset-plugin.tsx","../src/plugins/json-schema-preset/index.tsx","../src/plugins/json-schema-preset/react.tsx","../src/plugins/json-schema-preset/types.ts","../src/plugins/json-schema-preset/type-definition/array.tsx","../src/plugins/json-schema-preset/type-definition/boolean.tsx","../src/plugins/json-schema-preset/type-definition/date-time.tsx","../src/plugins/json-schema-preset/type-definition/index.tsx","../src/plugins/json-schema-preset/type-definition/integer.tsx","../src/plugins/json-schema-preset/type-definition/map.tsx","../src/plugins/json-schema-preset/type-definition/number.tsx","../src/plugins/json-schema-preset/type-definition/object.tsx","../src/plugins/json-schema-preset/type-definition/string.tsx","../src/shared/index.ts","../src/shared/flow-value/index.ts","../src/shared/flow-value/schema.ts","../src/shared/flow-value/types.ts","../src/shared/flow-value/utils.ts","../src/shared/format-legacy-refs/index.ts","../src/shared/inject-material/index.tsx","../src/shared/lazy-suspense/index.tsx","../src/shared/polyfill-create-root/index.tsx","../src/validate/index.ts","../src/validate/validate-flow-value/index.tsx"],"version":"5.9.2"}
|
|
1
|
+
{"root":["../src/index.ts","../src/components/index.ts","../src/components/assign-row/index.tsx","../src/components/assign-row/types.ts","../src/components/assign-rows/index.tsx","../src/components/batch-outputs/index.tsx","../src/components/batch-outputs/types.ts","../src/components/batch-variable-selector/index.tsx","../src/components/blur-input/index.tsx","../src/components/code-editor/editor-all.tsx","../src/components/code-editor/editor-json.tsx","../src/components/code-editor/editor-python.tsx","../src/components/code-editor/editor-shell.tsx","../src/components/code-editor/editor-sql.tsx","../src/components/code-editor/editor-ts.tsx","../src/components/code-editor/editor.tsx","../src/components/code-editor/factory.tsx","../src/components/code-editor/index.tsx","../src/components/code-editor/utils.ts","../src/components/code-editor/theme/dark.ts","../src/components/code-editor/theme/index.ts","../src/components/code-editor/theme/light.ts","../src/components/code-editor-mini/index.tsx","../src/components/condition-context/context.tsx","../src/components/condition-context/index.tsx","../src/components/condition-context/op.ts","../src/components/condition-context/types.ts","../src/components/condition-context/hooks/use-condition.tsx","../src/components/condition-row/index.tsx","../src/components/condition-row/types.ts","../src/components/constant-input/index.tsx","../src/components/constant-input/types.ts","../src/components/coze-editor-extensions/index.tsx","../src/components/coze-editor-extensions/extensions/inputs-tree.tsx","../src/components/coze-editor-extensions/extensions/variable-tag.tsx","../src/components/coze-editor-extensions/extensions/variable-tree.tsx","../src/components/db-condition-row/index.tsx","../src/components/db-condition-row/types.ts","../src/components/display-flow-value/index.tsx","../src/components/display-inputs-values/index.tsx","../src/components/display-outputs/index.tsx","../src/components/display-schema-tag/index.tsx","../src/components/display-schema-tree/index.tsx","../src/components/dynamic-value-input/hooks.ts","../src/components/dynamic-value-input/index.tsx","../src/components/inputs-values/index.tsx","../src/components/inputs-values/types.ts","../src/components/inputs-values-tree/icon.tsx","../src/components/inputs-values-tree/index.tsx","../src/components/inputs-values-tree/row.tsx","../src/components/inputs-values-tree/types.ts","../src/components/inputs-values-tree/hooks/use-child-list.tsx","../src/components/json-editor-with-variables/editor.tsx","../src/components/json-editor-with-variables/index.tsx","../src/components/json-schema-creator/index.tsx","../src/components/json-schema-creator/json-input-modal.tsx","../src/components/json-schema-creator/json-schema-creator.tsx","../src/components/json-schema-creator/utils/json-to-schema.ts","../src/components/json-schema-editor/default-value.tsx","../src/components/json-schema-editor/hooks.tsx","../src/components/json-schema-editor/icon.tsx","../src/components/json-schema-editor/index.tsx","../src/components/json-schema-editor/types.ts","../src/components/prompt-editor/editor.tsx","../src/components/prompt-editor/index.tsx","../src/components/prompt-editor/types.tsx","../src/components/prompt-editor/extensions/jinja.tsx","../src/components/prompt-editor/extensions/language-support.tsx","../src/components/prompt-editor/extensions/markdown.tsx","../src/components/prompt-editor-with-inputs/index.tsx","../src/components/prompt-editor-with-variables/index.tsx","../src/components/sql-editor-with-variables/editor.tsx","../src/components/sql-editor-with-variables/index.tsx","../src/components/type-selector/index.tsx","../src/components/variable-selector/context.tsx","../src/components/variable-selector/index.tsx","../src/components/variable-selector/use-variable-tree.tsx","../src/effects/index.ts","../src/effects/auto-rename-ref/index.ts","../src/effects/listen-ref-schema-change/index.ts","../src/effects/listen-ref-value-change/index.ts","../src/effects/provide-batch-input/index.ts","../src/effects/provide-json-schema-outputs/index.ts","../src/effects/sync-variable-title/index.ts","../src/effects/validate-when-variable-sync/index.ts","../src/form-plugins/index.ts","../src/form-plugins/batch-outputs-plugin/index.ts","../src/form-plugins/infer-assign-plugin/index.ts","../src/form-plugins/infer-inputs-plugin/index.ts","../src/hooks/index.ts","../src/hooks/use-object-list/index.tsx","../src/plugins/index.ts","../src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts","../src/plugins/disable-declaration-plugin/index.tsx","../src/plugins/json-schema-preset/create-type-preset-plugin.tsx","../src/plugins/json-schema-preset/index.tsx","../src/plugins/json-schema-preset/react.tsx","../src/plugins/json-schema-preset/types.ts","../src/plugins/json-schema-preset/type-definition/array.tsx","../src/plugins/json-schema-preset/type-definition/boolean.tsx","../src/plugins/json-schema-preset/type-definition/date-time.tsx","../src/plugins/json-schema-preset/type-definition/enum.tsx","../src/plugins/json-schema-preset/type-definition/index.tsx","../src/plugins/json-schema-preset/type-definition/integer.tsx","../src/plugins/json-schema-preset/type-definition/map.tsx","../src/plugins/json-schema-preset/type-definition/number.tsx","../src/plugins/json-schema-preset/type-definition/object.tsx","../src/plugins/json-schema-preset/type-definition/string.tsx","../src/shared/index.ts","../src/shared/flow-value/index.ts","../src/shared/flow-value/schema.ts","../src/shared/flow-value/types.ts","../src/shared/flow-value/utils.ts","../src/shared/format-legacy-refs/index.ts","../src/shared/inject-material/index.tsx","../src/shared/lazy-suspense/index.tsx","../src/shared/polyfill-create-root/index.tsx","../src/validate/index.ts","../src/validate/validate-flow-value/index.tsx"],"version":"5.9.2"}
|
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import { JsonSchemaTypeRegistry as OriginJsonSchemaTypeRegistry } from '@flowgram.ai/json-schema';
|
|
5
|
+
import { type IJsonSchema, JsonSchemaTypeRegistry as OriginJsonSchemaTypeRegistry } from '@flowgram.ai/json-schema';
|
|
6
6
|
import { IConditionRule, IConditionRuleFactory } from '../../components/condition-context/types';
|
|
7
7
|
export interface ConstantRendererProps<Value = any> {
|
|
8
8
|
value?: Value;
|
|
9
9
|
onChange?: (value: Value) => void;
|
|
10
10
|
readonly?: boolean;
|
|
11
|
+
schema?: IJsonSchema;
|
|
11
12
|
[key: string]: any;
|
|
12
13
|
}
|
|
13
14
|
export interface JsonSchemaTypeRegistry<Value = any> extends OriginJsonSchemaTypeRegistry {
|
|
15
|
+
/**
|
|
16
|
+
* The icon displayed when this type is used as an array item
|
|
17
|
+
*/
|
|
18
|
+
arrayIcon?: React.JSX.Element;
|
|
14
19
|
/**
|
|
15
20
|
* Render Constant Input
|
|
16
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/form-materials",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"@codemirror/state": "^6.4.1",
|
|
68
68
|
"@codemirror/view": "^6.26.1",
|
|
69
69
|
"zod": "^3.24.4",
|
|
70
|
-
"@flowgram.ai/
|
|
71
|
-
"@flowgram.ai/editor": "1.0.
|
|
72
|
-
"@flowgram.ai/
|
|
70
|
+
"@flowgram.ai/editor": "1.0.12",
|
|
71
|
+
"@flowgram.ai/coze-editor": "1.0.12",
|
|
72
|
+
"@flowgram.ai/json-schema": "1.0.12"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -86,8 +86,8 @@
|
|
|
86
86
|
"cross-env": "~7.0.3",
|
|
87
87
|
"@rsbuild/plugin-react": "^1.1.1",
|
|
88
88
|
"date-fns": "~4.1.0",
|
|
89
|
-
"@flowgram.ai/
|
|
90
|
-
"@flowgram.ai/
|
|
89
|
+
"@flowgram.ai/ts-config": "1.0.12",
|
|
90
|
+
"@flowgram.ai/eslint-config": "1.0.12"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"react": ">=16.8",
|
|
@@ -26,6 +26,8 @@ const OriginCodeEditor = createRenderer(preset, [
|
|
|
26
26
|
}),
|
|
27
27
|
]);
|
|
28
28
|
|
|
29
|
+
const MINI_EXTENSIONS = [EditorView.lineWrapping];
|
|
30
|
+
|
|
29
31
|
// CSS styles are in styles.css
|
|
30
32
|
|
|
31
33
|
type Preset = typeof preset;
|
|
@@ -79,6 +81,7 @@ export function BaseCodeEditor({
|
|
|
79
81
|
<EditorProvider>
|
|
80
82
|
<OriginCodeEditor
|
|
81
83
|
defaultValue={editorValue}
|
|
84
|
+
extensions={mini ? MINI_EXTENSIONS : undefined}
|
|
82
85
|
options={{
|
|
83
86
|
uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
|
|
84
87
|
languageId,
|
|
@@ -4,8 +4,23 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
.gedit-m-code-editor-container {
|
|
7
|
+
width: 100%;
|
|
8
|
+
min-width: 0;
|
|
9
|
+
max-width: 100%;
|
|
10
|
+
overflow: hidden;
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
.gedit-m-code-editor-container.mini {
|
|
10
|
-
height: 24px;
|
|
14
|
+
min-height: 24px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.gedit-m-code-editor-container.mini .cm-editor,
|
|
18
|
+
.gedit-m-code-editor-container.mini .cm-scroller,
|
|
19
|
+
.gedit-m-code-editor-container.mini .cm-content {
|
|
20
|
+
min-width: 0;
|
|
21
|
+
max-width: 100%;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.gedit-m-code-editor-container.mini .cm-scroller {
|
|
25
|
+
overflow-x: hidden;
|
|
11
26
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/* eslint-disable react/prop-types */
|
|
7
6
|
import React, { useMemo } from 'react';
|
|
8
7
|
|
|
9
8
|
import { Input } from '@douyinfe/semi-ui';
|
|
@@ -27,7 +26,7 @@ export function ConstantInput(props: PropsType) {
|
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
return strategy?.Renderer;
|
|
30
|
-
}, [strategies, schema]);
|
|
29
|
+
}, [strategies, schema, typeManager]);
|
|
31
30
|
|
|
32
31
|
if (!Renderer) {
|
|
33
32
|
if (fallbackRenderer) {
|
|
@@ -35,11 +34,14 @@ export function ConstantInput(props: PropsType) {
|
|
|
35
34
|
value,
|
|
36
35
|
onChange,
|
|
37
36
|
readonly,
|
|
37
|
+
schema,
|
|
38
38
|
...rest,
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
41
|
return <Input size="small" disabled placeholder="Unsupported type" />;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
return
|
|
44
|
+
return (
|
|
45
|
+
<Renderer value={value} onChange={onChange} readonly={readonly} schema={schema} {...rest} />
|
|
46
|
+
);
|
|
45
47
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { useMemo, useState } from 'react';
|
|
7
7
|
|
|
8
|
-
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
8
|
+
import { IJsonSchema, JsonSchemaTypeManager, useTypeManager } from '@flowgram.ai/json-schema';
|
|
9
9
|
import { I18n } from '@flowgram.ai/editor';
|
|
10
10
|
import { Button, Checkbox, IconButton } from '@douyinfe/semi-ui';
|
|
11
11
|
import {
|
|
@@ -29,6 +29,21 @@ import './styles.css';
|
|
|
29
29
|
|
|
30
30
|
const DEFAULT = { type: 'object' };
|
|
31
31
|
|
|
32
|
+
function getSchemaDefaultValue(
|
|
33
|
+
typeManager: JsonSchemaTypeManager,
|
|
34
|
+
schema: Partial<IJsonSchema> | undefined
|
|
35
|
+
) {
|
|
36
|
+
if (schema?.type === 'object') {
|
|
37
|
+
return '{}';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (schema?.type === 'array') {
|
|
41
|
+
return '[]';
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return typeManager.getDefaultValue(schema || {});
|
|
45
|
+
}
|
|
46
|
+
|
|
32
47
|
export function JsonSchemaEditor(props: {
|
|
33
48
|
value?: IJsonSchema;
|
|
34
49
|
onChange?: (value: IJsonSchema) => void;
|
|
@@ -86,6 +101,7 @@ function PropertyEdit(props: {
|
|
|
86
101
|
|
|
87
102
|
const [expand, setExpand] = useState(false);
|
|
88
103
|
const [collapse, setCollapse] = useState(false);
|
|
104
|
+
const typeManager = useTypeManager() as JsonSchemaTypeManager;
|
|
89
105
|
|
|
90
106
|
const { name, type, items, default: defaultValue, description, isPropertyRequired } = value || {};
|
|
91
107
|
|
|
@@ -136,9 +152,11 @@ function PropertyEdit(props: {
|
|
|
136
152
|
value={typeSelectorValue}
|
|
137
153
|
readonly={readonly}
|
|
138
154
|
onChange={(_value) => {
|
|
155
|
+
const nextTypeSchema = _value || {};
|
|
139
156
|
onChangeProps?.({
|
|
140
157
|
...(value || {}),
|
|
141
|
-
...
|
|
158
|
+
...nextTypeSchema,
|
|
159
|
+
default: getSchemaDefaultValue(typeManager, nextTypeSchema),
|
|
142
160
|
});
|
|
143
161
|
}}
|
|
144
162
|
/>
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/* eslint-disable react/prop-types */
|
|
7
6
|
import React from 'react';
|
|
8
7
|
|
|
9
8
|
import { I18n } from '@flowgram.ai/editor';
|
|
@@ -16,12 +15,12 @@ import { type JsonSchemaTypeRegistry } from '../types';
|
|
|
16
15
|
export const booleanRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
17
16
|
type: 'boolean',
|
|
18
17
|
ConstantRenderer: (props) => {
|
|
19
|
-
const { value, onChange, ...rest } = props;
|
|
18
|
+
const { value, onChange, readonly, schema, ...rest } = props;
|
|
20
19
|
return (
|
|
21
20
|
<Select
|
|
22
21
|
placeholder={I18n.t('Please Select Boolean')}
|
|
23
22
|
size="small"
|
|
24
|
-
disabled={
|
|
23
|
+
disabled={readonly}
|
|
25
24
|
optionList={[
|
|
26
25
|
{ label: I18n.t('True'), value: 1 },
|
|
27
26
|
{ label: I18n.t('False'), value: 0 },
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/* eslint-disable react/prop-types */
|
|
7
6
|
import React from 'react';
|
|
8
7
|
|
|
9
8
|
import { format } from 'date-fns';
|
|
@@ -14,23 +13,48 @@ import { ConditionPresetOp } from '@/components/condition-context/op';
|
|
|
14
13
|
|
|
15
14
|
import { type JsonSchemaTypeRegistry } from '../types';
|
|
16
15
|
|
|
16
|
+
const DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
|
17
|
+
|
|
18
|
+
const stringifyDateTime = (value: unknown) => {
|
|
19
|
+
if (value === null || value === undefined || value === '') {
|
|
20
|
+
return '';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const date =
|
|
24
|
+
value instanceof Date
|
|
25
|
+
? value
|
|
26
|
+
: typeof value === 'number'
|
|
27
|
+
? new Date(value)
|
|
28
|
+
: new Date(String(value));
|
|
29
|
+
|
|
30
|
+
if (Number.isNaN(date.getTime())) {
|
|
31
|
+
return '';
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return format(date, DATE_TIME_FORMAT);
|
|
35
|
+
};
|
|
36
|
+
|
|
17
37
|
export const dateTimeRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
18
38
|
type: 'date-time',
|
|
19
|
-
ConstantRenderer: (props: DatePickerProps & { readonly?: boolean }) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
ConstantRenderer: (props: DatePickerProps & { readonly?: boolean; schema?: unknown }) => {
|
|
40
|
+
const { readonly, schema, ...rest } = props;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<DatePicker
|
|
44
|
+
size="small"
|
|
45
|
+
type="dateTime"
|
|
46
|
+
density="compact"
|
|
47
|
+
defaultValue={Date.now()}
|
|
48
|
+
style={{ width: '100%', ...(rest.style || {}) }}
|
|
49
|
+
disabled={readonly}
|
|
50
|
+
{...rest}
|
|
51
|
+
onChange={(date) => {
|
|
52
|
+
rest.onChange?.(stringifyDateTime(date));
|
|
53
|
+
}}
|
|
54
|
+
value={rest.value}
|
|
55
|
+
/>
|
|
56
|
+
);
|
|
57
|
+
},
|
|
34
58
|
conditionRule: {
|
|
35
59
|
[ConditionPresetOp.EQ]: { type: 'date-time' },
|
|
36
60
|
[ConditionPresetOp.NEQ]: { type: 'date-time' },
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React from 'react';
|
|
7
|
+
|
|
8
|
+
import { Select } from '@douyinfe/semi-ui';
|
|
9
|
+
|
|
10
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
11
|
+
|
|
12
|
+
export const enumRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
13
|
+
type: 'enum',
|
|
14
|
+
parentType: [],
|
|
15
|
+
arrayIcon: (
|
|
16
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
17
|
+
<path
|
|
18
|
+
fillRule="evenodd"
|
|
19
|
+
clipRule="evenodd"
|
|
20
|
+
d="M3.6139 1.58105H0V14.4186H3.6139V13.1264H1.36702V2.87326H3.6139V1.58105ZM3.41656 13.3266V13.3264H1.16987V13.3266H3.41656ZM0.197537 14.2186H0.197344V1.78105H3.41656V1.78125H0.197537V14.2186ZM16 1.58105H12.3861V2.87326H14.633V13.1264H12.3861V14.4186H16V1.58105ZM12.5834 1.78105V2.67326H12.5836V1.78125H15.8027V1.78105H12.5834ZM12.5836 14.2186V13.3266H14.8305V2.67345H14.8303V13.3264H12.5834V14.2186H12.5836Z"
|
|
21
|
+
fill="currentColor"
|
|
22
|
+
/>
|
|
23
|
+
<path
|
|
24
|
+
d="M6.01442 7.34421C5.89401 7.46462 5.89401 7.65985 6.01442 7.78026L7.78218 9.54802C7.9026 9.66844 8.09782 9.66844 8.21823 9.54802L9.986 7.78026C10.1064 7.65985 10.1064 7.46462 9.986 7.34421L9.69137 7.04958C9.57096 6.92917 9.37573 6.92917 9.25532 7.04958L8.00021 8.3047L6.74509 7.04958C6.62468 6.92917 6.42946 6.92917 6.30904 7.04958L6.01442 7.34421ZM3.31699 7.99984C3.31699 10.5864 5.41379 12.6832 8.00033 12.6832C10.5869 12.6832 12.6837 10.5864 12.6837 7.99984C12.6837 5.4133 10.5869 3.3165 8.00033 3.3165C5.41379 3.3165 3.31699 5.4133 3.31699 7.99984ZM11.6503 7.99984C11.6503 10.0157 10.0162 11.6498 8.00033 11.6498C5.98449 11.6498 4.35033 10.0157 4.35033 7.99984C4.35033 5.984 5.98449 4.34984 8.00033 4.34984C10.0162 4.34984 11.6503 5.984 11.6503 7.99984Z"
|
|
25
|
+
fill="currentColor"
|
|
26
|
+
stroke="currentColor"
|
|
27
|
+
strokeWidth="0.2"
|
|
28
|
+
/>
|
|
29
|
+
</svg>
|
|
30
|
+
),
|
|
31
|
+
ConstantRenderer: (props) => {
|
|
32
|
+
const { schema, readonly, enableMultiLineStr, ...rest } = props;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Select
|
|
36
|
+
size="small"
|
|
37
|
+
disabled={readonly}
|
|
38
|
+
optionList={(schema?.enum || []).map((value) => ({
|
|
39
|
+
label: `${value}`,
|
|
40
|
+
value,
|
|
41
|
+
}))}
|
|
42
|
+
{...rest}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -10,6 +10,7 @@ import { objectRegistry } from './object';
|
|
|
10
10
|
import { numberRegistry } from './number';
|
|
11
11
|
import { mapRegistry } from './map';
|
|
12
12
|
import { integerRegistry } from './integer';
|
|
13
|
+
import { enumRegistry } from './enum';
|
|
13
14
|
import { dateTimeRegistry } from './date-time';
|
|
14
15
|
import { booleanRegistry } from './boolean';
|
|
15
16
|
import { arrayRegistry } from './array';
|
|
@@ -23,6 +24,7 @@ export const jsonSchemaTypePreset = [
|
|
|
23
24
|
booleanRegistry,
|
|
24
25
|
arrayRegistry,
|
|
25
26
|
mapRegistry,
|
|
27
|
+
enumRegistry,
|
|
26
28
|
dateTimeRegistry,
|
|
27
29
|
];
|
|
28
30
|
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/* eslint-disable react/prop-types */
|
|
7
6
|
import React from 'react';
|
|
8
7
|
|
|
9
8
|
import { I18n } from '@flowgram.ai/editor';
|
|
@@ -15,13 +14,13 @@ import { type JsonSchemaTypeRegistry } from '../types';
|
|
|
15
14
|
|
|
16
15
|
export const integerRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
17
16
|
type: 'integer',
|
|
18
|
-
ConstantRenderer: (
|
|
17
|
+
ConstantRenderer: ({ readonly, schema, ...rest }) => (
|
|
19
18
|
<InputNumber
|
|
20
19
|
placeholder={I18n.t('Please Input Integer')}
|
|
21
20
|
size="small"
|
|
22
|
-
disabled={
|
|
21
|
+
disabled={readonly}
|
|
23
22
|
precision={0}
|
|
24
|
-
{...
|
|
23
|
+
{...rest}
|
|
25
24
|
/>
|
|
26
25
|
),
|
|
27
26
|
conditionRule: {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/* eslint-disable react/prop-types */
|
|
7
6
|
import React from 'react';
|
|
8
7
|
|
|
9
8
|
import { I18n } from '@flowgram.ai/editor';
|
|
@@ -15,13 +14,13 @@ import { type JsonSchemaTypeRegistry } from '../types';
|
|
|
15
14
|
|
|
16
15
|
export const numberRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
17
16
|
type: 'number',
|
|
18
|
-
ConstantRenderer: (
|
|
17
|
+
ConstantRenderer: ({ readonly, schema, ...rest }) => (
|
|
19
18
|
<InputNumber
|
|
20
19
|
placeholder={I18n.t('Please Input Number')}
|
|
21
20
|
size="small"
|
|
22
|
-
disabled={
|
|
21
|
+
disabled={readonly}
|
|
23
22
|
hideButtons
|
|
24
|
-
{...
|
|
23
|
+
{...rest}
|
|
25
24
|
/>
|
|
26
25
|
),
|
|
27
26
|
conditionRule: {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/* eslint-disable react/prop-types */
|
|
7
6
|
import React from 'react';
|
|
8
7
|
|
|
9
8
|
import { I18n } from '@flowgram.ai/editor';
|
|
@@ -15,21 +14,21 @@ import { type JsonSchemaTypeRegistry } from '../types';
|
|
|
15
14
|
|
|
16
15
|
export const stringRegistry: Partial<JsonSchemaTypeRegistry> = {
|
|
17
16
|
type: 'string',
|
|
18
|
-
ConstantRenderer: (
|
|
19
|
-
|
|
17
|
+
ConstantRenderer: ({ readonly, schema, enableMultiLineStr, ...rest }) =>
|
|
18
|
+
enableMultiLineStr ? (
|
|
20
19
|
<TextArea
|
|
21
20
|
autosize
|
|
22
21
|
rows={1}
|
|
23
22
|
placeholder={I18n.t('Please Input String')}
|
|
24
|
-
disabled={
|
|
25
|
-
{...
|
|
23
|
+
disabled={readonly}
|
|
24
|
+
{...rest}
|
|
26
25
|
/>
|
|
27
26
|
) : (
|
|
28
27
|
<Input
|
|
29
28
|
size="small"
|
|
30
29
|
placeholder={I18n.t('Please Input String')}
|
|
31
|
-
disabled={
|
|
32
|
-
{...
|
|
30
|
+
disabled={readonly}
|
|
31
|
+
{...rest}
|
|
33
32
|
/>
|
|
34
33
|
),
|
|
35
34
|
conditionRule: {
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type IJsonSchema,
|
|
8
|
+
JsonSchemaTypeRegistry as OriginJsonSchemaTypeRegistry,
|
|
9
|
+
} from '@flowgram.ai/json-schema';
|
|
7
10
|
|
|
8
11
|
import { IConditionRule, IConditionRuleFactory } from '@/components/condition-context/types';
|
|
9
12
|
|
|
@@ -11,9 +14,15 @@ export interface ConstantRendererProps<Value = any> {
|
|
|
11
14
|
value?: Value;
|
|
12
15
|
onChange?: (value: Value) => void;
|
|
13
16
|
readonly?: boolean;
|
|
17
|
+
schema?: IJsonSchema;
|
|
14
18
|
[key: string]: any;
|
|
15
19
|
}
|
|
16
20
|
export interface JsonSchemaTypeRegistry<Value = any> extends OriginJsonSchemaTypeRegistry {
|
|
21
|
+
/**
|
|
22
|
+
* The icon displayed when this type is used as an array item
|
|
23
|
+
*/
|
|
24
|
+
arrayIcon?: React.JSX.Element;
|
|
25
|
+
|
|
17
26
|
/**
|
|
18
27
|
* Render Constant Input
|
|
19
28
|
*/
|