@flowgram.ai/form-materials 0.5.5 → 0.5.7
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/batch-outputs/index.js +5 -3
- package/dist/cjs/components/batch-outputs/styles.css +13 -0
- package/dist/cjs/components/blur-input/index.js +4 -1
- package/dist/cjs/components/code-editor/editor.js +16 -12
- package/dist/cjs/components/code-editor/styles.css +4 -0
- package/dist/cjs/components/code-editor-mini/index.js +2 -16
- package/dist/cjs/components/condition-context/hooks/use-condition.js +17 -1
- package/dist/cjs/components/condition-row/index.js +26 -12
- package/dist/cjs/components/condition-row/styles.css +19 -0
- package/dist/cjs/components/coze-editor-extensions/extensions/inputs-tree.js +2 -2
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +44 -15
- package/dist/{esm/components/coze-editor-extensions/styles.mjs → cjs/components/coze-editor-extensions/styles.css} +19 -18
- package/dist/cjs/components/db-condition-row/index.js +29 -14
- package/dist/cjs/components/db-condition-row/styles.css +30 -0
- package/dist/cjs/components/display-inputs-values/index.js +3 -2
- package/dist/cjs/components/display-inputs-values/styles.css +6 -0
- package/dist/cjs/components/display-outputs/index.js +5 -4
- package/dist/cjs/components/display-outputs/styles.css +6 -0
- package/dist/cjs/components/display-schema-tag/index.js +7 -4
- package/dist/cjs/components/display-schema-tag/styles.css +21 -0
- package/dist/cjs/components/display-schema-tree/index.js +12 -7
- package/dist/cjs/components/display-schema-tree/styles.css +64 -0
- package/dist/cjs/components/dynamic-value-input/index.js +9 -5
- package/dist/{esm/components/dynamic-value-input/styles.mjs → cjs/components/dynamic-value-input/styles.css} +23 -30
- package/dist/cjs/components/inputs-values/index.js +5 -3
- package/dist/cjs/components/inputs-values/styles.css +13 -0
- package/dist/cjs/components/inputs-values-tree/icon.js +70 -0
- package/dist/cjs/components/inputs-values-tree/index.js +3 -2
- package/dist/cjs/components/inputs-values-tree/row.js +19 -15
- package/dist/cjs/components/inputs-values-tree/styles.css +85 -0
- package/dist/cjs/components/json-schema-editor/default-value.js +2 -2
- package/dist/cjs/components/json-schema-editor/icon.js +70 -0
- package/dist/cjs/components/json-schema-editor/index.js +37 -25
- package/dist/cjs/components/json-schema-editor/styles.css +113 -0
- package/dist/cjs/components/prompt-editor/editor.js +16 -6
- package/dist/cjs/components/prompt-editor/styles.css +10 -0
- package/dist/cjs/components/prompt-editor-with-inputs/index.js +16 -26
- package/dist/cjs/components/prompt-editor-with-variables/index.js +17 -26
- package/dist/cjs/components/variable-selector/context.js +7 -3
- package/dist/cjs/components/variable-selector/index.js +16 -10
- package/dist/{esm/components/variable-selector/styles.mjs → cjs/components/variable-selector/styles.css} +37 -29
- package/dist/cjs/components/variable-selector/use-variable-tree.js +3 -1
- package/dist/cjs/effects/validate-when-variable-sync/index.js +3 -3
- package/dist/cjs/shared/inject-material/index.js +1 -1
- package/dist/esm/components/batch-outputs/index.mjs +5 -3
- package/dist/esm/components/batch-outputs/styles.css +13 -0
- package/dist/esm/components/blur-input/index.mjs +4 -1
- package/dist/esm/components/code-editor/editor.mjs +16 -11
- package/dist/esm/components/code-editor/styles.css +4 -0
- package/dist/esm/components/code-editor-mini/index.mjs +2 -6
- package/dist/esm/components/condition-context/hooks/use-condition.mjs +18 -2
- package/dist/esm/components/condition-row/index.mjs +26 -12
- package/dist/esm/components/condition-row/styles.css +19 -0
- package/dist/esm/components/coze-editor-extensions/extensions/inputs-tree.mjs +3 -3
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +45 -16
- package/dist/esm/components/coze-editor-extensions/styles.css +37 -0
- package/dist/esm/components/db-condition-row/index.mjs +29 -14
- package/dist/esm/components/db-condition-row/styles.css +30 -0
- package/dist/esm/components/display-inputs-values/index.mjs +3 -2
- package/dist/esm/components/display-inputs-values/styles.css +6 -0
- package/dist/esm/components/display-outputs/index.mjs +5 -4
- package/dist/esm/components/display-outputs/styles.css +6 -0
- package/dist/esm/components/display-schema-tag/index.mjs +8 -5
- package/dist/esm/components/display-schema-tag/styles.css +21 -0
- package/dist/esm/components/display-schema-tree/index.mjs +12 -7
- package/dist/esm/components/display-schema-tree/styles.css +64 -0
- package/dist/esm/components/dynamic-value-input/index.mjs +9 -5
- package/dist/esm/components/dynamic-value-input/styles.css +48 -0
- package/dist/esm/components/inputs-values/index.mjs +5 -3
- package/dist/esm/components/inputs-values/styles.css +13 -0
- package/dist/esm/components/inputs-values-tree/icon.mjs +26 -0
- package/dist/esm/components/inputs-values-tree/index.mjs +3 -2
- package/dist/esm/components/inputs-values-tree/row.mjs +18 -14
- package/dist/esm/components/inputs-values-tree/styles.css +85 -0
- package/dist/esm/components/json-schema-editor/default-value.mjs +2 -2
- package/dist/esm/components/json-schema-editor/icon.mjs +26 -0
- package/dist/esm/components/json-schema-editor/index.mjs +36 -24
- package/dist/esm/components/json-schema-editor/styles.css +113 -0
- package/dist/esm/components/prompt-editor/editor.mjs +16 -6
- package/dist/esm/components/prompt-editor/styles.css +10 -0
- package/dist/esm/components/prompt-editor-with-inputs/index.mjs +12 -4
- package/dist/esm/components/prompt-editor-with-variables/index.mjs +13 -4
- package/dist/esm/components/variable-selector/context.mjs +7 -3
- package/dist/esm/components/variable-selector/index.mjs +17 -11
- package/{src/components/variable-selector/styles.tsx → dist/esm/components/variable-selector/styles.css} +35 -38
- package/dist/esm/components/variable-selector/use-variable-tree.mjs +3 -1
- package/dist/esm/effects/validate-when-variable-sync/index.mjs +3 -3
- package/dist/esm/shared/inject-material/index.mjs +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/batch-outputs/index.d.ts +1 -0
- package/dist/types/components/code-editor/editor.d.ts +1 -0
- package/dist/types/components/condition-context/hooks/use-condition.d.ts +16 -1
- package/dist/types/components/condition-row/index.d.ts +5 -1
- package/dist/types/components/coze-editor-extensions/extensions/variable-tag.d.ts +1 -0
- package/dist/types/components/db-condition-row/index.d.ts +4 -0
- package/dist/types/components/db-condition-row/types.d.ts +0 -1
- package/dist/types/components/display-inputs-values/index.d.ts +1 -0
- package/dist/types/components/display-outputs/index.d.ts +1 -0
- package/dist/types/components/display-schema-tag/index.d.ts +1 -0
- package/dist/types/components/display-schema-tree/index.d.ts +1 -0
- package/dist/types/components/dynamic-value-input/index.d.ts +1 -0
- package/dist/types/components/inputs-values/index.d.ts +1 -0
- package/dist/types/components/inputs-values-tree/icon.d.ts +6 -0
- package/dist/types/components/inputs-values-tree/index.d.ts +1 -0
- package/dist/types/components/inputs-values-tree/row.d.ts +1 -0
- package/dist/types/components/json-schema-editor/icon.d.ts +6 -0
- package/dist/types/components/json-schema-editor/index.d.ts +1 -0
- package/dist/types/components/prompt-editor/editor.d.ts +1 -0
- package/dist/types/components/prompt-editor-with-inputs/index.d.ts +7 -2
- package/dist/types/components/prompt-editor-with-variables/index.d.ts +5 -2
- package/dist/types/components/variable-selector/context.d.ts +16 -3
- package/dist/types/components/variable-selector/index.d.ts +1 -0
- package/package.json +7 -10
- package/src/components/batch-outputs/index.tsx +5 -5
- package/src/components/batch-outputs/{styles.tsx → styles.css} +4 -6
- package/src/components/blur-input/index.tsx +4 -1
- package/src/components/code-editor/editor.tsx +19 -14
- package/src/components/code-editor/styles.css +11 -0
- package/src/components/code-editor-mini/index.tsx +2 -9
- package/src/components/condition-context/hooks/use-condition.tsx +51 -7
- package/src/components/condition-row/index.tsx +27 -22
- package/src/components/condition-row/{styles.tsx → styles.css} +10 -11
- package/src/components/coze-editor-extensions/extensions/inputs-tree.tsx +3 -3
- package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +35 -22
- package/src/components/coze-editor-extensions/{styles.tsx → styles.css} +8 -11
- package/src/components/db-condition-row/index.tsx +29 -26
- package/src/components/db-condition-row/{styles.tsx → styles.css} +14 -16
- package/src/components/db-condition-row/types.ts +0 -1
- package/src/components/display-inputs-values/index.tsx +3 -3
- package/src/components/display-inputs-values/{styles.ts → styles.css} +2 -4
- package/src/components/display-outputs/index.tsx +5 -5
- package/src/components/display-outputs/{styles.ts → styles.css} +2 -4
- package/src/components/display-schema-tag/index.tsx +7 -7
- package/src/components/display-schema-tag/{styles.ts → styles.css} +7 -10
- package/src/components/display-schema-tree/index.tsx +10 -10
- package/src/components/display-schema-tree/{styles.tsx → styles.css} +18 -24
- package/src/components/dynamic-value-input/index.tsx +6 -6
- package/src/components/dynamic-value-input/{styles.tsx → styles.css} +8 -12
- package/src/components/inputs-values/index.tsx +5 -5
- package/src/components/inputs-values/{styles.tsx → styles.css} +4 -6
- package/src/components/inputs-values-tree/icon.tsx +28 -0
- package/src/components/inputs-values-tree/index.tsx +3 -3
- package/src/components/inputs-values-tree/row.tsx +25 -27
- package/src/components/inputs-values-tree/styles.css +94 -0
- package/src/components/json-schema-editor/default-value.tsx +2 -4
- package/src/components/json-schema-editor/icon.tsx +28 -0
- package/src/components/json-schema-editor/index.tsx +45 -50
- package/src/components/json-schema-editor/styles.css +135 -0
- package/src/components/prompt-editor/editor.tsx +18 -7
- package/src/components/prompt-editor/styles.css +14 -0
- package/src/components/prompt-editor-with-inputs/index.tsx +18 -5
- package/src/components/prompt-editor-with-variables/index.tsx +13 -5
- package/src/components/variable-selector/context.tsx +22 -2
- package/src/components/variable-selector/index.tsx +24 -14
- package/src/components/variable-selector/styles.css +70 -0
- package/src/components/variable-selector/use-variable-tree.tsx +9 -1
- package/src/effects/validate-when-variable-sync/index.ts +7 -3
- package/src/shared/inject-material/index.tsx +1 -1
- package/dist/cjs/components/batch-outputs/styles.js +0 -60
- package/dist/cjs/components/condition-row/styles.js +0 -78
- package/dist/cjs/components/coze-editor-extensions/styles.js +0 -89
- package/dist/cjs/components/db-condition-row/styles.js +0 -94
- package/dist/cjs/components/display-inputs-values/styles.js +0 -51
- package/dist/cjs/components/display-outputs/styles.js +0 -51
- package/dist/cjs/components/display-schema-tag/styles.js +0 -71
- package/dist/cjs/components/display-schema-tree/styles.js +0 -135
- package/dist/cjs/components/dynamic-value-input/styles.js +0 -108
- package/dist/cjs/components/inputs-values/styles.js +0 -60
- package/dist/cjs/components/inputs-values-tree/styles.js +0 -177
- package/dist/cjs/components/json-schema-editor/styles.js +0 -231
- package/dist/cjs/components/prompt-editor/styles.js +0 -55
- package/dist/cjs/components/prompt-editor-with-inputs/editor.js +0 -47
- package/dist/cjs/components/prompt-editor-with-variables/editor.js +0 -48
- package/dist/cjs/components/variable-selector/styles.js +0 -114
- package/dist/esm/components/batch-outputs/styles.mjs +0 -13
- package/dist/esm/components/condition-row/styles.mjs +0 -22
- package/dist/esm/components/db-condition-row/styles.mjs +0 -32
- package/dist/esm/components/display-inputs-values/styles.mjs +0 -7
- package/dist/esm/components/display-outputs/styles.mjs +0 -7
- package/dist/esm/components/display-schema-tag/styles.mjs +0 -21
- package/dist/esm/components/display-schema-tree/styles.mjs +0 -79
- package/dist/esm/components/inputs-values/styles.mjs +0 -13
- package/dist/esm/components/inputs-values-tree/styles.mjs +0 -105
- package/dist/esm/components/json-schema-editor/styles.mjs +0 -138
- package/dist/esm/components/prompt-editor/styles.mjs +0 -11
- package/dist/esm/components/prompt-editor-with-inputs/editor.mjs +0 -13
- package/dist/esm/components/prompt-editor-with-variables/editor.mjs +0 -14
- package/dist/types/components/batch-outputs/styles.d.ts +0 -6
- package/dist/types/components/condition-row/styles.d.ts +0 -9
- package/dist/types/components/coze-editor-extensions/styles.d.ts +0 -9
- package/dist/types/components/db-condition-row/styles.d.ts +0 -12
- package/dist/types/components/display-inputs-values/styles.d.ts +0 -5
- package/dist/types/components/display-outputs/styles.d.ts +0 -5
- package/dist/types/components/display-schema-tag/styles.d.ts +0 -8
- package/dist/types/components/display-schema-tree/styles.d.ts +0 -11
- package/dist/types/components/dynamic-value-input/styles.d.ts +0 -8
- package/dist/types/components/inputs-values/styles.d.ts +0 -6
- package/dist/types/components/inputs-values-tree/styles.d.ts +0 -23
- package/dist/types/components/json-schema-editor/styles.d.ts +0 -30
- package/dist/types/components/prompt-editor/styles.d.ts +0 -7
- package/dist/types/components/prompt-editor-with-inputs/editor.d.ts +0 -11
- package/dist/types/components/prompt-editor-with-variables/editor.d.ts +0 -9
- package/dist/types/components/variable-selector/styles.d.ts +0 -14
- package/src/components/inputs-values-tree/styles.tsx +0 -128
- package/src/components/json-schema-editor/styles.tsx +0 -168
- package/src/components/prompt-editor/styles.tsx +0 -18
- package/src/components/prompt-editor-with-inputs/editor.tsx +0 -25
- package/src/components/prompt-editor-with-variables/editor.tsx +0 -20
|
@@ -5,9 +5,24 @@
|
|
|
5
5
|
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
6
6
|
import { IConditionRule, ConditionOpConfigs } from '../types';
|
|
7
7
|
interface HooksParams {
|
|
8
|
+
/**
|
|
9
|
+
* Left schema of condition
|
|
10
|
+
*/
|
|
8
11
|
leftSchema?: IJsonSchema;
|
|
12
|
+
/**
|
|
13
|
+
* Operator of condition
|
|
14
|
+
*/
|
|
9
15
|
operator?: string;
|
|
10
16
|
/**
|
|
17
|
+
* If op is not in opOptionList, clear it
|
|
18
|
+
*/
|
|
19
|
+
onClearOp?: () => void;
|
|
20
|
+
/**
|
|
21
|
+
* If targetSchema updated, clear it
|
|
22
|
+
*/
|
|
23
|
+
onClearRight?: () => void;
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated use ConditionProvider instead
|
|
11
26
|
* custom rule config
|
|
12
27
|
*/
|
|
13
28
|
ruleConfig?: {
|
|
@@ -15,7 +30,7 @@ interface HooksParams {
|
|
|
15
30
|
rules?: Record<string, IConditionRule>;
|
|
16
31
|
};
|
|
17
32
|
}
|
|
18
|
-
export declare function useCondition({ leftSchema, operator, ruleConfig }: HooksParams): {
|
|
33
|
+
export declare function useCondition({ leftSchema, operator, onClearOp, onClearRight, ruleConfig, }: HooksParams): {
|
|
19
34
|
rule: IConditionRule | undefined;
|
|
20
35
|
opConfig: import("..").ConditionOpConfig;
|
|
21
36
|
opOptionList: {
|
|
@@ -5,15 +5,19 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { IConditionRule, ConditionOpConfigs } from '../condition-context';
|
|
7
7
|
import { ConditionRowValueType } from './types';
|
|
8
|
+
import './styles.css';
|
|
8
9
|
interface PropTypes {
|
|
9
10
|
value?: ConditionRowValueType;
|
|
10
11
|
onChange: (value?: ConditionRowValueType) => void;
|
|
11
12
|
style?: React.CSSProperties;
|
|
12
13
|
readonly?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated use ConditionContext instead to pass ruleConfig to multiple
|
|
16
|
+
*/
|
|
13
17
|
ruleConfig?: {
|
|
14
18
|
ops?: ConditionOpConfigs;
|
|
15
19
|
rules?: Record<string, IConditionRule>;
|
|
16
20
|
};
|
|
17
21
|
}
|
|
18
|
-
export declare function ConditionRow({ style, value, onChange, readonly, ruleConfig
|
|
22
|
+
export declare function ConditionRow({ style, value, onChange, readonly, ruleConfig }: PropTypes): React.JSX.Element;
|
|
19
23
|
export { type ConditionRowValueType };
|
|
@@ -5,12 +5,16 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { type ConditionOpConfigs, type IConditionRule } from '../condition-context';
|
|
7
7
|
import { DBConditionOptionType, DBConditionRowValueType } from './types';
|
|
8
|
+
import './styles.css';
|
|
8
9
|
interface PropTypes {
|
|
9
10
|
value?: DBConditionRowValueType;
|
|
10
11
|
onChange: (value?: DBConditionRowValueType) => void;
|
|
11
12
|
style?: React.CSSProperties;
|
|
12
13
|
options?: DBConditionOptionType[];
|
|
13
14
|
readonly?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated use ConditionContext instead to pass ruleConfig to multiple
|
|
17
|
+
*/
|
|
14
18
|
ruleConfig?: {
|
|
15
19
|
ops?: ConditionOpConfigs;
|
|
16
20
|
rules?: Record<string, IConditionRule>;
|
|
@@ -6,6 +6,7 @@ import React from 'react';
|
|
|
6
6
|
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
7
7
|
import { IFlowConstantRefValue } from '../../shared';
|
|
8
8
|
import { ConstantInputStrategy } from '../constant-input';
|
|
9
|
+
import './styles.css';
|
|
9
10
|
interface PropsType {
|
|
10
11
|
value?: IFlowConstantRefValue;
|
|
11
12
|
onChange: (value?: IFlowConstantRefValue) => void;
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
7
7
|
import { ConfigType } from './types';
|
|
8
|
+
import './styles.css';
|
|
8
9
|
export declare function JsonSchemaEditor(props: {
|
|
9
10
|
value?: IJsonSchema;
|
|
10
11
|
onChange?: (value: IJsonSchema) => void;
|
|
@@ -6,6 +6,7 @@ import React from 'react';
|
|
|
6
6
|
import { InferValues } from '@flowgram.ai/coze-editor/react';
|
|
7
7
|
import preset from '@flowgram.ai/coze-editor/preset-prompt';
|
|
8
8
|
import { PropsType } from './types';
|
|
9
|
+
import './styles.css';
|
|
9
10
|
type Preset = typeof preset;
|
|
10
11
|
type Options = Partial<InferValues<Preset[number]>>;
|
|
11
12
|
export interface PromptEditorPropsType extends PropsType {
|
|
@@ -2,5 +2,10 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import type { IInputsValues } from '../../shared/flow-value';
|
|
7
|
+
import { PromptEditorPropsType } from '../prompt-editor';
|
|
8
|
+
export interface PromptEditorWithInputsProps extends PromptEditorPropsType {
|
|
9
|
+
inputsValues: IInputsValues;
|
|
10
|
+
}
|
|
11
|
+
export declare function PromptEditorWithInputs({ inputsValues, ...restProps }: PromptEditorWithInputsProps): React.JSX.Element;
|
|
@@ -2,5 +2,8 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { PromptEditorPropsType } from '../prompt-editor';
|
|
7
|
+
export interface PromptEditorWithVariablesProps extends PromptEditorPropsType {
|
|
8
|
+
}
|
|
9
|
+
export declare function PromptEditorWithVariables(props: PromptEditorWithVariablesProps): React.JSX.Element;
|
|
@@ -3,14 +3,27 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
+
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
6
7
|
import { BaseVariableField } from '@flowgram.ai/editor';
|
|
8
|
+
type VariableField = BaseVariableField<{
|
|
9
|
+
icon?: string | JSX.Element;
|
|
10
|
+
title?: string;
|
|
11
|
+
disabled?: boolean;
|
|
12
|
+
}>;
|
|
7
13
|
export declare const VariableSelectorContext: React.Context<{
|
|
8
|
-
|
|
14
|
+
includeSchema?: IJsonSchema | IJsonSchema[];
|
|
15
|
+
excludeSchema?: IJsonSchema | IJsonSchema[];
|
|
16
|
+
skipVariable?: (variable: VariableField) => boolean;
|
|
9
17
|
}>;
|
|
10
18
|
export declare const useVariableSelectorContext: () => {
|
|
11
|
-
|
|
19
|
+
includeSchema?: IJsonSchema | IJsonSchema[];
|
|
20
|
+
excludeSchema?: IJsonSchema | IJsonSchema[];
|
|
21
|
+
skipVariable?: (variable: VariableField) => boolean;
|
|
12
22
|
};
|
|
13
|
-
export declare const VariableSelectorProvider: ({ children, skipVariable, }: {
|
|
23
|
+
export declare const VariableSelectorProvider: ({ children, skipVariable, includeSchema, excludeSchema, }: {
|
|
14
24
|
skipVariable?: (variable?: BaseVariableField) => boolean;
|
|
25
|
+
includeSchema?: IJsonSchema | IJsonSchema[];
|
|
26
|
+
excludeSchema?: IJsonSchema | IJsonSchema[];
|
|
15
27
|
children: React.ReactNode;
|
|
16
28
|
}) => React.JSX.Element;
|
|
29
|
+
export {};
|
|
@@ -6,6 +6,7 @@ import React from 'react';
|
|
|
6
6
|
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
7
7
|
import { type TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
|
|
8
8
|
import { useVariableTree } from './use-variable-tree';
|
|
9
|
+
import './styles.css';
|
|
9
10
|
export interface VariableSelectorProps {
|
|
10
11
|
value?: string[];
|
|
11
12
|
config?: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/form-materials",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.7",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -67,9 +67,9 @@
|
|
|
67
67
|
"@codemirror/view": "~6.38.0",
|
|
68
68
|
"@codemirror/state": "~6.5.2",
|
|
69
69
|
"zod": "^3.24.4",
|
|
70
|
-
"@flowgram.ai/
|
|
71
|
-
"@flowgram.ai/
|
|
72
|
-
"@flowgram.ai/
|
|
70
|
+
"@flowgram.ai/json-schema": "0.5.7",
|
|
71
|
+
"@flowgram.ai/editor": "0.5.7",
|
|
72
|
+
"@flowgram.ai/coze-editor": "0.5.7"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -77,24 +77,21 @@
|
|
|
77
77
|
"@types/react": "^18",
|
|
78
78
|
"@types/react-dom": "^18",
|
|
79
79
|
"@types/inquirer": "^9.0.9",
|
|
80
|
-
"@types/styled-components": "^5",
|
|
81
80
|
"eslint": "^8.54.0",
|
|
82
81
|
"react": "^18",
|
|
83
82
|
"react-dom": "^18",
|
|
84
|
-
"styled-components": "^5",
|
|
85
83
|
"typescript": "^5.8.3",
|
|
86
84
|
"vitest": "^3.2.4",
|
|
87
85
|
"@rslib/core": "~0.12.4",
|
|
88
86
|
"cross-env": "~7.0.3",
|
|
89
87
|
"@rsbuild/plugin-react": "^1.1.1",
|
|
90
88
|
"date-fns": "~4.1.0",
|
|
91
|
-
"@flowgram.ai/
|
|
92
|
-
"@flowgram.ai/
|
|
89
|
+
"@flowgram.ai/eslint-config": "0.5.7",
|
|
90
|
+
"@flowgram.ai/ts-config": "0.5.7"
|
|
93
91
|
},
|
|
94
92
|
"peerDependencies": {
|
|
95
93
|
"react": ">=16.8",
|
|
96
|
-
"react-dom": ">=16.8"
|
|
97
|
-
"styled-components": ">=5"
|
|
94
|
+
"react-dom": ">=16.8"
|
|
98
95
|
},
|
|
99
96
|
"publishConfig": {
|
|
100
97
|
"access": "public",
|
|
@@ -13,7 +13,7 @@ import { useObjectList } from '@/hooks';
|
|
|
13
13
|
import { InjectVariableSelector } from '@/components/variable-selector';
|
|
14
14
|
|
|
15
15
|
import { PropsType } from './types';
|
|
16
|
-
import
|
|
16
|
+
import './styles.css';
|
|
17
17
|
|
|
18
18
|
export function BatchOutputs(props: PropsType) {
|
|
19
19
|
const { readonly, style } = props;
|
|
@@ -22,9 +22,9 @@ export function BatchOutputs(props: PropsType) {
|
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<div>
|
|
25
|
-
<
|
|
25
|
+
<div className="gedit-m-batch-outputs-rows" style={style}>
|
|
26
26
|
{list.map((item) => (
|
|
27
|
-
<
|
|
27
|
+
<div className="gedit-m-batch-outputs-row" key={item.id}>
|
|
28
28
|
<Input
|
|
29
29
|
style={{ width: 100 }}
|
|
30
30
|
disabled={readonly}
|
|
@@ -44,9 +44,9 @@ export function BatchOutputs(props: PropsType) {
|
|
|
44
44
|
size="small"
|
|
45
45
|
onClick={() => remove(item.id)}
|
|
46
46
|
/>
|
|
47
|
-
</
|
|
47
|
+
</div>
|
|
48
48
|
))}
|
|
49
|
-
</
|
|
49
|
+
</div>
|
|
50
50
|
<Button disabled={readonly} icon={<IconPlus />} size="small" onClick={() => add()}>
|
|
51
51
|
{I18n.t('Add')}
|
|
52
52
|
</Button>
|
|
@@ -3,17 +3,15 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const UIRows = styled.div`
|
|
6
|
+
.gedit-m-batch-outputs-rows {
|
|
9
7
|
display: flex;
|
|
10
8
|
flex-direction: column;
|
|
11
9
|
gap: 10px;
|
|
12
10
|
margin-bottom: 10px;
|
|
13
|
-
|
|
11
|
+
}
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
.gedit-m-batch-outputs-row {
|
|
16
14
|
display: flex;
|
|
17
15
|
align-items: center;
|
|
18
16
|
gap: 5px;
|
|
19
|
-
|
|
17
|
+
}
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { useEffect, useRef } from 'react';
|
|
7
7
|
|
|
8
|
-
import styled, { css } from 'styled-components';
|
|
9
8
|
import {
|
|
10
9
|
ActiveLinePlaceholder,
|
|
11
10
|
createRenderer,
|
|
@@ -17,6 +16,8 @@ import { EditorView } from '@codemirror/view';
|
|
|
17
16
|
|
|
18
17
|
import { getSuffixByLanguageId } from './utils';
|
|
19
18
|
|
|
19
|
+
import './styles.css';
|
|
20
|
+
|
|
20
21
|
const OriginCodeEditor = createRenderer(preset, [
|
|
21
22
|
EditorView.theme({
|
|
22
23
|
'&.cm-focused': {
|
|
@@ -25,13 +26,7 @@ const OriginCodeEditor = createRenderer(preset, [
|
|
|
25
26
|
}),
|
|
26
27
|
]);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
${({ $mini }) =>
|
|
30
|
-
$mini &&
|
|
31
|
-
css`
|
|
32
|
-
height: 24px;
|
|
33
|
-
`}
|
|
34
|
-
`;
|
|
29
|
+
// CSS styles are in styles.css
|
|
35
30
|
|
|
36
31
|
type Preset = typeof preset;
|
|
37
32
|
type Options = Partial<InferValues<Preset[number]>>;
|
|
@@ -62,18 +57,28 @@ export function BaseCodeEditor({
|
|
|
62
57
|
}: CodeEditorPropsType) {
|
|
63
58
|
const editorRef = useRef<EditorAPI | null>(null);
|
|
64
59
|
|
|
60
|
+
const editorValue = String(value || '');
|
|
61
|
+
|
|
65
62
|
useEffect(() => {
|
|
66
63
|
// listen to value change
|
|
67
|
-
if (editorRef.current?.getValue() !==
|
|
68
|
-
|
|
64
|
+
if (editorRef.current?.getValue() !== editorValue) {
|
|
65
|
+
// apply updates on readonly mode
|
|
66
|
+
const editorView = editorRef.current?.$view;
|
|
67
|
+
editorView?.dispatch({
|
|
68
|
+
changes: {
|
|
69
|
+
from: 0,
|
|
70
|
+
to: editorView?.state.doc.length,
|
|
71
|
+
insert: editorValue,
|
|
72
|
+
},
|
|
73
|
+
});
|
|
69
74
|
}
|
|
70
|
-
}, [
|
|
75
|
+
}, [editorValue]);
|
|
71
76
|
|
|
72
77
|
return (
|
|
73
|
-
<
|
|
78
|
+
<div className={`gedit-m-code-editor-container ${mini ? 'mini' : ''}`}>
|
|
74
79
|
<EditorProvider>
|
|
75
80
|
<OriginCodeEditor
|
|
76
|
-
defaultValue={
|
|
81
|
+
defaultValue={editorValue}
|
|
77
82
|
options={{
|
|
78
83
|
uri: `file:///untitled${getSuffixByLanguageId(languageId)}`,
|
|
79
84
|
languageId,
|
|
@@ -101,6 +106,6 @@ export function BaseCodeEditor({
|
|
|
101
106
|
{children}
|
|
102
107
|
</OriginCodeEditor>
|
|
103
108
|
</EditorProvider>
|
|
104
|
-
</
|
|
109
|
+
</div>
|
|
105
110
|
);
|
|
106
111
|
}
|
|
@@ -5,21 +5,14 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
-
import styled from 'styled-components';
|
|
9
|
-
|
|
10
8
|
import { CodeEditor, type CodeEditorPropsType } from '@/components/code-editor';
|
|
11
9
|
|
|
12
|
-
const UIMini = styled.div`
|
|
13
|
-
.ͼ1 .cm-content {
|
|
14
|
-
}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
10
|
/**
|
|
18
11
|
* @deprecated use mini in CodeEditorPropsType instead
|
|
19
12
|
*/
|
|
20
13
|
export function CodeEditorMini(props: CodeEditorPropsType) {
|
|
21
14
|
return (
|
|
22
|
-
<
|
|
15
|
+
<div className="gedit-m-code-editor-mini">
|
|
23
16
|
<CodeEditor
|
|
24
17
|
{...props}
|
|
25
18
|
options={{
|
|
@@ -29,6 +22,6 @@ export function CodeEditorMini(props: CodeEditorPropsType) {
|
|
|
29
22
|
...(props.options || {}),
|
|
30
23
|
}}
|
|
31
24
|
/>
|
|
32
|
-
</
|
|
25
|
+
</div>
|
|
33
26
|
);
|
|
34
27
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { useMemo } from 'react';
|
|
6
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
7
7
|
|
|
8
8
|
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
9
9
|
import { I18n } from '@flowgram.ai/editor';
|
|
@@ -14,10 +14,28 @@ import { IConditionRule, ConditionOpConfigs } from '../types';
|
|
|
14
14
|
import { useConditionContext } from '../context';
|
|
15
15
|
|
|
16
16
|
interface HooksParams {
|
|
17
|
+
/**
|
|
18
|
+
* Left schema of condition
|
|
19
|
+
*/
|
|
17
20
|
leftSchema?: IJsonSchema;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Operator of condition
|
|
24
|
+
*/
|
|
18
25
|
operator?: string;
|
|
19
26
|
|
|
20
27
|
/**
|
|
28
|
+
* If op is not in opOptionList, clear it
|
|
29
|
+
*/
|
|
30
|
+
onClearOp?: () => void;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* If targetSchema updated, clear it
|
|
34
|
+
*/
|
|
35
|
+
onClearRight?: () => void;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated use ConditionProvider instead
|
|
21
39
|
* custom rule config
|
|
22
40
|
*/
|
|
23
41
|
ruleConfig?: {
|
|
@@ -26,26 +44,32 @@ interface HooksParams {
|
|
|
26
44
|
};
|
|
27
45
|
}
|
|
28
46
|
|
|
29
|
-
export function useCondition({
|
|
47
|
+
export function useCondition({
|
|
48
|
+
leftSchema,
|
|
49
|
+
operator,
|
|
50
|
+
onClearOp,
|
|
51
|
+
onClearRight,
|
|
52
|
+
ruleConfig,
|
|
53
|
+
}: HooksParams) {
|
|
30
54
|
const typeManager = useTypeManager();
|
|
31
55
|
const { rules: contextRules, ops: contextOps } = useConditionContext();
|
|
32
56
|
|
|
33
|
-
//
|
|
57
|
+
// Merge user rules and context rules
|
|
34
58
|
const userRules = useMemo(
|
|
35
59
|
() => ruleConfig?.rules || contextRules || {},
|
|
36
60
|
[contextRules, ruleConfig?.rules]
|
|
37
61
|
);
|
|
38
62
|
|
|
39
|
-
//
|
|
63
|
+
// Merge user operators and context operators
|
|
40
64
|
const allOps = useMemo(() => ruleConfig?.ops || contextOps || {}, [contextOps, ruleConfig?.ops]);
|
|
41
65
|
|
|
42
|
-
//
|
|
66
|
+
// Get type configuration
|
|
43
67
|
const config = useMemo(
|
|
44
68
|
() => (leftSchema ? typeManager.getTypeBySchema(leftSchema) : undefined),
|
|
45
69
|
[leftSchema, typeManager]
|
|
46
70
|
);
|
|
47
71
|
|
|
48
|
-
//
|
|
72
|
+
// Calculate rule
|
|
49
73
|
const rule = useMemo(() => {
|
|
50
74
|
if (!config) {
|
|
51
75
|
return undefined;
|
|
@@ -59,7 +83,7 @@ export function useCondition({ leftSchema, operator, ruleConfig }: HooksParams)
|
|
|
59
83
|
return config.conditionRule;
|
|
60
84
|
}, [userRules, leftSchema, config]);
|
|
61
85
|
|
|
62
|
-
//
|
|
86
|
+
// Calculate operator option list
|
|
63
87
|
const opOptionList = useMemo(
|
|
64
88
|
() =>
|
|
65
89
|
Object.keys(rule || {})
|
|
@@ -72,6 +96,16 @@ export function useCondition({ leftSchema, operator, ruleConfig }: HooksParams)
|
|
|
72
96
|
[rule, allOps]
|
|
73
97
|
);
|
|
74
98
|
|
|
99
|
+
// When op not in list, clear it
|
|
100
|
+
useEffect(() => {
|
|
101
|
+
if (!operator || !rule) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!opOptionList.find((item) => item.value === operator)) {
|
|
105
|
+
onClearOp?.();
|
|
106
|
+
}
|
|
107
|
+
}, [operator, opOptionList, onClearOp]);
|
|
108
|
+
|
|
75
109
|
// get target schema
|
|
76
110
|
const targetSchema = useMemo(() => {
|
|
77
111
|
const targetType: string | IJsonSchema | null = rule?.[operator || ''] || null;
|
|
@@ -87,6 +121,16 @@ export function useCondition({ leftSchema, operator, ruleConfig }: HooksParams)
|
|
|
87
121
|
return targetType;
|
|
88
122
|
}, [rule, operator]);
|
|
89
123
|
|
|
124
|
+
const prevTargetSchemaRef = useRef<IJsonSchema | undefined>(undefined);
|
|
125
|
+
|
|
126
|
+
// When type of target schema updated, clear it
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
if (prevTargetSchemaRef.current?.type !== targetSchema?.type) {
|
|
129
|
+
onClearRight?.();
|
|
130
|
+
}
|
|
131
|
+
prevTargetSchemaRef.current = targetSchema;
|
|
132
|
+
}, [targetSchema, onClearRight]);
|
|
133
|
+
|
|
90
134
|
// get current operator config
|
|
91
135
|
const opConfig = useMemo(() => allOps[operator || ''], [operator, allOps]);
|
|
92
136
|
|