@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.
- package/dist/cjs/components/blur-input/index.js +2 -12
- package/dist/cjs/components/{prompt-editor-with-inputs/inputs-picker.js → coze-editor-extensions/extensions/inputs-tree.js} +70 -2
- package/dist/cjs/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.js +10 -7
- package/dist/cjs/components/coze-editor-extensions/index.js +86 -0
- package/dist/cjs/components/index.js +11 -1
- package/dist/cjs/components/json-editor-with-variables/editor.js +10 -6
- package/dist/cjs/components/prompt-editor-with-inputs/editor.js +2 -2
- package/dist/cjs/components/prompt-editor-with-variables/editor.js +3 -4
- package/dist/cjs/components/variable-selector/index.js +1 -0
- package/dist/cjs/index.js +10 -1
- package/dist/cjs/shared/inject-material/index.js +2 -1
- package/dist/esm/components/blur-input/index.mjs +2 -2
- package/dist/esm/components/coze-editor-extensions/extensions/inputs-tree.mjs +135 -0
- package/dist/esm/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.mjs +10 -7
- package/dist/esm/components/coze-editor-extensions/index.mjs +18 -0
- package/dist/esm/components/index.mjs +2 -1
- package/dist/esm/components/json-editor-with-variables/editor.mjs +8 -4
- package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +2 -2
- package/dist/esm/components/prompt-editor-with-variables/editor.mjs +3 -4
- package/dist/esm/components/variable-selector/index.mjs +1 -0
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/shared/inject-material/index.mjs +2 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/blur-input/index.d.ts +7 -1
- package/dist/types/components/{prompt-editor-with-inputs/inputs-picker.d.ts → coze-editor-extensions/extensions/inputs-tree.d.ts} +5 -0
- package/dist/types/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.d.ts +3 -1
- package/dist/types/components/coze-editor-extensions/index.d.ts +18 -0
- package/dist/types/components/dynamic-value-input/index.d.ts +3 -1
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/components/type-selector/index.d.ts +3 -1
- package/dist/types/components/variable-selector/index.d.ts +3 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/shared/inject-material/index.d.ts +6 -4
- package/package.json +10 -9
- package/src/components/blur-input/index.tsx +9 -1
- package/src/components/{prompt-editor-with-inputs/inputs-picker.tsx → coze-editor-extensions/extensions/inputs-tree.tsx} +95 -5
- package/src/components/{prompt-editor-with-variables → coze-editor-extensions}/extensions/variable-tree.tsx +9 -3
- package/src/components/coze-editor-extensions/index.tsx +33 -0
- package/src/components/index.ts +5 -0
- package/src/components/json-editor-with-variables/editor.tsx +4 -4
- package/src/components/prompt-editor-with-inputs/editor.tsx +2 -3
- package/src/components/prompt-editor-with-variables/editor.tsx +3 -5
- package/src/components/variable-selector/index.tsx +2 -0
- package/src/index.ts +3 -0
- package/src/shared/inject-material/index.tsx +10 -6
- package/dist/cjs/components/json-editor-with-variables/extensions/variable-tree.js +0 -97
- package/dist/cjs/components/prompt-editor-with-inputs/extensions/inputs-tree.js +0 -101
- package/dist/cjs/components/prompt-editor-with-variables/extensions/variable-tag.js +0 -151
- package/dist/cjs/components/prompt-editor-with-variables/styles.js +0 -89
- package/dist/esm/components/json-editor-with-variables/extensions/variable-tree.mjs +0 -63
- package/dist/esm/components/prompt-editor-with-inputs/extensions/inputs-tree.mjs +0 -67
- package/dist/esm/components/prompt-editor-with-inputs/inputs-picker.mjs +0 -70
- package/dist/esm/components/prompt-editor-with-variables/extensions/variable-tag.mjs +0 -117
- package/dist/esm/components/prompt-editor-with-variables/styles.mjs +0 -36
- package/dist/types/components/json-editor-with-variables/extensions/variable-tree.d.ts +0 -6
- package/dist/types/components/prompt-editor-with-inputs/extensions/inputs-tree.d.ts +0 -9
- package/dist/types/components/prompt-editor-with-variables/extensions/variable-tag.d.ts +0 -5
- package/dist/types/components/prompt-editor-with-variables/styles.d.ts +0 -9
- package/src/components/json-editor-with-variables/extensions/variable-tree.tsx +0 -83
- package/src/components/prompt-editor-with-inputs/extensions/inputs-tree.tsx +0 -94
- package/src/components/prompt-editor-with-variables/extensions/variable-tag.tsx +0 -174
- package/src/components/prompt-editor-with-variables/styles.tsx +0 -44
- /package/dist/cjs/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.js +0 -0
- /package/dist/cjs/components/{json-editor-with-variables → coze-editor-extensions}/styles.js +0 -0
- /package/dist/esm/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.mjs +0 -0
- /package/dist/esm/components/{json-editor-with-variables → coze-editor-extensions}/styles.mjs +0 -0
- /package/dist/types/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.d.ts +0 -0
- /package/dist/types/components/{json-editor-with-variables → coze-editor-extensions}/styles.d.ts +0 -0
- /package/src/components/{json-editor-with-variables → coze-editor-extensions}/extensions/variable-tag.tsx +0 -0
- /package/src/components/{json-editor-with-variables → coze-editor-extensions}/styles.tsx +0 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { lazy } from "react";
|
|
2
|
+
import { createInjectMaterial } from "../../shared/index.mjs";
|
|
3
|
+
const EditorVariableTree = createInjectMaterial(/*#__PURE__*/ lazy(()=>import("./extensions/variable-tree.mjs").then((module)=>({
|
|
4
|
+
default: module.VariableTree
|
|
5
|
+
}))), {
|
|
6
|
+
renderKey: 'EditorVariableTree'
|
|
7
|
+
});
|
|
8
|
+
const EditorVariableTagInject = createInjectMaterial(/*#__PURE__*/ lazy(()=>import("./extensions/variable-tag.mjs").then((module)=>({
|
|
9
|
+
default: module.VariableTagInject
|
|
10
|
+
}))), {
|
|
11
|
+
renderKey: 'EditorVariableTagInject'
|
|
12
|
+
});
|
|
13
|
+
const EditorInputsTree = createInjectMaterial(/*#__PURE__*/ lazy(()=>import("./extensions/inputs-tree.mjs").then((module)=>({
|
|
14
|
+
default: module.InputsTree
|
|
15
|
+
}))), {
|
|
16
|
+
renderKey: 'EditorInputsTree'
|
|
17
|
+
});
|
|
18
|
+
export { EditorInputsTree, EditorVariableTagInject, EditorVariableTree };
|
|
@@ -7,6 +7,7 @@ import { CodeEditor } from "./code-editor/index.mjs";
|
|
|
7
7
|
import { CodeEditorMini } from "./code-editor-mini/index.mjs";
|
|
8
8
|
import { ConditionRow } from "./condition-row/index.mjs";
|
|
9
9
|
import { ConstantInput } from "./constant-input/index.mjs";
|
|
10
|
+
import { EditorInputsTree, EditorVariableTagInject, EditorVariableTree } from "./coze-editor-extensions/index.mjs";
|
|
10
11
|
import { DBConditionRow } from "./db-condition-row/index.mjs";
|
|
11
12
|
import { DisplayFlowValue } from "./display-flow-value/index.mjs";
|
|
12
13
|
import { DisplayInputsValueAllInTag, DisplayInputsValues } from "./display-inputs-values/index.mjs";
|
|
@@ -23,4 +24,4 @@ import { PromptEditorWithInputs } from "./prompt-editor-with-inputs/index.mjs";
|
|
|
23
24
|
import { PromptEditorWithVariables } from "./prompt-editor-with-variables/index.mjs";
|
|
24
25
|
import { InjectTypeSelector, TypeSelector, getTypeSelectValue, parseTypeSelectValue } from "./type-selector/index.mjs";
|
|
25
26
|
import { InjectVariableSelector, VariableSelector, VariableSelectorProvider, useVariableTree } from "./variable-selector/index.mjs";
|
|
26
|
-
export { AssignRow, AssignRows, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonEditorWithVariables, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, useVariableTree };
|
|
27
|
+
export { AssignRow, AssignRows, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonEditorWithVariables, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, useVariableTree };
|
|
@@ -2,9 +2,11 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import "react";
|
|
3
3
|
import { I18n } from "@flowgram.ai/editor";
|
|
4
4
|
import { transformerCreator } from "@flowgram.ai/coze-editor/preset-code";
|
|
5
|
+
import { EditorVariableTagInject, EditorVariableTree } from "../coze-editor-extensions/index.mjs";
|
|
5
6
|
import { CodeEditor } from "../code-editor/index.mjs";
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const TRIGGER_CHARACTERS = [
|
|
8
|
+
'@'
|
|
9
|
+
];
|
|
8
10
|
function findAllMatches(inputString, regex) {
|
|
9
11
|
const globalRegex = new RegExp(regex, regex.flags.includes('g') ? regex.flags : regex.flags + 'g');
|
|
10
12
|
let match;
|
|
@@ -39,8 +41,10 @@ function JsonEditorWithVariables(props) {
|
|
|
39
41
|
...props.options || {}
|
|
40
42
|
},
|
|
41
43
|
children: [
|
|
42
|
-
/*#__PURE__*/ jsx(
|
|
43
|
-
|
|
44
|
+
/*#__PURE__*/ jsx(EditorVariableTree, {
|
|
45
|
+
triggerCharacters: TRIGGER_CHARACTERS
|
|
46
|
+
}),
|
|
47
|
+
/*#__PURE__*/ jsx(EditorVariableTagInject, {})
|
|
44
48
|
]
|
|
45
49
|
});
|
|
46
50
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import { PromptEditor } from "../prompt-editor/index.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { EditorInputsTree } from "../coze-editor-extensions/index.mjs";
|
|
5
5
|
function PromptEditorWithInputs({ inputsValues, ...restProps }) {
|
|
6
6
|
return /*#__PURE__*/ jsx(PromptEditor, {
|
|
7
7
|
...restProps,
|
|
8
|
-
children: /*#__PURE__*/ jsx(
|
|
8
|
+
children: /*#__PURE__*/ jsx(EditorInputsTree, {
|
|
9
9
|
inputsValues: inputsValues
|
|
10
10
|
})
|
|
11
11
|
});
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
3
|
import { PromptEditor } from "../prompt-editor/index.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { VariableTagInject } from "./extensions/variable-tag.mjs";
|
|
4
|
+
import { EditorVariableTagInject, EditorVariableTree } from "../coze-editor-extensions/index.mjs";
|
|
6
5
|
function PromptEditorWithVariables(props) {
|
|
7
6
|
return /*#__PURE__*/ jsxs(PromptEditor, {
|
|
8
7
|
...props,
|
|
9
8
|
children: [
|
|
10
|
-
/*#__PURE__*/ jsx(
|
|
11
|
-
/*#__PURE__*/ jsx(
|
|
9
|
+
/*#__PURE__*/ jsx(EditorVariableTree, {}),
|
|
10
|
+
/*#__PURE__*/ jsx(EditorVariableTagInject, {})
|
|
12
11
|
]
|
|
13
12
|
});
|
|
14
13
|
}
|
|
@@ -34,6 +34,7 @@ const VariableSelector = ({ value, config = {}, onChange, style, readonly = fals
|
|
|
34
34
|
});
|
|
35
35
|
return icon;
|
|
36
36
|
};
|
|
37
|
+
console.log('debugger treeValue', treeValue);
|
|
37
38
|
return /*#__PURE__*/ jsx(Fragment, {
|
|
38
39
|
children: /*#__PURE__*/ jsx(UITreeSelect, {
|
|
39
40
|
dropdownMatchSelectWidth: false,
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { AssignRow, AssignRows, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonEditorWithVariables, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, useVariableTree } from "./components/index.mjs";
|
|
1
|
+
import { AssignRow, AssignRows, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonEditorWithVariables, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, 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, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, FlowValueUtils, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, JsonSchemaUtils, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, 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, useObjectList, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync, withSuspense };
|
|
8
|
+
export { AssignRow, AssignRows, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, EditorInputsTree, EditorVariableTagInject, EditorVariableTree, FlowValueUtils, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonEditorWithVariables, JsonSchemaEditor, JsonSchemaTypePresetProvider, JsonSchemaUtils, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, 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, useObjectList, useTypeManager, useVariableTree, validateFlowValue, validateWhenVariableSync, withSuspense };
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import react from "react";
|
|
2
2
|
import { FlowRendererComponentType, FlowRendererRegistry, usePlaygroundContainer } from "@flowgram.ai/editor";
|
|
3
3
|
function createInjectMaterial(Component, params) {
|
|
4
|
+
const renderKey = params?.renderKey || Component.renderKey || Component.name || '';
|
|
4
5
|
const InjectComponent = (props)=>{
|
|
5
6
|
const container = usePlaygroundContainer();
|
|
6
7
|
if (!container?.isBound(FlowRendererRegistry)) return /*#__PURE__*/ react.createElement(Component, {
|
|
7
8
|
...props
|
|
8
9
|
});
|
|
9
10
|
const rendererRegistry = container.get(FlowRendererRegistry);
|
|
10
|
-
const renderKey = params?.renderKey || Component.renderKey || Component.name || '';
|
|
11
11
|
const renderer = rendererRegistry.tryToGetRendererComponent(renderKey);
|
|
12
12
|
if (renderer?.type !== FlowRendererComponentType.REACT) return /*#__PURE__*/ react.createElement(Component, {
|
|
13
13
|
...props
|
|
@@ -16,6 +16,7 @@ function createInjectMaterial(Component, params) {
|
|
|
16
16
|
...props
|
|
17
17
|
});
|
|
18
18
|
};
|
|
19
|
+
InjectComponent.renderKey = renderKey;
|
|
19
20
|
return InjectComponent;
|
|
20
21
|
}
|
|
21
22
|
export { createInjectMaterial };
|
|
@@ -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/styles.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.tsx","../src/components/code-editor/index.tsx","../src/components/code-editor/init-worker.ts","../src/components/code-editor/language-features.ts","../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-row/constants.ts","../src/components/condition-row/index.tsx","../src/components/condition-row/styles.tsx","../src/components/condition-row/types.ts","../src/components/condition-row/hooks/useOp.tsx","../src/components/condition-row/hooks/useRule.ts","../src/components/constant-input/index.tsx","../src/components/constant-input/types.ts","../src/components/db-condition-row/index.tsx","../src/components/db-condition-row/styles.tsx","../src/components/db-condition-row/types.ts","../src/components/db-condition-row/hooks/use-left.tsx","../src/components/db-condition-row/hooks/use-op.tsx","../src/components/display-flow-value/index.tsx","../src/components/display-inputs-values/index.tsx","../src/components/display-inputs-values/styles.ts","../src/components/display-outputs/index.tsx","../src/components/display-outputs/styles.ts","../src/components/display-schema-tag/index.tsx","../src/components/display-schema-tag/styles.ts","../src/components/display-schema-tree/index.tsx","../src/components/display-schema-tree/styles.tsx","../src/components/dynamic-value-input/hooks.ts","../src/components/dynamic-value-input/index.tsx","../src/components/dynamic-value-input/styles.tsx","../src/components/inputs-values/index.tsx","../src/components/inputs-values/styles.tsx","../src/components/inputs-values/types.ts","../src/components/inputs-values-tree/index.tsx","../src/components/inputs-values-tree/row.tsx","../src/components/inputs-values-tree/styles.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-
|
|
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/styles.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.tsx","../src/components/code-editor/index.tsx","../src/components/code-editor/init-worker.ts","../src/components/code-editor/language-features.ts","../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-row/constants.ts","../src/components/condition-row/index.tsx","../src/components/condition-row/styles.tsx","../src/components/condition-row/types.ts","../src/components/condition-row/hooks/useOp.tsx","../src/components/condition-row/hooks/useRule.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/styles.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/styles.tsx","../src/components/db-condition-row/types.ts","../src/components/db-condition-row/hooks/use-left.tsx","../src/components/db-condition-row/hooks/use-op.tsx","../src/components/display-flow-value/index.tsx","../src/components/display-inputs-values/index.tsx","../src/components/display-inputs-values/styles.ts","../src/components/display-outputs/index.tsx","../src/components/display-outputs/styles.ts","../src/components/display-schema-tag/index.tsx","../src/components/display-schema-tag/styles.ts","../src/components/display-schema-tree/index.tsx","../src/components/display-schema-tree/styles.tsx","../src/components/dynamic-value-input/hooks.ts","../src/components/dynamic-value-input/index.tsx","../src/components/dynamic-value-input/styles.tsx","../src/components/inputs-values/index.tsx","../src/components/inputs-values/styles.tsx","../src/components/inputs-values/types.ts","../src/components/inputs-values-tree/index.tsx","../src/components/inputs-values-tree/row.tsx","../src/components/inputs-values-tree/styles.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/index.tsx","../src/components/json-schema-editor/styles.tsx","../src/components/json-schema-editor/types.ts","../src/components/prompt-editor/editor.tsx","../src/components/prompt-editor/index.tsx","../src/components/prompt-editor/styles.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/editor.tsx","../src/components/prompt-editor-with-inputs/index.tsx","../src/components/prompt-editor-with-variables/editor.tsx","../src/components/prompt-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/styles.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/manager.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/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.8.3"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
1
5
|
/**
|
|
2
6
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
7
|
* SPDX-License-Identifier: MIT
|
|
4
8
|
*/
|
|
5
9
|
import React from 'react';
|
|
6
|
-
import {
|
|
10
|
+
import { Input } from '@douyinfe/semi-ui';
|
|
11
|
+
type InputProps = React.ComponentPropsWithoutRef<typeof Input>;
|
|
7
12
|
export declare function BlurInput(props: InputProps): React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { IFlowValue } from '../../../shared';
|
|
6
7
|
export declare function InputsPicker({ inputsValues, onSelect, }: {
|
|
7
8
|
inputsValues: any;
|
|
8
9
|
onSelect: (v: string) => void;
|
|
9
10
|
}): React.JSX.Element;
|
|
11
|
+
export declare function InputsTree({ inputsValues, triggerCharacters, }: {
|
|
12
|
+
inputsValues: Record<string, IFlowValue>;
|
|
13
|
+
triggerCharacters?: string[];
|
|
14
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
export declare const EditorVariableTree: import("react").FC<{
|
|
6
|
+
triggerCharacters?: string[];
|
|
7
|
+
}> & {
|
|
8
|
+
renderKey?: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const EditorVariableTagInject: import("react").FC<unknown> & {
|
|
11
|
+
renderKey?: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const EditorInputsTree: import("react").FC<{
|
|
14
|
+
inputsValues: Record<string, import("../../shared").IFlowValue>;
|
|
15
|
+
triggerCharacters?: string[];
|
|
16
|
+
}> & {
|
|
17
|
+
renderKey?: string;
|
|
18
|
+
};
|
|
@@ -23,5 +23,7 @@ export declare function DynamicValueInput({ value, onChange, readonly, style, sc
|
|
|
23
23
|
export declare namespace DynamicValueInput {
|
|
24
24
|
var renderKey: string;
|
|
25
25
|
}
|
|
26
|
-
export declare const InjectDynamicValueInput: React.FC<PropsType
|
|
26
|
+
export declare const InjectDynamicValueInput: React.FC<PropsType> & {
|
|
27
|
+
renderKey?: string;
|
|
28
|
+
};
|
|
27
29
|
export {};
|
|
@@ -11,6 +11,7 @@ export { CodeEditor, type CodeEditorPropsType } from './code-editor';
|
|
|
11
11
|
export { CodeEditorMini } from './code-editor-mini';
|
|
12
12
|
export { ConditionRow, type ConditionRowValueType } from './condition-row';
|
|
13
13
|
export { ConstantInput, type ConstantInputStrategy } from './constant-input';
|
|
14
|
+
export { EditorVariableTagInject, EditorVariableTree, EditorInputsTree, } from './coze-editor-extensions';
|
|
14
15
|
export { DBConditionRow, type DBConditionOptionType, type DBConditionRowValueType, } from './db-condition-row';
|
|
15
16
|
export { DisplayFlowValue } from './display-flow-value';
|
|
16
17
|
export { DisplayInputsValueAllInTag, DisplayInputsValues } from './display-inputs-values';
|
|
@@ -20,4 +20,6 @@ export declare function TypeSelector(props: TypeSelectorProps): React.JSX.Elemen
|
|
|
20
20
|
export declare namespace TypeSelector {
|
|
21
21
|
var renderKey: string;
|
|
22
22
|
}
|
|
23
|
-
export declare const InjectTypeSelector: React.FC<TypeSelectorProps
|
|
23
|
+
export declare const InjectTypeSelector: React.FC<TypeSelectorProps> & {
|
|
24
|
+
renderKey?: string;
|
|
25
|
+
};
|
|
@@ -25,5 +25,7 @@ export declare const VariableSelector: {
|
|
|
25
25
|
({ value, config, onChange, style, readonly, includeSchema, excludeSchema, hasError, triggerRender, }: VariableSelectorProps): React.JSX.Element;
|
|
26
26
|
renderKey: string;
|
|
27
27
|
};
|
|
28
|
-
export declare const InjectVariableSelector: React.FC<VariableSelectorProps
|
|
28
|
+
export declare const InjectVariableSelector: React.FC<VariableSelectorProps> & {
|
|
29
|
+
renderKey?: string;
|
|
30
|
+
};
|
|
29
31
|
export { VariableSelectorProvider } from './context';
|
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, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonEditorWithVariables, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, VariableSelectorProvider, getTypeSelectValue, parseTypeSelectValue, type AssignValueType, type CodeEditorPropsType, type ConditionRowValueType, type ConstantInputStrategy, type DBConditionOptionType, type DBConditionRowValueType, type JsonEditorWithVariablesProps, type PromptEditorPropsType, type PromptEditorWithInputsProps, type PromptEditorWithVariablesProps, type TypeSelectorProps, type VariableSelectorProps, useVariableTree, } from './components';
|
|
5
|
+
export { AssignRow, AssignRows, BatchOutputs, BatchVariableSelector, BlurInput, CodeEditor, CodeEditorMini, ConditionRow, ConstantInput, DBConditionRow, DisplayFlowValue, DisplayInputsValueAllInTag, DisplayInputsValues, DisplayOutputs, DisplaySchemaTag, DisplaySchemaTree, DynamicValueInput, InjectDynamicValueInput, InjectTypeSelector, InjectVariableSelector, InputsValues, InputsValuesTree, JsonEditorWithVariables, JsonSchemaEditor, PromptEditor, PromptEditorWithInputs, PromptEditorWithVariables, TypeSelector, VariableSelector, VariableSelectorProvider, EditorVariableTagInject, EditorVariableTree, EditorInputsTree, getTypeSelectValue, parseTypeSelectValue, type AssignValueType, type CodeEditorPropsType, type ConditionRowValueType, type ConstantInputStrategy, type DBConditionOptionType, type DBConditionRowValueType, type JsonEditorWithVariablesProps, type PromptEditorPropsType, type PromptEditorWithInputsProps, type PromptEditorWithVariablesProps, type TypeSelectorProps, type VariableSelectorProps, 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';
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
+
type WithRenderKey<T> = T & {
|
|
7
|
+
renderKey?: string;
|
|
8
|
+
};
|
|
6
9
|
/**
|
|
7
10
|
* Creates a material component wrapper with dependency injection support
|
|
8
11
|
*
|
|
@@ -39,8 +42,7 @@ import React from 'react';
|
|
|
39
42
|
* @param params.renderKey - Custom render key name, highest priority
|
|
40
43
|
* @returns Wrapper component with dependency injection support
|
|
41
44
|
*/
|
|
42
|
-
export declare function createInjectMaterial<Props>(Component: React.FC<Props>
|
|
43
|
-
renderKey?: string;
|
|
44
|
-
}, params?: {
|
|
45
|
+
export declare function createInjectMaterial<Props>(Component: WithRenderKey<React.FC<Props> | React.ExoticComponent<Props>>, params?: {
|
|
45
46
|
renderKey?: string;
|
|
46
|
-
}): React.FC<Props
|
|
47
|
+
}): WithRenderKey<React.FC<Props>>;
|
|
48
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/form-materials",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.11",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
"@codemirror/view": "~6.38.0",
|
|
31
31
|
"@codemirror/state": "~6.5.2",
|
|
32
32
|
"zod": "^3.24.4",
|
|
33
|
-
"@flowgram.ai/
|
|
34
|
-
"@flowgram.ai/
|
|
35
|
-
"@flowgram.ai/
|
|
33
|
+
"@flowgram.ai/json-schema": "0.4.11",
|
|
34
|
+
"@flowgram.ai/coze-editor": "0.4.11",
|
|
35
|
+
"@flowgram.ai/editor": "0.4.11"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -48,9 +48,10 @@
|
|
|
48
48
|
"typescript": "^5.8.3",
|
|
49
49
|
"vitest": "^0.34.6",
|
|
50
50
|
"@rslib/core": "~0.12.4",
|
|
51
|
+
"cross-env": "~7.0.3",
|
|
51
52
|
"@rsbuild/plugin-react": "^1.1.1",
|
|
52
|
-
"@flowgram.ai/eslint-config": "0.4.
|
|
53
|
-
"@flowgram.ai/ts-config": "0.4.
|
|
53
|
+
"@flowgram.ai/eslint-config": "0.4.11",
|
|
54
|
+
"@flowgram.ai/ts-config": "0.4.11"
|
|
54
55
|
},
|
|
55
56
|
"peerDependencies": {
|
|
56
57
|
"react": ">=16.8",
|
|
@@ -62,9 +63,9 @@
|
|
|
62
63
|
"registry": "https://registry.npmjs.org/"
|
|
63
64
|
},
|
|
64
65
|
"scripts": {
|
|
65
|
-
"build": "rslib build",
|
|
66
|
-
"build:fast": "rslib build",
|
|
67
|
-
"build:watch": "
|
|
66
|
+
"build": "cross-env NODE_ENV=production rslib build",
|
|
67
|
+
"build:fast": "cross-env NODE_ENV=development rslib build",
|
|
68
|
+
"build:watch": "npm run build:fast",
|
|
68
69
|
"name-export": "node scripts/name-export.js",
|
|
69
70
|
"clean": "rimraf dist",
|
|
70
71
|
"test": "exit 0",
|
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
/* eslint-disable react/prop-types */
|
|
7
|
+
/**
|
|
8
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
9
|
+
* SPDX-License-Identifier: MIT
|
|
10
|
+
*/
|
|
11
|
+
|
|
6
12
|
import React, { useEffect, useState } from 'react';
|
|
7
13
|
|
|
8
|
-
import
|
|
14
|
+
import { Input } from '@douyinfe/semi-ui';
|
|
15
|
+
|
|
16
|
+
type InputProps = React.ComponentPropsWithoutRef<typeof Input>;
|
|
9
17
|
|
|
10
18
|
export function BlurInput(props: InputProps) {
|
|
11
19
|
const [value, setValue] = useState('');
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import React, { useMemo } from 'react';
|
|
6
|
+
import React, { useMemo, useEffect, useState } from 'react';
|
|
7
7
|
|
|
8
8
|
import { isPlainObject, last } from 'lodash-es';
|
|
9
9
|
import {
|
|
@@ -13,10 +13,18 @@ import {
|
|
|
13
13
|
type BaseVariableField,
|
|
14
14
|
useScopeAvailable,
|
|
15
15
|
} from '@flowgram.ai/editor';
|
|
16
|
-
import {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
import {
|
|
17
|
+
Mention,
|
|
18
|
+
MentionOpenChangeEvent,
|
|
19
|
+
getCurrentMentionReplaceRange,
|
|
20
|
+
useEditor,
|
|
21
|
+
PositionMirror,
|
|
22
|
+
} from '@flowgram.ai/coze-editor/react';
|
|
23
|
+
import { EditorAPI } from '@flowgram.ai/coze-editor/preset-prompt';
|
|
24
|
+
import { type TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
|
|
25
|
+
import { Tree, Popover } from '@douyinfe/semi-ui';
|
|
26
|
+
|
|
27
|
+
import { IFlowValue, FlowValueUtils } from '@/shared';
|
|
20
28
|
|
|
21
29
|
type VariableField = BaseVariableField<{ icon?: string | JSX.Element; title?: string }>;
|
|
22
30
|
|
|
@@ -115,3 +123,85 @@ export function InputsPicker({
|
|
|
115
123
|
|
|
116
124
|
return <Tree treeData={treeData} onSelect={(v) => onSelect(v)} />;
|
|
117
125
|
}
|
|
126
|
+
|
|
127
|
+
const DEFAULT_TRIGGER_CHARACTERS = ['{', '{}', '@'];
|
|
128
|
+
|
|
129
|
+
export function InputsTree({
|
|
130
|
+
inputsValues,
|
|
131
|
+
triggerCharacters = DEFAULT_TRIGGER_CHARACTERS,
|
|
132
|
+
}: {
|
|
133
|
+
inputsValues: Record<string, IFlowValue>;
|
|
134
|
+
triggerCharacters?: string[];
|
|
135
|
+
}) {
|
|
136
|
+
const [posKey, setPosKey] = useState('');
|
|
137
|
+
const [visible, setVisible] = useState(false);
|
|
138
|
+
const [position, setPosition] = useState(-1);
|
|
139
|
+
const editor = useEditor<EditorAPI>();
|
|
140
|
+
|
|
141
|
+
function insert(variablePath: string) {
|
|
142
|
+
const range = getCurrentMentionReplaceRange(editor.$view.state);
|
|
143
|
+
|
|
144
|
+
if (!range) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* When user input {{xxxx}}, {{{xxx}}}(more brackets if possible), replace all brackets with {{xxxx}}
|
|
150
|
+
*/
|
|
151
|
+
let { from, to } = range;
|
|
152
|
+
while (editor.$view.state.doc.sliceString(from - 1, from) === '{') {
|
|
153
|
+
from--;
|
|
154
|
+
}
|
|
155
|
+
while (editor.$view.state.doc.sliceString(to, to + 1) === '}') {
|
|
156
|
+
to++;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
editor.replaceText({
|
|
160
|
+
...range,
|
|
161
|
+
text: '{{' + variablePath + '}}',
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
setVisible(false);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
function handleOpenChange(e: MentionOpenChangeEvent) {
|
|
168
|
+
setPosition(e.state.selection.main.head);
|
|
169
|
+
setVisible(e.value);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
useEffect(() => {
|
|
173
|
+
if (!editor) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}, [editor, visible]);
|
|
177
|
+
|
|
178
|
+
return (
|
|
179
|
+
<>
|
|
180
|
+
<Mention triggerCharacters={triggerCharacters} onOpenChange={handleOpenChange} />
|
|
181
|
+
|
|
182
|
+
<Popover
|
|
183
|
+
visible={visible}
|
|
184
|
+
trigger="custom"
|
|
185
|
+
position="topLeft"
|
|
186
|
+
rePosKey={posKey}
|
|
187
|
+
content={
|
|
188
|
+
<div style={{ width: 300, maxHeight: 300, overflowY: 'auto' }}>
|
|
189
|
+
<InputsPicker
|
|
190
|
+
inputsValues={inputsValues}
|
|
191
|
+
onSelect={(v) => {
|
|
192
|
+
insert(v);
|
|
193
|
+
}}
|
|
194
|
+
/>
|
|
195
|
+
</div>
|
|
196
|
+
}
|
|
197
|
+
>
|
|
198
|
+
{/* PositionMirror allows the Popover to appear at the specified cursor position */}
|
|
199
|
+
<PositionMirror
|
|
200
|
+
position={position}
|
|
201
|
+
// When Doc scroll, update position
|
|
202
|
+
onChange={() => setPosKey(String(Math.random()))}
|
|
203
|
+
/>
|
|
204
|
+
</Popover>
|
|
205
|
+
</>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
@@ -17,7 +17,13 @@ import { Popover, Tree } from '@douyinfe/semi-ui';
|
|
|
17
17
|
|
|
18
18
|
import { useVariableTree } from '@/components/variable-selector';
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const DEFAULT_TRIGGER_CHARACTER = ['{', '{}', '@'];
|
|
21
|
+
|
|
22
|
+
export function VariableTree({
|
|
23
|
+
triggerCharacters = DEFAULT_TRIGGER_CHARACTER,
|
|
24
|
+
}: {
|
|
25
|
+
triggerCharacters?: string[];
|
|
26
|
+
}) {
|
|
21
27
|
const [posKey, setPosKey] = useState('');
|
|
22
28
|
const [visible, setVisible] = useState(false);
|
|
23
29
|
const [position, setPosition] = useState(-1);
|
|
@@ -65,7 +71,7 @@ export function VariableTree() {
|
|
|
65
71
|
|
|
66
72
|
return (
|
|
67
73
|
<>
|
|
68
|
-
<Mention triggerCharacters={
|
|
74
|
+
<Mention triggerCharacters={triggerCharacters} onOpenChange={handleOpenChange} />
|
|
69
75
|
|
|
70
76
|
<Popover
|
|
71
77
|
visible={visible}
|
|
@@ -73,7 +79,7 @@ export function VariableTree() {
|
|
|
73
79
|
position="topLeft"
|
|
74
80
|
rePosKey={posKey}
|
|
75
81
|
content={
|
|
76
|
-
<div style={{ width: 300 }}>
|
|
82
|
+
<div style={{ width: 300, maxHeight: 300, overflowY: 'auto' }}>
|
|
77
83
|
<Tree
|
|
78
84
|
treeData={treeData}
|
|
79
85
|
onSelect={(v) => {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { lazy } from 'react';
|
|
7
|
+
|
|
8
|
+
import { createInjectMaterial } from '@/shared';
|
|
9
|
+
|
|
10
|
+
export const EditorVariableTree = createInjectMaterial(
|
|
11
|
+
lazy(() =>
|
|
12
|
+
import('./extensions/variable-tree').then((module) => ({ default: module.VariableTree }))
|
|
13
|
+
),
|
|
14
|
+
{
|
|
15
|
+
renderKey: 'EditorVariableTree',
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
export const EditorVariableTagInject = createInjectMaterial(
|
|
20
|
+
lazy(() =>
|
|
21
|
+
import('./extensions/variable-tag').then((module) => ({ default: module.VariableTagInject }))
|
|
22
|
+
),
|
|
23
|
+
{
|
|
24
|
+
renderKey: 'EditorVariableTagInject',
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
export const EditorInputsTree = createInjectMaterial(
|
|
29
|
+
lazy(() => import('./extensions/inputs-tree').then((module) => ({ default: module.InputsTree }))),
|
|
30
|
+
{
|
|
31
|
+
renderKey: 'EditorInputsTree',
|
|
32
|
+
}
|
|
33
|
+
);
|
package/src/components/index.ts
CHANGED
|
@@ -12,6 +12,11 @@ export { CodeEditor, type CodeEditorPropsType } from './code-editor';
|
|
|
12
12
|
export { CodeEditorMini } from './code-editor-mini';
|
|
13
13
|
export { ConditionRow, type ConditionRowValueType } from './condition-row';
|
|
14
14
|
export { ConstantInput, type ConstantInputStrategy } from './constant-input';
|
|
15
|
+
export {
|
|
16
|
+
EditorVariableTagInject,
|
|
17
|
+
EditorVariableTree,
|
|
18
|
+
EditorInputsTree,
|
|
19
|
+
} from './coze-editor-extensions';
|
|
15
20
|
export {
|
|
16
21
|
DBConditionRow,
|
|
17
22
|
type DBConditionOptionType,
|
|
@@ -9,10 +9,10 @@ import { I18n } from '@flowgram.ai/editor';
|
|
|
9
9
|
import { transformerCreator } from '@flowgram.ai/coze-editor/preset-code';
|
|
10
10
|
import { Text } from '@flowgram.ai/coze-editor/language-json';
|
|
11
11
|
|
|
12
|
+
import { EditorVariableTree, EditorVariableTagInject } from '@/components/coze-editor-extensions';
|
|
12
13
|
import { CodeEditor, type CodeEditorPropsType } from '@/components/code-editor';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
import { VariableTagInject } from './extensions/variable-tag';
|
|
15
|
+
const TRIGGER_CHARACTERS = ['@'];
|
|
16
16
|
|
|
17
17
|
type Match = { match: string; range: [number, number] };
|
|
18
18
|
function findAllMatches(inputString: string, regex: RegExp): Match[] {
|
|
@@ -62,8 +62,8 @@ export function JsonEditorWithVariables(props: JsonEditorWithVariablesProps) {
|
|
|
62
62
|
...(props.options || {}),
|
|
63
63
|
}}
|
|
64
64
|
>
|
|
65
|
-
<
|
|
66
|
-
<
|
|
65
|
+
<EditorVariableTree triggerCharacters={TRIGGER_CHARACTERS} />
|
|
66
|
+
<EditorVariableTagInject />
|
|
67
67
|
</CodeEditor>
|
|
68
68
|
);
|
|
69
69
|
}
|
|
@@ -6,8 +6,7 @@
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { PromptEditor, PromptEditorPropsType } from '@/components/prompt-editor';
|
|
9
|
-
|
|
10
|
-
import { InputsTree } from './extensions/inputs-tree';
|
|
9
|
+
import { EditorInputsTree } from '@/components/coze-editor-extensions';
|
|
11
10
|
|
|
12
11
|
export interface PromptEditorWithInputsProps extends PromptEditorPropsType {
|
|
13
12
|
inputsValues: any;
|
|
@@ -19,7 +18,7 @@ export function PromptEditorWithInputs({
|
|
|
19
18
|
}: PromptEditorWithInputsProps) {
|
|
20
19
|
return (
|
|
21
20
|
<PromptEditor {...restProps}>
|
|
22
|
-
<
|
|
21
|
+
<EditorInputsTree inputsValues={inputsValues} />
|
|
23
22
|
</PromptEditor>
|
|
24
23
|
);
|
|
25
24
|
}
|