@flowgram.ai/form-materials 0.4.12 → 0.4.14

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 (149) hide show
  1. package/dist/cjs/components/code-editor/editor.js +54 -77
  2. package/dist/cjs/components/code-editor/index.js +10 -2
  3. package/dist/cjs/components/code-editor/language-features.js +119 -16
  4. package/dist/cjs/components/code-editor/theme/dark.js +120 -50
  5. package/dist/cjs/components/code-editor/theme/light.js +110 -61
  6. package/dist/cjs/components/condition-context/context.js +59 -0
  7. package/dist/cjs/components/condition-context/hooks/use-condition.js +97 -0
  8. package/dist/cjs/components/condition-context/index.js +47 -0
  9. package/dist/cjs/components/condition-context/op.js +117 -0
  10. package/dist/cjs/components/condition-row/index.js +43 -26
  11. package/dist/cjs/components/condition-row/types.js +1 -35
  12. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tag.js +4 -3
  13. package/dist/cjs/components/coze-editor-extensions/extensions/variable-tree.js +3 -0
  14. package/dist/cjs/components/db-condition-row/index.js +59 -34
  15. package/dist/cjs/components/variable-selector/index.js +0 -1
  16. package/dist/cjs/form-plugins/batch-outputs-plugin/index.js +8 -1
  17. package/dist/cjs/form-plugins/infer-inputs-plugin/index.js +30 -3
  18. package/dist/cjs/plugins/json-schema-preset/create-type-preset-plugin.js +1 -0
  19. package/dist/cjs/plugins/json-schema-preset/react.js +1 -0
  20. package/dist/cjs/plugins/json-schema-preset/type-definition/array.js +30 -1
  21. package/dist/cjs/plugins/json-schema-preset/type-definition/boolean.js +23 -0
  22. package/dist/cjs/plugins/json-schema-preset/type-definition/date-time.js +31 -2
  23. package/dist/cjs/plugins/json-schema-preset/type-definition/index.js +9 -1
  24. package/dist/cjs/plugins/json-schema-preset/type-definition/integer.js +34 -1
  25. package/dist/cjs/{components/code-editor/init-worker.js → plugins/json-schema-preset/type-definition/map.js} +21 -23
  26. package/dist/cjs/plugins/json-schema-preset/type-definition/number.js +34 -1
  27. package/dist/cjs/plugins/json-schema-preset/type-definition/object.js +6 -1
  28. package/dist/cjs/plugins/json-schema-preset/type-definition/string.js +30 -1
  29. package/dist/cjs/plugins/json-schema-preset/types.js +18 -0
  30. package/dist/cjs/shared/flow-value/utils.js +22 -8
  31. package/dist/esm/components/code-editor/editor.mjs +4 -9
  32. package/dist/esm/components/code-editor/index.mjs +5 -2
  33. package/dist/esm/components/code-editor/language-features.mjs +49 -13
  34. package/dist/esm/components/code-editor/theme/dark.mjs +117 -50
  35. package/dist/esm/components/code-editor/theme/light.mjs +108 -62
  36. package/dist/esm/components/condition-context/context.mjs +19 -0
  37. package/dist/esm/components/condition-context/hooks/use-condition.mjs +63 -0
  38. package/dist/esm/components/condition-context/index.mjs +4 -0
  39. package/dist/esm/components/condition-context/op.mjs +80 -0
  40. package/dist/esm/components/condition-row/index.mjs +45 -28
  41. package/dist/esm/components/condition-row/types.mjs +0 -18
  42. package/dist/esm/components/coze-editor-extensions/extensions/variable-tag.mjs +4 -3
  43. package/dist/esm/components/coze-editor-extensions/extensions/variable-tree.mjs +3 -0
  44. package/dist/esm/components/db-condition-row/index.mjs +59 -34
  45. package/dist/esm/components/variable-selector/index.mjs +0 -1
  46. package/dist/esm/form-plugins/batch-outputs-plugin/index.mjs +8 -1
  47. package/dist/esm/form-plugins/infer-inputs-plugin/index.mjs +31 -4
  48. package/dist/esm/plugins/json-schema-preset/create-type-preset-plugin.mjs +2 -1
  49. package/dist/esm/plugins/json-schema-preset/react.mjs +2 -1
  50. package/dist/esm/plugins/json-schema-preset/type-definition/array.mjs +30 -1
  51. package/dist/esm/plugins/json-schema-preset/type-definition/boolean.mjs +23 -0
  52. package/dist/esm/plugins/json-schema-preset/type-definition/date-time.mjs +31 -2
  53. package/dist/esm/plugins/json-schema-preset/type-definition/index.mjs +7 -2
  54. package/dist/esm/plugins/json-schema-preset/type-definition/integer.mjs +34 -1
  55. package/dist/esm/plugins/json-schema-preset/type-definition/map.mjs +20 -0
  56. package/dist/esm/plugins/json-schema-preset/type-definition/number.mjs +34 -1
  57. package/dist/esm/plugins/json-schema-preset/type-definition/object.mjs +6 -1
  58. package/dist/esm/plugins/json-schema-preset/type-definition/string.mjs +30 -1
  59. package/dist/esm/plugins/json-schema-preset/types.mjs +0 -0
  60. package/dist/esm/shared/flow-value/utils.mjs +22 -8
  61. package/dist/tsconfig.tsbuildinfo +1 -1
  62. package/dist/types/components/code-editor/editor.d.ts +0 -2
  63. package/dist/types/components/code-editor/language-features.d.ts +4 -1
  64. package/dist/types/components/code-editor/theme/dark.d.ts +29 -0
  65. package/dist/types/components/code-editor/theme/light.d.ts +24 -0
  66. package/dist/types/components/condition-context/context.d.ts +14 -0
  67. package/dist/types/components/condition-context/hooks/use-condition.d.ts +29 -0
  68. package/dist/types/components/condition-context/index.d.ts +8 -0
  69. package/dist/types/components/condition-context/op.d.ts +22 -0
  70. package/dist/types/components/condition-context/types.d.ts +14 -0
  71. package/dist/types/components/condition-row/index.d.ts +4 -7
  72. package/dist/types/components/condition-row/types.d.ts +0 -24
  73. package/dist/types/components/db-condition-row/index.d.ts +4 -3
  74. package/dist/types/components/db-condition-row/types.d.ts +0 -8
  75. package/dist/types/form-plugins/batch-outputs-plugin/index.d.ts +4 -0
  76. package/dist/types/form-plugins/infer-inputs-plugin/index.d.ts +4 -0
  77. package/dist/types/plugins/json-schema-preset/create-type-preset-plugin.d.ts +1 -1
  78. package/dist/types/plugins/json-schema-preset/index.d.ts +1 -1
  79. package/dist/types/plugins/json-schema-preset/react.d.ts +1 -1
  80. package/dist/types/plugins/json-schema-preset/type-definition/array.d.ts +1 -1
  81. package/dist/types/plugins/json-schema-preset/type-definition/boolean.d.ts +1 -1
  82. package/dist/types/plugins/json-schema-preset/type-definition/date-time.d.ts +1 -1
  83. package/dist/types/plugins/json-schema-preset/type-definition/index.d.ts +3 -1
  84. package/dist/types/plugins/json-schema-preset/type-definition/integer.d.ts +1 -1
  85. package/dist/types/plugins/json-schema-preset/type-definition/map.d.ts +6 -0
  86. package/dist/types/plugins/json-schema-preset/type-definition/number.d.ts +1 -1
  87. package/dist/types/plugins/json-schema-preset/type-definition/object.d.ts +1 -1
  88. package/dist/types/plugins/json-schema-preset/type-definition/string.d.ts +1 -1
  89. package/dist/types/plugins/json-schema-preset/{manager.d.ts → types.d.ts} +5 -0
  90. package/dist/types/shared/flow-value/utils.d.ts +3 -1
  91. package/package.json +9 -8
  92. package/src/components/code-editor/editor.tsx +7 -10
  93. package/src/components/code-editor/index.tsx +3 -1
  94. package/src/components/code-editor/language-features.ts +52 -14
  95. package/src/components/code-editor/theme/dark.ts +62 -77
  96. package/src/components/code-editor/theme/light.ts +60 -91
  97. package/src/components/condition-context/context.tsx +28 -0
  98. package/src/components/condition-context/hooks/use-condition.tsx +99 -0
  99. package/src/components/condition-context/index.tsx +14 -0
  100. package/src/components/condition-context/op.ts +86 -0
  101. package/src/components/condition-context/types.ts +22 -0
  102. package/src/components/condition-row/index.tsx +44 -22
  103. package/src/components/condition-row/types.ts +0 -30
  104. package/src/components/coze-editor-extensions/extensions/variable-tag.tsx +6 -3
  105. package/src/components/coze-editor-extensions/extensions/variable-tree.tsx +3 -0
  106. package/src/components/db-condition-row/index.tsx +76 -24
  107. package/src/components/db-condition-row/types.ts +0 -13
  108. package/src/components/variable-selector/index.tsx +0 -2
  109. package/src/form-plugins/batch-outputs-plugin/index.ts +63 -44
  110. package/src/form-plugins/infer-inputs-plugin/index.ts +62 -14
  111. package/src/plugins/json-schema-preset/create-type-preset-plugin.tsx +4 -2
  112. package/src/plugins/json-schema-preset/index.tsx +1 -1
  113. package/src/plugins/json-schema-preset/react.tsx +5 -2
  114. package/src/plugins/json-schema-preset/type-definition/array.tsx +10 -1
  115. package/src/plugins/json-schema-preset/type-definition/boolean.tsx +17 -1
  116. package/src/plugins/json-schema-preset/type-definition/date-time.tsx +21 -2
  117. package/src/plugins/json-schema-preset/type-definition/index.tsx +10 -1
  118. package/src/plugins/json-schema-preset/type-definition/integer.tsx +19 -1
  119. package/src/plugins/json-schema-preset/type-definition/map.tsx +31 -0
  120. package/src/plugins/json-schema-preset/type-definition/number.tsx +19 -1
  121. package/src/plugins/json-schema-preset/type-definition/object.tsx +6 -1
  122. package/src/plugins/json-schema-preset/type-definition/string.tsx +19 -1
  123. package/src/plugins/json-schema-preset/{manager.ts → types.ts} +7 -0
  124. package/src/shared/flow-value/utils.ts +22 -9
  125. package/dist/cjs/components/condition-row/constants.js +0 -165
  126. package/dist/cjs/components/condition-row/hooks/useOp.js +0 -78
  127. package/dist/cjs/components/condition-row/hooks/useRule.js +0 -68
  128. package/dist/cjs/components/db-condition-row/hooks/use-left.js +0 -86
  129. package/dist/cjs/components/db-condition-row/hooks/use-op.js +0 -79
  130. package/dist/esm/components/code-editor/init-worker.mjs +0 -19
  131. package/dist/esm/components/condition-row/constants.mjs +0 -128
  132. package/dist/esm/components/condition-row/hooks/useOp.mjs +0 -44
  133. package/dist/esm/components/condition-row/hooks/useRule.mjs +0 -34
  134. package/dist/esm/components/db-condition-row/hooks/use-left.mjs +0 -52
  135. package/dist/esm/components/db-condition-row/hooks/use-op.mjs +0 -45
  136. package/dist/types/components/code-editor/init-worker.d.ts +0 -5
  137. package/dist/types/components/condition-row/constants.d.ts +0 -7
  138. package/dist/types/components/condition-row/hooks/useOp.d.ts +0 -18
  139. package/dist/types/components/condition-row/hooks/useRule.d.ts +0 -9
  140. package/dist/types/components/db-condition-row/hooks/use-left.d.ts +0 -18
  141. package/dist/types/components/db-condition-row/hooks/use-op.d.ts +0 -18
  142. package/src/components/code-editor/init-worker.ts +0 -27
  143. package/src/components/condition-row/constants.ts +0 -134
  144. package/src/components/condition-row/hooks/useOp.tsx +0 -56
  145. package/src/components/condition-row/hooks/useRule.ts +0 -35
  146. package/src/components/db-condition-row/hooks/use-left.tsx +0 -66
  147. package/src/components/db-condition-row/hooks/use-op.tsx +0 -59
  148. /package/dist/cjs/{plugins/json-schema-preset/manager.js → components/condition-context/types.js} +0 -0
  149. /package/dist/esm/{plugins/json-schema-preset/manager.mjs → components/condition-context/types.mjs} +0 -0
@@ -6,20 +6,39 @@
6
6
  /* eslint-disable react/prop-types */
7
7
  import React from 'react';
8
8
 
9
+ import { format } from 'date-fns';
10
+ import { type DatePickerProps } from '@douyinfe/semi-ui/lib/es/datePicker';
9
11
  import { DatePicker } from '@douyinfe/semi-ui';
10
12
 
11
- import { type JsonSchemaTypeRegistry } from '../manager';
13
+ import { ConditionPresetOp } from '@/components/condition-context/op';
14
+
15
+ import { type JsonSchemaTypeRegistry } from '../types';
12
16
 
13
17
  export const dateTimeRegistry: Partial<JsonSchemaTypeRegistry> = {
14
18
  type: 'date-time',
15
- ConstantRenderer: (props) => (
19
+ ConstantRenderer: (props: DatePickerProps & { readonly?: boolean }) => (
16
20
  <DatePicker
17
21
  size="small"
18
22
  type="dateTime"
19
23
  density="compact"
24
+ defaultValue={Date.now()}
20
25
  style={{ width: '100%', ...(props.style || {}) }}
21
26
  disabled={props.readonly}
22
27
  {...props}
28
+ onChange={(date) => {
29
+ props.onChange?.(format(date as Date, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"));
30
+ }}
31
+ value={props.value}
23
32
  />
24
33
  ),
34
+ conditionRule: {
35
+ [ConditionPresetOp.EQ]: { type: 'date-time' },
36
+ [ConditionPresetOp.NEQ]: { type: 'date-time' },
37
+ [ConditionPresetOp.GT]: { type: 'date-time' },
38
+ [ConditionPresetOp.GTE]: { type: 'date-time' },
39
+ [ConditionPresetOp.LT]: { type: 'date-time' },
40
+ [ConditionPresetOp.LTE]: { type: 'date-time' },
41
+ [ConditionPresetOp.IS_EMPTY]: null,
42
+ [ConditionPresetOp.IS_NOT_EMPTY]: null,
43
+ },
25
44
  };
@@ -8,10 +8,12 @@ import { jsonSchemaTypeManager } from '@flowgram.ai/json-schema';
8
8
  import { stringRegistry } from './string';
9
9
  import { objectRegistry } from './object';
10
10
  import { numberRegistry } from './number';
11
+ import { mapRegistry } from './map';
11
12
  import { integerRegistry } from './integer';
12
13
  import { dateTimeRegistry } from './date-time';
13
14
  import { booleanRegistry } from './boolean';
14
15
  import { arrayRegistry } from './array';
16
+ import { type JsonSchemaTypeRegistry } from '../types';
15
17
 
16
18
  export const jsonSchemaTypePreset = [
17
19
  stringRegistry,
@@ -20,7 +22,14 @@ export const jsonSchemaTypePreset = [
20
22
  integerRegistry,
21
23
  booleanRegistry,
22
24
  arrayRegistry,
25
+ mapRegistry,
23
26
  dateTimeRegistry,
24
27
  ];
25
28
 
26
- jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
29
+ export const initRegistries = () => {
30
+ if ((jsonSchemaTypeManager.getTypeByName('string') as JsonSchemaTypeRegistry)?.ConstantRenderer) {
31
+ return;
32
+ }
33
+
34
+ jsonSchemaTypePreset.forEach((_type) => jsonSchemaTypeManager.register(_type));
35
+ };
@@ -9,7 +9,9 @@ import React from 'react';
9
9
  import { I18n } from '@flowgram.ai/editor';
10
10
  import { InputNumber } from '@douyinfe/semi-ui';
11
11
 
12
- import { type JsonSchemaTypeRegistry } from '../manager';
12
+ import { ConditionPresetOp } from '@/components/condition-context/op';
13
+
14
+ import { type JsonSchemaTypeRegistry } from '../types';
13
15
 
14
16
  export const integerRegistry: Partial<JsonSchemaTypeRegistry> = {
15
17
  type: 'integer',
@@ -22,4 +24,20 @@ export const integerRegistry: Partial<JsonSchemaTypeRegistry> = {
22
24
  {...props}
23
25
  />
24
26
  ),
27
+ conditionRule: {
28
+ [ConditionPresetOp.EQ]: { type: 'number' },
29
+ [ConditionPresetOp.NEQ]: { type: 'number' },
30
+ [ConditionPresetOp.GT]: { type: 'number' },
31
+ [ConditionPresetOp.GTE]: { type: 'number' },
32
+ [ConditionPresetOp.LT]: { type: 'number' },
33
+ [ConditionPresetOp.LTE]: { type: 'number' },
34
+ [ConditionPresetOp.IN]: {
35
+ type: 'array',
36
+ extra: { weak: true },
37
+ },
38
+ [ConditionPresetOp.NIN]: {
39
+ type: 'array',
40
+ extra: { weak: true },
41
+ },
42
+ },
25
43
  };
@@ -0,0 +1,31 @@
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 { I18n } from '@flowgram.ai/editor';
10
+
11
+ import { ConditionPresetOp } from '@/components/condition-context/op';
12
+ import { CodeEditorMini } from '@/components/code-editor-mini';
13
+
14
+ import { type JsonSchemaTypeRegistry } from '../types';
15
+
16
+ export const mapRegistry: Partial<JsonSchemaTypeRegistry> = {
17
+ type: 'map',
18
+ ConstantRenderer: (props) => (
19
+ <CodeEditorMini
20
+ value={props.value}
21
+ onChange={(v) => props.onChange?.(v)}
22
+ languageId="json"
23
+ placeholder={I18n.t('Please Input Map')}
24
+ readonly={props.readonly}
25
+ />
26
+ ),
27
+ conditionRule: {
28
+ [ConditionPresetOp.IS_EMPTY]: null,
29
+ [ConditionPresetOp.IS_NOT_EMPTY]: null,
30
+ },
31
+ };
@@ -9,7 +9,9 @@ import React from 'react';
9
9
  import { I18n } from '@flowgram.ai/editor';
10
10
  import { InputNumber } from '@douyinfe/semi-ui';
11
11
 
12
- import { type JsonSchemaTypeRegistry } from '../manager';
12
+ import { ConditionPresetOp } from '@/components/condition-context/op';
13
+
14
+ import { type JsonSchemaTypeRegistry } from '../types';
13
15
 
14
16
  export const numberRegistry: Partial<JsonSchemaTypeRegistry> = {
15
17
  type: 'number',
@@ -22,4 +24,20 @@ export const numberRegistry: Partial<JsonSchemaTypeRegistry> = {
22
24
  {...props}
23
25
  />
24
26
  ),
27
+ conditionRule: {
28
+ [ConditionPresetOp.EQ]: { type: 'number' },
29
+ [ConditionPresetOp.NEQ]: { type: 'number' },
30
+ [ConditionPresetOp.GT]: { type: 'number' },
31
+ [ConditionPresetOp.GTE]: { type: 'number' },
32
+ [ConditionPresetOp.LT]: { type: 'number' },
33
+ [ConditionPresetOp.LTE]: { type: 'number' },
34
+ [ConditionPresetOp.IN]: {
35
+ type: 'array',
36
+ extra: { weak: true },
37
+ },
38
+ [ConditionPresetOp.NIN]: {
39
+ type: 'array',
40
+ extra: { weak: true },
41
+ },
42
+ },
25
43
  };
@@ -8,9 +8,10 @@ import React from 'react';
8
8
 
9
9
  import { I18n } from '@flowgram.ai/editor';
10
10
 
11
+ import { ConditionPresetOp } from '@/components/condition-context/op';
11
12
  import { CodeEditorMini } from '@/components/code-editor-mini';
12
13
 
13
- import { type JsonSchemaTypeRegistry } from '../manager';
14
+ import { type JsonSchemaTypeRegistry } from '../types';
14
15
 
15
16
  export const objectRegistry: Partial<JsonSchemaTypeRegistry> = {
16
17
  type: 'object',
@@ -23,4 +24,8 @@ export const objectRegistry: Partial<JsonSchemaTypeRegistry> = {
23
24
  readonly={props.readonly}
24
25
  />
25
26
  ),
27
+ conditionRule: {
28
+ [ConditionPresetOp.IS_EMPTY]: null,
29
+ [ConditionPresetOp.IS_NOT_EMPTY]: null,
30
+ },
26
31
  };
@@ -9,7 +9,9 @@ import React from 'react';
9
9
  import { I18n } from '@flowgram.ai/editor';
10
10
  import { Input, TextArea } from '@douyinfe/semi-ui';
11
11
 
12
- import { type JsonSchemaTypeRegistry } from '../manager';
12
+ import { ConditionPresetOp } from '@/components/condition-context/op';
13
+
14
+ import { type JsonSchemaTypeRegistry } from '../types';
13
15
 
14
16
  export const stringRegistry: Partial<JsonSchemaTypeRegistry> = {
15
17
  type: 'string',
@@ -30,4 +32,20 @@ export const stringRegistry: Partial<JsonSchemaTypeRegistry> = {
30
32
  {...props}
31
33
  />
32
34
  ),
35
+ conditionRule: {
36
+ [ConditionPresetOp.EQ]: { type: 'string' },
37
+ [ConditionPresetOp.NEQ]: { type: 'string' },
38
+ [ConditionPresetOp.CONTAINS]: { type: 'string' },
39
+ [ConditionPresetOp.NOT_CONTAINS]: { type: 'string' },
40
+ [ConditionPresetOp.IN]: {
41
+ type: 'array',
42
+ items: { type: 'string' },
43
+ },
44
+ [ConditionPresetOp.NIN]: {
45
+ type: 'array',
46
+ items: { type: 'string' },
47
+ },
48
+ [ConditionPresetOp.IS_EMPTY]: null,
49
+ [ConditionPresetOp.IS_NOT_EMPTY]: null,
50
+ },
33
51
  };
@@ -5,6 +5,8 @@
5
5
 
6
6
  import { JsonSchemaTypeRegistry as OriginJsonSchemaTypeRegistry } from '@flowgram.ai/json-schema';
7
7
 
8
+ import { IConditionRule, IConditionRuleFactory } from '@/components/condition-context/types';
9
+
8
10
  export interface ConstantRendererProps<Value = any> {
9
11
  value?: Value;
10
12
  onChange?: (value: Value) => void;
@@ -16,4 +18,9 @@ export interface JsonSchemaTypeRegistry<Value = any> extends OriginJsonSchemaTyp
16
18
  * Render Constant Input
17
19
  */
18
20
  ConstantRenderer: React.FC<ConstantRendererProps<Value>>;
21
+
22
+ /**
23
+ * Condition Rules
24
+ */
25
+ conditionRule?: IConditionRule | IConditionRuleFactory;
19
26
  }
@@ -70,42 +70,55 @@ export namespace FlowValueUtils {
70
70
  export function* traverse(
71
71
  value: any,
72
72
  options: {
73
- includeTypes?: FlowValueType[];
73
+ includeTypes: FlowValueType[];
74
74
  path?: string;
75
+ pathArr?: string[];
75
76
  }
76
- ): Generator<{ value: IFlowValue; path: string }> {
77
- const { includeTypes = ['ref', 'template'], path = '' } = options;
77
+ ): Generator<{ value: IFlowValue; path: string; pathArr: string[] }> {
78
+ const {
79
+ includeTypes = ['ref', 'template', 'expression', 'constant'],
80
+ path = '',
81
+ pathArr = [],
82
+ } = options || {};
78
83
 
79
84
  if (isPlainObject(value)) {
80
85
  if (isRef(value) && includeTypes.includes('ref')) {
81
- yield { value, path };
86
+ yield { value, path, pathArr };
82
87
  return;
83
88
  }
84
89
 
85
90
  if (isTemplate(value) && includeTypes.includes('template')) {
86
- yield { value, path };
91
+ yield { value, path, pathArr };
87
92
  return;
88
93
  }
89
94
 
90
95
  if (isExpression(value) && includeTypes.includes('expression')) {
91
- yield { value, path };
96
+ yield { value, path, pathArr };
92
97
  return;
93
98
  }
94
99
 
95
100
  if (isConstant(value) && includeTypes.includes('constant')) {
96
- yield { value, path };
101
+ yield { value, path, pathArr };
97
102
  return;
98
103
  }
99
104
 
100
105
  for (const [_key, _value] of Object.entries(value)) {
101
- yield* traverse(_value, { ...options, path: `${path}.${_key}` });
106
+ yield* traverse(_value, {
107
+ ...options,
108
+ path: path ? `${path}.${_key}` : _key,
109
+ pathArr: [...pathArr, _key],
110
+ });
102
111
  }
103
112
  return;
104
113
  }
105
114
 
106
115
  if (isArray(value)) {
107
116
  for (const [_idx, _value] of value.entries()) {
108
- yield* traverse(_value, { ...options, path: `${path}[${_idx}]` });
117
+ yield* traverse(_value, {
118
+ ...options,
119
+ path: path ? `${path}[${_idx}]` : `[${_idx}]`,
120
+ pathArr: [...pathArr, `[${_idx}]`],
121
+ });
109
122
  }
110
123
  return;
111
124
  }
@@ -1,165 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- defaultOpConfigs: ()=>defaultOpConfigs,
28
- defaultRules: ()=>defaultRules
29
- });
30
- const external_types_js_namespaceObject = require("./types.js");
31
- const defaultRules = {
32
- string: {
33
- [external_types_js_namespaceObject.Op.EQ]: 'string',
34
- [external_types_js_namespaceObject.Op.NEQ]: 'string',
35
- [external_types_js_namespaceObject.Op.CONTAINS]: 'string',
36
- [external_types_js_namespaceObject.Op.NOT_CONTAINS]: 'string',
37
- [external_types_js_namespaceObject.Op.IN]: 'array',
38
- [external_types_js_namespaceObject.Op.NIN]: 'array',
39
- [external_types_js_namespaceObject.Op.IS_EMPTY]: null,
40
- [external_types_js_namespaceObject.Op.IS_NOT_EMPTY]: null
41
- },
42
- number: {
43
- [external_types_js_namespaceObject.Op.EQ]: 'number',
44
- [external_types_js_namespaceObject.Op.NEQ]: 'number',
45
- [external_types_js_namespaceObject.Op.GT]: 'number',
46
- [external_types_js_namespaceObject.Op.GTE]: 'number',
47
- [external_types_js_namespaceObject.Op.LT]: 'number',
48
- [external_types_js_namespaceObject.Op.LTE]: 'number',
49
- [external_types_js_namespaceObject.Op.IN]: 'array',
50
- [external_types_js_namespaceObject.Op.NIN]: 'array'
51
- },
52
- integer: {
53
- [external_types_js_namespaceObject.Op.EQ]: 'number',
54
- [external_types_js_namespaceObject.Op.NEQ]: 'number',
55
- [external_types_js_namespaceObject.Op.GT]: 'number',
56
- [external_types_js_namespaceObject.Op.GTE]: 'number',
57
- [external_types_js_namespaceObject.Op.LT]: 'number',
58
- [external_types_js_namespaceObject.Op.LTE]: 'number',
59
- [external_types_js_namespaceObject.Op.IN]: 'array',
60
- [external_types_js_namespaceObject.Op.NIN]: 'array'
61
- },
62
- boolean: {
63
- [external_types_js_namespaceObject.Op.EQ]: 'boolean',
64
- [external_types_js_namespaceObject.Op.NEQ]: 'boolean',
65
- [external_types_js_namespaceObject.Op.IS_TRUE]: null,
66
- [external_types_js_namespaceObject.Op.IS_FALSE]: null,
67
- [external_types_js_namespaceObject.Op.IN]: 'array',
68
- [external_types_js_namespaceObject.Op.NIN]: 'array'
69
- },
70
- object: {
71
- [external_types_js_namespaceObject.Op.IS_EMPTY]: null,
72
- [external_types_js_namespaceObject.Op.IS_NOT_EMPTY]: null
73
- },
74
- array: {
75
- [external_types_js_namespaceObject.Op.IS_EMPTY]: null,
76
- [external_types_js_namespaceObject.Op.IS_NOT_EMPTY]: null,
77
- [external_types_js_namespaceObject.Op.CONTAINS]: 'array',
78
- [external_types_js_namespaceObject.Op.NOT_CONTAINS]: 'array',
79
- [external_types_js_namespaceObject.Op.EQ]: 'array',
80
- [external_types_js_namespaceObject.Op.NEQ]: 'array'
81
- },
82
- map: {
83
- [external_types_js_namespaceObject.Op.IS_EMPTY]: null,
84
- [external_types_js_namespaceObject.Op.IS_NOT_EMPTY]: null
85
- },
86
- ['date-time']: {
87
- [external_types_js_namespaceObject.Op.EQ]: 'date-time',
88
- [external_types_js_namespaceObject.Op.NEQ]: 'date-time',
89
- [external_types_js_namespaceObject.Op.GT]: 'date-time',
90
- [external_types_js_namespaceObject.Op.GTE]: 'date-time',
91
- [external_types_js_namespaceObject.Op.LT]: 'date-time',
92
- [external_types_js_namespaceObject.Op.LTE]: 'date-time'
93
- }
94
- };
95
- const defaultOpConfigs = {
96
- [external_types_js_namespaceObject.Op.EQ]: {
97
- label: 'Equal',
98
- abbreviation: '='
99
- },
100
- [external_types_js_namespaceObject.Op.NEQ]: {
101
- label: 'Not Equal',
102
- abbreviation: "\u2260"
103
- },
104
- [external_types_js_namespaceObject.Op.GT]: {
105
- label: 'Greater Than',
106
- abbreviation: '>'
107
- },
108
- [external_types_js_namespaceObject.Op.GTE]: {
109
- label: 'Greater Than or Equal',
110
- abbreviation: '>='
111
- },
112
- [external_types_js_namespaceObject.Op.LT]: {
113
- label: 'Less Than',
114
- abbreviation: '<'
115
- },
116
- [external_types_js_namespaceObject.Op.LTE]: {
117
- label: 'Less Than or Equal',
118
- abbreviation: '<='
119
- },
120
- [external_types_js_namespaceObject.Op.IN]: {
121
- label: 'In',
122
- abbreviation: "\u2208"
123
- },
124
- [external_types_js_namespaceObject.Op.NIN]: {
125
- label: 'Not In',
126
- abbreviation: "\u2209"
127
- },
128
- [external_types_js_namespaceObject.Op.CONTAINS]: {
129
- label: 'Contains',
130
- abbreviation: "\u2287"
131
- },
132
- [external_types_js_namespaceObject.Op.NOT_CONTAINS]: {
133
- label: 'Not Contains',
134
- abbreviation: "\u2289"
135
- },
136
- [external_types_js_namespaceObject.Op.IS_EMPTY]: {
137
- label: 'Is Empty',
138
- abbreviation: '=',
139
- rightDisplay: 'Empty'
140
- },
141
- [external_types_js_namespaceObject.Op.IS_NOT_EMPTY]: {
142
- label: 'Is Not Empty',
143
- abbreviation: "\u2260",
144
- rightDisplay: 'Empty'
145
- },
146
- [external_types_js_namespaceObject.Op.IS_TRUE]: {
147
- label: 'Is True',
148
- abbreviation: '=',
149
- rightDisplay: 'True'
150
- },
151
- [external_types_js_namespaceObject.Op.IS_FALSE]: {
152
- label: 'Is False',
153
- abbreviation: '=',
154
- rightDisplay: 'False'
155
- }
156
- };
157
- exports.defaultOpConfigs = __webpack_exports__.defaultOpConfigs;
158
- exports.defaultRules = __webpack_exports__.defaultRules;
159
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
160
- "defaultOpConfigs",
161
- "defaultRules"
162
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
163
- Object.defineProperty(exports, '__esModule', {
164
- value: true
165
- });
@@ -1,78 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- useOp: ()=>useOp
28
- });
29
- const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
- const external_react_namespaceObject = require("react");
31
- const editor_namespaceObject = require("@flowgram.ai/editor");
32
- const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
33
- const semi_icons_namespaceObject = require("@douyinfe/semi-icons");
34
- const external_constants_js_namespaceObject = require("../constants.js");
35
- function useOp({ rule, op, onChange, readonly, userOps }) {
36
- const options = (0, external_react_namespaceObject.useMemo)(()=>Object.keys(rule || {}).map((_op)=>({
37
- ...external_constants_js_namespaceObject.defaultOpConfigs[_op] || {},
38
- ...userOps?.[_op] || {},
39
- value: _op,
40
- label: editor_namespaceObject.I18n.t(userOps?.[_op]?.label || external_constants_js_namespaceObject.defaultOpConfigs[_op]?.label)
41
- })), [
42
- rule,
43
- userOps
44
- ]);
45
- const opConfig = (0, external_react_namespaceObject.useMemo)(()=>external_constants_js_namespaceObject.defaultOpConfigs[op], [
46
- op
47
- ]);
48
- const renderOpSelect = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Select, {
49
- style: {
50
- height: 22
51
- },
52
- disabled: readonly,
53
- size: "small",
54
- value: op,
55
- optionList: options,
56
- onChange: (v)=>{
57
- onChange(v);
58
- },
59
- triggerRender: ({ value })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Button, {
60
- size: "small",
61
- disabled: !rule,
62
- children: opConfig?.abbreviation || /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_icons_namespaceObject.IconChevronDownStroked, {
63
- size: "small"
64
- })
65
- })
66
- });
67
- return {
68
- renderOpSelect,
69
- opConfig
70
- };
71
- }
72
- exports.useOp = __webpack_exports__.useOp;
73
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
74
- "useOp"
75
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
76
- Object.defineProperty(exports, '__esModule', {
77
- value: true
78
- });
@@ -1,68 +0,0 @@
1
- "use strict";
2
- var __webpack_require__ = {};
3
- (()=>{
4
- __webpack_require__.d = (exports1, definition)=>{
5
- for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
- enumerable: true,
7
- get: definition[key]
8
- });
9
- };
10
- })();
11
- (()=>{
12
- __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
- })();
14
- (()=>{
15
- __webpack_require__.r = (exports1)=>{
16
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
- value: 'Module'
18
- });
19
- Object.defineProperty(exports1, '__esModule', {
20
- value: true
21
- });
22
- };
23
- })();
24
- var __webpack_exports__ = {};
25
- __webpack_require__.r(__webpack_exports__);
26
- __webpack_require__.d(__webpack_exports__, {
27
- useRule: ()=>useRule
28
- });
29
- const external_react_namespaceObject = require("react");
30
- const json_schema_namespaceObject = require("@flowgram.ai/json-schema");
31
- const editor_namespaceObject = require("@flowgram.ai/editor");
32
- const external_constants_js_namespaceObject = require("../constants.js");
33
- function useRule(left, userRules) {
34
- const available = (0, editor_namespaceObject.useScopeAvailable)();
35
- const rules = (0, external_react_namespaceObject.useMemo)(()=>({
36
- ...external_constants_js_namespaceObject.defaultRules,
37
- ...userRules || {}
38
- }), [
39
- userRules
40
- ]);
41
- const variable = (0, external_react_namespaceObject.useMemo)(()=>{
42
- if (!left) return;
43
- return available.getByKeyPath(left.content);
44
- }, [
45
- available,
46
- left
47
- ]);
48
- const rule = (0, external_react_namespaceObject.useMemo)(()=>{
49
- if (!variable) return;
50
- const schema = json_schema_namespaceObject.JsonSchemaUtils.astToSchema(variable.type, {
51
- drilldown: false
52
- });
53
- return rules[schema?.type];
54
- }, [
55
- variable?.type,
56
- rules
57
- ]);
58
- return {
59
- rule
60
- };
61
- }
62
- exports.useRule = __webpack_exports__.useRule;
63
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
64
- "useRule"
65
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
66
- Object.defineProperty(exports, '__esModule', {
67
- value: true
68
- });