@gingkoo/pandora-metabase 1.0.22 → 1.0.24

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 (58) hide show
  1. package/lib/cjs/components/dialog/custom-editor/index.js +2 -2
  2. package/lib/cjs/components/dialog/expression/index.js +1 -1
  3. package/lib/cjs/components/dialog/formula/index.d.ts +10 -0
  4. package/lib/cjs/components/dialog/formula/index.js +242 -0
  5. package/lib/cjs/components/dialog/formula/index.less +81 -0
  6. package/lib/cjs/components/dialog/formula/utils.d.ts +7 -0
  7. package/lib/cjs/components/dialog/formula/utils.js +45 -0
  8. package/lib/cjs/components/dialog/formula-list/index.d.ts +2 -2
  9. package/lib/cjs/components/dialog/formula-list/index.js +87 -29
  10. package/lib/cjs/components/dialog/formula-list/utils.d.ts +14 -1
  11. package/lib/cjs/components/dialog/formula-list/utils.js +159 -2
  12. package/lib/cjs/components/metabase/index.less +1 -0
  13. package/lib/cjs/components/modules/enum/filter-enum.d.ts +7 -2
  14. package/lib/cjs/components/modules/enum/filter-enum.js +8 -2
  15. package/lib/cjs/components/modules/join-data.js +27 -2
  16. package/lib/cjs/hooks/patch.js +81 -79
  17. package/lib/cjs/hooks/use-state.js +33 -27
  18. package/lib/cjs/index.js +3 -1
  19. package/lib/cjs/locale/en.js +4 -2
  20. package/lib/cjs/locale/zh.js +4 -2
  21. package/lib/cjs/store/helper.d.ts +1 -2
  22. package/lib/cjs/store/helper.js +1 -76
  23. package/lib/cjs/store/types.d.ts +36 -2
  24. package/lib/cjs/store/types.js +3 -0
  25. package/lib/cjs/types.d.ts +2 -1
  26. package/lib/cjs/utils.js +2 -1
  27. package/lib/es/components/dialog/custom-editor/index.js +2 -2
  28. package/lib/es/components/dialog/expression/index.js +1 -1
  29. package/lib/es/components/dialog/formula/index.d.ts +10 -0
  30. package/lib/es/components/dialog/formula/index.js +236 -0
  31. package/lib/es/components/dialog/formula/index.less +81 -0
  32. package/lib/es/components/dialog/formula/utils.d.ts +7 -0
  33. package/lib/es/components/dialog/formula/utils.js +37 -0
  34. package/lib/es/components/dialog/formula-list/index.d.ts +2 -2
  35. package/lib/es/components/dialog/formula-list/index.js +84 -26
  36. package/lib/es/components/dialog/formula-list/utils.d.ts +14 -1
  37. package/lib/es/components/dialog/formula-list/utils.js +160 -2
  38. package/lib/es/components/metabase/index.less +1 -0
  39. package/lib/es/components/modules/enum/filter-enum.d.ts +7 -2
  40. package/lib/es/components/modules/enum/filter-enum.js +8 -2
  41. package/lib/es/components/modules/join-data.js +27 -2
  42. package/lib/es/hooks/patch.js +81 -79
  43. package/lib/es/hooks/use-state.js +33 -27
  44. package/lib/es/index.js +3 -1
  45. package/lib/es/locale/en.js +4 -2
  46. package/lib/es/locale/zh.js +4 -2
  47. package/lib/es/store/helper.d.ts +1 -2
  48. package/lib/es/store/helper.js +0 -75
  49. package/lib/es/store/types.d.ts +36 -2
  50. package/lib/es/store/types.js +3 -0
  51. package/lib/es/types.d.ts +2 -1
  52. package/lib/es/types.js +18 -1
  53. package/lib/es/utils.js +2 -1
  54. package/package.json +1 -1
  55. package/lib/cjs/components/dialog/formula-list/enum.d.ts +0 -39
  56. package/lib/cjs/components/dialog/formula-list/enum.js +0 -123
  57. package/lib/es/components/dialog/formula-list/enum.d.ts +0 -39
  58. package/lib/es/components/dialog/formula-list/enum.js +0 -117
@@ -1,4 +1,4 @@
1
- import { MetaListType, MetaSummarize_Group, AtomsTypeEnum, AtomsItem } from './types';
1
+ import { MetaListType, MetaSummarize_Group } from './types';
2
2
  export declare const SummarizeAlias = "source";
3
3
  export declare const summarizeToSql: (arr: MetaSummarize_Group[], record: MetaSummarize_Group) => {
4
4
  sql: string;
@@ -6,4 +6,3 @@ export declare const summarizeToSql: (arr: MetaSummarize_Group[], record: MetaSu
6
6
  };
7
7
  export declare const compressionStructure: (data: MetaListType[]) => string;
8
8
  export declare const restoreStructure: (data: string) => MetaListType[];
9
- export declare const getTemItem: (type: AtomsTypeEnum) => AtomsItem;
@@ -4,10 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.summarizeToSql = exports.restoreStructure = exports.getTemItem = exports.compressionStructure = exports.SummarizeAlias = void 0;
7
+ exports.summarizeToSql = exports.restoreStructure = exports.compressionStructure = exports.SummarizeAlias = void 0;
8
8
  var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectSpread2"));
9
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
10
- var _types = require("./types");
11
10
  var _enum = require("./enum");
12
11
  var _excluded = ["children"],
13
12
  _excluded2 = ["metaKey"]; // import { SummarizeAlias } from './index';
@@ -422,78 +421,4 @@ var restoreStructure = exports.restoreStructure = function restoreStructure(data
422
421
  } catch (e) {
423
422
  return [];
424
423
  }
425
- };
426
- var getTemItem = exports.getTemItem = function getTemItem(type) {
427
- var temItem;
428
- // 字段
429
- if (type === _types.AtomsTypeEnum.FIELD) {
430
- temItem = {
431
- fieldName: '',
432
- // 字段名
433
- fieldNameZh: '',
434
- // 字段中文名
435
- fieldAlias: '',
436
- // 别名
437
- fieldUuid: '',
438
- // uuid
439
- fieldId: '',
440
- // 字段id
441
- // quotes?: string; // 字段展示的 不知道有没有用
442
- tableName: '',
443
- // 表名
444
- tableNameZh: '',
445
- tableId: '',
446
- // 表名
447
- tableAlias: '',
448
- // 别名
449
- tableUuid: '',
450
- // 表唯一标识
451
- datasourceName: '',
452
- // 数据源名
453
- datasourceId: '',
454
- // 数据源id
455
- type: _types.AtomsTypeEnum.FIELD
456
- };
457
- }
458
- // 表达式
459
- else if (type === _types.AtomsTypeEnum.EXPRESSION || type === _types.AtomsTypeEnum.JOIN_DEFAULT) {
460
- return {
461
- lhs: [],
462
- rhs: [],
463
- condition: '',
464
- quotes: '',
465
- type: type
466
- };
467
- } else if (type === _types.AtomsTypeEnum.EXISTS || type === _types.AtomsTypeEnum.NOT_EXISTS) {
468
- return {
469
- quotes: '',
470
- // 展示用户看的 组装的文字
471
- notExists: [],
472
- type: type
473
- };
474
- } else if (type === _types.AtomsTypeEnum.UNKNOWN) {
475
- return {
476
- // quotes: '', // 展示用户看的 组装的文字
477
- // notExists: [],
478
- val: '',
479
- type: type
480
- };
481
- } else if (type === _types.AtomsTypeEnum.INPUT_NUMBER) {
482
- return {
483
- val: 0,
484
- type: type
485
- };
486
- } else if (type === _types.AtomsTypeEnum.INPUT_NUMBER_LIST || type === _types.AtomsTypeEnum.INPUT_STRING_LIST) {
487
- temItem = {
488
- val: [],
489
- type: type
490
- };
491
- } else {
492
- // 其他
493
- temItem = {
494
- val: '',
495
- type: type
496
- };
497
- }
498
- return temItem;
499
424
  };
@@ -12,7 +12,9 @@ export declare enum AtomsTypeEnum {
12
12
  INPUT_NUMBER = "inputNumber",// 数字输入框
13
13
  CONSTANT = "constant",// 常量
14
14
  OPERATOR = "operator",// 运算符
15
- UNKNOWN = "unknown"
15
+ UNKNOWN = "unknown",//未选具体类型
16
+ FORMULA = "FORMULA",
17
+ COLLECTION = "collection"
16
18
  }
17
19
  export interface AtomsNotExists {
18
20
  quotes: string;
@@ -24,6 +26,21 @@ export interface AtomsExists {
24
26
  notExists?: MetaListType[];
25
27
  type: AtomsTypeEnum.EXISTS;
26
28
  }
29
+ export type Arity = {
30
+ exact: number;
31
+ } | {
32
+ min: number;
33
+ } | {
34
+ min: number;
35
+ max: number;
36
+ };
37
+ export interface AtomsFormula {
38
+ args: AtomsItem[];
39
+ arity?: Arity;
40
+ quotes: string;
41
+ name: string;
42
+ type: AtomsTypeEnum.FORMULA;
43
+ }
27
44
  export interface AtomsExpression {
28
45
  lhs: AtomsItem[];
29
46
  rhs: AtomsItem[];
@@ -82,7 +99,12 @@ export interface AtomsUnknown {
82
99
  val: string;
83
100
  type: AtomsTypeEnum.UNKNOWN;
84
101
  }
85
- export type AtomsItem = AtomsNotExists | AtomsExists | AtomsJoinDefault | AtomsExpression | AtomsField | AtomsInputString | AtomsInputStringList | AtomsInputNumberList | AtomsInputNumber | AtomsOprator | AtomsConstant | AtomsUnknown;
102
+ export interface AtomsCollection {
103
+ list: AtomsItem[];
104
+ quotes: string;
105
+ type: AtomsTypeEnum.COLLECTION;
106
+ }
107
+ export type AtomsItem = AtomsNotExists | AtomsExists | AtomsJoinDefault | AtomsExpression | AtomsFormula | AtomsField | AtomsInputString | AtomsInputStringList | AtomsInputNumberList | AtomsInputNumber | AtomsOprator | AtomsConstant | AtomsUnknown | AtomsCollection;
86
108
  export type ToolbarType = TypeEnum | 'filter' | 'summarize' | 'joinData' | 'permissionTable' | 'customColumn' | 'sort' | 'rowLimit' | 'union';
87
109
  export type MetaListType = MetaData | MetaJoin | MetaCustom | MetaFilter | MetaSummarize | MetaSort | MetaLimit | MetaPermissionTable | MetaUnion;
88
110
  export type initColumnsType = MetaData_ColumnsType;
@@ -293,10 +315,22 @@ export interface ParamsType {
293
315
  code: string;
294
316
  }
295
317
  export interface PopupData {
318
+ container?: any;
296
319
  visible: boolean;
297
320
  node?: any;
298
321
  content?: any;
299
322
  }
323
+ export interface FormulaTemplatesItem {
324
+ name: string;
325
+ args: {
326
+ type: AtomsTypeEnum;
327
+ check?: string | null;
328
+ }[];
329
+ arity?: Arity;
330
+ output?: string;
331
+ description?: string;
332
+ example?: string;
333
+ }
300
334
  export {};
301
335
  /**
302
336
  let a = {
@@ -12,6 +12,7 @@ var AtomsTypeEnum;
12
12
  AtomsTypeEnum["NOT_EXISTS"] = "notExists";
13
13
  AtomsTypeEnum["FIELD"] = "field";
14
14
  AtomsTypeEnum["EXPRESSION"] = "expression";
15
+ // FUNCTION = 'function', // 函数
15
16
  AtomsTypeEnum["INPUT_STRING"] = "inputString";
16
17
  AtomsTypeEnum["INPUT_STRING_LIST"] = "inputStringList";
17
18
  AtomsTypeEnum["INPUT_NUMBER_LIST"] = "inputNumberList";
@@ -19,6 +20,8 @@ var AtomsTypeEnum;
19
20
  AtomsTypeEnum["CONSTANT"] = "constant";
20
21
  AtomsTypeEnum["OPERATOR"] = "operator";
21
22
  AtomsTypeEnum["UNKNOWN"] = "unknown";
23
+ AtomsTypeEnum["FORMULA"] = "FORMULA";
24
+ AtomsTypeEnum["COLLECTION"] = "collection";
22
25
  })(AtomsTypeEnum || (exports.AtomsTypeEnum = AtomsTypeEnum = {}));
23
26
  // ----------- 第五个模块 聚合模块 ------------
24
27
  var MetaSummarize_Enum;
@@ -1,4 +1,4 @@
1
- import type { MetaListType, ToolbarType } from './store/types';
1
+ import type { MetaListType, ToolbarType, FormulaTemplatesItem } from './store/types';
2
2
  import { UnionEnum } from './store/enum';
3
3
  import { DataType } from './components/dialog/select-join-column';
4
4
  export interface MetaListProps {
@@ -32,6 +32,7 @@ export interface MetabaseProps {
32
32
  ignoreGroupByType?: boolean;
33
33
  filterCustomType?: boolean;
34
34
  notExistsColumns?: DataType[];
35
+ formulaTemplates?: FormulaTemplatesItem[];
35
36
  }
36
37
  export interface OptionItem {
37
38
  value?: string;
package/lib/cjs/utils.js CHANGED
@@ -448,6 +448,7 @@ function splitByUnion(data) {
448
448
  return result;
449
449
  }
450
450
  var patchData = exports.patchData = function patchData(metas) {
451
+ return metas;
451
452
  var mainTable = metas[0] || {};
452
453
  var version = (mainTable === null || mainTable === void 0 ? void 0 : mainTable.patchVersion) || '';
453
454
  if (version != '1.0.0') {
@@ -593,7 +594,7 @@ var buildSqlQuery = exports.buildSqlQuery = function buildSqlQuery() {
593
594
  var filterStrings = item.filter.map(function (f) {
594
595
  if (f.type === _types.AtomsTypeEnum.FIELD) {
595
596
  return f.fieldName;
596
- } else if (f.type === _types.AtomsTypeEnum.EXPRESSION || f.type === _types.AtomsTypeEnum.EXISTS || f.type === _types.AtomsTypeEnum.NOT_EXISTS) {
597
+ } else if (f.type === _types.AtomsTypeEnum.EXPRESSION || f.type === _types.AtomsTypeEnum.EXISTS || f.type === _types.AtomsTypeEnum.NOT_EXISTS || f.type === _types.AtomsTypeEnum.FORMULA || f.type === _types.AtomsTypeEnum.COLLECTION) {
597
598
  return f.quotes;
598
599
  } else if (f.type === _types.AtomsTypeEnum.JOIN_DEFAULT) {
599
600
  return '';
@@ -6,6 +6,7 @@ import { useState, useMemo, useRef } from 'react';
6
6
  import cx from 'classnames';
7
7
  import './index.less';
8
8
  import FormulaList from '../formula-list';
9
+ import { isOk } from '../formula-list/utils';
9
10
  import { __ } from '../../../locale';
10
11
  // import { getTemplate } from './utils';
11
12
  import Styled from 'styled-components';
@@ -30,7 +31,7 @@ var CaseEditor = function CaseEditor(props) {
30
31
  var ref = useRef(null);
31
32
  // 提交按钮是否可用
32
33
  var usable = useMemo(function () {
33
- return Array.from(caseList).length > 0 && name;
34
+ return isOk(caseList) && name;
34
35
  }, [caseList, name]);
35
36
  // 取消
36
37
  var _onClose = function _onClose() {
@@ -72,7 +73,6 @@ var CaseEditor = function CaseEditor(props) {
72
73
  })
73
74
  })]
74
75
  }), _jsx(FormulaList, {
75
- isCustom: true,
76
76
  value: caseList,
77
77
  data: data,
78
78
  ref: ref,
@@ -620,7 +620,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
620
620
  value: '',
621
621
  list: [{
622
622
  value: AtomsTypeEnum.INPUT_STRING,
623
- label: __('SqlQueryBuilder.input')
623
+ label: __('customColumn.input')
624
624
  }, {
625
625
  value: AtomsTypeEnum.CONSTANT,
626
626
  label: __('customColumn.constant')
@@ -0,0 +1,10 @@
1
+ import './index.less';
2
+ import { AtomsFormula } from '../../../store/types';
3
+ interface PropsType {
4
+ value: AtomsFormula;
5
+ data: any;
6
+ onOk: Function;
7
+ onCancel: Function;
8
+ }
9
+ declare const CaseEditor: (props: PropsType) => import("react/jsx-runtime").JSX.Element;
10
+ export default CaseEditor;
@@ -0,0 +1,236 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
4
+ var _templateObject;
5
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
+ import { useEffect, useState, useMemo, useRef } from 'react';
7
+ import cx from 'classnames';
8
+ import './index.less';
9
+ import FormulaList from '../formula-list';
10
+ import { AddIcon, CloseIcon } from '../../icons';
11
+ import { isOk } from '../formula-list/utils';
12
+ import { __ } from '../../../locale';
13
+ import { getTemArgs, getObjTem, getParamActions } from './utils';
14
+ import Styled from 'styled-components';
15
+ // import { OptionsTypeEnum, customTypes, otherList, operatorList, functionList } from './enum';
16
+ import { AtomsTypeEnum } from '../../../store/types';
17
+ import { Select, Button } from '@gingkoo/pandora';
18
+ import cloneDeep from 'lodash/cloneDeep';
19
+ import { useStore } from '../../../hooks/use-provider';
20
+ var VisualBox = Styled.div.attrs({
21
+ className: 'visual-box'
22
+ })(_templateObject || (_templateObject = _taggedTemplateLiteral([""])));
23
+ var CaseEditor = function CaseEditor(props) {
24
+ var _store$formulaTemplat, _fun$args;
25
+ var store = useStore();
26
+ var value = props.value,
27
+ data = props.data,
28
+ onOk = props.onOk,
29
+ onCancel = props.onCancel;
30
+ var _useState = useState(value),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ fun = _useState2[0],
33
+ setFun = _useState2[1];
34
+ var _useState3 = useState(getObjTem(store.formulaTemplates)),
35
+ _useState4 = _slicedToArray(_useState3, 2),
36
+ formulaList = _useState4[0],
37
+ setFunctionList = _useState4[1];
38
+ var _useState5 = useState({
39
+ canAdd: true,
40
+ canDel: true
41
+ }),
42
+ _useState6 = _slicedToArray(_useState5, 2),
43
+ formulaOpr = _useState6[0],
44
+ setFormulaOpr = _useState6[1];
45
+ useEffect(function () {
46
+ setFormulaOpr(getParamActions(fun.args, fun.arity));
47
+ }, [fun]);
48
+ var ref = useRef(null);
49
+ // EXPRESSION = 'expression', // 表达式
50
+ // // FUNCTION = 'function', // 函数
51
+ // INPUT_STRING = 'inputString', // 字符串输入框
52
+ // INPUT_STRING_LIST = 'inputStringList', // 字符串输入框
53
+ // INPUT_NUMBER_LIST = 'inputNumberList', // 数字输入框
54
+ // INPUT_NUMBER = 'inputNumber', // 数字输入框
55
+ // CONSTANT = 'constant', // 常量
56
+ // OPERATOR = 'operator', // 运算符
57
+ // UNKNOWN = 'unknown', //未选具体类型
58
+ // FORMULA = 'FORMULA',
59
+ // COLLECTION = 'collection',
60
+ // 提交按钮是否可用
61
+ var usable = useMemo(function () {
62
+ return fun.name && isOk(fun.args);
63
+ }, [fun]);
64
+ // 取消
65
+ var _onClose = function _onClose() {
66
+ onCancel === null || onCancel === void 0 || onCancel();
67
+ };
68
+ // 确定
69
+ var _onOk = function _onOk() {
70
+ typeof onOk === 'function' && (onOk === null || onOk === void 0 ? void 0 : onOk(fun));
71
+ };
72
+ // 选择公式名
73
+ var handleFunName = function handleFunName(name) {
74
+ var _formulaList$name;
75
+ formulaList === null || formulaList === void 0 || formulaList[name].args;
76
+ setFun(_objectSpread(_objectSpread({}, fun), {}, {
77
+ args: getTemArgs(formulaList === null || formulaList === void 0 ? void 0 : formulaList[name].args),
78
+ arity: formulaList === null || formulaList === void 0 || (_formulaList$name = formulaList[name]) === null || _formulaList$name === void 0 ? void 0 : _formulaList$name.arity,
79
+ name: name
80
+ }));
81
+ };
82
+ var addParams = function addParams(index) {
83
+ var _args = cloneDeep(fun.args);
84
+ var tem = getTemArgs(formulaList === null || formulaList === void 0 ? void 0 : formulaList[fun.name].args)[index + 1] || {
85
+ type: AtomsTypeEnum.COLLECTION,
86
+ list: []
87
+ };
88
+ _args.splice(index + 1, 0, tem);
89
+ setFun(_objectSpread(_objectSpread({}, fun), {}, {
90
+ args: _args
91
+ }));
92
+ };
93
+ var delParams = function delParams(index) {
94
+ var _args = cloneDeep(fun.args);
95
+ _args.splice(index, 1);
96
+ setFun(_objectSpread(_objectSpread({}, fun), {}, {
97
+ args: _args
98
+ }));
99
+ };
100
+ return _jsxs("div", {
101
+ className: 'function-box',
102
+ ref: ref,
103
+ children: [_jsx(VisualBox, {
104
+ children: _jsx("div", {
105
+ className: "Sqb-item Sqb-case-editor mb-2 mt-2",
106
+ children: _jsxs("div", {
107
+ className: "Sqb-item--content",
108
+ children: [_jsxs("div", {
109
+ className: 'Sqb-NotebookCell-header',
110
+ children: [_jsx("div", {
111
+ className: "mb-2 font-bold uppercase tracking-wider",
112
+ style: {
113
+ fontSize: 12,
114
+ color: '#949aab'
115
+ },
116
+ children: "\u8BF7\u5148\u9009\u62E9\u516C\u5F0F\uFF0C\u5207\u6362\u516C\u5F0F\u65F6\u4F1A\u91CD\u7F6E\u53C2\u6570"
117
+ }), _jsx("div", {
118
+ className: 'Sqb-NotebookCell formula-name',
119
+ children: _jsx(Select, {
120
+ triggerProps: {
121
+ clickToClose: true
122
+ },
123
+ value: fun.name,
124
+ triggerElement: function triggerElement(value) {
125
+ return _jsx("div", {
126
+ className: cx("Sqb-TableName Sqb-TableName-OPERATOR", {
127
+ notSelected: !fun.name
128
+ }),
129
+ children: fun.name ? fun.name : __('customColumn.selectFormula')
130
+ });
131
+ },
132
+ onChange: function onChange(val) {
133
+ handleFunName(val);
134
+ },
135
+ children: (_store$formulaTemplat = store.formulaTemplates) === null || _store$formulaTemplat === void 0 ? void 0 : _store$formulaTemplat.map(function (option, index) {
136
+ return _jsx(Select.Option, {
137
+ value: option.name,
138
+ children: option.name
139
+ }, index);
140
+ })
141
+ })
142
+ }), fun.name && _jsxs("div", {
143
+ className: "mb-2 font-bold uppercase tracking-wider",
144
+ style: {
145
+ fontSize: 12,
146
+ color: '#949aab'
147
+ },
148
+ children: [_jsxs("p", {
149
+ children: ["\u63CF\u8FF0\uFF1A", formulaList[fun.name].description]
150
+ }), _jsxs("p", {
151
+ children: ["\u6848\u4F8B\uFF1A", formulaList[fun.name].example]
152
+ })]
153
+ })]
154
+ }), fun === null || fun === void 0 || (_fun$args = fun.args) === null || _fun$args === void 0 ? void 0 : _fun$args.map(function (v, i) {
155
+ if (v.type === AtomsTypeEnum.COLLECTION) {
156
+ var _formulaList$fun$name;
157
+ return _jsxs("div", {
158
+ className: 'Sqb-item-formula-args',
159
+ children: [_jsxs("div", {
160
+ className: 'Sqb-item-formula',
161
+ children: [_jsxs("div", {
162
+ className: "mb-2 font-bold uppercase tracking-wider",
163
+ style: {
164
+ fontSize: 12,
165
+ color: '#949aab'
166
+ },
167
+ children: ["\u53C2\u6570", i + 1, ":"]
168
+ }), _jsx(FormulaList, {
169
+ check: (formulaList === null || formulaList === void 0 || (_formulaList$fun$name = formulaList[fun.name]) === null || _formulaList$fun$name === void 0 || (_formulaList$fun$name = _formulaList$fun$name.args) === null || _formulaList$fun$name === void 0 || (_formulaList$fun$name = _formulaList$fun$name[i]) === null || _formulaList$fun$name === void 0 ? void 0 : _formulaList$fun$name.check) || '',
170
+ value: v.list,
171
+ data: data,
172
+ ref: ref,
173
+ onChange: function onChange(data, _quotes) {
174
+ var _args = cloneDeep(fun.args);
175
+ _args[i].list = data;
176
+ _args[i].quotes = _quotes || '';
177
+ var quotes = _args.map(function (v) {
178
+ return v.quotes;
179
+ }).join(' , ');
180
+ setFun(_objectSpread(_objectSpread({}, fun), {}, {
181
+ quotes: fun.name + ' ( ' + quotes + ' ) ',
182
+ args: _args
183
+ }));
184
+ }
185
+ })]
186
+ }), _jsxs("div", {
187
+ className: 'Sqb-item-opr',
188
+ children: [_jsx(Button, {
189
+ primary: true,
190
+ disabled: !formulaOpr.canAdd,
191
+ shape: 'square',
192
+ icon: _jsx(AddIcon, {}),
193
+ onClick: function onClick() {
194
+ addParams(i);
195
+ }
196
+ }), _jsx(Button, {
197
+ primary: true,
198
+ level: 'danger',
199
+ shape: 'square',
200
+ icon: _jsx(CloseIcon, {}),
201
+ disabled: !formulaOpr.canDel,
202
+ onClick: function onClick() {
203
+ delParams(i);
204
+ }
205
+ })]
206
+ })]
207
+ }, i);
208
+ }
209
+ })]
210
+ })
211
+ })
212
+ }), _jsx("div", {
213
+ className: "btns p-4",
214
+ children: _jsxs("div", {
215
+ style: {
216
+ marginLeft: 'auto'
217
+ },
218
+ children: [_jsx("button", {
219
+ className: "btn",
220
+ onClick: function onClick() {
221
+ return _onClose();
222
+ },
223
+ children: __('customColumn.cancel')
224
+ }), _jsx("button", {
225
+ className: cx("btn ml-4", {
226
+ usable: usable
227
+ }),
228
+ disabled: !usable,
229
+ onClick: _onOk,
230
+ children: __('customColumn.complete')
231
+ })]
232
+ })
233
+ })]
234
+ });
235
+ };
236
+ export default CaseEditor;
@@ -0,0 +1,81 @@
1
+ .function-box {
2
+ display: flex;
3
+ flex-direction: column;
4
+ height: 100%;
5
+ width: 100%;
6
+ .visual-box {
7
+ flex: 1;
8
+ }
9
+
10
+ .Sqb-case-editor {
11
+ padding: 20px 20px 50px;
12
+ .Sqb-item--content {
13
+ width: 100%;
14
+ height: 100%;
15
+ .Sqb-item-formula-args {
16
+ display: flex;
17
+ align-items: center;
18
+ margin: 20px 0;
19
+ .Sqb-item-formula {
20
+ flex: 1;
21
+ }
22
+ .Sqb-item-opr {
23
+ display: flex;
24
+ gap: 10px;
25
+ margin-left: 10px;
26
+ }
27
+ }
28
+ }
29
+ }
30
+
31
+ .btns {
32
+ flex-direction: row;
33
+ align-items: center;
34
+ display: flex;
35
+ border-top: 1px solid #f0f0f0;
36
+ // position: absolute;
37
+ width: 100%;
38
+ bottom: 0;
39
+ z-index: 3;
40
+ background-color: #fff;
41
+ .btn {
42
+ padding: 0.75rem 1rem;
43
+
44
+ display: inline-block;
45
+ box-sizing: border-box;
46
+ text-decoration: none;
47
+ background: transparent;
48
+ border: 1px solid rgb(228, 228, 228);
49
+ color: #4c5773;
50
+ cursor: pointer;
51
+ text-decoration: none;
52
+ font-weight: bold;
53
+ font-family: 'Lato', sans-serif;
54
+ border-radius: 6px;
55
+
56
+ outline: none;
57
+
58
+ &:disabled {
59
+ opacity: 0.5;
60
+ cursor: not-allowed;
61
+ }
62
+ &:not(:disabled):hover {
63
+ color: #509ee3;
64
+ border-color: rgb(214, 214, 214);
65
+ background: #f9fbfc;
66
+ transition: all 200ms linear;
67
+ }
68
+
69
+ &.usable {
70
+ color: #ffffff;
71
+ background: #509ee3;
72
+ border: 1px solid #509ee3;
73
+ &:hover {
74
+ color: #ffffff;
75
+ border-color: #509ee3;
76
+ background-color: rgba(80, 158, 227, 0.88);
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
@@ -0,0 +1,7 @@
1
+ import { Arity, AtomsItem, AtomsCollection } from '../../../store/types';
2
+ export declare const getObjTem: (arr: any[]) => any;
3
+ export declare const getTemArgs: (temArgs: any[]) => AtomsCollection[];
4
+ export declare function getParamActions(params: AtomsItem[], arity?: Arity): {
5
+ canAdd: boolean;
6
+ canDel: boolean;
7
+ };
@@ -0,0 +1,37 @@
1
+ import { AtomsTypeEnum } from '../../../store/types';
2
+ import { getTemplateItem } from '../formula-list/utils';
3
+ export var getObjTem = function getObjTem(arr) {
4
+ var obj = {};
5
+ arr === null || arr === void 0 || arr.map(function (v) {
6
+ if (v.name) {
7
+ obj[v.name] = v;
8
+ }
9
+ });
10
+ return obj;
11
+ };
12
+ export var getTemArgs = function getTemArgs(temArgs) {
13
+ return (temArgs === null || temArgs === void 0 ? void 0 : temArgs.map(function (v) {
14
+ return {
15
+ type: AtomsTypeEnum.COLLECTION,
16
+ quotes: '',
17
+ list: [getTemplateItem(v.type)]
18
+ };
19
+ })) || [];
20
+ };
21
+ export function getParamActions(params, arity) {
22
+ var len = (params === null || params === void 0 ? void 0 : params.length) || 0;
23
+ if (!arity) {
24
+ return {
25
+ canAdd: true,
26
+ canDel: true
27
+ };
28
+ }
29
+ var effectiveMin = 'min' in arity ? arity.min : 'exact' in arity ? arity.exact : 0;
30
+ var effectiveMax = 'max' in arity ? arity.max : 'exact' in arity ? arity.exact // ← 这里!不能是 Infinity
31
+ : Infinity;
32
+ return {
33
+ canAdd: len < effectiveMax,
34
+ // 小于 max 才能加
35
+ canDel: len > effectiveMin // 大于 min 才能删
36
+ };
37
+ }
@@ -6,8 +6,8 @@ interface PropsType {
6
6
  value: AtomsItem[];
7
7
  data: any;
8
8
  exitData?: any;
9
- isCustom?: boolean;
10
- onChange?: Function;
9
+ onChange?: (atoms: AtomsItem[], quotes?: string) => void;
10
+ check?: string;
11
11
  }
12
12
  declare const FormulaList: React.ForwardRefExoticComponent<PropsType & React.RefAttributes<unknown>>;
13
13
  export default FormulaList;