@gingkoo/pandora-metabase 1.0.157-alpha.4 → 1.0.157-alpha.6

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 (31) hide show
  1. package/lib/cjs/components/dialog/custom-editor/index.js +56 -3
  2. package/lib/cjs/components/dialog/expression/index.js +14 -2
  3. package/lib/cjs/components/dialog/formula/index.js +3 -1
  4. package/lib/cjs/components/dialog/formula/utils.d.ts +1 -0
  5. package/lib/cjs/components/dialog/formula/utils.js +20 -2
  6. package/lib/cjs/components/dialog/formula-list/index.d.ts +1 -0
  7. package/lib/cjs/components/dialog/formula-list/index.js +309 -134
  8. package/lib/cjs/components/dialog/formula-list/index.less +52 -0
  9. package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +2 -1
  10. package/lib/cjs/components/dialog/select-column-multiple/index.js +4 -2
  11. package/lib/cjs/index.d.ts +3 -2
  12. package/lib/cjs/index.js +7 -0
  13. package/lib/cjs/locale/en.js +4 -0
  14. package/lib/cjs/locale/zh.js +4 -0
  15. package/lib/cjs/types.d.ts +10 -1
  16. package/lib/es/components/dialog/custom-editor/index.js +56 -3
  17. package/lib/es/components/dialog/expression/index.js +14 -2
  18. package/lib/es/components/dialog/formula/index.js +4 -2
  19. package/lib/es/components/dialog/formula/utils.d.ts +1 -0
  20. package/lib/es/components/dialog/formula/utils.js +18 -1
  21. package/lib/es/components/dialog/formula-list/index.d.ts +1 -0
  22. package/lib/es/components/dialog/formula-list/index.js +307 -132
  23. package/lib/es/components/dialog/formula-list/index.less +52 -0
  24. package/lib/es/components/dialog/select-column-multiple/index.d.ts +2 -1
  25. package/lib/es/components/dialog/select-column-multiple/index.js +4 -2
  26. package/lib/es/index.d.ts +3 -2
  27. package/lib/es/index.js +3 -1
  28. package/lib/es/locale/en.js +4 -0
  29. package/lib/es/locale/zh.js +4 -0
  30. package/lib/es/types.d.ts +10 -1
  31. package/package.json +1 -1
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports["default"] = void 0;
9
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
10
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/defineProperty"));
11
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
12
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/extends"));
13
11
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/typeof"));
14
12
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
13
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
15
14
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/toConsumableArray"));
16
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
17
15
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
16
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/asyncToGenerator"));
17
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/slicedToArray"));
18
18
  var _jsxRuntime = require("react/jsx-runtime");
19
19
  var _react = _interopRequireWildcard(require("react"));
20
20
  require("./index.less");
@@ -47,7 +47,116 @@ var _helper = require("../../../store/helper");
47
47
  var _excluded = ["operator", "leftAtoms", "rightAtoms", "atoms"],
48
48
  _excluded2 = ["notExistsToolbar", "toolbar"],
49
49
  _excluded3 = ["subToolbar", "notExistsColumns", "showFields", "isExit", "toolbar"];
50
- 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" != _typeof3(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 _t3 in e) "default" !== _t3 && {}.hasOwnProperty.call(e, _t3) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t3)) && (i.get || i.set) ? o(f, _t3, i) : f[_t3] = e[_t3]); return f; })(e, t); }
50
+ 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" != _typeof3(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 _t4 in e) "default" !== _t4 && {}.hasOwnProperty.call(e, _t4) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t4)) && (i.get || i.set) ? o(f, _t4, i) : f[_t4] = e[_t4]); return f; })(e, t); }
51
+ var SqlImportContent = function SqlImportContent(_ref2) {
52
+ var onSubmit = _ref2.onSubmit,
53
+ onClose = _ref2.onClose,
54
+ matchBrackets = _ref2.matchBrackets;
55
+ var _useState = (0, _react.useState)(''),
56
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
57
+ sql = _useState2[0],
58
+ setSql = _useState2[1];
59
+ var _useState3 = (0, _react.useState)(false),
60
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
61
+ loading = _useState4[0],
62
+ setLoading = _useState4[1];
63
+ var editorRef = (0, _react.useRef)(null);
64
+ (0, _react.useEffect)(function () {
65
+ var timer = window.setTimeout(function () {
66
+ var _editor$getCodeMirror, _codeMirror$focus;
67
+ var editor = editorRef.current;
68
+ var codeMirror = (editor === null || editor === void 0 ? void 0 : editor.editor) || (editor === null || editor === void 0 || (_editor$getCodeMirror = editor.getCodeMirror) === null || _editor$getCodeMirror === void 0 ? void 0 : _editor$getCodeMirror.call(editor)) || editor;
69
+ codeMirror === null || codeMirror === void 0 || (_codeMirror$focus = codeMirror.focus) === null || _codeMirror$focus === void 0 || _codeMirror$focus.call(codeMirror);
70
+ }, 0);
71
+ return function () {
72
+ return window.clearTimeout(timer);
73
+ };
74
+ }, []);
75
+ var submit = function () {
76
+ var _ref3 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
77
+ var applyResult, _t;
78
+ return _regenerator["default"].wrap(function (_context) {
79
+ while (1) switch (_context.prev = _context.next) {
80
+ case 0:
81
+ if (!(!sql.trim() || loading)) {
82
+ _context.next = 1;
83
+ break;
84
+ }
85
+ return _context.abrupt("return");
86
+ case 1:
87
+ setLoading(true);
88
+ _context.prev = 2;
89
+ _context.next = 3;
90
+ return onSubmit(sql.trim());
91
+ case 3:
92
+ applyResult = _context.sent;
93
+ if (typeof applyResult === 'function') {
94
+ applyResult();
95
+ }
96
+ _context.next = 4;
97
+ return new Promise(function (resolve) {
98
+ return window.requestAnimationFrame(function () {
99
+ return resolve();
100
+ });
101
+ });
102
+ case 4:
103
+ onClose();
104
+ _context.next = 6;
105
+ break;
106
+ case 5:
107
+ _context.prev = 5;
108
+ _t = _context["catch"](2);
109
+ case 6:
110
+ _context.prev = 6;
111
+ setLoading(false);
112
+ return _context.finish(6);
113
+ case 7:
114
+ case "end":
115
+ return _context.stop();
116
+ }
117
+ }, _callee, null, [[2, 5, 6, 7]]);
118
+ }));
119
+ return function submit() {
120
+ return _ref3.apply(this, arguments);
121
+ };
122
+ }();
123
+ return (0, _jsxRuntime.jsxs)("div", {
124
+ className: 'Sqb-FormulaSqlImport',
125
+ children: [(0, _jsxRuntime.jsx)("div", {
126
+ className: 'Sqb-FormulaSqlImport-editor',
127
+ children: (0, _jsxRuntime.jsx)(_pandora.Editor, {
128
+ ref: editorRef,
129
+ showFull: false,
130
+ className: 'Sqb-FormulaSqlPreviewEditor',
131
+ language: 'sql',
132
+ height: '100%',
133
+ fullscreen: true,
134
+ showLanguage: false,
135
+ matchBrackets: matchBrackets,
136
+ lineWrapping: true,
137
+ lineNumbers: true,
138
+ value: sql,
139
+ readOnly: loading,
140
+ onChange: function onChange(value) {
141
+ if (loading) return;
142
+ setSql(value);
143
+ }
144
+ })
145
+ }), (0, _jsxRuntime.jsxs)("div", {
146
+ className: 'Sqb-FormulaSqlImport-actions',
147
+ children: [(0, _jsxRuntime.jsx)(_pandora.Button, {
148
+ onClick: onClose,
149
+ children: (0, _locale.__)('customColumn.cancel')
150
+ }), (0, _jsxRuntime.jsx)(_pandora.Button, {
151
+ primary: true,
152
+ loading: loading,
153
+ disabled: !sql.trim() || loading,
154
+ onClick: submit,
155
+ children: (0, _locale.__)('customColumn.parseSql')
156
+ })]
157
+ })]
158
+ });
159
+ };
51
160
  var parentPopupLockCounts = new WeakMap();
52
161
  var CASE_FIXED_OPERATORS = ['case', 'when', 'then', 'else', 'end'];
53
162
  var LOGIC_FIXED_OPERATORS = ['(', ')'];
@@ -148,11 +257,11 @@ var getTokenStyleByClassName = function getTokenStyleByClassName(className, extr
148
257
  } : {}), extraStyle);
149
258
  };
150
259
  var FormulaList = (0, _react.forwardRef)(function (props, ref) {
151
- var _storage$_metabaseCop;
152
- 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),
153
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
154
- checkedItemsCount = _useState2[0],
155
- setCheckedItemsCount = _useState2[1];
260
+ var _storage$_metabaseCop, _store$preProps;
261
+ var _useState5 = (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),
262
+ _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
263
+ checkedItemsCount = _useState6[0],
264
+ setCheckedItemsCount = _useState6[1];
156
265
  (0, _react.useEffect)(function () {
157
266
  var _storage$_metabaseCop3;
158
267
  var handler = function handler() {
@@ -189,7 +298,8 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
189
298
  enableCopy = _props$enableCopy === void 0 ? true : _props$enableCopy,
190
299
  _props$enableZoom = props.enableZoom,
191
300
  enableZoom = _props$enableZoom === void 0 ? true : _props$enableZoom,
192
- parentPopupChannel = props.parentPopupChannel;
301
+ parentPopupChannel = props.parentPopupChannel,
302
+ onAddSql = props.onAddSql;
193
303
  var parentPopupLockCountRef = (0, _react.useRef)(0);
194
304
  var parentPopupUnlockTimerRef = (0, _react.useRef)(null);
195
305
  var setParentClosable = function setParentClosable(closable) {
@@ -316,15 +426,15 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
316
426
  }
317
427
  return _utils3.operatorList;
318
428
  }, [store.operatorList]);
319
- var _useState3 = (0, _react.useState)(false),
320
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
321
- sqlLoading = _useState4[0],
322
- setSqlLoading = _useState4[1];
323
- var _useState5 = (0, _react.useState)(false),
324
- _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
325
- diffLoading = _useState6[0],
326
- setDiffLoading = _useState6[1];
327
- var _useState7 = (0, _react.useState)(function () {
429
+ var _useState7 = (0, _react.useState)(false),
430
+ _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
431
+ sqlLoading = _useState8[0],
432
+ setSqlLoading = _useState8[1];
433
+ var _useState9 = (0, _react.useState)(false),
434
+ _useState0 = (0, _slicedToArray2["default"])(_useState9, 2),
435
+ diffLoading = _useState0[0],
436
+ setDiffLoading = _useState0[1];
437
+ var _useState1 = (0, _react.useState)(function () {
328
438
  if (!enableCopy) {
329
439
  return false;
330
440
  }
@@ -333,25 +443,25 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
333
443
  }
334
444
  return store.copyType.includes(_type);
335
445
  }),
336
- _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
337
- isCopy = _useState8[0],
338
- setIsCopy = _useState8[1];
446
+ _useState10 = (0, _slicedToArray2["default"])(_useState1, 2),
447
+ isCopy = _useState10[0],
448
+ setIsCopy = _useState10[1];
339
449
  var formulaList = (0, _react.useMemo)(function () {
340
450
  return (0, _utils.getObjTem)(store.formulaTemplates);
341
451
  }, [store.formulaTemplates]);
342
- var _useState9 = (0, _react.useState)(''),
343
- _useState0 = (0, _slicedToArray2["default"])(_useState9, 2),
344
- filterVal = _useState0[0],
345
- setFilterVal = _useState0[1];
452
+ var _useState11 = (0, _react.useState)(''),
453
+ _useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
454
+ filterVal = _useState12[0],
455
+ setFilterVal = _useState12[1];
346
456
  function getSelectDisplayText(item) {
347
457
  var displayField = item.displayField || 'value';
348
458
  var getOptionText = function getOptionText(value) {
349
- var _ref2, _option$displayField;
459
+ var _ref4, _option$displayField;
350
460
  var option = (item.options || []).find(function (currentOption) {
351
461
  return currentOption.value === value;
352
462
  });
353
463
  if (!option) return value || '';
354
- return String((_ref2 = (_option$displayField = option[displayField]) !== null && _option$displayField !== void 0 ? _option$displayField : option.value) !== null && _ref2 !== void 0 ? _ref2 : '');
464
+ return String((_ref4 = (_option$displayField = option[displayField]) !== null && _option$displayField !== void 0 ? _option$displayField : option.value) !== null && _ref4 !== void 0 ? _ref4 : '');
355
465
  };
356
466
  if (Array.isArray(item.val)) {
357
467
  return item.val.map(function (currentValue) {
@@ -533,13 +643,13 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
533
643
  setCaseList(nextList);
534
644
  };
535
645
  var getFormulaSqlText = function getFormulaSqlText(result) {
536
- var _ref3, _result$sql;
646
+ var _ref5, _result$sql;
537
647
  if (typeof result === 'string') return result;
538
648
  if (!result) return '';
539
- return String((_ref3 = (_result$sql = result.sql) !== null && _result$sql !== void 0 ? _result$sql : result.code) !== null && _ref3 !== void 0 ? _ref3 : '');
649
+ return String((_ref5 = (_result$sql = result.sql) !== null && _result$sql !== void 0 ? _result$sql : result.code) !== null && _ref5 !== void 0 ? _ref5 : '');
540
650
  };
541
651
  var getFormulaDiffData = function getFormulaDiffData(result) {
542
- var _result$oldCode, _ref4, _result$newCode;
652
+ var _result$oldCode, _ref6, _result$newCode;
543
653
  if (typeof result === 'string') {
544
654
  return {
545
655
  oldCode: '',
@@ -554,7 +664,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
554
664
  }
555
665
  return {
556
666
  oldCode: String((_result$oldCode = result.oldCode) !== null && _result$oldCode !== void 0 ? _result$oldCode : ''),
557
- newCode: String((_ref4 = (_result$newCode = result.newCode) !== null && _result$newCode !== void 0 ? _result$newCode : result.code) !== null && _ref4 !== void 0 ? _ref4 : '')
667
+ newCode: String((_ref6 = (_result$newCode = result.newCode) !== null && _result$newCode !== void 0 ? _result$newCode : result.code) !== null && _ref6 !== void 0 ? _ref6 : '')
558
668
  };
559
669
  };
560
670
  var normalizeFormulaValueForOutput = function normalizeFormulaValueForOutput() {
@@ -569,31 +679,65 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
569
679
  var getInitialFormulaValue = function getInitialFormulaValue() {
570
680
  return (0, _cloneDeep["default"])(normalizeFormulaValueForOutput(initialValueRef.current || []));
571
681
  };
682
+ var parseFormulaSql = (_store$preProps = store.preProps) === null || _store$preProps === void 0 ? void 0 : _store$preProps.parseFormulaSql;
683
+ var resolvedAddSql = onAddSql || (typeof parseFormulaSql === 'function' ? (function () {
684
+ var _ref7 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(sql) {
685
+ var result;
686
+ return _regenerator["default"].wrap(function (_context2) {
687
+ while (1) switch (_context2.prev = _context2.next) {
688
+ case 0:
689
+ _context2.next = 1;
690
+ return parseFormulaSql({
691
+ sql: sql,
692
+ availableTables: data
693
+ });
694
+ case 1:
695
+ result = _context2.sent;
696
+ if (!(!result || !Array.isArray(result.formulaList))) {
697
+ _context2.next = 2;
698
+ break;
699
+ }
700
+ _pandora.Toast.warning((0, _locale.__)('customColumn.sqlParseInvalid'));
701
+ throw new Error('INVALID_FORMULA_SQL_RESULT');
702
+ case 2:
703
+ return _context2.abrupt("return", function () {
704
+ return setCaseList(result.formulaList);
705
+ });
706
+ case 3:
707
+ case "end":
708
+ return _context2.stop();
709
+ }
710
+ }, _callee2);
711
+ }));
712
+ return function (_x) {
713
+ return _ref7.apply(this, arguments);
714
+ };
715
+ }()) : undefined);
572
716
  var showFormulaSql = function () {
573
- var _ref5 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
574
- var result, sql, _t;
575
- return _regenerator["default"].wrap(function (_context) {
576
- while (1) switch (_context.prev = _context.next) {
717
+ var _ref8 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3() {
718
+ var result, sql, _t2;
719
+ return _regenerator["default"].wrap(function (_context3) {
720
+ while (1) switch (_context3.prev = _context3.next) {
577
721
  case 0:
578
722
  if (!(!hasFormulaSqlAction || sqlLoading)) {
579
- _context.next = 1;
723
+ _context3.next = 1;
580
724
  break;
581
725
  }
582
- return _context.abrupt("return");
726
+ return _context3.abrupt("return");
583
727
  case 1:
584
728
  setSqlLoading(true);
585
- _context.prev = 2;
586
- _context.next = 3;
729
+ _context3.prev = 2;
730
+ _context3.next = 3;
587
731
  return store.getFormulaSqlCode(getCurrentFormulaValue());
588
732
  case 3:
589
- result = _context.sent;
733
+ result = _context3.sent;
590
734
  sql = getFormulaSqlText(result);
591
735
  if (sql) {
592
- _context.next = 4;
736
+ _context3.next = 4;
593
737
  break;
594
738
  }
595
739
  _pandora.Toast.warning('暂无可展示的SQL');
596
- return _context.abrupt("return");
740
+ return _context3.abrupt("return");
597
741
  case 4:
598
742
  openChildModal({
599
743
  title: '查看SQL',
@@ -614,54 +758,74 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
614
758
  }),
615
759
  onClose: function onClose() {}
616
760
  });
617
- _context.next = 6;
761
+ _context3.next = 6;
618
762
  break;
619
763
  case 5:
620
- _context.prev = 5;
621
- _t = _context["catch"](2);
764
+ _context3.prev = 5;
765
+ _t2 = _context3["catch"](2);
622
766
  _pandora.Toast.error('获取SQL失败');
623
767
  case 6:
624
- _context.prev = 6;
768
+ _context3.prev = 6;
625
769
  setSqlLoading(false);
626
- return _context.finish(6);
770
+ return _context3.finish(6);
627
771
  case 7:
628
772
  case "end":
629
- return _context.stop();
773
+ return _context3.stop();
630
774
  }
631
- }, _callee, null, [[2, 5, 6, 7]]);
775
+ }, _callee3, null, [[2, 5, 6, 7]]);
632
776
  }));
633
777
  return function showFormulaSql() {
634
- return _ref5.apply(this, arguments);
778
+ return _ref8.apply(this, arguments);
635
779
  };
636
780
  }();
781
+ var showAddSql = function showAddSql() {
782
+ closePopup();
783
+ var modalInstance;
784
+ modalInstance = openChildModal({
785
+ title: (0, _locale.__)('customColumn.addSql'),
786
+ transparentMask: true,
787
+ className: 'Sqb-FormulaSqlImportModal',
788
+ content: (0, _jsxRuntime.jsx)(SqlImportContent, {
789
+ onSubmit: resolvedAddSql,
790
+ onClose: function onClose() {
791
+ var _modalInstance2;
792
+ return (_modalInstance2 = modalInstance) === null || _modalInstance2 === void 0 ? void 0 : _modalInstance2.close();
793
+ },
794
+ matchBrackets: store.matchBrackets
795
+ }),
796
+ modalWidth: 900,
797
+ modalHeight: 600,
798
+ onClose: function onClose() {}
799
+ });
800
+ };
637
801
  var showFormulaDiff = function () {
638
- var _ref6 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2() {
639
- var result, _getFormulaDiffData, oldCode, newCode, _t2;
640
- return _regenerator["default"].wrap(function (_context2) {
641
- while (1) switch (_context2.prev = _context2.next) {
802
+ var _ref9 = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4() {
803
+ var result, _getFormulaDiffData, oldCode, newCode, _t3;
804
+ return _regenerator["default"].wrap(function (_context4) {
805
+ while (1) switch (_context4.prev = _context4.next) {
642
806
  case 0:
643
807
  if (!(!hasFormulaDiffAction || diffLoading)) {
644
- _context2.next = 1;
808
+ _context4.next = 1;
645
809
  break;
646
810
  }
647
- return _context2.abrupt("return");
811
+ return _context4.abrupt("return");
648
812
  case 1:
649
813
  setDiffLoading(true);
650
- _context2.prev = 2;
651
- _context2.next = 3;
814
+ _context4.prev = 2;
815
+ _context4.next = 3;
652
816
  return store.getFormulaDiffCode({
653
817
  oldCode: getInitialFormulaValue(),
654
818
  newCode: getCurrentFormulaValue()
655
819
  });
656
820
  case 3:
657
- result = _context2.sent;
821
+ result = _context4.sent;
658
822
  _getFormulaDiffData = getFormulaDiffData(result), oldCode = _getFormulaDiffData.oldCode, newCode = _getFormulaDiffData.newCode;
659
823
  if (!(!oldCode && !newCode)) {
660
- _context2.next = 4;
824
+ _context4.next = 4;
661
825
  break;
662
826
  }
663
827
  _pandora.Toast.warning('暂无可展示的对比结果');
664
- return _context2.abrupt("return");
828
+ return _context4.abrupt("return");
665
829
  case 4:
666
830
  openChildModal({
667
831
  title: '对比结果',
@@ -672,24 +836,24 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
672
836
  }),
673
837
  onClose: function onClose() {}
674
838
  });
675
- _context2.next = 6;
839
+ _context4.next = 6;
676
840
  break;
677
841
  case 5:
678
- _context2.prev = 5;
679
- _t2 = _context2["catch"](2);
842
+ _context4.prev = 5;
843
+ _t3 = _context4["catch"](2);
680
844
  _pandora.Toast.error('获取对比结果失败');
681
845
  case 6:
682
- _context2.prev = 6;
846
+ _context4.prev = 6;
683
847
  setDiffLoading(false);
684
- return _context2.finish(6);
848
+ return _context4.finish(6);
685
849
  case 7:
686
850
  case "end":
687
- return _context2.stop();
851
+ return _context4.stop();
688
852
  }
689
- }, _callee2, null, [[2, 5, 6, 7]]);
853
+ }, _callee4, null, [[2, 5, 6, 7]]);
690
854
  }));
691
855
  return function showFormulaDiff() {
692
- return _ref6.apply(this, arguments);
856
+ return _ref9.apply(this, arguments);
693
857
  };
694
858
  }();
695
859
  var renderTokenContent = function renderTokenContent(children) {
@@ -704,23 +868,23 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
704
868
  var childModalZIndex = (0, _helperDom.getTopLayerZIndex)() + 1;
705
869
  var modalInstance;
706
870
  var CaseWhenZoomEditor = function CaseWhenZoomEditor() {
707
- var _useState1 = (0, _react.useState)(function () {
871
+ var _useState13 = (0, _react.useState)(function () {
708
872
  return (0, _cloneDeep["default"])(value);
709
873
  }),
710
- _useState10 = (0, _slicedToArray2["default"])(_useState1, 2),
711
- draftValue = _useState10[0],
712
- setDraftValue = _useState10[1];
713
- var _useState11 = (0, _react.useState)(null),
714
- _useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
715
- activeZoomRegionKey = _useState12[0],
716
- setActiveZoomRegionKey = _useState12[1];
874
+ _useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
875
+ draftValue = _useState14[0],
876
+ setDraftValue = _useState14[1];
877
+ var _useState15 = (0, _react.useState)(null),
878
+ _useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
879
+ activeZoomRegionKey = _useState16[0],
880
+ setActiveZoomRegionKey = _useState16[1];
717
881
  var updateDraftValue = function updateDraftValue(nextValue) {
718
882
  setDraftValue(withSyncedQuotes(nextValue));
719
883
  };
720
884
  var handleOk = function handleOk() {
721
- var _modalInstance2, _modalInstance2$close;
885
+ var _modalInstance3, _modalInstance3$close;
722
886
  updateAtomAt(index, (0, _cloneDeep["default"])(draftValue));
723
- (_modalInstance2 = modalInstance) === null || _modalInstance2 === void 0 || (_modalInstance2$close = _modalInstance2.close) === null || _modalInstance2$close === void 0 || _modalInstance2$close.call(_modalInstance2);
887
+ (_modalInstance3 = modalInstance) === null || _modalInstance3 === void 0 || (_modalInstance3$close = _modalInstance3.close) === null || _modalInstance3$close === void 0 || _modalInstance3$close.call(_modalInstance3);
724
888
  };
725
889
  return (0, _jsxRuntime.jsx)(_useProvider.Provider, {
726
890
  value: store,
@@ -836,8 +1000,8 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
836
1000
  className: 'sqb-formula-list-zoom-editor-cancel',
837
1001
  style: ZOOM_FOOTER_CANCEL_STYLE,
838
1002
  onClick: function onClick() {
839
- var _modalInstance3, _modalInstance3$close;
840
- return (_modalInstance3 = modalInstance) === null || _modalInstance3 === void 0 || (_modalInstance3$close = _modalInstance3.close) === null || _modalInstance3$close === void 0 ? void 0 : _modalInstance3$close.call(_modalInstance3);
1003
+ var _modalInstance4, _modalInstance4$close;
1004
+ return (_modalInstance4 = modalInstance) === null || _modalInstance4 === void 0 || (_modalInstance4$close = _modalInstance4.close) === null || _modalInstance4$close === void 0 ? void 0 : _modalInstance4$close.call(_modalInstance4);
841
1005
  },
842
1006
  children: "\u53D6\u6D88"
843
1007
  }), (0, _jsxRuntime.jsx)(_pandora.Button, {
@@ -868,21 +1032,21 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
868
1032
  var childModalZIndex = (0, _helperDom.getTopLayerZIndex)() + 1;
869
1033
  var modalInstance;
870
1034
  var FormulaListZoomEditor = function FormulaListZoomEditor() {
871
- var _useState13 = (0, _react.useState)(function () {
1035
+ var _useState17 = (0, _react.useState)(function () {
872
1036
  return (0, _cloneDeep["default"])(caseList || []);
873
1037
  }),
874
- _useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
875
- draftList = _useState14[0],
876
- setDraftList = _useState14[1];
1038
+ _useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
1039
+ draftList = _useState18[0],
1040
+ setDraftList = _useState18[1];
877
1041
  var updateDraftList = function updateDraftList(nextList) {
878
1042
  setDraftList(nextList.map(function (item) {
879
1043
  return withSyncedQuotes(item);
880
1044
  }));
881
1045
  };
882
1046
  var handleOk = function handleOk() {
883
- var _modalInstance4, _modalInstance4$close;
1047
+ var _modalInstance5, _modalInstance5$close;
884
1048
  setCaseList((0, _cloneDeep["default"])(draftList));
885
- (_modalInstance4 = modalInstance) === null || _modalInstance4 === void 0 || (_modalInstance4$close = _modalInstance4.close) === null || _modalInstance4$close === void 0 || _modalInstance4$close.call(_modalInstance4);
1049
+ (_modalInstance5 = modalInstance) === null || _modalInstance5 === void 0 || (_modalInstance5$close = _modalInstance5.close) === null || _modalInstance5$close === void 0 || _modalInstance5$close.call(_modalInstance5);
886
1050
  };
887
1051
  return (0, _jsxRuntime.jsx)(_useProvider.Provider, {
888
1052
  value: store,
@@ -914,8 +1078,8 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
914
1078
  className: 'sqb-formula-list-zoom-editor-cancel',
915
1079
  style: ZOOM_FOOTER_CANCEL_STYLE,
916
1080
  onClick: function onClick() {
917
- var _modalInstance5, _modalInstance5$close;
918
- return (_modalInstance5 = modalInstance) === null || _modalInstance5 === void 0 || (_modalInstance5$close = _modalInstance5.close) === null || _modalInstance5$close === void 0 ? void 0 : _modalInstance5$close.call(_modalInstance5);
1081
+ var _modalInstance6, _modalInstance6$close;
1082
+ return (_modalInstance6 = modalInstance) === null || _modalInstance6 === void 0 || (_modalInstance6$close = _modalInstance6.close) === null || _modalInstance6$close === void 0 ? void 0 : _modalInstance6$close.call(_modalInstance6);
919
1083
  },
920
1084
  children: "\u53D6\u6D88"
921
1085
  }), (0, _jsxRuntime.jsx)(_pandora.Button, {
@@ -1148,43 +1312,43 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
1148
1312
  }
1149
1313
  });
1150
1314
  };
1151
- var _useState15 = (0, _react.useState)(-1),
1152
- _useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
1153
- ind = _useState16[0],
1154
- setInd = _useState16[1];
1315
+ var _useState19 = (0, _react.useState)(-1),
1316
+ _useState20 = (0, _slicedToArray2["default"])(_useState19, 2),
1317
+ ind = _useState20[0],
1318
+ setInd = _useState20[1];
1155
1319
  var filterCustomType = store.filterCustomType;
1156
1320
  var _ref = (0, _react.useRef)(null);
1157
- var _useState17 = (0, _react.useState)({
1321
+ var _useState21 = (0, _react.useState)({
1158
1322
  isError: false
1159
1323
  }),
1160
- _useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
1161
- errorInfo = _useState18[0],
1162
- setErrorInfo = _useState18[1];
1163
- var _useState19 = (0, _react.useState)(false),
1164
- _useState20 = (0, _slicedToArray2["default"])(_useState19, 2),
1165
- isCheck = _useState20[0],
1166
- setIsCheck = _useState20[1];
1167
- var myInstanceIdRef = (0, _react.useRef)(Math.random().toString(36).slice(2));
1168
- var _useState21 = (0, _react.useState)(null),
1169
1324
  _useState22 = (0, _slicedToArray2["default"])(_useState21, 2),
1170
- hoveredCaseGroupKey = _useState22[0],
1171
- setHoveredCaseGroupKey = _useState22[1];
1172
- var _useState23 = (0, _react.useState)(!!window.__sqb_selection_active__),
1325
+ errorInfo = _useState22[0],
1326
+ setErrorInfo = _useState22[1];
1327
+ var _useState23 = (0, _react.useState)(false),
1173
1328
  _useState24 = (0, _slicedToArray2["default"])(_useState23, 2),
1174
- globalSelectionActive = _useState24[0],
1175
- setGlobalSelectionActive = _useState24[1];
1176
- var _useState25 = (0, _react.useState)(window.__sqb_selection_owner__ || null),
1329
+ isCheck = _useState24[0],
1330
+ setIsCheck = _useState24[1];
1331
+ var myInstanceIdRef = (0, _react.useRef)(Math.random().toString(36).slice(2));
1332
+ var _useState25 = (0, _react.useState)(null),
1177
1333
  _useState26 = (0, _slicedToArray2["default"])(_useState25, 2),
1178
- globalSelectionOwner = _useState26[0],
1179
- setGlobalSelectionOwner = _useState26[1];
1180
- var _useState27 = (0, _react.useState)([]),
1334
+ hoveredCaseGroupKey = _useState26[0],
1335
+ setHoveredCaseGroupKey = _useState26[1];
1336
+ var _useState27 = (0, _react.useState)(!!window.__sqb_selection_active__),
1181
1337
  _useState28 = (0, _slicedToArray2["default"])(_useState27, 2),
1182
- selectedIndices = _useState28[0],
1183
- setSelectedIndices = _useState28[1];
1184
- var _useState29 = (0, _react.useState)(null),
1338
+ globalSelectionActive = _useState28[0],
1339
+ setGlobalSelectionActive = _useState28[1];
1340
+ var _useState29 = (0, _react.useState)(window.__sqb_selection_owner__ || null),
1185
1341
  _useState30 = (0, _slicedToArray2["default"])(_useState29, 2),
1186
- hoveredCopyIndex = _useState30[0],
1187
- setHoveredCopyIndex = _useState30[1];
1342
+ globalSelectionOwner = _useState30[0],
1343
+ setGlobalSelectionOwner = _useState30[1];
1344
+ var _useState31 = (0, _react.useState)([]),
1345
+ _useState32 = (0, _slicedToArray2["default"])(_useState31, 2),
1346
+ selectedIndices = _useState32[0],
1347
+ setSelectedIndices = _useState32[1];
1348
+ var _useState33 = (0, _react.useState)(null),
1349
+ _useState34 = (0, _slicedToArray2["default"])(_useState33, 2),
1350
+ hoveredCopyIndex = _useState34[0],
1351
+ setHoveredCopyIndex = _useState34[1];
1188
1352
  var getCaseGroupEnd = function getCaseGroupEnd(list, startIndex) {
1189
1353
  var depth = 0;
1190
1354
  for (var index = startIndex; index < list.length; index++) {
@@ -1441,6 +1605,11 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
1441
1605
  value: [val],
1442
1606
  theme: _enum.ColumnsPopupThemeEnum.skyBlue,
1443
1607
  readonly: snapshotMode,
1608
+ onValueSync: function onValueSync(fields) {
1609
+ var _caseList = caseList.slice();
1610
+ _caseList[i] = fields[0];
1611
+ setCaseList(_caseList);
1612
+ },
1444
1613
  onSelect: function onSelect(fields) {
1445
1614
  var _caseList = caseList.slice();
1446
1615
  _caseList[i] = fields[0];
@@ -1597,10 +1766,10 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
1597
1766
  title: (0, _locale.__)('metabase.prompt'),
1598
1767
  content: (0, _locale.__)('customColumn.confirmDelete'),
1599
1768
  onOk: function () {
1600
- var _onOk = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3() {
1769
+ var _onOk = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee5() {
1601
1770
  var selectedIndexSet, _caseList;
1602
- return _regenerator["default"].wrap(function (_context3) {
1603
- while (1) switch (_context3.prev = _context3.next) {
1771
+ return _regenerator["default"].wrap(function (_context5) {
1772
+ while (1) switch (_context5.prev = _context5.next) {
1604
1773
  case 0:
1605
1774
  selectedIndexSet = new Set(selectedIndices);
1606
1775
  _caseList = caseList.filter(function (_, index) {
@@ -1610,9 +1779,9 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
1610
1779
  initPaste();
1611
1780
  case 1:
1612
1781
  case "end":
1613
- return _context3.stop();
1782
+ return _context5.stop();
1614
1783
  }
1615
- }, _callee3);
1784
+ }, _callee5);
1616
1785
  }));
1617
1786
  function onOk() {
1618
1787
  return _onOk.apply(this, arguments);
@@ -1713,10 +1882,10 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
1713
1882
  };
1714
1883
  var showNotExists = function showNotExists(i) {
1715
1884
  var _caseList$i, _caseList$i2;
1716
- var _store$preProps = store.preProps,
1717
- notExistsToolbar = _store$preProps.notExistsToolbar,
1718
- toolbar = _store$preProps.toolbar,
1719
- other = (0, _objectWithoutProperties2["default"])(_store$preProps, _excluded2);
1885
+ var _store$preProps2 = store.preProps,
1886
+ notExistsToolbar = _store$preProps2.notExistsToolbar,
1887
+ toolbar = _store$preProps2.toolbar,
1888
+ other = (0, _objectWithoutProperties2["default"])(_store$preProps2, _excluded2);
1720
1889
  var _value = ((_caseList$i = caseList[i]) === null || _caseList$i === void 0 ? void 0 : _caseList$i.notExists) || [];
1721
1890
  var oldList = (0, _cloneDeep["default"])(((_caseList$i2 = caseList[i]) === null || _caseList$i2 === void 0 ? void 0 : _caseList$i2.notExists) || []);
1722
1891
  var childModalZIndex = (0, _helperDom.getTopLayerZIndex)() + 1;
@@ -1758,13 +1927,13 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
1758
1927
  };
1759
1928
  var showSubQuery = function showSubQuery(i) {
1760
1929
  var _caseList$i3, _caseList$i4;
1761
- var _store$preProps2 = store.preProps,
1762
- subToolbar = _store$preProps2.subToolbar,
1763
- notExistsColumns = _store$preProps2.notExistsColumns,
1764
- showFields = _store$preProps2.showFields,
1765
- isExit = _store$preProps2.isExit,
1766
- toolbar = _store$preProps2.toolbar,
1767
- other = (0, _objectWithoutProperties2["default"])(_store$preProps2, _excluded3);
1930
+ var _store$preProps3 = store.preProps,
1931
+ subToolbar = _store$preProps3.subToolbar,
1932
+ notExistsColumns = _store$preProps3.notExistsColumns,
1933
+ showFields = _store$preProps3.showFields,
1934
+ isExit = _store$preProps3.isExit,
1935
+ toolbar = _store$preProps3.toolbar,
1936
+ other = (0, _objectWithoutProperties2["default"])(_store$preProps3, _excluded3);
1768
1937
  var _value = ((_caseList$i3 = caseList[i]) === null || _caseList$i3 === void 0 ? void 0 : _caseList$i3.subQuery) || [];
1769
1938
  var oldList = (0, _cloneDeep["default"])(((_caseList$i4 = caseList[i]) === null || _caseList$i4 === void 0 ? void 0 : _caseList$i4.subQuery) || []);
1770
1939
  var childModalZIndex = (0, _helperDom.getTopLayerZIndex)() + 1;
@@ -2403,6 +2572,12 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
2403
2572
  disabled: diffLoading,
2404
2573
  onClick: showFormulaDiff,
2405
2574
  children: "\u5BF9\u6BD4\u7ED3\u679C"
2575
+ }), (hasFormulaSqlAction || hasFormulaDiffAction) && resolvedAddSql && (0, _jsxRuntime.jsx)(_pandora.Button, {
2576
+ className: 'Sqb-FormulaAddSqlAction',
2577
+ size: 'small',
2578
+ type: 'link',
2579
+ onClick: showAddSql,
2580
+ children: (0, _locale.__)('customColumn.addSql')
2406
2581
  })]
2407
2582
  }), !snapshotMode && (0, _jsxRuntime.jsx)("div", {
2408
2583
  className: 'errorMsg mt-2',