@gingkoo/pandora-metabase 1.0.82 → 1.0.84
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/components/dialog/expression/index.js +1 -0
- package/lib/cjs/components/dialog/formula-list/index.js +137 -74
- package/lib/cjs/components/dialog/formula-list/index.less +13 -0
- package/lib/cjs/components/metabase/index.js +26 -4
- package/lib/cjs/components/metabase/index.less +32 -1
- package/lib/cjs/components/modules/components/header.d.ts +2 -0
- package/lib/cjs/components/modules/components/header.js +11 -6
- package/lib/cjs/components/modules/components/item-wrapper.d.ts +9 -0
- package/lib/cjs/components/modules/components/item-wrapper.js +45 -0
- package/lib/cjs/components/modules/components/meta-icon.d.ts +11 -0
- package/lib/cjs/components/modules/components/meta-icon.js +60 -12
- package/lib/cjs/components/modules/custom-column.js +34 -28
- package/lib/cjs/components/modules/filter.js +18 -12
- package/lib/cjs/components/modules/join-data.js +417 -411
- package/lib/cjs/components/modules/permission-table.js +17 -11
- package/lib/cjs/components/modules/row-limit.js +18 -12
- package/lib/cjs/components/modules/sort.js +33 -27
- package/lib/cjs/components/modules/summarize/index.js +26 -20
- package/lib/cjs/components/modules/table-data.js +137 -131
- package/lib/cjs/components/modules/union.js +14 -8
- package/lib/cjs/components/popup.d.ts +1 -0
- package/lib/cjs/components/popup.js +37 -4
- package/lib/cjs/hooks/use-state.js +44 -4
- package/lib/cjs/index.js +5 -2
- package/lib/cjs/locale/en.js +5 -3
- package/lib/cjs/locale/zh.js +5 -3
- package/lib/cjs/types.d.ts +1 -0
- package/lib/cjs/utils/storage.d.ts +1 -0
- package/lib/cjs/utils/storage.js +2 -1
- package/lib/cjs/utils.d.ts +6 -0
- package/lib/cjs/utils.js +23 -3
- package/lib/es/components/dialog/expression/index.js +1 -0
- package/lib/es/components/dialog/formula-list/index.js +137 -76
- package/lib/es/components/dialog/formula-list/index.less +13 -0
- package/lib/es/components/metabase/index.js +26 -4
- package/lib/es/components/metabase/index.less +32 -1
- package/lib/es/components/modules/components/header.d.ts +2 -0
- package/lib/es/components/modules/components/header.js +12 -7
- package/lib/es/components/modules/components/item-wrapper.d.ts +9 -0
- package/lib/es/components/modules/components/item-wrapper.js +38 -0
- package/lib/es/components/modules/components/meta-icon.d.ts +11 -0
- package/lib/es/components/modules/components/meta-icon.js +60 -14
- package/lib/es/components/modules/custom-column.js +34 -28
- package/lib/es/components/modules/filter.js +18 -12
- package/lib/es/components/modules/join-data.js +417 -411
- package/lib/es/components/modules/permission-table.js +17 -11
- package/lib/es/components/modules/row-limit.js +18 -12
- package/lib/es/components/modules/sort.js +33 -27
- package/lib/es/components/modules/summarize/index.js +26 -20
- package/lib/es/components/modules/table-data.js +137 -131
- package/lib/es/components/modules/union.js +14 -8
- package/lib/es/components/popup.d.ts +1 -0
- package/lib/es/components/popup.js +37 -4
- package/lib/es/hooks/use-state.js +44 -4
- package/lib/es/index.js +5 -2
- package/lib/es/locale/en.js +5 -3
- package/lib/es/locale/zh.js +5 -3
- package/lib/es/types.d.ts +1 -0
- package/lib/es/utils/storage.d.ts +1 -0
- package/lib/es/utils/storage.js +2 -1
- package/lib/es/utils.d.ts +6 -0
- package/lib/es/utils.js +21 -1
- package/package.json +1 -1
|
@@ -166,15 +166,24 @@ var TriggerInternal = /*#__PURE__*/function (_React$Component) {
|
|
|
166
166
|
var _this$props = _this.props,
|
|
167
167
|
node = _this$props.node,
|
|
168
168
|
_this$props$innerSpac = _this$props.innerSpacing,
|
|
169
|
-
innerSpacing = _this$props$innerSpac === void 0 ? 10 : _this$props$innerSpac
|
|
169
|
+
innerSpacing = _this$props$innerSpac === void 0 ? 10 : _this$props$innerSpac,
|
|
170
|
+
_this$props$outSpacin = _this$props.outSpacing,
|
|
171
|
+
outSpacing = _this$props$outSpacin === void 0 ? 5 : _this$props$outSpacin;
|
|
172
|
+
// 假设 outSpacing 也是 props 或者常量,这里保持与你原代码一致,若未定义请确保其存在
|
|
173
|
+
// const outSpacing = this.props.outSpacing || 0;
|
|
170
174
|
var rect = node.getBoundingClientRect();
|
|
175
|
+
// --- 垂直方向逻辑 (保持原样) ---
|
|
171
176
|
var triggerTop = rect.top + window.scrollY;
|
|
172
|
-
var triggerLeft = rect.left + window.scrollX;
|
|
177
|
+
var triggerLeft = rect.left + window.scrollX; // 基准左侧位置
|
|
173
178
|
var triggerHeight = rect.height;
|
|
174
179
|
var popupContent = _this.ref.current;
|
|
175
180
|
var realHeight = popupContent.scrollHeight;
|
|
181
|
+
// 获取弹窗的实际宽度,用于水平碰撞检测
|
|
182
|
+
// 注意:此时 popupContent 可能还没有被渲染到最终位置,但 scrollWidth 通常能反映内容宽度
|
|
183
|
+
var realWidth = popupContent.scrollWidth;
|
|
176
184
|
var _getWindowSize = getWindowSize(),
|
|
177
|
-
viewportHeight = _getWindowSize.height
|
|
185
|
+
viewportHeight = _getWindowSize.height,
|
|
186
|
+
viewportWidth = _getWindowSize.width;
|
|
178
187
|
var spaceBelow = viewportHeight - rect.bottom;
|
|
179
188
|
var spaceAbove = rect.top;
|
|
180
189
|
var topPosition;
|
|
@@ -186,8 +195,32 @@ var TriggerInternal = /*#__PURE__*/function (_React$Component) {
|
|
|
186
195
|
maxHeight = Math.min(realHeight, spaceAbove - innerSpacing - outSpacing);
|
|
187
196
|
topPosition = triggerTop - innerSpacing - maxHeight;
|
|
188
197
|
}
|
|
189
|
-
|
|
198
|
+
// --- 水平方向逻辑 (新增) ---
|
|
199
|
+
var leftPosition = triggerLeft;
|
|
200
|
+
// 1. 检查是否超出右侧边界
|
|
201
|
+
if (leftPosition + realWidth > viewportWidth) {
|
|
202
|
+
// 如果超出,尝试向左移动,使弹窗右边缘对齐屏幕右边缘
|
|
203
|
+
leftPosition = viewportWidth - realWidth;
|
|
204
|
+
}
|
|
205
|
+
// 2. 检查是否超出左侧边界 (兜底策略)
|
|
206
|
+
// 如果弹窗太宽,或者触发点太靠左导致上面的计算结果小于0
|
|
207
|
+
if (leftPosition < 0) {
|
|
208
|
+
leftPosition = 0;
|
|
209
|
+
// 可选:如果弹窗比屏幕还宽,你可能希望限制它的最大宽度为屏幕宽度
|
|
210
|
+
// 此时需要重新计算 realWidth 或者直接限制样式
|
|
211
|
+
// 这里我们通过 CSS 的 maxWidth 来配合,或者在这里强制限制 width
|
|
212
|
+
// 如果必须通过 JS 控制宽度:
|
|
213
|
+
// popupContent.style.width = `${viewportWidth}px`;
|
|
214
|
+
// leftPosition = 0;
|
|
215
|
+
}
|
|
216
|
+
// --- 应用样式 ---
|
|
217
|
+
// 使用 transform 进行定位
|
|
218
|
+
_this.popupContainer.style.transform = "translate(".concat(leftPosition, "px, ").concat(topPosition, "px)");
|
|
219
|
+
// 设置最大高度
|
|
190
220
|
popupContent.style.maxHeight = "".concat(maxHeight, "px");
|
|
221
|
+
// 【重要】为了防止第2步中弹窗过宽超出屏幕,建议同时限制 popupContent 的最大宽度
|
|
222
|
+
// 这样即使 leftPosition=0,内容也不会撑破屏幕
|
|
223
|
+
popupContent.style.maxWidth = "".concat(viewportWidth - outSpacing * 2, "px");
|
|
191
224
|
});
|
|
192
225
|
_this.state = {
|
|
193
226
|
popupRefreshKey: 1
|
|
@@ -9,6 +9,7 @@ import { useEffect, useState, useRef, useMemo } from 'react';
|
|
|
9
9
|
import { uuidv4 } from '../utils/helper';
|
|
10
10
|
import { TypeEnum, JoinEnum, UnionEnum } from '../store/enum';
|
|
11
11
|
import { splitByUnion } from '../utils';
|
|
12
|
+
import storage from '../utils/storage';
|
|
12
13
|
import cloneDeep from 'lodash/cloneDeep';
|
|
13
14
|
import { findIndex } from '../utils';
|
|
14
15
|
var metaKey = 1;
|
|
@@ -172,6 +173,18 @@ var useStore = function useStore() {
|
|
|
172
173
|
_useState60 = _slicedToArray(_useState59, 2),
|
|
173
174
|
sourceData = _useState60[0],
|
|
174
175
|
setSourceData = _useState60[1]; // 原始数据
|
|
176
|
+
var _useState61 = useState(false),
|
|
177
|
+
_useState62 = _slicedToArray(_useState61, 2),
|
|
178
|
+
moduleCopy = _useState62[0],
|
|
179
|
+
setModuleCopy = _useState62[1]; // 是否开启模块复制功能
|
|
180
|
+
var _useState63 = useState(false),
|
|
181
|
+
_useState64 = _slicedToArray(_useState63, 2),
|
|
182
|
+
isMetabaseCopy = _useState64[0],
|
|
183
|
+
setIsMetabaseCopy = _useState64[1]; // 是否开启勾选组复制
|
|
184
|
+
var _useState65 = useState(storage._metabaseCopyModule || []),
|
|
185
|
+
_useState66 = _slicedToArray(_useState65, 2),
|
|
186
|
+
metabaseCopyModule = _useState66[0],
|
|
187
|
+
setMetabaseCopyModule = _useState66[1]; // 复制的内容
|
|
175
188
|
// 外层ref
|
|
176
189
|
var popupContainer = useRef();
|
|
177
190
|
// const [fetchDatasetFn, setFetchDatasetFn] = useState<(id: string) => Promise<any>>(
|
|
@@ -538,9 +551,10 @@ var useStore = function useStore() {
|
|
|
538
551
|
_setMeta(defaultMeta);
|
|
539
552
|
}
|
|
540
553
|
};
|
|
541
|
-
var
|
|
554
|
+
var getNewMeta = function getNewMeta(_type, index, groupIndex, obj) {
|
|
555
|
+
var type = _type || obj.type;
|
|
556
|
+
var item = false;
|
|
542
557
|
var newMeta = metaList[groupIndex].list.slice();
|
|
543
|
-
var item;
|
|
544
558
|
var mainTable = newMeta[0];
|
|
545
559
|
metaKey += 1;
|
|
546
560
|
if (type === TypeEnum.joinData) {
|
|
@@ -647,10 +661,30 @@ var useStore = function useStore() {
|
|
|
647
661
|
var newMetaList = metaList.slice();
|
|
648
662
|
newMetaList.splice.apply(newMetaList, [groupIndex + 1, 0, defaultOperator].concat(defaultMeta));
|
|
649
663
|
_setMeta(newMetaList);
|
|
664
|
+
return false;
|
|
665
|
+
}
|
|
666
|
+
if (obj) {
|
|
667
|
+
item = _objectSpread(_objectSpread({}, obj), {}, {
|
|
668
|
+
metaKey: metaKey
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
return item;
|
|
672
|
+
};
|
|
673
|
+
var addMeta = function addMeta(type, index, groupIndex, obj) {
|
|
674
|
+
var newMeta = metaList[groupIndex].list.slice();
|
|
675
|
+
var items = [];
|
|
676
|
+
if (obj) {
|
|
677
|
+
items = obj.map(function (v) {
|
|
678
|
+
return getNewMeta(type, index, groupIndex, v);
|
|
679
|
+
});
|
|
680
|
+
} else {
|
|
681
|
+
items = [getNewMeta(type, index, groupIndex, obj)];
|
|
682
|
+
}
|
|
683
|
+
if (items[0] === false) {
|
|
650
684
|
return;
|
|
651
685
|
}
|
|
652
686
|
// @ts-ignore
|
|
653
|
-
newMeta.splice(index, 0
|
|
687
|
+
newMeta.splice.apply(newMeta, [index, 0].concat(_toConsumableArray(items)));
|
|
654
688
|
setMeta(newMeta, groupIndex);
|
|
655
689
|
};
|
|
656
690
|
var delMeta = function delMeta(meta, groupIndex) {
|
|
@@ -810,7 +844,13 @@ var useStore = function useStore() {
|
|
|
810
844
|
setFetchDiffFn: setFetchDiffFn,
|
|
811
845
|
getModuleDiffCode: getModuleDiffCode,
|
|
812
846
|
isSubquery: isSubquery,
|
|
813
|
-
setIsSubquery: setIsSubquery
|
|
847
|
+
setIsSubquery: setIsSubquery,
|
|
848
|
+
moduleCopy: moduleCopy,
|
|
849
|
+
setModuleCopy: setModuleCopy,
|
|
850
|
+
metabaseCopyModule: metabaseCopyModule,
|
|
851
|
+
setMetabaseCopyModule: setMetabaseCopyModule,
|
|
852
|
+
isMetabaseCopy: isMetabaseCopy,
|
|
853
|
+
setIsMetabaseCopy: setIsMetabaseCopy
|
|
814
854
|
};
|
|
815
855
|
};
|
|
816
856
|
export default useStore;
|
package/lib/es/index.js
CHANGED
|
@@ -66,7 +66,9 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
66
66
|
_props$metabaseCopy = props.metabaseCopy,
|
|
67
67
|
metabaseCopy = _props$metabaseCopy === void 0 ? false : _props$metabaseCopy,
|
|
68
68
|
_props$moduleDiff = props.moduleDiff,
|
|
69
|
-
moduleDiff = _props$moduleDiff === void 0 ? false : _props$moduleDiff
|
|
69
|
+
moduleDiff = _props$moduleDiff === void 0 ? false : _props$moduleDiff,
|
|
70
|
+
_props$moduleCopy = props.moduleCopy,
|
|
71
|
+
moduleCopy = _props$moduleCopy === void 0 ? false : _props$moduleCopy;
|
|
70
72
|
var store = useData();
|
|
71
73
|
useEffect(function () {
|
|
72
74
|
getTables && store.setFetchDatasetFn(getTables);
|
|
@@ -107,7 +109,8 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
107
109
|
store.setMetabaseCopy(metabaseCopy);
|
|
108
110
|
store.setModuleDiff(moduleDiff);
|
|
109
111
|
store.setIsSubquery(isSubquery);
|
|
110
|
-
|
|
112
|
+
store.setModuleCopy(moduleCopy);
|
|
113
|
+
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit, tableEnableAlias, fieldEnableAlias, groupByEnableAlias, isSelectFields, tableFlat, copyType, metabaseCopy, moduleDiff, isSubquery, moduleCopy]);
|
|
111
114
|
React.useImperativeHandle(ref, function () {
|
|
112
115
|
return {
|
|
113
116
|
// setDatasource: (list) => {
|
package/lib/es/locale/en.js
CHANGED
|
@@ -169,7 +169,9 @@ export default register('en', {
|
|
|
169
169
|
'metabase.copySuccess': 'Copy success',
|
|
170
170
|
'metabase.pasteSuccess': 'Paste success',
|
|
171
171
|
'metabase.paste': 'Paste',
|
|
172
|
-
'customColumn.closeCopy': 'Close
|
|
173
|
-
'customColumn.openCopy': 'Open
|
|
174
|
-
'customColumn.copyAll': 'Copy All'
|
|
172
|
+
'customColumn.closeCopy': 'Close Select',
|
|
173
|
+
'customColumn.openCopy': 'Open Select',
|
|
174
|
+
'customColumn.copyAll': 'Copy All',
|
|
175
|
+
'customColumn.delSelect': 'Delete Selected',
|
|
176
|
+
'customColumn.confirmDelete': 'Confirm delete selected?'
|
|
175
177
|
});
|
package/lib/es/locale/zh.js
CHANGED
|
@@ -169,7 +169,9 @@ export default register('zh', {
|
|
|
169
169
|
'metabase.copySuccess': '复制成功',
|
|
170
170
|
'metabase.pasteSuccess': '粘贴成功',
|
|
171
171
|
'metabase.paste': '粘贴',
|
|
172
|
-
'customColumn.closeCopy': '
|
|
173
|
-
'customColumn.openCopy': '
|
|
174
|
-
'customColumn.copyAll': '复制全部'
|
|
172
|
+
'customColumn.closeCopy': '关闭勾选',
|
|
173
|
+
'customColumn.openCopy': '开启勾选',
|
|
174
|
+
'customColumn.copyAll': '复制全部',
|
|
175
|
+
'customColumn.delSelect': '删除选中',
|
|
176
|
+
'customColumn.confirmDelete': '确认删除选中?'
|
|
175
177
|
});
|
package/lib/es/types.d.ts
CHANGED
package/lib/es/utils/storage.js
CHANGED
|
@@ -37,7 +37,8 @@ export var Cache = /*#__PURE__*/function () {
|
|
|
37
37
|
var storageMap = {
|
|
38
38
|
theme: new Cache(Local, THEME),
|
|
39
39
|
_metabaseCopy: new Cache(Local, '_metabaseCopy'),
|
|
40
|
-
_metabaseCopyItems: new Cache(Local, '_metabaseCopyItems')
|
|
40
|
+
_metabaseCopyItems: new Cache(Local, '_metabaseCopyItems'),
|
|
41
|
+
_metabaseCopyModule: new Cache(Local, '_metabaseCopyModule')
|
|
41
42
|
};
|
|
42
43
|
function observer(obj, key) {
|
|
43
44
|
Object.defineProperty(obj, key, {
|
package/lib/es/utils.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ interface HelperResultType {
|
|
|
12
12
|
nextTypes: TypeEnum[];
|
|
13
13
|
prevList: MetaListType[];
|
|
14
14
|
nextList: MetaListType[];
|
|
15
|
+
prevItem: MetaListType;
|
|
16
|
+
nextItem: MetaListType;
|
|
15
17
|
prevGroupBy: MetaSummarize | undefined;
|
|
16
18
|
nextGroupBy: MetaSummarize | undefined;
|
|
17
19
|
prevTables: {
|
|
@@ -30,4 +32,8 @@ export declare const buildSqlQuery: (data: MetaListType[] | undefined, type: str
|
|
|
30
32
|
export declare const isError: (item: AtomsItem | AtomsItem[], data: DataType[]) => boolean;
|
|
31
33
|
export declare const changeCopyField: (items: AtomsItem[], data: any[]) => AtomsItem[];
|
|
32
34
|
export declare const changeExistsCopyField: (list: MetaListType[], data: any[]) => MetaListType[];
|
|
35
|
+
export declare const metaIsCheck: (data: any[], item: any) => boolean;
|
|
36
|
+
export declare const isCanPaste: (item: MetaListType | MetaListType[], options: {
|
|
37
|
+
nextTypes: string[];
|
|
38
|
+
}) => boolean;
|
|
33
39
|
export {};
|
package/lib/es/utils.js
CHANGED
|
@@ -62,6 +62,10 @@ export var getHelper = function getHelper(list, item) {
|
|
|
62
62
|
var leftList = list.slice(0, curIndex);
|
|
63
63
|
var rightList = list.slice(curIndex + 1);
|
|
64
64
|
var topList = leftList; // 包含自己
|
|
65
|
+
// let prevType = list[curIndex - 1]?.type || '';
|
|
66
|
+
// let nextType = list[curIndex + 1]?.type || '';
|
|
67
|
+
var prevItem = list[curIndex - 1] || {};
|
|
68
|
+
var nextItem = list[curIndex + 1] || {};
|
|
65
69
|
var ExistAboveGroupBy = false;
|
|
66
70
|
var ExistBelowGroupBy = false;
|
|
67
71
|
var prevTypes = [];
|
|
@@ -96,7 +100,9 @@ export var getHelper = function getHelper(list, item) {
|
|
|
96
100
|
nextList: nextList,
|
|
97
101
|
prevGroupBy: prevGroupBy,
|
|
98
102
|
nextGroupBy: nextGroupBy,
|
|
99
|
-
prevTables: prevTables
|
|
103
|
+
prevTables: prevTables,
|
|
104
|
+
prevItem: prevItem,
|
|
105
|
+
nextItem: nextItem
|
|
100
106
|
};
|
|
101
107
|
};
|
|
102
108
|
// 获取子查询的字段
|
|
@@ -887,4 +893,18 @@ export var changeExistsCopyField = function changeExistsCopyField(list, data) {
|
|
|
887
893
|
}
|
|
888
894
|
return _objectSpread({}, v);
|
|
889
895
|
})) || [];
|
|
896
|
+
};
|
|
897
|
+
export var metaIsCheck = function metaIsCheck(data, item) {
|
|
898
|
+
return (data === null || data === void 0 ? void 0 : data.filter(function (v) {
|
|
899
|
+
return v.metaKey == item.metaKey;
|
|
900
|
+
}).length) > 0;
|
|
901
|
+
};
|
|
902
|
+
export var isCanPaste = function isCanPaste(item, options) {
|
|
903
|
+
if (Array.isArray(item)) {
|
|
904
|
+
return item.every(function (v) {
|
|
905
|
+
return options.nextTypes.includes(v.type);
|
|
906
|
+
});
|
|
907
|
+
}
|
|
908
|
+
var type = item.type;
|
|
909
|
+
return options.nextTypes.includes(type);
|
|
890
910
|
};
|