@flowgram.ai/form-materials 0.2.31 → 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 +1256 -1363
- 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 +1399 -1507
- 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/useOp.tsx +3 -1
- package/src/components/condition-row/hooks/useRule.ts +2 -2
- package/src/components/condition-row/index.tsx +2 -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
|
@@ -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 {
|
|
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
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
}>({
|
|
19
|
+
onInit(ctx, opts) {
|
|
20
|
+
const typeManager = ctx.get(BaseTypeManager) as JsonSchemaTypeManager;
|
|
21
|
+
jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
|
|
22
|
+
|
|
23
|
+
opts.types.forEach((_type) => typeManager.register(_type));
|
|
24
|
+
},
|
|
25
|
+
containerModules: [jsonSchemaContainerModule],
|
|
26
|
+
});
|
|
@@ -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
|
+
};
|
package/src/typings/index.ts
CHANGED