@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
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import React from 'react';
7
+
8
+ import { IJsonSchema, JsonSchemaTypeManager } from '@flowgram.ai/json-schema';
9
+
10
+ import { useTypeManager } from '../../plugins';
11
+ import { HorizontalLine, TreeItem, TreeLevel, TreeRow, TreeTitle } from './styles';
12
+
13
+ interface PropsType {
14
+ value?: IJsonSchema;
15
+ parentKey?: string;
16
+ depth?: number;
17
+ drilldown?: boolean;
18
+ showIcon?: boolean;
19
+ typeManager?: JsonSchemaTypeManager;
20
+ }
21
+
22
+ export function DisplaySchemaTree(props: Omit<PropsType, 'parentKey' | 'depth'>) {
23
+ return <SchemaTree {...props} />;
24
+ }
25
+
26
+ function SchemaTree(props: PropsType) {
27
+ const {
28
+ value: schema = {},
29
+ drilldown = true,
30
+ depth = 0,
31
+ showIcon = true,
32
+ parentKey = '',
33
+ } = props || {};
34
+
35
+ const typeManager = useTypeManager();
36
+
37
+ const config = typeManager.getTypeBySchema(schema);
38
+ const title = typeManager.getComplexText(schema);
39
+ const icon = typeManager?.getDisplayIcon(schema);
40
+ let properties: IJsonSchema['properties'] =
41
+ drilldown && config ? config.getTypeSchemaProperties(schema) : {};
42
+ const childEntries = Object.entries(properties || {});
43
+
44
+ return (
45
+ <TreeItem depth={depth} key={parentKey || 'root'}>
46
+ <TreeRow>
47
+ {depth !== 0 && <HorizontalLine />}
48
+ {showIcon &&
49
+ icon &&
50
+ React.cloneElement(icon, {
51
+ className: 'tree-icon',
52
+ })}
53
+ <TreeTitle>
54
+ {parentKey ? (
55
+ <>
56
+ {`${parentKey} (`}
57
+ {title}
58
+ {')'}
59
+ </>
60
+ ) : (
61
+ title
62
+ )}
63
+ </TreeTitle>
64
+ </TreeRow>
65
+ {childEntries?.length ? (
66
+ <TreeLevel>
67
+ {childEntries.map(([key, value]) => (
68
+ <SchemaTree key={key} {...props} parentKey={key} value={value} depth={depth + 1} />
69
+ ))}
70
+ </TreeLevel>
71
+ ) : null}
72
+ </TreeItem>
73
+ );
74
+ }
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import styled, { css } from 'styled-components';
7
+
8
+ export const TreeRow = styled.div`
9
+ display: flex;
10
+ align-items: center;
11
+
12
+ .tree-icon {
13
+ margin-right: 8px;
14
+ width: 14px;
15
+ height: 14px;
16
+ }
17
+
18
+ height: 27px;
19
+ white-space: nowrap;
20
+ `;
21
+
22
+ export const HorizontalLine = styled.div`
23
+ position: relative;
24
+
25
+ &::before,
26
+ &::after {
27
+ content: '';
28
+ position: absolute;
29
+ background-color: var(--semi-color-text-3);
30
+ }
31
+
32
+ &::after {
33
+ top: 0px;
34
+ right: 6px;
35
+ width: 15px;
36
+ height: 1px;
37
+ }
38
+ `;
39
+
40
+ export const TreeTitle = styled.div`
41
+ // overflow: hidden;
42
+ // text-overflow: ellipsis;
43
+ `;
44
+
45
+ export const TreeLevel = styled.div`
46
+ padding-left: 30px;
47
+ position: relative;
48
+
49
+ /* &::before {
50
+ content: '';
51
+ position: absolute;
52
+ background-color: var(--semi-color-text-3);
53
+ top: 0px;
54
+ bottom: 0px;
55
+ left: -22px;
56
+ width: 1px;
57
+ } */
58
+ `;
59
+
60
+ export const TreeItem = styled.div<{ depth: number }>`
61
+ position: relative;
62
+
63
+ &::before {
64
+ content: '';
65
+ position: absolute;
66
+ background-color: var(--semi-color-text-3);
67
+ }
68
+
69
+ &:not(:last-child)::before {
70
+ width: 1px;
71
+ top: 0;
72
+ bottom: 0;
73
+ left: -22px;
74
+ }
75
+
76
+ &:last-child::before {
77
+ width: 1px;
78
+ top: 0;
79
+ height: 14px;
80
+ left: -22px;
81
+ }
82
+
83
+ ${(props) =>
84
+ props.depth === 0 &&
85
+ css`
86
+ &::before {
87
+ width: 0px !important;
88
+ }
89
+ `}
90
+ `;
@@ -1,5 +1,14 @@
1
1
  {
2
2
  "name": "dynamic-value-input",
3
- "depMaterials": ["flow-value", "constant-input", "variable-selector"],
4
- "depPackages": ["@douyinfe/semi-ui", "@douyinfe/semi-icons", "styled-components"]
3
+ "depMaterials": [
4
+ "flow-value",
5
+ "constant-input",
6
+ "variable-selector"
7
+ ],
8
+ "depPackages": [
9
+ "@douyinfe/semi-ui",
10
+ "@douyinfe/semi-icons",
11
+ "styled-components",
12
+ "@flowgram.ai/json-schema"
13
+ ]
5
14
  }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { useMemo, useState } from 'react';
7
+
8
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
9
+ import { useScopeAvailable } from '@flowgram.ai/editor';
10
+
11
+ import { IFlowConstantRefValue } from '../../typings/flow-value';
12
+
13
+ export function useRefVariable(value?: IFlowConstantRefValue) {
14
+ const available = useScopeAvailable();
15
+ const refVariable = useMemo(() => {
16
+ if (value?.type === 'ref') {
17
+ return available.getByKeyPath(value.content);
18
+ }
19
+ }, [value, available]);
20
+
21
+ return refVariable;
22
+ }
23
+
24
+ export function useSelectSchema(
25
+ schemaFromProps?: IJsonSchema,
26
+ constantProps?: {
27
+ schema?: IJsonSchema;
28
+ },
29
+ value?: IFlowConstantRefValue
30
+ ) {
31
+ let defaultSelectSchema = schemaFromProps || constantProps?.schema || { type: 'string' };
32
+ if (value?.type === 'constant') {
33
+ defaultSelectSchema = value?.schema || defaultSelectSchema;
34
+ }
35
+
36
+ const [selectSchema, setSelectSchema] = useState(defaultSelectSchema);
37
+
38
+ return [selectSchema, setSelectSchema] as const;
39
+ }
40
+
41
+ export function useIncludeSchema(schemaFromProps?: IJsonSchema) {
42
+ const includeSchema = useMemo(() => {
43
+ if (!schemaFromProps) {
44
+ return;
45
+ }
46
+ if (schemaFromProps?.type === 'number') {
47
+ return [schemaFromProps, { type: 'integer' }];
48
+ }
49
+ return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
50
+ }, [schemaFromProps]);
51
+
52
+ return includeSchema;
53
+ }
@@ -3,20 +3,19 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import React, { useMemo, useState } from 'react';
6
+ import React from 'react';
7
7
 
8
- import { useScopeAvailable } from '@flowgram.ai/editor';
8
+ import { JsonSchemaUtils, IJsonSchema } from '@flowgram.ai/json-schema';
9
9
  import { IconButton } from '@douyinfe/semi-ui';
10
10
  import { IconSetting } from '@douyinfe/semi-icons';
11
11
 
12
+ import { VariableSelector } from '../variable-selector';
13
+ import { TypeSelector } from '../type-selector';
12
14
  import { Strategy } from '../constant-input/types';
13
15
  import { ConstantInput } from '../constant-input';
14
- import { JsonSchemaUtils } from '../../utils';
15
16
  import { IFlowConstantRefValue } from '../../typings/flow-value';
16
17
  import { UIContainer, UIMain, UITrigger, UIType } from './styles';
17
- import { VariableSelector } from '../variable-selector';
18
- import { TypeSelector } from '../type-selector';
19
- import { IJsonSchema } from '../../typings';
18
+ import { useIncludeSchema, useRefVariable, useSelectSchema } from './hooks';
20
19
 
21
20
  interface PropsType {
22
21
  value?: IFlowConstantRefValue;
@@ -40,16 +39,9 @@ export function DynamicValueInput({
40
39
  schema: schemaFromProps,
41
40
  constantProps,
42
41
  }: PropsType) {
43
- const available = useScopeAvailable();
44
- const refVariable = useMemo(() => {
45
- if (value?.type === 'ref') {
46
- return available.getByKeyPath(value.content);
47
- }
48
- }, [value, available]);
49
-
50
- const [selectSchema, setSelectSchema] = useState(
51
- schemaFromProps || constantProps?.schema || { type: 'string' }
52
- );
42
+ const refVariable = useRefVariable(value);
43
+ const [selectSchema, setSelectSchema] = useSelectSchema(schemaFromProps, constantProps, value);
44
+ const includeSchema = useIncludeSchema(schemaFromProps);
53
45
 
54
46
  const renderTypeSelector = () => {
55
47
  if (schemaFromProps) {
@@ -65,23 +57,33 @@ export function DynamicValueInput({
65
57
  return (
66
58
  <TypeSelector
67
59
  value={selectSchema}
68
- onChange={(_v) => setSelectSchema(_v || { type: 'string' })}
60
+ onChange={(_v) => {
61
+ setSelectSchema(_v || { type: 'string' });
62
+ let content;
63
+
64
+ if (_v?.type === 'object') {
65
+ content = '{}';
66
+ }
67
+
68
+ if (_v?.type === 'array') {
69
+ content = '[]';
70
+ }
71
+
72
+ if (_v?.type === 'boolean') {
73
+ content = false;
74
+ }
75
+
76
+ onChange({
77
+ type: 'constant',
78
+ content,
79
+ schema: _v || { type: 'string' },
80
+ });
81
+ }}
69
82
  readonly={readonly}
70
83
  />
71
84
  );
72
85
  };
73
86
 
74
- // When is number type, include integer as well
75
- const includeSchema = useMemo(() => {
76
- if (!schemaFromProps) {
77
- return;
78
- }
79
- if (schemaFromProps?.type === 'number') {
80
- return [schemaFromProps, { type: 'integer' }];
81
- }
82
- return { ...schemaFromProps, extra: { ...schemaFromProps?.extra, weak: true } };
83
- }, [schemaFromProps]);
84
-
85
87
  const renderMain = () => {
86
88
  if (value?.type === 'ref') {
87
89
  // Display Variable Or Delete
@@ -15,5 +15,11 @@ export * from './prompt-editor';
15
15
  export * from './prompt-editor-with-variables';
16
16
  export * from './prompt-editor-with-inputs';
17
17
  export * from './code-editor';
18
+ export * from './code-editor-mini';
18
19
  export * from './json-editor-with-variables';
19
20
  export * from './inputs-values';
21
+ export * from './display-schema-tree';
22
+ export * from './display-outputs';
23
+ export * from './display-schema-tag';
24
+ export * from './display-flow-value';
25
+ export * from './display-inputs-values';
@@ -7,6 +7,7 @@
7
7
  "depPackages": [
8
8
  "@douyinfe/semi-ui",
9
9
  "@douyinfe/semi-icons",
10
- "styled-components"
10
+ "styled-components",
11
+ "@flowgram.ai/json-schema"
11
12
  ]
12
13
  }
@@ -3,8 +3,10 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
7
+
6
8
  import { Strategy } from '../constant-input/types';
7
- import { IFlowValue, IJsonSchema } from '../../typings';
9
+ import { IFlowValue } from '../../typings';
8
10
 
9
11
  export interface PropsType {
10
12
  value?: Record<string, IFlowValue | undefined>;
@@ -2,12 +2,12 @@
2
2
  "name": "json-schema-editor",
3
3
  "depMaterials": [
4
4
  "type-selector",
5
- "typings/json-schema",
6
5
  "constant-inputs"
7
6
  ],
8
7
  "depPackages": [
9
8
  "@douyinfe/semi-ui",
10
9
  "@douyinfe/semi-icons",
11
- "styled-components"
10
+ "styled-components",
11
+ "@flowgram.ai/json-schema"
12
12
  ]
13
13
  }
@@ -5,6 +5,7 @@
5
5
 
6
6
  import React, { useRef, useState, useCallback } from 'react';
7
7
 
8
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
8
9
  import { IconButton, JsonViewer, Tooltip } from '@douyinfe/semi-ui';
9
10
  import { IconBrackets } from '@douyinfe/semi-icons';
10
11
 
@@ -17,7 +18,6 @@ import {
17
18
  JSONViewerWrapper,
18
19
  } from './styles';
19
20
  import { ConstantInput } from '../constant-input';
20
- import { IJsonSchema } from '../../typings';
21
21
 
22
22
  /**
23
23
  * 根据不同的数据类型渲染对应的默认值输入组件。
@@ -6,8 +6,8 @@
6
6
  import { useEffect, useMemo, useRef, useState } from 'react';
7
7
 
8
8
  import { omit } from 'lodash';
9
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
9
10
 
10
- import { IJsonSchema } from '../../typings';
11
11
  import { PropertyValueType } from './types';
12
12
 
13
13
  let _id = 0;
@@ -5,6 +5,7 @@
5
5
 
6
6
  import React, { useMemo, useState } from 'react';
7
7
 
8
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
8
9
  import { Button, Checkbox, IconButton } from '@douyinfe/semi-ui';
9
10
  import {
10
11
  IconExpand,
@@ -16,7 +17,6 @@ import {
16
17
  } from '@douyinfe/semi-icons';
17
18
 
18
19
  import { TypeSelector } from '../type-selector';
19
- import { IJsonSchema } from '../../typings';
20
20
  import { ConfigType, PropertyValueType } from './types';
21
21
  import {
22
22
  IconAddChildren,
@@ -3,7 +3,7 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
- import { IJsonSchema } from '../../typings';
6
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
7
7
 
8
8
  export interface PropertyValueType extends IJsonSchema {
9
9
  name?: string;
@@ -1,5 +1,9 @@
1
1
  {
2
2
  "name": "type-selector",
3
- "depMaterials": ["typings/json-schema"],
4
- "depPackages": ["@douyinfe/semi-ui", "@douyinfe/semi-icons"]
3
+ "depMaterials": [],
4
+ "depPackages": [
5
+ "@douyinfe/semi-ui",
6
+ "@douyinfe/semi-icons",
7
+ "@flowgram.ai/json-schema"
8
+ ]
5
9
  }
@@ -5,10 +5,10 @@
5
5
 
6
6
  import React, { useMemo } from 'react';
7
7
 
8
- import { Cascader, IconButton } from '@douyinfe/semi-ui';
8
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
9
+ import { Cascader, Icon, IconButton } from '@douyinfe/semi-ui';
9
10
 
10
- import { IJsonSchema } from '../../typings';
11
- import { ArrayIcons, VariableTypeIcons, getSchemaIcon, options } from './constants';
11
+ import { useTypeManager } from '../../plugins';
12
12
 
13
13
  interface PropTypes {
14
14
  value?: Partial<IJsonSchema>;
@@ -21,6 +21,10 @@ interface PropTypes {
21
21
  style?: React.CSSProperties;
22
22
  }
23
23
 
24
+ const labelStyle: React.CSSProperties = { display: 'flex', alignItems: 'center', gap: 5 };
25
+
26
+ const firstUppercase = (str: string) => str.charAt(0).toUpperCase() + str.slice(1);
27
+
24
28
  export const getTypeSelectValue = (value?: Partial<IJsonSchema>): string[] | undefined => {
25
29
  if (value?.type === 'array' && value?.items) {
26
30
  return [value.type, ...(getTypeSelectValue(value.items) || [])];
@@ -44,17 +48,51 @@ export function TypeSelector(props: PropTypes) {
44
48
 
45
49
  const selectValue = useMemo(() => getTypeSelectValue(value), [value]);
46
50
 
51
+ const typeManager = useTypeManager();
52
+
53
+ const icon = typeManager.getDisplayIcon(value || {});
54
+
55
+ const options = useMemo(
56
+ () =>
57
+ typeManager.getTypeRegistriesWithParentType().map((_type) => {
58
+ const isArray = _type.type === 'array';
59
+
60
+ return {
61
+ label: (
62
+ <div style={labelStyle}>
63
+ <Icon size="small" svg={_type.icon} />
64
+ {firstUppercase(_type.type)}
65
+ </div>
66
+ ),
67
+ value: _type.type,
68
+ children: isArray
69
+ ? typeManager.getTypeRegistriesWithParentType('array').map((_type) => ({
70
+ label: (
71
+ <div style={labelStyle}>
72
+ <Icon
73
+ size="small"
74
+ svg={typeManager.getDisplayIcon({
75
+ type: 'array',
76
+ items: { type: _type.type },
77
+ })}
78
+ />
79
+ {firstUppercase(_type.type)}
80
+ </div>
81
+ ),
82
+ value: _type.type,
83
+ }))
84
+ : [],
85
+ };
86
+ }),
87
+ []
88
+ );
89
+
47
90
  return (
48
91
  <Cascader
49
92
  disabled={readonly || disabled}
50
93
  size="small"
51
94
  triggerRender={() => (
52
- <IconButton
53
- size="small"
54
- style={style}
55
- disabled={readonly || disabled}
56
- icon={getSchemaIcon(value)}
57
- />
95
+ <IconButton size="small" style={style} disabled={readonly || disabled} icon={icon} />
58
96
  )}
59
97
  treeData={options}
60
98
  value={selectValue}
@@ -65,5 +103,3 @@ export function TypeSelector(props: PropTypes) {
65
103
  />
66
104
  );
67
105
  }
68
-
69
- export { VariableTypeIcons, ArrayIcons, getSchemaIcon };
@@ -1,5 +1,9 @@
1
1
  {
2
2
  "name": "variable-selector",
3
- "depMaterials": ["type-selector", "utils/json-schema", "typings/json-schema"],
4
- "depPackages": ["@douyinfe/semi-ui", "styled-components"]
3
+ "depMaterials": [],
4
+ "depPackages": [
5
+ "@douyinfe/semi-ui",
6
+ "styled-components",
7
+ "@flowgram.ai/json-schema"
8
+ ]
5
9
  }
@@ -5,12 +5,12 @@
5
5
 
6
6
  import React, { useMemo } from 'react';
7
7
 
8
+ import { IJsonSchema } from '@flowgram.ai/json-schema';
8
9
  import { TriggerRenderProps } from '@douyinfe/semi-ui/lib/es/treeSelect';
9
10
  import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
10
11
  import { Popover } from '@douyinfe/semi-ui';
11
12
  import { IconChevronDownStroked, IconIssueStroked } from '@douyinfe/semi-icons';
12
13
 
13
- import { IJsonSchema } from '../../typings/json-schema';
14
14
  import { useVariableTree } from './use-variable-tree';
15
15
  import { UIPopoverContent, UIRootTitle, UITag, UITreeSelect, UIVarName } from './styles';
16
16
 
@@ -5,15 +5,18 @@
5
5
 
6
6
  import React, { useCallback } from 'react';
7
7
 
8
+ import { IJsonSchema, JsonSchemaUtils } from '@flowgram.ai/json-schema';
8
9
  import { ASTMatch, BaseVariableField, useAvailableVariables } from '@flowgram.ai/editor';
9
10
  import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
10
11
  import { Icon } from '@douyinfe/semi-ui';
11
12
 
12
- import { ArrayIcons, VariableTypeIcons } from '../type-selector/constants';
13
- import { JsonSchemaUtils } from '../../utils/json-schema';
14
- import { IJsonSchema } from '../../typings/json-schema';
13
+ import { useTypeManager } from '../../plugins';
15
14
 
16
- type VariableField = BaseVariableField<{ icon?: string | JSX.Element; title?: string }>;
15
+ type VariableField = BaseVariableField<{
16
+ icon?: string | JSX.Element;
17
+ title?: string;
18
+ disabled?: boolean;
19
+ }>;
17
20
 
18
21
  export function useVariableTree(params: {
19
22
  includeSchema?: IJsonSchema | IJsonSchema[];
@@ -22,6 +25,7 @@ export function useVariableTree(params: {
22
25
  }): TreeNodeData[] {
23
26
  const { includeSchema, excludeSchema, customSkip } = params;
24
27
 
28
+ const typeManager = useTypeManager();
25
29
  const variables = useAvailableVariables();
26
30
 
27
31
  const getVariableTypeIcon = useCallback((variable: VariableField) => {
@@ -33,22 +37,9 @@ export function useVariableTree(params: {
33
37
  return variable.meta.icon;
34
38
  }
35
39
 
36
- const _type = variable.type;
40
+ const schema = JsonSchemaUtils.astToSchema(variable.type, { drilldownObject: false });
37
41
 
38
- if (ASTMatch.isArray(_type)) {
39
- return (
40
- <Icon
41
- size="small"
42
- svg={ArrayIcons[_type.items?.kind.toLowerCase()] || VariableTypeIcons.array}
43
- />
44
- );
45
- }
46
-
47
- if (ASTMatch.isCustomType(_type)) {
48
- return <Icon size="small" svg={VariableTypeIcons[_type.typeName.toLowerCase()]} />;
49
- }
50
-
51
- return <Icon size="small" svg={VariableTypeIcons[variable.type?.kind.toLowerCase()]} />;
42
+ return <Icon size="small" svg={typeManager.getDisplayIcon(schema || {})} />;
52
43
  }, []);
53
44
 
54
45
  const renderVariable = (
@@ -80,7 +71,10 @@ export function useVariableTree(params: {
80
71
  : false;
81
72
  const isCustomSkip = customSkip ? customSkip(variable) : false;
82
73
 
83
- const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip;
74
+ // disabled in meta when created
75
+ const isMetaDisabled = variable.meta?.disabled;
76
+
77
+ const isSchemaMatch = isSchemaInclude && !isSchemaExclude && !isCustomSkip && !isMetaDisabled;
84
78
 
85
79
  // If not match, and no children, return null
86
80
  if (!isSchemaMatch && !children?.length) {
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "name": "provide-json-schema-outputs",
3
- "depMaterials": [
4
- "typings/json-schema",
5
- "utils/json-schema"
6
- ],
7
- "depPackages": []
3
+ "depMaterials": [],
4
+ "depPackages": [
5
+ "@flowgram.ai/json-schema"
6
+ ]
8
7
  }
@@ -3,6 +3,7 @@
3
3
  * SPDX-License-Identifier: MIT
4
4
  */
5
5
 
6
+ import { JsonSchemaUtils, IJsonSchema } from '@flowgram.ai/json-schema';
6
7
  import {
7
8
  ASTFactory,
8
9
  EffectOptions,
@@ -11,9 +12,6 @@ import {
11
12
  getNodeForm,
12
13
  } from '@flowgram.ai/editor';
13
14
 
14
- import { JsonSchemaUtils } from '../../utils';
15
- import { IJsonSchema } from '../../typings';
16
-
17
15
  export const provideJsonSchemaOutputs: EffectOptions[] = createEffectFromVariableProvider({
18
16
  parse: (value: IJsonSchema, ctx) => [
19
17
  ASTFactory.createVariableDeclaration({
@@ -18,6 +18,7 @@ export const syncVariableTitle: EffectOptions[] = [
18
18
  context.node.getData(FlowNodeVariableData).allScopes.forEach((_scope) => {
19
19
  _scope.output.variables.forEach((_var) => {
20
20
  _var.updateMeta({
21
+ ...(_var.meta || {}),
21
22
  title: value || context.node.id,
22
23
  icon: context.node.getNodeRegistry<FlowNodeRegistry>().info?.icon,
23
24
  });
@@ -3,5 +3,7 @@
3
3
  "depMaterials": [
4
4
  "flow-value"
5
5
  ],
6
- "depPackages": []
6
+ "depPackages": [
7
+ "@flowgram.ai/json-schema"
8
+ ]
7
9
  }