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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import React, { Fragment
|
|
2
|
+
import React, { Fragment } from 'react';
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
import { numericFormatter } from "react-numeric-component";
|
|
5
5
|
import { Empty, Table, Toolbar } from "rc-master-ui";
|
|
@@ -7,11 +7,15 @@ import 'dayjs/locale/es';
|
|
|
7
7
|
import 'dayjs/locale/vi';
|
|
8
8
|
import ContextMenu from "./ContextMenu";
|
|
9
9
|
import classNames from "classnames";
|
|
10
|
-
import { checkDecimalSeparator, checkThousandSeparator,
|
|
10
|
+
import { checkDecimalSeparator, checkThousandSeparator,
|
|
11
|
+
// convertFlatColumn,
|
|
12
|
+
isEmpty,
|
|
13
|
+
// removeColumns,
|
|
14
|
+
sumDataByField
|
|
11
15
|
// updateArrayByKey
|
|
12
16
|
} from "./hooks";
|
|
13
|
-
import {
|
|
14
|
-
import { flatColumns } from "./hooks/
|
|
17
|
+
// import {ConfigProvider} from "antd";
|
|
18
|
+
import { flatColumns } from "./hooks/columns";
|
|
15
19
|
import Pagination from "rc-master-ui/es/pagination";
|
|
16
20
|
import ComponentSpinner from "./LoadingSpinner";
|
|
17
21
|
import { ColumnsChoose } from "./ColumnsChoose";
|
|
@@ -91,7 +95,6 @@ const TableGrid = props => {
|
|
|
91
95
|
locale,
|
|
92
96
|
expandable,
|
|
93
97
|
rowHoverable,
|
|
94
|
-
// mergedData,
|
|
95
98
|
title,
|
|
96
99
|
format,
|
|
97
100
|
virtual = true,
|
|
@@ -116,10 +119,16 @@ const TableGrid = props => {
|
|
|
116
119
|
dataSourceFilter: propDataSourceFilter,
|
|
117
120
|
loading,
|
|
118
121
|
triggerChangeColumns,
|
|
122
|
+
triggerGroupColumns,
|
|
119
123
|
summary,
|
|
120
124
|
showToolbar,
|
|
121
125
|
onSorter,
|
|
122
126
|
bottomToolbar,
|
|
127
|
+
groupSetting,
|
|
128
|
+
groupAble,
|
|
129
|
+
getRowKey,
|
|
130
|
+
groupColumns,
|
|
131
|
+
groupToolbar,
|
|
123
132
|
...rest
|
|
124
133
|
} = props;
|
|
125
134
|
const {
|
|
@@ -134,16 +143,10 @@ const TableGrid = props => {
|
|
|
134
143
|
selectedRowKeys,
|
|
135
144
|
defaultSelectedRowKeys
|
|
136
145
|
} = selectionSettings || {};
|
|
137
|
-
const clickRef = useRef(null);
|
|
138
|
-
const menuRef = useRef(null);
|
|
146
|
+
const clickRef = React.useRef(null);
|
|
147
|
+
const menuRef = React.useRef(null);
|
|
139
148
|
const viewportWidth = window.innerWidth;
|
|
140
149
|
const viewportHeight = window.innerHeight;
|
|
141
|
-
|
|
142
|
-
// const defaultSelected = useMemo(() => {
|
|
143
|
-
// return defaultSelectedRowKeys ?? []
|
|
144
|
-
//
|
|
145
|
-
// }, [defaultSelectedRowKeys])
|
|
146
|
-
|
|
147
150
|
const [menuVisible, setMenuVisible] = React.useState(false);
|
|
148
151
|
const [selectedRowData, setSelectedRowData] = React.useState(null);
|
|
149
152
|
const [position, setPosition] = React.useState({
|
|
@@ -181,7 +184,7 @@ const TableGrid = props => {
|
|
|
181
184
|
}
|
|
182
185
|
return propContextMenuItems;
|
|
183
186
|
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
184
|
-
useLayoutEffect(() => {
|
|
187
|
+
React.useLayoutEffect(() => {
|
|
185
188
|
setMenuVisible(false);
|
|
186
189
|
}, []);
|
|
187
190
|
const onContextMenu = data => event => {
|
|
@@ -288,17 +291,7 @@ const TableGrid = props => {
|
|
|
288
291
|
const handleChange = sorter => {
|
|
289
292
|
onSorter?.(sorter);
|
|
290
293
|
};
|
|
291
|
-
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(
|
|
292
|
-
theme: {
|
|
293
|
-
components: {
|
|
294
|
-
Table: {
|
|
295
|
-
rowHoverBg: '#eb461912',
|
|
296
|
-
rowSelectedBg: '#eb4619',
|
|
297
|
-
rowSelectedHoverBg: '#eb4619'
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}, /*#__PURE__*/React.createElement(ContextMenu, {
|
|
294
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(ContextMenu, {
|
|
302
295
|
open: menuVisible,
|
|
303
296
|
pos: position,
|
|
304
297
|
setOpen: setMenuVisible,
|
|
@@ -318,10 +311,9 @@ const TableGrid = props => {
|
|
|
318
311
|
},
|
|
319
312
|
loading: {
|
|
320
313
|
spinning: columns && columns.length === 0 || loading === true,
|
|
321
|
-
// spinning: loading === true,
|
|
322
314
|
indicator: /*#__PURE__*/React.createElement(ComponentSpinner, null)
|
|
323
315
|
},
|
|
324
|
-
dataSource: dataSource
|
|
316
|
+
dataSource: columns && columns.length > 0 && loading !== true ? dataSource : []
|
|
325
317
|
// className={styles.customTable}
|
|
326
318
|
,
|
|
327
319
|
className: classNames(className, {
|
|
@@ -339,7 +331,6 @@ const TableGrid = props => {
|
|
|
339
331
|
onRow: (data, index) => {
|
|
340
332
|
return {
|
|
341
333
|
onDoubleClick: handleRowDoubleClick(data, index),
|
|
342
|
-
// onClick: handleRowClick,
|
|
343
334
|
onClick: handleRowClick(),
|
|
344
335
|
onContextMenu: onContextMenu(data)
|
|
345
336
|
};
|
|
@@ -370,7 +361,7 @@ const TableGrid = props => {
|
|
|
370
361
|
}
|
|
371
362
|
return /*#__PURE__*/React.createElement(Table.Summary, {
|
|
372
363
|
fixed: true
|
|
373
|
-
}, /*#__PURE__*/React.createElement(Table.Summary.Row, null, flatColumns(columns).filter(col => col.hidden !== true).map((col, index) => {
|
|
364
|
+
}, /*#__PURE__*/React.createElement(Table.Summary.Row, null, flatColumns([Table.SELECTION_COLUMN, ...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
374
365
|
const thousandSeparator = col.format?.thousandSeparator ? col.format?.thousandSeparator : format?.thousandSeparator;
|
|
375
366
|
const decimalSeparator = col.format?.decimalSeparator ? col.format?.decimalSeparator : format?.decimalSeparator;
|
|
376
367
|
const dec = col.format?.decimalScale || col.format?.decimalScale === 0 ? col.format?.decimalScale : format?.decimalScale;
|
|
@@ -394,7 +385,7 @@ const TableGrid = props => {
|
|
|
394
385
|
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : numericFormatter(cellValue, numericFormatProps));
|
|
395
386
|
})));
|
|
396
387
|
},
|
|
397
|
-
pagination: pagination && pagination.onChange ? false : {
|
|
388
|
+
pagination: !pagination || pagination && pagination.onChange ? false : {
|
|
398
389
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
399
390
|
...pagination
|
|
400
391
|
},
|
|
@@ -409,11 +400,11 @@ const TableGrid = props => {
|
|
|
409
400
|
justifyContent: 'space-between',
|
|
410
401
|
alignItems: 'center'
|
|
411
402
|
}
|
|
412
|
-
}, toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/React.createElement(Toolbar
|
|
403
|
+
}, groupAble && groupToolbar?.(), toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/React.createElement(Toolbar
|
|
413
404
|
// @ts-ignore
|
|
414
405
|
, {
|
|
415
406
|
style: {
|
|
416
|
-
width: pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' ? `calc(100% - 650px` : `calc(100% - 25px`
|
|
407
|
+
width: pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' ? `calc(100% - 650px - ${groupAble ? 50 : 0}px` : `calc(100% - 25px - ${groupAble ? 50 : 0}px`
|
|
417
408
|
},
|
|
418
409
|
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
419
410
|
mode: 'scroll'
|
|
@@ -434,53 +425,23 @@ const TableGrid = props => {
|
|
|
434
425
|
}, pagination)), showColumnChoose && /*#__PURE__*/React.createElement(ColumnsChoose, {
|
|
435
426
|
columns: columns,
|
|
436
427
|
t: t,
|
|
428
|
+
columnsGroup: groupColumns,
|
|
437
429
|
triggerChangeColumns: triggerChangeColumns
|
|
438
430
|
}))));
|
|
439
431
|
},
|
|
440
432
|
expandable: {
|
|
441
|
-
|
|
442
|
-
defaultExpandAllRows: true,
|
|
443
|
-
indentSize: 25,
|
|
444
|
-
...expandable,
|
|
445
|
-
expandIcon: args => {
|
|
446
|
-
const {
|
|
447
|
-
record,
|
|
448
|
-
expanded,
|
|
449
|
-
onExpand
|
|
450
|
-
} = args;
|
|
451
|
-
|
|
452
|
-
// @ts-ignore
|
|
453
|
-
if (record?.children?.length > 0 || record?.isChildren) {
|
|
454
|
-
return expanded ? /*#__PURE__*/React.createElement("button", {
|
|
455
|
-
onClick: e => {
|
|
456
|
-
e.preventDefault();
|
|
457
|
-
e.stopPropagation();
|
|
458
|
-
onExpand(record, e);
|
|
459
|
-
},
|
|
460
|
-
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded'
|
|
461
|
-
}) : /*#__PURE__*/React.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-collapsed'
|
|
468
|
-
});
|
|
469
|
-
} else {
|
|
470
|
-
return /*#__PURE__*/React.createElement("button", {
|
|
471
|
-
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced'
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
}
|
|
433
|
+
...expandable
|
|
475
434
|
}
|
|
476
|
-
})),
|
|
435
|
+
})), /*#__PURE__*/React.createElement("div", null), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/React.createElement(Pagination
|
|
477
436
|
// style={{padding: '0.75rem 1rem'}}
|
|
478
437
|
, _extends({
|
|
479
438
|
rootClassName: 'pagination-template',
|
|
480
439
|
showSizeChanger: true,
|
|
481
440
|
responsive: true,
|
|
482
|
-
size: 'small'
|
|
483
|
-
|
|
484
|
-
|
|
441
|
+
size: 'small'
|
|
442
|
+
// @ts-ignore
|
|
443
|
+
,
|
|
444
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
445
|
+
}, pagination)), bottomToolbar?.());
|
|
485
446
|
};
|
|
486
447
|
export 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;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// import * as React from 'react'
|
|
2
|
-
|
|
3
1
|
import { checkDecimalSeparator, checkThousandSeparator, convertDateToDayjs, convertDayjsToDate, getDatepickerFormat, getDateString, getTypeFilter, isColor, isEmpty } from "../utils";
|
|
4
2
|
import { NumericFormat, numericFormatter } from "react-numeric-component";
|
|
5
3
|
import dayjs from "dayjs";
|
|
@@ -34,15 +32,16 @@ export function flatColumns(columns, parentKey = 'key') {
|
|
|
34
32
|
}];
|
|
35
33
|
}, []);
|
|
36
34
|
}
|
|
37
|
-
export function flatColumns2(columns
|
|
35
|
+
export function flatColumns2(columns
|
|
36
|
+
// parentKey = 'key'
|
|
37
|
+
) {
|
|
38
38
|
// @ts-ignore
|
|
39
|
-
return columns.reduce((list, column
|
|
40
|
-
const {
|
|
41
|
-
fixed
|
|
42
|
-
} = column;
|
|
39
|
+
return columns.reduce((list, column) => {
|
|
40
|
+
// const { fixed } = column
|
|
43
41
|
// Convert `fixed='true'` to `fixed='left'` instead
|
|
44
|
-
const parsedFixed = fixed === true ? 'left' : fixed
|
|
45
|
-
const mergedKey = `${parentKey}-${index}
|
|
42
|
+
// const parsedFixed = fixed === true ? 'left' : fixed
|
|
43
|
+
// const mergedKey = `${parentKey}-${index}`
|
|
44
|
+
|
|
46
45
|
const subColumns = column.children;
|
|
47
46
|
if (column === SELECTION_COLUMN) {
|
|
48
47
|
return [...list, {
|
|
@@ -50,15 +49,15 @@ export function flatColumns2(columns, parentKey = 'key') {
|
|
|
50
49
|
}];
|
|
51
50
|
}
|
|
52
51
|
if (subColumns && subColumns.length > 0) {
|
|
53
|
-
return [...list, ...flatColumns(subColumns
|
|
54
|
-
fixed: parsedFixed,
|
|
52
|
+
return [...list, ...flatColumns(subColumns).map(subColum => ({
|
|
53
|
+
// fixed: parsedFixed,
|
|
55
54
|
...subColum
|
|
56
55
|
}))];
|
|
57
56
|
}
|
|
58
57
|
return [...list, {
|
|
59
|
-
key: mergedKey,
|
|
60
|
-
...column
|
|
61
|
-
fixed: parsedFixed
|
|
58
|
+
// key: mergedKey,
|
|
59
|
+
...column
|
|
60
|
+
// fixed: parsedFixed
|
|
62
61
|
}];
|
|
63
62
|
}, []);
|
|
64
63
|
}
|
|
@@ -125,8 +124,13 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
125
124
|
const type = getTypeFilter(column);
|
|
126
125
|
const dateFormat = getDatepickerFormat(column?.typeFilter ?? column?.type, column) ?? 'DD/MM/YYYY';
|
|
127
126
|
const dateRangeFormat = getDatepickerFormat(column?.type, column) ?? 'DD/MM/YYYY';
|
|
128
|
-
const find = dataSourceFilter?.find(it => it.key === column?.
|
|
127
|
+
const find = dataSourceFilter?.find(it => it.key === column?.field);
|
|
129
128
|
const options = find ? find.data : [];
|
|
129
|
+
|
|
130
|
+
// console.log('dataSourceFilter', dataSourceFilter)
|
|
131
|
+
// console.log('options', options)
|
|
132
|
+
// console.log('column', column)
|
|
133
|
+
|
|
130
134
|
switch (type) {
|
|
131
135
|
case 'Number':
|
|
132
136
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -361,7 +365,7 @@ export const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, vis
|
|
|
361
365
|
}, /*#__PURE__*/React.createElement(Select
|
|
362
366
|
// options={translateOption(numberOperator, t)}
|
|
363
367
|
, {
|
|
364
|
-
options: options,
|
|
368
|
+
options: find ? options : column.source ?? [],
|
|
365
369
|
style: {
|
|
366
370
|
width: '100%',
|
|
367
371
|
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,79 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React, { Fragment, useState } from "react";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import { useFloating, autoUpdate, offset, flip, shift, useHover, useFocus, useDismiss, useRole, useInteractions, FloatingPortal
|
|
5
|
+
// useClick
|
|
6
|
+
} from "@floating-ui/react";
|
|
7
|
+
import styled from "styled-components";
|
|
8
|
+
import { getTemplate } from "../utils";
|
|
9
|
+
const TooltipStyle = styled.div.withConfig({
|
|
10
|
+
displayName: "TooltipStyle",
|
|
11
|
+
componentId: "es-grid-template__sc-ibhq66-0"
|
|
12
|
+
})(["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;"]);
|
|
13
|
+
const HeaderContent = props => {
|
|
14
|
+
const {
|
|
15
|
+
t
|
|
16
|
+
} = props;
|
|
17
|
+
const {
|
|
18
|
+
headerTooltip,
|
|
19
|
+
headerText,
|
|
20
|
+
columnGroupText,
|
|
21
|
+
headerTemplate
|
|
22
|
+
} = props.column ?? {};
|
|
23
|
+
const text = React.useMemo(() => {
|
|
24
|
+
return columnGroupText ?? headerText;
|
|
25
|
+
}, [columnGroupText, headerText]);
|
|
26
|
+
const tooltip = React.useMemo(() => {
|
|
27
|
+
return headerTooltip ?? columnGroupText ?? headerText;
|
|
28
|
+
}, [columnGroupText, headerText, headerTooltip]);
|
|
29
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
30
|
+
const {
|
|
31
|
+
refs,
|
|
32
|
+
floatingStyles,
|
|
33
|
+
context
|
|
34
|
+
} = useFloating({
|
|
35
|
+
open: isOpen,
|
|
36
|
+
onOpenChange: setIsOpen,
|
|
37
|
+
placement: "top",
|
|
38
|
+
whileElementsMounted: autoUpdate,
|
|
39
|
+
middleware: [offset(5), flip({
|
|
40
|
+
fallbackAxisSideDirection: "start"
|
|
41
|
+
}), shift()]
|
|
42
|
+
});
|
|
43
|
+
const hover = useHover(context, {
|
|
44
|
+
move: false
|
|
45
|
+
});
|
|
46
|
+
const focus = useFocus(context);
|
|
47
|
+
const dismiss = useDismiss(context);
|
|
48
|
+
const role = useRole(context, {
|
|
49
|
+
role: "tooltip"
|
|
50
|
+
});
|
|
51
|
+
const {
|
|
52
|
+
getReferenceProps,
|
|
53
|
+
getFloatingProps
|
|
54
|
+
} = useInteractions([hover, focus, dismiss, role]);
|
|
55
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", _extends({
|
|
56
|
+
ref: refs.setReference
|
|
57
|
+
}, getReferenceProps(), {
|
|
58
|
+
tabIndex: -1,
|
|
59
|
+
style: {
|
|
60
|
+
flex: 1,
|
|
61
|
+
overflow: 'hidden',
|
|
62
|
+
textOverflow: 'ellipsis',
|
|
63
|
+
wordBreak: 'keep-all'
|
|
64
|
+
}
|
|
65
|
+
// style={{flex: 1}}
|
|
66
|
+
,
|
|
67
|
+
className: classnames('', {})
|
|
68
|
+
}), headerTemplate ? getTemplate(headerTemplate) : text), isOpen && (headerTooltip !== false || headerTemplate || headerTooltip || columnGroupText || headerText) && /*#__PURE__*/React.createElement(FloatingPortal, {
|
|
69
|
+
root: document.body
|
|
70
|
+
}, /*#__PURE__*/React.createElement(TooltipStyle, _extends({
|
|
71
|
+
className: "Tooltip",
|
|
72
|
+
ref: refs.setFloating,
|
|
73
|
+
style: {
|
|
74
|
+
...floatingStyles,
|
|
75
|
+
zIndex: 1999
|
|
76
|
+
}
|
|
77
|
+
}, getFloatingProps()), headerTooltip && typeof headerTooltip === 'function' ? headerTooltip() : t ? t(tooltip) : tooltip)));
|
|
78
|
+
};
|
|
79
|
+
export 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,74 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import React, { Fragment, useState } from "react";
|
|
3
|
+
import classnames from "classnames";
|
|
4
|
+
import { useFloating, autoUpdate, offset, flip, shift, useHover, useFocus, useDismiss, useRole, useInteractions, FloatingPortal
|
|
5
|
+
// useClick
|
|
6
|
+
} from "@floating-ui/react";
|
|
7
|
+
import styled from "styled-components";
|
|
8
|
+
import { useIsOverflow } from "../useIsOverflow";
|
|
9
|
+
// import {getTemplate} from "../utils";
|
|
10
|
+
|
|
11
|
+
const TooltipStyle = styled.div.withConfig({
|
|
12
|
+
displayName: "TooltipStyle",
|
|
13
|
+
componentId: "es-grid-template__sc-7yfbzv-0"
|
|
14
|
+
})(["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;"]);
|
|
15
|
+
const TooltipContent = props => {
|
|
16
|
+
const {
|
|
17
|
+
content,
|
|
18
|
+
tooltip,
|
|
19
|
+
value,
|
|
20
|
+
record,
|
|
21
|
+
rowIndex,
|
|
22
|
+
showTooltip
|
|
23
|
+
} = props;
|
|
24
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
25
|
+
const {
|
|
26
|
+
refs,
|
|
27
|
+
floatingStyles,
|
|
28
|
+
context
|
|
29
|
+
} = useFloating({
|
|
30
|
+
open: isOpen,
|
|
31
|
+
onOpenChange: setIsOpen,
|
|
32
|
+
placement: "top",
|
|
33
|
+
whileElementsMounted: autoUpdate,
|
|
34
|
+
middleware: [offset(5), flip({
|
|
35
|
+
fallbackAxisSideDirection: "start"
|
|
36
|
+
}), shift()]
|
|
37
|
+
});
|
|
38
|
+
const isOverflow = useIsOverflow(refs.reference);
|
|
39
|
+
const hover = useHover(context, {
|
|
40
|
+
move: false
|
|
41
|
+
});
|
|
42
|
+
const focus = useFocus(context);
|
|
43
|
+
const dismiss = useDismiss(context);
|
|
44
|
+
const role = useRole(context, {
|
|
45
|
+
role: "tooltip"
|
|
46
|
+
});
|
|
47
|
+
const {
|
|
48
|
+
getReferenceProps,
|
|
49
|
+
getFloatingProps
|
|
50
|
+
} = useInteractions([hover, focus, dismiss, role]);
|
|
51
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement("div", _extends({
|
|
52
|
+
ref: refs.setReference
|
|
53
|
+
}, getReferenceProps(), {
|
|
54
|
+
style: {
|
|
55
|
+
flex: 1,
|
|
56
|
+
overflow: 'hidden',
|
|
57
|
+
textOverflow: 'ellipsis',
|
|
58
|
+
wordBreak: 'keep-all'
|
|
59
|
+
},
|
|
60
|
+
className: classnames('', {})
|
|
61
|
+
}), content()), isOpen && showTooltip !== false && isOverflow &&
|
|
62
|
+
/*#__PURE__*/
|
|
63
|
+
// {true && (
|
|
64
|
+
React.createElement(FloatingPortal, {
|
|
65
|
+
root: document.body
|
|
66
|
+
}, /*#__PURE__*/React.createElement(TooltipStyle, _extends({
|
|
67
|
+
className: "Tooltip",
|
|
68
|
+
ref: refs.setFloating,
|
|
69
|
+
style: {
|
|
70
|
+
...floatingStyles
|
|
71
|
+
}
|
|
72
|
+
}, getFloatingProps()), tooltip && typeof tooltip === 'function' ? tooltip(value, record, rowIndex) : tooltip ?? content())));
|
|
73
|
+
};
|
|
74
|
+
export 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;
|