@flowgram.ai/form-materials 0.2.32 → 0.3.0
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/bin/index.ts +11 -5
- package/bin/materials.ts +1 -1
- package/dist/esm/index.js +1252 -1361
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +232 -202
- package/dist/index.d.ts +232 -202
- package/dist/index.js +1396 -1506
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/src/components/batch-variable-selector/config.json +6 -2
- package/src/components/batch-variable-selector/index.tsx +1 -1
- package/src/components/code-editor/theme/light.ts +1 -1
- package/src/components/code-editor-mini/config.json +7 -0
- package/src/components/code-editor-mini/index.tsx +31 -0
- package/src/components/condition-row/config.json +10 -2
- package/src/components/condition-row/hooks/useRule.ts +2 -2
- package/src/components/condition-row/index.tsx +1 -1
- package/src/components/condition-row/types.ts +3 -1
- package/src/components/constant-input/config.json +6 -3
- package/src/components/constant-input/index.tsx +10 -71
- package/src/components/constant-input/types.ts +6 -10
- package/src/components/display-flow-value/config.json +8 -0
- package/src/components/display-flow-value/index.tsx +59 -0
- package/src/components/display-inputs-values/config.json +9 -0
- package/src/components/display-inputs-values/index.tsx +27 -0
- package/src/components/display-inputs-values/styles.ts +12 -0
- package/src/components/display-outputs/config.json +10 -0
- package/src/components/display-outputs/index.tsx +58 -0
- package/src/components/display-outputs/styles.ts +12 -0
- package/src/components/display-schema-tag/config.json +10 -0
- package/src/components/display-schema-tag/index.tsx +44 -0
- package/src/components/display-schema-tag/styles.ts +28 -0
- package/src/components/display-schema-tree/config.json +11 -0
- package/src/components/display-schema-tree/index.tsx +74 -0
- package/src/components/display-schema-tree/styles.tsx +90 -0
- package/src/components/dynamic-value-input/config.json +11 -2
- package/src/components/dynamic-value-input/hooks.ts +53 -0
- package/src/components/dynamic-value-input/index.tsx +30 -28
- package/src/components/index.ts +6 -0
- package/src/components/inputs-values/config.json +2 -1
- package/src/components/inputs-values/types.ts +3 -1
- package/src/components/json-schema-editor/config.json +3 -3
- package/src/components/json-schema-editor/default-value.tsx +1 -1
- package/src/components/json-schema-editor/hooks.tsx +1 -1
- package/src/components/json-schema-editor/index.tsx +1 -1
- package/src/components/json-schema-editor/types.ts +1 -1
- package/src/components/type-selector/config.json +6 -2
- package/src/components/type-selector/index.tsx +47 -11
- package/src/components/variable-selector/config.json +6 -2
- package/src/components/variable-selector/index.tsx +1 -1
- package/src/components/variable-selector/use-variable-tree.tsx +14 -20
- package/src/effects/provide-json-schema-outputs/config.json +4 -5
- package/src/effects/provide-json-schema-outputs/index.ts +1 -3
- package/src/effects/sync-variable-title/index.ts +1 -0
- package/src/form-plugins/infer-inputs-plugin/config.json +3 -1
- package/src/form-plugins/infer-inputs-plugin/index.ts +2 -2
- package/src/index.ts +1 -1
- package/src/{utils → shared}/index.ts +1 -1
- package/src/shared/json-schema-preset/config.json +9 -0
- package/src/shared/json-schema-preset/create-type-preset-plugin.tsx +26 -0
- package/src/shared/json-schema-preset/index.tsx +39 -0
- package/src/shared/json-schema-preset/manager.ts +18 -0
- package/src/shared/json-schema-preset/type-definition/array.tsx +23 -0
- package/src/shared/json-schema-preset/type-definition/boolean.tsx +32 -0
- package/src/shared/json-schema-preset/type-definition/index.tsx +24 -0
- package/src/shared/json-schema-preset/type-definition/integer.tsx +24 -0
- package/src/shared/json-schema-preset/type-definition/number.tsx +24 -0
- package/src/shared/json-schema-preset/type-definition/object.tsx +23 -0
- package/src/shared/json-schema-preset/type-definition/string.tsx +18 -0
- package/src/typings/flow-value/config.json +4 -4
- package/src/typings/flow-value/index.ts +1 -1
- package/src/typings/index.ts +0 -1
- package/src/components/type-selector/constants.tsx +0 -364
- package/src/typings/json-schema/config.json +0 -5
- package/src/typings/json-schema/index.ts +0 -36
- package/src/utils/json-schema/config.json +0 -5
- package/src/utils/json-schema/index.ts +0 -180
- /package/src/{utils → shared}/format-legacy-refs/config.json +0 -0
- /package/src/{utils → shared}/format-legacy-refs/index.ts +0 -0
- /package/src/{utils → shared}/format-legacy-refs/readme.md +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowgram.ai/form-materials",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"homepage": "https://flowgram.ai/",
|
|
5
5
|
"repository": "https://github.com/bytedance/flowgram.ai",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
"@codemirror/view": "~6.38.0",
|
|
35
35
|
"@codemirror/state": "~6.5.2",
|
|
36
36
|
"typescript": "^5.8.3",
|
|
37
|
-
"@flowgram.ai/editor": "0.
|
|
37
|
+
"@flowgram.ai/editor": "0.3.0",
|
|
38
|
+
"@flowgram.ai/json-schema": "0.3.0"
|
|
38
39
|
},
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"@types/lodash": "^4.14.137",
|
|
@@ -50,8 +51,8 @@
|
|
|
50
51
|
"tsup": "^8.0.1",
|
|
51
52
|
"typescript": "^5.8.3",
|
|
52
53
|
"vitest": "^0.34.6",
|
|
53
|
-
"@flowgram.ai/eslint-config": "0.
|
|
54
|
-
"@flowgram.ai/ts-config": "0.
|
|
54
|
+
"@flowgram.ai/eslint-config": "0.3.0",
|
|
55
|
+
"@flowgram.ai/ts-config": "0.3.0"
|
|
55
56
|
},
|
|
56
57
|
"peerDependencies": {
|
|
57
58
|
"react": ">=16.8",
|
|
@@ -5,10 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
|
+
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
8
9
|
import { PrivateScopeProvider } from '@flowgram.ai/editor';
|
|
9
10
|
|
|
10
11
|
import { VariableSelector, VariableSelectorProps } from '../variable-selector';
|
|
11
|
-
import { IJsonSchema } from '../../typings';
|
|
12
12
|
|
|
13
13
|
const batchVariableSchema: IJsonSchema = {
|
|
14
14
|
type: 'array',
|
|
@@ -29,7 +29,7 @@ export const lightTheme: Extension = createTheme({
|
|
|
29
29
|
gutterForeground: '#666',
|
|
30
30
|
gutterBorderColor: 'transparent',
|
|
31
31
|
gutterBorderWidth: 0,
|
|
32
|
-
lineHighlight: '#
|
|
32
|
+
lineHighlight: '#e1e1e180',
|
|
33
33
|
bracketColors: ['#FFD700', '#DD99FF', '#78B0FF'],
|
|
34
34
|
tooltip: {
|
|
35
35
|
backgroundColor: '#f0f0f0',
|
|
@@ -0,0 +1,31 @@
|
|
|
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 styled from 'styled-components';
|
|
9
|
+
|
|
10
|
+
import { CodeEditor, CodeEditorPropsType } from '../code-editor';
|
|
11
|
+
|
|
12
|
+
const UIMini = styled.div`
|
|
13
|
+
.ͼ1 .cm-content {
|
|
14
|
+
padding: 0;
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
export function CodeEditorMini(props: CodeEditorPropsType) {
|
|
19
|
+
return (
|
|
20
|
+
<UIMini>
|
|
21
|
+
<CodeEditor
|
|
22
|
+
{...props}
|
|
23
|
+
options={{
|
|
24
|
+
lineNumbersGutter: false,
|
|
25
|
+
foldGutter: false,
|
|
26
|
+
...(props.options || {}),
|
|
27
|
+
}}
|
|
28
|
+
/>
|
|
29
|
+
</UIMini>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "condition-row",
|
|
3
|
-
"depMaterials": [
|
|
4
|
-
|
|
3
|
+
"depMaterials": [
|
|
4
|
+
"variable-selector",
|
|
5
|
+
"dynamic-value-input",
|
|
6
|
+
"flow-value"
|
|
7
|
+
],
|
|
8
|
+
"depPackages": [
|
|
9
|
+
"@douyinfe/semi-ui",
|
|
10
|
+
"styled-components",
|
|
11
|
+
"@flowgram.ai/json-schema"
|
|
12
|
+
]
|
|
5
13
|
}
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
import { useMemo } from 'react';
|
|
7
7
|
|
|
8
|
+
import { JsonSchemaUtils, JsonSchemaBasicType } from '@flowgram.ai/json-schema';
|
|
8
9
|
import { useScopeAvailable } from '@flowgram.ai/editor';
|
|
9
10
|
|
|
10
11
|
import { rules } from '../constants';
|
|
11
|
-
import {
|
|
12
|
-
import { IFlowRefValue, JsonSchemaBasicType } from '../../../typings';
|
|
12
|
+
import { IFlowRefValue } from '../../../typings';
|
|
13
13
|
|
|
14
14
|
export function useRule(left?: IFlowRefValue) {
|
|
15
15
|
const available = useScopeAvailable();
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
import React, { useMemo } from 'react';
|
|
7
7
|
|
|
8
|
+
import { JsonSchemaBasicType } from '@flowgram.ai/json-schema';
|
|
8
9
|
import { Input } from '@douyinfe/semi-ui';
|
|
9
10
|
|
|
10
11
|
import { ConditionRowValueType, Op } from './types';
|
|
@@ -13,7 +14,6 @@ import { useRule } from './hooks/useRule';
|
|
|
13
14
|
import { useOp } from './hooks/useOp';
|
|
14
15
|
import { VariableSelector } from '../variable-selector';
|
|
15
16
|
import { DynamicValueInput } from '../dynamic-value-input';
|
|
16
|
-
import { JsonSchemaBasicType } from '../../typings';
|
|
17
17
|
|
|
18
18
|
interface PropTypes {
|
|
19
19
|
value?: ConditionRowValueType;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { JsonSchemaBasicType } from '@flowgram.ai/json-schema';
|
|
7
|
+
|
|
8
|
+
import { IFlowConstantRefValue, IFlowRefValue } from '../../typings';
|
|
7
9
|
|
|
8
10
|
export enum Op {
|
|
9
11
|
EQ = 'eq',
|
|
@@ -6,83 +6,22 @@
|
|
|
6
6
|
/* eslint-disable react/prop-types */
|
|
7
7
|
import React, { useMemo } from 'react';
|
|
8
8
|
|
|
9
|
-
import { Input
|
|
9
|
+
import { Input } from '@douyinfe/semi-ui';
|
|
10
10
|
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
const defaultStrategies: Strategy[] = [
|
|
14
|
-
{
|
|
15
|
-
hit: (schema) => schema?.type === 'string',
|
|
16
|
-
Renderer: (props) => (
|
|
17
|
-
<Input placeholder="Please Input String" size="small" disabled={props.readonly} {...props} />
|
|
18
|
-
),
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
hit: (schema) => schema?.type === 'number',
|
|
22
|
-
Renderer: (props) => (
|
|
23
|
-
<InputNumber
|
|
24
|
-
placeholder="Please Input Number"
|
|
25
|
-
size="small"
|
|
26
|
-
disabled={props.readonly}
|
|
27
|
-
hideButtons
|
|
28
|
-
{...props}
|
|
29
|
-
/>
|
|
30
|
-
),
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
hit: (schema) => schema?.type === 'integer',
|
|
34
|
-
Renderer: (props) => (
|
|
35
|
-
<InputNumber
|
|
36
|
-
placeholder="Please Input Integer"
|
|
37
|
-
size="small"
|
|
38
|
-
disabled={props.readonly}
|
|
39
|
-
hideButtons
|
|
40
|
-
precision={0}
|
|
41
|
-
{...props}
|
|
42
|
-
/>
|
|
43
|
-
),
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
hit: (schema) => schema?.type === 'boolean',
|
|
47
|
-
Renderer: (props) => {
|
|
48
|
-
const { value, onChange, ...rest } = props;
|
|
49
|
-
return (
|
|
50
|
-
<Select
|
|
51
|
-
placeholder="Please Select Boolean"
|
|
52
|
-
size="small"
|
|
53
|
-
disabled={props.readonly}
|
|
54
|
-
optionList={[
|
|
55
|
-
{ label: 'True', value: 1 },
|
|
56
|
-
{ label: 'False', value: 0 },
|
|
57
|
-
]}
|
|
58
|
-
value={value ? 1 : 0}
|
|
59
|
-
onChange={(value) => onChange?.(!!value)}
|
|
60
|
-
{...rest}
|
|
61
|
-
/>
|
|
62
|
-
);
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
];
|
|
11
|
+
import { useTypeManager } from '../../shared';
|
|
12
|
+
import { PropsType } from './types';
|
|
66
13
|
|
|
67
14
|
export function ConstantInput(props: PropsType) {
|
|
68
|
-
const {
|
|
69
|
-
value,
|
|
70
|
-
onChange,
|
|
71
|
-
schema,
|
|
72
|
-
strategies: extraStrategies,
|
|
73
|
-
fallbackRenderer,
|
|
74
|
-
readonly,
|
|
75
|
-
...rest
|
|
76
|
-
} = props;
|
|
15
|
+
const { value, onChange, schema, strategies, fallbackRenderer, readonly, ...rest } = props;
|
|
77
16
|
|
|
78
|
-
const
|
|
79
|
-
// user's extraStrategies first
|
|
80
|
-
() => [...(extraStrategies || []), ...defaultStrategies],
|
|
81
|
-
[extraStrategies]
|
|
82
|
-
);
|
|
17
|
+
const typeManager = useTypeManager();
|
|
83
18
|
|
|
84
19
|
const Renderer = useMemo(() => {
|
|
85
|
-
const strategy = strategies.find((_strategy) => _strategy.hit(schema));
|
|
20
|
+
const strategy = (strategies || []).find((_strategy) => _strategy.hit(schema));
|
|
21
|
+
|
|
22
|
+
if (!strategy) {
|
|
23
|
+
return typeManager.getTypeBySchema(schema)?.ConstantRenderer;
|
|
24
|
+
}
|
|
86
25
|
|
|
87
26
|
return strategy?.Renderer;
|
|
88
27
|
}, [strategies, schema]);
|
|
@@ -3,22 +3,18 @@
|
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import { IJsonSchema } from '
|
|
6
|
+
import { IJsonSchema } from '@flowgram.ai/json-schema';
|
|
7
|
+
|
|
8
|
+
import { ConstantRendererProps } from '../../shared';
|
|
7
9
|
|
|
8
10
|
export interface Strategy<Value = any> {
|
|
9
11
|
hit: (schema: IJsonSchema) => boolean;
|
|
10
|
-
Renderer: React.FC<
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface RendererProps<Value = any> {
|
|
14
|
-
value?: Value;
|
|
15
|
-
onChange?: (value: Value) => void;
|
|
16
|
-
readonly?: boolean;
|
|
12
|
+
Renderer: React.FC<ConstantRendererProps<Value>>;
|
|
17
13
|
}
|
|
18
14
|
|
|
19
|
-
export interface PropsType extends
|
|
15
|
+
export interface PropsType extends ConstantRendererProps {
|
|
20
16
|
schema: IJsonSchema;
|
|
21
17
|
strategies?: Strategy[];
|
|
22
|
-
fallbackRenderer?: React.FC<
|
|
18
|
+
fallbackRenderer?: React.FC<ConstantRendererProps>;
|
|
23
19
|
[key: string]: any;
|
|
24
20
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useMemo } from 'react';
|
|
7
|
+
|
|
8
|
+
import { JsonSchemaTypeManager, JsonSchemaUtils } from '@flowgram.ai/json-schema';
|
|
9
|
+
import { useScopeAvailable } from '@flowgram.ai/editor';
|
|
10
|
+
|
|
11
|
+
import { DisplaySchemaTag } from '../display-schema-tag';
|
|
12
|
+
import { IFlowValue } from '../../typings';
|
|
13
|
+
|
|
14
|
+
interface PropsType {
|
|
15
|
+
value?: IFlowValue;
|
|
16
|
+
title?: JSX.Element | string;
|
|
17
|
+
showIconInTree?: boolean;
|
|
18
|
+
typeManager?: JsonSchemaTypeManager;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function DisplayFlowValue({ value, title, showIconInTree }: PropsType) {
|
|
22
|
+
const available = useScopeAvailable();
|
|
23
|
+
|
|
24
|
+
const variable = value?.type === 'ref' ? available.getByKeyPath(value?.content) : undefined;
|
|
25
|
+
|
|
26
|
+
const schema = useMemo(() => {
|
|
27
|
+
if (value?.type === 'ref') {
|
|
28
|
+
return JsonSchemaUtils.astToSchema(variable?.type);
|
|
29
|
+
}
|
|
30
|
+
if (value?.type === 'template') {
|
|
31
|
+
return { type: 'string' };
|
|
32
|
+
}
|
|
33
|
+
if (value?.type === 'constant') {
|
|
34
|
+
if (value?.schema) {
|
|
35
|
+
return value?.schema;
|
|
36
|
+
}
|
|
37
|
+
if (typeof value?.content === 'string') {
|
|
38
|
+
return { type: 'string' };
|
|
39
|
+
}
|
|
40
|
+
if (typeof value?.content === 'number') {
|
|
41
|
+
return { type: 'number' };
|
|
42
|
+
}
|
|
43
|
+
if (typeof value?.content === 'boolean') {
|
|
44
|
+
return { type: 'boolean' };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return { type: 'unknown' };
|
|
49
|
+
}, [value, variable?.hash]);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<DisplaySchemaTag
|
|
53
|
+
title={title}
|
|
54
|
+
value={schema}
|
|
55
|
+
showIconInTree={showIconInTree}
|
|
56
|
+
warning={value?.type === 'ref' && !variable}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { DisplayFlowValue } from '../display-flow-value';
|
|
9
|
+
import { IFlowValue } from '../../typings';
|
|
10
|
+
import { DisplayInputsWrapper } from './styles';
|
|
11
|
+
|
|
12
|
+
interface PropsType {
|
|
13
|
+
value?: Record<string, IFlowValue | undefined>;
|
|
14
|
+
showIconInTree?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function DisplayInputsValues({ value, showIconInTree }: PropsType) {
|
|
18
|
+
const childEntries = Object.entries(value || {});
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<DisplayInputsWrapper>
|
|
22
|
+
{childEntries.map(([key, value]) => (
|
|
23
|
+
<DisplayFlowValue key={key} title={key} value={value} showIconInTree={showIconInTree} />
|
|
24
|
+
))}
|
|
25
|
+
</DisplayInputsWrapper>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import React, { useEffect } from 'react';
|
|
7
|
+
|
|
8
|
+
import { IJsonSchema, JsonSchemaTypeManager, JsonSchemaUtils } from '@flowgram.ai/json-schema';
|
|
9
|
+
import { useCurrentScope, useRefresh } from '@flowgram.ai/editor';
|
|
10
|
+
|
|
11
|
+
import { DisplaySchemaTag } from '../display-schema-tag';
|
|
12
|
+
import { DisplayOutputsWrapper } from './styles';
|
|
13
|
+
|
|
14
|
+
interface PropsType {
|
|
15
|
+
value?: IJsonSchema;
|
|
16
|
+
showIconInTree?: boolean;
|
|
17
|
+
displayFromScope?: boolean;
|
|
18
|
+
typeManager?: JsonSchemaTypeManager;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function DisplayOutputs({ value, showIconInTree, displayFromScope }: PropsType) {
|
|
22
|
+
const scope = useCurrentScope();
|
|
23
|
+
const refresh = useRefresh();
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!displayFromScope) {
|
|
27
|
+
return () => null;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const disposable = scope.output.onListOrAnyVarChange(() => {
|
|
31
|
+
refresh();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return () => {
|
|
35
|
+
disposable.dispose();
|
|
36
|
+
};
|
|
37
|
+
}, [displayFromScope]);
|
|
38
|
+
|
|
39
|
+
const properties: IJsonSchema['properties'] = displayFromScope
|
|
40
|
+
? scope.output.variables?.reduce((acm, curr) => {
|
|
41
|
+
acm = {
|
|
42
|
+
...acm,
|
|
43
|
+
...(JsonSchemaUtils.astToSchema(curr.type)?.properties || {}),
|
|
44
|
+
};
|
|
45
|
+
return acm;
|
|
46
|
+
}, {})
|
|
47
|
+
: value?.properties || {};
|
|
48
|
+
|
|
49
|
+
const childEntries = Object.entries(properties || {});
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<DisplayOutputsWrapper>
|
|
53
|
+
{childEntries.map(([key, schema]) => (
|
|
54
|
+
<DisplaySchemaTag key={key} title={key} value={schema} showIconInTree={showIconInTree} />
|
|
55
|
+
))}
|
|
56
|
+
</DisplayOutputsWrapper>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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 } from '@flowgram.ai/json-schema';
|
|
9
|
+
import { Popover } from '@douyinfe/semi-ui';
|
|
10
|
+
|
|
11
|
+
import { DisplaySchemaTree } from '../display-schema-tree';
|
|
12
|
+
import { useTypeManager } from '../../shared';
|
|
13
|
+
import { PopoverContent, StyledTag, TitleSpan } from './styles';
|
|
14
|
+
|
|
15
|
+
interface PropsType {
|
|
16
|
+
title?: JSX.Element | string;
|
|
17
|
+
value?: IJsonSchema;
|
|
18
|
+
showIconInTree?: boolean;
|
|
19
|
+
warning?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function DisplaySchemaTag({ value = {}, showIconInTree, title, warning }: PropsType) {
|
|
23
|
+
const typeManager = useTypeManager();
|
|
24
|
+
const icon =
|
|
25
|
+
typeManager?.getDisplayIcon(value) || typeManager.getDisplayIcon({ type: 'unknown' });
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<Popover
|
|
29
|
+
content={
|
|
30
|
+
<PopoverContent>
|
|
31
|
+
<DisplaySchemaTree value={value} typeManager={typeManager} showIcon={showIconInTree} />
|
|
32
|
+
</PopoverContent>
|
|
33
|
+
}
|
|
34
|
+
>
|
|
35
|
+
<StyledTag color={warning ? 'amber' : 'white'}>
|
|
36
|
+
{icon &&
|
|
37
|
+
React.cloneElement(icon, {
|
|
38
|
+
className: 'tag-icon',
|
|
39
|
+
})}
|
|
40
|
+
{title && <TitleSpan>{title}</TitleSpan>}
|
|
41
|
+
</StyledTag>
|
|
42
|
+
</Popover>
|
|
43
|
+
);
|
|
44
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import styled from 'styled-components';
|
|
7
|
+
import { Tag } from '@douyinfe/semi-ui';
|
|
8
|
+
|
|
9
|
+
export const PopoverContent = styled.div`
|
|
10
|
+
padding: 10px;
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const StyledTag = styled(Tag)`
|
|
14
|
+
padding: 4px;
|
|
15
|
+
|
|
16
|
+
.tag-icon {
|
|
17
|
+
width: 12px;
|
|
18
|
+
height: 12px;
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export const TitleSpan = styled.span`
|
|
23
|
+
display: inline-block;
|
|
24
|
+
margin-left: 4px;
|
|
25
|
+
margin-top: -1px;
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
text-overflow: ellipsis;
|
|
28
|
+
`;
|