@flowgram.ai/form-materials 0.3.0 → 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 (33) hide show
  1. package/bin/materials.ts +9 -1
  2. package/dist/esm/index.js +117 -87
  3. package/dist/esm/index.js.map +1 -1
  4. package/dist/index.d.mts +94 -87
  5. package/dist/index.d.ts +94 -87
  6. package/dist/index.js +191 -164
  7. package/dist/index.js.map +1 -1
  8. package/package.json +5 -5
  9. package/src/components/condition-row/constants.ts +4 -0
  10. package/src/components/constant-input/index.tsx +1 -1
  11. package/src/components/constant-input/types.ts +1 -1
  12. package/src/components/display-schema-tag/index.tsx +1 -1
  13. package/src/components/display-schema-tree/index.tsx +1 -1
  14. package/src/components/json-schema-editor/config.json +1 -1
  15. package/src/components/type-selector/index.tsx +1 -1
  16. package/src/components/variable-selector/use-variable-tree.tsx +1 -1
  17. package/src/index.ts +1 -0
  18. package/src/plugins/disable-declaration-plugin/config.json +5 -0
  19. package/src/plugins/disable-declaration-plugin/create-disable-declaration-plugin.ts +31 -0
  20. package/src/plugins/disable-declaration-plugin/index.tsx +6 -0
  21. package/src/plugins/index.ts +7 -0
  22. package/src/{shared → plugins}/json-schema-preset/create-type-preset-plugin.tsx +4 -2
  23. package/src/shared/index.ts +0 -1
  24. /package/src/{shared → plugins}/json-schema-preset/config.json +0 -0
  25. /package/src/{shared → plugins}/json-schema-preset/index.tsx +0 -0
  26. /package/src/{shared → plugins}/json-schema-preset/manager.ts +0 -0
  27. /package/src/{shared → plugins}/json-schema-preset/type-definition/array.tsx +0 -0
  28. /package/src/{shared → plugins}/json-schema-preset/type-definition/boolean.tsx +0 -0
  29. /package/src/{shared → plugins}/json-schema-preset/type-definition/index.tsx +0 -0
  30. /package/src/{shared → plugins}/json-schema-preset/type-definition/integer.tsx +0 -0
  31. /package/src/{shared → plugins}/json-schema-preset/type-definition/number.tsx +0 -0
  32. /package/src/{shared → plugins}/json-schema-preset/type-definition/object.tsx +0 -0
  33. /package/src/{shared → plugins}/json-schema-preset/type-definition/string.tsx +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowgram.ai/form-materials",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "homepage": "https://flowgram.ai/",
5
5
  "repository": "https://github.com/bytedance/flowgram.ai",
6
6
  "license": "MIT",
@@ -34,8 +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.3.0",
38
- "@flowgram.ai/json-schema": "0.3.0"
37
+ "@flowgram.ai/editor": "0.3.1",
38
+ "@flowgram.ai/json-schema": "0.3.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/lodash": "^4.14.137",
@@ -51,8 +51,8 @@
51
51
  "tsup": "^8.0.1",
52
52
  "typescript": "^5.8.3",
53
53
  "vitest": "^0.34.6",
54
- "@flowgram.ai/eslint-config": "0.3.0",
55
- "@flowgram.ai/ts-config": "0.3.0"
54
+ "@flowgram.ai/ts-config": "0.3.1",
55
+ "@flowgram.ai/eslint-config": "0.3.1"
56
56
  },
57
57
  "peerDependencies": {
58
58
  "react": ">=16.8",
@@ -51,6 +51,10 @@ export const rules: IRules = {
51
51
  array: {
52
52
  [Op.IS_EMPTY]: null,
53
53
  [Op.IS_NOT_EMPTY]: null,
54
+ [Op.CONTAINS]: 'array',
55
+ [Op.NOT_CONTAINS]: 'array',
56
+ [Op.EQ]: 'array',
57
+ [Op.NEQ]: 'array',
54
58
  },
55
59
  map: {
56
60
  [Op.IS_EMPTY]: null,
@@ -8,7 +8,7 @@ import React, { useMemo } from 'react';
8
8
 
9
9
  import { Input } from '@douyinfe/semi-ui';
10
10
 
11
- import { useTypeManager } from '../../shared';
11
+ import { useTypeManager } from '../../plugins';
12
12
  import { PropsType } from './types';
13
13
 
14
14
  export function ConstantInput(props: PropsType) {
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { IJsonSchema } from '@flowgram.ai/json-schema';
7
7
 
8
- import { ConstantRendererProps } from '../../shared';
8
+ import { ConstantRendererProps } from '../../plugins';
9
9
 
10
10
  export interface Strategy<Value = any> {
11
11
  hit: (schema: IJsonSchema) => boolean;
@@ -9,7 +9,7 @@ import { IJsonSchema } from '@flowgram.ai/json-schema';
9
9
  import { Popover } from '@douyinfe/semi-ui';
10
10
 
11
11
  import { DisplaySchemaTree } from '../display-schema-tree';
12
- import { useTypeManager } from '../../shared';
12
+ import { useTypeManager } from '../../plugins';
13
13
  import { PopoverContent, StyledTag, TitleSpan } from './styles';
14
14
 
15
15
  interface PropsType {
@@ -7,7 +7,7 @@ import React from 'react';
7
7
 
8
8
  import { IJsonSchema, JsonSchemaTypeManager } from '@flowgram.ai/json-schema';
9
9
 
10
- import { useTypeManager } from '../../shared';
10
+ import { useTypeManager } from '../../plugins';
11
11
  import { HorizontalLine, TreeItem, TreeLevel, TreeRow, TreeTitle } from './styles';
12
12
 
13
13
  interface PropsType {
@@ -2,7 +2,7 @@
2
2
  "name": "json-schema-editor",
3
3
  "depMaterials": [
4
4
  "type-selector",
5
- "constant-inputs",
5
+ "constant-inputs"
6
6
  ],
7
7
  "depPackages": [
8
8
  "@douyinfe/semi-ui",
@@ -8,7 +8,7 @@ import React, { useMemo } from 'react';
8
8
  import { IJsonSchema } from '@flowgram.ai/json-schema';
9
9
  import { Cascader, Icon, IconButton } from '@douyinfe/semi-ui';
10
10
 
11
- import { useTypeManager } from '../../shared';
11
+ import { useTypeManager } from '../../plugins';
12
12
 
13
13
  interface PropTypes {
14
14
  value?: Partial<IJsonSchema>;
@@ -10,7 +10,7 @@ import { ASTMatch, BaseVariableField, useAvailableVariables } from '@flowgram.ai
10
10
  import { TreeNodeData } from '@douyinfe/semi-ui/lib/es/tree';
11
11
  import { Icon } from '@douyinfe/semi-ui';
12
12
 
13
- import { useTypeManager } from '../../shared';
13
+ import { useTypeManager } from '../../plugins';
14
14
 
15
15
  type VariableField = BaseVariableField<{
16
16
  icon?: string | JSX.Element;
package/src/index.ts CHANGED
@@ -8,3 +8,4 @@ export * from './effects';
8
8
  export * from './shared';
9
9
  export * from './typings';
10
10
  export * from './form-plugins';
11
+ export * from './plugins';
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "disable-declaration-plugin",
3
+ "depMaterials": [],
4
+ "depPackages": []
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';
@@ -14,13 +14,15 @@ import { jsonSchemaTypePreset } from './type-definition';
14
14
  import { JsonSchemaTypeRegistry } from './manager';
15
15
 
16
16
  export const createTypePresetPlugin = definePluginCreator<{
17
- types: JsonSchemaTypeRegistry[];
17
+ types?: JsonSchemaTypeRegistry[];
18
+ unregisterTypes?: string[];
18
19
  }>({
19
20
  onInit(ctx, opts) {
20
21
  const typeManager = ctx.get(BaseTypeManager) as JsonSchemaTypeManager;
21
22
  jsonSchemaTypePreset.forEach((_type) => typeManager.register(_type));
22
23
 
23
- opts.types.forEach((_type) => typeManager.register(_type));
24
+ opts.types?.forEach((_type) => typeManager.register(_type));
25
+ opts.unregisterTypes?.forEach((_type) => typeManager.unregister(_type));
24
26
  },
25
27
  containerModules: [jsonSchemaContainerModule],
26
28
  });
@@ -4,4 +4,3 @@
4
4
  */
5
5
 
6
6
  export * from './format-legacy-refs';
7
- export * from './json-schema-preset';