es-grid-template 1.8.70 → 1.8.72
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/es/grid-component/TempTable.js +2 -1
- package/es/group-component/ColumnsChoose.d.ts +13 -0
- package/es/group-component/ColumnsChoose.js +211 -0
- package/es/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/es/group-component/ColumnsGroup/ColumnsGroup.js +230 -0
- package/es/group-component/ColumnsGroup/index.d.ts +1 -0
- package/es/group-component/ColumnsGroup/index.js +1 -0
- package/es/group-component/ContextMenu.d.ts +19 -0
- package/es/group-component/ContextMenu.js +74 -0
- package/es/group-component/InternalTable.d.ts +8 -0
- package/es/group-component/InternalTable.js +224 -0
- package/es/group-component/TableContainer.d.ts +49 -0
- package/es/group-component/TableContainer.js +375 -0
- package/es/group-component/TableContainerEdit.d.ts +48 -0
- package/es/group-component/TableContainerEdit.js +2068 -0
- package/es/group-component/body/EditableCell.d.ts +16 -0
- package/es/group-component/body/EditableCell.js +1066 -0
- package/es/group-component/body/TableBody.d.ts +14 -0
- package/es/group-component/body/TableBody.js +82 -0
- package/es/group-component/body/TableBodyCell.d.ts +12 -0
- package/es/group-component/body/TableBodyCell.js +587 -0
- package/es/group-component/body/TableBodyCellEdit.d.ts +17 -0
- package/es/group-component/body/TableBodyCellEdit.js +1398 -0
- package/es/group-component/body/TableBodyCellEmpty.d.ts +12 -0
- package/es/group-component/body/TableBodyCellEmpty.js +149 -0
- package/es/group-component/body/TableBodyRow.d.ts +21 -0
- package/es/group-component/body/TableBodyRow.js +199 -0
- package/es/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
- package/es/group-component/body/TableBodyRowGroupCell.js +567 -0
- package/es/group-component/components/ControlCheckbox.d.ts +13 -0
- package/es/group-component/components/ControlCheckbox.js +84 -0
- package/es/group-component/components/EditForm/EditForm.d.ts +27 -0
- package/es/group-component/components/EditForm/EditForm.js +394 -0
- package/es/group-component/components/EditForm/index.d.ts +1 -0
- package/es/group-component/components/EditForm/index.js +1 -0
- package/es/group-component/components/InputControl/InputControl.d.ts +27 -0
- package/es/group-component/components/InputControl/InputControl.js +118 -0
- package/es/group-component/components/InputControl/index.d.ts +1 -0
- package/es/group-component/components/InputControl/index.js +1 -0
- package/es/group-component/components/async-select/index.d.ts +11 -0
- package/es/group-component/components/async-select/index.js +38 -0
- package/es/group-component/components/async-table-select/index.d.ts +11 -0
- package/es/group-component/components/async-table-select/index.js +40 -0
- package/es/group-component/components/checkbox-control/index.d.ts +13 -0
- package/es/group-component/components/checkbox-control/index.js +40 -0
- package/es/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/es/group-component/components/checkbox-filter/CheckboxFilter.js +258 -0
- package/es/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/es/group-component/components/checkbox-filter/FilterSearch.js +36 -0
- package/es/group-component/components/command/Command.d.ts +10 -0
- package/es/group-component/components/command/Command.js +35 -0
- package/es/group-component/components/number/index.d.ts +12 -0
- package/es/group-component/components/number/index.js +42 -0
- package/es/group-component/components/number-range/index.d.ts +13 -0
- package/es/group-component/components/number-range/index.js +79 -0
- package/es/group-component/features/operator.d.ts +24 -0
- package/es/group-component/features/operator.js +62 -0
- package/es/group-component/footer/TableFooter.d.ts +7 -0
- package/es/group-component/footer/TableFooter.js +34 -0
- package/es/group-component/footer/TableFooterCell.d.ts +7 -0
- package/es/group-component/footer/TableFooterCell.js +66 -0
- package/es/group-component/footer/TableFooterRow.d.ts +8 -0
- package/es/group-component/footer/TableFooterRow.js +30 -0
- package/es/group-component/header/TableHead.d.ts +15 -0
- package/es/group-component/header/TableHead.js +98 -0
- package/es/group-component/header/TableHeadCell.d.ts +15 -0
- package/es/group-component/header/TableHeadCell.js +310 -0
- package/es/group-component/header/TableHeadCell2.d.ts +17 -0
- package/es/group-component/header/TableHeadCell2.js +321 -0
- package/es/group-component/header/TableHeadGroupCell.d.ts +17 -0
- package/es/group-component/header/TableHeadGroupCell.js +94 -0
- package/es/group-component/header/TableHeadRow.d.ts +15 -0
- package/es/group-component/header/TableHeadRow.js +52 -0
- package/es/group-component/header/renderFilter.d.ts +20 -0
- package/es/group-component/header/renderFilter.js +291 -0
- package/es/group-component/hook/convert.d.ts +1 -0
- package/es/group-component/hook/convert.js +28 -0
- package/es/group-component/hook/useColumns.d.ts +28 -0
- package/es/group-component/hook/useColumns.js +306 -0
- package/es/group-component/hook/useFilterOperator.d.ts +7 -0
- package/es/group-component/hook/useFilterOperator.js +33 -0
- package/es/group-component/hook/utils.d.ts +220 -0
- package/es/group-component/hook/utils.js +2340 -0
- package/es/group-component/index.d.ts +2 -0
- package/es/group-component/index.js +2 -0
- package/es/group-component/style.d.ts +22 -0
- package/es/group-component/style.js +48 -0
- package/es/group-component/style.scss +1438 -0
- package/es/group-component/table/Grid.d.ts +33 -0
- package/es/group-component/table/Grid.js +438 -0
- package/es/group-component/table/TableWrapper.d.ts +33 -0
- package/es/group-component/table/TableWrapper.js +250 -0
- package/es/group-component/useContext.d.ts +100 -0
- package/es/group-component/useContext.js +21 -0
- package/es/table-component/InternalTable.js +6 -1
- package/es/table-component/TableContainer.js +4 -2
- package/es/table-component/TableContainerEdit.js +2 -2
- package/es/table-component/body/TableBodyCell.js +49 -40
- package/es/table-component/body/TableBodyCellEdit.js +9 -3
- package/es/table-component/body/TableBodyRow.js +4 -1
- package/es/table-component/hook/utils.d.ts +1 -0
- package/es/table-component/hook/utils.js +15 -7
- package/es/table-component/style.js +1 -1
- package/es/table-component/table/Grid.js +3 -0
- package/es/table-component/useContext.d.ts +5 -0
- package/es/table-virtuoso/InternalTable.js +2 -2
- package/es/table-virtuoso/body/TableBodyCell.js +2 -7
- package/es/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
- package/es/table-virtuoso/body/TableBodyCellRowGroup.js +196 -0
- package/es/table-virtuoso/body/TableBodyRow.d.ts +1 -1
- package/es/table-virtuoso/body/TableBodyRow.js +43 -1
- package/es/table-virtuoso/hook/utils.d.ts +1 -0
- package/es/table-virtuoso/hook/utils.js +29 -0
- package/es/table-virtuoso/style.js +3 -1
- package/es/table-virtuoso/table/Grid.js +2 -2
- package/es/table-virtuoso/table/TableWrapper.d.ts +7 -1
- package/es/table-virtuoso/table/TableWrapper.js +24 -5
- package/es/table-virtuoso/useContext.d.ts +6 -3
- package/es/table-virtuoso/useContext.js +18 -0
- package/lib/grid-component/TempTable.js +2 -1
- package/lib/group-component/ColumnsChoose.d.ts +13 -0
- package/lib/group-component/ColumnsChoose.js +221 -0
- package/lib/group-component/ColumnsGroup/ColumnsGroup.d.ts +12 -0
- package/lib/group-component/ColumnsGroup/ColumnsGroup.js +241 -0
- package/lib/group-component/ColumnsGroup/index.d.ts +1 -0
- package/lib/group-component/ColumnsGroup/index.js +16 -0
- package/lib/group-component/ContextMenu.d.ts +19 -0
- package/lib/group-component/ContextMenu.js +83 -0
- package/lib/group-component/InternalTable.d.ts +8 -0
- package/lib/group-component/InternalTable.js +233 -0
- package/lib/group-component/TableContainer.d.ts +49 -0
- package/lib/group-component/TableContainer.js +382 -0
- package/lib/group-component/TableContainerEdit.d.ts +48 -0
- package/lib/group-component/TableContainerEdit.js +2075 -0
- package/lib/group-component/body/EditableCell.d.ts +16 -0
- package/lib/group-component/body/EditableCell.js +1075 -0
- package/lib/group-component/body/TableBody.d.ts +14 -0
- package/lib/group-component/body/TableBody.js +91 -0
- package/lib/group-component/body/TableBodyCell.d.ts +12 -0
- package/lib/group-component/body/TableBodyCell.js +595 -0
- package/lib/group-component/body/TableBodyCellEdit.d.ts +17 -0
- package/lib/group-component/body/TableBodyCellEdit.js +1405 -0
- package/lib/group-component/body/TableBodyCellEmpty.d.ts +12 -0
- package/lib/group-component/body/TableBodyCellEmpty.js +156 -0
- package/lib/group-component/body/TableBodyRow.d.ts +21 -0
- package/lib/group-component/body/TableBodyRow.js +206 -0
- package/lib/group-component/body/TableBodyRowGroupCell.d.ts +12 -0
- package/lib/group-component/body/TableBodyRowGroupCell.js +575 -0
- package/lib/group-component/components/ControlCheckbox.d.ts +13 -0
- package/lib/group-component/components/ControlCheckbox.js +92 -0
- package/lib/group-component/components/EditForm/EditForm.d.ts +27 -0
- package/lib/group-component/components/EditForm/EditForm.js +404 -0
- package/lib/group-component/components/EditForm/index.d.ts +1 -0
- package/lib/group-component/components/EditForm/index.js +16 -0
- package/lib/group-component/components/InputControl/InputControl.d.ts +27 -0
- package/lib/group-component/components/InputControl/InputControl.js +127 -0
- package/lib/group-component/components/InputControl/index.d.ts +1 -0
- package/lib/group-component/components/InputControl/index.js +16 -0
- package/lib/group-component/components/async-select/index.d.ts +11 -0
- package/lib/group-component/components/async-select/index.js +47 -0
- package/lib/group-component/components/async-table-select/index.d.ts +11 -0
- package/lib/group-component/components/async-table-select/index.js +49 -0
- package/lib/group-component/components/checkbox-control/index.d.ts +13 -0
- package/lib/group-component/components/checkbox-control/index.js +48 -0
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/lib/group-component/components/checkbox-filter/CheckboxFilter.js +267 -0
- package/lib/group-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/lib/group-component/components/checkbox-filter/FilterSearch.js +44 -0
- package/lib/group-component/components/command/Command.d.ts +10 -0
- package/lib/group-component/components/command/Command.js +44 -0
- package/lib/group-component/components/number/index.d.ts +12 -0
- package/lib/group-component/components/number/index.js +50 -0
- package/lib/group-component/components/number-range/index.d.ts +13 -0
- package/lib/group-component/components/number-range/index.js +87 -0
- package/lib/group-component/features/operator.d.ts +24 -0
- package/lib/group-component/features/operator.js +67 -0
- package/lib/group-component/footer/TableFooter.d.ts +7 -0
- package/lib/group-component/footer/TableFooter.js +44 -0
- package/lib/group-component/footer/TableFooterCell.d.ts +7 -0
- package/lib/group-component/footer/TableFooterCell.js +75 -0
- package/lib/group-component/footer/TableFooterRow.d.ts +8 -0
- package/lib/group-component/footer/TableFooterRow.js +37 -0
- package/lib/group-component/header/TableHead.d.ts +15 -0
- package/lib/group-component/header/TableHead.js +107 -0
- package/lib/group-component/header/TableHeadCell.d.ts +15 -0
- package/lib/group-component/header/TableHeadCell.js +319 -0
- package/lib/group-component/header/TableHeadCell2.d.ts +17 -0
- package/lib/group-component/header/TableHeadCell2.js +330 -0
- package/lib/group-component/header/TableHeadGroupCell.d.ts +17 -0
- package/lib/group-component/header/TableHeadGroupCell.js +103 -0
- package/lib/group-component/header/TableHeadRow.d.ts +15 -0
- package/lib/group-component/header/TableHeadRow.js +59 -0
- package/lib/group-component/header/renderFilter.d.ts +20 -0
- package/lib/group-component/header/renderFilter.js +301 -0
- package/lib/group-component/hook/convert.d.ts +1 -0
- package/lib/group-component/hook/convert.js +34 -0
- package/lib/group-component/hook/useColumns.d.ts +28 -0
- package/lib/group-component/hook/useColumns.js +318 -0
- package/lib/group-component/hook/useFilterOperator.d.ts +7 -0
- package/lib/group-component/hook/useFilterOperator.js +40 -0
- package/lib/group-component/hook/utils.d.ts +220 -0
- package/lib/group-component/hook/utils.js +2468 -0
- package/lib/group-component/index.d.ts +2 -0
- package/lib/group-component/index.js +9 -0
- package/lib/group-component/style.d.ts +22 -0
- package/lib/group-component/style.js +55 -0
- package/lib/group-component/style.scss +1438 -0
- package/lib/group-component/table/Grid.d.ts +33 -0
- package/lib/group-component/table/Grid.js +443 -0
- package/lib/group-component/table/TableWrapper.d.ts +33 -0
- package/lib/group-component/table/TableWrapper.js +259 -0
- package/lib/group-component/useContext.d.ts +100 -0
- package/lib/group-component/useContext.js +27 -0
- package/lib/table-component/InternalTable.js +6 -1
- package/lib/table-component/TableContainer.js +4 -2
- package/lib/table-component/TableContainerEdit.js +2 -2
- package/lib/table-component/body/TableBodyCell.js +49 -40
- package/lib/table-component/body/TableBodyCellEdit.js +9 -3
- package/lib/table-component/body/TableBodyRow.js +4 -1
- package/lib/table-component/hook/utils.d.ts +1 -0
- package/lib/table-component/hook/utils.js +16 -7
- package/lib/table-component/style.js +1 -1
- package/lib/table-component/table/Grid.js +3 -0
- package/lib/table-component/useContext.d.ts +5 -0
- package/lib/table-virtuoso/InternalTable.js +2 -2
- package/lib/table-virtuoso/body/TableBodyCell.js +2 -7
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.d.ts +14 -0
- package/lib/table-virtuoso/body/TableBodyCellRowGroup.js +203 -0
- package/lib/table-virtuoso/body/TableBodyRow.d.ts +1 -1
- package/lib/table-virtuoso/body/TableBodyRow.js +43 -1
- package/lib/table-virtuoso/hook/utils.d.ts +1 -0
- package/lib/table-virtuoso/hook/utils.js +32 -1
- package/lib/table-virtuoso/style.js +3 -1
- package/lib/table-virtuoso/table/Grid.js +2 -2
- package/lib/table-virtuoso/table/TableWrapper.d.ts +7 -1
- package/lib/table-virtuoso/table/TableWrapper.js +24 -5
- package/lib/table-virtuoso/useContext.d.ts +6 -3
- package/lib/table-virtuoso/useContext.js +18 -0
- package/package.json +1 -1
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { flexRender } from '@tanstack/react-table';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import { Button, Space } from 'antd';
|
|
4
|
+
import { ArrowDown, ArrowUp, FilterFill, SortCancel } from 'becoxy-icons';
|
|
5
|
+
import classNames from 'classnames';
|
|
6
|
+
import { Checkbox, Dropdown, Select } from 'rc-master-ui';
|
|
7
|
+
import { excludeItems, extendsObject, getCommonPinningStyles, getDefaultOperator, getTypeFilter, removeDuplicatesByKey } from "../hook/utils";
|
|
8
|
+
import { TableContext } from "../useContext";
|
|
9
|
+
import { renderFilter } from "./renderFilter";
|
|
10
|
+
import ReactDOMServer from 'react-dom/server';
|
|
11
|
+
import { booleanOperator, nonActionColumn, numberOperator, stringOperator, translateOption } from "../../grid-component/hooks";
|
|
12
|
+
const TableHeadCell2 = props => {
|
|
13
|
+
const {
|
|
14
|
+
column,
|
|
15
|
+
header,
|
|
16
|
+
getPopupContainer,
|
|
17
|
+
table,
|
|
18
|
+
depth,
|
|
19
|
+
colSpan,
|
|
20
|
+
rowSpan
|
|
21
|
+
} = props;
|
|
22
|
+
const {
|
|
23
|
+
t,
|
|
24
|
+
prefix,
|
|
25
|
+
setSorterChange,
|
|
26
|
+
setFilterChange,
|
|
27
|
+
wrapSettings,
|
|
28
|
+
selectionSettings,
|
|
29
|
+
isSelectionChange,
|
|
30
|
+
setIsSelectionChange,
|
|
31
|
+
id,
|
|
32
|
+
locale,
|
|
33
|
+
format,
|
|
34
|
+
dataSourceFilter
|
|
35
|
+
} = useContext(TableContext);
|
|
36
|
+
const isPinned = column.getIsPinned();
|
|
37
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
|
|
38
|
+
const isFirstRightPinnedColumn = isPinned === 'right' && column.getIsFirstColumn('right');
|
|
39
|
+
const [selectedKeys, setSelectedKeys] = React.useState([]);
|
|
40
|
+
const [visible, setVisible] = React.useState(false);
|
|
41
|
+
const {
|
|
42
|
+
filterIcon
|
|
43
|
+
} = column.columnDef.meta ?? {};
|
|
44
|
+
const originalColumn = column.columnDef.meta ?? {};
|
|
45
|
+
const cellStyles = typeof originalColumn.onCellHeaderStyles === 'function' ? originalColumn.onCellHeaderStyles(header) : originalColumn.onCellHeaderStyles;
|
|
46
|
+
const filtered = (column.getFilterValue() ?? []).length > 0;
|
|
47
|
+
const cellContent = flexRender(column.columnDef.header, header.getContext());
|
|
48
|
+
const html = ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, cellContent));
|
|
49
|
+
const hasValue = html.trim().length > 0;
|
|
50
|
+
const style = {
|
|
51
|
+
transition: 'width transform 0.2s ease-in-out',
|
|
52
|
+
whiteSpace: 'nowrap',
|
|
53
|
+
...cellStyles
|
|
54
|
+
};
|
|
55
|
+
const getDropdownTrigger = () => {
|
|
56
|
+
let iconFilter;
|
|
57
|
+
if (typeof filterIcon === 'function') {
|
|
58
|
+
iconFilter = filterIcon(filtered);
|
|
59
|
+
} else if (filterIcon) {
|
|
60
|
+
iconFilter = filterIcon;
|
|
61
|
+
} else {
|
|
62
|
+
iconFilter = /*#__PURE__*/React.createElement(FilterFill, {
|
|
63
|
+
style: {
|
|
64
|
+
color: filtered ? '#E3165B' : '#283046'
|
|
65
|
+
},
|
|
66
|
+
fontSize: 12
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
70
|
+
role: "button",
|
|
71
|
+
tabIndex: -1,
|
|
72
|
+
className: classNames(`${prefix}-trigger`, {
|
|
73
|
+
active: filtered
|
|
74
|
+
}),
|
|
75
|
+
onClick: e => {
|
|
76
|
+
e.stopPropagation();
|
|
77
|
+
}
|
|
78
|
+
}, iconFilter);
|
|
79
|
+
};
|
|
80
|
+
const triggerVisible = newVisible => {
|
|
81
|
+
setVisible(newVisible);
|
|
82
|
+
};
|
|
83
|
+
const onVisibleChange = (newVisible, info) => {
|
|
84
|
+
if (info.source === 'trigger') {
|
|
85
|
+
if (newVisible) {
|
|
86
|
+
const filterValue = column.getFilterValue() ?? [];
|
|
87
|
+
const operatorValue = column.getFilterOperator() ?? getDefaultOperator(column.columnDef?.meta ?? {});
|
|
88
|
+
setSelectedKeys(filterValue);
|
|
89
|
+
column.setFilterOperator?.(operatorValue);
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
const inputFilter = document.querySelector('.filter-input');
|
|
92
|
+
if (inputFilter) {
|
|
93
|
+
inputFilter.focus();
|
|
94
|
+
}
|
|
95
|
+
}, 200);
|
|
96
|
+
} else {}
|
|
97
|
+
triggerVisible(newVisible);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const doFilter = type => {
|
|
101
|
+
if (type) {
|
|
102
|
+
column.setFilterValue(!originalColumn.typeFilter || originalColumn.typeFilter === 'Text' ? selectedKeys.length === 0 ? [''] : selectedKeys : selectedKeys);
|
|
103
|
+
} else {
|
|
104
|
+
column.setFilterValue(undefined);
|
|
105
|
+
setSelectedKeys([]);
|
|
106
|
+
}
|
|
107
|
+
setFilterChange(true);
|
|
108
|
+
triggerVisible(false);
|
|
109
|
+
setTimeout(() => {
|
|
110
|
+
setFilterChange(false);
|
|
111
|
+
}, 10);
|
|
112
|
+
};
|
|
113
|
+
const mergedDropdownProps = extendsObject({
|
|
114
|
+
trigger: ['click'],
|
|
115
|
+
placement: 'bottomRight',
|
|
116
|
+
// placement: direction === 'rtl' ? 'bottomLeft' : 'bottomRight',
|
|
117
|
+
children: getDropdownTrigger(),
|
|
118
|
+
getPopupContainer
|
|
119
|
+
}, {
|
|
120
|
+
// ...filterDropdownProps,
|
|
121
|
+
// rootClassName: classNames(rootClassName, filterDropdownProps.rootClassName),
|
|
122
|
+
open: visible,
|
|
123
|
+
onOpenChange: onVisibleChange,
|
|
124
|
+
destroyPopupOnHide: true,
|
|
125
|
+
dropdownRender: () => {
|
|
126
|
+
const type = getTypeFilter(originalColumn);
|
|
127
|
+
const operatorValue = column.getFilterOperator() ?? getDefaultOperator(originalColumn);
|
|
128
|
+
const operatorOptions = ['Checkbox', 'Dropdown', 'DropTree', 'CheckboxDropdown'].includes(type) ? booleanOperator : !type || type === 'Text' ? stringOperator : numberOperator;
|
|
129
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
130
|
+
// className='ui-rc-table-filter-dropdown'
|
|
131
|
+
|
|
132
|
+
className: classNames(`${prefix}-grid-filter-dropdown`, {}),
|
|
133
|
+
style: {}
|
|
134
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
135
|
+
style: {
|
|
136
|
+
minWidth: 275,
|
|
137
|
+
padding: '8px'
|
|
138
|
+
}
|
|
139
|
+
}, /*#__PURE__*/React.createElement("div", null), column.columnDef?.meta?.hideOperator === true && column.columnDef?.meta?.typeFilter !== 'DateRange' && column.columnDef?.meta?.typeFilter !== 'NumberRange' && /*#__PURE__*/React.createElement("div", {
|
|
140
|
+
className: 'mb-1'
|
|
141
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
142
|
+
options: translateOption(operatorOptions, t),
|
|
143
|
+
style: {
|
|
144
|
+
width: '100%',
|
|
145
|
+
marginBottom: 8
|
|
146
|
+
},
|
|
147
|
+
value: operatorValue,
|
|
148
|
+
onChange: val => {
|
|
149
|
+
column.setFilterOperator(val);
|
|
150
|
+
}
|
|
151
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
style: {
|
|
153
|
+
marginBottom: 8
|
|
154
|
+
}
|
|
155
|
+
}, renderFilter({
|
|
156
|
+
column: column.columnDef,
|
|
157
|
+
selectedKeys,
|
|
158
|
+
setSelectedKeys,
|
|
159
|
+
doFilter,
|
|
160
|
+
format,
|
|
161
|
+
dataSourceFilter
|
|
162
|
+
|
|
163
|
+
// selectedKeys: (column.getFilterValue() ?? []) as string[],
|
|
164
|
+
// setSelectedKeys: column.setFilterValue,
|
|
165
|
+
})), /*#__PURE__*/React.createElement(Space, {
|
|
166
|
+
style: {
|
|
167
|
+
justifyContent: 'end',
|
|
168
|
+
width: '100%'
|
|
169
|
+
}
|
|
170
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
171
|
+
type: "primary",
|
|
172
|
+
onClick: () => {
|
|
173
|
+
// column.setFilterValue(selectedKeys)
|
|
174
|
+
|
|
175
|
+
doFilter(true);
|
|
176
|
+
},
|
|
177
|
+
size: "small",
|
|
178
|
+
style: {
|
|
179
|
+
width: 90
|
|
180
|
+
}
|
|
181
|
+
}, t ? t('Filter') : 'Filter'), /*#__PURE__*/React.createElement(Button, {
|
|
182
|
+
type: "link",
|
|
183
|
+
size: "small",
|
|
184
|
+
onClick: () => {
|
|
185
|
+
// column.setFilterValue([])
|
|
186
|
+
// column.setFilterOperator('')
|
|
187
|
+
|
|
188
|
+
setSelectedKeys([]);
|
|
189
|
+
doFilter(false);
|
|
190
|
+
}
|
|
191
|
+
}, t ? t('Clear') : 'Clear'))));
|
|
192
|
+
|
|
193
|
+
// if (typeof filterDropdownProps?.dropdownRender === 'function') {
|
|
194
|
+
// return filterDropdownProps.dropdownRender(dropdownContent);
|
|
195
|
+
// }
|
|
196
|
+
// return dropdownContent;
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
200
|
+
// ref={setNodeRef}
|
|
201
|
+
className: classNames(`${prefix}-grid-cell`, {
|
|
202
|
+
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
203
|
+
[`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
|
|
204
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
205
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
206
|
+
[`${prefix}-grid-cell-text-center`]: (originalColumn?.headerTextAlign ?? originalColumn?.textAlign) === 'center',
|
|
207
|
+
[`${prefix}-grid-cell-text-right`]: (originalColumn?.headerTextAlign ?? originalColumn.textAlign) === 'right'
|
|
208
|
+
}),
|
|
209
|
+
key: column.id,
|
|
210
|
+
style: {
|
|
211
|
+
...style,
|
|
212
|
+
minWidth: column.getSize(),
|
|
213
|
+
gridRow: `${depth + 1} / span ${rowSpan}`,
|
|
214
|
+
gridColumn: `span ${colSpan}`,
|
|
215
|
+
...getCommonPinningStyles(column),
|
|
216
|
+
width: 'auto'
|
|
217
|
+
},
|
|
218
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
219
|
+
"data-tooltip-delay-show": 500,
|
|
220
|
+
"data-tooltip-html": !hasValue ? '' : ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement("div", null, cellContent))
|
|
221
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
222
|
+
className: classNames('', {
|
|
223
|
+
[`${prefix}-grid-filter-column`]: column.id !== 'selection_column',
|
|
224
|
+
[`${prefix}-grid-selection-column`]: column.id === 'selection_column'
|
|
225
|
+
})
|
|
226
|
+
}, column.id === 'selection_column' && selectionSettings && selectionSettings.hideSelectAll !== true && selectionSettings.type !== 'single' && selectionSettings.mode !== 'radio' && /*#__PURE__*/React.createElement(Checkbox, {
|
|
227
|
+
checked: table.getIsAllRowsSelected(),
|
|
228
|
+
indeterminate: table.getIsSomePageRowsSelected(),
|
|
229
|
+
onChange: e => {
|
|
230
|
+
table.getToggleAllRowsSelectedHandler()(e);
|
|
231
|
+
const prevSelected = isSelectionChange?.rowsData ?? [];
|
|
232
|
+
const allRowsInPage = table.getRowModel().flatRows;
|
|
233
|
+
if (table.getIsAllRowsSelected()) {
|
|
234
|
+
const cc = excludeItems(prevSelected, allRowsInPage);
|
|
235
|
+
setIsSelectionChange({
|
|
236
|
+
isChange: true,
|
|
237
|
+
type: 'all',
|
|
238
|
+
rowData: {},
|
|
239
|
+
rowsData: cc
|
|
240
|
+
});
|
|
241
|
+
} else {
|
|
242
|
+
const abc = [...prevSelected, ...allRowsInPage];
|
|
243
|
+
const newSeletedRows = removeDuplicatesByKey(abc, 'id');
|
|
244
|
+
setIsSelectionChange({
|
|
245
|
+
isChange: true,
|
|
246
|
+
type: 'all',
|
|
247
|
+
rowData: {},
|
|
248
|
+
rowsData: newSeletedRows
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}), column.id !== 'selection_column' && /*#__PURE__*/React.createElement("span", {
|
|
253
|
+
className: "ui-rc-table-column-title",
|
|
254
|
+
style: {
|
|
255
|
+
flex: 1
|
|
256
|
+
}
|
|
257
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
258
|
+
className: classNames('', {
|
|
259
|
+
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
260
|
+
[`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')
|
|
261
|
+
})
|
|
262
|
+
}, cellContent)), !nonActionColumn.includes(column.id) && column.columns.length < 1 && /*#__PURE__*/React.createElement("span", {
|
|
263
|
+
className: "ui-rc-header-trigger"
|
|
264
|
+
}, column.getCanSort() && /*#__PURE__*/React.createElement("div", {
|
|
265
|
+
style: {
|
|
266
|
+
marginInlineEnd: 6,
|
|
267
|
+
cursor: 'pointer'
|
|
268
|
+
},
|
|
269
|
+
onClick: e => {
|
|
270
|
+
setSorterChange(true);
|
|
271
|
+
const toggleSortingHandler = column.getToggleSortingHandler();
|
|
272
|
+
if (typeof toggleSortingHandler === 'function') {
|
|
273
|
+
toggleSortingHandler(e);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}, column.getIsSorted() ? column.getIsSorted() === 'asc' ? /*#__PURE__*/React.createElement(ArrowUp, {
|
|
277
|
+
fontSize: 15,
|
|
278
|
+
color: '#000'
|
|
279
|
+
// data-tooltip-id={`${id}-tooltip-header-trigger`}
|
|
280
|
+
,
|
|
281
|
+
"data-tooltip-id": `${id}-tooltip-content`
|
|
282
|
+
// data-tooltip-content='Nhấp để sắp xếp giảm dần'
|
|
283
|
+
,
|
|
284
|
+
"data-tooltip-content": locale?.triggerDesc ?? 'Click to sort descending'
|
|
285
|
+
}) : /*#__PURE__*/React.createElement(ArrowDown, {
|
|
286
|
+
fontSize: 15,
|
|
287
|
+
color: '#000',
|
|
288
|
+
"data-tooltip-id": `${id}-tooltip-content`
|
|
289
|
+
// data-tooltip-id={`${id}-tooltip-header-trigger`}
|
|
290
|
+
// data-tooltip-content='Nhấp để hủy sắp xếp'
|
|
291
|
+
,
|
|
292
|
+
"data-tooltip-content": locale?.cancelSort ?? 'Click to cancel sorting'
|
|
293
|
+
}) : /*#__PURE__*/React.createElement(SortCancel
|
|
294
|
+
// data-tooltip-id={`${id}-tooltip-header-trigger`}
|
|
295
|
+
, {
|
|
296
|
+
"data-tooltip-id": `${id}-tooltip-content`
|
|
297
|
+
// data-tooltip-content='Nhấp để sắp xếp tăng dần'
|
|
298
|
+
,
|
|
299
|
+
"data-tooltip-content": locale?.triggerAsc ?? 'Click to sort ascending',
|
|
300
|
+
fontSize: 15,
|
|
301
|
+
style: {
|
|
302
|
+
display: 'flex'
|
|
303
|
+
},
|
|
304
|
+
className: classNames(`ui-rc-table-column-sorter-cancel`, {
|
|
305
|
+
active: true
|
|
306
|
+
})
|
|
307
|
+
})), column.getCanFilter() && /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Dropdown, mergedDropdownProps)))), column.getCanResize() && /*#__PURE__*/React.createElement("div", {
|
|
308
|
+
onDoubleClick: () => column.resetSize(),
|
|
309
|
+
onMouseDown: header.getResizeHandler(),
|
|
310
|
+
onTouchStart: header.getResizeHandler(),
|
|
311
|
+
// onMouseUp: () => {
|
|
312
|
+
// requestAnimationFrame(() => {
|
|
313
|
+
// columnVirtualizer.measure()
|
|
314
|
+
// // rowHeaderVirtualizer.measure()
|
|
315
|
+
// })
|
|
316
|
+
// },
|
|
317
|
+
|
|
318
|
+
className: `resizer ${column.getIsResizing() ? 'isResizing' : ''}`
|
|
319
|
+
}));
|
|
320
|
+
};
|
|
321
|
+
export default TableHeadCell2;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Table } from '@tanstack/react-table';
|
|
2
|
+
import { type Header } from '@tanstack/react-table';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import type { Virtualizer } from '@tanstack/react-virtual';
|
|
5
|
+
interface TableHeadCellProps<T> {
|
|
6
|
+
t?: any;
|
|
7
|
+
table: Table<T>;
|
|
8
|
+
column: any;
|
|
9
|
+
header: Header<T, unknown>;
|
|
10
|
+
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
11
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
12
|
+
colSpan: number;
|
|
13
|
+
rowSpan: number;
|
|
14
|
+
depth: number;
|
|
15
|
+
}
|
|
16
|
+
declare const TableHeadGroupCell: <RecordType extends object>(props: TableHeadCellProps<RecordType>) => React.JSX.Element;
|
|
17
|
+
export default TableHeadGroupCell;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { flexRender } from '@tanstack/react-table';
|
|
2
|
+
import React, { useContext } from 'react';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
import { Checkbox } from 'rc-master-ui';
|
|
5
|
+
import { getCommonPinningStyles2 } from "../hook/utils";
|
|
6
|
+
import { TableContext } from "../useContext";
|
|
7
|
+
import ReactDOMServer from 'react-dom/server';
|
|
8
|
+
const TableHeadGroupCell = props => {
|
|
9
|
+
const {
|
|
10
|
+
column,
|
|
11
|
+
header,
|
|
12
|
+
table,
|
|
13
|
+
depth,
|
|
14
|
+
colSpan,
|
|
15
|
+
rowSpan
|
|
16
|
+
} = props;
|
|
17
|
+
const {
|
|
18
|
+
prefix,
|
|
19
|
+
wrapSettings,
|
|
20
|
+
selectionSettings,
|
|
21
|
+
setIsSelectionChange,
|
|
22
|
+
id
|
|
23
|
+
} = useContext(TableContext);
|
|
24
|
+
const isPinned = column.getIsPinned();
|
|
25
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && column.getIsLastColumn('left');
|
|
26
|
+
const isFirstRightPinnedColumn = isPinned === 'right' && column.getIsFirstColumn('right');
|
|
27
|
+
const originalColumn = column.columnDef.meta ?? {};
|
|
28
|
+
const cellStyles = typeof originalColumn.onCellHeaderStyles === 'function' ? originalColumn.onCellHeaderStyles(header) : originalColumn.onCellHeaderStyles;
|
|
29
|
+
const cellContent = flexRender(column.columnDef.header, header.getContext());
|
|
30
|
+
const html = ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, cellContent));
|
|
31
|
+
const hasValue = html.trim().length > 0;
|
|
32
|
+
const style = {
|
|
33
|
+
transition: 'width transform 0.2s ease-in-out',
|
|
34
|
+
whiteSpace: 'nowrap',
|
|
35
|
+
...cellStyles
|
|
36
|
+
};
|
|
37
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
38
|
+
// ref={setNodeRef}
|
|
39
|
+
className: classNames(`${prefix}-grid-cell`, {
|
|
40
|
+
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
41
|
+
[`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
|
|
42
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
43
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
|
|
44
|
+
[`${prefix}-grid-cell-text-center`]: (originalColumn?.headerTextAlign ?? originalColumn?.textAlign) === 'center',
|
|
45
|
+
[`${prefix}-grid-cell-text-right`]: (originalColumn?.headerTextAlign ?? originalColumn.textAlign) === 'right'
|
|
46
|
+
}),
|
|
47
|
+
"data-col-span": colSpan,
|
|
48
|
+
key: header.id,
|
|
49
|
+
style: {
|
|
50
|
+
minWidth: column.getSize(),
|
|
51
|
+
flex: 1,
|
|
52
|
+
gridRow: `${depth + 1} / span ${rowSpan}`,
|
|
53
|
+
gridColumn: `span ${colSpan}`,
|
|
54
|
+
...getCommonPinningStyles2(header),
|
|
55
|
+
width: 'auto',
|
|
56
|
+
...style
|
|
57
|
+
},
|
|
58
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
59
|
+
"data-tooltip-html": !hasValue ? '' : ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement("div", null, cellContent))
|
|
60
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
61
|
+
className: classNames('', {
|
|
62
|
+
[`${prefix}-grid-filter-column`]: column.id !== 'selection_column',
|
|
63
|
+
[`${prefix}-grid-selection-column`]: column.id === 'selection_column'
|
|
64
|
+
})
|
|
65
|
+
}, column.id === 'selection_column' && selectionSettings && selectionSettings.hideSelectAll !== false && selectionSettings.type !== 'single' && selectionSettings.mode !== 'radio' && /*#__PURE__*/React.createElement(Checkbox, {
|
|
66
|
+
checked: table.getIsAllRowsSelected(),
|
|
67
|
+
indeterminate: table.getIsSomeRowsSelected(),
|
|
68
|
+
onChange: e => {
|
|
69
|
+
setIsSelectionChange({
|
|
70
|
+
isChange: true,
|
|
71
|
+
type: 'all',
|
|
72
|
+
rowData: {},
|
|
73
|
+
rowsData: []
|
|
74
|
+
});
|
|
75
|
+
table.getToggleAllRowsSelectedHandler()(e);
|
|
76
|
+
}
|
|
77
|
+
}), column.id !== 'selection_column' && /*#__PURE__*/React.createElement("span", {
|
|
78
|
+
className: "ui-rc-table-column-title",
|
|
79
|
+
style: {
|
|
80
|
+
flex: 1
|
|
81
|
+
}
|
|
82
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
83
|
+
className: classNames('', {
|
|
84
|
+
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
85
|
+
[`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')
|
|
86
|
+
})
|
|
87
|
+
}, cellContent))), column.getCanResize() && /*#__PURE__*/React.createElement("div", {
|
|
88
|
+
onDoubleClick: () => column.resetSize(),
|
|
89
|
+
onMouseDown: header.getResizeHandler(),
|
|
90
|
+
onTouchStart: header.getResizeHandler(),
|
|
91
|
+
className: `resizer ${column.getIsResizing() ? 'isResizing' : ''}`
|
|
92
|
+
}));
|
|
93
|
+
};
|
|
94
|
+
export default TableHeadGroupCell;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Column } from '@tanstack/react-table';
|
|
2
|
+
import { type HeaderGroup, type Table } from '@tanstack/react-table';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import type { Virtualizer } from '@tanstack/react-virtual';
|
|
5
|
+
interface TableHeadRowProps<T> {
|
|
6
|
+
headerGroup: HeaderGroup<T>;
|
|
7
|
+
table: Table<T>;
|
|
8
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
9
|
+
virtualPaddingLeft: number | undefined;
|
|
10
|
+
virtualPaddingRight: number | undefined;
|
|
11
|
+
fixedLeftColumns: Column<T, unknown>[];
|
|
12
|
+
fixedRightColumns: Column<T, unknown>[];
|
|
13
|
+
}
|
|
14
|
+
declare const TableHeadRow: ({ table, headerGroup, columnVirtualizer, }: TableHeadRowProps<any>) => React.JSX.Element;
|
|
15
|
+
export default TableHeadRow;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { horizontalListSortingStrategy, SortableContext } from '@dnd-kit/sortable';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { TableContext } from "../useContext";
|
|
4
|
+
import TableHeadCell from "./TableHeadCell";
|
|
5
|
+
const TableHeadRow = ({
|
|
6
|
+
table,
|
|
7
|
+
headerGroup,
|
|
8
|
+
columnVirtualizer
|
|
9
|
+
}) => {
|
|
10
|
+
const {
|
|
11
|
+
prefix,
|
|
12
|
+
onRowHeaderStyles
|
|
13
|
+
} = React.useContext(TableContext);
|
|
14
|
+
const columnOrder = table.getState().columnOrder;
|
|
15
|
+
const rowStyles = typeof onRowHeaderStyles === 'function' ? onRowHeaderStyles() : onRowHeaderStyles;
|
|
16
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
17
|
+
key: headerGroup.id
|
|
18
|
+
// ref={el => {
|
|
19
|
+
// if (el) rowHeaderVirtualizer.measureElement(el)
|
|
20
|
+
// }}
|
|
21
|
+
,
|
|
22
|
+
|
|
23
|
+
"data-index": headerGroup.id,
|
|
24
|
+
className: `${prefix}-grid-row ${prefix}-grid-header`,
|
|
25
|
+
style: {
|
|
26
|
+
...rowStyles,
|
|
27
|
+
width: '100%'
|
|
28
|
+
}
|
|
29
|
+
}, /*#__PURE__*/React.createElement(SortableContext, {
|
|
30
|
+
items: columnOrder,
|
|
31
|
+
strategy: horizontalListSortingStrategy
|
|
32
|
+
}, headerGroup.headers.map(header => {
|
|
33
|
+
const columnRelativeDepth = header.depth - header.column.depth;
|
|
34
|
+
if (columnRelativeDepth > 1) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
let rowSpan = 1;
|
|
38
|
+
if (header.isPlaceholder) {
|
|
39
|
+
const leafs = header.getLeafHeaders();
|
|
40
|
+
rowSpan = leafs[leafs.length - 1].depth - header.depth;
|
|
41
|
+
}
|
|
42
|
+
return /*#__PURE__*/React.createElement(TableHeadCell, {
|
|
43
|
+
key: header.id,
|
|
44
|
+
header: header,
|
|
45
|
+
table: table,
|
|
46
|
+
columnVirtualizer: columnVirtualizer,
|
|
47
|
+
colSpan: header.colSpan,
|
|
48
|
+
rowSpan: rowSpan
|
|
49
|
+
});
|
|
50
|
+
})));
|
|
51
|
+
};
|
|
52
|
+
export default TableHeadRow;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { IFormat } from "../../grid-component/type";
|
|
4
|
+
type RenderFilterProps<RecordType> = {
|
|
5
|
+
column: ColumnDef<RecordType, unknown>;
|
|
6
|
+
selectedKeys: any[];
|
|
7
|
+
setSelectedKeys: (keys: any[]) => void;
|
|
8
|
+
t?: any;
|
|
9
|
+
locale?: any;
|
|
10
|
+
dataSourceFilter?: {
|
|
11
|
+
key: string;
|
|
12
|
+
data: any[];
|
|
13
|
+
}[];
|
|
14
|
+
format?: IFormat;
|
|
15
|
+
buddhistLocale?: any;
|
|
16
|
+
dateRangeLocale?: any;
|
|
17
|
+
doFilter?: (type: boolean) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const renderFilter: <RecordType>(args: RenderFilterProps<RecordType>) => React.JSX.Element;
|
|
20
|
+
export {};
|