@gingkoo/pandora-metabase 1.0.23 → 1.0.25
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.
- package/lib/cjs/common/SplitView/index.js +12 -11
- package/lib/cjs/components/dialog/custom-column/expression-editor.js +2 -1
- package/lib/cjs/components/dialog/custom-column/tokenizedI-input.js +2 -1
- package/lib/cjs/components/dialog/custom-editor/index.js +2 -1
- package/lib/cjs/components/dialog/expression/index.js +13 -12
- package/lib/cjs/components/dialog/formula/index.d.ts +10 -0
- package/lib/cjs/components/dialog/formula/index.js +242 -0
- package/lib/cjs/components/dialog/formula/index.less +81 -0
- package/lib/cjs/components/dialog/formula/utils.d.ts +7 -0
- package/lib/cjs/components/dialog/formula/utils.js +45 -0
- package/lib/cjs/components/dialog/formula-list/index.d.ts +3 -1
- package/lib/cjs/components/dialog/formula-list/index.js +107 -43
- package/lib/cjs/components/dialog/formula-list/utils.d.ts +14 -1
- package/lib/cjs/components/dialog/formula-list/utils.js +159 -2
- package/lib/cjs/components/dialog/index.d.ts +1 -0
- package/lib/cjs/components/dialog/index.js +9 -2
- package/lib/cjs/components/dialog/select-column/index.js +6 -13
- package/lib/cjs/components/dialog/select-column-multiple/index.js +0 -1
- package/lib/cjs/components/dialog/select-table/index.js +7 -7
- package/lib/cjs/components/icons.js +36 -36
- package/lib/cjs/components/metabase/index.js +6 -6
- package/lib/cjs/components/metabase/index.less +10 -0
- package/lib/cjs/components/modules/components/Wrapper.js +6 -6
- package/lib/cjs/components/modules/custom-column.js +4 -4
- package/lib/cjs/components/modules/enum/filter-enum.d.ts +7 -2
- package/lib/cjs/components/modules/enum/filter-enum.js +8 -2
- package/lib/cjs/components/modules/join-data.js +78 -36
- package/lib/cjs/components/modules/summarize/group-by.js +6 -13
- package/lib/cjs/components/modules/summarize/select-index.js +6 -13
- package/lib/cjs/components/modules/table-data.js +9 -16
- package/lib/cjs/components/popup.js +2 -1
- package/lib/cjs/hooks/patch.js +106 -76
- package/lib/cjs/hooks/use-state.js +100 -65
- package/lib/cjs/index.js +5 -2
- package/lib/cjs/locale/en.js +6 -3
- package/lib/cjs/locale/zh.js +6 -3
- package/lib/cjs/store/helper.d.ts +1 -2
- package/lib/cjs/store/helper.js +1 -76
- package/lib/cjs/store/types.d.ts +36 -2
- package/lib/cjs/store/types.js +3 -0
- package/lib/cjs/types.d.ts +2 -1
- package/lib/cjs/utils.d.ts +1 -0
- package/lib/cjs/utils.js +16 -2
- package/lib/es/common/SplitView/index.js +10 -10
- package/lib/es/components/dialog/custom-editor/index.js +2 -1
- package/lib/es/components/dialog/expression/index.js +11 -11
- package/lib/es/components/dialog/formula/index.d.ts +10 -0
- package/lib/es/components/dialog/formula/index.js +236 -0
- package/lib/es/components/dialog/formula/index.less +81 -0
- package/lib/es/components/dialog/formula/utils.d.ts +7 -0
- package/lib/es/components/dialog/formula/utils.js +37 -0
- package/lib/es/components/dialog/formula-list/index.d.ts +3 -1
- package/lib/es/components/dialog/formula-list/index.js +104 -40
- package/lib/es/components/dialog/formula-list/utils.d.ts +14 -1
- package/lib/es/components/dialog/formula-list/utils.js +160 -2
- package/lib/es/components/dialog/index.d.ts +1 -0
- package/lib/es/components/dialog/index.js +2 -1
- package/lib/es/components/dialog/select-column/index.js +7 -14
- package/lib/es/components/dialog/select-column-multiple/index.js +0 -1
- package/lib/es/components/dialog/select-table/index.js +7 -7
- package/lib/es/components/icons.js +36 -36
- package/lib/es/components/metabase/index.js +6 -6
- package/lib/es/components/metabase/index.less +10 -0
- package/lib/es/components/modules/components/Wrapper.js +6 -6
- package/lib/es/components/modules/custom-column.js +4 -4
- package/lib/es/components/modules/enum/filter-enum.d.ts +7 -2
- package/lib/es/components/modules/enum/filter-enum.js +8 -2
- package/lib/es/components/modules/join-data.js +78 -36
- package/lib/es/components/modules/summarize/group-by.js +7 -14
- package/lib/es/components/modules/summarize/select-index.js +7 -14
- package/lib/es/components/modules/table-data.js +10 -17
- package/lib/es/hooks/patch.js +105 -75
- package/lib/es/hooks/use-state.js +101 -66
- package/lib/es/index.js +3 -1
- package/lib/es/locale/en.js +6 -3
- package/lib/es/locale/zh.js +6 -3
- package/lib/es/store/helper.d.ts +1 -2
- package/lib/es/store/helper.js +0 -75
- package/lib/es/store/types.d.ts +36 -2
- package/lib/es/store/types.js +3 -0
- package/lib/es/types.d.ts +2 -1
- package/lib/es/types.js +18 -1
- package/lib/es/utils.d.ts +1 -0
- package/lib/es/utils.js +13 -1
- package/package.json +2 -2
- package/lib/cjs/components/dialog/formula-list/enum.d.ts +0 -39
- package/lib/cjs/components/dialog/formula-list/enum.js +0 -123
- package/lib/es/components/dialog/formula-list/enum.d.ts +0 -39
- package/lib/es/components/dialog/formula-list/enum.js +0 -117
package/lib/cjs/store/helper.js
CHANGED
|
@@ -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.
|
|
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
|
};
|
package/lib/cjs/store/types.d.ts
CHANGED
|
@@ -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
|
|
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 = {
|
package/lib/cjs/store/types.js
CHANGED
|
@@ -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;
|
package/lib/cjs/types.d.ts
CHANGED
|
@@ -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.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ interface HelperResultType {
|
|
|
14
14
|
}
|
|
15
15
|
export declare const getHelper: (list: MetaListType[], item: MetaListType) => HelperResultType;
|
|
16
16
|
export declare const getSubColumns: (metaList: any) => DataType[];
|
|
17
|
+
export declare function isValidSQLAlias(str: string): boolean;
|
|
17
18
|
export declare const changeTableAlias: (list: MetaListType[] | [], curObj: Pick<MetaData_TableType, "tableUuid" | "alias">) => MetaListType[];
|
|
18
19
|
export declare const changeFieldAlias: (list: MetaListType[], curObj: Pick<MetaData_ColumnsType, "fieldUuid" | "fieldAlias">) => MetaListType[];
|
|
19
20
|
export declare function splitByUnion(data: any): any[];
|
package/lib/cjs/utils.js
CHANGED
|
@@ -4,7 +4,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.
|
|
7
|
+
exports.getSubColumns = exports.getHelper = exports.findIndex = exports.changeTableAlias = exports.changeFieldAlias = exports.buildSqlQuery = void 0;
|
|
8
|
+
exports.isValidSQLAlias = isValidSQLAlias;
|
|
9
|
+
exports.patchData = void 0;
|
|
8
10
|
exports.reassembleByUnion = reassembleByUnion;
|
|
9
11
|
exports.splitByUnion = splitByUnion;
|
|
10
12
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/esm/objectWithoutProperties"));
|
|
@@ -250,11 +252,22 @@ var _changeAlias = function changeAlias(items, val, type) {
|
|
|
250
252
|
});
|
|
251
253
|
}
|
|
252
254
|
return v;
|
|
255
|
+
} else if (v.type === _types.AtomsTypeEnum.FORMULA) {
|
|
256
|
+
v.args = _changeAlias(v.args, val, type);
|
|
257
|
+
return v;
|
|
258
|
+
} else if (v.type === _types.AtomsTypeEnum.COLLECTION) {
|
|
259
|
+
v.list = _changeAlias(v.list, val, type);
|
|
260
|
+
return v;
|
|
253
261
|
} else {
|
|
254
262
|
return v;
|
|
255
263
|
}
|
|
256
264
|
});
|
|
257
265
|
};
|
|
266
|
+
function isValidSQLAlias(str) {
|
|
267
|
+
if (!str) return false;
|
|
268
|
+
var regex = /^[A-Za-z_][A-Za-z0-9_]{0,29}$/;
|
|
269
|
+
return regex.test(str);
|
|
270
|
+
}
|
|
258
271
|
var changeTableAlias = exports.changeTableAlias = function changeTableAlias(list, curObj) {
|
|
259
272
|
var _cloneDeep = (0, _cloneDeep3["default"])(curObj),
|
|
260
273
|
tableUuid = _cloneDeep.tableUuid,
|
|
@@ -448,6 +461,7 @@ function splitByUnion(data) {
|
|
|
448
461
|
return result;
|
|
449
462
|
}
|
|
450
463
|
var patchData = exports.patchData = function patchData(metas) {
|
|
464
|
+
return metas;
|
|
451
465
|
var mainTable = metas[0] || {};
|
|
452
466
|
var version = (mainTable === null || mainTable === void 0 ? void 0 : mainTable.patchVersion) || '';
|
|
453
467
|
if (version != '1.0.0') {
|
|
@@ -593,7 +607,7 @@ var buildSqlQuery = exports.buildSqlQuery = function buildSqlQuery() {
|
|
|
593
607
|
var filterStrings = item.filter.map(function (f) {
|
|
594
608
|
if (f.type === _types.AtomsTypeEnum.FIELD) {
|
|
595
609
|
return f.fieldName;
|
|
596
|
-
} else if (f.type === _types.AtomsTypeEnum.EXPRESSION || f.type === _types.AtomsTypeEnum.EXISTS || f.type === _types.AtomsTypeEnum.NOT_EXISTS) {
|
|
610
|
+
} 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
611
|
return f.quotes;
|
|
598
612
|
} else if (f.type === _types.AtomsTypeEnum.JOIN_DEFAULT) {
|
|
599
613
|
return '';
|
|
@@ -51,17 +51,17 @@ var SplitView = React.forwardRef(function (props, ref) {
|
|
|
51
51
|
hMaximum = _useState8[0],
|
|
52
52
|
setHMaximum = _useState8[1];
|
|
53
53
|
var _useState9 = useState(false),
|
|
54
|
-
|
|
55
|
-
vMinimum =
|
|
56
|
-
setVMinimum =
|
|
57
|
-
var
|
|
58
|
-
_useState10 = _slicedToArray(_useState1, 2),
|
|
59
|
-
vMaximum = _useState10[0],
|
|
60
|
-
setVMaximum = _useState10[1];
|
|
61
|
-
var _useState11 = useState(0),
|
|
54
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
55
|
+
vMinimum = _useState10[0],
|
|
56
|
+
setVMinimum = _useState10[1];
|
|
57
|
+
var _useState11 = useState(false),
|
|
62
58
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
vMaximum = _useState12[0],
|
|
60
|
+
setVMaximum = _useState12[1];
|
|
61
|
+
var _useState13 = useState(0),
|
|
62
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
63
|
+
bottomHeight = _useState14[0],
|
|
64
|
+
setBottomHeight = _useState14[1];
|
|
65
65
|
React.useImperativeHandle(ref, function () {
|
|
66
66
|
return {
|
|
67
67
|
open: function open() {
|
|
@@ -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
|
|
34
|
+
return isOk(caseList) && name;
|
|
34
35
|
}, [caseList, name]);
|
|
35
36
|
// 取消
|
|
36
37
|
var _onClose = function _onClose() {
|
|
@@ -79,18 +79,18 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
79
79
|
special_type = _useState8[0],
|
|
80
80
|
setSpecial_type = _useState8[1];
|
|
81
81
|
var _useState9 = useState(value.formula || {}),
|
|
82
|
-
|
|
83
|
-
formula =
|
|
84
|
-
setFormula =
|
|
82
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
83
|
+
formula = _useState10[0],
|
|
84
|
+
setFormula = _useState10[1];
|
|
85
85
|
var store = useStore();
|
|
86
|
-
var
|
|
87
|
-
_useState10 = _slicedToArray(_useState1, 2),
|
|
88
|
-
popupVisible = _useState10[0],
|
|
89
|
-
setPopupVisible = _useState10[1];
|
|
90
|
-
var _useState11 = useState((value === null || value === void 0 || (_value$lhs = value.lhs) === null || _value$lhs === void 0 ? void 0 : _value$lhs.length) > 0 || false),
|
|
86
|
+
var _useState11 = useState(false),
|
|
91
87
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
popupVisible = _useState12[0],
|
|
89
|
+
setPopupVisible = _useState12[1];
|
|
90
|
+
var _useState13 = useState((value === null || value === void 0 || (_value$lhs = value.lhs) === null || _value$lhs === void 0 ? void 0 : _value$lhs.length) > 0 || false),
|
|
91
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
92
|
+
isNext = _useState14[0],
|
|
93
|
+
setIsNext = _useState14[1];
|
|
94
94
|
var table2Selected = Boolean(rhsVal && (rhsVal === null || rhsVal === void 0 ? void 0 : rhsVal.length) > 0);
|
|
95
95
|
var disabled = useMemo(function () {
|
|
96
96
|
if (!condition) return true;
|
|
@@ -620,7 +620,7 @@ var SelectFilterColumn = function SelectFilterColumn(_ref) {
|
|
|
620
620
|
value: '',
|
|
621
621
|
list: [{
|
|
622
622
|
value: AtomsTypeEnum.INPUT_STRING,
|
|
623
|
-
label: __('
|
|
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
|
+
};
|