@gingkoo/pandora-metabase 1.0.118 → 1.0.119

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 (195) hide show
  1. package/lib/cjs/common/Portal/index.js +0 -2
  2. package/lib/cjs/common/SplitView/index.d.ts +0 -4
  3. package/lib/cjs/common/SplitView/index.js +0 -10
  4. package/lib/cjs/components/dialog/custom-column/config.js +4 -48
  5. package/lib/cjs/components/dialog/custom-column/expression-editor.js +3 -14
  6. package/lib/cjs/components/dialog/custom-column/expressions/suggest.d.ts +2 -34
  7. package/lib/cjs/components/dialog/custom-column/expressions/suggest.js +2 -43
  8. package/lib/cjs/components/dialog/custom-column/expressions/tokenizer.js +8 -65
  9. package/lib/cjs/components/dialog/custom-column/index.js +2 -4
  10. package/lib/cjs/components/dialog/custom-column/tokenized-expression.js +2 -3
  11. package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +1 -1
  12. package/lib/cjs/components/dialog/custom-editor/index.js +2 -7
  13. package/lib/cjs/components/dialog/diff-viewer/index copy.js +1 -16
  14. package/lib/cjs/components/dialog/expression/date-format-picker.js +2 -20
  15. package/lib/cjs/components/dialog/expression/date-format.js +2 -8
  16. package/lib/cjs/components/dialog/expression/index.d.ts +0 -3
  17. package/lib/cjs/components/dialog/expression/index.js +2 -83
  18. package/lib/cjs/components/dialog/formula/index.js +1 -30
  19. package/lib/cjs/components/dialog/formula/utils.js +2 -10
  20. package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.d.ts +19 -0
  21. package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.js +109 -0
  22. package/lib/cjs/components/dialog/formula-list/LogicGroup.d.ts +9 -0
  23. package/lib/cjs/components/dialog/formula-list/LogicGroup.js +43 -0
  24. package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -0
  25. package/lib/cjs/components/dialog/formula-list/index.js +967 -503
  26. package/lib/cjs/components/dialog/formula-list/index.less +724 -0
  27. package/lib/cjs/components/dialog/formula-list/utils.d.ts +0 -7
  28. package/lib/cjs/components/dialog/formula-list/utils.js +117 -113
  29. package/lib/cjs/components/dialog/select-column/index.d.ts +0 -6
  30. package/lib/cjs/components/dialog/select-column/index.js +4 -15
  31. package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +0 -8
  32. package/lib/cjs/components/dialog/select-column-multiple/index.js +6 -45
  33. package/lib/cjs/components/dialog/select-join/index.d.ts +0 -5
  34. package/lib/cjs/components/dialog/select-join/index.js +0 -6
  35. package/lib/cjs/components/dialog/select-join-column/index.d.ts +0 -8
  36. package/lib/cjs/components/dialog/select-join-column/index.js +7 -21
  37. package/lib/cjs/components/dialog/select-join-column-multiple/index.d.ts +0 -8
  38. package/lib/cjs/components/dialog/select-join-column-multiple/index.js +5 -35
  39. package/lib/cjs/components/dialog/select-permission-table/index.d.ts +0 -5
  40. package/lib/cjs/components/dialog/select-permission-table/index.js +0 -6
  41. package/lib/cjs/components/dialog/select-summarize/index.d.ts +3 -3
  42. package/lib/cjs/components/dialog/select-summarize/index.js +105 -18
  43. package/lib/cjs/components/dialog/select-summarize/index.less +23 -0
  44. package/lib/cjs/components/dialog/select-table/index.d.ts +0 -6
  45. package/lib/cjs/components/dialog/select-table/index.js +1 -9
  46. package/lib/cjs/components/metabase/index.js +72 -86
  47. package/lib/cjs/components/metabase/index.less +7 -7
  48. package/lib/cjs/components/modules/components/Wrapper.js +1 -1
  49. package/lib/cjs/components/modules/components/header.js +2 -2
  50. package/lib/cjs/components/modules/components/meta-icon.d.ts +0 -3
  51. package/lib/cjs/components/modules/components/meta-icon.js +2 -47
  52. package/lib/cjs/components/modules/custom-column.js +3 -29
  53. package/lib/cjs/components/modules/enum/filter-enum.js +9 -88
  54. package/lib/cjs/components/modules/filter.js +2 -20
  55. package/lib/cjs/components/modules/index.d.ts +4 -2
  56. package/lib/cjs/components/modules/index.js +24 -1
  57. package/lib/cjs/components/modules/join-data.js +13 -291
  58. package/lib/cjs/components/modules/row-limit.js +0 -1
  59. package/lib/cjs/components/modules/sort.js +1 -61
  60. package/lib/cjs/components/modules/summarize/group-by.d.ts +0 -5
  61. package/lib/cjs/components/modules/summarize/group-by.js +231 -76
  62. package/lib/cjs/components/modules/summarize/select-index.js +96 -46
  63. package/lib/cjs/components/modules/table-data.js +11 -64
  64. package/lib/cjs/components/popup.js +26 -32
  65. package/lib/cjs/hooks/patch.d.ts +1 -0
  66. package/lib/cjs/hooks/patch.js +104 -6
  67. package/lib/cjs/hooks/patch2.js +3 -165
  68. package/lib/cjs/hooks/use-provider.js +0 -3
  69. package/lib/cjs/hooks/use-state.js +55 -135
  70. package/lib/cjs/index.js +0 -15
  71. package/lib/cjs/locale/en.js +5 -0
  72. package/lib/cjs/locale/index.js +1 -4
  73. package/lib/cjs/locale/zh.js +5 -0
  74. package/lib/cjs/sql-formula.js +0 -1
  75. package/lib/cjs/store/enum.d.ts +6 -6
  76. package/lib/cjs/store/enum.js +0 -13
  77. package/lib/cjs/store/helper.d.ts +2 -1
  78. package/lib/cjs/store/helper.js +15 -225
  79. package/lib/cjs/store/types.d.ts +45 -67
  80. package/lib/cjs/store/types.js +3 -49
  81. package/lib/cjs/types.d.ts +1 -0
  82. package/lib/cjs/utils/cookies.js +0 -3
  83. package/lib/cjs/utils/event.js +1 -1
  84. package/lib/cjs/utils/helper-dom.d.ts +1 -0
  85. package/lib/cjs/utils/helper-dom.js +17 -10
  86. package/lib/cjs/utils/helper.js +1 -24
  87. package/lib/cjs/utils/keydown.js +4 -7
  88. package/lib/cjs/utils/platform.d.ts +0 -9
  89. package/lib/cjs/utils/platform.js +0 -10
  90. package/lib/cjs/utils/selection.js +0 -6
  91. package/lib/cjs/utils/storage.d.ts +0 -9
  92. package/lib/cjs/utils/storage.js +1 -11
  93. package/lib/cjs/utils/transformSql.d.ts +5 -0
  94. package/lib/cjs/utils/transformSql.js +42 -113
  95. package/lib/cjs/utils.d.ts +1 -6
  96. package/lib/cjs/utils.js +115 -255
  97. package/lib/es/common/Portal/index.js +0 -2
  98. package/lib/es/common/SplitView/index.d.ts +0 -4
  99. package/lib/es/common/SplitView/index.js +0 -10
  100. package/lib/es/components/dialog/custom-column/config.js +4 -48
  101. package/lib/es/components/dialog/custom-column/expression-editor.js +3 -14
  102. package/lib/es/components/dialog/custom-column/expressions/suggest.d.ts +2 -34
  103. package/lib/es/components/dialog/custom-column/expressions/suggest.js +2 -43
  104. package/lib/es/components/dialog/custom-column/expressions/tokenizer.js +8 -65
  105. package/lib/es/components/dialog/custom-column/index.js +2 -4
  106. package/lib/es/components/dialog/custom-column/tokenized-expression.js +1 -3
  107. package/lib/es/components/dialog/custom-column/tokenizedI-input.js +1 -1
  108. package/lib/es/components/dialog/custom-editor/index.js +1 -7
  109. package/lib/es/components/dialog/diff-viewer/index copy.js +1 -15
  110. package/lib/es/components/dialog/expression/date-format-picker.js +2 -20
  111. package/lib/es/components/dialog/expression/date-format.js +2 -8
  112. package/lib/es/components/dialog/expression/index.d.ts +0 -3
  113. package/lib/es/components/dialog/expression/index.js +2 -82
  114. package/lib/es/components/dialog/formula/index.js +0 -30
  115. package/lib/es/components/dialog/formula/utils.js +2 -10
  116. package/lib/es/components/dialog/formula-list/CaseWhenGroup.d.ts +19 -0
  117. package/lib/es/components/dialog/formula-list/CaseWhenGroup.js +102 -0
  118. package/lib/es/components/dialog/formula-list/LogicGroup.d.ts +9 -0
  119. package/lib/es/components/dialog/formula-list/LogicGroup.js +36 -0
  120. package/lib/es/components/dialog/formula-list/index.d.ts +3 -0
  121. package/lib/es/components/dialog/formula-list/index.js +966 -503
  122. package/lib/es/components/dialog/formula-list/index.less +724 -0
  123. package/lib/es/components/dialog/formula-list/utils.d.ts +0 -7
  124. package/lib/es/components/dialog/formula-list/utils.js +117 -113
  125. package/lib/es/components/dialog/index.js +3 -3
  126. package/lib/es/components/dialog/select-column/index.d.ts +0 -6
  127. package/lib/es/components/dialog/select-column/index.js +4 -14
  128. package/lib/es/components/dialog/select-column-multiple/index.d.ts +0 -8
  129. package/lib/es/components/dialog/select-column-multiple/index.js +7 -47
  130. package/lib/es/components/dialog/select-join/index.d.ts +0 -5
  131. package/lib/es/components/dialog/select-join/index.js +0 -5
  132. package/lib/es/components/dialog/select-join-column/index.d.ts +0 -8
  133. package/lib/es/components/dialog/select-join-column/index.js +7 -20
  134. package/lib/es/components/dialog/select-join-column-multiple/index.d.ts +0 -8
  135. package/lib/es/components/dialog/select-join-column-multiple/index.js +5 -34
  136. package/lib/es/components/dialog/select-permission-table/index.d.ts +0 -5
  137. package/lib/es/components/dialog/select-permission-table/index.js +0 -5
  138. package/lib/es/components/dialog/select-summarize/index.d.ts +3 -3
  139. package/lib/es/components/dialog/select-summarize/index.js +106 -18
  140. package/lib/es/components/dialog/select-summarize/index.less +23 -0
  141. package/lib/es/components/dialog/select-table/index.d.ts +0 -6
  142. package/lib/es/components/dialog/select-table/index.js +1 -8
  143. package/lib/es/components/metabase/index.js +72 -87
  144. package/lib/es/components/metabase/index.less +7 -7
  145. package/lib/es/components/modules/components/Wrapper.js +1 -1
  146. package/lib/es/components/modules/components/header.js +2 -2
  147. package/lib/es/components/modules/components/meta-icon.d.ts +0 -3
  148. package/lib/es/components/modules/components/meta-icon.js +2 -46
  149. package/lib/es/components/modules/custom-column.js +3 -29
  150. package/lib/es/components/modules/enum/filter-enum.js +9 -88
  151. package/lib/es/components/modules/filter.js +2 -19
  152. package/lib/es/components/modules/index.d.ts +4 -2
  153. package/lib/es/components/modules/index.js +24 -1
  154. package/lib/es/components/modules/join-data.js +13 -291
  155. package/lib/es/components/modules/row-limit.js +0 -1
  156. package/lib/es/components/modules/sort.js +1 -61
  157. package/lib/es/components/modules/summarize/group-by.d.ts +0 -5
  158. package/lib/es/components/modules/summarize/group-by.js +233 -78
  159. package/lib/es/components/modules/summarize/select-index.js +96 -46
  160. package/lib/es/components/modules/table-data.js +11 -64
  161. package/lib/es/components/popup.js +27 -33
  162. package/lib/es/hooks/patch.d.ts +1 -0
  163. package/lib/es/hooks/patch.js +103 -5
  164. package/lib/es/hooks/patch2.js +2 -164
  165. package/lib/es/hooks/use-provider.js +0 -3
  166. package/lib/es/hooks/use-state.js +55 -135
  167. package/lib/es/index.js +0 -14
  168. package/lib/es/locale/en.js +5 -0
  169. package/lib/es/locale/index.js +1 -4
  170. package/lib/es/locale/zh.js +5 -0
  171. package/lib/es/sql-formula.js +0 -1
  172. package/lib/es/store/enum.d.ts +6 -6
  173. package/lib/es/store/enum.js +0 -13
  174. package/lib/es/store/helper.d.ts +2 -1
  175. package/lib/es/store/helper.js +13 -224
  176. package/lib/es/store/types.d.ts +45 -67
  177. package/lib/es/store/types.js +3 -49
  178. package/lib/es/types.d.ts +1 -0
  179. package/lib/es/types.js +1 -18
  180. package/lib/es/utils/cookies.js +0 -3
  181. package/lib/es/utils/event.js +1 -1
  182. package/lib/es/utils/helper-dom.d.ts +1 -0
  183. package/lib/es/utils/helper-dom.js +16 -9
  184. package/lib/es/utils/helper.js +1 -24
  185. package/lib/es/utils/keydown.js +4 -7
  186. package/lib/es/utils/platform.d.ts +0 -9
  187. package/lib/es/utils/platform.js +0 -10
  188. package/lib/es/utils/selection.js +0 -6
  189. package/lib/es/utils/storage.d.ts +0 -9
  190. package/lib/es/utils/storage.js +1 -10
  191. package/lib/es/utils/transformSql.d.ts +5 -0
  192. package/lib/es/utils/transformSql.js +42 -112
  193. package/lib/es/utils.d.ts +1 -6
  194. package/lib/es/utils.js +116 -255
  195. package/package.json +1 -1
@@ -6,11 +6,12 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports["default"] = void 0;
9
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
10
10
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
11
11
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
12
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
13
13
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
14
+ var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
14
15
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
15
16
  var _jsxRuntime = require("react/jsx-runtime");
16
17
  var _react = _interopRequireWildcard(require("react"));
@@ -36,25 +37,28 @@ var _useProvider = require("../../../hooks/use-provider");
36
37
  var _itemName = _interopRequireDefault(require("../../modules/components/item-name"));
37
38
  var _diffViewer = _interopRequireDefault(require("../diff-viewer"));
38
39
  var _storage = _interopRequireDefault(require("../../../utils/storage"));
40
+ var _helperDom = require("../../../utils/helper-dom");
41
+ var _CaseWhenGroup = _interopRequireDefault(require("./CaseWhenGroup"));
42
+ var _LogicGroup = _interopRequireDefault(require("./LogicGroup"));
39
43
  var _excluded = ["notExistsToolbar", "toolbar"],
40
- _excluded2 = ["subToolbar", "notExistsColumns", "showFields", "isExit", "toolbar"]; // import './index.less';
44
+ _excluded2 = ["subToolbar", "notExistsColumns", "showFields", "isExit", "toolbar"];
41
45
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
46
+ var CASE_FIXED_OPERATORS = ['case', 'when', 'then', 'else', 'end'];
47
+ var LOGIC_FIXED_OPERATORS = ['(', ')'];
48
+ var LOGIC_REQUIRED_OPERATORS = ['(', ')'];
42
49
  var FormulaList = (0, _react.forwardRef)(function (props, ref) {
43
- var _storage$_metabaseCop, _caseList2;
44
- // 响应 storage._metabaseCopyItems 变化,保证粘贴按钮能实时显示
50
+ var _storage$_metabaseCop;
45
51
  var _useState = (0, _react.useState)((_storage["default"] === null || _storage["default"] === void 0 || (_storage$_metabaseCop = _storage["default"]._metabaseCopyItems) === null || _storage$_metabaseCop === void 0 ? void 0 : _storage$_metabaseCop.length) || 0),
46
52
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
47
53
  checkedItemsCount = _useState2[0],
48
54
  setCheckedItemsCount = _useState2[1];
49
55
  (0, _react.useEffect)(function () {
50
56
  var _storage$_metabaseCop3;
51
- // 监听 _metabaseCopyItems 变化(自定义事件)
52
57
  var handler = function handler() {
53
58
  var _storage$_metabaseCop2;
54
59
  setCheckedItemsCount((_storage["default"] === null || _storage["default"] === void 0 || (_storage$_metabaseCop2 = _storage["default"]._metabaseCopyItems) === null || _storage$_metabaseCop2 === void 0 ? void 0 : _storage$_metabaseCop2.length) || 0);
55
60
  };
56
61
  window.addEventListener('sqb-checked-items-changed', handler);
57
- // 初始化
58
62
  setCheckedItemsCount((_storage["default"] === null || _storage["default"] === void 0 || (_storage$_metabaseCop3 = _storage["default"]._metabaseCopyItems) === null || _storage$_metabaseCop3 === void 0 ? void 0 : _storage$_metabaseCop3.length) || 0);
59
63
  return function () {
60
64
  window.removeEventListener('sqb-checked-items-changed', handler);
@@ -76,7 +80,96 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
76
80
  showPreview = _props$showPreview === void 0 ? true : _props$showPreview,
77
81
  check = props.check,
78
82
  _props$_type = props._type,
79
- _type = _props$_type === void 0 ? 'filter' : _props$_type;
83
+ _type = _props$_type === void 0 ? 'filter' : _props$_type,
84
+ _props$embedded = props.embedded,
85
+ embedded = _props$embedded === void 0 ? false : _props$embedded,
86
+ _props$enableCopy = props.enableCopy,
87
+ enableCopy = _props$enableCopy === void 0 ? true : _props$enableCopy,
88
+ parentPopupChannel = props.parentPopupChannel;
89
+ var parentPopupLockCountRef = (0, _react.useRef)(0);
90
+ var parentPopupUnlockTimerRef = (0, _react.useRef)(null);
91
+ var setParentClosable = function setParentClosable(closable) {
92
+ if (!parentPopupChannel) return;
93
+ if (parentPopupChannel === 'secondary') {
94
+ store.setClosable2(closable);
95
+ return;
96
+ }
97
+ store.setClosable(closable);
98
+ };
99
+ var lockParentPopup = function lockParentPopup() {
100
+ if (!parentPopupChannel) return;
101
+ if (parentPopupUnlockTimerRef.current) {
102
+ window.clearTimeout(parentPopupUnlockTimerRef.current);
103
+ parentPopupUnlockTimerRef.current = null;
104
+ }
105
+ parentPopupLockCountRef.current += 1;
106
+ if (parentPopupLockCountRef.current === 1) {
107
+ setParentClosable(false);
108
+ }
109
+ };
110
+ var unlockParentPopup = function unlockParentPopup() {
111
+ var delay = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
112
+ if (!parentPopupChannel) return;
113
+ var runUnlock = function runUnlock() {
114
+ parentPopupUnlockTimerRef.current = null;
115
+ parentPopupLockCountRef.current = Math.max(0, parentPopupLockCountRef.current - 1);
116
+ if (parentPopupLockCountRef.current === 0) {
117
+ setParentClosable(true);
118
+ }
119
+ };
120
+ if (delay > 0) {
121
+ if (parentPopupUnlockTimerRef.current) {
122
+ window.clearTimeout(parentPopupUnlockTimerRef.current);
123
+ }
124
+ parentPopupUnlockTimerRef.current = window.setTimeout(runUnlock, delay);
125
+ return;
126
+ }
127
+ runUnlock();
128
+ };
129
+ var openChildModal = function openChildModal(options) {
130
+ var _options$zIndex, _modalInstance;
131
+ var lockDelay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 120;
132
+ if (parentPopupChannel) {
133
+ lockParentPopup();
134
+ }
135
+ var modalZIndex = (_options$zIndex = options.zIndex) !== null && _options$zIndex !== void 0 ? _options$zIndex : (0, _helperDom.getTopLayerZIndex)() + 1;
136
+ var closed = false;
137
+ var modalInstance;
138
+ var releaseParentPopup = function releaseParentPopup() {
139
+ if (!parentPopupChannel || closed) return;
140
+ closed = true;
141
+ unlockParentPopup(lockDelay);
142
+ };
143
+ modalInstance = _pandora.Modal2.openModal((0, _objectSpread2["default"])((0, _objectSpread2["default"])({
144
+ zIndex: modalZIndex
145
+ }, options), {}, {
146
+ onClose: function onClose() {
147
+ var _options$onClose;
148
+ releaseParentPopup();
149
+ (_options$onClose = options.onClose) === null || _options$onClose === void 0 || _options$onClose.call(options);
150
+ }
151
+ }));
152
+ var originalClose = (_modalInstance = modalInstance) === null || _modalInstance === void 0 || (_modalInstance = _modalInstance.close) === null || _modalInstance === void 0 ? void 0 : _modalInstance.bind(modalInstance);
153
+ if (originalClose) {
154
+ modalInstance.close = function () {
155
+ releaseParentPopup();
156
+ return originalClose.apply(void 0, arguments);
157
+ };
158
+ }
159
+ return modalInstance;
160
+ };
161
+ (0, _react.useEffect)(function () {
162
+ return function () {
163
+ if (parentPopupUnlockTimerRef.current) {
164
+ window.clearTimeout(parentPopupUnlockTimerRef.current);
165
+ parentPopupUnlockTimerRef.current = null;
166
+ }
167
+ if (parentPopupLockCountRef.current > 0) {
168
+ parentPopupLockCountRef.current = 0;
169
+ setParentClosable(true);
170
+ }
171
+ };
172
+ }, [parentPopupChannel]);
80
173
  var mergedTypes = (0, _react.useMemo)(function () {
81
174
  var map = new Map();
82
175
  [].concat((0, _toConsumableArray2["default"])(_customTypes), (0, _toConsumableArray2["default"])(otherTypes)).forEach(function (item) {
@@ -98,14 +191,12 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
98
191
  return map;
99
192
  }, [otherTypes]);
100
193
  var caseList = value || [];
101
- // const [caseList, setCaseListState] = useState<AtomsItem[]>(cloneDeep(value));
102
194
  var caseListRef = (0, _react.useRef)(caseList);
103
195
  var operatorList = (0, _react.useMemo)(function () {
104
196
  if (store.operatorList.length > 0) {
105
197
  return store.operatorList;
106
- } else {
107
- return _utils3.operatorList;
108
198
  }
199
+ return _utils3.operatorList;
109
200
  }, [store.operatorList]);
110
201
  var _useState3 = (0, _react.useState)(''),
111
202
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
@@ -116,6 +207,9 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
116
207
  previewMode = _useState6[0],
117
208
  setPreviewMode = _useState6[1];
118
209
  var _useState7 = (0, _react.useState)(function () {
210
+ if (!enableCopy) {
211
+ return false;
212
+ }
119
213
  if (store.copyType.includes(_types.FormulaTypeEnum.ALL)) {
120
214
  return true;
121
215
  }
@@ -124,33 +218,221 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
124
218
  _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
125
219
  isCopy = _useState8[0],
126
220
  setIsCopy = _useState8[1];
127
- // const [formulaList, setFunctionList] = useState<{ [params: string]: FormulaTemplatesItem }>(
128
- // );
129
221
  var formulaList = (0, _react.useMemo)(function () {
130
222
  return (0, _utils.getObjTem)(store.formulaTemplates);
131
223
  }, [store.formulaTemplates]);
132
- (0, _react.useEffect)(function () {
133
- setOldCode(getPreviewStr(caseList));
134
- }, []);
135
224
  var _useState9 = (0, _react.useState)(''),
136
225
  _useState0 = (0, _slicedToArray2["default"])(_useState9, 2),
137
226
  filterVal = _useState0[0],
138
227
  setFilterVal = _useState0[1];
139
228
  var setCaseList = function setCaseList(data) {
140
- var quotes = data.map(function (v, i) {
141
- if (v !== null && v !== void 0 && v.quotes) {
142
- return v === null || v === void 0 ? void 0 : v.quotes;
143
- } else if (v !== null && v !== void 0 && v.fieldName) {
144
- return v === null || v === void 0 ? void 0 : v.fieldName;
145
- } else {
146
- return v.val;
147
- }
229
+ var quotes = data.map(function (v) {
230
+ if (v !== null && v !== void 0 && v.quotes) return v.quotes;
231
+ if (v !== null && v !== void 0 && v.fieldName) return v.fieldName;
232
+ return v === null || v === void 0 ? void 0 : v.val;
148
233
  }).join(' ');
149
- // setCaseListState(data);
150
234
  caseList = data;
151
235
  caseListRef.current = data;
152
236
  onChange === null || onChange === void 0 || onChange(data, quotes);
153
237
  };
238
+ var updateAtomAt = function updateAtomAt(index, nextItem) {
239
+ var nextList = caseList.slice();
240
+ nextList[index] = nextItem;
241
+ setCaseList(nextList);
242
+ };
243
+ function getItemDisplayText(v) {
244
+ if (!v) return '';
245
+ if (v.quotes) return v.quotes;
246
+ if (v.fieldName) return v.fieldName;
247
+ if (v.type === _types.AtomsTypeEnum.FORMULA) {
248
+ return v.name ? (0, _utils.getQuotes)(v, v.args, formulaList) : '';
249
+ }
250
+ if (v.type === _types.AtomsTypeEnum.CASE_WHEN) {
251
+ var caseValueText = (v.caseValue || []).map(function (item) {
252
+ return getItemDisplayText(item);
253
+ }).join(' ');
254
+ var branchText = (v.branches || []).map(function (branch) {
255
+ var whenText = (branch.when || []).map(function (item) {
256
+ return getItemDisplayText(item);
257
+ }).join(' ');
258
+ var thenText = (branch.then || []).map(function (item) {
259
+ return getItemDisplayText(item);
260
+ }).join(' ');
261
+ return "when ".concat(whenText, " then ").concat(thenText).trim();
262
+ }).join(' ');
263
+ var elseText = (v.elseValue || []).length ? " else ".concat((v.elseValue || []).map(function (item) {
264
+ return getItemDisplayText(item);
265
+ }).join(' ')) : '';
266
+ return "case ".concat(caseValueText, " ").concat(branchText).concat(elseText, " end").replace(/\s+/g, ' ').trim();
267
+ }
268
+ if (v.type === _types.AtomsTypeEnum.AND_OR) {
269
+ var listText = (v.list || []).map(function (item) {
270
+ return getItemDisplayText(item);
271
+ }).join(' ');
272
+ return "".concat(v.operator || 'and', " ( ").concat(listText, " )").replace(/\s+/g, ' ').trim();
273
+ }
274
+ if (Array.isArray(v.val)) {
275
+ return v.val.join(', ');
276
+ }
277
+ return v.val || '';
278
+ }
279
+ var getPreviewStr = function getPreviewStr() {
280
+ var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
281
+ return data.map(function (v) {
282
+ if (v.type === _types.AtomsTypeEnum.OPERATOR && (v.val === 'and' || v.val === 'or')) {
283
+ return "\r".concat(v.val, "\r");
284
+ }
285
+ if (v.type === _types.AtomsTypeEnum.OPERATOR && (v.val === '(' || v.val === ')')) {
286
+ return "".concat(v.val);
287
+ }
288
+ return getItemDisplayText(v);
289
+ }).join(' ');
290
+ };
291
+ (0, _react.useEffect)(function () {
292
+ setOldCode(getPreviewStr(caseList));
293
+ }, []);
294
+ var renderTokenContent = function renderTokenContent(children) {
295
+ return (0, _jsxRuntime.jsx)("span", {
296
+ className: 'Sqb-TokenContent',
297
+ children: children
298
+ });
299
+ };
300
+ var renderNestedFormulaList = function renderNestedFormulaList(list, onNestedChange) {
301
+ return (0, _jsxRuntime.jsx)("div", {
302
+ className: 'Sqb-NestedFormulaList',
303
+ children: (0, _jsxRuntime.jsx)(FormulaList, {
304
+ ref: ref,
305
+ embedded: true,
306
+ value: list,
307
+ data: data,
308
+ exitData: exitData,
309
+ onChange: function onChange(atoms) {
310
+ return onNestedChange(atoms);
311
+ },
312
+ customTypes: _customTypes,
313
+ otherTypes: otherTypes,
314
+ isCustom: isCustom,
315
+ showPreview: false,
316
+ check: check,
317
+ _type: _type,
318
+ parentPopupChannel: parentPopupChannel
319
+ })
320
+ });
321
+ };
322
+ var renderCaseWhenEditor = function renderCaseWhenEditor(value, index) {
323
+ return (0, _jsxRuntime.jsx)(_CaseWhenGroup["default"], {
324
+ caseValueContent: renderNestedFormulaList(value.caseValue || [], function (nextList) {
325
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
326
+ caseValue: nextList
327
+ }));
328
+ }),
329
+ branches: (value.branches || []).map(function (branch, branchIndex) {
330
+ return {
331
+ key: "case-".concat(index, "-branch-").concat(branchIndex),
332
+ whenContent: renderNestedFormulaList(branch.when || [], function (nextList) {
333
+ var nextBranches = (value.branches || []).slice();
334
+ nextBranches[branchIndex] = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, branch), {}, {
335
+ when: nextList
336
+ });
337
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
338
+ branches: nextBranches
339
+ }));
340
+ }),
341
+ thenContent: renderNestedFormulaList(branch.then || [], function (nextList) {
342
+ var nextBranches = (value.branches || []).slice();
343
+ nextBranches[branchIndex] = (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, branch), {}, {
344
+ then: nextList
345
+ });
346
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
347
+ branches: nextBranches
348
+ }));
349
+ }),
350
+ onAddAfter: function onAddAfter(e) {
351
+ e.stopPropagation();
352
+ var nextBranches = (value.branches || []).slice();
353
+ nextBranches.splice(branchIndex + 1, 0, {
354
+ when: [{
355
+ val: '',
356
+ type: _types.AtomsTypeEnum.UNKNOWN
357
+ }],
358
+ then: [{
359
+ val: '',
360
+ type: _types.AtomsTypeEnum.UNKNOWN
361
+ }]
362
+ });
363
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
364
+ branches: nextBranches
365
+ }));
366
+ },
367
+ onDelete: function onDelete(e) {
368
+ e.stopPropagation();
369
+ var nextBranches = (value.branches || []).filter(function (_, currentIndex) {
370
+ return currentIndex !== branchIndex;
371
+ });
372
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
373
+ branches: nextBranches
374
+ }));
375
+ }
376
+ };
377
+ }),
378
+ elseContent: value.elseValue ? renderNestedFormulaList(value.elseValue || [], function (nextList) {
379
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
380
+ elseValue: nextList
381
+ }));
382
+ }) : undefined,
383
+ onAddBranch: function onAddBranch(e) {
384
+ e.stopPropagation();
385
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
386
+ branches: [].concat((0, _toConsumableArray2["default"])(value.branches || []), [{
387
+ when: [{
388
+ val: '',
389
+ type: _types.AtomsTypeEnum.UNKNOWN
390
+ }],
391
+ then: [{
392
+ val: '',
393
+ type: _types.AtomsTypeEnum.UNKNOWN
394
+ }]
395
+ }])
396
+ }));
397
+ },
398
+ onAddElse: function onAddElse(e) {
399
+ e.stopPropagation();
400
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
401
+ elseValue: [{
402
+ val: '',
403
+ type: _types.AtomsTypeEnum.UNKNOWN
404
+ }]
405
+ }));
406
+ },
407
+ onRemoveElse: function onRemoveElse(e) {
408
+ e.stopPropagation();
409
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
410
+ elseValue: undefined
411
+ }));
412
+ },
413
+ onDeleteCase: function onDeleteCase(e) {
414
+ return handleDel(e, index);
415
+ }
416
+ });
417
+ };
418
+ var renderAndOrEditor = function renderAndOrEditor(value, index) {
419
+ return (0, _jsxRuntime.jsx)(_LogicGroup["default"], {
420
+ operator: value.operator || 'and',
421
+ onToggleOperator: function onToggleOperator() {
422
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
423
+ operator: value.operator === 'or' ? 'and' : 'or'
424
+ }));
425
+ },
426
+ content: renderNestedFormulaList(value.list || [], function (nextList) {
427
+ updateAtomAt(index, (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, value), {}, {
428
+ list: nextList
429
+ }));
430
+ }),
431
+ onDelete: function onDelete(e) {
432
+ return handleDel(e, index);
433
+ }
434
+ });
435
+ };
154
436
  var _useState1 = (0, _react.useState)(-1),
155
437
  _useState10 = (0, _slicedToArray2["default"])(_useState1, 2),
156
438
  ind = _useState10[0],
@@ -168,51 +450,194 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
168
450
  isCheck = _useState14[0],
169
451
  setIsCheck = _useState14[1];
170
452
  var myInstanceIdRef = (0, _react.useRef)(Math.random().toString(36).slice(2));
171
- var _useState15 = (0, _react.useState)(!!window.__sqb_selection_active__),
453
+ var _useState15 = (0, _react.useState)(null),
172
454
  _useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
173
- globalSelectionActive = _useState16[0],
174
- setGlobalSelectionActive = _useState16[1];
175
- var _useState17 = (0, _react.useState)(window.__sqb_selection_owner__ || null),
455
+ hoveredCaseGroupKey = _useState16[0],
456
+ setHoveredCaseGroupKey = _useState16[1];
457
+ var _useState17 = (0, _react.useState)(!!window.__sqb_selection_active__),
176
458
  _useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
177
- globalSelectionOwner = _useState18[0],
178
- setGlobalSelectionOwner = _useState18[1];
179
- var _useState19 = (0, _react.useState)([]),
459
+ globalSelectionActive = _useState18[0],
460
+ setGlobalSelectionActive = _useState18[1];
461
+ var _useState19 = (0, _react.useState)(window.__sqb_selection_owner__ || null),
180
462
  _useState20 = (0, _slicedToArray2["default"])(_useState19, 2),
181
- selectedIndices = _useState20[0],
182
- setSelectedIndices = _useState20[1];
183
- var _useState21 = (0, _react.useState)(null),
463
+ globalSelectionOwner = _useState20[0],
464
+ setGlobalSelectionOwner = _useState20[1];
465
+ var _useState21 = (0, _react.useState)([]),
184
466
  _useState22 = (0, _slicedToArray2["default"])(_useState21, 2),
185
- hoveredCopyIndex = _useState22[0],
186
- setHoveredCopyIndex = _useState22[1];
187
- (0, _react.useEffect)(function () {
188
- var _errorInfo = (0, _utils3.validateExpressionIntegrity)(caseList);
189
- setErrorInfo(_errorInfo);
467
+ selectedIndices = _useState22[0],
468
+ setSelectedIndices = _useState22[1];
469
+ var _useState23 = (0, _react.useState)(null),
470
+ _useState24 = (0, _slicedToArray2["default"])(_useState23, 2),
471
+ hoveredCopyIndex = _useState24[0],
472
+ setHoveredCopyIndex = _useState24[1];
473
+ var getCaseGroupEnd = function getCaseGroupEnd(list, startIndex) {
474
+ var depth = 0;
475
+ for (var index = startIndex; index < list.length; index++) {
476
+ var item = list[index];
477
+ if (item.type !== _types.AtomsTypeEnum.OPERATOR) continue;
478
+ if (item.val === 'case') depth += 1;
479
+ if (item.val === 'end') {
480
+ depth -= 1;
481
+ if (depth === 0) {
482
+ return index;
483
+ }
484
+ }
485
+ }
486
+ return startIndex;
487
+ };
488
+ var getLogicGroupIndices = function getLogicGroupIndices(list, startIndex) {
489
+ var _list, _list2;
490
+ var prevItem = list[startIndex - 1];
491
+ var currentItem = list[startIndex];
492
+ if (!currentItem) return [];
493
+ if (currentItem.type === _types.AtomsTypeEnum.OPERATOR && ['and', 'or'].includes(currentItem.val) && ((_list = list[startIndex + 1]) === null || _list === void 0 ? void 0 : _list.type) === _types.AtomsTypeEnum.OPERATOR && ((_list2 = list[startIndex + 1]) === null || _list2 === void 0 ? void 0 : _list2.val) === '(') {
494
+ var depth = 0;
495
+ var _indices = [];
496
+ for (var index = startIndex; index < list.length; index++) {
497
+ var item = list[index];
498
+ _indices.push(index);
499
+ if ((item === null || item === void 0 ? void 0 : item.type) !== _types.AtomsTypeEnum.OPERATOR) continue;
500
+ if (item.val === '(') depth += 1;
501
+ if (item.val === ')') {
502
+ depth -= 1;
503
+ if (depth === 0) {
504
+ return _indices;
505
+ }
506
+ }
507
+ }
508
+ return _indices;
509
+ }
510
+ if (currentItem.type === _types.AtomsTypeEnum.OPERATOR) return [];
511
+ if ((prevItem === null || prevItem === void 0 ? void 0 : prevItem.type) === _types.AtomsTypeEnum.OPERATOR && ['and', 'or'].includes((prevItem === null || prevItem === void 0 ? void 0 : prevItem.val) || '')) {
512
+ return [];
513
+ }
514
+ var indices = [startIndex];
515
+ var cursor = startIndex;
516
+ while (cursor + 2 < list.length) {
517
+ var operatorItem = list[cursor + 1];
518
+ var nextItem = list[cursor + 2];
519
+ if ((operatorItem === null || operatorItem === void 0 ? void 0 : operatorItem.type) !== _types.AtomsTypeEnum.OPERATOR || !['and', 'or'].includes((operatorItem === null || operatorItem === void 0 ? void 0 : operatorItem.val) || '') || !nextItem || nextItem.type === _types.AtomsTypeEnum.OPERATOR) {
520
+ break;
521
+ }
522
+ indices.push(cursor + 1, cursor + 2);
523
+ cursor += 2;
524
+ }
525
+ return indices.length >= 3 ? indices : [];
526
+ };
527
+ var renderGroups = (0, _react.useMemo)(function () {
528
+ var groups = [];
529
+ var index = 0;
530
+ while (index < caseList.length) {
531
+ var item = caseList[index];
532
+ if ((item === null || item === void 0 ? void 0 : item.type) === _types.AtomsTypeEnum.OPERATOR && (item === null || item === void 0 ? void 0 : item.val) === 'case') {
533
+ var endIndex = getCaseGroupEnd(caseList, index);
534
+ groups.push({
535
+ type: 'caseWhen',
536
+ indices: Array.from({
537
+ length: endIndex - index + 1
538
+ }, function (_, offset) {
539
+ return index + offset;
540
+ })
541
+ });
542
+ index = endIndex + 1;
543
+ continue;
544
+ }
545
+ var logicIndices = getLogicGroupIndices(caseList, index);
546
+ if (logicIndices.length > 0) {
547
+ groups.push({
548
+ type: 'logic',
549
+ indices: logicIndices
550
+ });
551
+ index = logicIndices[logicIndices.length - 1] + 1;
552
+ continue;
553
+ }
554
+ groups.push({
555
+ type: 'single',
556
+ indices: [index]
557
+ });
558
+ index += 1;
559
+ }
560
+ return groups;
190
561
  }, [caseList]);
191
- // 获取预览字符串
192
- var getPreviewStr = function getPreviewStr() {
193
- var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
194
- return data.map(function (v, i) {
195
- if (v !== null && v !== void 0 && v.quotes) {
196
- return v === null || v === void 0 ? void 0 : v.quotes;
197
- } else if (v !== null && v !== void 0 && v.fieldName) {
198
- return v === null || v === void 0 ? void 0 : v.fieldName;
199
- } else {
200
- if (v.type === _types.AtomsTypeEnum.OPERATOR && (v.val === 'and' || v.val === 'or')) {
201
- return "\r".concat(v.val, "\r");
562
+ var getCaseGroupRows = function getCaseGroupRows(indices) {
563
+ var rows = [];
564
+ var currentRow = [];
565
+ var depth = 0;
566
+ indices.forEach(function (itemIndex) {
567
+ var item = caseList[itemIndex];
568
+ if ((item === null || item === void 0 ? void 0 : item.type) === _types.AtomsTypeEnum.OPERATOR) {
569
+ if (item.val === 'case') {
570
+ if (depth === 0) {
571
+ if (currentRow.length > 0) rows.push(currentRow);
572
+ currentRow = [itemIndex];
573
+ depth = 1;
574
+ return;
575
+ }
576
+ depth += 1;
202
577
  }
203
- if (v.type === _types.AtomsTypeEnum.OPERATOR && (v.val === '(' || v.val === ')')) {
204
- return "".concat(v.val);
578
+ if (depth === 1 && (item.val === 'when' || item.val === 'else')) {
579
+ if (currentRow.length > 0) rows.push(currentRow);
580
+ currentRow = [itemIndex];
581
+ return;
582
+ }
583
+ if (item.val === 'end') {
584
+ depth -= 1;
585
+ if (depth === 0) {
586
+ if (currentRow.length > 0) rows.push(currentRow);
587
+ rows.push([itemIndex]);
588
+ currentRow = [];
589
+ return;
590
+ }
205
591
  }
206
- return v.val;
207
592
  }
208
- }).join(' ');
593
+ currentRow.push(itemIndex);
594
+ });
595
+ if (currentRow.length > 0) {
596
+ rows.push(currentRow);
597
+ }
598
+ return rows;
209
599
  };
600
+ var isFixedCaseOperator = function isFixedCaseOperator(item) {
601
+ return item.type === _types.AtomsTypeEnum.OPERATOR && CASE_FIXED_OPERATORS.includes(item.val || '');
602
+ };
603
+ var isFixedLogicOperator = function isFixedLogicOperator(item) {
604
+ return item.type === _types.AtomsTypeEnum.OPERATOR && LOGIC_FIXED_OPERATORS.includes(item.val || '');
605
+ };
606
+ var isRequiredLogicOperator = function isRequiredLogicOperator(item) {
607
+ return item.type === _types.AtomsTypeEnum.OPERATOR && LOGIC_REQUIRED_OPERATORS.includes(item.val || '');
608
+ };
609
+ var canDeleteItem = function canDeleteItem(item, groupType) {
610
+ if (groupType === 'logic') {
611
+ return !isRequiredLogicOperator(item);
612
+ }
613
+ return !isFixedCaseOperator(item);
614
+ };
615
+ var canShowInsertArrows = function canShowInsertArrows(item, groupType) {
616
+ if (groupType === 'caseWhen') {
617
+ return !isFixedCaseOperator(item);
618
+ }
619
+ if (groupType === 'logic') {
620
+ return !isRequiredLogicOperator(item);
621
+ }
622
+ return !(item.type === _types.AtomsTypeEnum.OPERATOR && ['case', 'end'].includes(item.val));
623
+ };
624
+ (0, _react.useEffect)(function () {
625
+ var _errorInfo = (0, _utils3.validateExpressionIntegrity)(caseList);
626
+ setErrorInfo(_errorInfo);
627
+ }, [caseList]);
210
628
  function closePopup() {
211
629
  store.setPopup({
212
630
  visible: false
213
631
  });
214
632
  }
215
- // 连接符
633
+ var getSelectTriggerProps = function getSelectTriggerProps() {
634
+ return {
635
+ clickToClose: true,
636
+ style: {
637
+ zIndex: (0, _helperDom.getTopLayerZIndex)() + 1
638
+ }
639
+ };
640
+ };
216
641
  var selectOperator = function selectOperator(props) {
217
642
  var triggerElement = props.triggerElement,
218
643
  ind = props.ind,
@@ -228,9 +653,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
228
653
  },
229
654
  showSearch: true,
230
655
  trigger: trigger,
231
- triggerProps: {
232
- clickToClose: true
233
- },
656
+ triggerProps: getSelectTriggerProps(),
234
657
  virtualListProps: {
235
658
  threshold: null
236
659
  },
@@ -247,6 +670,9 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
247
670
  onVisibleChange: function onVisibleChange(visible) {
248
671
  if (visible) {
249
672
  setFilterVal('');
673
+ lockParentPopup();
674
+ } else {
675
+ unlockParentPopup(300);
250
676
  }
251
677
  },
252
678
  value: '',
@@ -260,7 +686,6 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
260
686
  },
261
687
  value: filterVal,
262
688
  placeholder: (0, _locale.__)('SqlQueryBuilder.pleaseEnter'),
263
- // size='large'
264
689
  onChange: function onChange(val) {
265
690
  setFilterVal(val);
266
691
  }
@@ -278,7 +703,6 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
278
703
  })]
279
704
  });
280
705
  };
281
- // 字段
282
706
  function handleField(e, i, val) {
283
707
  store.setPopup({
284
708
  visible: true,
@@ -289,7 +713,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
289
713
  multiple: false,
290
714
  value: [val],
291
715
  theme: _enum.ColumnsPopupThemeEnum.skyBlue,
292
- onSelect: function onSelect(fields, quotes) {
716
+ onSelect: function onSelect(fields) {
293
717
  var _caseList = caseList.slice();
294
718
  _caseList[i] = fields[0];
295
719
  setCaseList(_caseList);
@@ -298,7 +722,6 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
298
722
  })
299
723
  });
300
724
  }
301
- // 常量
302
725
  var handleConstant = function handleConstant(val, i) {
303
726
  var _caseList = caseList.slice();
304
727
  var currentItem = _caseList[i];
@@ -318,7 +741,6 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
318
741
  _caseList = (0, _utils3.insertTemplateAt)(oldVal, val, _caseList, i);
319
742
  setCaseList(_caseList);
320
743
  };
321
- // 表达式
322
744
  function handleExpression(e, i, val) {
323
745
  store.setPopup({
324
746
  visible: true,
@@ -339,7 +761,6 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
339
761
  })
340
762
  });
341
763
  }
342
- // 删除
343
764
  function handleDel(e, index) {
344
765
  e.stopPropagation();
345
766
  var _caseList = caseList.slice();
@@ -347,13 +768,21 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
347
768
  setCaseList(_caseList);
348
769
  closePopup();
349
770
  }
350
- // 重置粘贴状态
771
+ function handleDelItems(e, indices) {
772
+ e.stopPropagation();
773
+ if (!indices.length) return;
774
+ var indexSet = new Set(indices);
775
+ var _caseList = caseList.filter(function (_, itemIndex) {
776
+ return !indexSet.has(itemIndex);
777
+ });
778
+ setCaseList(_caseList);
779
+ closePopup();
780
+ }
351
781
  function initPaste() {
352
782
  var isDispatch = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
353
783
  setSelectedIndices([]);
354
784
  setLocalItem([]);
355
785
  setIsCheck(false);
356
- //有些事不需要通知别的过滤器重置勾选状态
357
786
  if (isDispatch) {
358
787
  window.dispatchEvent(new CustomEvent('sqb-check-active', {
359
788
  detail: {
@@ -362,11 +791,9 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
362
791
  }));
363
792
  }
364
793
  }
365
- // 粘贴到末尾并清除勾选
366
794
  function handlePaste() {
367
795
  var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
368
796
  var _caseList = caseList.slice();
369
- // determine items to paste (selected items have priority)
370
797
  var itemsToPaste = _storage["default"]._metabaseCopyItems || [];
371
798
  itemsToPaste = (0, _utils2.changeCopyField)(itemsToPaste, data);
372
799
  if (itemsToPaste.length) {
@@ -379,13 +806,10 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
379
806
  }
380
807
  initPaste();
381
808
  }
382
- // 将值存在 localStorage
383
809
  function setLocalItem(next) {
384
810
  var _caseList = caseList.slice();
385
- // determine items to paste (selected items have priority)
386
811
  var itemsToPaste = [];
387
812
  if (next.length > 0) {
388
- // paste all selected items
389
813
  itemsToPaste = next.map(function (i) {
390
814
  return _caseList[i] ? (0, _cloneDeep["default"])(_caseList[i]) : null;
391
815
  }).filter(Boolean);
@@ -407,11 +831,33 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
407
831
  });
408
832
  setSelectedIndices(next);
409
833
  setLocalItem(next);
410
- // const active = next.length > 0;
411
834
  }
835
+ function toggleSelectGroup(indices, checked) {
836
+ var next = selectedIndices.slice();
837
+ if (checked) {
838
+ indices.forEach(function (index) {
839
+ if (!next.includes(index)) next.push(index);
840
+ });
841
+ } else {
842
+ var indexSet = new Set(indices);
843
+ next = next.filter(function (index) {
844
+ return !indexSet.has(index);
845
+ });
846
+ }
847
+ next = next.sort(function (a, b) {
848
+ return a - b;
849
+ });
850
+ setSelectedIndices(next);
851
+ setLocalItem(next);
852
+ }
853
+ var isGroupSelected = function isGroupSelected(indices) {
854
+ return indices.length > 0 && indices.every(function (index) {
855
+ return selectedIndices.includes(index);
856
+ });
857
+ };
412
858
  var copyAll = function copyAll() {
413
859
  _setIsCheck(true);
414
- var allIndices = caseList.map(function (v, i) {
860
+ var allIndices = caseList.map(function (_, i) {
415
861
  return i;
416
862
  });
417
863
  setSelectedIndices(allIndices);
@@ -420,11 +866,9 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
420
866
  var delSelect = function delSelect() {
421
867
  _pandora.Modal.confirm({
422
868
  title: (0, _locale.__)('metabase.prompt'),
423
- // 提示
424
869
  content: (0, _locale.__)('customColumn.confirmDelete'),
425
- // 确认删除吗
426
870
  onOk: function () {
427
- var _onOk = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee() {
871
+ var _onOk = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
428
872
  var selectedIndexSet, _caseList;
429
873
  return _regenerator["default"].wrap(function (_context) {
430
874
  while (1) switch (_context.prev = _context.next) {
@@ -449,7 +893,6 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
449
893
  onCancel: function onCancel() {}
450
894
  });
451
895
  };
452
- // 开启关闭勾选,清除别的过滤器勾选
453
896
  var _setIsCheck = function _setIsCheck(val) {
454
897
  initPaste();
455
898
  setIsCheck(val);
@@ -467,7 +910,6 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
467
910
  window.removeEventListener('sqb-check-active', onCheckActive);
468
911
  };
469
912
  }, []);
470
- // 添加
471
913
  var addOperator = function addOperator(type, index, position) {
472
914
  var _caseList = caseList.slice() || [];
473
915
  var _ind = index;
@@ -487,14 +929,59 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
487
929
  _caseList.splice(index + 1, 0, temItem);
488
930
  _ind = index + 1;
489
931
  } else {
490
- //替换
491
932
  _caseList.splice(index, 1, temItem);
492
933
  _ind = index;
493
934
  }
494
935
  setCaseList(_caseList);
495
936
  return _ind < 0 ? 0 : _ind;
496
937
  };
497
- // NotExists 窗口
938
+ var getItemNameProps = function getItemNameProps(v) {
939
+ if (v.type === _types.AtomsTypeEnum.NOT_EXISTS || v.type === _types.AtomsTypeEnum.EXISTS) {
940
+ return {
941
+ isError: (0, _utils2.isExistsError)(v.notExists, store.existsError)
942
+ };
943
+ }
944
+ if (v.type === _types.AtomsTypeEnum.SUB_QUERY) {
945
+ return {
946
+ isError: (0, _utils2.isExistsError)(v.subQuery, store.existsError)
947
+ };
948
+ }
949
+ if (v.type === _types.AtomsTypeEnum.FIELD) {
950
+ return {
951
+ isError: (0, _utils2.isError)(v, data)
952
+ };
953
+ }
954
+ if (v.type === _types.AtomsTypeEnum.CONSTANT) {
955
+ return {
956
+ isError: !!(v.id || v.val) && !(0, _utils3.getConstantLabel)(store.constantList, v.id || v.val),
957
+ message: '常量丢失'
958
+ };
959
+ }
960
+ if (otherTypeMap.has(String(v.type))) {
961
+ var currentOtherType = otherTypeMap.get(String(v.type));
962
+ var listSource = (currentOtherType === null || currentOtherType === void 0 ? void 0 : currentOtherType.list) || [];
963
+ return {
964
+ isError: !!(v.id || v.val) && !(0, _utils3.getConstantLabel)(listSource, v.id || v.val),
965
+ message: "".concat(currentOtherType === null || currentOtherType === void 0 ? void 0 : currentOtherType.label, "\u4E22\u5931")
966
+ };
967
+ }
968
+ if (v.type === _types.AtomsTypeEnum.EXPRESSION) {
969
+ return {
970
+ isError: (0, _utils2.isError)(v, data)
971
+ };
972
+ }
973
+ if (v.type === _types.AtomsTypeEnum.FORMULA) {
974
+ var formulaMissing = (0, _utils.formulaIsError)(v, formulaList);
975
+ return {
976
+ isError: (0, _utils2.isError)(v, data) || formulaMissing,
977
+ message: formulaMissing ? '公式丢失' : ''
978
+ };
979
+ }
980
+ return {
981
+ isError: false,
982
+ message: ''
983
+ };
984
+ };
498
985
  var showNotExists = function showNotExists(i) {
499
986
  var _caseList$i, _caseList$i2;
500
987
  var _store$preProps = store.preProps,
@@ -503,23 +990,22 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
503
990
  other = (0, _objectWithoutProperties2["default"])(_store$preProps, _excluded);
504
991
  var _value = ((_caseList$i = caseList[i]) === null || _caseList$i === void 0 ? void 0 : _caseList$i.notExists) || [];
505
992
  var oldList = (0, _cloneDeep["default"])(((_caseList$i2 = caseList[i]) === null || _caseList$i2 === void 0 ? void 0 : _caseList$i2.notExists) || []);
993
+ var childModalZIndex = (0, _helperDom.getTopLayerZIndex)() + 1;
506
994
  var _toolbar = notExistsToolbar || toolbar;
507
- // _toolbar = _toolbar.filter((v: string) => v !== 'group'); // 子查询不需要分组
508
- var o = _pandora.Modal2.openModal({
995
+ var o = openChildModal({
996
+ zIndex: childModalZIndex,
509
997
  title: caseList[i].type,
510
- transparentMask: true,
998
+ transparentMask: false,
511
999
  content: (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
512
1000
  children: (0, _jsxRuntime.jsx)(_index2["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, other), {}, {
1001
+ popupZIndex: childModalZIndex + 1,
513
1002
  notExistsColumns: exitData,
514
- // showFields={false}
515
1003
  isExit: true,
516
- // showSubquery={subShowSubquery}
517
1004
  toolbar: _toolbar,
518
1005
  btnText: (0, _locale.__)('SqlQueryBuilder.confirm'),
519
1006
  value: (0, _cloneDeep["default"])(_value),
520
1007
  onOk: function onOk(newList) {
521
1008
  try {
522
- // 子查询未改变不做操作
523
1009
  if ((0, _isEqual["default"])(newList, oldList)) {
524
1010
  o.close();
525
1011
  return;
@@ -533,18 +1019,14 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
533
1019
  onChange === null || onChange === void 0 || onChange(caseList, '');
534
1020
  setCaseList((0, _toConsumableArray2["default"])(caseList));
535
1021
  o.close();
536
- } catch (e) {
537
- console.warn(e);
538
- } finally {
1022
+ } catch (e) {} finally {
539
1023
  o.close();
540
1024
  }
541
1025
  }
542
1026
  }))
543
- }),
544
- onClose: function onClose() {}
1027
+ })
545
1028
  });
546
1029
  };
547
- // 子查询 窗口
548
1030
  var showSubQuery = function showSubQuery(i) {
549
1031
  var _caseList$i3, _caseList$i4;
550
1032
  var _store$preProps2 = store.preProps,
@@ -556,12 +1038,15 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
556
1038
  other = (0, _objectWithoutProperties2["default"])(_store$preProps2, _excluded2);
557
1039
  var _value = ((_caseList$i3 = caseList[i]) === null || _caseList$i3 === void 0 ? void 0 : _caseList$i3.subQuery) || [];
558
1040
  var oldList = (0, _cloneDeep["default"])(((_caseList$i4 = caseList[i]) === null || _caseList$i4 === void 0 ? void 0 : _caseList$i4.subQuery) || []);
1041
+ var childModalZIndex = (0, _helperDom.getTopLayerZIndex)() + 1;
559
1042
  var _toolbar = subToolbar || toolbar;
560
- var o = _pandora.Modal2.openModal({
1043
+ var o = openChildModal({
1044
+ zIndex: childModalZIndex,
561
1045
  title: (0, _locale.__)('SqlQueryBuilder.subquery'),
562
- transparentMask: true,
1046
+ transparentMask: false,
563
1047
  content: (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
564
1048
  children: (0, _jsxRuntime.jsx)(_index2["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, other), {}, {
1049
+ popupZIndex: childModalZIndex + 1,
565
1050
  isExit: true,
566
1051
  isSubquery: true,
567
1052
  notExistsColumns: exitData,
@@ -571,7 +1056,6 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
571
1056
  value: (0, _cloneDeep["default"])(_value),
572
1057
  onOk: function onOk(newList) {
573
1058
  try {
574
- // 子查询未改变不做操作
575
1059
  if ((0, _isEqual["default"])(newList, oldList)) {
576
1060
  o.close();
577
1061
  return;
@@ -585,15 +1069,12 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
585
1069
  onChange === null || onChange === void 0 || onChange(caseList, '');
586
1070
  setCaseList((0, _toConsumableArray2["default"])(caseList));
587
1071
  o.close();
588
- } catch (e) {
589
- console.warn(e);
590
- } finally {
1072
+ } catch (e) {} finally {
591
1073
  o.close();
592
1074
  }
593
1075
  }
594
1076
  }))
595
- }),
596
- onClose: function onClose() {}
1077
+ })
597
1078
  });
598
1079
  };
599
1080
  function selectConstant(e) {
@@ -618,7 +1099,6 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
618
1099
  })
619
1100
  });
620
1101
  }
621
- // 函数弹窗
622
1102
  var showFunction = function showFunction(e, i) {
623
1103
  var _value = caseList[i];
624
1104
  var o = _pandora.Modal2.openModal({
@@ -655,317 +1135,275 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
655
1135
  onClose: function onClose() {}
656
1136
  });
657
1137
  };
658
- // 分段
659
- var itemDom = function itemDom(v, index) {
1138
+ var itemDom = function itemDom(v, index, groupType) {
660
1139
  var type = v.type;
661
1140
  if (v.type === _types.AtomsTypeEnum.NOT_EXISTS || v.type === _types.AtomsTypeEnum.EXISTS) {
662
- return (0, _jsxRuntime.jsx)(_itemName["default"], {
663
- isError: (0, _utils2.isExistsError)(v.notExists, store.existsError),
664
- children: (0, _jsxRuntime.jsxs)("div", {
665
- className: "Sqb-TableName purple-name",
666
- onClick: function onClick(e) {
667
- return showNotExists(index);
668
- },
669
- children: [v.type, " ( * )", (0, _jsxRuntime.jsx)("span", {
670
- className: 'item-del',
671
- style: {
672
- fontSize: 0
673
- },
674
- onClick: function onClick(e) {
675
- return handleDel(e, index);
676
- },
677
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
678
- })]
679
- }, index)
680
- }, index);
681
- } else if (v.type === _types.AtomsTypeEnum.SUB_QUERY) {
682
- return (0, _jsxRuntime.jsx)(_itemName["default"], {
683
- isError: (0, _utils2.isExistsError)(v.subQuery, store.existsError),
684
- children: (0, _jsxRuntime.jsxs)("div", {
685
- className: "Sqb-TableName purple-name",
686
- onClick: function onClick(e) {
687
- return showSubQuery(index);
688
- },
689
- children: [v.label || (0, _locale.__)('SqlQueryBuilder.subquery'), (0, _jsxRuntime.jsx)("span", {
690
- className: 'item-del',
691
- style: {
692
- fontSize: 0
693
- },
694
- onClick: function onClick(e) {
695
- return handleDel(e, index);
696
- },
697
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
698
- })]
699
- }, index)
700
- }, index);
701
- } else if (type === _types.AtomsTypeEnum.FIELD) {
702
- // 字段
703
- return (0, _jsxRuntime.jsx)(_itemName["default"], {
704
- isError: (0, _utils2.isError)(v, data),
705
- children: (0, _jsxRuntime.jsxs)("div", {
706
- className: (0, _classnames["default"])("Sqb-TableName ", {
707
- notSelected: !(v !== null && v !== void 0 && v.fieldName)
1141
+ return {
1142
+ className: 'purple-name',
1143
+ onClick: function onClick() {
1144
+ return showNotExists(index);
1145
+ },
1146
+ node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1147
+ children: [v.type, " ( * )", renderDeleteIcon(v, index, groupType)]
1148
+ })
1149
+ };
1150
+ }
1151
+ if (v.type === _types.AtomsTypeEnum.SUB_QUERY) {
1152
+ return {
1153
+ className: 'purple-name',
1154
+ onClick: function onClick() {
1155
+ return showSubQuery(index);
1156
+ },
1157
+ node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1158
+ children: [v.label || (0, _locale.__)('SqlQueryBuilder.subquery'), renderDeleteIcon(v, index, groupType)]
1159
+ })
1160
+ };
1161
+ }
1162
+ if (type === _types.AtomsTypeEnum.FIELD) {
1163
+ return {
1164
+ className: (0, _classnames["default"])({
1165
+ notSelected: !(v !== null && v !== void 0 && v.fieldName)
1166
+ }),
1167
+ onClick: function onClick(e) {
1168
+ return handleField(e, index, v);
1169
+ },
1170
+ node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1171
+ children: [!(v !== null && v !== void 0 && v.fieldName) && (0, _locale.__)('customColumn.selectField'), v.fieldName, renderDeleteIcon(v, index, groupType)]
1172
+ })
1173
+ };
1174
+ }
1175
+ if (type === _types.AtomsTypeEnum.INPUT_STRING) {
1176
+ return {
1177
+ className: 'notSelected',
1178
+ node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1179
+ children: [(0, _jsxRuntime.jsx)(_pandoraIcons.FieldString, {}), (0, _jsxRuntime.jsx)(_pandora.Input, {
1180
+ className: ':sqb-Custom-input',
1181
+ value: v.val,
1182
+ placeholder: (0, _locale.__)('SqlQueryBuilder.pleaseEnter'),
1183
+ size: 'large',
1184
+ onChange: function onChange(val) {
1185
+ handleConstant(val, index);
1186
+ }
1187
+ }), renderDeleteIcon(v, index, groupType)]
1188
+ })
1189
+ };
1190
+ }
1191
+ if (type === _types.AtomsTypeEnum.INPUT_NUMBER) {
1192
+ return {
1193
+ className: 'notSelected',
1194
+ node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1195
+ children: [(0, _jsxRuntime.jsx)(_pandoraIcons.FieldNumber, {}), (0, _jsxRuntime.jsx)(_pandora.InputNumber, {
1196
+ className: ':sqb-Custom-input',
1197
+ value: v.val,
1198
+ placeholder: (0, _locale.__)('SqlQueryBuilder.pleaseEnter'),
1199
+ size: 'large',
1200
+ onChange: function onChange(val) {
1201
+ handleConstant(val, index);
1202
+ }
1203
+ }), renderDeleteIcon(v, index, groupType)]
1204
+ })
1205
+ };
1206
+ }
1207
+ if (type === _types.AtomsTypeEnum.OPERATOR) {
1208
+ if (isFixedCaseOperator(v)) {
1209
+ return {
1210
+ raw: true,
1211
+ node: (0, _jsxRuntime.jsx)("span", {
1212
+ className: 'Sqb-CaseKeyword',
1213
+ children: v.val
1214
+ })
1215
+ };
1216
+ }
1217
+ if (groupType === 'logic' && isFixedLogicOperator(v)) {
1218
+ return {
1219
+ raw: true,
1220
+ node: (0, _jsxRuntime.jsx)("span", {
1221
+ className: 'Sqb-CaseKeyword',
1222
+ children: v.val
1223
+ })
1224
+ };
1225
+ }
1226
+ if (groupType === 'logic' && ['and', 'or'].includes(v.val)) {
1227
+ var nextLogicOperator = v.val === 'and' ? 'or' : 'and';
1228
+ return {
1229
+ className: (0, _classnames["default"])({
1230
+ 'logic-operator': true,
1231
+ 'logic-and': v.val === 'and',
1232
+ 'logic-or': v.val === 'or'
708
1233
  }),
709
- onClick: function onClick(e) {
710
- return handleField(e, index, v);
1234
+ onClick: function onClick() {
1235
+ handleConstant(nextLogicOperator, index);
711
1236
  },
712
- children: [!(v !== null && v !== void 0 && v.fieldName) && (0, _locale.__)('customColumn.selectField'), v.fieldName, (0, _jsxRuntime.jsx)("span", {
713
- className: 'item-del',
714
- style: {
715
- fontSize: 0
716
- },
717
- onClick: function onClick(e) {
718
- return handleDel(e, index);
719
- },
720
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
721
- })]
722
- })
723
- }, index);
724
- } else if (type === _types.AtomsTypeEnum.INPUT_STRING) {
725
- // 输入框
726
- return (0, _jsxRuntime.jsxs)("div", {
727
- className: (0, _classnames["default"])("Sqb-TableName notSelected "),
728
- children: [(0, _jsxRuntime.jsx)(_pandoraIcons.FieldString, {}), (0, _jsxRuntime.jsx)(_pandora.Input, {
729
- className: ':Sqb-Custom-input',
1237
+ node: renderTokenContent(v.val)
1238
+ };
1239
+ }
1240
+ return {
1241
+ className: (0, _classnames["default"])('operator-trigger', {
1242
+ notSelected: !v.val,
1243
+ 'flow-operator': ['case', 'when', 'then', 'else', 'end'].includes(v.val),
1244
+ 'logic-operator': ['and', 'or'].includes(v.val),
1245
+ 'logic-and': v.val === 'and',
1246
+ 'logic-or': v.val === 'or'
1247
+ }),
1248
+ node: (0, _jsxRuntime.jsx)(_pandora.Select, {
1249
+ triggerProps: getSelectTriggerProps(),
730
1250
  value: v.val,
731
- placeholder: (0, _locale.__)('SqlQueryBuilder.pleaseEnter'),
732
- size: 'large',
733
- onChange: function onChange(val) {
734
- handleConstant(val, index);
735
- }
736
- }), (0, _jsxRuntime.jsx)("span", {
737
- className: 'item-del',
738
- style: {
739
- fontSize: 0
740
- },
741
- onClick: function onClick(e) {
742
- return handleDel(e, index);
1251
+ triggerElement: function triggerElement() {
1252
+ return renderTokenContent((0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1253
+ children: [!v.val && (0, _locale.__)('customColumn.selectOperator'), v.val, renderDeleteIcon(v, index)]
1254
+ }));
743
1255
  },
744
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
745
- })]
746
- });
747
- } else if (type === _types.AtomsTypeEnum.INPUT_NUMBER) {
748
- // 输入框
749
- return (0, _jsxRuntime.jsxs)("div", {
750
- className: (0, _classnames["default"])("Sqb-TableName notSelected "),
751
- children: [(0, _jsxRuntime.jsx)(_pandoraIcons.FieldNumber, {}), (0, _jsxRuntime.jsx)(_pandora.InputNumber, {
752
- className: ':sqb-Custom-input',
753
- value: v.val,
754
- placeholder: (0, _locale.__)('SqlQueryBuilder.pleaseEnter'),
755
- size: 'large',
756
1256
  onChange: function onChange(val) {
757
1257
  handleConstant(val, index);
758
- }
759
- }), (0, _jsxRuntime.jsx)("span", {
760
- className: 'item-del',
761
- style: {
762
- fontSize: 0
763
1258
  },
764
- onClick: function onClick(e) {
765
- return handleDel(e, index);
766
- },
767
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
768
- })]
769
- });
770
- } else if (type === _types.AtomsTypeEnum.OPERATOR) {
771
- //连接符
772
- return (0, _jsxRuntime.jsx)(_pandora.Select, {
773
- triggerProps: {
774
- clickToClose: true
775
- },
776
- value: v.val,
777
- triggerElement: function triggerElement(value) {
778
- return (0, _jsxRuntime.jsxs)("div", {
779
- className: (0, _classnames["default"])("Sqb-TableName Sqb-TableName-OPERATOR", {
780
- notSelected: !v.val
781
- }),
782
- children: [!v.val && (0, _locale.__)('customColumn.selectOperator'), v.val, (0, _jsxRuntime.jsx)("span", {
783
- className: 'item-del',
784
- style: {
785
- fontSize: 0
786
- },
787
- onClick: function onClick(e) {
788
- return handleDel(e, index);
789
- },
790
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
791
- })]
792
- });
793
- },
794
- onChange: function onChange(val) {
795
- handleConstant(val, index);
796
- },
797
- children: operatorList.map(function (option, index) {
798
- return (0, _jsxRuntime.jsx)(_pandora.Select.Option, {
799
- value: option,
800
- children: option
801
- }, index + '' + ind);
1259
+ children: operatorList.map(function (option, optionIndex) {
1260
+ return (0, _jsxRuntime.jsx)(_pandora.Select.Option, {
1261
+ value: option,
1262
+ children: option
1263
+ }, optionIndex + '' + ind);
1264
+ })
802
1265
  })
803
- });
804
- } else if (type === _types.AtomsTypeEnum.CONSTANT) {
805
- //常量
806
- return (0, _jsxRuntime.jsx)(_itemName["default"], {
807
- isError: !!(v.id || v.val) && !(0, _utils3.getConstantLabel)(store.constantList, v.id || v.val),
808
- message: "\u5E38\u91CF\u4E22\u5931",
809
- children: (0, _jsxRuntime.jsxs)("div", {
810
- className: (0, _classnames["default"])("Sqb-TableName", {
811
- notSelected: !v.val
812
- }),
813
- "v-index": index,
814
- "v-val": v.id || v.val,
815
- onClick: selectConstant,
816
- children: [(0, _utils3.getConstantLabel)(store.constantList, v.id || v.val, v.val) || (0, _locale.__)('SqlQueryBuilder.pickConstant'), (0, _jsxRuntime.jsx)("span", {
817
- className: 'item-del',
818
- style: {
819
- fontSize: 0
820
- },
821
- onClick: function onClick(e) {
822
- return handleDel(e, index);
823
- },
824
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
825
- })]
1266
+ };
1267
+ }
1268
+ if (type === _types.AtomsTypeEnum.CONSTANT) {
1269
+ return {
1270
+ className: (0, _classnames["default"])({
1271
+ notSelected: !v.val
1272
+ }),
1273
+ attrs: {
1274
+ 'v-index': index,
1275
+ 'v-val': v.id || v.val
1276
+ },
1277
+ onClick: selectConstant,
1278
+ node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1279
+ children: [(0, _utils3.getConstantLabel)(store.constantList, v.id || v.val, v.val) || (0, _locale.__)('SqlQueryBuilder.pickConstant'), renderDeleteIcon(v, index, groupType)]
826
1280
  })
827
- }, index);
828
- } else if (otherTypeMap.has(String(type))) {
829
- // 业务自定义常量类型(otherTypes)
1281
+ };
1282
+ }
1283
+ if (otherTypeMap.has(String(type))) {
830
1284
  var currentOtherType = otherTypeMap.get(String(type));
831
1285
  var listSource = (currentOtherType === null || currentOtherType === void 0 ? void 0 : currentOtherType.list) || [];
832
- return (0, _jsxRuntime.jsx)(_itemName["default"], {
833
- isError: !!(v.id || v.val) && !(0, _utils3.getConstantLabel)(listSource, v.id || v.val),
834
- message: "".concat(currentOtherType === null || currentOtherType === void 0 ? void 0 : currentOtherType.label, "\u4E22\u5931"),
835
- children: (0, _jsxRuntime.jsxs)("div", {
836
- className: (0, _classnames["default"])("Sqb-TableName", {
837
- notSelected: !v.val
838
- }),
839
- "v-index": index,
840
- "v-val": v.id || v.val,
841
- "v-type": type,
842
- onClick: selectConstant,
843
- children: [(0, _utils3.getConstantLabel)(listSource, v.id || v.val, v.val) || "\u8BF7\u9009\u62E9".concat(currentOtherType.label), (0, _jsxRuntime.jsx)("span", {
844
- className: 'item-del',
845
- style: {
846
- fontSize: 0
847
- },
848
- onClick: function onClick(e) {
849
- return handleDel(e, index);
850
- },
851
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
852
- })]
1286
+ return {
1287
+ className: (0, _classnames["default"])({
1288
+ notSelected: !v.val
1289
+ }),
1290
+ attrs: {
1291
+ 'v-index': index,
1292
+ 'v-val': v.id || v.val,
1293
+ 'v-type': type
1294
+ },
1295
+ onClick: selectConstant,
1296
+ node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1297
+ children: [(0, _utils3.getConstantLabel)(listSource, v.id || v.val, v.val) || "\u8BF7\u9009\u62E9".concat(currentOtherType.label), renderDeleteIcon(v, index, groupType)]
853
1298
  })
854
- }, index);
855
- } else if (type === _types.AtomsTypeEnum.EXPRESSION) {
1299
+ };
1300
+ }
1301
+ if (type === _types.AtomsTypeEnum.EXPRESSION) {
856
1302
  if (~['早于', '晚于', '在'].indexOf(v.condition) && v.rhs.length > 1) {
857
- var _caseList$index$quote;
858
- var _caseList = caseList.slice();
859
- _caseList[index].rhs = [_caseList[index].rhs[0]];
860
- _caseList[index].quotes = (_caseList$index$quote = _caseList[index].quotes.split(' || ')) === null || _caseList$index$quote === void 0 ? void 0 : _caseList$index$quote[0];
861
- setCaseList(_caseList);
1303
+ var _nextList$index$quote;
1304
+ var nextList = caseList.slice();
1305
+ nextList[index].rhs = [nextList[index].rhs[0]];
1306
+ nextList[index].quotes = (_nextList$index$quote = nextList[index].quotes.split(' || ')) === null || _nextList$index$quote === void 0 ? void 0 : _nextList$index$quote[0];
1307
+ setCaseList(nextList);
862
1308
  }
863
- // 表达式
864
- return (0, _jsxRuntime.jsx)(_itemName["default"], {
865
- isError: (0, _utils2.isError)(v, data),
866
- children: (0, _jsxRuntime.jsxs)("div", {
867
- className: (0, _classnames["default"])("Sqb-TableName purple-name", {
868
- notSelected: !v.quotes
869
- }),
870
- onClick: function onClick(e) {
871
- return handleExpression(e, index, v);
872
- },
873
- children: [v.quotes ? v.quotes : (0, _locale.__)('customColumn.selectExpression'), (0, _jsxRuntime.jsx)("span", {
874
- className: 'item-del',
875
- style: {
876
- fontSize: 0
877
- },
878
- onClick: function onClick(e) {
879
- return handleDel(e, index);
880
- },
881
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
882
- })]
1309
+ return {
1310
+ className: (0, _classnames["default"])('purple-name', {
1311
+ notSelected: !v.quotes
1312
+ }),
1313
+ onClick: function onClick(e) {
1314
+ return handleExpression(e, index, v);
1315
+ },
1316
+ node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1317
+ children: [v.quotes ? v.quotes : (0, _locale.__)('customColumn.selectExpression'), renderDeleteIcon(v, index, groupType)]
883
1318
  })
884
- }, index);
885
- } else if (type === _types.AtomsTypeEnum.FORMULA) {
886
- // 公式
887
- return (0, _jsxRuntime.jsx)(_itemName["default"], {
888
- isError: (0, _utils2.isError)(v, data) || (0, _utils.formulaIsError)(v, formulaList),
889
- message: (0, _utils.formulaIsError)(v, formulaList) ? '公式丢失' : '',
890
- children: (0, _jsxRuntime.jsxs)("div", {
891
- className: (0, _classnames["default"])("Sqb-TableName gray-name"),
892
- onClick: function onClick(e) {
893
- return showFunction(e, index);
1319
+ };
1320
+ }
1321
+ if (type === _types.AtomsTypeEnum.CASE_WHEN) {
1322
+ return {
1323
+ raw: true,
1324
+ node: renderCaseWhenEditor(v, index)
1325
+ };
1326
+ }
1327
+ if (type === _types.AtomsTypeEnum.AND_OR) {
1328
+ return {
1329
+ raw: true,
1330
+ node: renderAndOrEditor(v, index)
1331
+ };
1332
+ }
1333
+ if (type === _types.AtomsTypeEnum.FORMULA) {
1334
+ return {
1335
+ className: 'gray-name',
1336
+ onClick: function onClick(e) {
1337
+ return showFunction(e, index);
1338
+ },
1339
+ node: (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1340
+ children: [v.name ? (0, _utils.getQuotes)(v, v.args, formulaList) : (0, _locale.__)('customColumn.selectFormula'), renderDeleteIcon(v, index, groupType)]
1341
+ })
1342
+ };
1343
+ }
1344
+ if (type === _types.AtomsTypeEnum.SELECT) {
1345
+ return {
1346
+ className: (0, _classnames["default"])('operator-trigger', {
1347
+ notSelected: !v.val,
1348
+ 'flow-operator': v.val === 'caseWhen',
1349
+ 'logic-operator': v.val === 'andOr'
1350
+ }),
1351
+ node: (0, _jsxRuntime.jsx)(_pandora.Select, {
1352
+ triggerProps: getSelectTriggerProps(),
1353
+ multiple: v.multiple,
1354
+ value: v.val,
1355
+ triggerElement: function triggerElement() {
1356
+ return renderTokenContent((0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1357
+ children: [!v.val && (0, _locale.__)('customColumn.selectOperator'), v.val, !v.fixed && renderDeleteIcon(v, index, groupType)]
1358
+ }));
894
1359
  },
895
- children: [v.name ? (0, _utils.getQuotes)(v, v.args, formulaList) : (0, _locale.__)('customColumn.selectFormula'), (0, _jsxRuntime.jsx)("span", {
896
- className: 'item-del',
897
- style: {
898
- fontSize: 0
899
- },
900
- onClick: function onClick(e) {
901
- return handleDel(e, index);
902
- },
903
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
904
- })]
1360
+ onChange: function onChange(val) {
1361
+ handleConstant(val, index);
1362
+ },
1363
+ children: v.options.map(function (option, optionIndex) {
1364
+ return (0, _jsxRuntime.jsx)(_pandora.Select.Option, {
1365
+ value: option.value,
1366
+ children: option.label
1367
+ }, optionIndex + '' + ind);
1368
+ })
905
1369
  })
906
- }, index);
907
- } else if (type === _types.AtomsTypeEnum.SELECT) {
908
- // 选择框
909
- return (0, _jsxRuntime.jsx)(_pandora.Select, {
910
- triggerProps: {
911
- clickToClose: true
912
- },
913
- multiple: v.multiple,
914
- value: v.val,
915
- triggerElement: function triggerElement(value) {
916
- return (0, _jsxRuntime.jsxs)("div", {
917
- className: (0, _classnames["default"])("Sqb-TableName Sqb-TableName-OPERATOR", {
918
- notSelected: !v.val
919
- }),
920
- children: [!v.val && (0, _locale.__)('customColumn.selectOperator'), v.val, !v.fixed && (0, _jsxRuntime.jsx)("span", {
921
- className: 'item-del',
922
- style: {
923
- fontSize: 0
924
- },
925
- onClick: function onClick(e) {
926
- return handleDel(e, index);
927
- },
928
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
929
- })]
930
- });
931
- },
932
- onChange: function onChange(val) {
933
- handleConstant(val, index);
1370
+ };
1371
+ }
1372
+ if (groupType === 'logic') {
1373
+ return {
1374
+ className: (0, _classnames["default"])('gray-name', 'notSelected'),
1375
+ style: {
1376
+ minWidth: 44,
1377
+ justifyContent: 'center'
934
1378
  },
935
- children: v.options.map(function (option, index) {
936
- return (0, _jsxRuntime.jsx)(_pandora.Select.Option, {
937
- value: option.value,
938
- children: option.label
939
- }, index + '' + ind);
1379
+ node: selectOperator({
1380
+ triggerElement: function triggerElement() {
1381
+ return renderTokenContent((0, _jsxRuntime.jsx)(_icons.AddIcon, {}));
1382
+ },
1383
+ ind: index,
1384
+ position: ''
940
1385
  })
941
- });
942
- } else {
943
- return selectOperator({
1386
+ };
1387
+ }
1388
+ return {
1389
+ className: (0, _classnames["default"])({
1390
+ notSelected: true
1391
+ }),
1392
+ node: selectOperator({
944
1393
  triggerElement: function triggerElement() {
945
- return (0, _jsxRuntime.jsxs)("div", {
946
- className: (0, _classnames["default"])("Sqb-TableName ", {
947
- notSelected: true
948
- }),
949
- children: [(0, _locale.__)('customColumn.selectCustomInput'), (0, _jsxRuntime.jsx)("span", {
950
- className: 'item-del',
951
- style: {
952
- fontSize: 0
953
- },
954
- onClick: function onClick(e) {
955
- return handleDel(e, index);
956
- },
957
- children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
958
- })]
959
- });
1394
+ return renderTokenContent((0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
1395
+ children: [(0, _locale.__)('customColumn.selectCustomInput'), renderDeleteIcon(v, index, groupType)]
1396
+ }));
960
1397
  },
961
1398
  ind: index,
962
1399
  position: ''
963
- });
964
- }
1400
+ })
1401
+ };
965
1402
  };
966
1403
  var copyDom = function copyDom() {
967
1404
  var index = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : -1;
968
1405
  var positioned = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
1406
+ if (embedded) return null;
969
1407
  if (!isCopy || selectedIndices.length === 0 && checkedItemsCount === 0) return null;
970
1408
  return (0, _jsxRuntime.jsx)("div", {
971
1409
  className: (0, _classnames["default"])('Sqb-Filter-item-copy', {
@@ -993,10 +1431,147 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
993
1431
  })
994
1432
  });
995
1433
  };
1434
+ var renderItemShell = function renderItemShell(v, i, groupType, extraClassName) {
1435
+ var showCheckbox = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
1436
+ var itemContent = itemDom(v, i, groupType);
1437
+ var isCompositeAtom = v.type === _types.AtomsTypeEnum.CASE_WHEN || v.type === _types.AtomsTypeEnum.AND_OR;
1438
+ var isPassiveCaseKeyword = groupType === 'caseWhen' && isFixedCaseOperator(v) || groupType === 'logic' && isFixedLogicOperator(v);
1439
+ return (0, _jsxRuntime.jsx)(_react["default"].Fragment, {
1440
+ children: (0, _jsxRuntime.jsxs)("div", {
1441
+ className: (0, _classnames["default"])('Sqb-Filter-item', (0, _defineProperty2["default"])({
1442
+ hover: ind === i && hoveredCopyIndex !== i,
1443
+ 'item-fixed': v.fixed || false,
1444
+ 'item-selected': isCheck,
1445
+ 'item-composite': isCompositeAtom,
1446
+ 'group-child': groupType !== 'single',
1447
+ 'group-flow-child': groupType === 'caseWhen',
1448
+ 'group-logic-child': groupType === 'logic'
1449
+ }, extraClassName || '', !!extraClassName)),
1450
+ onMouseEnter: function onMouseEnter(e) {
1451
+ if (isCheck || isPassiveCaseKeyword) return;
1452
+ setInd(i);
1453
+ },
1454
+ onMouseLeave: function onMouseLeave() {
1455
+ if (isCheck || isPassiveCaseKeyword) return;
1456
+ setInd(-1);
1457
+ },
1458
+ children: [copyDom(i), canShowInsertArrows(v, groupType) && selectOperator({
1459
+ triggerElement: function triggerElement() {
1460
+ return (0, _jsxRuntime.jsx)("div", {
1461
+ className: 'left-arrow',
1462
+ "v-index": i,
1463
+ "v-type": 'before',
1464
+ onClick: function onClick() {
1465
+ if (!selectedIndices.length) addOperator(_types.AtomsTypeEnum.UNKNOWN, i, 'before');
1466
+ },
1467
+ children: (0, _jsxRuntime.jsx)("img", {
1468
+ src: _arrow["default"]
1469
+ })
1470
+ });
1471
+ },
1472
+ ind: i,
1473
+ position: 'before',
1474
+ trigger: 'hover'
1475
+ }), !embedded && showCheckbox && v.type !== _types.AtomsTypeEnum.UNKNOWN && (0, _jsxRuntime.jsx)(_pandora.Checkbox, {
1476
+ className: 'item-check',
1477
+ checked: selectedIndices.includes(i),
1478
+ disabled: globalSelectionActive && globalSelectionOwner !== myInstanceIdRef.current,
1479
+ onChange: function onChange(e) {
1480
+ var _e$target$checked, _e$target;
1481
+ return toggleSelect(i, (_e$target$checked = e === null || e === void 0 || (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.checked) !== null && _e$target$checked !== void 0 ? _e$target$checked : !selectedIndices.includes(i));
1482
+ }
1483
+ }), (0, _jsxRuntime.jsx)("div", {
1484
+ style: {
1485
+ pointerEvents: isCheck || store.isMetabaseCopy ? 'none' : 'auto'
1486
+ },
1487
+ className: (0, _classnames["default"])({
1488
+ openCheck: isCheck
1489
+ }),
1490
+ children: (0, _jsxRuntime.jsx)(_itemName["default"], (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, getItemNameProps(v)), {}, {
1491
+ children: itemContent.raw ? itemContent.node : (0, _jsxRuntime.jsx)("div", (0, _objectSpread2["default"])((0, _objectSpread2["default"])({
1492
+ className: (0, _classnames["default"])('Sqb-TableName', itemContent.className),
1493
+ onClick: itemContent.onClick,
1494
+ style: itemContent.style
1495
+ }, itemContent.attrs || {}), {}, {
1496
+ children: itemContent.node
1497
+ }))
1498
+ }))
1499
+ }), canShowInsertArrows(v, groupType) && selectOperator({
1500
+ triggerElement: function triggerElement(value) {
1501
+ return (0, _jsxRuntime.jsx)("div", {
1502
+ className: 'right-arrow',
1503
+ "v-index": i,
1504
+ "v-type": 'after',
1505
+ onClick: function onClick() {
1506
+ addOperator(_types.AtomsTypeEnum.UNKNOWN, i, 'after');
1507
+ },
1508
+ children: (0, _jsxRuntime.jsx)("img", {
1509
+ src: _arrow["default"]
1510
+ })
1511
+ });
1512
+ },
1513
+ ind: i,
1514
+ position: 'after',
1515
+ trigger: 'hover'
1516
+ })]
1517
+ })
1518
+ }, i);
1519
+ };
1520
+ var renderCaseSection = function renderCaseSection(itemIndices, groupType, sectionClassName) {
1521
+ return itemIndices.map(function (itemIndex) {
1522
+ return renderItemShell(caseList[itemIndex], itemIndex, groupType, "case-row-item ".concat(sectionClassName), false);
1523
+ });
1524
+ };
1525
+ var renderDeleteIcon = function renderDeleteIcon(item, index, groupType) {
1526
+ if (!canDeleteItem(item, groupType)) return null;
1527
+ return (0, _jsxRuntime.jsx)("span", {
1528
+ className: 'item-del',
1529
+ style: {
1530
+ fontSize: 0
1531
+ },
1532
+ onClick: function onClick(e) {
1533
+ return handleDel(e, index);
1534
+ },
1535
+ children: (0, _jsxRuntime.jsx)(_icons.CloseIcon, {})
1536
+ });
1537
+ };
1538
+ var renderCaseRecoverButton = function renderCaseRecoverButton(onClick, className, label) {
1539
+ return (0, _jsxRuntime.jsxs)("button", {
1540
+ type: 'button',
1541
+ className: (0, _classnames["default"])('Sqb-CaseRecover', className),
1542
+ onClick: onClick,
1543
+ children: [(0, _jsxRuntime.jsx)(_pandoraIcons.FfPlus, {}), (0, _jsxRuntime.jsx)("span", {
1544
+ children: label
1545
+ })]
1546
+ });
1547
+ };
1548
+ var renderGroupInsertArrow = function renderGroupInsertArrow(index, position) {
1549
+ return selectOperator({
1550
+ triggerElement: function triggerElement() {
1551
+ return (0, _jsxRuntime.jsx)("div", {
1552
+ className: position === 'before' ? 'left-arrow' : 'right-arrow',
1553
+ "v-index": index,
1554
+ "v-type": position,
1555
+ onClick: function onClick() {
1556
+ if (position === 'before' && selectedIndices.length) return;
1557
+ addOperator(_types.AtomsTypeEnum.UNKNOWN, index, position);
1558
+ },
1559
+ children: (0, _jsxRuntime.jsx)("img", {
1560
+ src: _arrow["default"]
1561
+ })
1562
+ });
1563
+ },
1564
+ ind: index,
1565
+ position: position,
1566
+ trigger: 'hover'
1567
+ });
1568
+ };
996
1569
  return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
997
1570
  children: (0, _jsxRuntime.jsxs)("div", {
998
- className: "Sqb-NotebookCell",
999
- children: [isCopy && caseList.length > 0 && (0, _jsxRuntime.jsxs)(_pandora.Space, {
1571
+ className: (0, _classnames["default"])('Sqb-NotebookCell', {
1572
+ 'Sqb-NotebookCell--embedded': embedded
1573
+ }),
1574
+ children: [!embedded && isCopy && caseList.length > 0 && (0, _jsxRuntime.jsxs)(_pandora.Space, {
1000
1575
  size: 'small',
1001
1576
  direction: 'vertical',
1002
1577
  className: (0, _classnames["default"])('item-isCheck', {
@@ -1035,75 +1610,8 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
1035
1610
  },
1036
1611
  children: "\u6E05\u9664\u590D\u5236"
1037
1612
  })]
1038
- }), (_caseList2 = caseList) === null || _caseList2 === void 0 ? void 0 : _caseList2.map(function (v, i) {
1039
- return (0, _jsxRuntime.jsx)(_react["default"].Fragment, {
1040
- children: (0, _jsxRuntime.jsxs)("div", {
1041
- className: (0, _classnames["default"])('Sqb-Filter-item', {
1042
- hover: ind === i && hoveredCopyIndex !== i,
1043
- 'item-fixed': v.fixed || false,
1044
- 'item-selected': isCheck
1045
- }),
1046
- onMouseEnter: function onMouseEnter(e) {
1047
- if (isCheck) return;
1048
- setInd(i);
1049
- },
1050
- onMouseLeave: function onMouseLeave() {
1051
- if (isCheck) return;
1052
- setInd(-1);
1053
- },
1054
- children: [copyDom(i), selectOperator({
1055
- triggerElement: function triggerElement() {
1056
- return (0, _jsxRuntime.jsx)("div", {
1057
- className: 'left-arrow',
1058
- "v-index": i,
1059
- "v-type": 'before',
1060
- onClick: function onClick() {
1061
- if (!selectedIndices.length) addOperator(_types.AtomsTypeEnum.UNKNOWN, i, 'before');
1062
- },
1063
- children: (0, _jsxRuntime.jsx)("img", {
1064
- src: _arrow["default"]
1065
- })
1066
- });
1067
- },
1068
- ind: i,
1069
- position: 'before',
1070
- trigger: 'hover'
1071
- }), v.type !== _types.AtomsTypeEnum.UNKNOWN && (0, _jsxRuntime.jsx)(_pandora.Checkbox, {
1072
- className: 'item-check',
1073
- checked: selectedIndices.includes(i),
1074
- disabled: globalSelectionActive && globalSelectionOwner !== myInstanceIdRef.current,
1075
- onChange: function onChange(e) {
1076
- var _e$target$checked, _e$target;
1077
- return toggleSelect(i, (_e$target$checked = e === null || e === void 0 || (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.checked) !== null && _e$target$checked !== void 0 ? _e$target$checked : !selectedIndices.includes(i));
1078
- }
1079
- }), (0, _jsxRuntime.jsx)("div", {
1080
- style: {
1081
- pointerEvents: isCheck || store.isMetabaseCopy ? 'none' : 'auto'
1082
- },
1083
- className: (0, _classnames["default"])('Sqb-Filter-item-content', {
1084
- openCheck: isCheck
1085
- }),
1086
- children: itemDom(v, i)
1087
- }), selectOperator({
1088
- triggerElement: function triggerElement(value) {
1089
- return (0, _jsxRuntime.jsx)("div", {
1090
- className: 'right-arrow',
1091
- "v-index": i,
1092
- "v-type": 'after',
1093
- onClick: function onClick() {
1094
- addOperator(_types.AtomsTypeEnum.UNKNOWN, i, 'after');
1095
- },
1096
- children: (0, _jsxRuntime.jsx)("img", {
1097
- src: _arrow["default"]
1098
- })
1099
- });
1100
- },
1101
- ind: i,
1102
- position: 'after',
1103
- trigger: 'hover'
1104
- })]
1105
- }, i)
1106
- }, i);
1613
+ }), caseList.map(function (item, itemIndex) {
1614
+ return renderItemShell(item, itemIndex, 'single');
1107
1615
  }), Array.from(caseList).length < 1 && selectOperator({
1108
1616
  triggerElement: function triggerElement() {
1109
1617
  return (0, _jsxRuntime.jsx)("div", {
@@ -1114,7 +1622,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
1114
1622
  ind: -1,
1115
1623
  position: 'add',
1116
1624
  trigger: 'click'
1117
- }), copyDom(-1, false), showPreview && (0, _jsxRuntime.jsx)("div", {
1625
+ }), !embedded && copyDom(-1, false), !embedded && showPreview && (0, _jsxRuntime.jsx)("div", {
1118
1626
  className: (0, _classnames["default"])("mb-2 font-bold uppercase tracking-wider preview-box"),
1119
1627
  style: {
1120
1628
  fontSize: 12,
@@ -1157,54 +1665,10 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
1157
1665
  isSqlError: errorInfo.isError
1158
1666
  }),
1159
1667
  children: caseList.map(function (v, i) {
1160
- if (v !== null && v !== void 0 && v.quotes) {
1161
- return (0, _jsxRuntime.jsx)("span", {
1162
- className: 'mr-1',
1163
- children: v === null || v === void 0 ? void 0 : v.quotes
1164
- }, i);
1165
- } else if (v !== null && v !== void 0 && v.fieldName) {
1166
- return (0, _jsxRuntime.jsx)("span", {
1167
- className: 'mr-1',
1168
- children: v === null || v === void 0 ? void 0 : v.fieldName
1169
- }, i);
1170
- } else {
1171
- if (v.type === _types.AtomsTypeEnum.OPERATOR && (v.val === 'and' || v.val === 'or')) {
1172
- return (0, _jsxRuntime.jsxs)("span", {
1173
- className: 'mr-1',
1174
- children: [(0, _jsxRuntime.jsx)("br", {}), v.val, (0, _jsxRuntime.jsx)("br", {})]
1175
- }, i);
1176
- }
1177
- if (v.type === _types.AtomsTypeEnum.OPERATOR) {
1178
- if (v.val === '(' || v.val === ')') {
1179
- return (0, _jsxRuntime.jsx)("span", {
1180
- className: (0, _classnames["default"])('mr-1', {
1181
- error: errorInfo.isBracket
1182
- }),
1183
- children: v.val
1184
- }, i);
1185
- }
1186
- if (v.val === 'case' || v.val === 'end' || v.val === 'when' || v.val === 'then') {
1187
- return (0, _jsxRuntime.jsx)("span", {
1188
- className: (0, _classnames["default"])('mr-1', {
1189
- error: errorInfo.isCase
1190
- }),
1191
- children: v.val
1192
- }, i);
1193
- }
1194
- if (v.val === 'over') {
1195
- return (0, _jsxRuntime.jsx)("span", {
1196
- className: (0, _classnames["default"])('mr-1', {
1197
- error: errorInfo.isOver
1198
- }),
1199
- children: v.val
1200
- }, i);
1201
- }
1202
- }
1203
- return (0, _jsxRuntime.jsx)("span", {
1204
- className: 'mr-1',
1205
- children: v.val
1206
- }, i);
1207
- }
1668
+ return (0, _jsxRuntime.jsx)("span", {
1669
+ className: 'mr-1',
1670
+ children: getItemDisplayText(v)
1671
+ }, i);
1208
1672
  })
1209
1673
  }), (0, _jsxRuntime.jsx)("div", {
1210
1674
  className: 'errorMsg mt-2',