@flowgram.ai/form-materials 1.0.1 → 1.0.3
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/assign-rows/index.js +8 -2
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tree.js +7 -3
- package/dist/cjs/components/display-outputs/index.js +3 -2
- package/dist/cjs/components/index.js +5 -1
- package/dist/cjs/components/json-schema-creator/index.js +36 -0
- package/dist/cjs/components/json-schema-creator/json-input-modal.js +96 -0
- package/dist/cjs/components/json-schema-creator/json-schema-creator.js +60 -0
- package/dist/cjs/components/json-schema-creator/utils/json-to-schema.js +67 -0
- package/dist/cjs/index.js +3 -0
- package/dist/esm/components/assign-rows/index.mjs +9 -3
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tree.mjs +8 -4
- package/dist/esm/components/display-outputs/index.mjs +4 -3
- package/dist/esm/components/index.mjs +2 -1
- package/dist/esm/components/json-schema-creator/index.mjs +2 -0
- package/dist/esm/components/json-schema-creator/json-input-modal.mjs +62 -0
- package/dist/esm/components/json-schema-creator/json-schema-creator.mjs +26 -0
- package/dist/esm/components/json-schema-creator/utils/json-to-schema.mjs +33 -0
- package/dist/esm/index.mjs +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/assign-rows/index.d.ts +2 -0
- package/dist/types/components/display-outputs/index.d.ts +2 -1
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/json-schema-creator/index.d.ts +6 -0
- package/dist/types/components/json-schema-creator/json-input-modal.d.ts +13 -0
- package/dist/types/components/json-schema-creator/json-schema-creator.d.ts +11 -0
- package/dist/types/components/json-schema-creator/utils/json-to-schema.d.ts +6 -0
- package/dist/types/index.d.ts +1 -1
- package/package.json +6 -6
- package/src/components/assign-rows/index.tsx +7 -6
- package/src/components/coze-editor-extensions/extensions/variable-tree.tsx +14 -4
- package/src/components/display-outputs/index.tsx +5 -4
- package/src/components/index.ts +1 -0
- package/src/components/json-schema-creator/index.tsx +7 -0
- package/src/components/json-schema-creator/json-input-modal.tsx +61 -0
- package/src/components/json-schema-creator/json-schema-creator.tsx +37 -0
- package/src/components/json-schema-creator/utils/json-to-schema.ts +50 -0
- package/src/index.ts +2 -0
|
@@ -33,10 +33,16 @@ const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
|
33
33
|
const semi_icons_namespaceObject = require("@douyinfe/semi-icons");
|
|
34
34
|
const index_js_namespaceObject = require("../assign-row/index.js");
|
|
35
35
|
function AssignRows(props) {
|
|
36
|
-
const { name, readonly } = props;
|
|
36
|
+
const { name, readonly, defaultValue } = props;
|
|
37
37
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(editor_namespaceObject.FieldArray, {
|
|
38
38
|
name: name,
|
|
39
|
-
|
|
39
|
+
defaultValue: defaultValue,
|
|
40
|
+
children: ({ field })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)("div", {
|
|
41
|
+
style: {
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: 'column',
|
|
44
|
+
gap: 5
|
|
45
|
+
},
|
|
40
46
|
children: [
|
|
41
47
|
field.map((childField, index)=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.AssignRow, {
|
|
42
48
|
readonly: readonly,
|
|
@@ -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 external_lodash_es_namespaceObject = require("lodash-es");
|
|
31
32
|
const react_namespaceObject = require("@flowgram.ai/coze-editor/react");
|
|
32
33
|
const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
33
34
|
const index_js_namespaceObject = require("../../variable-selector/index.js");
|
|
@@ -65,6 +66,7 @@ function VariableTree({ triggerCharacters = DEFAULT_TRIGGER_CHARACTER }) {
|
|
|
65
66
|
visible
|
|
66
67
|
]);
|
|
67
68
|
const treeData = (0, index_js_namespaceObject.useVariableTree)({});
|
|
69
|
+
const debounceUpdatePosKey = (0, external_react_namespaceObject.useCallback)((0, external_lodash_es_namespaceObject.debounce)(()=>setPosKey(String(Math.random())), 100), []);
|
|
68
70
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
69
71
|
children: [
|
|
70
72
|
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.Mention, {
|
|
@@ -84,8 +86,8 @@ function VariableTree({ triggerCharacters = DEFAULT_TRIGGER_CHARACTER }) {
|
|
|
84
86
|
},
|
|
85
87
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Tree, {
|
|
86
88
|
treeData: treeData,
|
|
87
|
-
onExpand: (
|
|
88
|
-
|
|
89
|
+
onExpand: ()=>{
|
|
90
|
+
debounceUpdatePosKey();
|
|
89
91
|
},
|
|
90
92
|
onSelect: (v)=>{
|
|
91
93
|
insert(v);
|
|
@@ -94,7 +96,9 @@ function VariableTree({ triggerCharacters = DEFAULT_TRIGGER_CHARACTER }) {
|
|
|
94
96
|
}),
|
|
95
97
|
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.PositionMirror, {
|
|
96
98
|
position: position,
|
|
97
|
-
onChange: ()=>
|
|
99
|
+
onChange: ()=>{
|
|
100
|
+
setPosKey(String(Math.random()));
|
|
101
|
+
}
|
|
98
102
|
})
|
|
99
103
|
})
|
|
100
104
|
]
|
|
@@ -32,10 +32,10 @@ const json_schema_namespaceObject = require("@flowgram.ai/json-schema");
|
|
|
32
32
|
const editor_namespaceObject = require("@flowgram.ai/editor");
|
|
33
33
|
const index_js_namespaceObject = require("../display-schema-tag/index.js");
|
|
34
34
|
require("./styles.css");
|
|
35
|
-
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
35
|
+
function DisplayOutputs({ value, showIconInTree, displayFromScope, style }) {
|
|
36
36
|
const scope = (0, editor_namespaceObject.useCurrentScope)();
|
|
37
37
|
const refresh = (0, editor_namespaceObject.useRefresh)();
|
|
38
|
-
(0, external_react_namespaceObject.
|
|
38
|
+
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
39
39
|
if (!displayFromScope || !scope) return ()=>null;
|
|
40
40
|
const disposable = scope.output.onListOrAnyVarChange(()=>{
|
|
41
41
|
refresh();
|
|
@@ -56,6 +56,7 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
56
56
|
const childEntries = Object.entries(properties || {});
|
|
57
57
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
58
58
|
className: "gedit-m-display-outputs-wrapper",
|
|
59
|
+
style: style,
|
|
59
60
|
children: childEntries.map(([key, schema])=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.DisplaySchemaTag, {
|
|
60
61
|
title: key,
|
|
61
62
|
value: schema,
|
|
@@ -70,7 +70,8 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
70
70
|
getTypeSelectValue: ()=>external_type_selector_index_js_namespaceObject.getTypeSelectValue,
|
|
71
71
|
DisplayInputsValues: ()=>external_display_inputs_values_index_js_namespaceObject.DisplayInputsValues,
|
|
72
72
|
BatchOutputs: ()=>external_batch_outputs_index_js_namespaceObject.BatchOutputs,
|
|
73
|
-
VariableSelector: ()=>external_variable_selector_index_js_namespaceObject.VariableSelector
|
|
73
|
+
VariableSelector: ()=>external_variable_selector_index_js_namespaceObject.VariableSelector,
|
|
74
|
+
JsonSchemaCreator: ()=>external_json_schema_creator_index_js_namespaceObject.JsonSchemaCreator
|
|
74
75
|
});
|
|
75
76
|
const index_js_namespaceObject = require("./assign-row/index.js");
|
|
76
77
|
const external_assign_rows_index_js_namespaceObject = require("./assign-rows/index.js");
|
|
@@ -93,6 +94,7 @@ const external_dynamic_value_input_index_js_namespaceObject = require("./dynamic
|
|
|
93
94
|
const external_inputs_values_index_js_namespaceObject = require("./inputs-values/index.js");
|
|
94
95
|
const external_inputs_values_tree_index_js_namespaceObject = require("./inputs-values-tree/index.js");
|
|
95
96
|
const external_json_editor_with_variables_index_js_namespaceObject = require("./json-editor-with-variables/index.js");
|
|
97
|
+
const external_json_schema_creator_index_js_namespaceObject = require("./json-schema-creator/index.js");
|
|
96
98
|
const external_json_schema_editor_index_js_namespaceObject = require("./json-schema-editor/index.js");
|
|
97
99
|
const external_prompt_editor_index_js_namespaceObject = require("./prompt-editor/index.js");
|
|
98
100
|
const external_prompt_editor_with_inputs_index_js_namespaceObject = require("./prompt-editor-with-inputs/index.js");
|
|
@@ -130,6 +132,7 @@ exports.InputsValues = __webpack_exports__.InputsValues;
|
|
|
130
132
|
exports.InputsValuesTree = __webpack_exports__.InputsValuesTree;
|
|
131
133
|
exports.JsonCodeEditor = __webpack_exports__.JsonCodeEditor;
|
|
132
134
|
exports.JsonEditorWithVariables = __webpack_exports__.JsonEditorWithVariables;
|
|
135
|
+
exports.JsonSchemaCreator = __webpack_exports__.JsonSchemaCreator;
|
|
133
136
|
exports.JsonSchemaEditor = __webpack_exports__.JsonSchemaEditor;
|
|
134
137
|
exports.PromptEditor = __webpack_exports__.PromptEditor;
|
|
135
138
|
exports.PromptEditorWithInputs = __webpack_exports__.PromptEditorWithInputs;
|
|
@@ -178,6 +181,7 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
178
181
|
"InputsValuesTree",
|
|
179
182
|
"JsonCodeEditor",
|
|
180
183
|
"JsonEditorWithVariables",
|
|
184
|
+
"JsonSchemaCreator",
|
|
181
185
|
"JsonSchemaEditor",
|
|
182
186
|
"PromptEditor",
|
|
183
187
|
"PromptEditorWithInputs",
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
JsonSchemaCreator: ()=>external_json_schema_creator_js_namespaceObject.JsonSchemaCreator
|
|
28
|
+
});
|
|
29
|
+
const external_json_schema_creator_js_namespaceObject = require("./json-schema-creator.js");
|
|
30
|
+
exports.JsonSchemaCreator = __webpack_exports__.JsonSchemaCreator;
|
|
31
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
32
|
+
"JsonSchemaCreator"
|
|
33
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
34
|
+
Object.defineProperty(exports, '__esModule', {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
JsonInputModal: ()=>JsonInputModal
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
const editor_namespaceObject = require("@flowgram.ai/editor");
|
|
32
|
+
const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
33
|
+
const json_to_schema_js_namespaceObject = require("./utils/json-to-schema.js");
|
|
34
|
+
const index_js_namespaceObject = require("../code-editor/index.js");
|
|
35
|
+
const { Text } = semi_ui_namespaceObject.Typography;
|
|
36
|
+
function JsonInputModal({ visible, onClose, onConfirm }) {
|
|
37
|
+
const [jsonInput, setJsonInput] = (0, external_react_namespaceObject.useState)('');
|
|
38
|
+
const [error, setError] = (0, external_react_namespaceObject.useState)('');
|
|
39
|
+
const handleConfirm = ()=>{
|
|
40
|
+
try {
|
|
41
|
+
const schema = (0, json_to_schema_js_namespaceObject.jsonToSchema)(jsonInput);
|
|
42
|
+
onConfirm(schema);
|
|
43
|
+
setJsonInput('');
|
|
44
|
+
setError('');
|
|
45
|
+
} catch (err) {
|
|
46
|
+
setError(err.message);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(semi_ui_namespaceObject.Modal, {
|
|
50
|
+
visible: visible,
|
|
51
|
+
onCancel: onClose,
|
|
52
|
+
onOk: handleConfirm,
|
|
53
|
+
title: editor_namespaceObject.I18n.t('JSON to JSONSchema'),
|
|
54
|
+
okText: editor_namespaceObject.I18n.t('Generate'),
|
|
55
|
+
cancelText: editor_namespaceObject.I18n.t('Cancel'),
|
|
56
|
+
width: 600,
|
|
57
|
+
children: [
|
|
58
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
59
|
+
style: {
|
|
60
|
+
marginBottom: 8
|
|
61
|
+
},
|
|
62
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(Text, {
|
|
63
|
+
children: [
|
|
64
|
+
editor_namespaceObject.I18n.t('Paste JSON data'),
|
|
65
|
+
":"
|
|
66
|
+
]
|
|
67
|
+
})
|
|
68
|
+
}),
|
|
69
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
70
|
+
style: {
|
|
71
|
+
minHeight: 300
|
|
72
|
+
},
|
|
73
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.JsonCodeEditor, {
|
|
74
|
+
value: jsonInput,
|
|
75
|
+
onChange: (value)=>setJsonInput(value || '')
|
|
76
|
+
})
|
|
77
|
+
}),
|
|
78
|
+
error && /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
79
|
+
style: {
|
|
80
|
+
marginTop: 8
|
|
81
|
+
},
|
|
82
|
+
children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(Text, {
|
|
83
|
+
type: "danger",
|
|
84
|
+
children: error
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
exports.JsonInputModal = __webpack_exports__.JsonInputModal;
|
|
91
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
92
|
+
"JsonInputModal"
|
|
93
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
94
|
+
Object.defineProperty(exports, '__esModule', {
|
|
95
|
+
value: true
|
|
96
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
JsonSchemaCreator: ()=>JsonSchemaCreator
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_react_namespaceObject = require("react");
|
|
31
|
+
const editor_namespaceObject = require("@flowgram.ai/editor");
|
|
32
|
+
const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
|
|
33
|
+
const external_json_input_modal_js_namespaceObject = require("./json-input-modal.js");
|
|
34
|
+
function JsonSchemaCreator({ onSchemaCreate }) {
|
|
35
|
+
const [visible, setVisible] = (0, external_react_namespaceObject.useState)(false);
|
|
36
|
+
const handleCreate = (schema)=>{
|
|
37
|
+
onSchemaCreate?.(schema);
|
|
38
|
+
setVisible(false);
|
|
39
|
+
};
|
|
40
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
|
|
41
|
+
children: [
|
|
42
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Button, {
|
|
43
|
+
onClick: ()=>setVisible(true),
|
|
44
|
+
children: editor_namespaceObject.I18n.t('JSON to JSONSchema')
|
|
45
|
+
}),
|
|
46
|
+
/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_json_input_modal_js_namespaceObject.JsonInputModal, {
|
|
47
|
+
visible: visible,
|
|
48
|
+
onClose: ()=>setVisible(false),
|
|
49
|
+
onConfirm: handleCreate
|
|
50
|
+
})
|
|
51
|
+
]
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
exports.JsonSchemaCreator = __webpack_exports__.JsonSchemaCreator;
|
|
55
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
56
|
+
"JsonSchemaCreator"
|
|
57
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
58
|
+
Object.defineProperty(exports, '__esModule', {
|
|
59
|
+
value: true
|
|
60
|
+
});
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
jsonToSchema: ()=>jsonToSchema
|
|
28
|
+
});
|
|
29
|
+
function jsonToSchema(jsonString) {
|
|
30
|
+
const data = JSON.parse(jsonString);
|
|
31
|
+
return generateSchema(data);
|
|
32
|
+
}
|
|
33
|
+
function generateSchema(value) {
|
|
34
|
+
if (null === value) return {
|
|
35
|
+
type: 'string'
|
|
36
|
+
};
|
|
37
|
+
if (Array.isArray(value)) {
|
|
38
|
+
const schema = {
|
|
39
|
+
type: 'array'
|
|
40
|
+
};
|
|
41
|
+
if (value.length > 0) schema.items = generateSchema(value[0]);
|
|
42
|
+
return schema;
|
|
43
|
+
}
|
|
44
|
+
if ('object' == typeof value) {
|
|
45
|
+
const schema = {
|
|
46
|
+
type: 'object',
|
|
47
|
+
properties: {},
|
|
48
|
+
required: []
|
|
49
|
+
};
|
|
50
|
+
for (const [key, val] of Object.entries(value)){
|
|
51
|
+
schema.properties[key] = generateSchema(val);
|
|
52
|
+
schema.required.push(key);
|
|
53
|
+
}
|
|
54
|
+
return schema;
|
|
55
|
+
}
|
|
56
|
+
const type = typeof value;
|
|
57
|
+
return {
|
|
58
|
+
type: type
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.jsonToSchema = __webpack_exports__.jsonToSchema;
|
|
62
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
63
|
+
"jsonToSchema"
|
|
64
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
65
|
+
Object.defineProperty(exports, '__esModule', {
|
|
66
|
+
value: true
|
|
67
|
+
});
|
package/dist/cjs/index.js
CHANGED
|
@@ -62,6 +62,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
62
62
|
BatchOutputs: ()=>index_js_namespaceObject.BatchOutputs,
|
|
63
63
|
polyfillCreateRoot: ()=>external_shared_index_js_namespaceObject.polyfillCreateRoot,
|
|
64
64
|
VariableSelector: ()=>index_js_namespaceObject.VariableSelector,
|
|
65
|
+
JsonSchemaCreator: ()=>index_js_namespaceObject.JsonSchemaCreator,
|
|
65
66
|
BatchVariableSelector: ()=>index_js_namespaceObject.BatchVariableSelector,
|
|
66
67
|
AssignRow: ()=>index_js_namespaceObject.AssignRow,
|
|
67
68
|
createInferAssignPlugin: ()=>external_form_plugins_index_js_namespaceObject.createInferAssignPlugin,
|
|
@@ -140,6 +141,7 @@ exports.InputsValues = __webpack_exports__.InputsValues;
|
|
|
140
141
|
exports.InputsValuesTree = __webpack_exports__.InputsValuesTree;
|
|
141
142
|
exports.JsonCodeEditor = __webpack_exports__.JsonCodeEditor;
|
|
142
143
|
exports.JsonEditorWithVariables = __webpack_exports__.JsonEditorWithVariables;
|
|
144
|
+
exports.JsonSchemaCreator = __webpack_exports__.JsonSchemaCreator;
|
|
143
145
|
exports.JsonSchemaEditor = __webpack_exports__.JsonSchemaEditor;
|
|
144
146
|
exports.JsonSchemaTypePresetProvider = __webpack_exports__.JsonSchemaTypePresetProvider;
|
|
145
147
|
exports.JsonSchemaUtils = __webpack_exports__.JsonSchemaUtils;
|
|
@@ -218,6 +220,7 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
|
218
220
|
"InputsValuesTree",
|
|
219
221
|
"JsonCodeEditor",
|
|
220
222
|
"JsonEditorWithVariables",
|
|
223
|
+
"JsonSchemaCreator",
|
|
221
224
|
"JsonSchemaEditor",
|
|
222
225
|
"JsonSchemaTypePresetProvider",
|
|
223
226
|
"JsonSchemaUtils",
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import { FieldArray } from "@flowgram.ai/editor";
|
|
4
4
|
import { Button } from "@douyinfe/semi-ui";
|
|
5
5
|
import { IconPlus } from "@douyinfe/semi-icons";
|
|
6
6
|
import { AssignRow } from "../assign-row/index.mjs";
|
|
7
7
|
function AssignRows(props) {
|
|
8
|
-
const { name, readonly } = props;
|
|
8
|
+
const { name, readonly, defaultValue } = props;
|
|
9
9
|
return /*#__PURE__*/ jsx(FieldArray, {
|
|
10
10
|
name: name,
|
|
11
|
-
|
|
11
|
+
defaultValue: defaultValue,
|
|
12
|
+
children: ({ field })=>/*#__PURE__*/ jsxs("div", {
|
|
13
|
+
style: {
|
|
14
|
+
display: 'flex',
|
|
15
|
+
flexDirection: 'column',
|
|
16
|
+
gap: 5
|
|
17
|
+
},
|
|
12
18
|
children: [
|
|
13
19
|
field.map((childField, index)=>/*#__PURE__*/ jsx(AssignRow, {
|
|
14
20
|
readonly: readonly,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
2
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
|
+
import { debounce } from "lodash-es";
|
|
3
4
|
import { Mention, PositionMirror, getCurrentMentionReplaceRange, useEditor } from "@flowgram.ai/coze-editor/react";
|
|
4
5
|
import { Popover, Tree } from "@douyinfe/semi-ui";
|
|
5
6
|
import { useVariableTree } from "../../variable-selector/index.mjs";
|
|
@@ -37,6 +38,7 @@ function VariableTree({ triggerCharacters = DEFAULT_TRIGGER_CHARACTER }) {
|
|
|
37
38
|
visible
|
|
38
39
|
]);
|
|
39
40
|
const treeData = useVariableTree({});
|
|
41
|
+
const debounceUpdatePosKey = useCallback(debounce(()=>setPosKey(String(Math.random())), 100), []);
|
|
40
42
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
41
43
|
children: [
|
|
42
44
|
/*#__PURE__*/ jsx(Mention, {
|
|
@@ -56,8 +58,8 @@ function VariableTree({ triggerCharacters = DEFAULT_TRIGGER_CHARACTER }) {
|
|
|
56
58
|
},
|
|
57
59
|
children: /*#__PURE__*/ jsx(Tree, {
|
|
58
60
|
treeData: treeData,
|
|
59
|
-
onExpand: (
|
|
60
|
-
|
|
61
|
+
onExpand: ()=>{
|
|
62
|
+
debounceUpdatePosKey();
|
|
61
63
|
},
|
|
62
64
|
onSelect: (v)=>{
|
|
63
65
|
insert(v);
|
|
@@ -66,7 +68,9 @@ function VariableTree({ triggerCharacters = DEFAULT_TRIGGER_CHARACTER }) {
|
|
|
66
68
|
}),
|
|
67
69
|
children: /*#__PURE__*/ jsx(PositionMirror, {
|
|
68
70
|
position: position,
|
|
69
|
-
onChange: ()=>
|
|
71
|
+
onChange: ()=>{
|
|
72
|
+
setPosKey(String(Math.random()));
|
|
73
|
+
}
|
|
70
74
|
})
|
|
71
75
|
})
|
|
72
76
|
]
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { useLayoutEffect } from "react";
|
|
3
3
|
import { JsonSchemaUtils } from "@flowgram.ai/json-schema";
|
|
4
4
|
import { useCurrentScope, useRefresh } from "@flowgram.ai/editor";
|
|
5
5
|
import { DisplaySchemaTag } from "../display-schema-tag/index.mjs";
|
|
6
6
|
import "./styles.css";
|
|
7
|
-
function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
7
|
+
function DisplayOutputs({ value, showIconInTree, displayFromScope, style }) {
|
|
8
8
|
const scope = useCurrentScope();
|
|
9
9
|
const refresh = useRefresh();
|
|
10
|
-
|
|
10
|
+
useLayoutEffect(()=>{
|
|
11
11
|
if (!displayFromScope || !scope) return ()=>null;
|
|
12
12
|
const disposable = scope.output.onListOrAnyVarChange(()=>{
|
|
13
13
|
refresh();
|
|
@@ -28,6 +28,7 @@ function DisplayOutputs({ value, showIconInTree, displayFromScope }) {
|
|
|
28
28
|
const childEntries = Object.entries(properties || {});
|
|
29
29
|
return /*#__PURE__*/ jsx("div", {
|
|
30
30
|
className: "gedit-m-display-outputs-wrapper",
|
|
31
|
+
style: style,
|
|
31
32
|
children: childEntries.map(([key, schema])=>/*#__PURE__*/ jsx(DisplaySchemaTag, {
|
|
32
33
|
title: key,
|
|
33
34
|
value: schema,
|
|
@@ -19,6 +19,7 @@ import { DynamicValueInput, InjectDynamicValueInput } from "./dynamic-value-inpu
|
|
|
19
19
|
import { InputsValues } from "./inputs-values/index.mjs";
|
|
20
20
|
import { InputsValuesTree } from "./inputs-values-tree/index.mjs";
|
|
21
21
|
import { JsonEditorWithVariables } from "./json-editor-with-variables/index.mjs";
|
|
22
|
+
import { JsonSchemaCreator } from "./json-schema-creator/index.mjs";
|
|
22
23
|
import { JsonSchemaEditor } from "./json-schema-editor/index.mjs";
|
|
23
24
|
import { PromptEditor } from "./prompt-editor/index.mjs";
|
|
24
25
|
import { PromptEditorWithInputs } from "./prompt-editor-with-inputs/index.mjs";
|
|
@@ -26,4 +27,4 @@ import { PromptEditorWithVariables } from "./prompt-editor-with-variables/index.
|
|
|
26
27
|
import { SQLEditorWithVariables } from "./sql-editor-with-variables/index.mjs";
|
|
27
28
|
import { InjectTypeSelector, TypeSelector, getTypeSelectValue, parseTypeSelectValue } from "./type-selector/index.mjs";
|
|
28
29
|
import { InjectVariableSelector, VariableSelector, VariableSelectorProvider, useVariableTree } from "./variable-selector/index.mjs";
|
|
29
|
-
export { AssignRow, AssignRows, BaseCodeEditor, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionPresetOp, ConditionProvider, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonCodeEditor, JsonEditorWithVariables, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, PythonCodeEditor, SQLCodeEditor, SQLEditorWithVariables, ShellCodeEditor, TypeScriptCodeEditor, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, useCondition, useConditionContext, useVariableTree };
|
|
30
|
+
export { AssignRow, AssignRows, BaseCodeEditor, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionPresetOp, ConditionProvider, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonCodeEditor, JsonEditorWithVariables, JsonSchemaCreator, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, PythonCodeEditor, SQLCodeEditor, SQLEditorWithVariables, ShellCodeEditor, TypeScriptCodeEditor, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, useCondition, useConditionContext, useVariableTree };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { I18n } from "@flowgram.ai/editor";
|
|
4
|
+
import { Modal, Typography } from "@douyinfe/semi-ui";
|
|
5
|
+
import { jsonToSchema } from "./utils/json-to-schema.mjs";
|
|
6
|
+
import { JsonCodeEditor } from "../code-editor/index.mjs";
|
|
7
|
+
const { Text } = Typography;
|
|
8
|
+
function JsonInputModal({ visible, onClose, onConfirm }) {
|
|
9
|
+
const [jsonInput, setJsonInput] = useState('');
|
|
10
|
+
const [error, setError] = useState('');
|
|
11
|
+
const handleConfirm = ()=>{
|
|
12
|
+
try {
|
|
13
|
+
const schema = jsonToSchema(jsonInput);
|
|
14
|
+
onConfirm(schema);
|
|
15
|
+
setJsonInput('');
|
|
16
|
+
setError('');
|
|
17
|
+
} catch (err) {
|
|
18
|
+
setError(err.message);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return /*#__PURE__*/ jsxs(Modal, {
|
|
22
|
+
visible: visible,
|
|
23
|
+
onCancel: onClose,
|
|
24
|
+
onOk: handleConfirm,
|
|
25
|
+
title: I18n.t('JSON to JSONSchema'),
|
|
26
|
+
okText: I18n.t('Generate'),
|
|
27
|
+
cancelText: I18n.t('Cancel'),
|
|
28
|
+
width: 600,
|
|
29
|
+
children: [
|
|
30
|
+
/*#__PURE__*/ jsx("div", {
|
|
31
|
+
style: {
|
|
32
|
+
marginBottom: 8
|
|
33
|
+
},
|
|
34
|
+
children: /*#__PURE__*/ jsxs(Text, {
|
|
35
|
+
children: [
|
|
36
|
+
I18n.t('Paste JSON data'),
|
|
37
|
+
":"
|
|
38
|
+
]
|
|
39
|
+
})
|
|
40
|
+
}),
|
|
41
|
+
/*#__PURE__*/ jsx("div", {
|
|
42
|
+
style: {
|
|
43
|
+
minHeight: 300
|
|
44
|
+
},
|
|
45
|
+
children: /*#__PURE__*/ jsx(JsonCodeEditor, {
|
|
46
|
+
value: jsonInput,
|
|
47
|
+
onChange: (value)=>setJsonInput(value || '')
|
|
48
|
+
})
|
|
49
|
+
}),
|
|
50
|
+
error && /*#__PURE__*/ jsx("div", {
|
|
51
|
+
style: {
|
|
52
|
+
marginTop: 8
|
|
53
|
+
},
|
|
54
|
+
children: /*#__PURE__*/ jsx(Text, {
|
|
55
|
+
type: "danger",
|
|
56
|
+
children: error
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
export { JsonInputModal };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { I18n } from "@flowgram.ai/editor";
|
|
4
|
+
import { Button } from "@douyinfe/semi-ui";
|
|
5
|
+
import { JsonInputModal } from "./json-input-modal.mjs";
|
|
6
|
+
function JsonSchemaCreator({ onSchemaCreate }) {
|
|
7
|
+
const [visible, setVisible] = useState(false);
|
|
8
|
+
const handleCreate = (schema)=>{
|
|
9
|
+
onSchemaCreate?.(schema);
|
|
10
|
+
setVisible(false);
|
|
11
|
+
};
|
|
12
|
+
return /*#__PURE__*/ jsxs(Fragment, {
|
|
13
|
+
children: [
|
|
14
|
+
/*#__PURE__*/ jsx(Button, {
|
|
15
|
+
onClick: ()=>setVisible(true),
|
|
16
|
+
children: I18n.t('JSON to JSONSchema')
|
|
17
|
+
}),
|
|
18
|
+
/*#__PURE__*/ jsx(JsonInputModal, {
|
|
19
|
+
visible: visible,
|
|
20
|
+
onClose: ()=>setVisible(false),
|
|
21
|
+
onConfirm: handleCreate
|
|
22
|
+
})
|
|
23
|
+
]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export { JsonSchemaCreator };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function jsonToSchema(jsonString) {
|
|
2
|
+
const data = JSON.parse(jsonString);
|
|
3
|
+
return generateSchema(data);
|
|
4
|
+
}
|
|
5
|
+
function generateSchema(value) {
|
|
6
|
+
if (null === value) return {
|
|
7
|
+
type: 'string'
|
|
8
|
+
};
|
|
9
|
+
if (Array.isArray(value)) {
|
|
10
|
+
const schema = {
|
|
11
|
+
type: 'array'
|
|
12
|
+
};
|
|
13
|
+
if (value.length > 0) schema.items = generateSchema(value[0]);
|
|
14
|
+
return schema;
|
|
15
|
+
}
|
|
16
|
+
if ('object' == typeof value) {
|
|
17
|
+
const schema = {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {},
|
|
20
|
+
required: []
|
|
21
|
+
};
|
|
22
|
+
for (const [key, val] of Object.entries(value)){
|
|
23
|
+
schema.properties[key] = generateSchema(val);
|
|
24
|
+
schema.required.push(key);
|
|
25
|
+
}
|
|
26
|
+
return schema;
|
|
27
|
+
}
|
|
28
|
+
const type = typeof value;
|
|
29
|
+
return {
|
|
30
|
+
type: type
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export { jsonToSchema };
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AssignRow, AssignRows, BaseCodeEditor, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionPresetOp, ConditionProvider, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonCodeEditor, JsonEditorWithVariables, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, PythonCodeEditor, SQLCodeEditor, SQLEditorWithVariables, ShellCodeEditor, TypeScriptCodeEditor, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, useCondition, useConditionContext, useVariableTree } from "./components/index.mjs";
|
|
1
|
+
import { AssignRow, AssignRows, BaseCodeEditor, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionPresetOp, ConditionProvider, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonCodeEditor, JsonEditorWithVariables, JsonSchemaCreator, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, PythonCodeEditor, SQLCodeEditor, SQLEditorWithVariables, ShellCodeEditor, TypeScriptCodeEditor, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, useCondition, useConditionContext, useVariableTree } from "./components/index.mjs";
|
|
2
2
|
import { autoRenameRefEffect, listenRefSchemaChange, listenRefValueChange, provideBatchInputEffect, provideJsonSchemaOutputs, syncVariableTitle, validateWhenVariableSync } from "./effects/index.mjs";
|
|
3
3
|
import { createBatchOutputsFormPlugin, createInferAssignPlugin, createInferInputsPlugin, provideBatchOutputsEffect } from "./form-plugins/index.mjs";
|
|
4
4
|
import { useObjectList } from "./hooks/index.mjs";
|
|
5
5
|
import { JsonSchemaTypePresetProvider, JsonSchemaUtils, createDisableDeclarationPlugin, createTypePresetPlugin, useTypeManager } from "./plugins/index.mjs";
|
|
6
6
|
import { FlowValueUtils, createInjectMaterial, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, lazySuspense, polyfillCreateRoot, unstableSetCreateRoot, withSuspense } from "./shared/index.mjs";
|
|
7
7
|
import { validateFlowValue } from "./validate/index.mjs";
|
|
8
|
-
export { AssignRow, AssignRows, BaseCodeEditor, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionPresetOp, ConditionProvider, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, FlowValueUtils, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonCodeEditor, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, JsonSchemaUtils, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, PythonCodeEditor, SQLCodeEditor, SQLEditorWithVariables, ShellCodeEditor, TypeScriptCodeEditor, TypeSelector, VariableSelector, VariableSelectorProvider, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferAssignPlugin, createInferInputsPlugin, createInjectMaterial, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, lazySuspense, listenRefSchemaChange, listenRefValueChange, parseTypeSelectValue, polyfillCreateRoot, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, unstableSetCreateRoot, useCondition, useConditionContext, useObjectList, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync, withSuspense };
|
|
8
|
+
export { AssignRow, AssignRows, BaseCodeEditor, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionPresetOp, ConditionProvider, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, FlowValueUtils, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonCodeEditor, JsonEditorWithVariables, JsonSchemaCreator, JsonSchemaEditor, JsonSchemaTypePresetProvider, JsonSchemaUtils, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, PythonCodeEditor, SQLCodeEditor, SQLEditorWithVariables, ShellCodeEditor, TypeScriptCodeEditor, TypeSelector, VariableSelector, VariableSelectorProvider, autoRenameRefEffect, createBatchOutputsFormPlugin, createDisableDeclarationPlugin, createInferAssignPlugin, createInferInputsPlugin, createInjectMaterial, createTypePresetPlugin, formatLegacyRefOnInit, formatLegacyRefOnSubmit, formatLegacyRefToNewRef, formatNewRefToLegacyRef, getTypeSelectValue, isLegacyFlowRefValueSchema, isNewFlowRefValueSchema, lazySuspense, listenRefSchemaChange, listenRefValueChange, parseTypeSelectValue, polyfillCreateRoot, provideBatchInputEffect, provideBatchOutputsEffect, provideJsonSchemaOutputs, syncVariableTitle, unstableSetCreateRoot, useCondition, useConditionContext, useObjectList, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync, withSuspense };
|
|
@@ -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-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/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"}
|
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { AssignValueType } from '../assign-row';
|
|
6
7
|
interface AssignRowsProps {
|
|
7
8
|
name: string;
|
|
8
9
|
readonly?: boolean;
|
|
10
|
+
defaultValue?: AssignValueType[];
|
|
9
11
|
}
|
|
10
12
|
export declare function AssignRows(props: AssignRowsProps): React.JSX.Element;
|
|
11
13
|
export {};
|
|
@@ -10,6 +10,7 @@ interface PropsType {
|
|
|
10
10
|
showIconInTree?: boolean;
|
|
11
11
|
displayFromScope?: boolean;
|
|
12
12
|
typeManager?: JsonSchemaTypeManager;
|
|
13
|
+
style?: React.CSSProperties;
|
|
13
14
|
}
|
|
14
|
-
export declare function DisplayOutputs({ value, showIconInTree, displayFromScope }: PropsType): React.JSX.Element;
|
|
15
|
+
export declare function DisplayOutputs({ value, showIconInTree, displayFromScope, style }: PropsType): React.JSX.Element;
|
|
15
16
|
export {};
|
|
@@ -23,6 +23,7 @@ export { DynamicValueInput, InjectDynamicValueInput } from './dynamic-value-inpu
|
|
|
23
23
|
export { InputsValues } from './inputs-values';
|
|
24
24
|
export { InputsValuesTree } from './inputs-values-tree';
|
|
25
25
|
export { JsonEditorWithVariables, type JsonEditorWithVariablesProps, } from './json-editor-with-variables';
|
|
26
|
+
export { JsonSchemaCreator, type JsonSchemaCreatorProps } from './json-schema-creator';
|
|
26
27
|
export { JsonSchemaEditor } from './json-schema-editor';
|
|
27
28
|
export { PromptEditor, type PromptEditorPropsType } from './prompt-editor';
|
|
28
29
|
export { PromptEditorWithInputs, type PromptEditorWithInputsProps, } from './prompt-editor-with-inputs';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
7
|
+
interface JsonInputModalProps {
|
|
8
|
+
visible: boolean;
|
|
9
|
+
onClose: () => void;
|
|
10
|
+
onConfirm: (schema: IJsonSchema) => void;
|
|
11
|
+
}
|
|
12
|
+
export declare function JsonInputModal({ visible, onClose, onConfirm }: JsonInputModalProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
7
|
+
export interface JsonSchemaCreatorProps {
|
|
8
|
+
/** 生成 schema 后的回调 */
|
|
9
|
+
onSchemaCreate?: (schema: IJsonSchema) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function JsonSchemaCreator({ onSchemaCreate }: JsonSchemaCreatorProps): React.JSX.Element;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
export { AssignRow, AssignRows, BaseCodeEditor, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionPresetOp, ConditionProvider, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonCodeEditor, JsonEditorWithVariables, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, PythonCodeEditor, SQLCodeEditor, SQLEditorWithVariables, ShellCodeEditor, TypeScriptCodeEditor, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, type AssignValueType, type CodeEditorPropsType, type ConditionOpConfig, type ConditionOpConfigs, type ConditionRowValueType, type ConstantInputStrategy, type DBConditionOptionType, type DBConditionRowValueType, type IConditionRule, type IConditionRuleFactory, type JsonEditorWithVariablesProps, type PromptEditorPropsType, type PromptEditorWithInputsProps, type PromptEditorWithVariablesProps, type SQLEditorWithVariablesProps, type TypeSelectorProps, type VariableSelectorProps, useCondition, useConditionContext, useVariableTree, } from './components';
|
|
5
|
+
export { AssignRow, AssignRows, BaseCodeEditor, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionPresetOp, ConditionProvider, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonCodeEditor, JsonEditorWithVariables, JsonSchemaCreator, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, PythonCodeEditor, SQLCodeEditor, SQLEditorWithVariables, ShellCodeEditor, TypeScriptCodeEditor, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, type AssignValueType, type CodeEditorPropsType, type ConditionOpConfig, type ConditionOpConfigs, type ConditionRowValueType, type ConstantInputStrategy, type DBConditionOptionType, type DBConditionRowValueType, type IConditionRule, type IConditionRuleFactory, type JsonEditorWithVariablesProps, type JsonSchemaCreatorProps, type PromptEditorPropsType, type PromptEditorWithInputsProps, type PromptEditorWithVariablesProps, type SQLEditorWithVariablesProps, type TypeSelectorProps, type VariableSelectorProps, useCondition, useConditionContext, useVariableTree, } from './components';
|
|
6
6
|
export { autoRenameRefEffect, listenRefSchemaChange, listenRefValueChange, provideBatchInputEffect, provideJsonSchemaOutputs, syncVariableTitle, validateWhenVariableSync, } from './effects';
|
|
7
7
|
export { createBatchOutputsFormPlugin, createInferAssignPlugin, createInferInputsPlugin, provideBatchOutputsEffect, } from './form-plugins';
|
|
8
8
|
export { useObjectList } from './hooks';
|
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.3",
|
|
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/view": "~6.38.0",
|
|
68
68
|
"@codemirror/state": "~6.5.2",
|
|
69
69
|
"zod": "^3.24.4",
|
|
70
|
-
"@flowgram.ai/editor": "1.0.
|
|
71
|
-
"@flowgram.ai/
|
|
72
|
-
"@flowgram.ai/
|
|
70
|
+
"@flowgram.ai/editor": "1.0.3",
|
|
71
|
+
"@flowgram.ai/coze-editor": "1.0.3",
|
|
72
|
+
"@flowgram.ai/json-schema": "1.0.3"
|
|
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.3",
|
|
90
|
+
"@flowgram.ai/eslint-config": "1.0.3"
|
|
91
91
|
},
|
|
92
92
|
"peerDependencies": {
|
|
93
93
|
"react": ">=16.8",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import { FieldArray
|
|
8
|
+
import { FieldArray } from '@flowgram.ai/editor';
|
|
9
9
|
import { Button } from '@douyinfe/semi-ui';
|
|
10
10
|
import { IconPlus } from '@douyinfe/semi-icons';
|
|
11
11
|
|
|
@@ -14,15 +14,16 @@ import { AssignRow, AssignValueType } from '@/components/assign-row';
|
|
|
14
14
|
interface AssignRowsProps {
|
|
15
15
|
name: string;
|
|
16
16
|
readonly?: boolean;
|
|
17
|
+
defaultValue?: AssignValueType[];
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
export function AssignRows(props: AssignRowsProps) {
|
|
20
|
-
const { name, readonly } = props;
|
|
21
|
+
const { name, readonly, defaultValue } = props;
|
|
21
22
|
|
|
22
23
|
return (
|
|
23
|
-
<FieldArray name={name}>
|
|
24
|
-
{({ field }
|
|
25
|
-
|
|
24
|
+
<FieldArray<AssignValueType | undefined> name={name} defaultValue={defaultValue}>
|
|
25
|
+
{({ field }) => (
|
|
26
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>
|
|
26
27
|
{field.map((childField, index) => (
|
|
27
28
|
<AssignRow
|
|
28
29
|
key={childField.key}
|
|
@@ -52,7 +53,7 @@ export function AssignRows(props: AssignRowsProps) {
|
|
|
52
53
|
Declaration
|
|
53
54
|
</Button>
|
|
54
55
|
</div>
|
|
55
|
-
|
|
56
|
+
</div>
|
|
56
57
|
)}
|
|
57
58
|
</FieldArray>
|
|
58
59
|
);
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
|
+
import { debounce } from 'lodash-es';
|
|
8
9
|
import {
|
|
9
10
|
Mention,
|
|
10
11
|
MentionOpenChangeEvent,
|
|
@@ -69,6 +70,11 @@ export function VariableTree({
|
|
|
69
70
|
|
|
70
71
|
const treeData = useVariableTree({});
|
|
71
72
|
|
|
73
|
+
const debounceUpdatePosKey = useCallback(
|
|
74
|
+
debounce(() => setPosKey(String(Math.random())), 100),
|
|
75
|
+
[]
|
|
76
|
+
);
|
|
77
|
+
|
|
72
78
|
return (
|
|
73
79
|
<>
|
|
74
80
|
<Mention triggerCharacters={triggerCharacters} onOpenChange={handleOpenChange} />
|
|
@@ -82,8 +88,9 @@ export function VariableTree({
|
|
|
82
88
|
<div style={{ width: 300, maxHeight: 300, overflowY: 'auto' }}>
|
|
83
89
|
<Tree
|
|
84
90
|
treeData={treeData}
|
|
85
|
-
onExpand={(
|
|
86
|
-
|
|
91
|
+
onExpand={() => {
|
|
92
|
+
// When Expand, an animation is triggered, so we need to update the position by debounce
|
|
93
|
+
debounceUpdatePosKey();
|
|
87
94
|
}}
|
|
88
95
|
onSelect={(v) => {
|
|
89
96
|
insert(v);
|
|
@@ -96,7 +103,10 @@ export function VariableTree({
|
|
|
96
103
|
<PositionMirror
|
|
97
104
|
position={position}
|
|
98
105
|
// When Doc scroll, update position
|
|
99
|
-
onChange={() =>
|
|
106
|
+
onChange={() => {
|
|
107
|
+
// Update immediately to avoid the popover position lagging behind the cursor
|
|
108
|
+
setPosKey(String(Math.random()));
|
|
109
|
+
}}
|
|
100
110
|
/>
|
|
101
111
|
</Popover>
|
|
102
112
|
</>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, {
|
|
6
|
+
import React, { useLayoutEffect } from 'react';
|
|
7
7
|
|
|
8
8
|
import { IJsonSchema, JsonSchemaTypeManager, JsonSchemaUtils } from '@flowgram.ai/json-schema';
|
|
9
9
|
import { useCurrentScope, useRefresh } from '@flowgram.ai/editor';
|
|
@@ -17,13 +17,14 @@ interface PropsType {
|
|
|
17
17
|
showIconInTree?: boolean;
|
|
18
18
|
displayFromScope?: boolean;
|
|
19
19
|
typeManager?: JsonSchemaTypeManager;
|
|
20
|
+
style?: React.CSSProperties;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
export function DisplayOutputs({ value, showIconInTree, displayFromScope }: PropsType) {
|
|
23
|
+
export function DisplayOutputs({ value, showIconInTree, displayFromScope, style }: PropsType) {
|
|
23
24
|
const scope = useCurrentScope();
|
|
24
25
|
const refresh = useRefresh();
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
useLayoutEffect(() => {
|
|
27
28
|
if (!displayFromScope || !scope) {
|
|
28
29
|
return () => null;
|
|
29
30
|
}
|
|
@@ -50,7 +51,7 @@ export function DisplayOutputs({ value, showIconInTree, displayFromScope }: Prop
|
|
|
50
51
|
const childEntries = Object.entries(properties || {});
|
|
51
52
|
|
|
52
53
|
return (
|
|
53
|
-
<div className="gedit-m-display-outputs-wrapper">
|
|
54
|
+
<div className="gedit-m-display-outputs-wrapper" style={style}>
|
|
54
55
|
{childEntries.map(([key, schema]) => (
|
|
55
56
|
<DisplaySchemaTag
|
|
56
57
|
key={key}
|
package/src/components/index.ts
CHANGED
|
@@ -53,6 +53,7 @@ export {
|
|
|
53
53
|
JsonEditorWithVariables,
|
|
54
54
|
type JsonEditorWithVariablesProps,
|
|
55
55
|
} from './json-editor-with-variables';
|
|
56
|
+
export { JsonSchemaCreator, type JsonSchemaCreatorProps } from './json-schema-creator';
|
|
56
57
|
export { JsonSchemaEditor } from './json-schema-editor';
|
|
57
58
|
export { PromptEditor, type PromptEditorPropsType } from './prompt-editor';
|
|
58
59
|
export {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import type { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
9
|
+
import { I18n } from '@flowgram.ai/editor';
|
|
10
|
+
import { Modal, Typography } from '@douyinfe/semi-ui';
|
|
11
|
+
|
|
12
|
+
import { jsonToSchema } from './utils/json-to-schema';
|
|
13
|
+
import { JsonCodeEditor } from '../code-editor';
|
|
14
|
+
|
|
15
|
+
const { Text } = Typography;
|
|
16
|
+
|
|
17
|
+
interface JsonInputModalProps {
|
|
18
|
+
visible: boolean;
|
|
19
|
+
onClose: () => void;
|
|
20
|
+
onConfirm: (schema: IJsonSchema) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function JsonInputModal({ visible, onClose, onConfirm }: JsonInputModalProps) {
|
|
24
|
+
const [jsonInput, setJsonInput] = useState('');
|
|
25
|
+
const [error, setError] = useState('');
|
|
26
|
+
|
|
27
|
+
const handleConfirm = () => {
|
|
28
|
+
try {
|
|
29
|
+
const schema = jsonToSchema(jsonInput);
|
|
30
|
+
onConfirm(schema);
|
|
31
|
+
setJsonInput('');
|
|
32
|
+
setError('');
|
|
33
|
+
} catch (err) {
|
|
34
|
+
setError((err as Error).message);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Modal
|
|
40
|
+
visible={visible}
|
|
41
|
+
onCancel={onClose}
|
|
42
|
+
onOk={handleConfirm}
|
|
43
|
+
title={I18n.t('JSON to JSONSchema')}
|
|
44
|
+
okText={I18n.t('Generate')}
|
|
45
|
+
cancelText={I18n.t('Cancel')}
|
|
46
|
+
width={600}
|
|
47
|
+
>
|
|
48
|
+
<div style={{ marginBottom: 8 }}>
|
|
49
|
+
<Text>{I18n.t('Paste JSON data')}:</Text>
|
|
50
|
+
</div>
|
|
51
|
+
<div style={{ minHeight: 300 }}>
|
|
52
|
+
<JsonCodeEditor value={jsonInput} onChange={(value) => setJsonInput(value || '')} />
|
|
53
|
+
</div>
|
|
54
|
+
{error && (
|
|
55
|
+
<div style={{ marginTop: 8 }}>
|
|
56
|
+
<Text type="danger">{error}</Text>
|
|
57
|
+
</div>
|
|
58
|
+
)}
|
|
59
|
+
</Modal>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useState } from 'react';
|
|
7
|
+
|
|
8
|
+
import type { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
9
|
+
import { I18n } from '@flowgram.ai/editor';
|
|
10
|
+
import { Button } from '@douyinfe/semi-ui';
|
|
11
|
+
|
|
12
|
+
import { JsonInputModal } from './json-input-modal';
|
|
13
|
+
|
|
14
|
+
export interface JsonSchemaCreatorProps {
|
|
15
|
+
/** 生成 schema 后的回调 */
|
|
16
|
+
onSchemaCreate?: (schema: IJsonSchema) => void;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function JsonSchemaCreator({ onSchemaCreate }: JsonSchemaCreatorProps) {
|
|
20
|
+
const [visible, setVisible] = useState(false);
|
|
21
|
+
|
|
22
|
+
const handleCreate = (schema: IJsonSchema) => {
|
|
23
|
+
onSchemaCreate?.(schema);
|
|
24
|
+
setVisible(false);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<>
|
|
29
|
+
<Button onClick={() => setVisible(true)}>{I18n.t('JSON to JSONSchema')}</Button>
|
|
30
|
+
<JsonInputModal
|
|
31
|
+
visible={visible}
|
|
32
|
+
onClose={() => setVisible(false)}
|
|
33
|
+
onConfirm={handleCreate}
|
|
34
|
+
/>
|
|
35
|
+
</>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
7
|
+
|
|
8
|
+
export function jsonToSchema(jsonString: string): IJsonSchema {
|
|
9
|
+
// 1. 解析 JSON
|
|
10
|
+
const data = JSON.parse(jsonString); // 会自动抛出语法错误
|
|
11
|
+
|
|
12
|
+
// 2. 生成 schema
|
|
13
|
+
return generateSchema(data);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function generateSchema(value: any): IJsonSchema {
|
|
17
|
+
// null
|
|
18
|
+
if (value === null) {
|
|
19
|
+
return { type: 'string' };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// array
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
const schema: IJsonSchema = { type: 'array' };
|
|
25
|
+
if (value.length > 0) {
|
|
26
|
+
schema.items = generateSchema(value[0]);
|
|
27
|
+
}
|
|
28
|
+
return schema;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// object
|
|
32
|
+
if (typeof value === 'object') {
|
|
33
|
+
const schema: IJsonSchema = {
|
|
34
|
+
type: 'object',
|
|
35
|
+
properties: {},
|
|
36
|
+
required: [],
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
for (const [key, val] of Object.entries(value)) {
|
|
40
|
+
schema.properties![key] = generateSchema(val);
|
|
41
|
+
schema.required!.push(key);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return schema;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// primitive types
|
|
48
|
+
const type = typeof value;
|
|
49
|
+
return { type: type as any };
|
|
50
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -34,6 +34,7 @@ export {
|
|
|
34
34
|
InputsValuesTree,
|
|
35
35
|
JsonCodeEditor,
|
|
36
36
|
JsonEditorWithVariables,
|
|
37
|
+
JsonSchemaCreator,
|
|
37
38
|
JsonSchemaEditor,
|
|
38
39
|
PromptEditor,
|
|
39
40
|
PromptEditorWithInputs,
|
|
@@ -59,6 +60,7 @@ export {
|
|
|
59
60
|
type IConditionRule,
|
|
60
61
|
type IConditionRuleFactory,
|
|
61
62
|
type JsonEditorWithVariablesProps,
|
|
63
|
+
type JsonSchemaCreatorProps,
|
|
62
64
|
type PromptEditorPropsType,
|
|
63
65
|
type PromptEditorWithInputsProps,
|
|
64
66
|
type PromptEditorWithVariablesProps,
|