@flowgram.ai/form-materials 0.4.10 → 0.4.11

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.
Files changed (70) hide show
  1. package/dist/cjs/components/blur-input/index.js +2 -12
  2. package/dist/cjs/components/{prompt-editor-with-inputs/inputs-picker.js → coze-editor-extensions/extensions/inputs-tree.js} +70 -2
  3. package/dist/cjs/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.js +10 -7
  4. package/dist/cjs/components/coze-editor-extensions/index.js +86 -0
  5. package/dist/cjs/components/index.js +11 -1
  6. package/dist/cjs/components/json-editor-with-variables/editor.js +10 -6
  7. package/dist/cjs/components/prompt-editor-with-inputs/editor.js +2 -2
  8. package/dist/cjs/components/prompt-editor-with-variables/editor.js +3 -4
  9. package/dist/cjs/components/variable-selector/index.js +1 -0
  10. package/dist/cjs/index.js +10 -1
  11. package/dist/cjs/shared/inject-material/index.js +2 -1
  12. package/dist/esm/components/blur-input/index.mjs +2 -2
  13. package/dist/esm/components/coze-editor-extensions/extensions/inputs-tree.mjs +135 -0
  14. package/dist/esm/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.mjs +10 -7
  15. package/dist/esm/components/coze-editor-extensions/index.mjs +18 -0
  16. package/dist/esm/components/index.mjs +2 -1
  17. package/dist/esm/components/json-editor-with-variables/editor.mjs +8 -4
  18. package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +2 -2
  19. package/dist/esm/components/prompt-editor-with-variables/editor.mjs +3 -4
  20. package/dist/esm/components/variable-selector/index.mjs +1 -0
  21. package/dist/esm/index.mjs +2 -2
  22. package/dist/esm/shared/inject-material/index.mjs +2 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/dist/types/components/blur-input/index.d.ts +7 -1
  25. package/dist/types/components/{prompt-editor-with-inputs/inputs-picker.d.ts → coze-editor-extensions/extensions/inputs-tree.d.ts} +5 -0
  26. package/dist/types/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.d.ts +3 -1
  27. package/dist/types/components/coze-editor-extensions/index.d.ts +18 -0
  28. package/dist/types/components/dynamic-value-input/index.d.ts +3 -1
  29. package/dist/types/components/index.d.ts +1 -0
  30. package/dist/types/components/type-selector/index.d.ts +3 -1
  31. package/dist/types/components/variable-selector/index.d.ts +3 -1
  32. package/dist/types/index.d.ts +1 -1
  33. package/dist/types/shared/inject-material/index.d.ts +6 -4
  34. package/package.json +10 -9
  35. package/src/components/blur-input/index.tsx +9 -1
  36. package/src/components/{prompt-editor-with-inputs/inputs-picker.tsx → coze-editor-extensions/extensions/inputs-tree.tsx} +95 -5
  37. package/src/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.tsx +9 -3
  38. package/src/components/coze-editor-extensions/index.tsx +33 -0
  39. package/src/components/index.ts +5 -0
  40. package/src/components/json-editor-with-variables/editor.tsx +4 -4
  41. package/src/components/prompt-editor-with-inputs/editor.tsx +2 -3
  42. package/src/components/prompt-editor-with-variables/editor.tsx +3 -5
  43. package/src/components/variable-selector/index.tsx +2 -0
  44. package/src/index.ts +3 -0
  45. package/src/shared/inject-material/index.tsx +10 -6
  46. package/dist/cjs/components/json-editor-with-variables/extensions/variable-tree.js +0 -97
  47. package/dist/cjs/components/prompt-editor-with-inputs/extensions/inputs-tree.js +0 -101
  48. package/dist/cjs/components/prompt-editor-with-variables/extensions/variable-tag.js +0 -151
  49. package/dist/cjs/components/prompt-editor-with-variables/styles.js +0 -89
  50. package/dist/esm/components/json-editor-with-variables/extensions/variable-tree.mjs +0 -63
  51. package/dist/esm/components/prompt-editor-with-inputs/extensions/inputs-tree.mjs +0 -67
  52. package/dist/esm/components/prompt-editor-with-inputs/inputs-picker.mjs +0 -70
  53. package/dist/esm/components/prompt-editor-with-variables/extensions/variable-tag.mjs +0 -117
  54. package/dist/esm/components/prompt-editor-with-variables/styles.mjs +0 -36
  55. package/dist/types/components/json-editor-with-variables/extensions/variable-tree.d.ts +0 -6
  56. package/dist/types/components/prompt-editor-with-inputs/extensions/inputs-tree.d.ts +0 -9
  57. package/dist/types/components/prompt-editor-with-variables/extensions/variable-tag.d.ts +0 -5
  58. package/dist/types/components/prompt-editor-with-variables/styles.d.ts +0 -9
  59. package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +0 -83
  60. package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +0 -94
  61. package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +0 -174
  62. package/src/components/prompt-editor-with-variables/styles.tsx +0 -44
  63. /package/dist/cjs/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.js +0 -0
  64. /package/dist/cjs/components/{json-editor-with-variables → coze-editor-extensions}/styles.js +0 -0
  65. /package/dist/esm/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.mjs +0 -0
  66. /package/dist/esm/components/{json-editor-with-variables → coze-editor-extensions}/styles.mjs +0 -0
  67. /package/dist/types/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.d.ts +0 -0
  68. /package/dist/types/components/{json-editor-with-variables → coze-editor-extensions}/styles.d.ts +0 -0
  69. /package/src/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.tsx +0 -0
  70. /package/src/components/{json-editor-with-variables → coze-editor-extensions}/styles.tsx +0 -0
@@ -1,14 +1,5 @@
1
1
  "use strict";
2
2
  var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.n = (module)=>{
5
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
- __webpack_require__.d(getter, {
7
- a: getter
8
- });
9
- return getter;
10
- };
11
- })();
12
3
  (()=>{
13
4
  __webpack_require__.d = (exports1, definition)=>{
14
5
  for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
@@ -37,8 +28,7 @@ __webpack_require__.d(__webpack_exports__, {
37
28
  });
38
29
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
39
30
  const external_react_namespaceObject = require("react");
40
- const input_namespaceObject = require("@douyinfe/semi-ui/lib/es/input");
41
- var input_default = /*#__PURE__*/ __webpack_require__.n(input_namespaceObject);
31
+ const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
42
32
  function BlurInput(props) {
43
33
  const [value, setValue] = (0, external_react_namespaceObject.useState)('');
44
34
  (0, external_react_namespaceObject.useEffect)(()=>{
@@ -46,7 +36,7 @@ function BlurInput(props) {
46
36
  }, [
47
37
  props.value
48
38
  ]);
49
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(input_default(), {
39
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Input, {
50
40
  ...props,
51
41
  value: value,
52
42
  onChange: (value)=>{
@@ -24,14 +24,16 @@ var __webpack_require__ = {};
24
24
  var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
+ InputsTree: ()=>InputsTree,
27
28
  InputsPicker: ()=>InputsPicker
28
29
  });
29
30
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
31
  const external_react_namespaceObject = require("react");
31
32
  const external_lodash_es_namespaceObject = require("lodash-es");
32
33
  const editor_namespaceObject = require("@flowgram.ai/editor");
34
+ const react_namespaceObject = require("@flowgram.ai/coze-editor/react");
33
35
  const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
34
- const index_js_namespaceObject = require("../../shared/index.js");
36
+ const index_js_namespaceObject = require("../../../shared/index.js");
35
37
  function InputsPicker({ inputsValues, onSelect }) {
36
38
  const available = (0, editor_namespaceObject.useScopeAvailable)();
37
39
  const getArrayDrilldown = (type, depth = 1)=>{
@@ -95,9 +97,75 @@ function InputsPicker({ inputsValues, onSelect }) {
95
97
  onSelect: (v)=>onSelect(v)
96
98
  });
97
99
  }
100
+ const DEFAULT_TRIGGER_CHARACTERS = [
101
+ '{',
102
+ '{}',
103
+ '@'
104
+ ];
105
+ function InputsTree({ inputsValues, triggerCharacters = DEFAULT_TRIGGER_CHARACTERS }) {
106
+ const [posKey, setPosKey] = (0, external_react_namespaceObject.useState)('');
107
+ const [visible, setVisible] = (0, external_react_namespaceObject.useState)(false);
108
+ const [position, setPosition] = (0, external_react_namespaceObject.useState)(-1);
109
+ const editor = (0, react_namespaceObject.useEditor)();
110
+ function insert(variablePath) {
111
+ const range = (0, react_namespaceObject.getCurrentMentionReplaceRange)(editor.$view.state);
112
+ if (!range) return;
113
+ let { from, to } = range;
114
+ while('{' === editor.$view.state.doc.sliceString(from - 1, from))from--;
115
+ while('}' === editor.$view.state.doc.sliceString(to, to + 1))to++;
116
+ editor.replaceText({
117
+ ...range,
118
+ text: '{{' + variablePath + '}}'
119
+ });
120
+ setVisible(false);
121
+ }
122
+ function handleOpenChange(e) {
123
+ setPosition(e.state.selection.main.head);
124
+ setVisible(e.value);
125
+ }
126
+ (0, external_react_namespaceObject.useEffect)(()=>{
127
+ if (!editor) return;
128
+ }, [
129
+ editor,
130
+ visible
131
+ ]);
132
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
133
+ children: [
134
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.Mention, {
135
+ triggerCharacters: triggerCharacters,
136
+ onOpenChange: handleOpenChange
137
+ }),
138
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Popover, {
139
+ visible: visible,
140
+ trigger: "custom",
141
+ position: "topLeft",
142
+ rePosKey: posKey,
143
+ content: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
144
+ style: {
145
+ width: 300,
146
+ maxHeight: 300,
147
+ overflowY: 'auto'
148
+ },
149
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(InputsPicker, {
150
+ inputsValues: inputsValues,
151
+ onSelect: (v)=>{
152
+ insert(v);
153
+ }
154
+ })
155
+ }),
156
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.PositionMirror, {
157
+ position: position,
158
+ onChange: ()=>setPosKey(String(Math.random()))
159
+ })
160
+ })
161
+ ]
162
+ });
163
+ }
98
164
  exports.InputsPicker = __webpack_exports__.InputsPicker;
165
+ exports.InputsTree = __webpack_exports__.InputsTree;
99
166
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
100
- "InputsPicker"
167
+ "InputsPicker",
168
+ "InputsTree"
101
169
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
102
170
  Object.defineProperty(exports, '__esModule', {
103
171
  value: true
@@ -31,7 +31,12 @@ const external_react_namespaceObject = require("react");
31
31
  const react_namespaceObject = require("@flowgram.ai/coze-editor/react");
32
32
  const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
33
33
  const index_js_namespaceObject = require("../../variable-selector/index.js");
34
- function VariableTree() {
34
+ const DEFAULT_TRIGGER_CHARACTER = [
35
+ '{',
36
+ '{}',
37
+ '@'
38
+ ];
39
+ function VariableTree({ triggerCharacters = DEFAULT_TRIGGER_CHARACTER }) {
35
40
  const [posKey, setPosKey] = (0, external_react_namespaceObject.useState)('');
36
41
  const [visible, setVisible] = (0, external_react_namespaceObject.useState)(false);
37
42
  const [position, setPosition] = (0, external_react_namespaceObject.useState)(-1);
@@ -63,11 +68,7 @@ function VariableTree() {
63
68
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(jsx_runtime_namespaceObject.Fragment, {
64
69
  children: [
65
70
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(react_namespaceObject.Mention, {
66
- triggerCharacters: [
67
- '{',
68
- '{}',
69
- '@'
70
- ],
71
+ triggerCharacters: triggerCharacters,
71
72
  onOpenChange: handleOpenChange
72
73
  }),
73
74
  /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Popover, {
@@ -77,7 +78,9 @@ function VariableTree() {
77
78
  rePosKey: posKey,
78
79
  content: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
79
80
  style: {
80
- width: 300
81
+ width: 300,
82
+ maxHeight: 300,
83
+ overflowY: 'auto'
81
84
  },
82
85
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Tree, {
83
86
  treeData: treeData,
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "./extensions/inputs-tree": function(module) {
4
+ module.exports = import("./extensions/inputs-tree.js").then(function(module) {
5
+ return module;
6
+ });
7
+ },
8
+ "./extensions/variable-tag": function(module) {
9
+ module.exports = import("./extensions/variable-tag.js").then(function(module) {
10
+ return module;
11
+ });
12
+ },
13
+ "./extensions/variable-tree": function(module) {
14
+ module.exports = import("./extensions/variable-tree.js").then(function(module) {
15
+ return module;
16
+ });
17
+ }
18
+ };
19
+ var __webpack_module_cache__ = {};
20
+ function __webpack_require__(moduleId) {
21
+ var cachedModule = __webpack_module_cache__[moduleId];
22
+ if (void 0 !== cachedModule) return cachedModule.exports;
23
+ var module = __webpack_module_cache__[moduleId] = {
24
+ exports: {}
25
+ };
26
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
27
+ return module.exports;
28
+ }
29
+ (()=>{
30
+ __webpack_require__.d = (exports1, definition)=>{
31
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
32
+ enumerable: true,
33
+ get: definition[key]
34
+ });
35
+ };
36
+ })();
37
+ (()=>{
38
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
39
+ })();
40
+ (()=>{
41
+ __webpack_require__.r = (exports1)=>{
42
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
43
+ value: 'Module'
44
+ });
45
+ Object.defineProperty(exports1, '__esModule', {
46
+ value: true
47
+ });
48
+ };
49
+ })();
50
+ var __webpack_exports__ = {};
51
+ (()=>{
52
+ __webpack_require__.r(__webpack_exports__);
53
+ __webpack_require__.d(__webpack_exports__, {
54
+ EditorInputsTree: ()=>EditorInputsTree,
55
+ EditorVariableTagInject: ()=>EditorVariableTagInject,
56
+ EditorVariableTree: ()=>EditorVariableTree
57
+ });
58
+ const external_react_namespaceObject = require("react");
59
+ const index_js_namespaceObject = require("../../shared/index.js");
60
+ const EditorVariableTree = (0, index_js_namespaceObject.createInjectMaterial)(/*#__PURE__*/ (0, external_react_namespaceObject.lazy)(()=>Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "./extensions/variable-tree")).then((module)=>({
61
+ default: module.VariableTree
62
+ }))), {
63
+ renderKey: 'EditorVariableTree'
64
+ });
65
+ const EditorVariableTagInject = (0, index_js_namespaceObject.createInjectMaterial)(/*#__PURE__*/ (0, external_react_namespaceObject.lazy)(()=>Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "./extensions/variable-tag")).then((module)=>({
66
+ default: module.VariableTagInject
67
+ }))), {
68
+ renderKey: 'EditorVariableTagInject'
69
+ });
70
+ const EditorInputsTree = (0, index_js_namespaceObject.createInjectMaterial)(/*#__PURE__*/ (0, external_react_namespaceObject.lazy)(()=>Promise.resolve().then(__webpack_require__.bind(__webpack_require__, "./extensions/inputs-tree")).then((module)=>({
71
+ default: module.InputsTree
72
+ }))), {
73
+ renderKey: 'EditorInputsTree'
74
+ });
75
+ })();
76
+ exports.EditorInputsTree = __webpack_exports__.EditorInputsTree;
77
+ exports.EditorVariableTagInject = __webpack_exports__.EditorVariableTagInject;
78
+ exports.EditorVariableTree = __webpack_exports__.EditorVariableTree;
79
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
80
+ "EditorInputsTree",
81
+ "EditorVariableTagInject",
82
+ "EditorVariableTree"
83
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
84
+ Object.defineProperty(exports, '__esModule', {
85
+ value: true
86
+ });
@@ -32,6 +32,7 @@ __webpack_require__.d(__webpack_exports__, {
32
32
  DynamicValueInput: ()=>external_dynamic_value_input_index_js_namespaceObject.DynamicValueInput,
33
33
  AssignRows: ()=>external_assign_rows_index_js_namespaceObject.AssignRows,
34
34
  ConditionRow: ()=>external_condition_row_index_js_namespaceObject.ConditionRow,
35
+ EditorInputsTree: ()=>external_coze_editor_extensions_index_js_namespaceObject.EditorInputsTree,
35
36
  InjectDynamicValueInput: ()=>external_dynamic_value_input_index_js_namespaceObject.InjectDynamicValueInput,
36
37
  PromptEditorWithVariables: ()=>external_prompt_editor_with_variables_index_js_namespaceObject.PromptEditorWithVariables,
37
38
  JsonEditorWithVariables: ()=>external_json_editor_with_variables_index_js_namespaceObject.JsonEditorWithVariables,
@@ -48,11 +49,13 @@ __webpack_require__.d(__webpack_exports__, {
48
49
  VariableSelectorProvider: ()=>external_variable_selector_index_js_namespaceObject.VariableSelectorProvider,
49
50
  DisplayFlowValue: ()=>external_display_flow_value_index_js_namespaceObject.DisplayFlowValue,
50
51
  JsonSchemaEditor: ()=>external_json_schema_editor_index_js_namespaceObject.JsonSchemaEditor,
51
- PromptEditorWithInputs: ()=>external_prompt_editor_with_inputs_index_js_namespaceObject.PromptEditorWithInputs,
52
+ EditorVariableTagInject: ()=>external_coze_editor_extensions_index_js_namespaceObject.EditorVariableTagInject,
52
53
  InputsValuesTree: ()=>external_inputs_values_tree_index_js_namespaceObject.InputsValuesTree,
54
+ PromptEditorWithInputs: ()=>external_prompt_editor_with_inputs_index_js_namespaceObject.PromptEditorWithInputs,
53
55
  parseTypeSelectValue: ()=>external_type_selector_index_js_namespaceObject.parseTypeSelectValue,
54
56
  CodeEditor: ()=>external_code_editor_index_js_namespaceObject.CodeEditor,
55
57
  DisplayInputsValueAllInTag: ()=>external_display_inputs_values_index_js_namespaceObject.DisplayInputsValueAllInTag,
58
+ EditorVariableTree: ()=>external_coze_editor_extensions_index_js_namespaceObject.EditorVariableTree,
56
59
  getTypeSelectValue: ()=>external_type_selector_index_js_namespaceObject.getTypeSelectValue,
57
60
  DisplayInputsValues: ()=>external_display_inputs_values_index_js_namespaceObject.DisplayInputsValues,
58
61
  BatchOutputs: ()=>external_batch_outputs_index_js_namespaceObject.BatchOutputs,
@@ -67,6 +70,7 @@ const external_code_editor_index_js_namespaceObject = require("./code-editor/ind
67
70
  const external_code_editor_mini_index_js_namespaceObject = require("./code-editor-mini/index.js");
68
71
  const external_condition_row_index_js_namespaceObject = require("./condition-row/index.js");
69
72
  const external_constant_input_index_js_namespaceObject = require("./constant-input/index.js");
73
+ const external_coze_editor_extensions_index_js_namespaceObject = require("./coze-editor-extensions/index.js");
70
74
  const external_db_condition_row_index_js_namespaceObject = require("./db-condition-row/index.js");
71
75
  const external_display_flow_value_index_js_namespaceObject = require("./display-flow-value/index.js");
72
76
  const external_display_inputs_values_index_js_namespaceObject = require("./display-inputs-values/index.js");
@@ -100,6 +104,9 @@ exports.DisplayOutputs = __webpack_exports__.DisplayOutputs;
100
104
  exports.DisplaySchemaTag = __webpack_exports__.DisplaySchemaTag;
101
105
  exports.DisplaySchemaTree = __webpack_exports__.DisplaySchemaTree;
102
106
  exports.DynamicValueInput = __webpack_exports__.DynamicValueInput;
107
+ exports.EditorInputsTree = __webpack_exports__.EditorInputsTree;
108
+ exports.EditorVariableTagInject = __webpack_exports__.EditorVariableTagInject;
109
+ exports.EditorVariableTree = __webpack_exports__.EditorVariableTree;
103
110
  exports.InjectDynamicValueInput = __webpack_exports__.InjectDynamicValueInput;
104
111
  exports.InjectTypeSelector = __webpack_exports__.InjectTypeSelector;
105
112
  exports.InjectVariableSelector = __webpack_exports__.InjectVariableSelector;
@@ -134,6 +141,9 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
134
141
  "DisplaySchemaTag",
135
142
  "DisplaySchemaTree",
136
143
  "DynamicValueInput",
144
+ "EditorInputsTree",
145
+ "EditorVariableTagInject",
146
+ "EditorVariableTree",
137
147
  "InjectDynamicValueInput",
138
148
  "InjectTypeSelector",
139
149
  "InjectVariableSelector",
@@ -30,9 +30,11 @@ const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
30
  require("react");
31
31
  const editor_namespaceObject = require("@flowgram.ai/editor");
32
32
  const preset_code_namespaceObject = require("@flowgram.ai/coze-editor/preset-code");
33
- const index_js_namespaceObject = require("../code-editor/index.js");
34
- const variable_tree_js_namespaceObject = require("./extensions/variable-tree.js");
35
- const variable_tag_js_namespaceObject = require("./extensions/variable-tag.js");
33
+ const index_js_namespaceObject = require("../coze-editor-extensions/index.js");
34
+ const external_code_editor_index_js_namespaceObject = require("../code-editor/index.js");
35
+ const TRIGGER_CHARACTERS = [
36
+ '@'
37
+ ];
36
38
  function findAllMatches(inputString, regex) {
37
39
  const globalRegex = new RegExp(regex, regex.flags.includes('g') ? regex.flags : regex.flags + 'g');
38
40
  let match;
@@ -58,7 +60,7 @@ const transformer = (0, preset_code_namespaceObject.transformerCreator)((text)=>
58
60
  return text;
59
61
  });
60
62
  function JsonEditorWithVariables(props) {
61
- return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(index_js_namespaceObject.CodeEditor, {
63
+ return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_code_editor_index_js_namespaceObject.CodeEditor, {
62
64
  languageId: "json",
63
65
  activeLinePlaceholder: editor_namespaceObject.I18n.t("Press '@' to Select variable"),
64
66
  ...props,
@@ -67,8 +69,10 @@ function JsonEditorWithVariables(props) {
67
69
  ...props.options || {}
68
70
  },
69
71
  children: [
70
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(variable_tree_js_namespaceObject.VariableTree, {}),
71
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(variable_tag_js_namespaceObject.VariableTagInject, {})
72
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.EditorVariableTree, {
73
+ triggerCharacters: TRIGGER_CHARACTERS
74
+ }),
75
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.EditorVariableTagInject, {})
72
76
  ]
73
77
  });
74
78
  }
@@ -29,11 +29,11 @@ __webpack_require__.d(__webpack_exports__, {
29
29
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
30
  require("react");
31
31
  const index_js_namespaceObject = require("../prompt-editor/index.js");
32
- const inputs_tree_js_namespaceObject = require("./extensions/inputs-tree.js");
32
+ const external_coze_editor_extensions_index_js_namespaceObject = require("../coze-editor-extensions/index.js");
33
33
  function PromptEditorWithInputs({ inputsValues, ...restProps }) {
34
34
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(index_js_namespaceObject.PromptEditor, {
35
35
  ...restProps,
36
- children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(inputs_tree_js_namespaceObject.InputsTree, {
36
+ children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_coze_editor_extensions_index_js_namespaceObject.EditorInputsTree, {
37
37
  inputsValues: inputsValues
38
38
  })
39
39
  });
@@ -29,14 +29,13 @@ __webpack_require__.d(__webpack_exports__, {
29
29
  const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
30
  require("react");
31
31
  const index_js_namespaceObject = require("../prompt-editor/index.js");
32
- const variable_tree_js_namespaceObject = require("./extensions/variable-tree.js");
33
- const variable_tag_js_namespaceObject = require("./extensions/variable-tag.js");
32
+ const external_coze_editor_extensions_index_js_namespaceObject = require("../coze-editor-extensions/index.js");
34
33
  function PromptEditorWithVariables(props) {
35
34
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(index_js_namespaceObject.PromptEditor, {
36
35
  ...props,
37
36
  children: [
38
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(variable_tree_js_namespaceObject.VariableTree, {}),
39
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(variable_tag_js_namespaceObject.VariableTagInject, {})
37
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_coze_editor_extensions_index_js_namespaceObject.EditorVariableTree, {}),
38
+ /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_coze_editor_extensions_index_js_namespaceObject.EditorVariableTagInject, {})
40
39
  ]
41
40
  });
42
41
  }
@@ -65,6 +65,7 @@ const VariableSelector = ({ value, config = {}, onChange, style, readonly = fals
65
65
  });
66
66
  return icon;
67
67
  };
68
+ console.log('debugger treeValue', treeValue);
68
69
  return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(jsx_runtime_namespaceObject.Fragment, {
69
70
  children: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_styles_js_namespaceObject.UITreeSelect, {
70
71
  dropdownMatchSelectWidth: false,
package/dist/cjs/index.js CHANGED
@@ -45,6 +45,7 @@ __webpack_require__.d(__webpack_exports__, {
45
45
  useVariableTree: ()=>index_js_namespaceObject.useVariableTree,
46
46
  formatLegacyRefOnSubmit: ()=>external_shared_index_js_namespaceObject.formatLegacyRefOnSubmit,
47
47
  DisplayFlowValue: ()=>index_js_namespaceObject.DisplayFlowValue,
48
+ EditorVariableTagInject: ()=>index_js_namespaceObject.EditorVariableTagInject,
48
49
  formatLegacyRefToNewRef: ()=>external_shared_index_js_namespaceObject.formatLegacyRefToNewRef,
49
50
  formatLegacyRefOnInit: ()=>external_shared_index_js_namespaceObject.formatLegacyRefOnInit,
50
51
  CodeEditor: ()=>index_js_namespaceObject.CodeEditor,
@@ -59,10 +60,11 @@ __webpack_require__.d(__webpack_exports__, {
59
60
  CodeEditorMini: ()=>index_js_namespaceObject.CodeEditorMini,
60
61
  DBConditionRow: ()=>index_js_namespaceObject.DBConditionRow,
61
62
  DynamicValueInput: ()=>index_js_namespaceObject.DynamicValueInput,
63
+ EditorInputsTree: ()=>index_js_namespaceObject.EditorInputsTree,
62
64
  PromptEditorWithVariables: ()=>index_js_namespaceObject.PromptEditorWithVariables,
63
65
  lazySuspense: ()=>external_shared_index_js_namespaceObject.lazySuspense,
64
- unstableSetCreateRoot: ()=>external_shared_index_js_namespaceObject.unstableSetCreateRoot,
65
66
  provideJsonSchemaOutputs: ()=>external_effects_index_js_namespaceObject.provideJsonSchemaOutputs,
67
+ unstableSetCreateRoot: ()=>external_shared_index_js_namespaceObject.unstableSetCreateRoot,
66
68
  createInferInputsPlugin: ()=>external_form_plugins_index_js_namespaceObject.createInferInputsPlugin,
67
69
  InjectVariableSelector: ()=>index_js_namespaceObject.InjectVariableSelector,
68
70
  DisplayOutputs: ()=>index_js_namespaceObject.DisplayOutputs,
@@ -82,6 +84,7 @@ __webpack_require__.d(__webpack_exports__, {
82
84
  InputsValuesTree: ()=>index_js_namespaceObject.InputsValuesTree,
83
85
  parseTypeSelectValue: ()=>index_js_namespaceObject.parseTypeSelectValue,
84
86
  syncVariableTitle: ()=>external_effects_index_js_namespaceObject.syncVariableTitle,
87
+ EditorVariableTree: ()=>index_js_namespaceObject.EditorVariableTree,
85
88
  JsonSchemaUtils: ()=>external_plugins_index_js_namespaceObject.JsonSchemaUtils,
86
89
  DisplayInputsValues: ()=>index_js_namespaceObject.DisplayInputsValues,
87
90
  autoRenameRefEffect: ()=>external_effects_index_js_namespaceObject.autoRenameRefEffect,
@@ -112,6 +115,9 @@ exports.DisplayOutputs = __webpack_exports__.DisplayOutputs;
112
115
  exports.DisplaySchemaTag = __webpack_exports__.DisplaySchemaTag;
113
116
  exports.DisplaySchemaTree = __webpack_exports__.DisplaySchemaTree;
114
117
  exports.DynamicValueInput = __webpack_exports__.DynamicValueInput;
118
+ exports.EditorInputsTree = __webpack_exports__.EditorInputsTree;
119
+ exports.EditorVariableTagInject = __webpack_exports__.EditorVariableTagInject;
120
+ exports.EditorVariableTree = __webpack_exports__.EditorVariableTree;
115
121
  exports.FlowValueUtils = __webpack_exports__.FlowValueUtils;
116
122
  exports.InjectDynamicValueInput = __webpack_exports__.InjectDynamicValueInput;
117
123
  exports.InjectTypeSelector = __webpack_exports__.InjectTypeSelector;
@@ -176,6 +182,9 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
176
182
  "DisplaySchemaTag",
177
183
  "DisplaySchemaTree",
178
184
  "DynamicValueInput",
185
+ "EditorInputsTree",
186
+ "EditorVariableTagInject",
187
+ "EditorVariableTree",
179
188
  "FlowValueUtils",
180
189
  "InjectDynamicValueInput",
181
190
  "InjectTypeSelector",
@@ -39,13 +39,13 @@ const external_react_namespaceObject = require("react");
39
39
  var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject);
40
40
  const editor_namespaceObject = require("@flowgram.ai/editor");
41
41
  function createInjectMaterial(Component, params) {
42
+ const renderKey = params?.renderKey || Component.renderKey || Component.name || '';
42
43
  const InjectComponent = (props)=>{
43
44
  const container = (0, editor_namespaceObject.usePlaygroundContainer)();
44
45
  if (!container?.isBound(editor_namespaceObject.FlowRendererRegistry)) return /*#__PURE__*/ external_react_default().createElement(Component, {
45
46
  ...props
46
47
  });
47
48
  const rendererRegistry = container.get(editor_namespaceObject.FlowRendererRegistry);
48
- const renderKey = params?.renderKey || Component.renderKey || Component.name || '';
49
49
  const renderer = rendererRegistry.tryToGetRendererComponent(renderKey);
50
50
  if (renderer?.type !== editor_namespaceObject.FlowRendererComponentType.REACT) return /*#__PURE__*/ external_react_default().createElement(Component, {
51
51
  ...props
@@ -54,6 +54,7 @@ function createInjectMaterial(Component, params) {
54
54
  ...props
55
55
  });
56
56
  };
57
+ InjectComponent.renderKey = renderKey;
57
58
  return InjectComponent;
58
59
  }
59
60
  exports.createInjectMaterial = __webpack_exports__.createInjectMaterial;
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useEffect, useState } from "react";
3
- import input from "@douyinfe/semi-ui/lib/es/input";
3
+ import { Input } from "@douyinfe/semi-ui";
4
4
  function BlurInput(props) {
5
5
  const [value, setValue] = useState('');
6
6
  useEffect(()=>{
@@ -8,7 +8,7 @@ function BlurInput(props) {
8
8
  }, [
9
9
  props.value
10
10
  ]);
11
- return /*#__PURE__*/ jsx(input, {
11
+ return /*#__PURE__*/ jsx(Input, {
12
12
  ...props,
13
13
  value: value,
14
14
  onChange: (value)=>{
@@ -0,0 +1,135 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useState } from "react";
3
+ import { isPlainObject, last } from "lodash-es";
4
+ import { ASTMatch, useScopeAvailable } from "@flowgram.ai/editor";
5
+ import { Mention, PositionMirror, getCurrentMentionReplaceRange, useEditor } from "@flowgram.ai/coze-editor/react";
6
+ import { Popover, Tree } from "@douyinfe/semi-ui";
7
+ import { FlowValueUtils } from "../../../shared/index.mjs";
8
+ function InputsPicker({ inputsValues, onSelect }) {
9
+ const available = useScopeAvailable();
10
+ const getArrayDrilldown = (type, depth = 1)=>{
11
+ if (ASTMatch.isArray(type.items)) return getArrayDrilldown(type.items, depth + 1);
12
+ return {
13
+ type: type.items,
14
+ depth: depth
15
+ };
16
+ };
17
+ const renderVariable = (variable, keyPath)=>{
18
+ let type = variable?.type;
19
+ let children;
20
+ if (ASTMatch.isObject(type)) children = (type.properties || []).map((_property)=>renderVariable(_property, [
21
+ ...keyPath,
22
+ _property.key
23
+ ])).filter(Boolean);
24
+ if (ASTMatch.isArray(type)) {
25
+ const drilldown = getArrayDrilldown(type);
26
+ if (ASTMatch.isObject(drilldown.type)) children = (drilldown.type.properties || []).map((_property)=>renderVariable(_property, [
27
+ ...keyPath,
28
+ ...new Array(drilldown.depth).fill('[0]'),
29
+ _property.key
30
+ ])).filter(Boolean);
31
+ }
32
+ const key = keyPath.map((_key, idx)=>'[0]' === _key || 0 === idx ? _key : `.${_key}`).join('');
33
+ return {
34
+ key: key,
35
+ label: last(keyPath),
36
+ value: key,
37
+ children
38
+ };
39
+ };
40
+ const getTreeData = (value, keyPath)=>{
41
+ const currKey = keyPath.join('.');
42
+ if (FlowValueUtils.isFlowValue(value)) {
43
+ if (FlowValueUtils.isRef(value)) {
44
+ const variable = available.getByKeyPath(value.content || []);
45
+ if (variable) return renderVariable(variable, keyPath);
46
+ }
47
+ return {
48
+ key: currKey,
49
+ value: currKey,
50
+ label: last(keyPath)
51
+ };
52
+ }
53
+ if (isPlainObject(value)) return {
54
+ key: currKey,
55
+ value: currKey,
56
+ label: last(keyPath),
57
+ children: Object.entries(value).map(([key, value])=>getTreeData(value, [
58
+ ...keyPath,
59
+ key
60
+ ])).filter(Boolean)
61
+ };
62
+ };
63
+ const treeData = useMemo(()=>Object.entries(inputsValues).map(([key, value])=>getTreeData(value, [
64
+ key
65
+ ])).filter(Boolean), []);
66
+ return /*#__PURE__*/ jsx(Tree, {
67
+ treeData: treeData,
68
+ onSelect: (v)=>onSelect(v)
69
+ });
70
+ }
71
+ const DEFAULT_TRIGGER_CHARACTERS = [
72
+ '{',
73
+ '{}',
74
+ '@'
75
+ ];
76
+ function InputsTree({ inputsValues, triggerCharacters = DEFAULT_TRIGGER_CHARACTERS }) {
77
+ const [posKey, setPosKey] = useState('');
78
+ const [visible, setVisible] = useState(false);
79
+ const [position, setPosition] = useState(-1);
80
+ const editor = useEditor();
81
+ function insert(variablePath) {
82
+ const range = getCurrentMentionReplaceRange(editor.$view.state);
83
+ if (!range) return;
84
+ let { from, to } = range;
85
+ while('{' === editor.$view.state.doc.sliceString(from - 1, from))from--;
86
+ while('}' === editor.$view.state.doc.sliceString(to, to + 1))to++;
87
+ editor.replaceText({
88
+ ...range,
89
+ text: '{{' + variablePath + '}}'
90
+ });
91
+ setVisible(false);
92
+ }
93
+ function handleOpenChange(e) {
94
+ setPosition(e.state.selection.main.head);
95
+ setVisible(e.value);
96
+ }
97
+ useEffect(()=>{
98
+ if (!editor) return;
99
+ }, [
100
+ editor,
101
+ visible
102
+ ]);
103
+ return /*#__PURE__*/ jsxs(Fragment, {
104
+ children: [
105
+ /*#__PURE__*/ jsx(Mention, {
106
+ triggerCharacters: triggerCharacters,
107
+ onOpenChange: handleOpenChange
108
+ }),
109
+ /*#__PURE__*/ jsx(Popover, {
110
+ visible: visible,
111
+ trigger: "custom",
112
+ position: "topLeft",
113
+ rePosKey: posKey,
114
+ content: /*#__PURE__*/ jsx("div", {
115
+ style: {
116
+ width: 300,
117
+ maxHeight: 300,
118
+ overflowY: 'auto'
119
+ },
120
+ children: /*#__PURE__*/ jsx(InputsPicker, {
121
+ inputsValues: inputsValues,
122
+ onSelect: (v)=>{
123
+ insert(v);
124
+ }
125
+ })
126
+ }),
127
+ children: /*#__PURE__*/ jsx(PositionMirror, {
128
+ position: position,
129
+ onChange: ()=>setPosKey(String(Math.random()))
130
+ })
131
+ })
132
+ ]
133
+ });
134
+ }
135
+ export { InputsPicker, InputsTree };
@@ -3,7 +3,12 @@ import { useEffect, useState } from "react";
3
3
  import { Mention, PositionMirror, getCurrentMentionReplaceRange, useEditor } from "@flowgram.ai/coze-editor/react";
4
4
  import { Popover, Tree } from "@douyinfe/semi-ui";
5
5
  import { useVariableTree } from "../../variable-selector/index.mjs";
6
- function VariableTree() {
6
+ const DEFAULT_TRIGGER_CHARACTER = [
7
+ '{',
8
+ '{}',
9
+ '@'
10
+ ];
11
+ function VariableTree({ triggerCharacters = DEFAULT_TRIGGER_CHARACTER }) {
7
12
  const [posKey, setPosKey] = useState('');
8
13
  const [visible, setVisible] = useState(false);
9
14
  const [position, setPosition] = useState(-1);
@@ -35,11 +40,7 @@ function VariableTree() {
35
40
  return /*#__PURE__*/ jsxs(Fragment, {
36
41
  children: [
37
42
  /*#__PURE__*/ jsx(Mention, {
38
- triggerCharacters: [
39
- '{',
40
- '{}',
41
- '@'
42
- ],
43
+ triggerCharacters: triggerCharacters,
43
44
  onOpenChange: handleOpenChange
44
45
  }),
45
46
  /*#__PURE__*/ jsx(Popover, {
@@ -49,7 +50,9 @@ function VariableTree() {
49
50
  rePosKey: posKey,
50
51
  content: /*#__PURE__*/ jsx("div", {
51
52
  style: {
52
- width: 300
53
+ width: 300,
54
+ maxHeight: 300,
55
+ overflowY: 'auto'
53
56
  },
54
57
  children: /*#__PURE__*/ jsx(Tree, {
55
58
  treeData: treeData,