@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
@@ -1,86 +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
- useLeft: ()=>useLeft
28
- });
29
- const jsx_runtime_namespaceObject = require("react/jsx-runtime");
30
- const external_react_namespaceObject = require("react");
31
- const json_schema_namespaceObject = require("@flowgram.ai/json-schema");
32
- const semi_ui_namespaceObject = require("@douyinfe/semi-ui");
33
- const external_index_js_namespaceObject = require("../../index.js");
34
- const external_styles_js_namespaceObject = require("../styles.js");
35
- const defaultRules = external_index_js_namespaceObject.ConditionRow.defaultRules;
36
- function useLeft({ left, options, userRules, readonly, onChange }) {
37
- const rules = (0, external_react_namespaceObject.useMemo)(()=>({
38
- ...defaultRules,
39
- ...userRules || {}
40
- }), [
41
- userRules
42
- ]);
43
- const typeManager = (0, json_schema_namespaceObject.useTypeManager)();
44
- const rule = (0, external_react_namespaceObject.useMemo)(()=>{
45
- if (!left) return;
46
- const option = options?.find((item)=>item.value === left);
47
- if (!option?.schema?.type) return;
48
- return rules[option.schema.type];
49
- }, [
50
- left,
51
- options,
52
- rules
53
- ]);
54
- const renderDBOptionSelect = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_styles_js_namespaceObject.UISelect, {
55
- disabled: readonly,
56
- size: "small",
57
- style: {
58
- width: '100%'
59
- },
60
- value: left,
61
- onChange: (v)=>onChange(v),
62
- optionList: options?.map((item)=>({
63
- label: /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsxs)(external_styles_js_namespaceObject.UIOptionLabel, {
64
- children: [
65
- /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Icon, {
66
- size: "small",
67
- svg: typeManager.getDisplayIcon(item.schema)
68
- }),
69
- item.label
70
- ]
71
- }),
72
- value: item.value
73
- })) || []
74
- });
75
- return {
76
- rule,
77
- renderDBOptionSelect
78
- };
79
- }
80
- exports.useLeft = __webpack_exports__.useLeft;
81
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
82
- "useLeft"
83
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
84
- Object.defineProperty(exports, '__esModule', {
85
- value: true
86
- });
@@ -1,79 +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_index_js_namespaceObject = require("../../index.js");
35
- const defaultOpConfigs = external_index_js_namespaceObject.ConditionRow.defaultOpConfigs;
36
- function useOp({ rule, op, onChange, readonly, userOps }) {
37
- const options = (0, external_react_namespaceObject.useMemo)(()=>Object.keys(rule || {}).map((_op)=>({
38
- ...defaultOpConfigs[_op] || {},
39
- ...userOps?.[_op] || {},
40
- value: _op,
41
- label: editor_namespaceObject.I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
42
- })), [
43
- rule,
44
- userOps
45
- ]);
46
- const opConfig = (0, external_react_namespaceObject.useMemo)(()=>defaultOpConfigs[op], [
47
- op
48
- ]);
49
- const renderOpSelect = ()=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Select, {
50
- style: {
51
- height: 22
52
- },
53
- disabled: readonly,
54
- size: "small",
55
- value: op,
56
- optionList: options,
57
- onChange: (v)=>{
58
- onChange(v);
59
- },
60
- triggerRender: ({ value })=>/*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_ui_namespaceObject.Button, {
61
- size: "small",
62
- disabled: !rule,
63
- children: opConfig?.abbreviation || /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(semi_icons_namespaceObject.IconChevronDownStroked, {
64
- size: "small"
65
- })
66
- })
67
- });
68
- return {
69
- renderOpSelect,
70
- opConfig
71
- };
72
- }
73
- exports.useOp = __webpack_exports__.useOp;
74
- for(var __webpack_i__ in __webpack_exports__)if (-1 === [
75
- "useOp"
76
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
77
- Object.defineProperty(exports, '__esModule', {
78
- value: true
79
- });
@@ -1,19 +0,0 @@
1
- import { typescript } from "@flowgram.ai/coze-editor/language-typescript";
2
- let tsWorkerInit = false;
3
- const initTsWorker = ()=>{
4
- if (tsWorkerInit) return;
5
- tsWorkerInit = true;
6
- const tsWorker = new Worker(new URL("@flowgram.ai/coze-editor/language-typescript/worker", import.meta.url), {
7
- type: 'module'
8
- });
9
- typescript.languageService.initialize(tsWorker, {
10
- compilerOptions: {
11
- lib: [
12
- 'es2015',
13
- 'dom'
14
- ],
15
- noImplicitAny: false
16
- }
17
- });
18
- };
19
- export { initTsWorker };
@@ -1,128 +0,0 @@
1
- import { Op } from "./types.mjs";
2
- const defaultRules = {
3
- string: {
4
- [Op.EQ]: 'string',
5
- [Op.NEQ]: 'string',
6
- [Op.CONTAINS]: 'string',
7
- [Op.NOT_CONTAINS]: 'string',
8
- [Op.IN]: 'array',
9
- [Op.NIN]: 'array',
10
- [Op.IS_EMPTY]: null,
11
- [Op.IS_NOT_EMPTY]: null
12
- },
13
- number: {
14
- [Op.EQ]: 'number',
15
- [Op.NEQ]: 'number',
16
- [Op.GT]: 'number',
17
- [Op.GTE]: 'number',
18
- [Op.LT]: 'number',
19
- [Op.LTE]: 'number',
20
- [Op.IN]: 'array',
21
- [Op.NIN]: 'array'
22
- },
23
- integer: {
24
- [Op.EQ]: 'number',
25
- [Op.NEQ]: 'number',
26
- [Op.GT]: 'number',
27
- [Op.GTE]: 'number',
28
- [Op.LT]: 'number',
29
- [Op.LTE]: 'number',
30
- [Op.IN]: 'array',
31
- [Op.NIN]: 'array'
32
- },
33
- boolean: {
34
- [Op.EQ]: 'boolean',
35
- [Op.NEQ]: 'boolean',
36
- [Op.IS_TRUE]: null,
37
- [Op.IS_FALSE]: null,
38
- [Op.IN]: 'array',
39
- [Op.NIN]: 'array'
40
- },
41
- object: {
42
- [Op.IS_EMPTY]: null,
43
- [Op.IS_NOT_EMPTY]: null
44
- },
45
- array: {
46
- [Op.IS_EMPTY]: null,
47
- [Op.IS_NOT_EMPTY]: null,
48
- [Op.CONTAINS]: 'array',
49
- [Op.NOT_CONTAINS]: 'array',
50
- [Op.EQ]: 'array',
51
- [Op.NEQ]: 'array'
52
- },
53
- map: {
54
- [Op.IS_EMPTY]: null,
55
- [Op.IS_NOT_EMPTY]: null
56
- },
57
- ['date-time']: {
58
- [Op.EQ]: 'date-time',
59
- [Op.NEQ]: 'date-time',
60
- [Op.GT]: 'date-time',
61
- [Op.GTE]: 'date-time',
62
- [Op.LT]: 'date-time',
63
- [Op.LTE]: 'date-time'
64
- }
65
- };
66
- const defaultOpConfigs = {
67
- [Op.EQ]: {
68
- label: 'Equal',
69
- abbreviation: '='
70
- },
71
- [Op.NEQ]: {
72
- label: 'Not Equal',
73
- abbreviation: "\u2260"
74
- },
75
- [Op.GT]: {
76
- label: 'Greater Than',
77
- abbreviation: '>'
78
- },
79
- [Op.GTE]: {
80
- label: 'Greater Than or Equal',
81
- abbreviation: '>='
82
- },
83
- [Op.LT]: {
84
- label: 'Less Than',
85
- abbreviation: '<'
86
- },
87
- [Op.LTE]: {
88
- label: 'Less Than or Equal',
89
- abbreviation: '<='
90
- },
91
- [Op.IN]: {
92
- label: 'In',
93
- abbreviation: "\u2208"
94
- },
95
- [Op.NIN]: {
96
- label: 'Not In',
97
- abbreviation: "\u2209"
98
- },
99
- [Op.CONTAINS]: {
100
- label: 'Contains',
101
- abbreviation: "\u2287"
102
- },
103
- [Op.NOT_CONTAINS]: {
104
- label: 'Not Contains',
105
- abbreviation: "\u2289"
106
- },
107
- [Op.IS_EMPTY]: {
108
- label: 'Is Empty',
109
- abbreviation: '=',
110
- rightDisplay: 'Empty'
111
- },
112
- [Op.IS_NOT_EMPTY]: {
113
- label: 'Is Not Empty',
114
- abbreviation: "\u2260",
115
- rightDisplay: 'Empty'
116
- },
117
- [Op.IS_TRUE]: {
118
- label: 'Is True',
119
- abbreviation: '=',
120
- rightDisplay: 'True'
121
- },
122
- [Op.IS_FALSE]: {
123
- label: 'Is False',
124
- abbreviation: '=',
125
- rightDisplay: 'False'
126
- }
127
- };
128
- export { defaultOpConfigs, defaultRules };
@@ -1,44 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useMemo } from "react";
3
- import { I18n } from "@flowgram.ai/editor";
4
- import { Button, Select } from "@douyinfe/semi-ui";
5
- import { IconChevronDownStroked } from "@douyinfe/semi-icons";
6
- import { defaultOpConfigs } from "../constants.mjs";
7
- function useOp({ rule, op, onChange, readonly, userOps }) {
8
- const options = useMemo(()=>Object.keys(rule || {}).map((_op)=>({
9
- ...defaultOpConfigs[_op] || {},
10
- ...userOps?.[_op] || {},
11
- value: _op,
12
- label: I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
13
- })), [
14
- rule,
15
- userOps
16
- ]);
17
- const opConfig = useMemo(()=>defaultOpConfigs[op], [
18
- op
19
- ]);
20
- const renderOpSelect = ()=>/*#__PURE__*/ jsx(Select, {
21
- style: {
22
- height: 22
23
- },
24
- disabled: readonly,
25
- size: "small",
26
- value: op,
27
- optionList: options,
28
- onChange: (v)=>{
29
- onChange(v);
30
- },
31
- triggerRender: ({ value })=>/*#__PURE__*/ jsx(Button, {
32
- size: "small",
33
- disabled: !rule,
34
- children: opConfig?.abbreviation || /*#__PURE__*/ jsx(IconChevronDownStroked, {
35
- size: "small"
36
- })
37
- })
38
- });
39
- return {
40
- renderOpSelect,
41
- opConfig
42
- };
43
- }
44
- export { useOp };
@@ -1,34 +0,0 @@
1
- import { useMemo } from "react";
2
- import { JsonSchemaUtils } from "@flowgram.ai/json-schema";
3
- import { useScopeAvailable } from "@flowgram.ai/editor";
4
- import { defaultRules } from "../constants.mjs";
5
- function useRule(left, userRules) {
6
- const available = useScopeAvailable();
7
- const rules = useMemo(()=>({
8
- ...defaultRules,
9
- ...userRules || {}
10
- }), [
11
- userRules
12
- ]);
13
- const variable = useMemo(()=>{
14
- if (!left) return;
15
- return available.getByKeyPath(left.content);
16
- }, [
17
- available,
18
- left
19
- ]);
20
- const rule = useMemo(()=>{
21
- if (!variable) return;
22
- const schema = JsonSchemaUtils.astToSchema(variable.type, {
23
- drilldown: false
24
- });
25
- return rules[schema?.type];
26
- }, [
27
- variable?.type,
28
- rules
29
- ]);
30
- return {
31
- rule
32
- };
33
- }
34
- export { useRule };
@@ -1,52 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useMemo } from "react";
3
- import { useTypeManager } from "@flowgram.ai/json-schema";
4
- import { Icon } from "@douyinfe/semi-ui";
5
- import { ConditionRow } from "../../index.mjs";
6
- import { UIOptionLabel, UISelect } from "../styles.mjs";
7
- const defaultRules = ConditionRow.defaultRules;
8
- function useLeft({ left, options, userRules, readonly, onChange }) {
9
- const rules = useMemo(()=>({
10
- ...defaultRules,
11
- ...userRules || {}
12
- }), [
13
- userRules
14
- ]);
15
- const typeManager = useTypeManager();
16
- const rule = useMemo(()=>{
17
- if (!left) return;
18
- const option = options?.find((item)=>item.value === left);
19
- if (!option?.schema?.type) return;
20
- return rules[option.schema.type];
21
- }, [
22
- left,
23
- options,
24
- rules
25
- ]);
26
- const renderDBOptionSelect = ()=>/*#__PURE__*/ jsx(UISelect, {
27
- disabled: readonly,
28
- size: "small",
29
- style: {
30
- width: '100%'
31
- },
32
- value: left,
33
- onChange: (v)=>onChange(v),
34
- optionList: options?.map((item)=>({
35
- label: /*#__PURE__*/ jsxs(UIOptionLabel, {
36
- children: [
37
- /*#__PURE__*/ jsx(Icon, {
38
- size: "small",
39
- svg: typeManager.getDisplayIcon(item.schema)
40
- }),
41
- item.label
42
- ]
43
- }),
44
- value: item.value
45
- })) || []
46
- });
47
- return {
48
- rule,
49
- renderDBOptionSelect
50
- };
51
- }
52
- export { useLeft };
@@ -1,45 +0,0 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useMemo } from "react";
3
- import { I18n } from "@flowgram.ai/editor";
4
- import { Button, Select } from "@douyinfe/semi-ui";
5
- import { IconChevronDownStroked } from "@douyinfe/semi-icons";
6
- import { ConditionRow } from "../../index.mjs";
7
- const defaultOpConfigs = ConditionRow.defaultOpConfigs;
8
- function useOp({ rule, op, onChange, readonly, userOps }) {
9
- const options = useMemo(()=>Object.keys(rule || {}).map((_op)=>({
10
- ...defaultOpConfigs[_op] || {},
11
- ...userOps?.[_op] || {},
12
- value: _op,
13
- label: I18n.t(userOps?.[_op]?.label || defaultOpConfigs[_op]?.label)
14
- })), [
15
- rule,
16
- userOps
17
- ]);
18
- const opConfig = useMemo(()=>defaultOpConfigs[op], [
19
- op
20
- ]);
21
- const renderOpSelect = ()=>/*#__PURE__*/ jsx(Select, {
22
- style: {
23
- height: 22
24
- },
25
- disabled: readonly,
26
- size: "small",
27
- value: op,
28
- optionList: options,
29
- onChange: (v)=>{
30
- onChange(v);
31
- },
32
- triggerRender: ({ value })=>/*#__PURE__*/ jsx(Button, {
33
- size: "small",
34
- disabled: !rule,
35
- children: opConfig?.abbreviation || /*#__PURE__*/ jsx(IconChevronDownStroked, {
36
- size: "small"
37
- })
38
- })
39
- });
40
- return {
41
- renderOpSelect,
42
- opConfig
43
- };
44
- }
45
- export { useOp };
@@ -1,5 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- export declare const initTsWorker: () => void;
@@ -1,7 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { IRules, OpConfigs } from './types';
6
- export declare const defaultRules: IRules;
7
- export declare const defaultOpConfigs: OpConfigs;
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import React from 'react';
6
- import { IRule, OpConfigs } from '../types';
7
- interface HookParams {
8
- rule?: IRule;
9
- op?: string;
10
- onChange: (op: string) => void;
11
- readonly?: boolean;
12
- userOps?: OpConfigs;
13
- }
14
- export declare function useOp({ rule, op, onChange, readonly, userOps }: HookParams): {
15
- renderOpSelect: () => React.JSX.Element;
16
- opConfig: import("../types").OpConfig;
17
- };
18
- export {};
@@ -1,9 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import { IFlowRefValue } from '../../../shared';
6
- import { IRules } from '../types';
7
- export declare function useRule(left?: IFlowRefValue, userRules?: IRules): {
8
- rule: Partial<Record<string, string | null>> | undefined;
9
- };
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import React from 'react';
6
- import { DBConditionOptionType, IRules } from '../types';
7
- interface HookParams {
8
- left?: string;
9
- options?: DBConditionOptionType[];
10
- userRules?: IRules;
11
- readonly?: boolean;
12
- onChange: (leftKey: string) => void;
13
- }
14
- export declare function useLeft({ left, options, userRules, readonly, onChange }: HookParams): {
15
- rule: Partial<Record<string, string | null>> | undefined;
16
- renderDBOptionSelect: () => React.JSX.Element;
17
- };
18
- export {};
@@ -1,18 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
- import React from 'react';
6
- import { IRule, OpConfigs } from '../types';
7
- interface HookParams {
8
- rule?: IRule;
9
- op?: string;
10
- onChange: (op: string) => void;
11
- readonly?: boolean;
12
- userOps?: OpConfigs;
13
- }
14
- export declare function useOp({ rule, op, onChange, readonly, userOps }: HookParams): {
15
- renderOpSelect: () => React.JSX.Element;
16
- opConfig: import("../../condition-row/types").OpConfig;
17
- };
18
- export {};
@@ -1,27 +0,0 @@
1
- /**
2
- * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
3
- * SPDX-License-Identifier: MIT
4
- */
5
-
6
- import { typescript } from '@flowgram.ai/coze-editor/language-typescript';
7
-
8
- let tsWorkerInit = false;
9
-
10
- export const initTsWorker = () => {
11
- if (tsWorkerInit) {
12
- return;
13
- }
14
- tsWorkerInit = true;
15
-
16
- const tsWorker = new Worker(
17
- new URL(`@flowgram.ai/coze-editor/language-typescript/worker`, import.meta.url),
18
- { type: 'module' }
19
- );
20
- typescript.languageService.initialize(tsWorker, {
21
- compilerOptions: {
22
- // eliminate Promise error
23
- lib: ['es2015', 'dom'],
24
- noImplicitAny: false,
25
- },
26
- });
27
- };