@gingkoo/pandora-metabase 1.0.61 → 1.0.62

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 (35) hide show
  1. package/lib/cjs/components/dialog/formula-list/index.js +159 -79
  2. package/lib/cjs/components/dialog/select-column-multiple/index.js +3 -3
  3. package/lib/cjs/components/dialog/select-join-column/index.js +3 -3
  4. package/lib/cjs/components/dialog/select-join-column-multiple/index.js +2 -2
  5. package/lib/cjs/components/dialog/select-permission-table/index.d.ts +2 -1
  6. package/lib/cjs/components/dialog/select-permission-table/index.js +4 -3
  7. package/lib/cjs/components/dialog/select-table/index.d.ts +3 -1
  8. package/lib/cjs/components/dialog/select-table/index.js +104 -9
  9. package/lib/cjs/components/metabase/index.less +0 -1
  10. package/lib/cjs/components/modules/join-data.js +4 -1
  11. package/lib/cjs/components/modules/permission-table.js +1 -0
  12. package/lib/cjs/components/modules/table-data.js +2 -0
  13. package/lib/cjs/hooks/use-state.js +103 -42
  14. package/lib/cjs/index.js +5 -2
  15. package/lib/cjs/types.d.ts +1 -0
  16. package/lib/cjs/utils/helper.d.ts +1 -1
  17. package/lib/cjs/utils/helper.js +2 -2
  18. package/lib/es/components/dialog/formula-list/index.js +159 -79
  19. package/lib/es/components/dialog/select-column-multiple/index.js +3 -3
  20. package/lib/es/components/dialog/select-join-column/index.js +3 -3
  21. package/lib/es/components/dialog/select-join-column-multiple/index.js +2 -2
  22. package/lib/es/components/dialog/select-permission-table/index.d.ts +2 -1
  23. package/lib/es/components/dialog/select-permission-table/index.js +4 -3
  24. package/lib/es/components/dialog/select-table/index.d.ts +3 -1
  25. package/lib/es/components/dialog/select-table/index.js +104 -9
  26. package/lib/es/components/metabase/index.less +0 -1
  27. package/lib/es/components/modules/join-data.js +4 -1
  28. package/lib/es/components/modules/permission-table.js +1 -0
  29. package/lib/es/components/modules/table-data.js +2 -0
  30. package/lib/es/hooks/use-state.js +104 -43
  31. package/lib/es/index.js +5 -2
  32. package/lib/es/types.d.ts +1 -0
  33. package/lib/es/utils/helper.d.ts +1 -1
  34. package/lib/es/utils/helper.js +2 -2
  35. package/package.json +1 -1
@@ -30,6 +30,7 @@ var _useProvider = require("../../../hooks/use-provider");
30
30
  var _itemName = _interopRequireDefault(require("../../modules/components/item-name"));
31
31
  var _excluded = ["notExistsToolbar", "toolbar"]; // import './index.less';
32
32
  var FormulaList = (0, _react.forwardRef)(function (props, ref) {
33
+ var _caseList2;
33
34
  var value = props.value,
34
35
  data = props.data,
35
36
  exitData = props.exitData,
@@ -44,6 +45,10 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
44
45
  showPreview = _props$showPreview === void 0 ? true : _props$showPreview,
45
46
  check = props.check;
46
47
  var caseList = value || [];
48
+ var _useState = (0, _react.useState)(''),
49
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
50
+ filterVal = _useState2[0],
51
+ setFilterVal = _useState2[1];
47
52
  var setCaseList = function setCaseList(data) {
48
53
  var quotes = data.map(function (v, i) {
49
54
  if (v !== null && v !== void 0 && v.quotes) {
@@ -55,11 +60,12 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
55
60
  }
56
61
  }).join(' ');
57
62
  onChange === null || onChange === void 0 || onChange(data, quotes);
63
+ caseList = data;
58
64
  };
59
- var _useState = (0, _react.useState)(-1),
60
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
61
- ind = _useState2[0],
62
- setInd = _useState2[1];
65
+ var _useState3 = (0, _react.useState)(-1),
66
+ _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
67
+ ind = _useState4[0],
68
+ setInd = _useState4[1];
63
69
  var store = (0, _useProvider.useStore)();
64
70
  var filterCustomType = store.filterCustomType;
65
71
  function closePopup() {
@@ -67,6 +73,72 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
67
73
  visible: false
68
74
  });
69
75
  }
76
+ // 连接符
77
+ var selectOperator = function selectOperator(props) {
78
+ var triggerElement = props.triggerElement,
79
+ ind = props.ind,
80
+ position = props.position,
81
+ _props$trigger = props.trigger,
82
+ trigger = _props$trigger === void 0 ? 'click' : _props$trigger;
83
+ var showOperatorList = _utils2.operatorList.filter(function (v) {
84
+ return ~(v + (v || '')).toLocaleLowerCase().indexOf(filterVal.toLocaleLowerCase());
85
+ });
86
+ return (0, _jsxRuntime.jsxs)(_pandora.Select, {
87
+ style: {
88
+ width: '100px'
89
+ },
90
+ showSearch: true,
91
+ trigger: trigger,
92
+ triggerProps: {
93
+ clickToClose: true
94
+ },
95
+ virtualListProps: {
96
+ threshold: null
97
+ },
98
+ triggerElement: triggerElement,
99
+ onChange: function onChange(val) {
100
+ if (filterVal) {
101
+ var curInd = addOperator(_types.AtomsTypeEnum.OPERATOR, ind, position);
102
+ handleConstant(val, curInd);
103
+ setFilterVal('');
104
+ } else {
105
+ addOperator(val, ind, position);
106
+ }
107
+ },
108
+ onVisibleChange: function onVisibleChange(visible) {
109
+ if (visible) {
110
+ setFilterVal('');
111
+ }
112
+ },
113
+ value: '',
114
+ children: [(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
115
+ children: (0, _jsxRuntime.jsx)(_pandora.Input, {
116
+ autoFocus: true,
117
+ className: ':Sqb-Operator-input',
118
+ style: {
119
+ margin: '5px auto',
120
+ width: "calc(100% - 10px)"
121
+ },
122
+ value: filterVal,
123
+ placeholder: (0, _locale.__)('SqlQueryBuilder.pleaseEnter'),
124
+ // size='large'
125
+ onChange: function onChange(val) {
126
+ setFilterVal(val);
127
+ }
128
+ })
129
+ }), filterVal ? showOperatorList.map(function (option, index) {
130
+ return (0, _jsxRuntime.jsx)(_pandora.Select.Option, {
131
+ value: option,
132
+ children: option
133
+ }, index + '' + ind);
134
+ }) : _customTypes.map(function (option, index) {
135
+ return (0, _jsxRuntime.jsx)(_pandora.Select.Option, {
136
+ value: option.value,
137
+ children: option.label
138
+ }, index + '' + ind);
139
+ })]
140
+ });
141
+ };
70
142
  // 字段
71
143
  function handleField(e, i, val) {
72
144
  store.setPopup({
@@ -127,18 +199,24 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
127
199
  // 添加
128
200
  var addOperator = function addOperator(type, index, position) {
129
201
  var _caseList = caseList.slice() || [];
202
+ var _ind = index;
130
203
  var temItem = (0, _utils2.getTemplateItem)(type);
131
204
  if (position === 'add') {
132
205
  _caseList.push(temItem);
206
+ _ind = index + 1;
133
207
  } else if (position === 'before') {
134
208
  _caseList.splice(index, 0, temItem);
209
+ _ind = index;
135
210
  } else if (position === 'after') {
136
211
  _caseList.splice(index + 1, 0, temItem);
212
+ _ind = index + 1;
137
213
  } else {
138
214
  //替换
139
215
  _caseList.splice(index, 1, temItem);
216
+ _ind = index;
140
217
  }
141
218
  setCaseList(_caseList);
219
+ return _ind < 0 ? 0 : _ind;
142
220
  };
143
221
  // NotExists 窗口
144
222
  var showNotExists = function showNotExists(i) {
@@ -415,12 +493,8 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
415
493
  })
416
494
  }, index);
417
495
  } else {
418
- return (0, _jsxRuntime.jsx)(_pandora.Select, {
419
- triggerProps: {
420
- clickToClose: true
421
- },
422
- value: v.val,
423
- triggerElement: function triggerElement(value) {
496
+ return selectOperator({
497
+ triggerElement: function triggerElement() {
424
498
  return (0, _jsxRuntime.jsxs)("div", {
425
499
  className: (0, _classnames["default"])("Sqb-TableName ", {
426
500
  notSelected: true
@@ -436,22 +510,46 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
436
510
  })]
437
511
  });
438
512
  },
439
- onChange: function onChange(val) {
440
- addOperator(val, index, '');
441
- },
442
- children: _customTypes.map(function (option, index) {
443
- return (0, _jsxRuntime.jsx)(_pandora.Select.Option, {
444
- value: option.value,
445
- children: option.label
446
- }, index + '' + ind);
447
- })
513
+ ind: index,
514
+ position: ''
448
515
  });
516
+ // return (
517
+ // <Select
518
+ // triggerProps={{
519
+ // clickToClose: true,
520
+ // }}
521
+ // value={v.val}
522
+ // triggerElement={(value) => {
523
+ // return (
524
+ // <div
525
+ // className={cx(`Sqb-TableName `, {
526
+ // notSelected: true,
527
+ // })}
528
+ // >
529
+ // {__('customColumn.selectCustomInput')}
530
+ // <span style={{ fontSize: 0 }} onClick={(e) => handleDel(e, index)}>
531
+ // <CloseIcon />
532
+ // </span>
533
+ // </div>
534
+ // );
535
+ // }}
536
+ // onChange={(val) => {
537
+ // addOperator(val, index, '');
538
+ // }}
539
+ // >
540
+ // {_customTypes.map((option, index) => (
541
+ // <Select.Option key={index + '' + ind} value={option.value}>
542
+ // {option.label}
543
+ // </Select.Option>
544
+ // ))}
545
+ // </Select>
546
+ // );
449
547
  }
450
548
  };
451
549
  return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
452
550
  children: (0, _jsxRuntime.jsxs)("div", {
453
551
  className: "Sqb-NotebookCell",
454
- children: [caseList === null || caseList === void 0 ? void 0 : caseList.map(function (v, i) {
552
+ children: [(_caseList2 = caseList) === null || _caseList2 === void 0 ? void 0 : _caseList2.map(function (v, i) {
455
553
  return (0, _jsxRuntime.jsxs)("div", {
456
554
  className: (0, _classnames["default"])('Sqb-Filter-item', {
457
555
  hover: ind === i
@@ -462,14 +560,7 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
462
560
  onMouseLeave: function onMouseLeave() {
463
561
  setInd(-1);
464
562
  },
465
- children: [(0, _jsxRuntime.jsx)(_pandora.Select, {
466
- trigger: 'hover',
467
- triggerProps: {
468
- clickToClose: true
469
- },
470
- virtualListProps: {
471
- threshold: null
472
- },
563
+ children: [selectOperator({
473
564
  triggerElement: function triggerElement() {
474
565
  return (0, _jsxRuntime.jsx)("div", {
475
566
  className: 'left-arrow',
@@ -483,30 +574,10 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
483
574
  })
484
575
  });
485
576
  },
486
- onChange: function onChange(val) {
487
- addOperator(val, i, 'before');
488
- },
489
- children: _customTypes.map(function (option, index) {
490
- return (0, _jsxRuntime.jsx)(_pandora.Select.Option, {
491
- value: option.value,
492
- children: option.label
493
- }, index + '' + ind);
494
- })
495
- }), itemDom(v, i), (0, _jsxRuntime.jsx)(_pandora.Select, {
496
- trigger: 'hover',
497
- triggerProps: {
498
- clickToClose: true
499
- },
500
- virtualListProps: {
501
- threshold: null
502
- },
503
- style: {
504
- width: '100px'
505
- },
506
- value: '',
507
- autoWidth: {
508
- minWidth: 300
509
- },
577
+ ind: i,
578
+ position: 'before',
579
+ trigger: 'hover'
580
+ }), itemDom(v, i), selectOperator({
510
581
  triggerElement: function triggerElement(value) {
511
582
  return (0, _jsxRuntime.jsx)("div", {
512
583
  className: 'right-arrow',
@@ -520,41 +591,50 @@ var FormulaList = (0, _react.forwardRef)(function (props, ref) {
520
591
  })
521
592
  });
522
593
  },
523
- onChange: function onChange(val, option) {
524
- addOperator(val, i, 'after');
525
- },
526
- children: _customTypes.map(function (option, index) {
527
- return (0, _jsxRuntime.jsx)(_pandora.Select.Option, {
528
- value: option.value,
529
- children: option.label
530
- }, index + '' + ind);
531
- })
594
+ ind: i,
595
+ position: 'after',
596
+ trigger: 'hover'
532
597
  })]
533
598
  }, i);
534
- }), Array.from(caseList).length < 1 && (0, _jsxRuntime.jsx)(_pandora.Select, {
535
- trigger: 'click',
536
- triggerProps: {
537
- clickToClose: true
538
- },
539
- virtualListProps: {
540
- threshold: null
541
- },
599
+ }), Array.from(caseList).length < 1 && selectOperator({
542
600
  triggerElement: function triggerElement() {
543
601
  return (0, _jsxRuntime.jsx)("div", {
544
602
  className: (0, _classnames["default"])("Sqb-TableName gray-name"),
545
603
  children: (0, _jsxRuntime.jsx)(_icons.AddIcon, {})
546
604
  });
547
605
  },
548
- onChange: function onChange(val) {
549
- addOperator(val, -1, 'add');
550
- },
551
- children: _customTypes.map(function (option, index) {
552
- return (0, _jsxRuntime.jsx)(_pandora.Select.Option, {
553
- value: option.value,
554
- children: option.label
555
- }, index + '' + ind);
556
- })
557
- }), showPreview && (0, _jsxRuntime.jsxs)("p", {
606
+ ind: -1,
607
+ position: 'add',
608
+ trigger: 'click'
609
+ })
610
+ // (
611
+ // <Select
612
+ // trigger={'click'}
613
+ // triggerProps={{
614
+ // clickToClose: true,
615
+ // }}
616
+ // virtualListProps={{
617
+ // threshold: null,
618
+ // }}
619
+ // triggerElement={() => {
620
+ // return (
621
+ // <div className={cx(`Sqb-TableName gray-name`)}>
622
+ // <AddIcon />
623
+ // </div>
624
+ // );
625
+ // }}
626
+ // onChange={(val) => {
627
+ // addOperator(val, -1, 'add');
628
+ // }}
629
+ // >
630
+ // {_customTypes.map((option, index) => (
631
+ // <Select.Option key={index + '' + ind} value={option.value}>
632
+ // {option.label}
633
+ // </Select.Option>
634
+ // ))}
635
+ // </Select>
636
+ // )
637
+ , showPreview && (0, _jsxRuntime.jsxs)("p", {
558
638
  className: "mb-2 font-bold uppercase tracking-wider",
559
639
  style: {
560
640
  fontSize: 12,
@@ -188,7 +188,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
188
188
  tableName = v.name,
189
189
  _v$datasourceName = v.datasourceName,
190
190
  datasourceName = _v$datasourceName === void 0 ? '' : _v$datasourceName;
191
- var fullName = datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias);
191
+ var fullName = datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias, store.tableEnableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias, store.tableEnableAlias);
192
192
  if (val === '' || ~fullName.toLocaleLowerCase().indexOf(val.toLocaleLowerCase())) {
193
193
  // let open = tableList.filter((vv) => vv.tableUuid === v.tableUuid)?.[0]?.open || false;
194
194
  return (0, _objectSpread2["default"])({}, v);
@@ -281,8 +281,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
281
281
  },
282
282
  children: (0, _jsxRuntime.jsx)("h3", {
283
283
  className: 'List-item-title ml-2',
284
- title: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias),
285
- children: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias)
284
+ title: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias, store.tableEnableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias, store.tableEnableAlias),
285
+ children: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias, store.tableEnableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias, store.tableEnableAlias)
286
286
  })
287
287
  }), isMultiple && !isGroup && (0, _jsxRuntime.jsx)("span", {
288
288
  className: 'List-title-arrow',
@@ -131,7 +131,7 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
131
131
  tableName = v.name,
132
132
  _v$datasourceName = v.datasourceName,
133
133
  datasourceName = _v$datasourceName === void 0 ? '' : _v$datasourceName;
134
- var fullName = datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias);
134
+ var fullName = datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(tableName, tableAlias, store.tableEnableAlias)) : (0, _helper2.mergeNameAlias)(tableName, tableAlias, store.tableEnableAlias);
135
135
  if (val === '' || ~fullName.toLocaleLowerCase().indexOf(val.toLocaleLowerCase())) {
136
136
  // let open = tableList.filter((vv) => vv.tableUuid === v.tableUuid)?.[0]?.open || false;
137
137
  return (0, _objectSpread2["default"])({}, v);
@@ -221,8 +221,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
221
221
  },
222
222
  children: (0, _jsxRuntime.jsx)("h3", {
223
223
  className: 'List-item-title ml-2',
224
- title: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias),
225
- children: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias)
224
+ title: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias, store.tableEnableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias, store.tableEnableAlias),
225
+ children: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias, store.tableEnableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias, store.tableEnableAlias)
226
226
  })
227
227
  }), isMultiple && (0, _jsxRuntime.jsx)("span", {
228
228
  className: 'List-title-arrow',
@@ -195,8 +195,8 @@ var SelectJoinColumn = function SelectJoinColumn(_ref) {
195
195
  },
196
196
  children: (0, _jsxRuntime.jsx)("h3", {
197
197
  className: 'List-item-title ml-2',
198
- title: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias),
199
- children: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias)
198
+ title: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias, store.tableEnableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias, store.tableEnableAlias),
199
+ children: datasourceName ? "".concat(datasourceName, ".").concat((0, _helper2.mergeNameAlias)(table, tableAlias, store.tableEnableAlias)) : (0, _helper2.mergeNameAlias)(table, tableAlias, store.tableEnableAlias)
200
200
  })
201
201
  }), isMultiple && (0, _jsxRuntime.jsx)("span", {
202
202
  className: 'List-title-arrow',
@@ -10,6 +10,7 @@ interface PropsType {
10
10
  value: MetaData_TableType;
11
11
  onChange: (reocrd: MetaData_TableType) => void;
12
12
  didUpdate?: Function;
13
+ tableEnableAlias: boolean;
13
14
  }
14
- declare const SelectPermissionTable: ({ data, value, onChange, didUpdate }: PropsType) => import("react/jsx-runtime").JSX.Element;
15
+ declare const SelectPermissionTable: ({ data, value, onChange, didUpdate, tableEnableAlias, }: PropsType) => import("react/jsx-runtime").JSX.Element;
15
16
  export default SelectPermissionTable;
@@ -27,7 +27,8 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
27
27
  value = _ref.value,
28
28
  _ref$onChange = _ref.onChange,
29
29
  onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
30
- didUpdate = _ref.didUpdate;
30
+ didUpdate = _ref.didUpdate,
31
+ tableEnableAlias = _ref.tableEnableAlias;
31
32
  var _useState = (0, _react.useState)(data.slice()),
32
33
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
33
34
  datasource = _useState2[0],
@@ -39,7 +40,7 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
39
40
  var val = e.target.value;
40
41
  var newList = (0, _cloneDeep["default"])(data.slice());
41
42
  setDatasource(newList.filter(function (v) {
42
- return ~(v.datasourceName + '.' + (0, _helper.mergeNameAlias)(v.name, v.alias)).toLocaleLowerCase().indexOf(val.toLocaleLowerCase());
43
+ return ~(v.datasourceName + '.' + (0, _helper.mergeNameAlias)(v.name, v.alias, tableEnableAlias)).toLocaleLowerCase().indexOf(val.toLocaleLowerCase());
43
44
  }));
44
45
  }
45
46
  return (0, _jsxRuntime.jsx)("div", {
@@ -85,7 +86,7 @@ var SelectPermissionTable = function SelectPermissionTable(_ref) {
85
86
  }), (0, _jsxRuntime.jsx)("div", {
86
87
  children: (0, _jsxRuntime.jsxs)("h4", {
87
88
  className: 'List-item-title ml-2',
88
- children: [v.datasourceName ? "".concat(v.datasourceName, ".") : '', v.name === 'source' ? PrevResult : (0, _helper.mergeNameAlias)(v.name, v.alias)]
89
+ children: [v.datasourceName ? "".concat(v.datasourceName, ".") : '', v.name === 'source' ? PrevResult : (0, _helper.mergeNameAlias)(v.name, v.alias, tableEnableAlias)]
89
90
  })
90
91
  })]
91
92
  })
@@ -9,9 +9,11 @@ import { MetaData_TableType } from '../../../store/types';
9
9
  import { DatasourceType } from '../../../types';
10
10
  interface PropsType {
11
11
  data: DatasourceType[];
12
+ sourceTable: any[];
12
13
  value: MetaData_TableType;
13
14
  onChange: (reocrd: MetaData_TableType) => void;
14
15
  didUpdate?: Function;
16
+ tableFlat?: boolean;
15
17
  }
16
- declare const SelectTable: ({ data, value, onChange, didUpdate }: PropsType) => import("react/jsx-runtime").JSX.Element;
18
+ declare const SelectTable: ({ data, sourceTable, value, onChange, didUpdate, tableFlat, }: PropsType) => import("react/jsx-runtime").JSX.Element;
17
19
  export default SelectTable;
@@ -29,10 +29,14 @@ var _icons = require("../../icons");
29
29
  var SelectTable = function SelectTable(_ref) {
30
30
  var _ref$data = _ref.data,
31
31
  data = _ref$data === void 0 ? [] : _ref$data,
32
+ _ref$sourceTable = _ref.sourceTable,
33
+ sourceTable = _ref$sourceTable === void 0 ? [] : _ref$sourceTable,
32
34
  value = _ref.value,
33
35
  _ref$onChange = _ref.onChange,
34
36
  onChange = _ref$onChange === void 0 ? function () {} : _ref$onChange,
35
- didUpdate = _ref.didUpdate;
37
+ didUpdate = _ref.didUpdate,
38
+ _ref$tableFlat = _ref.tableFlat,
39
+ tableFlat = _ref$tableFlat === void 0 ? false : _ref$tableFlat;
36
40
  var store = (0, _useProvider.useStore)();
37
41
  var _useState = (0, _react.useState)(false),
38
42
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
@@ -41,18 +45,22 @@ var SelectTable = function SelectTable(_ref) {
41
45
  var _useState3 = (0, _react.useState)(data.slice()),
42
46
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 1),
43
47
  datasource = _useState4[0];
44
- var _useState5 = (0, _react.useState)([]),
48
+ var _useState5 = (0, _react.useState)(sourceTable.slice()),
45
49
  _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
46
- list = _useState6[0],
47
- setList = _useState6[1];
50
+ datasourceTable = _useState6[0],
51
+ setDatasourceTable = _useState6[1];
48
52
  var _useState7 = (0, _react.useState)([]),
49
53
  _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
50
- originList = _useState8[0],
51
- setOriginList = _useState8[1];
52
- var _useState9 = (0, _react.useState)(value),
54
+ list = _useState8[0],
55
+ setList = _useState8[1];
56
+ var _useState9 = (0, _react.useState)([]),
53
57
  _useState0 = (0, _slicedToArray2["default"])(_useState9, 2),
54
- val = _useState0[0],
55
- setVal = _useState0[1];
58
+ originList = _useState0[0],
59
+ setOriginList = _useState0[1];
60
+ var _useState1 = (0, _react.useState)(value),
61
+ _useState10 = (0, _slicedToArray2["default"])(_useState1, 2),
62
+ val = _useState10[0],
63
+ setVal = _useState10[1];
56
64
  (0, _react.useEffect)(function () {
57
65
  if (value.datasourceId) {
58
66
  getTables(value.datasourceId);
@@ -93,6 +101,21 @@ var SelectTable = function SelectTable(_ref) {
93
101
  return ~(v.name + (v.name_zh || '')).toLocaleLowerCase().indexOf(val.toLocaleLowerCase());
94
102
  }));
95
103
  }
104
+ function onInput1(e) {
105
+ var val = e.target.value;
106
+ var newList = (0, _cloneDeep["default"])(sourceTable.slice());
107
+ var _new = newList.map(function (v) {
108
+ var _v$children;
109
+ return (0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, v), {}, {
110
+ children: v === null || v === void 0 || (_v$children = v.children) === null || _v$children === void 0 ? void 0 : _v$children.filter(function (v) {
111
+ return ~(v.name + (v.name_zh || '')).toLocaleLowerCase().indexOf(val.toLocaleLowerCase());
112
+ })
113
+ });
114
+ }).filter(function (v) {
115
+ return v.children.length > 0;
116
+ });
117
+ setDatasourceTable(_new);
118
+ }
96
119
  function goPrevPage() {
97
120
  setVal({
98
121
  datasourceId: '',
@@ -104,6 +127,78 @@ var SelectTable = function SelectTable(_ref) {
104
127
  alias: ''
105
128
  });
106
129
  }
130
+ if (tableFlat) {
131
+ return (0, _jsxRuntime.jsx)("div", {
132
+ className: (0, _classnames["default"])("Sqb-SelectTable--box pb-2"),
133
+ children: (0, _jsxRuntime.jsx)("div", {
134
+ style: {
135
+ minWidth: 300
136
+ },
137
+ children: (0, _jsxRuntime.jsxs)("div", {
138
+ style: {
139
+ width: '100%'
140
+ },
141
+ children: [(0, _jsxRuntime.jsx)("div", {
142
+ className: (0, _classnames["default"])("Sqb-List-section"),
143
+ children: (0, _jsxRuntime.jsxs)("div", {
144
+ className: (0, _classnames["default"])("Sqb-List-search m-2 rounded-lg"),
145
+ children: [(0, _jsxRuntime.jsx)("span", {
146
+ className: 'px-2',
147
+ children: (0, _jsxRuntime.jsx)(_icons.SearchIcon, {})
148
+ }), (0, _jsxRuntime.jsx)("input", {
149
+ autoFocus: true,
150
+ type: 'text',
151
+ className: 'p-2',
152
+ placeholder: (0, _locale.__)('data.search'),
153
+ onInput: onInput1
154
+ })]
155
+ })
156
+ }), datasourceTable.map(function (table) {
157
+ var _table$children;
158
+ return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
159
+ children: [(0, _jsxRuntime.jsx)("div", {
160
+ className: (0, _classnames["default"])("Sqb-List-title mx-4 pb-2 pt-2"),
161
+ children: table.datasourceName
162
+ }), Array.isArray(table.children) && (table === null || table === void 0 || (_table$children = table.children) === null || _table$children === void 0 ? void 0 : _table$children.map(function (v) {
163
+ var _val = {
164
+ datasourceId: table.datasourceId,
165
+ datasourceName: table.datasourceName,
166
+ name: '',
167
+ name_zh: '',
168
+ id: '',
169
+ tableUuid: (0, _helper.uuidv4)('table'),
170
+ alias: ''
171
+ };
172
+ return (0, _jsxRuntime.jsx)("div", {
173
+ className: (0, _classnames["default"])("Sqb-List-section"),
174
+ children: (0, _jsxRuntime.jsx)("div", {
175
+ className: (0, _classnames["default"])("Sqb-List-item mx-2", {
176
+ active: value.name === v.name
177
+ }),
178
+ onClick: function onClick() {
179
+ onChange((0, _objectSpread2["default"])((0, _objectSpread2["default"])({}, _val), v));
180
+ },
181
+ children: (0, _jsxRuntime.jsxs)("a", {
182
+ className: 'p-2',
183
+ children: [(0, _jsxRuntime.jsx)("span", {
184
+ className: 'List-item-icon',
185
+ children: (0, _jsxRuntime.jsx)(_icons.TableIcon, {})
186
+ }), (0, _jsxRuntime.jsx)("div", {
187
+ children: (0, _jsxRuntime.jsx)("h4", {
188
+ className: 'List-item-title ml-2',
189
+ children: (0, _helper.replaceTpl)(store.tableNameTpl, v)
190
+ })
191
+ })]
192
+ })
193
+ })
194
+ }, v.name);
195
+ }))]
196
+ });
197
+ })]
198
+ })
199
+ })
200
+ });
201
+ }
107
202
  var nextPage = !val.datasourceId;
108
203
  // 没有选 数据源 先选数据源
109
204
  if (nextPage) {
@@ -51,7 +51,6 @@
51
51
  width: 66.6667%;
52
52
  box-sizing: border-box;
53
53
 
54
- .Sqb-Custom-input,
55
54
  .sqb-Custom-input {
56
55
  border-radius: 0;
57
56
  padding: 0;
@@ -506,6 +506,7 @@ var JoinData = function JoinData(props) {
506
506
  visible: true,
507
507
  node: node,
508
508
  content: (0, _jsxRuntime.jsx)(_dialog.SelectPermissionTable, {
509
+ tableEnableAlias: store.tableEnableAlias,
509
510
  data: data,
510
511
  value: newMeta[index][table_type],
511
512
  onChange: function onChange(data) {
@@ -547,6 +548,8 @@ var JoinData = function JoinData(props) {
547
548
  visible: true,
548
549
  node: e.currentTarget,
549
550
  content: (0, _jsxRuntime.jsx)(_dialog.SelectTable, {
551
+ sourceTable: store.sourceTable || [],
552
+ tableFlat: store.tableFlat,
550
553
  data: store.sourceList,
551
554
  value: value,
552
555
  onChange: function onChange(data) {
@@ -1348,7 +1351,7 @@ var JoinData = function JoinData(props) {
1348
1351
  if (meta.table1.name === _helper2.SummarizeAlias) {
1349
1352
  return PrevResult;
1350
1353
  } else {
1351
- return "".concat(meta.table1.datasourceName, ".").concat((0, _helper.mergeNameAlias)(meta.table1.name, meta.table1.alias));
1354
+ return "".concat(meta.table1.datasourceName, ".").concat((0, _helper.mergeNameAlias)(meta.table1.name, meta.table1.alias, store.tableEnableAlias));
1352
1355
  }
1353
1356
  } else {
1354
1357
  return '';
@@ -91,6 +91,7 @@ var PermissionTable = function PermissionTable(props) {
91
91
  visible: true,
92
92
  node: e.currentTarget,
93
93
  content: (0, _jsxRuntime.jsx)(_dialog.SelectPermissionTable, {
94
+ tableEnableAlias: store.tableEnableAlias,
94
95
  data: data,
95
96
  value: meta.table,
96
97
  onChange: function onChange(data) {
@@ -87,7 +87,9 @@ var TableData = function TableData(props) {
87
87
  visible: true,
88
88
  node: e.currentTarget,
89
89
  content: (0, _jsxRuntime.jsx)(_dialog.SelectTable, {
90
+ tableFlat: store.tableFlat,
90
91
  data: store.sourceList,
92
+ sourceTable: store.sourceTable || [],
91
93
  value: meta.table,
92
94
  onChange: function onChange(data) {
93
95
  if (meta.table.datasourceId !== data.datasourceId || meta.table.name !== data.name) {