@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,9 @@ var Portal = forwardRef(function (props, ref) {
6
6
  _props$children = props.children,
7
7
  children = _props$children === void 0 ? null : _props$children;
8
8
  var containerRef = useRef();
9
- // Ref return nothing, only for wrapper check exist
10
9
  useImperativeHandle(ref, function () {
11
10
  return {};
12
11
  });
13
- // Create container in client side with sync to avoid useEffect not get ref
14
12
  var initRef = useRef(false);
15
13
  if (!initRef.current) {
16
14
  containerRef.current = getContainer();
@@ -9,9 +9,5 @@ interface SplitViewProps {
9
9
  topMinH?: number;
10
10
  bottomMinH?: number;
11
11
  }
12
- /**
13
- * 先不考虑局部情况,只考虑该组件占据整个浏览器窗口
14
- * @returns React.ReactNode
15
- */
16
12
  declare const SplitView: React.ForwardRefExoticComponent<SplitViewProps & React.RefAttributes<unknown>>;
17
13
  export default SplitView;
@@ -12,10 +12,6 @@ var StyledSashHorizontal = styled.div.attrs({
12
12
  })(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n top: ", ";\n"])), function (props) {
13
13
  return props.top + 'px';
14
14
  });
15
- /**
16
- * 先不考虑局部情况,只考虑该组件占据整个浏览器窗口
17
- * @returns React.ReactNode
18
- */
19
15
  var SplitView = React.forwardRef(function (props, ref) {
20
16
  var _props$direction = props.direction,
21
17
  direction = _props$direction === void 0 ? 'vertical' : _props$direction,
@@ -79,7 +75,6 @@ var SplitView = React.forwardRef(function (props, ref) {
79
75
  setSashClicked(true);
80
76
  }
81
77
  var onMouseMove = useCallback(function (e) {
82
- // 按下
83
78
  if (sashClicked) {
84
79
  var x = e.clientX || e.pageX;
85
80
  var y = e.clientY || e.pageY;
@@ -138,13 +133,9 @@ var SplitView = React.forwardRef(function (props, ref) {
138
133
  return _jsxs("div", {
139
134
  className: cx('split-view-container', {
140
135
  'sash-horizontal': sashClicked,
141
- // 'sash-vertical': sashClicked,
142
136
  'h-center': !vMinimum && !vMaximum,
143
137
  'h-minimum': vMinimum,
144
138
  'h-maximum': vMaximum
145
- // 'v-center': !vMinimum && !vMaximum,
146
- // 'v-minimum': vMinimum,
147
- // 'v-maximum': vMaximum,
148
139
  }),
149
140
  onMouseUp: onMouseUp,
150
141
  onMouseMove: onMouseMove,
@@ -152,7 +143,6 @@ var SplitView = React.forwardRef(function (props, ref) {
152
143
  className: 'sash-container',
153
144
  children: _jsx(StyledSashHorizontal, {
154
145
  top: sashY - 2,
155
- // @ts-ignore
156
146
  className: cx({
157
147
  active: sashClicked
158
148
  }),
@@ -1,39 +1,23 @@
1
1
  import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- // @ts-nocheck
4
3
  export var DISPLAY_QUOTES = {
5
4
  identifierQuoteDefault: '',
6
5
  literalQuoteDefault: ''
7
6
  };
8
7
  export var EDITOR_QUOTES = {
9
- // specifies where different quoting is used:
10
8
  characters: {
11
9
  '[': 'identifier',
12
10
  "'": 'literal',
13
11
  '"': 'literal'
14
12
  },
15
- // specifies the default quoting style:
16
13
  literalQuoteDefault: '"',
17
14
  identifierQuoteDefault: '[',
18
- // always quote identifiers even if they have non-word characters or conflict with reserved words
19
15
  identifierAlwaysQuoted: true
20
16
  };
21
- // export const EDITOR_QUOTES = {
22
- // characters: {
23
- // "'": "literal",
24
- // '"': "identifier",
25
- // },
26
- // literalQuoteDefault: "'",
27
- // identifierQuoteDefault: '"',
28
- // identifierAlwaysQuoted: false,
29
- // };
30
17
  export var EDITOR_FK_SYMBOLS = {
31
- // specifies which symbols can be used to delimit foreign/joined fields
32
18
  symbols: ['.', ' → '],
33
- // specifies the default/canonical symbol
34
19
  "default": ' → '
35
20
  };
36
- // copied relevant parts from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence
37
21
  export var OPERATOR_PRECEDENCE = {
38
22
  not: 17,
39
23
  '*': 15,
@@ -45,7 +29,6 @@ export var OPERATOR_PRECEDENCE = {
45
29
  };
46
30
  export var EXPRESSION_TYPES = ['expression', 'aggregation', 'boolean', 'string', 'number'];
47
31
  export var EXPRESSION_SUBTYPES = {
48
- // can't currently add "boolean" as a subtype of expression due to conflict between segments and fields
49
32
  expression: new Set(['string', 'number'])
50
33
  };
51
34
  export var isExpressionType = function isExpressionType(typeA, typeB) {
@@ -55,7 +38,6 @@ export function getFunctionArgType(clause, index) {
55
38
  return clause.multiple ? clause.args[0] : clause.args[index];
56
39
  }
57
40
  export var MBQL_CLAUSES = {
58
- // aggregation functions
59
41
  count: {
60
42
  displayName: "Count",
61
43
  type: 'aggregation',
@@ -135,7 +117,6 @@ export var MBQL_CLAUSES = {
135
117
  args: ['number', 'number'],
136
118
  requiresFeature: 'percentile-aggregations'
137
119
  },
138
- // string functions
139
120
  lower: {
140
121
  displayName: "lower",
141
122
  type: 'string',
@@ -188,7 +169,6 @@ export var MBQL_CLAUSES = {
188
169
  type: 'string',
189
170
  args: ['string']
190
171
  },
191
- // numeric functions
192
172
  abs: {
193
173
  displayName: "abs",
194
174
  type: 'number',
@@ -237,7 +217,6 @@ export var MBQL_CLAUSES = {
237
217
  args: ['number'],
238
218
  requiresFeature: 'advanced-math-expressions'
239
219
  },
240
- // boolean functions
241
220
  contains: {
242
221
  displayName: "contains",
243
222
  type: 'boolean',
@@ -276,7 +255,6 @@ export var MBQL_CLAUSES = {
276
255
  type: 'boolean',
277
256
  args: ['expression']
278
257
  },
279
- // other expression functions
280
258
  coalesce: {
281
259
  displayName: "coalesce",
282
260
  type: 'expression',
@@ -287,10 +265,8 @@ export var MBQL_CLAUSES = {
287
265
  displayName: "case",
288
266
  type: 'expression',
289
267
  args: ['expression', 'expression'],
290
- // ideally we'd alternate boolean/expression
291
268
  multiple: true
292
269
  },
293
- // boolean operators
294
270
  and: {
295
271
  displayName: "AND",
296
272
  type: 'boolean',
@@ -306,7 +282,6 @@ export var MBQL_CLAUSES = {
306
282
  type: 'boolean',
307
283
  args: ['boolean']
308
284
  },
309
- // numeric operators
310
285
  '*': {
311
286
  displayName: '*',
312
287
  tokenName: 'Multi',
@@ -331,7 +306,6 @@ export var MBQL_CLAUSES = {
331
306
  type: 'number',
332
307
  args: ['number', 'number']
333
308
  },
334
- // comparison operators
335
309
  '!=': {
336
310
  displayName: '!=',
337
311
  tokenName: 'NotEqual',
@@ -373,12 +347,9 @@ for (var _i = 0, _Object$entries = Object.entries(MBQL_CLAUSES); _i < _Object$en
373
347
  var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
374
348
  name = _Object$entries$_i[0],
375
349
  clause = _Object$entries$_i[1];
376
- if (clause.name !== undefined && clause.name !== name) {
377
- console.warn('Mismatched name for MBQL_CLAUSES ' + name);
378
- }
350
+ if (clause.name !== undefined && clause.name !== name) {}
379
351
  clause.name = name;
380
352
  }
381
- // Reserved token names
382
353
  var MBQL_TO_EXPRESSION_NAME = new Map(Object.entries(MBQL_CLAUSES).map(function (_ref) {
383
354
  var _ref2 = _slicedToArray(_ref, 2),
384
355
  mbql = _ref2[0],
@@ -389,29 +360,16 @@ var EXPRESSION_TO_MBQL_NAME = new Map(Object.entries(MBQL_CLAUSES).map(function
389
360
  var _ref4 = _slicedToArray(_ref3, 2),
390
361
  mbql = _ref4[0],
391
362
  displayName = _ref4[1].displayName;
392
- return [
393
- // case-insensitive
394
- displayName.toLowerCase(), mbql];
363
+ return [displayName.toLowerCase(), mbql];
395
364
  }));
396
365
  export function getExpressionName(mbqlName) {
397
366
  return MBQL_TO_EXPRESSION_NAME.get(mbqlName);
398
367
  }
399
368
  export function getMBQLName(expressionName) {
400
- // case-insensitive
401
369
  return EXPRESSION_TO_MBQL_NAME.get(expressionName.toLowerCase());
402
370
  }
403
- export var AGGREGATION_FUNCTIONS = new Set([
404
- // count-where/sum-where must come before count/sum
405
- 'count-where', 'sum-where', 'count', 'cum-count', 'sum', 'cum-sum', 'distinct', 'stddev', 'avg', 'min', 'max', 'share', 'var', 'median', 'percentile']);
406
- export var EXPRESSION_FUNCTIONS = new Set([
407
- // string
408
- 'lower', 'upper', 'substring', 'regex-match-first', 'concat', 'replace', 'trim', 'rtrim', 'ltrim', 'length',
409
- // number
410
- 'abs', 'floor', 'ceil', 'round', 'sqrt', 'power', 'log', 'exp',
411
- // boolean
412
- 'contains', 'ends-with', 'starts-with', 'between', 'time-interval', 'is-null', 'is-empty',
413
- // other
414
- 'coalesce']);
371
+ export var AGGREGATION_FUNCTIONS = new Set(['count-where', 'sum-where', 'count', 'cum-count', 'sum', 'cum-sum', 'distinct', 'stddev', 'avg', 'min', 'max', 'share', 'var', 'median', 'percentile']);
372
+ export var EXPRESSION_FUNCTIONS = new Set(['lower', 'upper', 'substring', 'regex-match-first', 'concat', 'replace', 'trim', 'rtrim', 'ltrim', 'length', 'abs', 'floor', 'ceil', 'round', 'sqrt', 'power', 'log', 'exp', 'contains', 'ends-with', 'starts-with', 'between', 'time-interval', 'is-null', 'is-empty', 'coalesce']);
415
373
  export var EXPRESSION_OPERATORS = new Set(['+', '-', '*', '/']);
416
374
  export var FILTER_OPERATORS = new Set(['!=', '<=', '>=', '<', '>', '=']);
417
375
  export var BOOLEAN_UNARY_OPERATORS = new Set(['not']);
@@ -419,7 +377,5 @@ export var LOGICAL_AND_OPERATOR = new Set(['and']);
419
377
  export var LOGICAL_OR_OPERATOR = new Set(['or']);
420
378
  export var FUNCTIONS = new Set([].concat(_toConsumableArray(EXPRESSION_FUNCTIONS), _toConsumableArray(AGGREGATION_FUNCTIONS)));
421
379
  export var OPERATORS = new Set([].concat(_toConsumableArray(EXPRESSION_OPERATORS), _toConsumableArray(FILTER_OPERATORS), _toConsumableArray(BOOLEAN_UNARY_OPERATORS), _toConsumableArray(LOGICAL_AND_OPERATOR), _toConsumableArray(LOGICAL_OR_OPERATOR)));
422
- // "standard" filters, can be edited using UI
423
380
  export var STANDARD_FILTERS = new Set(['!=', '<=', '>=', '<', '>', '=', 'contains', 'does-not-contain', 'ends-with', 'starts-with', 'between', 'time-interval', 'is-null', 'not-null', 'is-empty', 'not-empty', 'inside']);
424
- // "standard" aggregations, can be edited using UI
425
381
  export var STANDARD_AGGREGATIONS = new Set(['count', 'cum-count', 'sum', 'cum-sum', 'distinct', 'stddev', 'avg', 'min', 'max']);
@@ -29,7 +29,7 @@ var ExpressionEditor = function ExpressionEditor(props) {
29
29
  }),
30
30
  _useState2 = _slicedToArray(_useState, 2),
31
31
  popup = _useState2[0],
32
- setPopup = _useState2[1]; // 弹框信息
32
+ setPopup = _useState2[1];
33
33
  var input = useRef(null);
34
34
  var _useState3 = useState(expression),
35
35
  _useState4 = _slicedToArray(_useState3, 2),
@@ -38,7 +38,7 @@ var ExpressionEditor = function ExpressionEditor(props) {
38
38
  var _useState5 = useState(''),
39
39
  _useState6 = _slicedToArray(_useState5, 2),
40
40
  errorMessage = _useState6[0],
41
- setErrorMessage = _useState6[1]; // 报错信息 'Unknown Field: a'
41
+ setErrorMessage = _useState6[1];
42
42
  var _useState7 = useState(false),
43
43
  _useState8 = _slicedToArray(_useState7, 2),
44
44
  error = _useState8[0],
@@ -62,7 +62,6 @@ var ExpressionEditor = function ExpressionEditor(props) {
62
62
  });
63
63
  store.setClosable(true);
64
64
  }
65
- // 设置关闭位置
66
65
  function _setCaretPosition(position, autosuggest) {
67
66
  setCaretPosition(input.current, position);
68
67
  if (autosuggest) {
@@ -71,7 +70,6 @@ var ExpressionEditor = function ExpressionEditor(props) {
71
70
  });
72
71
  }
73
72
  }
74
- // 根据当前光标位置判断弹出框内容
75
73
  function onExpressionChange(source) {
76
74
  var inputElement = input.current;
77
75
  if (!inputElement) return;
@@ -83,7 +81,7 @@ var ExpressionEditor = function ExpressionEditor(props) {
83
81
  selectionEnd = _getSelectionPosition2[1];
84
82
  var hasSelection = selectionStart !== selectionEnd;
85
83
  var targetOffset = !hasSelection ? selectionEnd : null;
86
- if (targetOffset === null) return void 0; // 框选
84
+ if (targetOffset === null) return void 0;
87
85
  setCaretPosition(input.current, selectionStart);
88
86
  var popupInfo = suggest.choosePopup({
89
87
  source: source,
@@ -108,11 +106,9 @@ var ExpressionEditor = function ExpressionEditor(props) {
108
106
  if (matchPrefix && !/^\[.*\]$/.test(matchPrefix)) {
109
107
  partialSource = partialSource.slice(0, -matchPrefix.length);
110
108
  }
111
- // 去掉后面空格
112
109
  if (/.*\s$/.test(partialSource)) {
113
110
  partialSource = partialSource.slice(0, -1);
114
111
  }
115
- // 去掉前面空格
116
112
  if (/^\s.*/.test(leftoverSource)) {
117
113
  leftoverSource = leftoverSource.slice(1);
118
114
  }
@@ -152,7 +148,6 @@ var ExpressionEditor = function ExpressionEditor(props) {
152
148
  });
153
149
  store.setClosable(false);
154
150
  }
155
- // 键盘点击 方向键 & 回车 & esc
156
151
  function onInputKeyDown(e) {
157
152
  if (e.keyCode === KEYCODE_LEFT || e.keyCode === KEYCODE_RIGHT) {
158
153
  setTimeout(function () {
@@ -174,15 +169,11 @@ var ExpressionEditor = function ExpressionEditor(props) {
174
169
  e.preventDefault();
175
170
  }
176
171
  }
177
- // TODO 校验公式待完成
178
172
  function checkExpression(expression) {
179
- // let _expression = expression.replace(/\s/g, '');
180
173
  return [true];
181
174
  }
182
- // 失去焦点 检查语法错误情况,并将表达式传给父级
183
175
  function onInputBlur(e) {
184
176
  if (e.target === document.activeElement) {
185
- // `Invalid expression`
186
177
  return;
187
178
  }
188
179
  var _checkExpression = checkExpression(source),
@@ -193,11 +184,9 @@ var ExpressionEditor = function ExpressionEditor(props) {
193
184
  props.onChange(source);
194
185
  setErrorMessage('');
195
186
  } else {
196
- // props.onError(errorMessage);
197
187
  setErrorMessage(errorMessage);
198
188
  }
199
189
  }
200
- // 计算当前是否弹框,和弹框内容
201
190
  function _triggerAutosuggest() {
202
191
  onExpressionChange(source);
203
192
  }
@@ -7,8 +7,8 @@ export declare enum OptionsTypeEnum {
7
7
  OTHER = "other"
8
8
  }
9
9
  export declare enum SelectPopupTypeEnum {
10
- FUNCTION_DESC = "function_desc",// 弹函数描述提示框
11
- SELECT_LIST = "select_list",// 弹select下拉框
10
+ FUNCTION_DESC = "function_desc",
11
+ SELECT_LIST = "select_list",
12
12
  EMPTY = "empty"
13
13
  }
14
14
  type SelectPopup = {
@@ -29,38 +29,6 @@ interface ChoosePopupType {
29
29
  fields: MetaData_ColumnsType[];
30
30
  }
31
31
  declare class Suggest {
32
- /**
33
- * 主要是看光标前面是什么
34
- * 1、主动识别的有
35
- * 1)字段
36
- * ① 光标在[]中间 筛选只能在表字段列表筛选 如果没有匹配 则不显示弹框
37
- * ② 光标在]后面 显示运算符
38
- * ③ 光标在[前面 不用理
39
- * 2)字符串
40
- * ① 光标在字符串中间 筛选 函数、表字段
41
- * ② 光标在字符串后面 如果有匹配同上面① 如果没匹配 则不显示弹框
42
- * ③ 光标在字符串前面 不用理
43
- * 3)函数
44
- * ① 点函数名 筛选 函数、表字段
45
- * ② 函数括号里面 如果光标前面是(,或者后面是)提示函数详情
46
- * ③ 在)后面,显示运算符
47
- * ④ 在函数名前面 不用理会
48
- * 4)括号
49
- * ① 光标在(后面 显示所有函数、表字段
50
- * ① 光标在)后面 显示运算符弹框
51
- * ② 光标在(前面 或者在)前面 都不用理会
52
- * 5)运算符
53
- * ① 光标在前面显示运算符弹框
54
- * ② 光标在后面显示所有函数、表字段
55
- * 6)起点
56
- * ① 显示所有函数、表字段
57
- *
58
- * 2、不识别的有
59
- * 1)"aaa" 双引号字符串里面的 都不提示
60
- * 2)1234 数字里面
61
- * 3)前面包含特殊符号 ! @ ...
62
- *
63
- */
64
32
  choosePopup({ source, targetOffset, fields }: ChoosePopupType): ChoosePopupResultType;
65
33
  }
66
34
  declare const _default: Suggest;
@@ -18,67 +18,29 @@ export var SelectPopupTypeEnum;
18
18
  SelectPopupTypeEnum["EMPTY"] = "empty";
19
19
  })(SelectPopupTypeEnum || (SelectPopupTypeEnum = {}));
20
20
  var Operator = ['*', '+', '-', '/'];
21
- var Suggest = /*#__PURE__*/function () {
21
+ var Suggest = function () {
22
22
  function Suggest() {
23
23
  _classCallCheck(this, Suggest);
24
24
  }
25
25
  return _createClass(Suggest, [{
26
26
  key: "choosePopup",
27
- value:
28
- /**
29
- * 主要是看光标前面是什么
30
- * 1、主动识别的有
31
- * 1)字段
32
- * ① 光标在[]中间 筛选只能在表字段列表筛选 如果没有匹配 则不显示弹框
33
- * ② 光标在]后面 显示运算符
34
- * ③ 光标在[前面 不用理
35
- * 2)字符串
36
- * ① 光标在字符串中间 筛选 函数、表字段
37
- * ② 光标在字符串后面 如果有匹配同上面① 如果没匹配 则不显示弹框
38
- * ③ 光标在字符串前面 不用理
39
- * 3)函数
40
- * ① 点函数名 筛选 函数、表字段
41
- * ② 函数括号里面 如果光标前面是(,或者后面是)提示函数详情
42
- * ③ 在)后面,显示运算符
43
- * ④ 在函数名前面 不用理会
44
- * 4)括号
45
- * ① 光标在(后面 显示所有函数、表字段
46
- * ① 光标在)后面 显示运算符弹框
47
- * ② 光标在(前面 或者在)前面 都不用理会
48
- * 5)运算符
49
- * ① 光标在前面显示运算符弹框
50
- * ② 光标在后面显示所有函数、表字段
51
- * 6)起点
52
- * ① 显示所有函数、表字段
53
- *
54
- * 2、不识别的有
55
- * 1)"aaa" 双引号字符串里面的 都不提示
56
- * 2)1234 数字里面
57
- * 3)前面包含特殊符号 ! @ ...
58
- *
59
- */
60
- // [ID] + power([ID], 2) * ([ID] - [ID]) + 123 + aaa
61
- function choosePopup(_ref) {
27
+ value: function choosePopup(_ref) {
62
28
  var source = _ref.source,
63
29
  targetOffset = _ref.targetOffset,
64
30
  fields = _ref.fields;
65
31
  var partialSource = source.slice(0, targetOffset);
66
- // matchPrefix 只匹配 字符串 如:字段[id]、函数abs、字符串 aaa 其他都返回null,如果字符串外面“有双引号” 也是null
67
32
  var matchPrefix = partialMatch(partialSource);
68
33
  var _fields = fields.map(function (v) {
69
34
  return v.name;
70
35
  });
71
- // ① 没有匹配到 或者匹配到字段的
72
36
  if (!matchPrefix || _.last(matchPrefix) === ']') {
73
37
  var functionDisplayName = enclosingFunction(partialSource);
74
- // 匹配到在函数里面
75
38
  if (functionDisplayName) {
76
39
  return {
77
40
  type: SelectPopupTypeEnum.FUNCTION_DESC,
78
41
  functionName: functionDisplayName
79
42
  };
80
43
  }
81
- // 匹配到是字段后面
82
44
  if (matchPrefix && _.last(matchPrefix) === ']') {
83
45
  return {
84
46
  type: SelectPopupTypeEnum.SELECT_LIST,
@@ -89,7 +51,6 @@ var Suggest = /*#__PURE__*/function () {
89
51
  }]
90
52
  };
91
53
  }
92
- // 没有匹配到
93
54
  if (!matchPrefix) {
94
55
  var _partialSource = partialSource.replace(/\s/g, '');
95
56
  var prevStr = _partialSource.substr(-1);
@@ -128,7 +89,6 @@ var Suggest = /*#__PURE__*/function () {
128
89
  var funcList = Object.keys(functions).filter(function (v) {
129
90
  return v.includes(matchPrefix);
130
91
  });
131
- // ② 匹配到前面是字符串
132
92
  if (_.first(matchPrefix) !== '[') {
133
93
  var data = [];
134
94
  fieldList.length && data.push({
@@ -151,7 +111,6 @@ var Suggest = /*#__PURE__*/function () {
151
111
  fieldList = _fields.filter(function (v) {
152
112
  return v.includes(matchPrefix.substr(1));
153
113
  });
154
- // ③ 匹配到前面是字段
155
114
  if (_.first(matchPrefix) === '[') {
156
115
  if (fieldList.length) {
157
116
  return {
@@ -2,7 +2,6 @@ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutPr
2
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
3
3
  var _excluded = ["error"];
4
4
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
5
- // @ts-nocheck
6
5
  var t = function t(msg) {
7
6
  return msg;
8
7
  };
@@ -35,64 +34,14 @@ export function tokenize(expression) {
35
34
  var length = expression.length;
36
35
  var index = 0;
37
36
  var isWhiteSpace = function isWhiteSpace(cp) {
38
- return cp === 0x0009 ||
39
- // tab
40
- cp === 0x000a ||
41
- // line feed
42
- cp === 0x000b ||
43
- // vertical tab
44
- cp === 0x000c ||
45
- // form feed
46
- cp === 0x000d ||
47
- // carriage return
48
- cp === 0x0020 ||
49
- // space
50
- cp === 0x0085 ||
51
- // next line
52
- cp === 0x00a0 ||
53
- // non-breking space
54
- cp === 0x1680 ||
55
- // ogham space
56
- cp === 0x2000 ||
57
- // en quad
58
- cp === 0x2001 ||
59
- // em quad
60
- cp === 0x2002 ||
61
- // en space
62
- cp === 0x2003 ||
63
- // em space
64
- cp === 0x2004 ||
65
- // third em space
66
- cp === 0x2005 ||
67
- // fourth em space
68
- cp === 0x2006 ||
69
- // sixth em space
70
- cp === 0x2007 ||
71
- // figure space
72
- cp === 0x2008 ||
73
- // punctuation space
74
- cp === 0x2009 ||
75
- // thin space
76
- cp === 0x200a ||
77
- // hair space
78
- cp === 0x2028 ||
79
- // line separator
80
- cp === 0x2029 ||
81
- // paragraph separator
82
- cp === 0x202f ||
83
- // no break narrow space
84
- cp === 0x205f ||
85
- // four-eighteenths em space
86
- cp === 0x3000;
87
- }; // cjk language space
37
+ return cp === 0x0009 || cp === 0x000a || cp === 0x000b || cp === 0x000c || cp === 0x000d || cp === 0x0020 || cp === 0x0085 || cp === 0x00a0 || cp === 0x1680 || cp === 0x2000 || cp === 0x2001 || cp === 0x2002 || cp === 0x2003 || cp === 0x2004 || cp === 0x2005 || cp === 0x2006 || cp === 0x2007 || cp === 0x2008 || cp === 0x2009 || cp === 0x200a || cp === 0x2028 || cp === 0x2029 || cp === 0x202f || cp === 0x205f || cp === 0x3000;
38
+ };
88
39
  var isDigit = function isDigit(cp) {
89
40
  return cp >= 0x30 && cp <= 0x39;
90
- }; // 0..9
41
+ };
91
42
  var isAlpha = function isAlpha(cp) {
92
- return cp >= 0x41 && cp <= 0x5a ||
93
- // A..Z
94
- cp >= 0x61 && cp <= 0x7a;
95
- }; // a..z
43
+ return cp >= 0x41 && cp <= 0x5a || cp >= 0x61 && cp <= 0x7a;
44
+ };
96
45
  var skipWhitespaces = function skipWhitespaces() {
97
46
  while (index < length) {
98
47
  var cp = source.charCodeAt(index);
@@ -120,14 +69,11 @@ export function tokenize(expression) {
120
69
  case OPERATOR.GreaterThan:
121
70
  ++index;
122
71
  if (source[index] === OPERATOR.Equal) {
123
- // OPERATOR.LessThanEqual (<=) or
124
- // OPERATOR.GreaterThanEqual (>=)
125
72
  ++index;
126
73
  }
127
74
  break;
128
75
  case '!':
129
76
  if (source[start + 1] === OPERATOR.Equal) {
130
- // OPERATOR.NotEqual (!=)
131
77
  index += 2;
132
78
  }
133
79
  break;
@@ -286,7 +232,6 @@ export function tokenize(expression) {
286
232
  error: _error2
287
233
  };
288
234
  } else if (ch === '\\') {
289
- // ignore the next char, even if it's [ or ]
290
235
  index++;
291
236
  }
292
237
  }
@@ -303,12 +248,10 @@ export function tokenize(expression) {
303
248
  };
304
249
  var isIdentifierStart = function isIdentifierStart(cp) {
305
250
  return isAlpha(cp) || cp === 0x5f;
306
- }; // underscore;
251
+ };
307
252
  var isIdentifierChar = function isIdentifierChar(cp) {
308
- return isAlpha(cp) || isDigit(cp) || cp === 0x2e ||
309
- // dot
310
- cp === 0x5f;
311
- }; // underscore
253
+ return isAlpha(cp) || isDigit(cp) || cp === 0x2e || cp === 0x5f;
254
+ };
312
255
  var scanIdentifier = function scanIdentifier() {
313
256
  var start = index;
314
257
  var initial = source.charCodeAt(start);
@@ -7,7 +7,6 @@ import cx from 'classnames';
7
7
  import { __ } from '../../../locale';
8
8
  import ExpressionEditor from './expression-editor';
9
9
  var WIDTH = 480;
10
- // 自定义列
11
10
  var CustomColumn = function CustomColumn(_ref) {
12
11
  var value = _ref.value,
13
12
  _ref$data = _ref.data,
@@ -18,13 +17,12 @@ var CustomColumn = function CustomColumn(_ref) {
18
17
  var _useState = useState((value === null || value === void 0 ? void 0 : value.name) || ''),
19
18
  _useState2 = _slicedToArray(_useState, 2),
20
19
  name = _useState2[0],
21
- setName = _useState2[1]; // 表达式名字
20
+ setName = _useState2[1];
22
21
  var _useState3 = useState(''),
23
22
  _useState4 = _slicedToArray(_useState3, 2),
24
23
  expression = _useState4[0],
25
- setExpression = _useState4[1]; // 表达式
24
+ setExpression = _useState4[1];
26
25
  var isUpdate = !!value;
27
- // 提交按钮是否可用
28
26
  var usable = useMemo(function () {
29
27
  return expression && name;
30
28
  }, [expression, name]);
@@ -6,7 +6,6 @@ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
6
6
  import _inherits from "@babel/runtime/helpers/esm/inherits";
7
7
  function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
8
8
  import { jsx as _jsx } from "react/jsx-runtime";
9
- /* eslint-disable react/prop-types */
10
9
  import React from 'react';
11
10
  import './tokenized-expression.less';
12
11
  import cx from 'classnames';
@@ -23,7 +22,6 @@ function mapTokenType(token) {
23
22
  case TOKEN.String:
24
23
  return 'string-literal';
25
24
  case TOKEN.Identifier:
26
- // FIXME metric vs dimension vs segment
27
25
  return 'dimension';
28
26
  default:
29
27
  return 'token';
@@ -62,7 +60,7 @@ function createSpans(source) {
62
60
  }
63
61
  return spans;
64
62
  }
65
- var TokenizedExpression = /*#__PURE__*/function (_React$Component) {
63
+ var TokenizedExpression = function (_React$Component) {
66
64
  function TokenizedExpression() {
67
65
  _classCallCheck(this, TokenizedExpression);
68
66
  return _callSuper(this, TokenizedExpression, arguments);
@@ -13,7 +13,7 @@ import ReactDOM from 'react-dom';
13
13
  import ReactDOMServer from 'react-dom/server';
14
14
  import { getCaretPosition, saveSelection } from '../../../utils/selection';
15
15
  import TokenizedExpression from './tokenized-expression';
16
- var TokenizedInput = /*#__PURE__*/function (_React$Component) {
16
+ var TokenizedInput = function (_React$Component) {
17
17
  function TokenizedInput() {
18
18
  var _this;
19
19
  _classCallCheck(this, TokenizedInput);
@@ -9,9 +9,7 @@ import './index.less';
9
9
  import FormulaList from '../formula-list';
10
10
  import { isOk } from '../formula-list/utils';
11
11
  import { __ } from '../../../locale';
12
- // import { getTemplate } from './utils';
13
12
  import Styled from 'styled-components';
14
- // import { OptionsTypeEnum, customTypes, otherList, operatorList, functionList } from './enum';
15
13
  import { FormulaTypeEnum } from '../../../store/types';
16
14
  import { Input, Toast } from '@gingkoo/pandora';
17
15
  import { isValidSQLAlias } from '../../../utils';
@@ -27,7 +25,6 @@ var CaseEditor = function CaseEditor(props) {
27
25
  onOk = props.onOk,
28
26
  onCancel = props.onCancel;
29
27
  var store = useStore();
30
- // const [popup, setPopup] = useState<PopupType>({ visible: false }); // 弹框信息
31
28
  var _useState = useState(value.formulaList || []),
32
29
  _useState2 = _slicedToArray(_useState, 2),
33
30
  caseList = _useState2[0],
@@ -35,17 +32,14 @@ var CaseEditor = function CaseEditor(props) {
35
32
  var _useState3 = useState((value === null || value === void 0 ? void 0 : value.name) || ''),
36
33
  _useState4 = _slicedToArray(_useState3, 2),
37
34
  name = _useState4[0],
38
- setName = _useState4[1]; // 表达式名字
35
+ setName = _useState4[1];
39
36
  var ref = useRef(null);
40
- // 提交按钮是否可用
41
37
  var usable = useMemo(function () {
42
38
  return isOk(caseList) && name;
43
39
  }, [caseList, name]);
44
- // 取消
45
40
  var _onClose = function _onClose() {
46
41
  onCancel === null || onCancel === void 0 || onCancel();
47
42
  };
48
- // 确定
49
43
  var _onOk = function _onOk() {
50
44
  if (!isValidSQLAlias(name)) {
51
45
  Toast.warning(__('SqlQueryBuilder.nameForRules'));