@flowgram.ai/form-materials 0.4.13 → 0.4.14
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/code-editor/editor.js +54 -77
- package/dist/cjs/components/code-editor/index.js +10 -2
- package/dist/cjs/components/code-editor/language-features.js +119 -16
- package/dist/cjs/components/code-editor/theme/dark.js +120 -50
- package/dist/cjs/components/code-editor/theme/light.js +110 -61
- package/dist/cjs/components/condition-context/context.js +59 -0
- package/dist/cjs/components/condition-context/hooks/use-condition.js +97 -0
- package/dist/cjs/components/condition-context/index.js +47 -0
- package/dist/cjs/components/condition-context/op.js +117 -0
- package/dist/cjs/components/condition-row/index.js +43 -26
- package/dist/cjs/components/condition-row/types.js +1 -35
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +4 -3
- package/dist/cjs/components/coze-editor-extensions/extensions/variable-tree.js +3 -0
- package/dist/cjs/components/db-condition-row/index.js +59 -34
- package/dist/cjs/form-plugins/infer-inputs-plugin/index.js +30 -3
- package/dist/cjs/plugins/json-schema-preset/create-type-preset-plugin.js +1 -0
- package/dist/cjs/plugins/json-schema-preset/react.js +1 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/array.js +30 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +23 -0
- package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +31 -2
- package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +9 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +34 -1
- package/dist/cjs/{components/code-editor/init-worker.js → plugins/json-schema-preset/type-definition/map.js} +21 -23
- package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +34 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/object.js +6 -1
- package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +30 -1
- package/dist/cjs/plugins/json-schema-preset/types.js +18 -0
- package/dist/cjs/shared/flow-value/utils.js +22 -8
- package/dist/esm/components/code-editor/editor.mjs +4 -9
- package/dist/esm/components/code-editor/index.mjs +5 -2
- package/dist/esm/components/code-editor/language-features.mjs +49 -13
- package/dist/esm/components/code-editor/theme/dark.mjs +117 -50
- package/dist/esm/components/code-editor/theme/light.mjs +108 -62
- package/dist/esm/components/condition-context/context.mjs +19 -0
- package/dist/esm/components/condition-context/hooks/use-condition.mjs +63 -0
- package/dist/esm/components/condition-context/index.mjs +4 -0
- package/dist/esm/components/condition-context/op.mjs +80 -0
- package/dist/esm/components/condition-row/index.mjs +45 -28
- package/dist/esm/components/condition-row/types.mjs +0 -18
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +4 -3
- package/dist/esm/components/coze-editor-extensions/extensions/variable-tree.mjs +3 -0
- package/dist/esm/components/db-condition-row/index.mjs +59 -34
- package/dist/esm/form-plugins/infer-inputs-plugin/index.mjs +31 -4
- package/dist/esm/plugins/json-schema-preset/create-type-preset-plugin.mjs +2 -1
- package/dist/esm/plugins/json-schema-preset/react.mjs +2 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/array.mjs +30 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +23 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +31 -2
- package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +7 -2
- package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +34 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/map.mjs +20 -0
- package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +34 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/object.mjs +6 -1
- package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +30 -1
- package/dist/esm/plugins/json-schema-preset/types.mjs +0 -0
- package/dist/esm/shared/flow-value/utils.mjs +22 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/components/code-editor/editor.d.ts +0 -2
- package/dist/types/components/code-editor/language-features.d.ts +4 -1
- package/dist/types/components/code-editor/theme/dark.d.ts +29 -0
- package/dist/types/components/code-editor/theme/light.d.ts +24 -0
- package/dist/types/components/condition-context/context.d.ts +14 -0
- package/dist/types/components/condition-context/hooks/use-condition.d.ts +29 -0
- package/dist/types/components/condition-context/index.d.ts +8 -0
- package/dist/types/components/condition-context/op.d.ts +22 -0
- package/dist/types/components/condition-context/types.d.ts +14 -0
- package/dist/types/components/condition-row/index.d.ts +4 -7
- package/dist/types/components/condition-row/types.d.ts +0 -24
- package/dist/types/components/db-condition-row/index.d.ts +4 -3
- package/dist/types/components/db-condition-row/types.d.ts +0 -8
- package/dist/types/form-plugins/infer-inputs-plugin/index.d.ts +4 -0
- package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/index.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/react.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/array.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/boolean.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/date-time.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/index.d.ts +3 -1
- package/dist/types/plugins/json-schema-preset/type-definition/integer.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/map.d.ts +6 -0
- package/dist/types/plugins/json-schema-preset/type-definition/number.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/object.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/type-definition/string.d.ts +1 -1
- package/dist/types/plugins/json-schema-preset/{manager.d.ts → types.d.ts} +5 -0
- package/dist/types/shared/flow-value/utils.d.ts +3 -1
- package/package.json +7 -6
- package/src/components/code-editor/editor.tsx +7 -10
- package/src/components/code-editor/index.tsx +3 -1
- package/src/components/code-editor/language-features.ts +52 -14
- package/src/components/code-editor/theme/dark.ts +62 -77
- package/src/components/code-editor/theme/light.ts +60 -91
- package/src/components/condition-context/context.tsx +28 -0
- package/src/components/condition-context/hooks/use-condition.tsx +99 -0
- package/src/components/condition-context/index.tsx +14 -0
- package/src/components/condition-context/op.ts +86 -0
- package/src/components/condition-context/types.ts +22 -0
- package/src/components/condition-row/index.tsx +44 -22
- package/src/components/condition-row/types.ts +0 -30
- package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +6 -3
- package/src/components/coze-editor-extensions/extensions/variable-tree.tsx +3 -0
- package/src/components/db-condition-row/index.tsx +76 -24
- package/src/components/db-condition-row/types.ts +0 -13
- package/src/form-plugins/infer-inputs-plugin/index.ts +62 -14
- package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +4 -2
- package/src/plugins/json-schema-preset/index.tsx +1 -1
- package/src/plugins/json-schema-preset/react.tsx +5 -2
- package/src/plugins/json-schema-preset/type-definition/array.tsx +10 -1
- package/src/plugins/json-schema-preset/type-definition/boolean.tsx +17 -1
- package/src/plugins/json-schema-preset/type-definition/date-time.tsx +21 -2
- package/src/plugins/json-schema-preset/type-definition/index.tsx +10 -1
- package/src/plugins/json-schema-preset/type-definition/integer.tsx +19 -1
- package/src/plugins/json-schema-preset/type-definition/map.tsx +31 -0
- package/src/plugins/json-schema-preset/type-definition/number.tsx +19 -1
- package/src/plugins/json-schema-preset/type-definition/object.tsx +6 -1
- package/src/plugins/json-schema-preset/type-definition/string.tsx +19 -1
- package/src/plugins/json-schema-preset/{manager.ts → types.ts} +7 -0
- package/src/shared/flow-value/utils.ts +22 -9
- package/dist/cjs/components/condition-row/constants.js +0 -165
- package/dist/cjs/components/condition-row/hooks/useOp.js +0 -78
- package/dist/cjs/components/condition-row/hooks/useRule.js +0 -68
- package/dist/cjs/components/db-condition-row/hooks/use-left.js +0 -86
- package/dist/cjs/components/db-condition-row/hooks/use-op.js +0 -79
- package/dist/esm/components/code-editor/init-worker.mjs +0 -19
- package/dist/esm/components/condition-row/constants.mjs +0 -128
- package/dist/esm/components/condition-row/hooks/useOp.mjs +0 -44
- package/dist/esm/components/condition-row/hooks/useRule.mjs +0 -34
- package/dist/esm/components/db-condition-row/hooks/use-left.mjs +0 -52
- package/dist/esm/components/db-condition-row/hooks/use-op.mjs +0 -45
- package/dist/types/components/code-editor/init-worker.d.ts +0 -5
- package/dist/types/components/condition-row/constants.d.ts +0 -7
- package/dist/types/components/condition-row/hooks/useOp.d.ts +0 -18
- package/dist/types/components/condition-row/hooks/useRule.d.ts +0 -9
- package/dist/types/components/db-condition-row/hooks/use-left.d.ts +0 -18
- package/dist/types/components/db-condition-row/hooks/use-op.d.ts +0 -18
- package/src/components/code-editor/init-worker.ts +0 -27
- package/src/components/condition-row/constants.ts +0 -134
- package/src/components/condition-row/hooks/useOp.tsx +0 -56
- package/src/components/condition-row/hooks/useRule.ts +0 -35
- package/src/components/db-condition-row/hooks/use-left.tsx +0 -66
- package/src/components/db-condition-row/hooks/use-op.tsx +0 -59
- /package/dist/cjs/{plugins/json-schema-preset/manager.js → components/condition-context/types.js} +0 -0
- /package/dist/esm/{plugins/json-schema-preset/manager.mjs → components/condition-context/types.mjs} +0 -0
|
@@ -3,4 +3,28 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
import { type Extension } from '@codemirror/state';
|
|
6
|
+
export declare const colors: {
|
|
7
|
+
background: string;
|
|
8
|
+
foreground: string;
|
|
9
|
+
selection: string;
|
|
10
|
+
cursor: string;
|
|
11
|
+
dropdownBackground: string;
|
|
12
|
+
dropdownBorder: string;
|
|
13
|
+
activeLine: string;
|
|
14
|
+
matchingBracket: string;
|
|
15
|
+
keyword: string;
|
|
16
|
+
storage: string;
|
|
17
|
+
variable: string;
|
|
18
|
+
parameter: string;
|
|
19
|
+
function: string;
|
|
20
|
+
string: string;
|
|
21
|
+
constant: string;
|
|
22
|
+
type: string;
|
|
23
|
+
class: string;
|
|
24
|
+
number: string;
|
|
25
|
+
comment: string;
|
|
26
|
+
heading: string;
|
|
27
|
+
invalid: string;
|
|
28
|
+
regexp: string;
|
|
29
|
+
};
|
|
6
30
|
export declare const lightTheme: Extension;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
import { IConditionRule, ConditionOpConfigs } from './types';
|
|
7
|
+
interface ContextType {
|
|
8
|
+
rules?: Record<string, IConditionRule>;
|
|
9
|
+
ops?: ConditionOpConfigs;
|
|
10
|
+
}
|
|
11
|
+
export declare const ConditionContext: React.Context<ContextType>;
|
|
12
|
+
export declare const ConditionProvider: (props: React.PropsWithChildren<ContextType>) => React.JSX.Element;
|
|
13
|
+
export declare const useConditionContext: () => ContextType;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
6
|
+
import { IConditionRule, ConditionOpConfigs } from '../types';
|
|
7
|
+
interface HooksParams {
|
|
8
|
+
leftSchema?: IJsonSchema;
|
|
9
|
+
operator?: string;
|
|
10
|
+
/**
|
|
11
|
+
* custom rule config
|
|
12
|
+
*/
|
|
13
|
+
ruleConfig?: {
|
|
14
|
+
ops?: ConditionOpConfigs;
|
|
15
|
+
rules?: Record<string, IConditionRule>;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export declare function useCondition({ leftSchema, operator, ruleConfig }: HooksParams): {
|
|
19
|
+
rule: IConditionRule | undefined;
|
|
20
|
+
opConfig: import("..").ConditionOpConfig;
|
|
21
|
+
opOptionList: {
|
|
22
|
+
value: string;
|
|
23
|
+
label: string;
|
|
24
|
+
abbreviation: string;
|
|
25
|
+
rightDisplay?: string;
|
|
26
|
+
}[];
|
|
27
|
+
targetSchema: IJsonSchema<string> | undefined;
|
|
28
|
+
};
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
export { type IConditionRule, type IConditionRuleFactory, type ConditionOpConfigs, type ConditionOpConfig, } from './types';
|
|
6
|
+
export { ConditionPresetOp } from './op';
|
|
7
|
+
export { ConditionProvider, useConditionContext } from './context';
|
|
8
|
+
export { useCondition } from './hooks/use-condition';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
import { ConditionOpConfigs } from './types';
|
|
6
|
+
export declare enum ConditionPresetOp {
|
|
7
|
+
EQ = "eq",
|
|
8
|
+
NEQ = "neq",
|
|
9
|
+
GT = "gt",
|
|
10
|
+
GTE = "gte",
|
|
11
|
+
LT = "lt",
|
|
12
|
+
LTE = "lte",
|
|
13
|
+
IN = "in",
|
|
14
|
+
NIN = "nin",
|
|
15
|
+
CONTAINS = "contains",
|
|
16
|
+
NOT_CONTAINS = "not_contains",
|
|
17
|
+
IS_EMPTY = "is_empty",
|
|
18
|
+
IS_NOT_EMPTY = "is_not_empty",
|
|
19
|
+
IS_TRUE = "is_true",
|
|
20
|
+
IS_FALSE = "is_false"
|
|
21
|
+
}
|
|
22
|
+
export declare const defaultConditionOpConfigs: ConditionOpConfigs;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
import { type IJsonSchema } from '@flowgram.ai/json-schema';
|
|
6
|
+
export interface ConditionOpConfig {
|
|
7
|
+
label: string;
|
|
8
|
+
abbreviation: string;
|
|
9
|
+
rightDisplay?: string;
|
|
10
|
+
}
|
|
11
|
+
export type OpKey = string;
|
|
12
|
+
export type ConditionOpConfigs = Record<OpKey, ConditionOpConfig>;
|
|
13
|
+
export type IConditionRule = Record<OpKey, string | IJsonSchema | null>;
|
|
14
|
+
export type IConditionRuleFactory = (schema?: IJsonSchema) => Record<OpKey, string | IJsonSchema | null>;
|
|
@@ -3,20 +3,17 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import {
|
|
6
|
+
import { IConditionRule, ConditionOpConfigs } from '../condition-context';
|
|
7
|
+
import { ConditionRowValueType } from './types';
|
|
7
8
|
interface PropTypes {
|
|
8
9
|
value?: ConditionRowValueType;
|
|
9
10
|
onChange: (value?: ConditionRowValueType) => void;
|
|
10
11
|
style?: React.CSSProperties;
|
|
11
12
|
readonly?: boolean;
|
|
12
13
|
ruleConfig?: {
|
|
13
|
-
ops?:
|
|
14
|
-
rules?:
|
|
14
|
+
ops?: ConditionOpConfigs;
|
|
15
|
+
rules?: Record<string, IConditionRule>;
|
|
15
16
|
};
|
|
16
17
|
}
|
|
17
18
|
export declare function ConditionRow({ style, value, onChange, readonly, ruleConfig, }: PropTypes): React.JSX.Element;
|
|
18
|
-
export declare namespace ConditionRow {
|
|
19
|
-
var defaultRules: IRules;
|
|
20
|
-
var defaultOpConfigs: OpConfigs;
|
|
21
|
-
}
|
|
22
19
|
export { type ConditionRowValueType };
|
|
@@ -3,30 +3,6 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
import { IFlowConstantRefValue, IFlowRefValue } from '../../shared';
|
|
6
|
-
export declare enum Op {
|
|
7
|
-
EQ = "eq",
|
|
8
|
-
NEQ = "neq",
|
|
9
|
-
GT = "gt",
|
|
10
|
-
GTE = "gte",
|
|
11
|
-
LT = "lt",
|
|
12
|
-
LTE = "lte",
|
|
13
|
-
IN = "in",
|
|
14
|
-
NIN = "nin",
|
|
15
|
-
CONTAINS = "contains",
|
|
16
|
-
NOT_CONTAINS = "not_contains",
|
|
17
|
-
IS_EMPTY = "is_empty",
|
|
18
|
-
IS_NOT_EMPTY = "is_not_empty",
|
|
19
|
-
IS_TRUE = "is_true",
|
|
20
|
-
IS_FALSE = "is_false"
|
|
21
|
-
}
|
|
22
|
-
export interface OpConfig {
|
|
23
|
-
label: string;
|
|
24
|
-
abbreviation: string;
|
|
25
|
-
rightDisplay?: string;
|
|
26
|
-
}
|
|
27
|
-
export type OpConfigs = Record<string, OpConfig>;
|
|
28
|
-
export type IRule = Partial<Record<string, string | null>>;
|
|
29
|
-
export type IRules = Record<string, IRule>;
|
|
30
6
|
export interface ConditionRowValueType {
|
|
31
7
|
left?: IFlowRefValue;
|
|
32
8
|
operator?: string;
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import {
|
|
6
|
+
import { type ConditionOpConfigs, type IConditionRule } from '../condition-context';
|
|
7
|
+
import { DBConditionOptionType, DBConditionRowValueType } from './types';
|
|
7
8
|
interface PropTypes {
|
|
8
9
|
value?: DBConditionRowValueType;
|
|
9
10
|
onChange: (value?: DBConditionRowValueType) => void;
|
|
@@ -11,8 +12,8 @@ interface PropTypes {
|
|
|
11
12
|
options?: DBConditionOptionType[];
|
|
12
13
|
readonly?: boolean;
|
|
13
14
|
ruleConfig?: {
|
|
14
|
-
ops?:
|
|
15
|
-
rules?:
|
|
15
|
+
ops?: ConditionOpConfigs;
|
|
16
|
+
rules?: Record<string, IConditionRule>;
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
export declare function DBConditionRow({ style, value, onChange, readonly, options, ruleConfig, }: PropTypes): React.JSX.Element;
|
|
@@ -4,14 +4,6 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
6
6
|
import { IFlowConstantRefValue } from '../../shared';
|
|
7
|
-
export interface OpConfig {
|
|
8
|
-
label: string;
|
|
9
|
-
abbreviation: string;
|
|
10
|
-
rightDisplay?: string;
|
|
11
|
-
}
|
|
12
|
-
export type OpConfigs = Record<string, OpConfig>;
|
|
13
|
-
export type IRule = Partial<Record<string, string | null>>;
|
|
14
|
-
export type IRules = Record<string, IRule>;
|
|
15
7
|
export interface DBConditionRowValueType {
|
|
16
8
|
left?: string;
|
|
17
9
|
schema?: IJsonSchema;
|
|
@@ -6,6 +6,10 @@ interface InputConfig {
|
|
|
6
6
|
sourceKey: string;
|
|
7
7
|
targetKey: string;
|
|
8
8
|
scope?: 'private' | 'public';
|
|
9
|
+
/**
|
|
10
|
+
* For backend runtime, constant schema is redundant, so we can choose to ignore it
|
|
11
|
+
*/
|
|
12
|
+
ignoreConstantSchema?: boolean;
|
|
9
13
|
}
|
|
10
14
|
export declare const createInferInputsPlugin: import("@flowgram.ai/node").FormPluginCreator<InputConfig>;
|
|
11
15
|
export {};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import { JsonSchemaTypeRegistry } from './
|
|
5
|
+
import { JsonSchemaTypeRegistry } from './types';
|
|
6
6
|
export declare const createTypePresetPlugin: import("@flowgram.ai/core").PluginCreator<{
|
|
7
7
|
types?: Partial<JsonSchemaTypeRegistry> & Pick<JsonSchemaTypeRegistry, "type">[];
|
|
8
8
|
unregisterTypes?: string[];
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
import { type JsonSchemaBasicType, JsonSchemaUtils, type IJsonSchema } from '@flowgram.ai/json-schema';
|
|
6
|
+
import { type ConstantRendererProps, type JsonSchemaTypeRegistry } from './types';
|
|
6
7
|
import { useTypeManager, JsonSchemaTypePresetProvider } from './react';
|
|
7
|
-
import { ConstantRendererProps, type JsonSchemaTypeRegistry } from './manager';
|
|
8
8
|
import { createTypePresetPlugin } from './create-type-preset-plugin';
|
|
9
9
|
export { createTypePresetPlugin, useTypeManager, JsonSchemaTypePresetProvider, JsonSchemaUtils, type IJsonSchema, type JsonSchemaTypeRegistry, type ConstantRendererProps, type JsonSchemaBasicType, };
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import { type IJsonSchema, JsonSchemaTypeManager } from '@flowgram.ai/json-schema';
|
|
7
|
-
import { type JsonSchemaTypeRegistry } from './
|
|
7
|
+
import { type JsonSchemaTypeRegistry } from './types';
|
|
8
8
|
export declare const useTypeManager: () => JsonSchemaTypeManager<IJsonSchema, JsonSchemaTypeRegistry>;
|
|
9
9
|
export declare const JsonSchemaTypePresetProvider: ({ types, children, }: React.PropsWithChildren<{
|
|
10
10
|
types: JsonSchemaTypeRegistry[];
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import { type JsonSchemaTypeRegistry } from '../
|
|
5
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
6
6
|
export declare const arrayRegistry: Partial<JsonSchemaTypeRegistry>;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import { type JsonSchemaTypeRegistry } from '../
|
|
5
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
6
6
|
export declare const booleanRegistry: Partial<JsonSchemaTypeRegistry>;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import { type JsonSchemaTypeRegistry } from '../
|
|
5
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
6
6
|
export declare const dateTimeRegistry: Partial<JsonSchemaTypeRegistry>;
|
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
|
|
5
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
6
|
+
export declare const jsonSchemaTypePreset: Partial<JsonSchemaTypeRegistry<any>>[];
|
|
7
|
+
export declare const initRegistries: () => void;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import { type JsonSchemaTypeRegistry } from '../
|
|
5
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
6
6
|
export declare const integerRegistry: Partial<JsonSchemaTypeRegistry>;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import { type JsonSchemaTypeRegistry } from '../
|
|
5
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
6
6
|
export declare const numberRegistry: Partial<JsonSchemaTypeRegistry>;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import { type JsonSchemaTypeRegistry } from '../
|
|
5
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
6
6
|
export declare const objectRegistry: Partial<JsonSchemaTypeRegistry>;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
|
-
import { type JsonSchemaTypeRegistry } from '../
|
|
5
|
+
import { type JsonSchemaTypeRegistry } from '../types';
|
|
6
6
|
export declare const stringRegistry: Partial<JsonSchemaTypeRegistry>;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
import { JsonSchemaTypeRegistry as OriginJsonSchemaTypeRegistry } from '@flowgram.ai/json-schema';
|
|
6
|
+
import { IConditionRule, IConditionRuleFactory } from '../../components/condition-context/types';
|
|
6
7
|
export interface ConstantRendererProps<Value = any> {
|
|
7
8
|
value?: Value;
|
|
8
9
|
onChange?: (value: Value) => void;
|
|
@@ -14,4 +15,8 @@ export interface JsonSchemaTypeRegistry<Value = any> extends OriginJsonSchemaTyp
|
|
|
14
15
|
* Render Constant Input
|
|
15
16
|
*/
|
|
16
17
|
ConstantRenderer: React.FC<ConstantRendererProps<Value>>;
|
|
18
|
+
/**
|
|
19
|
+
* Condition Rules
|
|
20
|
+
*/
|
|
21
|
+
conditionRule?: IConditionRule | IConditionRuleFactory;
|
|
17
22
|
}
|
|
@@ -37,11 +37,13 @@ export declare namespace FlowValueUtils {
|
|
|
37
37
|
* @returns A generator of flow values
|
|
38
38
|
*/
|
|
39
39
|
function traverse(value: any, options: {
|
|
40
|
-
includeTypes
|
|
40
|
+
includeTypes: FlowValueType[];
|
|
41
41
|
path?: string;
|
|
42
|
+
pathArr?: string[];
|
|
42
43
|
}): Generator<{
|
|
43
44
|
value: IFlowValue;
|
|
44
45
|
path: string;
|
|
46
|
+
pathArr: string[];
|
|
45
47
|
}>;
|
|
46
48
|
/**
|
|
47
49
|
* Get all key paths in the template value
|
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.14",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -68,9 +68,9 @@
|
|
|
68
68
|
"@codemirror/view": "~6.38.0",
|
|
69
69
|
"@codemirror/state": "~6.5.2",
|
|
70
70
|
"zod": "^3.24.4",
|
|
71
|
-
"@flowgram.ai/
|
|
72
|
-
"@flowgram.ai/
|
|
73
|
-
"@flowgram.ai/
|
|
71
|
+
"@flowgram.ai/json-schema": "0.4.14",
|
|
72
|
+
"@flowgram.ai/coze-editor": "0.4.14",
|
|
73
|
+
"@flowgram.ai/editor": "0.4.14"
|
|
74
74
|
},
|
|
75
75
|
"devDependencies": {
|
|
76
76
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -88,8 +88,9 @@
|
|
|
88
88
|
"@rslib/core": "~0.12.4",
|
|
89
89
|
"cross-env": "~7.0.3",
|
|
90
90
|
"@rsbuild/plugin-react": "^1.1.1",
|
|
91
|
-
"
|
|
92
|
-
"@flowgram.ai/eslint-config": "0.4.
|
|
91
|
+
"date-fns": "~4.1.0",
|
|
92
|
+
"@flowgram.ai/eslint-config": "0.4.14",
|
|
93
|
+
"@flowgram.ai/ts-config": "0.4.14"
|
|
93
94
|
},
|
|
94
95
|
"peerDependencies": {
|
|
95
96
|
"react": ">=16.8",
|
|
@@ -12,12 +12,11 @@ import {
|
|
|
12
12
|
InferValues,
|
|
13
13
|
} from '@flowgram.ai/coze-editor/react';
|
|
14
14
|
import preset, { type EditorAPI } from '@flowgram.ai/coze-editor/preset-code';
|
|
15
|
+
import { Skeleton } from '@douyinfe/semi-ui';
|
|
15
16
|
import { EditorView } from '@codemirror/view';
|
|
16
17
|
|
|
17
18
|
import { getSuffixByLanguageId } from './utils';
|
|
18
|
-
|
|
19
|
-
import './theme';
|
|
20
|
-
import './language-features';
|
|
19
|
+
import { useDynamicLoadLanguage } from './language-features';
|
|
21
20
|
|
|
22
21
|
const OriginCodeEditor = createRenderer(preset, [
|
|
23
22
|
EditorView.theme({
|
|
@@ -52,6 +51,8 @@ export function CodeEditor({
|
|
|
52
51
|
options,
|
|
53
52
|
readonly,
|
|
54
53
|
}: CodeEditorPropsType) {
|
|
54
|
+
const { loaded } = useDynamicLoadLanguage(languageId);
|
|
55
|
+
|
|
55
56
|
const editorRef = useRef<EditorAPI | null>(null);
|
|
56
57
|
|
|
57
58
|
useEffect(() => {
|
|
@@ -61,13 +62,9 @@ export function CodeEditor({
|
|
|
61
62
|
}
|
|
62
63
|
}, [value]);
|
|
63
64
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
module.initTsWorker();
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
}, [languageId]);
|
|
65
|
+
if (!loaded) {
|
|
66
|
+
return <Skeleton />;
|
|
67
|
+
}
|
|
71
68
|
|
|
72
69
|
return (
|
|
73
70
|
<EditorProvider>
|
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
import { lazySuspense } from '@/shared';
|
|
7
7
|
|
|
8
8
|
export const CodeEditor = lazySuspense(() =>
|
|
9
|
-
import('./editor').then((
|
|
9
|
+
Promise.all([import('./editor'), import('./theme')]).then(([editorModule]) => ({
|
|
10
|
+
default: editorModule.CodeEditor,
|
|
11
|
+
}))
|
|
10
12
|
);
|
|
11
13
|
|
|
12
14
|
export type { CodeEditorPropsType } from './editor';
|
|
@@ -3,21 +3,59 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
7
|
+
|
|
6
8
|
import { languages } from '@flowgram.ai/coze-editor/preset-code';
|
|
7
|
-
import { typescript } from '@flowgram.ai/coze-editor/language-typescript';
|
|
8
|
-
import { shell } from '@flowgram.ai/coze-editor/language-shell';
|
|
9
|
-
import { python } from '@flowgram.ai/coze-editor/language-python';
|
|
10
|
-
import { json } from '@flowgram.ai/coze-editor/language-json';
|
|
11
9
|
import { mixLanguages } from '@flowgram.ai/coze-editor';
|
|
12
10
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
export const dynamicLoadLanguages: Record<string, () => Promise<void>> = {
|
|
12
|
+
python: () =>
|
|
13
|
+
import('@flowgram.ai/coze-editor/language-python').then((module) => {
|
|
14
|
+
languages.register('python', module.python);
|
|
15
|
+
}),
|
|
16
|
+
shell: () =>
|
|
17
|
+
import('@flowgram.ai/coze-editor/language-shell').then((module) => {
|
|
18
|
+
languages.register('shell', module.shell);
|
|
19
|
+
}),
|
|
20
|
+
typescript: () =>
|
|
21
|
+
import('@flowgram.ai/coze-editor/language-typescript').then((module) => {
|
|
22
|
+
languages.register('typescript', module.typescript);
|
|
23
|
+
|
|
24
|
+
// Init TypeScript language service
|
|
25
|
+
const tsWorker = new Worker(
|
|
26
|
+
new URL(`@flowgram.ai/coze-editor/language-typescript/worker`, import.meta.url),
|
|
27
|
+
{ type: 'module' }
|
|
28
|
+
);
|
|
29
|
+
module.typescript.languageService.initialize(tsWorker, {
|
|
30
|
+
compilerOptions: {
|
|
31
|
+
// eliminate Promise error
|
|
32
|
+
lib: ['es2015', 'dom'],
|
|
33
|
+
noImplicitAny: false,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}),
|
|
37
|
+
json: () =>
|
|
38
|
+
import('@flowgram.ai/coze-editor/language-json').then((module) => {
|
|
39
|
+
languages.register('json', {
|
|
40
|
+
// mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
|
|
41
|
+
language: mixLanguages({
|
|
42
|
+
outerLanguage: module.json.language,
|
|
43
|
+
}),
|
|
44
|
+
languageService: module.json.languageService,
|
|
45
|
+
});
|
|
46
|
+
}),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export const useDynamicLoadLanguage = (languageId: string) => {
|
|
50
|
+
const [loaded, setLoaded] = useState(useMemo(() => !!languages.get(languageId), [languageId]));
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (!loaded && dynamicLoadLanguages[languageId]) {
|
|
54
|
+
dynamicLoadLanguages[languageId]().then(() => {
|
|
55
|
+
setLoaded(true);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}, [languageId, loaded]);
|
|
16
59
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
language: mixLanguages({
|
|
20
|
-
outerLanguage: json.language,
|
|
21
|
-
}),
|
|
22
|
-
languageService: json.languageService,
|
|
23
|
-
});
|
|
60
|
+
return { loaded };
|
|
61
|
+
};
|