@gingkoo/pandora-metabase 1.0.145 → 1.0.147
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/Loading/index.d.ts +2 -1
- package/lib/cjs/components/dialog/custom-column/dialog/function-tip.d.ts +2 -1
- package/lib/cjs/components/dialog/custom-column/dialog/select-list.d.ts +2 -1
- package/lib/cjs/components/dialog/custom-column/expression-editor.d.ts +2 -1
- package/lib/cjs/components/dialog/custom-column/index.d.ts +2 -1
- package/lib/cjs/components/dialog/custom-column/tokenized-expression.d.ts +1 -1
- package/lib/cjs/components/dialog/custom-editor/index.d.ts +2 -1
- package/lib/cjs/components/dialog/expression/index.d.ts +2 -1
- package/lib/cjs/components/dialog/formula/index.js +15 -0
- package/lib/cjs/components/dialog/formula-list/CaseWhenGroup.d.ts +1 -1
- package/lib/cjs/components/dialog/formula-list/LogicGroup.d.ts +1 -1
- package/lib/cjs/components/dialog/formula-list/index.js +21 -11
- package/lib/cjs/components/dialog/formula-list/index.less +8 -2
- package/lib/cjs/components/dialog/select-column/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-column-multiple/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-join/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-join-column/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-join-column-multiple/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-list/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-permission-table/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-summarize/index.d.ts +2 -1
- package/lib/cjs/components/dialog/select-table/index.d.ts +2 -1
- package/lib/cjs/components/icons.d.ts +30 -29
- package/lib/cjs/components/metabase/index.d.ts +2 -1
- package/lib/cjs/components/metabase/index.js +16 -1
- package/lib/cjs/components/metabase/index.less +34 -0
- package/lib/cjs/components/modules/components/Wrapper.d.ts +1 -1
- package/lib/cjs/components/modules/components/header.d.ts +2 -1
- package/lib/cjs/components/modules/components/item-name.d.ts +1 -1
- package/lib/cjs/components/modules/components/item-wrapper.d.ts +1 -1
- package/lib/cjs/components/modules/components/meta-icon.d.ts +2 -1
- package/lib/cjs/components/modules/custom-column.d.ts +2 -1
- package/lib/cjs/components/modules/custom-column.js +16 -12
- package/lib/cjs/components/modules/filter.d.ts +2 -1
- package/lib/cjs/components/modules/join-data.d.ts +2 -1
- package/lib/cjs/components/modules/join-data.js +132 -113
- package/lib/cjs/components/modules/permission-table.d.ts +2 -1
- package/lib/cjs/components/modules/row-limit.d.ts +2 -1
- package/lib/cjs/components/modules/sort.d.ts +2 -1
- package/lib/cjs/components/modules/sort.js +18 -14
- package/lib/cjs/components/modules/summarize/group-by.d.ts +2 -1
- package/lib/cjs/components/modules/summarize/group-by.js +32 -28
- package/lib/cjs/components/modules/summarize/index.d.ts +2 -1
- package/lib/cjs/components/modules/summarize/select-index.d.ts +2 -1
- package/lib/cjs/components/modules/summarize/select-index.js +32 -28
- package/lib/cjs/components/modules/table-data.d.ts +2 -1
- package/lib/cjs/components/modules/table-data.js +53 -46
- package/lib/cjs/components/modules/union.d.ts +2 -1
- package/lib/cjs/components/popup.d.ts +1 -1
- package/lib/cjs/components/right-click-menu.d.ts +16 -0
- package/lib/cjs/components/right-click-menu.js +179 -0
- package/lib/cjs/components/right-click-value.d.ts +8 -0
- package/lib/cjs/components/right-click-value.js +33 -0
- package/lib/cjs/hooks/use-provider.d.ts +1 -1
- package/lib/cjs/hooks/use-state.js +62 -22
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +4 -1
- package/lib/cjs/types.d.ts +17 -0
- package/lib/es/common/Loading/index.d.ts +2 -1
- package/lib/es/components/dialog/custom-column/dialog/function-tip.d.ts +2 -1
- package/lib/es/components/dialog/custom-column/dialog/select-list.d.ts +2 -1
- package/lib/es/components/dialog/custom-column/expression-editor.d.ts +2 -1
- package/lib/es/components/dialog/custom-column/index.d.ts +2 -1
- package/lib/es/components/dialog/custom-column/tokenized-expression.d.ts +1 -1
- package/lib/es/components/dialog/custom-editor/index.d.ts +2 -1
- package/lib/es/components/dialog/expression/index.d.ts +2 -1
- package/lib/es/components/dialog/formula/index.js +15 -0
- package/lib/es/components/dialog/formula-list/CaseWhenGroup.d.ts +1 -1
- package/lib/es/components/dialog/formula-list/LogicGroup.d.ts +1 -1
- package/lib/es/components/dialog/formula-list/index.js +22 -12
- package/lib/es/components/dialog/formula-list/index.less +8 -2
- package/lib/es/components/dialog/select-column/index.d.ts +2 -1
- package/lib/es/components/dialog/select-column-multiple/index.d.ts +2 -1
- package/lib/es/components/dialog/select-join/index.d.ts +2 -1
- package/lib/es/components/dialog/select-join-column/index.d.ts +2 -1
- package/lib/es/components/dialog/select-join-column-multiple/index.d.ts +2 -1
- package/lib/es/components/dialog/select-list/index.d.ts +2 -1
- package/lib/es/components/dialog/select-permission-table/index.d.ts +2 -1
- package/lib/es/components/dialog/select-summarize/index.d.ts +2 -1
- package/lib/es/components/dialog/select-table/index.d.ts +2 -1
- package/lib/es/components/icons.d.ts +30 -29
- package/lib/es/components/metabase/index.d.ts +2 -1
- package/lib/es/components/metabase/index.js +15 -2
- package/lib/es/components/metabase/index.less +34 -0
- package/lib/es/components/modules/components/Wrapper.d.ts +1 -1
- package/lib/es/components/modules/components/header.d.ts +2 -1
- package/lib/es/components/modules/components/item-name.d.ts +1 -1
- package/lib/es/components/modules/components/item-wrapper.d.ts +1 -1
- package/lib/es/components/modules/components/meta-icon.d.ts +2 -1
- package/lib/es/components/modules/custom-column.d.ts +2 -1
- package/lib/es/components/modules/custom-column.js +16 -12
- package/lib/es/components/modules/filter.d.ts +2 -1
- package/lib/es/components/modules/join-data.d.ts +2 -1
- package/lib/es/components/modules/join-data.js +132 -113
- package/lib/es/components/modules/permission-table.d.ts +2 -1
- package/lib/es/components/modules/row-limit.d.ts +2 -1
- package/lib/es/components/modules/sort.d.ts +2 -1
- package/lib/es/components/modules/sort.js +18 -14
- package/lib/es/components/modules/summarize/group-by.d.ts +2 -1
- package/lib/es/components/modules/summarize/group-by.js +32 -28
- package/lib/es/components/modules/summarize/index.d.ts +2 -1
- package/lib/es/components/modules/summarize/select-index.d.ts +2 -1
- package/lib/es/components/modules/summarize/select-index.js +32 -28
- package/lib/es/components/modules/table-data.d.ts +2 -1
- package/lib/es/components/modules/table-data.js +53 -46
- package/lib/es/components/modules/union.d.ts +2 -1
- package/lib/es/components/popup.d.ts +1 -1
- package/lib/es/components/right-click-menu.d.ts +16 -0
- package/lib/es/components/right-click-menu.js +172 -0
- package/lib/es/components/right-click-value.d.ts +8 -0
- package/lib/es/components/right-click-value.js +25 -0
- package/lib/es/hooks/use-provider.d.ts +1 -1
- package/lib/es/hooks/use-state.js +62 -22
- package/lib/es/index.d.ts +2 -2
- package/lib/es/index.js +4 -1
- package/lib/es/types.d.ts +17 -0
- package/package.json +2 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { MetaData } from '../../store/types';
|
|
2
3
|
interface PropsType {
|
|
3
4
|
meta: MetaData;
|
|
4
5
|
groupIndex: number;
|
|
5
6
|
}
|
|
6
|
-
declare const TableData: (props: PropsType) =>
|
|
7
|
+
declare const TableData: (props: PropsType) => React.JSX.Element;
|
|
7
8
|
export default TableData;
|
|
@@ -18,6 +18,7 @@ import { changeTableAlias, getSubColumns, mergeSubQueryColumns, isValidSQLAlias,
|
|
|
18
18
|
import { RelatedWork } from '@gingkoo/pandora-icons';
|
|
19
19
|
import cloneDeep from 'lodash/cloneDeep';
|
|
20
20
|
import ItemName from './components/item-name';
|
|
21
|
+
import RightClickValue from '../right-click-value';
|
|
21
22
|
import { SelectTable, SelectColumn } from '../dialog';
|
|
22
23
|
import Wrapper from './components/Wrapper';
|
|
23
24
|
import NextDom from './components/meta-icon';
|
|
@@ -292,14 +293,58 @@ var TableData = function TableData(props) {
|
|
|
292
293
|
className: "Sqb-NotebookCell",
|
|
293
294
|
children: [meta.isSubquery ? _jsx(ItemName, {
|
|
294
295
|
isError: isExistsError(meta.subquery || [], store.existsError),
|
|
296
|
+
children: _jsx(RightClickValue, {
|
|
297
|
+
value: meta,
|
|
298
|
+
children: _jsxs("div", {
|
|
299
|
+
className: cx("Sqb-TableName", {
|
|
300
|
+
notSelected: !subQuerySelected
|
|
301
|
+
}),
|
|
302
|
+
onClick: function onClick() {
|
|
303
|
+
showSubQuery(meta.subquery);
|
|
304
|
+
},
|
|
305
|
+
children: [subQuerySelected && _jsx(_Fragment, {
|
|
306
|
+
children: function () {
|
|
307
|
+
var showButton = store.tableEnableAlias || tableIsError() && isDel;
|
|
308
|
+
var icon = isDel ? _jsx(ExclamationCircleFill, {}) : store.tableEnableAlias ? 'As' : '';
|
|
309
|
+
return showButton ? _jsx(Tooltip, {
|
|
310
|
+
title: __(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
|
|
311
|
+
children: _jsx(Button, {
|
|
312
|
+
danger: tableIsError(),
|
|
313
|
+
className: cx(':Sqb-TableName-as', {
|
|
314
|
+
isError: tableIsError()
|
|
315
|
+
}),
|
|
316
|
+
shape: 'circle',
|
|
317
|
+
style: isDel ? {
|
|
318
|
+
fontSize: 18,
|
|
319
|
+
backgroundColor: '#fff',
|
|
320
|
+
width: 'auto',
|
|
321
|
+
height: 'auto'
|
|
322
|
+
} : {},
|
|
323
|
+
iconOnly: true,
|
|
324
|
+
primary: !isDel,
|
|
325
|
+
icon: icon,
|
|
326
|
+
size: 'small',
|
|
327
|
+
onClick: function onClick(e) {
|
|
328
|
+
if (store.tableEnableAlias) {
|
|
329
|
+
var _meta$table3;
|
|
330
|
+
e.stopPropagation();
|
|
331
|
+
onChangeTableAlias(((_meta$table3 = meta.table) === null || _meta$table3 === void 0 ? void 0 : _meta$table3.alias) || '');
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
})
|
|
335
|
+
}) : null;
|
|
336
|
+
}()
|
|
337
|
+
}), subQuerySelected ? "".concat(((_meta$subquery2 = meta.subquery) === null || _meta$subquery2 === void 0 ? void 0 : _meta$subquery2[0]).table.datasourceName, ".").concat(((_meta$subquery3 = meta.subquery) === null || _meta$subquery3 === void 0 ? void 0 : _meta$subquery3[0]).table.name, " ").concat((_meta$table4 = meta.table) !== null && _meta$table4 !== void 0 && _meta$table4.alias && store.tableEnableAlias ? "as ".concat((_meta$table5 = meta.table) === null || _meta$table5 === void 0 ? void 0 : _meta$table5.alias) : '', " ") : __('SqlQueryBuilder.setSubQuery')]
|
|
338
|
+
})
|
|
339
|
+
})
|
|
340
|
+
}) : _jsx(RightClickValue, {
|
|
341
|
+
value: meta.table,
|
|
295
342
|
children: _jsxs("div", {
|
|
296
343
|
className: cx("Sqb-TableName", {
|
|
297
|
-
notSelected: !
|
|
344
|
+
notSelected: !selected
|
|
298
345
|
}),
|
|
299
|
-
onClick:
|
|
300
|
-
|
|
301
|
-
},
|
|
302
|
-
children: [subQuerySelected && _jsx(_Fragment, {
|
|
346
|
+
onClick: selectTable,
|
|
347
|
+
children: [selected && _jsx(_Fragment, {
|
|
303
348
|
children: function () {
|
|
304
349
|
var showButton = store.tableEnableAlias || tableIsError() && isDel;
|
|
305
350
|
var icon = isDel ? _jsx(ExclamationCircleFill, {}) : store.tableEnableAlias ? 'As' : '';
|
|
@@ -323,54 +368,16 @@ var TableData = function TableData(props) {
|
|
|
323
368
|
size: 'small',
|
|
324
369
|
onClick: function onClick(e) {
|
|
325
370
|
if (store.tableEnableAlias) {
|
|
326
|
-
var _meta$
|
|
371
|
+
var _meta$table6;
|
|
327
372
|
e.stopPropagation();
|
|
328
|
-
onChangeTableAlias(((_meta$
|
|
373
|
+
onChangeTableAlias(((_meta$table6 = meta.table) === null || _meta$table6 === void 0 ? void 0 : _meta$table6.alias) || '');
|
|
329
374
|
}
|
|
330
375
|
}
|
|
331
376
|
})
|
|
332
377
|
}) : null;
|
|
333
378
|
}()
|
|
334
|
-
}),
|
|
379
|
+
}), selected ? "".concat(meta.table.datasourceName, ".").concat(meta.table.name, " ").concat((_meta$table7 = meta.table) !== null && _meta$table7 !== void 0 && _meta$table7.alias && store.tableEnableAlias ? "as ".concat((_meta$table8 = meta.table) === null || _meta$table8 === void 0 ? void 0 : _meta$table8.alias) : '') : __('SqlQueryBuilder.pickTable')]
|
|
335
380
|
})
|
|
336
|
-
}) : _jsxs("div", {
|
|
337
|
-
className: cx("Sqb-TableName", {
|
|
338
|
-
notSelected: !selected
|
|
339
|
-
}),
|
|
340
|
-
onClick: selectTable,
|
|
341
|
-
children: [selected && _jsx(_Fragment, {
|
|
342
|
-
children: function () {
|
|
343
|
-
var showButton = store.tableEnableAlias || tableIsError() && isDel;
|
|
344
|
-
var icon = isDel ? _jsx(ExclamationCircleFill, {}) : store.tableEnableAlias ? 'As' : '';
|
|
345
|
-
return showButton ? _jsx(Tooltip, {
|
|
346
|
-
title: __(tableIsError() ? isDel ? 'metabase.verify' : 'SqlQueryBuilder.repeatAlias' : 'SqlQueryBuilder.alias'),
|
|
347
|
-
children: _jsx(Button, {
|
|
348
|
-
danger: tableIsError(),
|
|
349
|
-
className: cx(':Sqb-TableName-as', {
|
|
350
|
-
isError: tableIsError()
|
|
351
|
-
}),
|
|
352
|
-
shape: 'circle',
|
|
353
|
-
style: isDel ? {
|
|
354
|
-
fontSize: 18,
|
|
355
|
-
backgroundColor: '#fff',
|
|
356
|
-
width: 'auto',
|
|
357
|
-
height: 'auto'
|
|
358
|
-
} : {},
|
|
359
|
-
iconOnly: true,
|
|
360
|
-
primary: !isDel,
|
|
361
|
-
icon: icon,
|
|
362
|
-
size: 'small',
|
|
363
|
-
onClick: function onClick(e) {
|
|
364
|
-
if (store.tableEnableAlias) {
|
|
365
|
-
var _meta$table6;
|
|
366
|
-
e.stopPropagation();
|
|
367
|
-
onChangeTableAlias(((_meta$table6 = meta.table) === null || _meta$table6 === void 0 ? void 0 : _meta$table6.alias) || '');
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
})
|
|
371
|
-
}) : null;
|
|
372
|
-
}()
|
|
373
|
-
}), selected ? "".concat(meta.table.datasourceName, ".").concat(meta.table.name, " ").concat((_meta$table7 = meta.table) !== null && _meta$table7 !== void 0 && _meta$table7.alias && store.tableEnableAlias ? "as ".concat((_meta$table8 = meta.table) === null || _meta$table8 === void 0 ? void 0 : _meta$table8.alias) : '') : __('SqlQueryBuilder.pickTable')]
|
|
374
381
|
}), store.showSubquery && _jsx(Tooltip, {
|
|
375
382
|
title: __('SqlQueryBuilder.switchSubQuery'),
|
|
376
383
|
children: _jsx(Button, {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { UnionEnum } from '../../store/enum';
|
|
2
3
|
interface PropsType {
|
|
3
4
|
store?: any;
|
|
@@ -5,5 +6,5 @@ interface PropsType {
|
|
|
5
6
|
union: UnionEnum;
|
|
6
7
|
groupIndex: number;
|
|
7
8
|
}
|
|
8
|
-
declare const RowLimit: (props: PropsType) =>
|
|
9
|
+
declare const RowLimit: (props: PropsType) => React.JSX.Element;
|
|
9
10
|
export default RowLimit;
|
|
@@ -41,7 +41,7 @@ declare class TriggerInternal extends React.Component<PropsType, StateType> {
|
|
|
41
41
|
private getContainer;
|
|
42
42
|
private getComponent;
|
|
43
43
|
private didUpdate;
|
|
44
|
-
render():
|
|
44
|
+
render(): React.JSX.Element | null;
|
|
45
45
|
}
|
|
46
46
|
export declare function generateTrigger(PortalComponent: any): typeof TriggerInternal;
|
|
47
47
|
declare const _default: typeof TriggerInternal;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export type RightClickMenuState = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
item: any;
|
|
6
|
+
itemText: string;
|
|
7
|
+
target: HTMLElement;
|
|
8
|
+
};
|
|
9
|
+
export declare const openSqbRightClickMenu: (store: any, event: React.MouseEvent<HTMLElement>, setMenuState?: (state: RightClickMenuState | null) => void) => void;
|
|
10
|
+
interface SqbRightClickMenuProps {
|
|
11
|
+
popupZIndex?: number;
|
|
12
|
+
state?: RightClickMenuState | null;
|
|
13
|
+
setState?: (state: RightClickMenuState | null) => void;
|
|
14
|
+
}
|
|
15
|
+
declare const SqbRightClickMenu: ({ popupZIndex, state, setState }: SqbRightClickMenuProps) => React.JSX.Element | null;
|
|
16
|
+
export default SqbRightClickMenu;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
2
|
+
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useEffect } from 'react';
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
import { normalizeLegacySummarizeForSave, splitByUnion } from '../utils';
|
|
8
|
+
import { useStore } from '../hooks/use-provider';
|
|
9
|
+
var findRightClickTarget = function findRightClickTarget(target) {
|
|
10
|
+
var element = target instanceof HTMLElement ? target : null;
|
|
11
|
+
while (element) {
|
|
12
|
+
var _element$classList, _element$classList2, _element$classList3;
|
|
13
|
+
if ((_element$classList = element.classList) !== null && _element$classList !== void 0 && _element$classList.contains('Sqb-TableName') || (_element$classList2 = element.classList) !== null && _element$classList2 !== void 0 && _element$classList2.contains(':Sqb-TableName') && !((_element$classList3 = element.classList) !== null && _element$classList3 !== void 0 && _element$classList3.contains('operator-trigger'))) {
|
|
14
|
+
return element;
|
|
15
|
+
}
|
|
16
|
+
element = element.parentElement;
|
|
17
|
+
}
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
var getRightClickTriggerText = function getRightClickTriggerText(element) {
|
|
21
|
+
return (element.innerText || '').replace(/\s+/g, ' ').trim();
|
|
22
|
+
};
|
|
23
|
+
var getRightClickTriggerValue = function getRightClickTriggerValue(store, element, triggerText) {
|
|
24
|
+
var valueId = element.getAttribute('data-right-click-id');
|
|
25
|
+
if (valueId) {
|
|
26
|
+
var registeredValue = store.getRightClickButtonValue(valueId);
|
|
27
|
+
if (registeredValue !== undefined && registeredValue !== null) {
|
|
28
|
+
return registeredValue;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return triggerText;
|
|
32
|
+
};
|
|
33
|
+
var isEmptyRightClickTriggerValue = function isEmptyRightClickTriggerValue(value) {
|
|
34
|
+
if (value === undefined || value === null) return true;
|
|
35
|
+
if (typeof value === 'string') return !value.trim();
|
|
36
|
+
if (Array.isArray(value)) return value.length === 0;
|
|
37
|
+
if (_typeof(value) === 'object') {
|
|
38
|
+
if (value.type === 'exists' || value.type === 'notExists') {
|
|
39
|
+
return !Array.isArray(value.notExists) || value.notExists.length === 0;
|
|
40
|
+
}
|
|
41
|
+
if (value.type === 'FORMULA') {
|
|
42
|
+
return !String(value.name || '').trim();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
47
|
+
export var openSqbRightClickMenu = function openSqbRightClickMenu(store, event, setMenuState) {
|
|
48
|
+
var _store$getRightClickM;
|
|
49
|
+
var rightClickMenu = store.rightClickMenu || [];
|
|
50
|
+
var onRightClickMenuClick = (_store$getRightClickM = store.getRightClickMenuClick) === null || _store$getRightClickM === void 0 ? void 0 : _store$getRightClickM.call(store);
|
|
51
|
+
var setState = setMenuState || store.setRightClickMenuState;
|
|
52
|
+
if (!Array.isArray(rightClickMenu) || rightClickMenu.length === 0 || typeof onRightClickMenuClick !== 'function') {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
var target = findRightClickTarget(event.target);
|
|
56
|
+
if (!target || target.classList.contains('notSelected')) {
|
|
57
|
+
setState(null);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
var itemText = getRightClickTriggerText(target);
|
|
61
|
+
var item = getRightClickTriggerValue(store, target, itemText);
|
|
62
|
+
if (isEmptyRightClickTriggerValue(item)) {
|
|
63
|
+
setState(null);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
event.stopPropagation();
|
|
68
|
+
setState({
|
|
69
|
+
x: event.clientX,
|
|
70
|
+
y: event.clientY,
|
|
71
|
+
item: item,
|
|
72
|
+
itemText: itemText,
|
|
73
|
+
target: target
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
var SqbRightClickMenu = function SqbRightClickMenu(_ref) {
|
|
77
|
+
var popupZIndex = _ref.popupZIndex,
|
|
78
|
+
state = _ref.state,
|
|
79
|
+
setState = _ref.setState;
|
|
80
|
+
var store = useStore();
|
|
81
|
+
var _store$rightClickMenu = store.rightClickMenu,
|
|
82
|
+
rightClickMenu = _store$rightClickMenu === void 0 ? [] : _store$rightClickMenu;
|
|
83
|
+
var rightClickMenuState = state === undefined ? store.rightClickMenuState : state;
|
|
84
|
+
var setRightClickMenuState = setState || store.setRightClickMenuState;
|
|
85
|
+
var handleRightClickMenuItem = function () {
|
|
86
|
+
var _ref2 = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(menuItem) {
|
|
87
|
+
var _store$getRightClickM2;
|
|
88
|
+
var onRightClickMenuClick, shouldClose;
|
|
89
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
90
|
+
while (1) switch (_context.prev = _context.next) {
|
|
91
|
+
case 0:
|
|
92
|
+
if (!(!rightClickMenuState || menuItem.disabled)) {
|
|
93
|
+
_context.next = 1;
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
return _context.abrupt("return");
|
|
97
|
+
case 1:
|
|
98
|
+
onRightClickMenuClick = (_store$getRightClickM2 = store.getRightClickMenuClick) === null || _store$getRightClickM2 === void 0 ? void 0 : _store$getRightClickM2.call(store);
|
|
99
|
+
if (!(typeof onRightClickMenuClick !== 'function')) {
|
|
100
|
+
_context.next = 2;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
return _context.abrupt("return");
|
|
104
|
+
case 2:
|
|
105
|
+
_context.next = 3;
|
|
106
|
+
return onRightClickMenuClick({
|
|
107
|
+
item: rightClickMenuState.item,
|
|
108
|
+
itemText: rightClickMenuState.itemText,
|
|
109
|
+
menuValue: menuItem.value,
|
|
110
|
+
menuItem: menuItem,
|
|
111
|
+
data: normalizeLegacySummarizeForSave(splitByUnion(store.metaList)),
|
|
112
|
+
target: rightClickMenuState.target
|
|
113
|
+
});
|
|
114
|
+
case 3:
|
|
115
|
+
shouldClose = _context.sent;
|
|
116
|
+
if (shouldClose === true) {
|
|
117
|
+
setRightClickMenuState(null);
|
|
118
|
+
}
|
|
119
|
+
case 4:
|
|
120
|
+
case "end":
|
|
121
|
+
return _context.stop();
|
|
122
|
+
}
|
|
123
|
+
}, _callee);
|
|
124
|
+
}));
|
|
125
|
+
return function handleRightClickMenuItem(_x) {
|
|
126
|
+
return _ref2.apply(this, arguments);
|
|
127
|
+
};
|
|
128
|
+
}();
|
|
129
|
+
useEffect(function () {
|
|
130
|
+
if (!rightClickMenuState) return;
|
|
131
|
+
var closeRightClickMenu = function closeRightClickMenu() {
|
|
132
|
+
return setRightClickMenuState(null);
|
|
133
|
+
};
|
|
134
|
+
window.addEventListener('click', closeRightClickMenu);
|
|
135
|
+
window.addEventListener('scroll', closeRightClickMenu, true);
|
|
136
|
+
window.addEventListener('resize', closeRightClickMenu);
|
|
137
|
+
return function () {
|
|
138
|
+
window.removeEventListener('click', closeRightClickMenu);
|
|
139
|
+
window.removeEventListener('scroll', closeRightClickMenu, true);
|
|
140
|
+
window.removeEventListener('resize', closeRightClickMenu);
|
|
141
|
+
};
|
|
142
|
+
}, [rightClickMenuState]);
|
|
143
|
+
if (!rightClickMenuState) return null;
|
|
144
|
+
return _jsx("div", {
|
|
145
|
+
className: 'Sqb-right-click-menu',
|
|
146
|
+
style: {
|
|
147
|
+
left: rightClickMenuState.x,
|
|
148
|
+
top: rightClickMenuState.y,
|
|
149
|
+
zIndex: popupZIndex ? popupZIndex + 10 : 9999
|
|
150
|
+
},
|
|
151
|
+
onClick: function onClick(event) {
|
|
152
|
+
return event.stopPropagation();
|
|
153
|
+
},
|
|
154
|
+
onContextMenu: function onContextMenu(event) {
|
|
155
|
+
return event.preventDefault();
|
|
156
|
+
},
|
|
157
|
+
children: rightClickMenu.map(function (menuItem) {
|
|
158
|
+
return _jsx("button", {
|
|
159
|
+
type: 'button',
|
|
160
|
+
className: cx('Sqb-right-click-menu-item', {
|
|
161
|
+
disabled: menuItem.disabled
|
|
162
|
+
}),
|
|
163
|
+
disabled: menuItem.disabled,
|
|
164
|
+
onClick: function onClick() {
|
|
165
|
+
return handleRightClickMenuItem(menuItem);
|
|
166
|
+
},
|
|
167
|
+
children: menuItem.label
|
|
168
|
+
}, menuItem.value);
|
|
169
|
+
})
|
|
170
|
+
});
|
|
171
|
+
};
|
|
172
|
+
export default SqbRightClickMenu;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface RightClickValueProps {
|
|
3
|
+
value: any;
|
|
4
|
+
children: React.ReactElement;
|
|
5
|
+
}
|
|
6
|
+
declare const RightClickValue: ({ value, children }: RightClickValueProps) => React.ReactElement<any, string | React.JSXElementConstructor<any>>;
|
|
7
|
+
export declare const useRightClickValue: (value: any) => string;
|
|
8
|
+
export default RightClickValue;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { useStore } from '../hooks/use-provider';
|
|
3
|
+
var RightClickValue = function RightClickValue(_ref) {
|
|
4
|
+
var value = _ref.value,
|
|
5
|
+
children = _ref.children;
|
|
6
|
+
var valueId = useRightClickValue(value);
|
|
7
|
+
return React.cloneElement(children, {
|
|
8
|
+
'data-right-click-id': valueId
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
export var useRightClickValue = function useRightClickValue(value) {
|
|
12
|
+
var store = useStore();
|
|
13
|
+
var valueIdRef = useRef();
|
|
14
|
+
if (!valueIdRef.current) {
|
|
15
|
+
valueIdRef.current = "sqb-right-click-".concat(Math.random().toString(36).slice(2));
|
|
16
|
+
}
|
|
17
|
+
useEffect(function () {
|
|
18
|
+
store.setRightClickButtonValue(valueIdRef.current, value);
|
|
19
|
+
return function () {
|
|
20
|
+
store.removeRightClickButtonValue(valueIdRef.current);
|
|
21
|
+
};
|
|
22
|
+
}, [store, value]);
|
|
23
|
+
return valueIdRef.current;
|
|
24
|
+
};
|
|
25
|
+
export default RightClickValue;
|
|
@@ -6,6 +6,6 @@ interface ProviderProps {
|
|
|
6
6
|
value: ContextProps;
|
|
7
7
|
children: React.ReactNode;
|
|
8
8
|
}
|
|
9
|
-
export declare const Provider: ({ value, children }: ProviderProps) =>
|
|
9
|
+
export declare const Provider: ({ value, children }: ProviderProps) => React.JSX.Element;
|
|
10
10
|
export declare const useStore: any;
|
|
11
11
|
export {};
|
|
@@ -188,38 +188,67 @@ var useStore = function useStore() {
|
|
|
188
188
|
_useState64 = _slicedToArray(_useState63, 2),
|
|
189
189
|
showFormulaDiff = _useState64[0],
|
|
190
190
|
setShowFormulaDiff = _useState64[1];
|
|
191
|
-
var _useState65 = useState(
|
|
191
|
+
var _useState65 = useState(true),
|
|
192
192
|
_useState66 = _slicedToArray(_useState65, 2),
|
|
193
|
-
|
|
194
|
-
|
|
193
|
+
matchBrackets = _useState66[0],
|
|
194
|
+
setMatchBrackets = _useState66[1];
|
|
195
195
|
var _useState67 = useState(false),
|
|
196
196
|
_useState68 = _slicedToArray(_useState67, 2),
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
var _useState69 = useState(
|
|
197
|
+
hasFormulaSqlCode = _useState68[0],
|
|
198
|
+
setHasFormulaSqlCode = _useState68[1];
|
|
199
|
+
var _useState69 = useState(false),
|
|
200
200
|
_useState70 = _slicedToArray(_useState69, 2),
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
var _useState71 = useState(
|
|
201
|
+
hasFormulaDiffCode = _useState70[0],
|
|
202
|
+
setHasFormulaDiffCode = _useState70[1];
|
|
203
|
+
var _useState71 = useState([]),
|
|
204
204
|
_useState72 = _slicedToArray(_useState71, 2),
|
|
205
|
-
|
|
206
|
-
|
|
205
|
+
sourceData = _useState72[0],
|
|
206
|
+
setSourceData = _useState72[1];
|
|
207
207
|
var _useState73 = useState(false),
|
|
208
208
|
_useState74 = _slicedToArray(_useState73, 2),
|
|
209
|
-
|
|
210
|
-
|
|
209
|
+
moduleCopy = _useState74[0],
|
|
210
|
+
setModuleCopy = _useState74[1];
|
|
211
211
|
var _useState75 = useState(false),
|
|
212
212
|
_useState76 = _slicedToArray(_useState75, 2),
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
var _useState77 = useState(
|
|
213
|
+
isMetabaseCopy = _useState76[0],
|
|
214
|
+
setIsMetabaseCopy = _useState76[1];
|
|
215
|
+
var _useState77 = useState(false),
|
|
216
216
|
_useState78 = _slicedToArray(_useState77, 2),
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
var _useState79 = useState(
|
|
217
|
+
joinAliasConflictCheck = _useState78[0],
|
|
218
|
+
setJoinAliasConflictCheck = _useState78[1];
|
|
219
|
+
var _useState79 = useState([]),
|
|
220
220
|
_useState80 = _slicedToArray(_useState79, 2),
|
|
221
|
-
|
|
222
|
-
|
|
221
|
+
existsError = _useState80[0],
|
|
222
|
+
setExistsError = _useState80[1];
|
|
223
|
+
var rightClickButtonValueMap = useRef({});
|
|
224
|
+
var _useState81 = useState([]),
|
|
225
|
+
_useState82 = _slicedToArray(_useState81, 2),
|
|
226
|
+
rightClickMenu = _useState82[0],
|
|
227
|
+
setRightClickMenu = _useState82[1];
|
|
228
|
+
var _useState83 = useState(null),
|
|
229
|
+
_useState84 = _slicedToArray(_useState83, 2),
|
|
230
|
+
rightClickMenuState = _useState84[0],
|
|
231
|
+
setRightClickMenuState = _useState84[1];
|
|
232
|
+
var rightClickMenuClickRef = useRef();
|
|
233
|
+
var _useState85 = useState(storage._metabaseCopyModule || []),
|
|
234
|
+
_useState86 = _slicedToArray(_useState85, 2),
|
|
235
|
+
metabaseCopyModule = _useState86[0],
|
|
236
|
+
setMetabaseCopyModule = _useState86[1];
|
|
237
|
+
var setRightClickMenuClick = function setRightClickMenuClick(fn) {
|
|
238
|
+
rightClickMenuClickRef.current = fn;
|
|
239
|
+
};
|
|
240
|
+
var getRightClickMenuClick = function getRightClickMenuClick() {
|
|
241
|
+
return rightClickMenuClickRef.current;
|
|
242
|
+
};
|
|
243
|
+
var setRightClickButtonValue = function setRightClickButtonValue(id, value) {
|
|
244
|
+
rightClickButtonValueMap.current[id] = value;
|
|
245
|
+
};
|
|
246
|
+
var removeRightClickButtonValue = function removeRightClickButtonValue(id) {
|
|
247
|
+
delete rightClickButtonValueMap.current[id];
|
|
248
|
+
};
|
|
249
|
+
var getRightClickButtonValue = function getRightClickButtonValue(id) {
|
|
250
|
+
return rightClickButtonValueMap.current[id];
|
|
251
|
+
};
|
|
223
252
|
var setFormulaTemplates = function setFormulaTemplates(data) {
|
|
224
253
|
var newData = data === null || data === void 0 ? void 0 : data.map(function (v) {
|
|
225
254
|
var children = v.children.map(function (vv) {
|
|
@@ -1088,6 +1117,8 @@ var useStore = function useStore() {
|
|
|
1088
1117
|
setShowFormulaSql: setShowFormulaSql,
|
|
1089
1118
|
showFormulaDiff: showFormulaDiff,
|
|
1090
1119
|
setShowFormulaDiff: setShowFormulaDiff,
|
|
1120
|
+
matchBrackets: matchBrackets,
|
|
1121
|
+
setMatchBrackets: setMatchBrackets,
|
|
1091
1122
|
hasFormulaSqlCode: hasFormulaSqlCode,
|
|
1092
1123
|
hasFormulaDiffCode: hasFormulaDiffCode,
|
|
1093
1124
|
sourceData: sourceData,
|
|
@@ -1111,7 +1142,16 @@ var useStore = function useStore() {
|
|
|
1111
1142
|
setExistsErrorFn: setExistsErrorFn,
|
|
1112
1143
|
existsError: existsError,
|
|
1113
1144
|
joinAliasConflictCheck: joinAliasConflictCheck,
|
|
1114
|
-
setJoinAliasConflictCheck: setJoinAliasConflictCheck
|
|
1145
|
+
setJoinAliasConflictCheck: setJoinAliasConflictCheck,
|
|
1146
|
+
setRightClickButtonValue: setRightClickButtonValue,
|
|
1147
|
+
removeRightClickButtonValue: removeRightClickButtonValue,
|
|
1148
|
+
getRightClickButtonValue: getRightClickButtonValue,
|
|
1149
|
+
rightClickMenu: rightClickMenu,
|
|
1150
|
+
setRightClickMenu: setRightClickMenu,
|
|
1151
|
+
rightClickMenuState: rightClickMenuState,
|
|
1152
|
+
setRightClickMenuState: setRightClickMenuState,
|
|
1153
|
+
setRightClickMenuClick: setRightClickMenuClick,
|
|
1154
|
+
getRightClickMenuClick: getRightClickMenuClick
|
|
1115
1155
|
};
|
|
1116
1156
|
};
|
|
1117
1157
|
export default useStore;
|
package/lib/es/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import './locale/en';
|
|
3
3
|
import './locale/zh';
|
|
4
|
-
import type { MetabaseProps, SqlVisionBuilderRef, DatasourceType } from './types';
|
|
4
|
+
import type { MetabaseProps, SqlVisionBuilderRef, DatasourceType, MetabaseRightClickMenuItem, MetabaseRightClickMenuClickParams } from './types';
|
|
5
5
|
import type { MetaListType, ToolbarType } from './store/types';
|
|
6
6
|
declare const SqlVisionBuilder: React.ForwardRefExoticComponent<MetabaseProps & React.RefAttributes<SqlVisionBuilderRef>>;
|
|
7
7
|
export default SqlVisionBuilder;
|
|
8
|
-
export { MetabaseProps, DatasourceType, MetaListType, ToolbarType, SqlVisionBuilderRef };
|
|
8
|
+
export { MetabaseProps, DatasourceType, MetaListType, ToolbarType, SqlVisionBuilderRef, MetabaseRightClickMenuItem, MetabaseRightClickMenuClickParams, };
|
package/lib/es/index.js
CHANGED
|
@@ -72,6 +72,8 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
72
72
|
showFormulaSql = _props$showFormulaSql === void 0 ? true : _props$showFormulaSql,
|
|
73
73
|
_props$showFormulaDif = props.showFormulaDiff,
|
|
74
74
|
showFormulaDiff = _props$showFormulaDif === void 0 ? true : _props$showFormulaDif,
|
|
75
|
+
_props$matchBrackets = props.matchBrackets,
|
|
76
|
+
matchBrackets = _props$matchBrackets === void 0 ? true : _props$matchBrackets,
|
|
75
77
|
_props$joinAliasConfl = props.joinAliasConflictCheck,
|
|
76
78
|
joinAliasConflictCheck = _props$joinAliasConfl === void 0 ? false : _props$joinAliasConfl,
|
|
77
79
|
_props$operatorList = props.operatorList,
|
|
@@ -124,11 +126,12 @@ var SqlVisionBuilder = React.forwardRef(function (props, ref) {
|
|
|
124
126
|
store.setModuleDiff(moduleDiff);
|
|
125
127
|
store.setShowFormulaSql(showFormulaSql);
|
|
126
128
|
store.setShowFormulaDiff(showFormulaDiff);
|
|
129
|
+
store.setMatchBrackets(matchBrackets);
|
|
127
130
|
store.setIsSubquery(isSubquery);
|
|
128
131
|
store.setModuleCopy(moduleCopy);
|
|
129
132
|
store.setJoinAliasConflictCheck(joinAliasConflictCheck);
|
|
130
133
|
store.setOperatorList(operatorList || []);
|
|
131
|
-
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit, tableEnableAlias, fieldEnableAlias, groupByEnableAlias, isSelectFields, tableFlat, copyType, metabaseCopy, moduleDiff, showFormulaSql, showFormulaDiff, getFormulaSqlCode, getFormulaDiffCode, isSubquery, moduleCopy, joinAliasConflictCheck, operatorList]);
|
|
134
|
+
}, [showFields, fieldNameTpl, tableNameTpl, toolbar, showSubquery, subShowSubquery, constantList, formulaTemplates, ignoreGroupByType, filterCustomType, isExit, tableEnableAlias, fieldEnableAlias, groupByEnableAlias, isSelectFields, tableFlat, copyType, metabaseCopy, moduleDiff, showFormulaSql, showFormulaDiff, matchBrackets, getFormulaSqlCode, getFormulaDiffCode, isSubquery, moduleCopy, joinAliasConflictCheck, operatorList]);
|
|
132
135
|
React.useImperativeHandle(ref, function () {
|
|
133
136
|
return {
|
|
134
137
|
reset: function reset() {
|
package/lib/es/types.d.ts
CHANGED
|
@@ -26,6 +26,20 @@ export interface FormulaDiffCodeParams {
|
|
|
26
26
|
oldCode: AtomsItem[];
|
|
27
27
|
newCode: AtomsItem[];
|
|
28
28
|
}
|
|
29
|
+
export interface MetabaseRightClickMenuItem {
|
|
30
|
+
label: React.ReactNode;
|
|
31
|
+
value: React.Key;
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
[key: string]: any;
|
|
34
|
+
}
|
|
35
|
+
export interface MetabaseRightClickMenuClickParams {
|
|
36
|
+
item: any;
|
|
37
|
+
itemText: string;
|
|
38
|
+
menuValue: React.Key;
|
|
39
|
+
menuItem: MetabaseRightClickMenuItem;
|
|
40
|
+
data: MetaListType[];
|
|
41
|
+
target?: HTMLElement;
|
|
42
|
+
}
|
|
29
43
|
export interface MetabaseProps {
|
|
30
44
|
loading?: boolean;
|
|
31
45
|
btnText?: string;
|
|
@@ -69,6 +83,9 @@ export interface MetabaseProps {
|
|
|
69
83
|
moduleCopy?: boolean;
|
|
70
84
|
showFormulaSql?: boolean;
|
|
71
85
|
showFormulaDiff?: boolean;
|
|
86
|
+
matchBrackets?: boolean;
|
|
87
|
+
rightClickMenu?: MetabaseRightClickMenuItem[];
|
|
88
|
+
onRightClickMenuClick?: (params: MetabaseRightClickMenuClickParams) => boolean | void | Promise<boolean | void>;
|
|
72
89
|
joinAliasConflictCheck?: boolean;
|
|
73
90
|
getModuleDiffCode?: (obj: {
|
|
74
91
|
oldCode: MetaListType;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gingkoo/pandora-metabase",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.147",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/es/index.js",
|
|
6
6
|
"module": "lib/es/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"react-dom": "^17.0.0 || ^18.0.0"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@gingkoo/pandora": "1.2.20-alpha.
|
|
30
|
+
"@gingkoo/pandora": "1.2.20-alpha.7",
|
|
31
31
|
"@gingkoo/pandora-hooks": "1.0.5",
|
|
32
32
|
"@gingkoo/pandora-icons": "0.0.1-alpha.28",
|
|
33
33
|
"@types/diff": "^8.0.0",
|