@flowgram.ai/form-materials 0.1.0-alpha.19 → 0.1.0-alpha.20
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/blur-input/index.js +4 -1
- package/dist/cjs/components/condition-context/hooks/use-condition.js +4 -0
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +13 -4
- 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/effects/validate-when-variable-sync/index.js +3 -3
- package/dist/cjs/index.js +3 -0
- package/dist/esm/components/assign-rows/index.mjs +9 -3
- package/dist/esm/components/blur-input/index.mjs +4 -1
- package/dist/esm/components/condition-context/hooks/use-condition.mjs +4 -0
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +13 -4
- 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/effects/validate-when-variable-sync/index.mjs +3 -3
- 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/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +7 -3
- package/package.json +6 -6
- package/src/components/assign-rows/index.tsx +7 -6
- package/src/components/blur-input/index.tsx +4 -1
- package/src/components/condition-context/hooks/use-condition.tsx +4 -0
- package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +16 -8
- 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/effects/validate-when-variable-sync/index.ts +7 -3
- package/src/index.ts +2 -0
- package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +17 -12
- package/src/shared/inject-material/README.md +0 -170
- package/src/shared/inject-material/README.zh.md +0 -174
|
@@ -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,
|
|
@@ -43,7 +43,10 @@ function BlurInput(props) {
|
|
|
43
43
|
onChange: (value)=>{
|
|
44
44
|
setValue(value);
|
|
45
45
|
},
|
|
46
|
-
onBlur: (e)=>
|
|
46
|
+
onBlur: (e)=>{
|
|
47
|
+
props.onChange?.(value, e);
|
|
48
|
+
props.onBlur?.(e);
|
|
49
|
+
}
|
|
47
50
|
});
|
|
48
51
|
}
|
|
49
52
|
exports.BlurInput = __webpack_exports__.BlurInput;
|
|
@@ -87,6 +87,10 @@ function useCondition({ leftSchema, operator, onClearOp, onClearRight, ruleConfi
|
|
|
87
87
|
]);
|
|
88
88
|
const prevTargetSchemaRef = (0, external_react_namespaceObject.useRef)(void 0);
|
|
89
89
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
90
|
+
if (!prevTargetSchemaRef.current) {
|
|
91
|
+
prevTargetSchemaRef.current = targetSchema;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
90
94
|
if (prevTargetSchemaRef.current?.type !== targetSchema?.type) onClearRight?.();
|
|
91
95
|
prevTargetSchemaRef.current = targetSchema;
|
|
92
96
|
}, [
|
|
@@ -109,12 +109,21 @@ class VariableTagWidget extends view_namespaceObject.WidgetType {
|
|
|
109
109
|
this.toDispose.push(editor_namespaceObject.Disposable.create(()=>{
|
|
110
110
|
this.root.unmount();
|
|
111
111
|
}));
|
|
112
|
-
|
|
113
|
-
this.renderVariable(
|
|
114
|
-
}
|
|
112
|
+
const refresh = ()=>{
|
|
113
|
+
this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
|
|
114
|
+
};
|
|
115
|
+
this.toDispose.push(this.scope.available.trackByKeyPath(this.keyPath, refresh, {
|
|
116
|
+
triggerOnInit: false
|
|
117
|
+
}));
|
|
118
|
+
if (this.keyPath?.[0]) this.toDispose.push(this.scope.available.trackByKeyPath([
|
|
119
|
+
this.keyPath[0]
|
|
120
|
+
], refresh, {
|
|
121
|
+
selector: (curr)=>({
|
|
122
|
+
...curr?.meta
|
|
123
|
+
}),
|
|
115
124
|
triggerOnInit: false
|
|
116
125
|
}));
|
|
117
|
-
|
|
126
|
+
refresh();
|
|
118
127
|
return dom;
|
|
119
128
|
}
|
|
120
129
|
eq(other) {
|
|
@@ -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
|
+
});
|
|
@@ -26,15 +26,15 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26
26
|
__webpack_require__.d(__webpack_exports__, {
|
|
27
27
|
validateWhenVariableSync: ()=>validateWhenVariableSync
|
|
28
28
|
});
|
|
29
|
-
const external_lodash_es_namespaceObject = require("lodash-es");
|
|
30
29
|
const editor_namespaceObject = require("@flowgram.ai/editor");
|
|
31
30
|
const validateWhenVariableSync = ({ scope } = {})=>[
|
|
32
31
|
{
|
|
33
32
|
event: editor_namespaceObject.DataEvent.onValueInit,
|
|
34
|
-
effect: ({ context, form })=>{
|
|
33
|
+
effect: ({ context, form, name })=>{
|
|
35
34
|
const nodeScope = 'private' === scope ? (0, editor_namespaceObject.getNodePrivateScope)(context.node) : (0, editor_namespaceObject.getNodeScope)(context.node);
|
|
36
35
|
const disposable = nodeScope.available.onListOrAnyVarChange(()=>{
|
|
37
|
-
|
|
36
|
+
const errorKeys = Object.entries(form.state.errors || {}).filter(([_, errors])=>errors?.length > 0).filter(([key])=>key.startsWith(name) || name.startsWith(key)).map(([key])=>key);
|
|
37
|
+
if (errorKeys.length > 0) form.validate();
|
|
38
38
|
});
|
|
39
39
|
return ()=>disposable.dispose();
|
|
40
40
|
}
|
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,
|
|
@@ -59,6 +59,10 @@ function useCondition({ leftSchema, operator, onClearOp, onClearRight, ruleConfi
|
|
|
59
59
|
]);
|
|
60
60
|
const prevTargetSchemaRef = useRef(void 0);
|
|
61
61
|
useEffect(()=>{
|
|
62
|
+
if (!prevTargetSchemaRef.current) {
|
|
63
|
+
prevTargetSchemaRef.current = targetSchema;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
62
66
|
if (prevTargetSchemaRef.current?.type !== targetSchema?.type) onClearRight?.();
|
|
63
67
|
prevTargetSchemaRef.current = targetSchema;
|
|
64
68
|
}, [
|
|
@@ -81,12 +81,21 @@ class VariableTagWidget extends WidgetType {
|
|
|
81
81
|
this.toDispose.push(Disposable.create(()=>{
|
|
82
82
|
this.root.unmount();
|
|
83
83
|
}));
|
|
84
|
-
|
|
85
|
-
this.renderVariable(
|
|
86
|
-
}
|
|
84
|
+
const refresh = ()=>{
|
|
85
|
+
this.renderVariable(this.scope.available.getByKeyPath(this.keyPath));
|
|
86
|
+
};
|
|
87
|
+
this.toDispose.push(this.scope.available.trackByKeyPath(this.keyPath, refresh, {
|
|
88
|
+
triggerOnInit: false
|
|
89
|
+
}));
|
|
90
|
+
if (this.keyPath?.[0]) this.toDispose.push(this.scope.available.trackByKeyPath([
|
|
91
|
+
this.keyPath[0]
|
|
92
|
+
], refresh, {
|
|
93
|
+
selector: (curr)=>({
|
|
94
|
+
...curr?.meta
|
|
95
|
+
}),
|
|
87
96
|
triggerOnInit: false
|
|
88
97
|
}));
|
|
89
|
-
|
|
98
|
+
refresh();
|
|
90
99
|
return dom;
|
|
91
100
|
}
|
|
92
101
|
eq(other) {
|
|
@@ -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 };
|