@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.
Files changed (142) hide show
  1. package/dist/cjs/components/code-editor/editor.js +54 -77
  2. package/dist/cjs/components/code-editor/index.js +10 -2
  3. package/dist/cjs/components/code-editor/language-features.js +119 -16
  4. package/dist/cjs/components/code-editor/theme/dark.js +120 -50
  5. package/dist/cjs/components/code-editor/theme/light.js +110 -61
  6. package/dist/cjs/components/condition-context/context.js +59 -0
  7. package/dist/cjs/components/condition-context/hooks/use-condition.js +97 -0
  8. package/dist/cjs/components/condition-context/index.js +47 -0
  9. package/dist/cjs/components/condition-context/op.js +117 -0
  10. package/dist/cjs/components/condition-row/index.js +43 -26
  11. package/dist/cjs/components/condition-row/types.js +1 -35
  12. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +4 -3
  13. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tree.js +3 -0
  14. package/dist/cjs/components/db-condition-row/index.js +59 -34
  15. package/dist/cjs/form-plugins/infer-inputs-plugin/index.js +30 -3
  16. package/dist/cjs/plugins/json-schema-preset/create-type-preset-plugin.js +1 -0
  17. package/dist/cjs/plugins/json-schema-preset/react.js +1 -0
  18. package/dist/cjs/plugins/json-schema-preset/type-definition/array.js +30 -1
  19. package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +23 -0
  20. package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +31 -2
  21. package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +9 -1
  22. package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +34 -1
  23. package/dist/cjs/{components/code-editor/init-worker.js → plugins/json-schema-preset/type-definition/map.js} +21 -23
  24. package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +34 -1
  25. package/dist/cjs/plugins/json-schema-preset/type-definition/object.js +6 -1
  26. package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +30 -1
  27. package/dist/cjs/plugins/json-schema-preset/types.js +18 -0
  28. package/dist/cjs/shared/flow-value/utils.js +22 -8
  29. package/dist/esm/components/code-editor/editor.mjs +4 -9
  30. package/dist/esm/components/code-editor/index.mjs +5 -2
  31. package/dist/esm/components/code-editor/language-features.mjs +49 -13
  32. package/dist/esm/components/code-editor/theme/dark.mjs +117 -50
  33. package/dist/esm/components/code-editor/theme/light.mjs +108 -62
  34. package/dist/esm/components/condition-context/context.mjs +19 -0
  35. package/dist/esm/components/condition-context/hooks/use-condition.mjs +63 -0
  36. package/dist/esm/components/condition-context/index.mjs +4 -0
  37. package/dist/esm/components/condition-context/op.mjs +80 -0
  38. package/dist/esm/components/condition-row/index.mjs +45 -28
  39. package/dist/esm/components/condition-row/types.mjs +0 -18
  40. package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +4 -3
  41. package/dist/esm/components/coze-editor-extensions/extensions/variable-tree.mjs +3 -0
  42. package/dist/esm/components/db-condition-row/index.mjs +59 -34
  43. package/dist/esm/form-plugins/infer-inputs-plugin/index.mjs +31 -4
  44. package/dist/esm/plugins/json-schema-preset/create-type-preset-plugin.mjs +2 -1
  45. package/dist/esm/plugins/json-schema-preset/react.mjs +2 -1
  46. package/dist/esm/plugins/json-schema-preset/type-definition/array.mjs +30 -1
  47. package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +23 -0
  48. package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +31 -2
  49. package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +7 -2
  50. package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +34 -1
  51. package/dist/esm/plugins/json-schema-preset/type-definition/map.mjs +20 -0
  52. package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +34 -1
  53. package/dist/esm/plugins/json-schema-preset/type-definition/object.mjs +6 -1
  54. package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +30 -1
  55. package/dist/esm/plugins/json-schema-preset/types.mjs +0 -0
  56. package/dist/esm/shared/flow-value/utils.mjs +22 -8
  57. package/dist/tsconfig.tsbuildinfo +1 -1
  58. package/dist/types/components/code-editor/editor.d.ts +0 -2
  59. package/dist/types/components/code-editor/language-features.d.ts +4 -1
  60. package/dist/types/components/code-editor/theme/dark.d.ts +29 -0
  61. package/dist/types/components/code-editor/theme/light.d.ts +24 -0
  62. package/dist/types/components/condition-context/context.d.ts +14 -0
  63. package/dist/types/components/condition-context/hooks/use-condition.d.ts +29 -0
  64. package/dist/types/components/condition-context/index.d.ts +8 -0
  65. package/dist/types/components/condition-context/op.d.ts +22 -0
  66. package/dist/types/components/condition-context/types.d.ts +14 -0
  67. package/dist/types/components/condition-row/index.d.ts +4 -7
  68. package/dist/types/components/condition-row/types.d.ts +0 -24
  69. package/dist/types/components/db-condition-row/index.d.ts +4 -3
  70. package/dist/types/components/db-condition-row/types.d.ts +0 -8
  71. package/dist/types/form-plugins/infer-inputs-plugin/index.d.ts +4 -0
  72. package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +1 -1
  73. package/dist/types/plugins/json-schema-preset/index.d.ts +1 -1
  74. package/dist/types/plugins/json-schema-preset/react.d.ts +1 -1
  75. package/dist/types/plugins/json-schema-preset/type-definition/array.d.ts +1 -1
  76. package/dist/types/plugins/json-schema-preset/type-definition/boolean.d.ts +1 -1
  77. package/dist/types/plugins/json-schema-preset/type-definition/date-time.d.ts +1 -1
  78. package/dist/types/plugins/json-schema-preset/type-definition/index.d.ts +3 -1
  79. package/dist/types/plugins/json-schema-preset/type-definition/integer.d.ts +1 -1
  80. package/dist/types/plugins/json-schema-preset/type-definition/map.d.ts +6 -0
  81. package/dist/types/plugins/json-schema-preset/type-definition/number.d.ts +1 -1
  82. package/dist/types/plugins/json-schema-preset/type-definition/object.d.ts +1 -1
  83. package/dist/types/plugins/json-schema-preset/type-definition/string.d.ts +1 -1
  84. package/dist/types/plugins/json-schema-preset/{manager.d.ts → types.d.ts} +5 -0
  85. package/dist/types/shared/flow-value/utils.d.ts +3 -1
  86. package/package.json +7 -6
  87. package/src/components/code-editor/editor.tsx +7 -10
  88. package/src/components/code-editor/index.tsx +3 -1
  89. package/src/components/code-editor/language-features.ts +52 -14
  90. package/src/components/code-editor/theme/dark.ts +62 -77
  91. package/src/components/code-editor/theme/light.ts +60 -91
  92. package/src/components/condition-context/context.tsx +28 -0
  93. package/src/components/condition-context/hooks/use-condition.tsx +99 -0
  94. package/src/components/condition-context/index.tsx +14 -0
  95. package/src/components/condition-context/op.ts +86 -0
  96. package/src/components/condition-context/types.ts +22 -0
  97. package/src/components/condition-row/index.tsx +44 -22
  98. package/src/components/condition-row/types.ts +0 -30
  99. package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +6 -3
  100. package/src/components/coze-editor-extensions/extensions/variable-tree.tsx +3 -0
  101. package/src/components/db-condition-row/index.tsx +76 -24
  102. package/src/components/db-condition-row/types.ts +0 -13
  103. package/src/form-plugins/infer-inputs-plugin/index.ts +62 -14
  104. package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +4 -2
  105. package/src/plugins/json-schema-preset/index.tsx +1 -1
  106. package/src/plugins/json-schema-preset/react.tsx +5 -2
  107. package/src/plugins/json-schema-preset/type-definition/array.tsx +10 -1
  108. package/src/plugins/json-schema-preset/type-definition/boolean.tsx +17 -1
  109. package/src/plugins/json-schema-preset/type-definition/date-time.tsx +21 -2
  110. package/src/plugins/json-schema-preset/type-definition/index.tsx +10 -1
  111. package/src/plugins/json-schema-preset/type-definition/integer.tsx +19 -1
  112. package/src/plugins/json-schema-preset/type-definition/map.tsx +31 -0
  113. package/src/plugins/json-schema-preset/type-definition/number.tsx +19 -1
  114. package/src/plugins/json-schema-preset/type-definition/object.tsx +6 -1
  115. package/src/plugins/json-schema-preset/type-definition/string.tsx +19 -1
  116. package/src/plugins/json-schema-preset/{manager.ts → types.ts} +7 -0
  117. package/src/shared/flow-value/utils.ts +22 -9
  118. package/dist/cjs/components/condition-row/constants.js +0 -165
  119. package/dist/cjs/components/condition-row/hooks/useOp.js +0 -78
  120. package/dist/cjs/components/condition-row/hooks/useRule.js +0 -68
  121. package/dist/cjs/components/db-condition-row/hooks/use-left.js +0 -86
  122. package/dist/cjs/components/db-condition-row/hooks/use-op.js +0 -79
  123. package/dist/esm/components/code-editor/init-worker.mjs +0 -19
  124. package/dist/esm/components/condition-row/constants.mjs +0 -128
  125. package/dist/esm/components/condition-row/hooks/useOp.mjs +0 -44
  126. package/dist/esm/components/condition-row/hooks/useRule.mjs +0 -34
  127. package/dist/esm/components/db-condition-row/hooks/use-left.mjs +0 -52
  128. package/dist/esm/components/db-condition-row/hooks/use-op.mjs +0 -45
  129. package/dist/types/components/code-editor/init-worker.d.ts +0 -5
  130. package/dist/types/components/condition-row/constants.d.ts +0 -7
  131. package/dist/types/components/condition-row/hooks/useOp.d.ts +0 -18
  132. package/dist/types/components/condition-row/hooks/useRule.d.ts +0 -9
  133. package/dist/types/components/db-condition-row/hooks/use-left.d.ts +0 -18
  134. package/dist/types/components/db-condition-row/hooks/use-op.d.ts +0 -18
  135. package/src/components/code-editor/init-worker.ts +0 -27
  136. package/src/components/condition-row/constants.ts +0 -134
  137. package/src/components/condition-row/hooks/useOp.tsx +0 -56
  138. package/src/components/condition-row/hooks/useRule.ts +0 -35
  139. package/src/components/db-condition-row/hooks/use-left.tsx +0 -66
  140. package/src/components/db-condition-row/hooks/use-op.tsx +0 -59
  141. /package/dist/cjs/{plugins/json-schema-preset/manager.js → components/condition-context/types.js} +0 -0
  142. /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 { ConditionRowValueType, IRules, OpConfigs } from './types';
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?: OpConfigs;
14
- rules?: IRules;
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 { DBConditionOptionType, DBConditionRowValueType, IRules, OpConfigs } from './types';
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?: OpConfigs;
15
- rules?: IRules;
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 './manager';
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 './manager';
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 '../manager';
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 '../manager';
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 '../manager';
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
- export declare const jsonSchemaTypePreset: Partial<import("..").JsonSchemaTypeRegistry<any>>[];
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 '../manager';
5
+ import { type JsonSchemaTypeRegistry } from '../types';
6
6
  export declare const integerRegistry: Partial<JsonSchemaTypeRegistry>;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+ import { type JsonSchemaTypeRegistry } from '../types';
6
+ export declare const mapRegistry: 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 '../manager';
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 '../manager';
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 '../manager';
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?: FlowValueType[];
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.13",
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/editor": "0.4.13",
72
- "@flowgram.ai/json-schema": "0.4.13",
73
- "@flowgram.ai/coze-editor": "0.4.13"
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
- "@flowgram.ai/ts-config": "0.4.13",
92
- "@flowgram.ai/eslint-config": "0.4.13"
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
- useEffect(() => {
65
- if (languageId === 'typescript') {
66
- import('./init-worker').then((module) => {
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((module) => ({ default: module.CodeEditor }))
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
- languages.register('python', python);
14
- languages.register('shell', shell);
15
- languages.register('typescript', typescript);
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
- languages.register('json', {
18
- // mixLanguages is used to solve the problem that interpolation also uses parentheses, which causes incorrect highlighting
19
- language: mixLanguages({
20
- outerLanguage: json.language,
21
- }),
22
- languageService: json.languageService,
23
- });
60
+ return { loaded };
61
+ };