@flowgram.ai/form-materials 0.2.32 → 0.3.1

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 (84) hide show
  1. package/bin/index.ts +11 -5
  2. package/bin/materials.ts +9 -1
  3. package/dist/esm/index.js +1229 -1308
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/index.d.mts +162 -125
  6. package/dist/index.d.ts +162 -125
  7. package/dist/index.js +1380 -1463
  8. package/dist/index.js.map +1 -1
  9. package/package.json +5 -4
  10. package/src/components/batch-variable-selector/config.json +6 -2
  11. package/src/components/batch-variable-selector/index.tsx +1 -1
  12. package/src/components/code-editor/theme/light.ts +1 -1
  13. package/src/components/code-editor-mini/config.json +7 -0
  14. package/src/components/code-editor-mini/index.tsx +31 -0
  15. package/src/components/condition-row/config.json +10 -2
  16. package/src/components/condition-row/constants.ts +4 -0
  17. package/src/components/condition-row/hooks/useRule.ts +2 -2
  18. package/src/components/condition-row/index.tsx +1 -1
  19. package/src/components/condition-row/types.ts +3 -1
  20. package/src/components/constant-input/config.json +6 -3
  21. package/src/components/constant-input/index.tsx +10 -71
  22. package/src/components/constant-input/types.ts +6 -10
  23. package/src/components/display-flow-value/config.json +8 -0
  24. package/src/components/display-flow-value/index.tsx +59 -0
  25. package/src/components/display-inputs-values/config.json +9 -0
  26. package/src/components/display-inputs-values/index.tsx +27 -0
  27. package/src/components/display-inputs-values/styles.ts +12 -0
  28. package/src/components/display-outputs/config.json +10 -0
  29. package/src/components/display-outputs/index.tsx +58 -0
  30. package/src/components/display-outputs/styles.ts +12 -0
  31. package/src/components/display-schema-tag/config.json +10 -0
  32. package/src/components/display-schema-tag/index.tsx +44 -0
  33. package/src/components/display-schema-tag/styles.ts +28 -0
  34. package/src/components/display-schema-tree/config.json +11 -0
  35. package/src/components/display-schema-tree/index.tsx +74 -0
  36. package/src/components/display-schema-tree/styles.tsx +90 -0
  37. package/src/components/dynamic-value-input/config.json +11 -2
  38. package/src/components/dynamic-value-input/hooks.ts +53 -0
  39. package/src/components/dynamic-value-input/index.tsx +30 -28
  40. package/src/components/index.ts +6 -0
  41. package/src/components/inputs-values/config.json +2 -1
  42. package/src/components/inputs-values/types.ts +3 -1
  43. package/src/components/json-schema-editor/config.json +2 -2
  44. package/src/components/json-schema-editor/default-value.tsx +1 -1
  45. package/src/components/json-schema-editor/hooks.tsx +1 -1
  46. package/src/components/json-schema-editor/index.tsx +1 -1
  47. package/src/components/json-schema-editor/types.ts +1 -1
  48. package/src/components/type-selector/config.json +6 -2
  49. package/src/components/type-selector/index.tsx +47 -11
  50. package/src/components/variable-selector/config.json +6 -2
  51. package/src/components/variable-selector/index.tsx +1 -1
  52. package/src/components/variable-selector/use-variable-tree.tsx +14 -20
  53. package/src/effects/provide-json-schema-outputs/config.json +4 -5
  54. package/src/effects/provide-json-schema-outputs/index.ts +1 -3
  55. package/src/effects/sync-variable-title/index.ts +1 -0
  56. package/src/form-plugins/infer-inputs-plugin/config.json +3 -1
  57. package/src/form-plugins/infer-inputs-plugin/index.ts +2 -2
  58. package/src/index.ts +2 -1
  59. package/src/{typings/json-schema → plugins/disable-declaration-plugin}/config.json +1 -1
  60. package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
  61. package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
  62. package/src/plugins/index.ts +7 -0
  63. package/src/plugins/json-schema-preset/config.json +9 -0
  64. package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +28 -0
  65. package/src/plugins/json-schema-preset/index.tsx +39 -0
  66. package/src/plugins/json-schema-preset/manager.ts +18 -0
  67. package/src/plugins/json-schema-preset/type-definition/array.tsx +23 -0
  68. package/src/plugins/json-schema-preset/type-definition/boolean.tsx +32 -0
  69. package/src/plugins/json-schema-preset/type-definition/index.tsx +24 -0
  70. package/src/plugins/json-schema-preset/type-definition/integer.tsx +24 -0
  71. package/src/plugins/json-schema-preset/type-definition/number.tsx +24 -0
  72. package/src/plugins/json-schema-preset/type-definition/object.tsx +23 -0
  73. package/src/plugins/json-schema-preset/type-definition/string.tsx +18 -0
  74. package/src/{utils → shared}/index.ts +0 -1
  75. package/src/typings/flow-value/config.json +4 -4
  76. package/src/typings/flow-value/index.ts +1 -1
  77. package/src/typings/index.ts +0 -1
  78. package/src/components/type-selector/constants.tsx +0 -364
  79. package/src/typings/json-schema/index.ts +0 -36
  80. package/src/utils/json-schema/config.json +0 -5
  81. package/src/utils/json-schema/index.ts +0 -180
  82. /package/src/{utils → shared}/format-legacy-refs/config.json +0 -0
  83. /package/src/{utils → shared}/format-legacy-refs/index.ts +0 -0
  84. /package/src/{utils → shared}/format-legacy-refs/readme.md +0 -0
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  import { get, set } from 'lodash';
7
+ import { JsonSchemaUtils, IJsonSchema } from '@flowgram.ai/json-schema';
7
8
  import {
8
9
  defineFormPluginCreator,
9
10
  getNodePrivateScope,
@@ -11,8 +12,7 @@ import {
11
12
  Scope,
12
13
  } from '@flowgram.ai/editor';
13
14
 
14
- import { JsonSchemaUtils } from '../../utils';
15
- import { IFlowConstantValue, IFlowRefValue, IFlowTemplateValue, IJsonSchema } from '../../typings';
15
+ import { IFlowConstantValue, IFlowRefValue, IFlowTemplateValue } from '../../typings';
16
16
 
17
17
  interface InputConfig {
18
18
  sourceKey: string;
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@
5
5
 
6
6
  export * from './components';
7
7
  export * from './effects';
8
- export * from './utils';
8
+ export * from './shared';
9
9
  export * from './typings';
10
10
  export * from './form-plugins';
11
+ export * from './plugins';
@@ -1,5 +1,5 @@
1
1
  {
2
- "name": "json-schema",
2
+ "name": "disable-declaration-plugin",
3
3
  "depMaterials": [],
4
4
  "depPackages": []
5
5
  }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import {
7
+ ASTMatch,
8
+ definePluginCreator,
9
+ type GlobalEventActionType,
10
+ VariableEngine,
11
+ } from '@flowgram.ai/editor';
12
+
13
+ export const createDisableDeclarationPlugin = definePluginCreator<void>({
14
+ onInit(ctx) {
15
+ const variableEngine = ctx.get(VariableEngine);
16
+
17
+ const handleEvent = (action: GlobalEventActionType) => {
18
+ if (ASTMatch.isVariableDeclaration(action.ast)) {
19
+ if (!action.ast.meta?.disabled) {
20
+ action.ast.updateMeta({
21
+ ...(action.ast.meta || {}),
22
+ disabled: true,
23
+ });
24
+ }
25
+ }
26
+ };
27
+
28
+ variableEngine.onGlobalEvent('NewAST', handleEvent);
29
+ variableEngine.onGlobalEvent('UpdateAST', handleEvent);
30
+ },
31
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export { createDisableDeclarationPlugin } from './create-disable-declaration-plugin';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ export * from './json-schema-preset';
7
+ export * from './disable-declaration-plugin';
@@ -0,0 +1,9 @@
1
+ {
2
+ "name": "json-schema-preset",
3
+ "depMaterials": [
4
+ "components/code-editor-mini"
5
+ ],
6
+ "depPackages": [
7
+ "@flowgram.ai/json-schema"
8
+ ]
9
+ }
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import {
7
+ BaseTypeManager,
8
+ jsonSchemaContainerModule,
9
+ JsonSchemaTypeManager,
10
+ } from '@flowgram.ai/json-schema';
11
+ import { definePluginCreator } from '@flowgram.ai/editor';
12
+
13
+ import { jsonSchemaTypePreset } from './type-definition';
14
+ import { JsonSchemaTypeRegistry } from './manager';
15
+
16
+ export const createTypePresetPlugin = definePluginCreator<{
17
+ types?: JsonSchemaTypeRegistry[];
18
+ unregisterTypes?: string[];
19
+ }>({
20
+ onInit(ctx, opts) {
21
+ const typeManager = ctx.get(BaseTypeManager) as JsonSchemaTypeManager;
22
+ jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
23
+
24
+ opts.types?.forEach((_type) => typeManager.register(_type));
25
+ opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
26
+ },
27
+ containerModules: [jsonSchemaContainerModule],
28
+ });
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+ import React from 'react';
6
+
7
+ import {
8
+ type IJsonSchema,
9
+ JsonSchemaUtils,
10
+ useTypeManager as useOriginTypeManager,
11
+ TypePresetProvider as OriginTypePresetProvider,
12
+ JsonSchemaTypeManager,
13
+ } from '@flowgram.ai/json-schema';
14
+
15
+ import { jsonSchemaTypePreset } from './type-definition';
16
+ import { type JsonSchemaTypeRegistry, type ConstantRendererProps } from './manager';
17
+ import { createTypePresetPlugin } from './create-type-preset-plugin';
18
+
19
+ const useTypeManager = () =>
20
+ useOriginTypeManager() as JsonSchemaTypeManager<IJsonSchema, JsonSchemaTypeRegistry>;
21
+
22
+ const JsonSchemaTypePresetProvider = ({
23
+ types = [],
24
+ children,
25
+ }: React.PropsWithChildren<{ types: JsonSchemaTypeRegistry[] }>) => (
26
+ <OriginTypePresetProvider types={[...jsonSchemaTypePreset, ...types]}>
27
+ {children}
28
+ </OriginTypePresetProvider>
29
+ );
30
+
31
+ export {
32
+ createTypePresetPlugin,
33
+ useTypeManager,
34
+ JsonSchemaTypePresetProvider,
35
+ IJsonSchema,
36
+ JsonSchemaUtils,
37
+ JsonSchemaTypeRegistry,
38
+ ConstantRendererProps,
39
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { JsonSchemaTypeRegistry as OriginJsonSchemaTypeRegistry } from '@flowgram.ai/json-schema';
7
+
8
+ export interface ConstantRendererProps<Value = any> {
9
+ value?: Value;
10
+ onChange?: (value: Value) => void;
11
+ readonly?: boolean;
12
+ }
13
+ export interface JsonSchemaTypeRegistry<Value = any> extends OriginJsonSchemaTypeRegistry {
14
+ /**
15
+ * Render Constant Input
16
+ */
17
+ ConstantRenderer: React.FC<ConstantRendererProps<Value>>;
18
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /* eslint-disable react/prop-types */
7
+ import React from 'react';
8
+
9
+ import { type JsonSchemaTypeRegistry } from '../manager';
10
+ import { CodeEditorMini } from '../../../components/code-editor-mini';
11
+
12
+ export const arrayRegistry: Partial<JsonSchemaTypeRegistry> = {
13
+ type: 'array',
14
+ ConstantRenderer: (props) => (
15
+ <CodeEditorMini
16
+ value={props.value}
17
+ languageId="json"
18
+ onChange={(v) => props.onChange?.(v)}
19
+ placeholder="Please Input Array"
20
+ readonly={props.readonly}
21
+ />
22
+ ),
23
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /* eslint-disable react/prop-types */
7
+ import React from 'react';
8
+
9
+ import { Select } from '@douyinfe/semi-ui';
10
+
11
+ import { type JsonSchemaTypeRegistry } from '../manager';
12
+
13
+ export const booleanRegistry: Partial<JsonSchemaTypeRegistry> = {
14
+ type: 'boolean',
15
+ ConstantRenderer: (props) => {
16
+ const { value, onChange, ...rest } = props;
17
+ return (
18
+ <Select
19
+ placeholder="Please Select Boolean"
20
+ size="small"
21
+ disabled={props.readonly}
22
+ optionList={[
23
+ { label: 'True', value: 1 },
24
+ { label: 'False', value: 0 },
25
+ ]}
26
+ value={value ? 1 : 0}
27
+ onChange={(value) => onChange?.(!!value)}
28
+ {...rest}
29
+ />
30
+ );
31
+ },
32
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { jsonSchemaTypeManager } from '@flowgram.ai/json-schema';
7
+
8
+ import { stringRegistry } from './string';
9
+ import { objectRegistry } from './object';
10
+ import { numberRegistry } from './number';
11
+ import { integerRegistry } from './integer';
12
+ import { booleanRegistry } from './boolean';
13
+ import { arrayRegistry } from './array';
14
+
15
+ export const jsonSchemaTypePreset = [
16
+ stringRegistry,
17
+ objectRegistry,
18
+ numberRegistry,
19
+ integerRegistry,
20
+ booleanRegistry,
21
+ arrayRegistry,
22
+ ];
23
+
24
+ jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /* eslint-disable react/prop-types */
7
+ import React from 'react';
8
+
9
+ import { InputNumber } from '@douyinfe/semi-ui';
10
+
11
+ import { type JsonSchemaTypeRegistry } from '../manager';
12
+
13
+ export const integerRegistry: Partial<JsonSchemaTypeRegistry> = {
14
+ type: 'integer',
15
+ ConstantRenderer: (props) => (
16
+ <InputNumber
17
+ placeholder="Please Input Integer"
18
+ size="small"
19
+ disabled={props.readonly}
20
+ precision={0}
21
+ {...props}
22
+ />
23
+ ),
24
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /* eslint-disable react/prop-types */
7
+ import React from 'react';
8
+
9
+ import { InputNumber } from '@douyinfe/semi-ui';
10
+
11
+ import { type JsonSchemaTypeRegistry } from '../manager';
12
+
13
+ export const numberRegistry: Partial<JsonSchemaTypeRegistry> = {
14
+ type: 'number',
15
+ ConstantRenderer: (props) => (
16
+ <InputNumber
17
+ placeholder="Please Input Number"
18
+ size="small"
19
+ disabled={props.readonly}
20
+ hideButtons
21
+ {...props}
22
+ />
23
+ ),
24
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /* eslint-disable react/prop-types */
7
+ import React from 'react';
8
+
9
+ import { type JsonSchemaTypeRegistry } from '../manager';
10
+ import { CodeEditorMini } from '../../../components/code-editor-mini';
11
+
12
+ export const objectRegistry: Partial<JsonSchemaTypeRegistry> = {
13
+ type: 'object',
14
+ ConstantRenderer: (props) => (
15
+ <CodeEditorMini
16
+ value={props.value}
17
+ onChange={(v) => props.onChange?.(v)}
18
+ languageId="json"
19
+ placeholder="Please Input Object"
20
+ readonly={props.readonly}
21
+ />
22
+ ),
23
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /* eslint-disable react/prop-types */
7
+ import React from 'react';
8
+
9
+ import { Input } from '@douyinfe/semi-ui';
10
+
11
+ import { type JsonSchemaTypeRegistry } from '../manager';
12
+
13
+ export const stringRegistry: Partial<JsonSchemaTypeRegistry> = {
14
+ type: 'string',
15
+ ConstantRenderer: (props) => (
16
+ <Input placeholder="Please Input String" size="small" disabled={props.readonly} {...props} />
17
+ ),
18
+ };
@@ -4,4 +4,3 @@
4
4
  */
5
5
 
6
6
  export * from './format-legacy-refs';
7
- export * from './json-schema';
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "flow-value",
3
- "depMaterials": [
4
- "typings/json-schema"
5
- ],
6
- "depPackages": []
3
+ "depMaterials": [],
4
+ "depPackages": [
5
+ "@flowgram.ai/json-schema"
6
+ ]
7
7
  }
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import { IJsonSchema } from '../json-schema';
6
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
7
7
 
8
8
  export interface IFlowValueExtra {
9
9
  index?: number;
@@ -4,4 +4,3 @@
4
4
  */
5
5
 
6
6
  export * from './flow-value';
7
- export * from './json-schema';