es-grid-template 1.2.0 → 1.2.2
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/assets/index.css +695 -0
- package/assets/index.scss +1063 -0
- package/es/grid-component/ColumnsChoose.d.ts +1 -0
- package/es/grid-component/ColumnsChoose.js +63 -28
- package/es/grid-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/grid-component/ColumnsGroup/ColumnsGroup.js +223 -0
- package/es/grid-component/ColumnsGroup/index.d.ts +1 -0
- package/es/grid-component/ColumnsGroup/index.js +1 -0
- package/es/grid-component/ConvertColumnTable.d.ts +7 -0
- package/es/grid-component/ConvertColumnTable.js +143 -0
- package/es/grid-component/EditableCell.js +1 -1
- package/es/grid-component/GridStyle.js +1 -1
- package/es/grid-component/InternalTable.d.ts +1 -0
- package/es/grid-component/InternalTable.js +150 -249
- package/es/grid-component/TableGrid.d.ts +4 -1
- package/es/grid-component/TableGrid.js +31 -70
- package/es/grid-component/hooks/{useColumns → columns}/index.d.ts +2 -2
- package/es/grid-component/hooks/{useColumns → columns}/index.js +20 -16
- package/es/grid-component/hooks/content/HeaderContent.d.ts +11 -0
- package/es/grid-component/hooks/content/HeaderContent.js +79 -0
- package/es/grid-component/hooks/content/TooltipContent.d.ts +13 -0
- package/es/grid-component/hooks/content/TooltipContent.js +74 -0
- package/es/grid-component/hooks/useColumns.d.ts +16 -0
- package/es/grid-component/hooks/useColumns.js +280 -0
- package/es/grid-component/hooks/utils.d.ts +26 -1
- package/es/grid-component/hooks/utils.js +331 -1
- package/es/grid-component/index.js +3 -1
- package/es/grid-component/styles.scss +365 -68
- package/es/grid-component/table/Grid.d.ts +2 -0
- package/es/grid-component/table/Grid.js +18 -6
- package/es/grid-component/table/GridEdit.d.ts +4 -1
- package/es/grid-component/table/GridEdit.js +941 -307
- package/es/grid-component/table/Group.d.ts +13 -0
- package/es/grid-component/table/Group.js +154 -0
- package/es/grid-component/type.d.ts +39 -2
- package/lib/grid-component/ColumnsChoose.d.ts +1 -0
- package/lib/grid-component/ColumnsChoose.js +62 -27
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/grid-component/ColumnsGroup/ColumnsGroup.js +234 -0
- package/lib/grid-component/ColumnsGroup/index.d.ts +1 -0
- package/lib/grid-component/ColumnsGroup/index.js +16 -0
- package/lib/grid-component/ConvertColumnTable.d.ts +7 -0
- package/lib/grid-component/ConvertColumnTable.js +152 -0
- package/lib/grid-component/EditableCell.js +1 -1
- package/lib/grid-component/GridStyle.js +1 -1
- package/lib/grid-component/InternalTable.d.ts +1 -0
- package/lib/grid-component/InternalTable.js +144 -249
- package/lib/grid-component/TableGrid.d.ts +4 -1
- package/lib/grid-component/TableGrid.js +26 -68
- package/lib/grid-component/hooks/{useColumns → columns}/index.d.ts +2 -2
- package/lib/grid-component/hooks/{useColumns → columns}/index.js +20 -16
- package/lib/grid-component/hooks/content/HeaderContent.d.ts +11 -0
- package/lib/grid-component/hooks/content/HeaderContent.js +86 -0
- package/lib/grid-component/hooks/content/TooltipContent.d.ts +13 -0
- package/lib/grid-component/hooks/content/TooltipContent.js +81 -0
- package/lib/grid-component/hooks/useColumns.d.ts +16 -0
- package/lib/grid-component/hooks/useColumns.js +291 -0
- package/lib/grid-component/hooks/utils.d.ts +26 -1
- package/lib/grid-component/hooks/utils.js +347 -5
- package/lib/grid-component/index.js +2 -1
- package/lib/grid-component/styles.scss +365 -68
- package/lib/grid-component/table/Grid.d.ts +2 -0
- package/lib/grid-component/table/Grid.js +18 -6
- package/lib/grid-component/table/GridEdit.d.ts +4 -1
- package/lib/grid-component/table/GridEdit.js +939 -305
- package/lib/grid-component/table/Group.d.ts +13 -0
- package/lib/grid-component/table/Group.js +163 -0
- package/lib/grid-component/type.d.ts +39 -2
- package/package.json +106 -105
|
@@ -5,9 +5,12 @@ import type { ColumnsTable, GetRowKey, GridTableProps } from "./type";
|
|
|
5
5
|
type GridProps<T> = GridTableProps<T> & {
|
|
6
6
|
triggerChangeColumns?: (columns: ColumnsTable<T>, type: string) => void;
|
|
7
7
|
triggerChangeData?: (newData: T[], type: string) => void;
|
|
8
|
+
triggerGroupColumns?: (groupedColumns: string[]) => void;
|
|
8
9
|
tableRef: any;
|
|
9
10
|
bottomToolbar?: () => React.ReactElement;
|
|
10
|
-
getRowKey
|
|
11
|
+
getRowKey: GetRowKey<T>;
|
|
12
|
+
rowSelection?: any;
|
|
13
|
+
groupToolbar?: () => React.ReactNode;
|
|
11
14
|
};
|
|
12
15
|
declare const TableGrid: <RecordType extends object>(props: GridProps<RecordType>) => React.JSX.Element;
|
|
13
16
|
export default TableGrid;
|
|
@@ -15,14 +15,15 @@ require("dayjs/locale/vi");
|
|
|
15
15
|
var _ContextMenu = _interopRequireDefault(require("./ContextMenu"));
|
|
16
16
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
17
|
var _hooks = require("./hooks");
|
|
18
|
-
var
|
|
19
|
-
var _useColumns = require("./hooks/useColumns");
|
|
18
|
+
var _columns = require("./hooks/columns");
|
|
20
19
|
var _pagination = _interopRequireDefault(require("rc-master-ui/es/pagination"));
|
|
21
20
|
var _LoadingSpinner = _interopRequireDefault(require("./LoadingSpinner"));
|
|
22
21
|
var _ColumnsChoose = require("./ColumnsChoose");
|
|
23
22
|
var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
|
|
24
23
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
25
24
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
|
+
// import {ConfigProvider} from "antd";
|
|
26
|
+
|
|
26
27
|
const convertFilters = filters => {
|
|
27
28
|
const result = [];
|
|
28
29
|
filters.forEach(({
|
|
@@ -98,7 +99,6 @@ const TableGrid = props => {
|
|
|
98
99
|
locale,
|
|
99
100
|
expandable,
|
|
100
101
|
rowHoverable,
|
|
101
|
-
// mergedData,
|
|
102
102
|
title,
|
|
103
103
|
format,
|
|
104
104
|
virtual = true,
|
|
@@ -123,10 +123,16 @@ const TableGrid = props => {
|
|
|
123
123
|
dataSourceFilter: propDataSourceFilter,
|
|
124
124
|
loading,
|
|
125
125
|
triggerChangeColumns,
|
|
126
|
+
triggerGroupColumns,
|
|
126
127
|
summary,
|
|
127
128
|
showToolbar,
|
|
128
129
|
onSorter,
|
|
129
130
|
bottomToolbar,
|
|
131
|
+
groupSetting,
|
|
132
|
+
groupAble,
|
|
133
|
+
getRowKey,
|
|
134
|
+
groupColumns,
|
|
135
|
+
groupToolbar,
|
|
130
136
|
...rest
|
|
131
137
|
} = props;
|
|
132
138
|
const {
|
|
@@ -141,16 +147,10 @@ const TableGrid = props => {
|
|
|
141
147
|
selectedRowKeys,
|
|
142
148
|
defaultSelectedRowKeys
|
|
143
149
|
} = selectionSettings || {};
|
|
144
|
-
const clickRef =
|
|
145
|
-
const menuRef =
|
|
150
|
+
const clickRef = _react.default.useRef(null);
|
|
151
|
+
const menuRef = _react.default.useRef(null);
|
|
146
152
|
const viewportWidth = window.innerWidth;
|
|
147
153
|
const viewportHeight = window.innerHeight;
|
|
148
|
-
|
|
149
|
-
// const defaultSelected = useMemo(() => {
|
|
150
|
-
// return defaultSelectedRowKeys ?? []
|
|
151
|
-
//
|
|
152
|
-
// }, [defaultSelectedRowKeys])
|
|
153
|
-
|
|
154
154
|
const [menuVisible, setMenuVisible] = _react.default.useState(false);
|
|
155
155
|
const [selectedRowData, setSelectedRowData] = _react.default.useState(null);
|
|
156
156
|
const [position, setPosition] = _react.default.useState({
|
|
@@ -188,7 +188,7 @@ const TableGrid = props => {
|
|
|
188
188
|
}
|
|
189
189
|
return propContextMenuItems;
|
|
190
190
|
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
191
|
-
|
|
191
|
+
_react.default.useLayoutEffect(() => {
|
|
192
192
|
setMenuVisible(false);
|
|
193
193
|
}, []);
|
|
194
194
|
const onContextMenu = data => event => {
|
|
@@ -295,17 +295,7 @@ const TableGrid = props => {
|
|
|
295
295
|
const handleChange = sorter => {
|
|
296
296
|
onSorter?.(sorter);
|
|
297
297
|
};
|
|
298
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(
|
|
299
|
-
theme: {
|
|
300
|
-
components: {
|
|
301
|
-
Table: {
|
|
302
|
-
rowHoverBg: '#eb461912',
|
|
303
|
-
rowSelectedBg: '#eb4619',
|
|
304
|
-
rowSelectedHoverBg: '#eb4619'
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
}, /*#__PURE__*/_react.default.createElement(_ContextMenu.default, {
|
|
298
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_ContextMenu.default, {
|
|
309
299
|
open: menuVisible,
|
|
310
300
|
pos: position,
|
|
311
301
|
setOpen: setMenuVisible,
|
|
@@ -325,10 +315,9 @@ const TableGrid = props => {
|
|
|
325
315
|
},
|
|
326
316
|
loading: {
|
|
327
317
|
spinning: columns && columns.length === 0 || loading === true,
|
|
328
|
-
// spinning: loading === true,
|
|
329
318
|
indicator: /*#__PURE__*/_react.default.createElement(_LoadingSpinner.default, null)
|
|
330
319
|
},
|
|
331
|
-
dataSource: dataSource
|
|
320
|
+
dataSource: columns && columns.length > 0 && loading !== true ? dataSource : []
|
|
332
321
|
// className={styles.customTable}
|
|
333
322
|
,
|
|
334
323
|
className: (0, _classnames.default)(className, {
|
|
@@ -346,7 +335,6 @@ const TableGrid = props => {
|
|
|
346
335
|
onRow: (data, index) => {
|
|
347
336
|
return {
|
|
348
337
|
onDoubleClick: handleRowDoubleClick(data, index),
|
|
349
|
-
// onClick: handleRowClick,
|
|
350
338
|
onClick: handleRowClick(),
|
|
351
339
|
onContextMenu: onContextMenu(data)
|
|
352
340
|
};
|
|
@@ -377,7 +365,7 @@ const TableGrid = props => {
|
|
|
377
365
|
}
|
|
378
366
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary, {
|
|
379
367
|
fixed: true
|
|
380
|
-
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0,
|
|
368
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0, _columns.flatColumns)([_rcMasterUi.Table.SELECTION_COLUMN, ...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
381
369
|
const thousandSeparator = col.format?.thousandSeparator ? col.format?.thousandSeparator : format?.thousandSeparator;
|
|
382
370
|
const decimalSeparator = col.format?.decimalSeparator ? col.format?.decimalSeparator : format?.decimalSeparator;
|
|
383
371
|
const dec = col.format?.decimalScale || col.format?.decimalScale === 0 ? col.format?.decimalScale : format?.decimalScale;
|
|
@@ -401,7 +389,7 @@ const TableGrid = props => {
|
|
|
401
389
|
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps));
|
|
402
390
|
})));
|
|
403
391
|
},
|
|
404
|
-
pagination: pagination && pagination.onChange ? false : {
|
|
392
|
+
pagination: !pagination || pagination && pagination.onChange ? false : {
|
|
405
393
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
406
394
|
...pagination
|
|
407
395
|
},
|
|
@@ -416,11 +404,11 @@ const TableGrid = props => {
|
|
|
416
404
|
justifyContent: 'space-between',
|
|
417
405
|
alignItems: 'center'
|
|
418
406
|
}
|
|
419
|
-
}, toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar
|
|
407
|
+
}, groupAble && groupToolbar?.(), toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar
|
|
420
408
|
// @ts-ignore
|
|
421
409
|
, {
|
|
422
410
|
style: {
|
|
423
|
-
width: pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' ? `calc(100% - 650px` : `calc(100% - 25px`
|
|
411
|
+
width: pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' ? `calc(100% - 650px - ${groupAble ? 50 : 0}px` : `calc(100% - 25px - ${groupAble ? 50 : 0}px`
|
|
424
412
|
},
|
|
425
413
|
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
426
414
|
mode: 'scroll'
|
|
@@ -441,53 +429,23 @@ const TableGrid = props => {
|
|
|
441
429
|
}, pagination)), showColumnChoose && /*#__PURE__*/_react.default.createElement(_ColumnsChoose.ColumnsChoose, {
|
|
442
430
|
columns: columns,
|
|
443
431
|
t: t,
|
|
432
|
+
columnsGroup: groupColumns,
|
|
444
433
|
triggerChangeColumns: triggerChangeColumns
|
|
445
434
|
}))));
|
|
446
435
|
},
|
|
447
436
|
expandable: {
|
|
448
|
-
|
|
449
|
-
defaultExpandAllRows: true,
|
|
450
|
-
indentSize: 25,
|
|
451
|
-
...expandable,
|
|
452
|
-
expandIcon: args => {
|
|
453
|
-
const {
|
|
454
|
-
record,
|
|
455
|
-
expanded,
|
|
456
|
-
onExpand
|
|
457
|
-
} = args;
|
|
458
|
-
|
|
459
|
-
// @ts-ignore
|
|
460
|
-
if (record?.children?.length > 0 || record?.isChildren) {
|
|
461
|
-
return expanded ? /*#__PURE__*/_react.default.createElement("button", {
|
|
462
|
-
onClick: e => {
|
|
463
|
-
e.preventDefault();
|
|
464
|
-
e.stopPropagation();
|
|
465
|
-
onExpand(record, e);
|
|
466
|
-
},
|
|
467
|
-
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded'
|
|
468
|
-
}) : /*#__PURE__*/_react.default.createElement("button", {
|
|
469
|
-
onClick: e => {
|
|
470
|
-
e.preventDefault();
|
|
471
|
-
e.stopPropagation();
|
|
472
|
-
onExpand(record, e);
|
|
473
|
-
},
|
|
474
|
-
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed'
|
|
475
|
-
});
|
|
476
|
-
} else {
|
|
477
|
-
return /*#__PURE__*/_react.default.createElement("button", {
|
|
478
|
-
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced'
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
}
|
|
437
|
+
...expandable
|
|
482
438
|
}
|
|
483
|
-
})),
|
|
439
|
+
})), /*#__PURE__*/_react.default.createElement("div", null), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/_react.default.createElement(_pagination.default
|
|
484
440
|
// style={{padding: '0.75rem 1rem'}}
|
|
485
441
|
, (0, _extends2.default)({
|
|
486
442
|
rootClassName: 'pagination-template',
|
|
487
443
|
showSizeChanger: true,
|
|
488
444
|
responsive: true,
|
|
489
|
-
size: 'small'
|
|
490
|
-
|
|
491
|
-
|
|
445
|
+
size: 'small'
|
|
446
|
+
// @ts-ignore
|
|
447
|
+
,
|
|
448
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
449
|
+
}, pagination)), bottomToolbar?.());
|
|
492
450
|
};
|
|
493
451
|
var _default = exports.default = TableGrid;
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import type { TableLocale } from "rc-master-ui/lib/table/interface";
|
|
4
4
|
import type { ColumnsTable } from "../../type";
|
|
5
5
|
export declare function flatColumns<RecordType>(columns: ColumnsTable<RecordType>, parentKey?: string): ColumnsTable<RecordType>;
|
|
6
|
-
export declare function flatColumns2<RecordType>(columns: ColumnsTable<RecordType
|
|
6
|
+
export declare function flatColumns2<RecordType>(columns: ColumnsTable<RecordType>): ColumnsTable<RecordType>;
|
|
7
7
|
export declare const getValueCell: <T>(column: ColumnType<T>, value: any, format?: IFormat) => any;
|
|
8
|
-
export declare const renderContent:
|
|
8
|
+
export declare const renderContent: (column: any, value: any, record: any, index: number, format?: IFormat) => React.JSX.Element;
|
|
9
9
|
export declare const renderFilter: <RecordType>(column: ColumnType<RecordType>, selectedKeys: string[], setSelectedKeys: any, confirm: any, visible: boolean, searchValue: string, setSearchValue: any, dataSourceFilter: any[], buddhistLocale: any, locale?: TableLocale, t?: any) => React.JSX.Element;
|
|
@@ -17,8 +17,6 @@ var _CheckboxFilter = _interopRequireDefault(require("../../CheckboxFilter"));
|
|
|
17
17
|
var _useSelection = require("rc-master-ui/es/table/hooks/useSelection");
|
|
18
18
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
19
19
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
20
|
-
// import * as React from 'react'
|
|
21
|
-
|
|
22
20
|
const {
|
|
23
21
|
RangePicker
|
|
24
22
|
} = _rcMasterUi.DatePicker;
|
|
@@ -45,15 +43,16 @@ function flatColumns(columns, parentKey = 'key') {
|
|
|
45
43
|
}];
|
|
46
44
|
}, []);
|
|
47
45
|
}
|
|
48
|
-
function flatColumns2(columns
|
|
46
|
+
function flatColumns2(columns
|
|
47
|
+
// parentKey = 'key'
|
|
48
|
+
) {
|
|
49
49
|
// @ts-ignore
|
|
50
|
-
return columns.reduce((list, column
|
|
51
|
-
const {
|
|
52
|
-
fixed
|
|
53
|
-
} = column;
|
|
50
|
+
return columns.reduce((list, column) => {
|
|
51
|
+
// const { fixed } = column
|
|
54
52
|
// Convert `fixed='true'` to `fixed='left'` instead
|
|
55
|
-
const parsedFixed = fixed === true ? 'left' : fixed
|
|
56
|
-
const mergedKey = `${parentKey}-${index}
|
|
53
|
+
// const parsedFixed = fixed === true ? 'left' : fixed
|
|
54
|
+
// const mergedKey = `${parentKey}-${index}`
|
|
55
|
+
|
|
57
56
|
const subColumns = column.children;
|
|
58
57
|
if (column === _useSelection.SELECTION_COLUMN) {
|
|
59
58
|
return [...list, {
|
|
@@ -61,15 +60,15 @@ function flatColumns2(columns, parentKey = 'key') {
|
|
|
61
60
|
}];
|
|
62
61
|
}
|
|
63
62
|
if (subColumns && subColumns.length > 0) {
|
|
64
|
-
return [...list, ...flatColumns(subColumns
|
|
65
|
-
fixed: parsedFixed,
|
|
63
|
+
return [...list, ...flatColumns(subColumns).map(subColum => ({
|
|
64
|
+
// fixed: parsedFixed,
|
|
66
65
|
...subColum
|
|
67
66
|
}))];
|
|
68
67
|
}
|
|
69
68
|
return [...list, {
|
|
70
|
-
key: mergedKey,
|
|
71
|
-
...column
|
|
72
|
-
fixed: parsedFixed
|
|
69
|
+
// key: mergedKey,
|
|
70
|
+
...column
|
|
71
|
+
// fixed: parsedFixed
|
|
73
72
|
}];
|
|
74
73
|
}, []);
|
|
75
74
|
}
|
|
@@ -138,8 +137,13 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
|
|
|
138
137
|
const type = (0, _utils.getTypeFilter)(column);
|
|
139
138
|
const dateFormat = (0, _utils.getDatepickerFormat)(column?.typeFilter ?? column?.type, column) ?? 'DD/MM/YYYY';
|
|
140
139
|
const dateRangeFormat = (0, _utils.getDatepickerFormat)(column?.type, column) ?? 'DD/MM/YYYY';
|
|
141
|
-
const find = dataSourceFilter?.find(it => it.key === column?.
|
|
140
|
+
const find = dataSourceFilter?.find(it => it.key === column?.field);
|
|
142
141
|
const options = find ? find.data : [];
|
|
142
|
+
|
|
143
|
+
// console.log('dataSourceFilter', dataSourceFilter)
|
|
144
|
+
// console.log('options', options)
|
|
145
|
+
// console.log('column', column)
|
|
146
|
+
|
|
143
147
|
switch (type) {
|
|
144
148
|
case 'Number':
|
|
145
149
|
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
|
|
@@ -374,7 +378,7 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
|
|
|
374
378
|
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select
|
|
375
379
|
// options={translateOption(numberOperator, t)}
|
|
376
380
|
, {
|
|
377
|
-
options: options,
|
|
381
|
+
options: find ? options : column.source ?? [],
|
|
378
382
|
style: {
|
|
379
383
|
width: '100%',
|
|
380
384
|
marginBottom: 8
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { ColumnTable } from "../../type";
|
|
3
|
+
type Props = {
|
|
4
|
+
t?: any;
|
|
5
|
+
content?: string;
|
|
6
|
+
column?: ColumnTable;
|
|
7
|
+
template?: React.ReactElement | React.ReactNode | (() => React.ReactElement | React.ReactNode);
|
|
8
|
+
tooltip?: string | number | React.ReactElement | React.ReactNode | (() => React.ReactElement | React.ReactNode);
|
|
9
|
+
};
|
|
10
|
+
declare const HeaderContent: (props: Props) => React.JSX.Element;
|
|
11
|
+
export default HeaderContent;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _react2 = require("@floating-ui/react");
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
var _utils = require("../utils");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
const TooltipStyle = _styledComponents.default.div.withConfig({
|
|
17
|
+
displayName: "TooltipStyle",
|
|
18
|
+
componentId: "es-grid-template__sc-ibhq66-0"
|
|
19
|
+
})(["width:max-content;background-color:#444;color:white;font-size:90%;padding:4px 8px;border-radius:4px;opacity:0.9;z-index:9999;max-width:450px;"]);
|
|
20
|
+
const HeaderContent = props => {
|
|
21
|
+
const {
|
|
22
|
+
t
|
|
23
|
+
} = props;
|
|
24
|
+
const {
|
|
25
|
+
headerTooltip,
|
|
26
|
+
headerText,
|
|
27
|
+
columnGroupText,
|
|
28
|
+
headerTemplate
|
|
29
|
+
} = props.column ?? {};
|
|
30
|
+
const text = _react.default.useMemo(() => {
|
|
31
|
+
return columnGroupText ?? headerText;
|
|
32
|
+
}, [columnGroupText, headerText]);
|
|
33
|
+
const tooltip = _react.default.useMemo(() => {
|
|
34
|
+
return headerTooltip ?? columnGroupText ?? headerText;
|
|
35
|
+
}, [columnGroupText, headerText, headerTooltip]);
|
|
36
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
37
|
+
const {
|
|
38
|
+
refs,
|
|
39
|
+
floatingStyles,
|
|
40
|
+
context
|
|
41
|
+
} = (0, _react2.useFloating)({
|
|
42
|
+
open: isOpen,
|
|
43
|
+
onOpenChange: setIsOpen,
|
|
44
|
+
placement: "top",
|
|
45
|
+
whileElementsMounted: _react2.autoUpdate,
|
|
46
|
+
middleware: [(0, _react2.offset)(5), (0, _react2.flip)({
|
|
47
|
+
fallbackAxisSideDirection: "start"
|
|
48
|
+
}), (0, _react2.shift)()]
|
|
49
|
+
});
|
|
50
|
+
const hover = (0, _react2.useHover)(context, {
|
|
51
|
+
move: false
|
|
52
|
+
});
|
|
53
|
+
const focus = (0, _react2.useFocus)(context);
|
|
54
|
+
const dismiss = (0, _react2.useDismiss)(context);
|
|
55
|
+
const role = (0, _react2.useRole)(context, {
|
|
56
|
+
role: "tooltip"
|
|
57
|
+
});
|
|
58
|
+
const {
|
|
59
|
+
getReferenceProps,
|
|
60
|
+
getFloatingProps
|
|
61
|
+
} = (0, _react2.useInteractions)([hover, focus, dismiss, role]);
|
|
62
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
63
|
+
ref: refs.setReference
|
|
64
|
+
}, getReferenceProps(), {
|
|
65
|
+
tabIndex: -1,
|
|
66
|
+
style: {
|
|
67
|
+
flex: 1,
|
|
68
|
+
overflow: 'hidden',
|
|
69
|
+
textOverflow: 'ellipsis',
|
|
70
|
+
wordBreak: 'keep-all'
|
|
71
|
+
}
|
|
72
|
+
// style={{flex: 1}}
|
|
73
|
+
,
|
|
74
|
+
className: (0, _classnames.default)('', {})
|
|
75
|
+
}), headerTemplate ? (0, _utils.getTemplate)(headerTemplate) : text), isOpen && (headerTooltip !== false || headerTemplate || headerTooltip || columnGroupText || headerText) && /*#__PURE__*/_react.default.createElement(_react2.FloatingPortal, {
|
|
76
|
+
root: document.body
|
|
77
|
+
}, /*#__PURE__*/_react.default.createElement(TooltipStyle, (0, _extends2.default)({
|
|
78
|
+
className: "Tooltip",
|
|
79
|
+
ref: refs.setFloating,
|
|
80
|
+
style: {
|
|
81
|
+
...floatingStyles,
|
|
82
|
+
zIndex: 1999
|
|
83
|
+
}
|
|
84
|
+
}, getFloatingProps()), headerTooltip && typeof headerTooltip === 'function' ? headerTooltip() : t ? t(tooltip) : tooltip)));
|
|
85
|
+
};
|
|
86
|
+
var _default = exports.default = HeaderContent;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { ReactElement, ReactNode } from "react";
|
|
2
|
+
type Props = {
|
|
3
|
+
t?: any;
|
|
4
|
+
content?: any;
|
|
5
|
+
value?: any;
|
|
6
|
+
record?: any;
|
|
7
|
+
rowIndex?: any;
|
|
8
|
+
template?: React.ReactElement | React.ReactNode | (() => React.ReactElement | React.ReactNode);
|
|
9
|
+
tooltip?: ReactNode | ReactElement | ((value: any, record: any, index: number) => ReactNode | ReactElement);
|
|
10
|
+
showTooltip?: boolean;
|
|
11
|
+
};
|
|
12
|
+
declare const TooltipContent: (props: Props) => React.JSX.Element;
|
|
13
|
+
export default TooltipContent;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
+
var _react2 = require("@floating-ui/react");
|
|
12
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
+
var _useIsOverflow = require("../useIsOverflow");
|
|
14
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
15
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
16
|
+
// import {getTemplate} from "../utils";
|
|
17
|
+
|
|
18
|
+
const TooltipStyle = _styledComponents.default.div.withConfig({
|
|
19
|
+
displayName: "TooltipStyle",
|
|
20
|
+
componentId: "es-grid-template__sc-7yfbzv-0"
|
|
21
|
+
})(["width:max-content;background-color:#444;color:white;font-size:90%;padding:4px 8px;border-radius:4px;opacity:0.9;z-index:9999;max-width:450px;"]);
|
|
22
|
+
const TooltipContent = props => {
|
|
23
|
+
const {
|
|
24
|
+
content,
|
|
25
|
+
tooltip,
|
|
26
|
+
value,
|
|
27
|
+
record,
|
|
28
|
+
rowIndex,
|
|
29
|
+
showTooltip
|
|
30
|
+
} = props;
|
|
31
|
+
const [isOpen, setIsOpen] = (0, _react.useState)(false);
|
|
32
|
+
const {
|
|
33
|
+
refs,
|
|
34
|
+
floatingStyles,
|
|
35
|
+
context
|
|
36
|
+
} = (0, _react2.useFloating)({
|
|
37
|
+
open: isOpen,
|
|
38
|
+
onOpenChange: setIsOpen,
|
|
39
|
+
placement: "top",
|
|
40
|
+
whileElementsMounted: _react2.autoUpdate,
|
|
41
|
+
middleware: [(0, _react2.offset)(5), (0, _react2.flip)({
|
|
42
|
+
fallbackAxisSideDirection: "start"
|
|
43
|
+
}), (0, _react2.shift)()]
|
|
44
|
+
});
|
|
45
|
+
const isOverflow = (0, _useIsOverflow.useIsOverflow)(refs.reference);
|
|
46
|
+
const hover = (0, _react2.useHover)(context, {
|
|
47
|
+
move: false
|
|
48
|
+
});
|
|
49
|
+
const focus = (0, _react2.useFocus)(context);
|
|
50
|
+
const dismiss = (0, _react2.useDismiss)(context);
|
|
51
|
+
const role = (0, _react2.useRole)(context, {
|
|
52
|
+
role: "tooltip"
|
|
53
|
+
});
|
|
54
|
+
const {
|
|
55
|
+
getReferenceProps,
|
|
56
|
+
getFloatingProps
|
|
57
|
+
} = (0, _react2.useInteractions)([hover, focus, dismiss, role]);
|
|
58
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
|
|
59
|
+
ref: refs.setReference
|
|
60
|
+
}, getReferenceProps(), {
|
|
61
|
+
style: {
|
|
62
|
+
flex: 1,
|
|
63
|
+
overflow: 'hidden',
|
|
64
|
+
textOverflow: 'ellipsis',
|
|
65
|
+
wordBreak: 'keep-all'
|
|
66
|
+
},
|
|
67
|
+
className: (0, _classnames.default)('', {})
|
|
68
|
+
}), content()), isOpen && showTooltip !== false && isOverflow &&
|
|
69
|
+
/*#__PURE__*/
|
|
70
|
+
// {true && (
|
|
71
|
+
_react.default.createElement(_react2.FloatingPortal, {
|
|
72
|
+
root: document.body
|
|
73
|
+
}, /*#__PURE__*/_react.default.createElement(TooltipStyle, (0, _extends2.default)({
|
|
74
|
+
className: "Tooltip",
|
|
75
|
+
ref: refs.setFloating,
|
|
76
|
+
style: {
|
|
77
|
+
...floatingStyles
|
|
78
|
+
}
|
|
79
|
+
}, getFloatingProps()), tooltip && typeof tooltip === 'function' ? tooltip(value, record, rowIndex) : tooltip ?? content())));
|
|
80
|
+
};
|
|
81
|
+
var _default = exports.default = TooltipContent;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AnyObject, IGroupSetting } from "../type";
|
|
2
|
+
export declare const SELECTION_COLUMN: {};
|
|
3
|
+
interface UseColumnsConfig {
|
|
4
|
+
t?: any;
|
|
5
|
+
buddhistLocale?: any;
|
|
6
|
+
dataSourceFilter?: any;
|
|
7
|
+
locale?: any;
|
|
8
|
+
format?: any;
|
|
9
|
+
handleResize?: any;
|
|
10
|
+
sortMultiple?: boolean;
|
|
11
|
+
groupAble?: boolean;
|
|
12
|
+
groupSetting?: IGroupSetting;
|
|
13
|
+
groupColumns?: string[];
|
|
14
|
+
}
|
|
15
|
+
declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig) => readonly [any];
|
|
16
|
+
export default useColumns;
|