es-grid-template 1.7.23 → 1.7.25
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/index.d.ts +1 -0
- package/es/index.js +3 -1
- package/es/table-component/ColumnsChoose.d.ts +13 -0
- package/es/table-component/ColumnsChoose.js +206 -0
- package/es/table-component/ContextMenu.d.ts +20 -0
- package/es/table-component/ContextMenu.js +75 -0
- package/es/table-component/InternalTable.d.ts +9 -0
- package/es/table-component/InternalTable.js +308 -0
- package/es/table-component/TableContainer.d.ts +31 -0
- package/es/table-component/TableContainer.js +249 -0
- package/es/table-component/TableContainerEdit.d.ts +31 -0
- package/es/table-component/TableContainerEdit.js +1301 -0
- package/es/table-component/body/EditableCell.d.ts +16 -0
- package/es/table-component/body/EditableCell.js +1039 -0
- package/es/table-component/body/TableBody.d.ts +19 -0
- package/es/table-component/body/TableBody.js +64 -0
- package/es/table-component/body/TableBodyCell.d.ts +12 -0
- package/es/table-component/body/TableBodyCell.js +149 -0
- package/es/table-component/body/TableBodyCellEdit.d.ts +16 -0
- package/es/table-component/body/TableBodyCellEdit.js +931 -0
- package/es/table-component/body/TableBodyRow.d.ts +21 -0
- package/es/table-component/body/TableBodyRow.js +151 -0
- package/es/table-component/components/ControlCheckbox.d.ts +13 -0
- package/es/table-component/components/ControlCheckbox.js +84 -0
- package/es/table-component/components/EditForm/EditForm.d.ts +27 -0
- package/es/table-component/components/EditForm/EditForm.js +395 -0
- package/es/table-component/components/EditForm/index.d.ts +1 -0
- package/es/table-component/components/EditForm/index.js +1 -0
- package/es/table-component/components/InputControl/InputControl.d.ts +27 -0
- package/es/table-component/components/InputControl/InputControl.js +121 -0
- package/es/table-component/components/InputControl/index.d.ts +1 -0
- package/es/table-component/components/InputControl/index.js +1 -0
- package/es/table-component/components/async-select/index.d.ts +11 -0
- package/es/table-component/components/async-select/index.js +41 -0
- package/es/table-component/components/async-table-select/index.d.ts +11 -0
- package/es/table-component/components/async-table-select/index.js +44 -0
- package/es/table-component/components/checkbox-control/index.d.ts +13 -0
- package/es/table-component/components/checkbox-control/index.js +40 -0
- package/es/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/es/table-component/components/checkbox-filter/CheckboxFilter.js +240 -0
- package/es/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/es/table-component/components/checkbox-filter/FilterSearch.js +36 -0
- package/es/table-component/components/command/Command.d.ts +10 -0
- package/es/table-component/components/command/Command.js +33 -0
- package/es/table-component/components/number/index.d.ts +10 -0
- package/es/table-component/components/number/index.js +42 -0
- package/es/table-component/components/number-range/index.d.ts +11 -0
- package/es/table-component/components/number-range/index.js +66 -0
- package/es/table-component/features/operator.d.ts +24 -0
- package/es/table-component/features/operator.js +62 -0
- package/es/table-component/footer/TableFooter.d.ts +13 -0
- package/es/table-component/footer/TableFooter.js +33 -0
- package/es/table-component/footer/TableFooterCell.d.ts +10 -0
- package/es/table-component/footer/TableFooterCell.js +66 -0
- package/es/table-component/footer/TableFooterRow.d.ts +14 -0
- package/es/table-component/footer/TableFooterRow.js +73 -0
- package/es/table-component/header/TableHead.d.ts +14 -0
- package/es/table-component/header/TableHead.js +60 -0
- package/es/table-component/header/TableHeadCell.d.ts +14 -0
- package/es/table-component/header/TableHeadCell.js +343 -0
- package/es/table-component/header/TableHeadRow.d.ts +16 -0
- package/es/table-component/header/TableHeadRow.js +76 -0
- package/es/table-component/header/renderFilter.d.ts +20 -0
- package/es/table-component/header/renderFilter.js +281 -0
- package/es/table-component/hook/constant.d.ts +73 -0
- package/es/table-component/hook/constant.js +240 -0
- package/es/table-component/hook/useColumns.d.ts +9 -0
- package/es/table-component/hook/useColumns.js +169 -0
- package/es/table-component/hook/useFilterOperator.d.ts +7 -0
- package/es/table-component/hook/useFilterOperator.js +33 -0
- package/es/table-component/hook/utils.d.ts +133 -0
- package/es/table-component/hook/utils.js +1870 -0
- package/es/table-component/index.d.ts +5 -0
- package/es/table-component/index.js +2 -0
- package/es/table-component/style.scss +1129 -0
- package/es/table-component/table/Grid.d.ts +24 -0
- package/es/table-component/table/Grid.js +234 -0
- package/es/table-component/type.d.ts +513 -0
- package/es/table-component/type.js +1 -0
- package/es/table-component/useContext.d.ts +74 -0
- package/es/table-component/useContext.js +15 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -1
- package/lib/table-component/ColumnsChoose.d.ts +13 -0
- package/lib/table-component/ColumnsChoose.js +216 -0
- package/lib/table-component/ContextMenu.d.ts +20 -0
- package/lib/table-component/ContextMenu.js +85 -0
- package/lib/table-component/InternalTable.d.ts +9 -0
- package/lib/table-component/InternalTable.js +313 -0
- package/lib/table-component/TableContainer.d.ts +31 -0
- package/lib/table-component/TableContainer.js +257 -0
- package/lib/table-component/TableContainerEdit.d.ts +31 -0
- package/lib/table-component/TableContainerEdit.js +1310 -0
- package/lib/table-component/body/EditableCell.d.ts +16 -0
- package/lib/table-component/body/EditableCell.js +1041 -0
- package/lib/table-component/body/TableBody.d.ts +19 -0
- package/lib/table-component/body/TableBody.js +72 -0
- package/lib/table-component/body/TableBodyCell.d.ts +12 -0
- package/lib/table-component/body/TableBodyCell.js +158 -0
- package/lib/table-component/body/TableBodyCellEdit.d.ts +16 -0
- package/lib/table-component/body/TableBodyCellEdit.js +938 -0
- package/lib/table-component/body/TableBodyRow.d.ts +21 -0
- package/lib/table-component/body/TableBodyRow.js +158 -0
- package/lib/table-component/components/ControlCheckbox.d.ts +13 -0
- package/lib/table-component/components/ControlCheckbox.js +92 -0
- package/lib/table-component/components/EditForm/EditForm.d.ts +27 -0
- package/lib/table-component/components/EditForm/EditForm.js +406 -0
- package/lib/table-component/components/EditForm/index.d.ts +1 -0
- package/lib/table-component/components/EditForm/index.js +16 -0
- package/lib/table-component/components/InputControl/InputControl.d.ts +27 -0
- package/lib/table-component/components/InputControl/InputControl.js +131 -0
- package/lib/table-component/components/InputControl/index.d.ts +1 -0
- package/lib/table-component/components/InputControl/index.js +16 -0
- package/lib/table-component/components/async-select/index.d.ts +11 -0
- package/lib/table-component/components/async-select/index.js +49 -0
- package/lib/table-component/components/async-table-select/index.d.ts +11 -0
- package/lib/table-component/components/async-table-select/index.js +53 -0
- package/lib/table-component/components/checkbox-control/index.d.ts +13 -0
- package/lib/table-component/components/checkbox-control/index.js +48 -0
- package/lib/table-component/components/checkbox-filter/CheckboxFilter.d.ts +18 -0
- package/lib/table-component/components/checkbox-filter/CheckboxFilter.js +249 -0
- package/lib/table-component/components/checkbox-filter/FilterSearch.d.ts +12 -0
- package/lib/table-component/components/checkbox-filter/FilterSearch.js +44 -0
- package/lib/table-component/components/command/Command.d.ts +10 -0
- package/lib/table-component/components/command/Command.js +42 -0
- package/lib/table-component/components/number/index.d.ts +10 -0
- package/lib/table-component/components/number/index.js +50 -0
- package/lib/table-component/components/number-range/index.d.ts +11 -0
- package/lib/table-component/components/number-range/index.js +74 -0
- package/lib/table-component/features/operator.d.ts +24 -0
- package/lib/table-component/features/operator.js +67 -0
- package/lib/table-component/footer/TableFooter.d.ts +13 -0
- package/lib/table-component/footer/TableFooter.js +42 -0
- package/lib/table-component/footer/TableFooterCell.d.ts +10 -0
- package/lib/table-component/footer/TableFooterCell.js +76 -0
- package/lib/table-component/footer/TableFooterRow.d.ts +14 -0
- package/lib/table-component/footer/TableFooterRow.js +81 -0
- package/lib/table-component/header/TableHead.d.ts +14 -0
- package/lib/table-component/header/TableHead.js +69 -0
- package/lib/table-component/header/TableHeadCell.d.ts +14 -0
- package/lib/table-component/header/TableHeadCell.js +352 -0
- package/lib/table-component/header/TableHeadRow.d.ts +16 -0
- package/lib/table-component/header/TableHeadRow.js +84 -0
- package/lib/table-component/header/renderFilter.d.ts +20 -0
- package/lib/table-component/header/renderFilter.js +291 -0
- package/lib/table-component/hook/constant.d.ts +73 -0
- package/lib/table-component/hook/constant.js +247 -0
- package/lib/table-component/hook/useColumns.d.ts +9 -0
- package/lib/table-component/hook/useColumns.js +180 -0
- package/lib/table-component/hook/useFilterOperator.d.ts +7 -0
- package/lib/table-component/hook/useFilterOperator.js +40 -0
- package/lib/table-component/hook/utils.d.ts +133 -0
- package/lib/table-component/hook/utils.js +1969 -0
- package/lib/table-component/index.d.ts +5 -0
- package/lib/table-component/index.js +9 -0
- package/lib/table-component/style.scss +1129 -0
- package/lib/table-component/table/Grid.d.ts +24 -0
- package/lib/table-component/table/Grid.js +236 -0
- package/lib/table-component/type.d.ts +513 -0
- package/lib/table-component/type.js +5 -0
- package/lib/table-component/useContext.d.ts +74 -0
- package/lib/table-component/useContext.js +21 -0
- package/package.json +4 -2
|
@@ -0,0 +1,352 @@
|
|
|
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 _reactTable = require("@tanstack/react-table");
|
|
9
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _antd = require("antd");
|
|
11
|
+
var _becoxyIcons = require("becoxy-icons");
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
var _rcMasterUi = require("rc-master-ui");
|
|
14
|
+
var _constant = require("../hook/constant");
|
|
15
|
+
var _utils = require("../hook/utils");
|
|
16
|
+
var _useContext = require("../useContext");
|
|
17
|
+
var _renderFilter = require("./renderFilter");
|
|
18
|
+
var _server = _interopRequireDefault(require("react-dom/server"));
|
|
19
|
+
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); }
|
|
20
|
+
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; }
|
|
21
|
+
// import { useSortable } from "@dnd-kit/sortable"
|
|
22
|
+
|
|
23
|
+
// import { CSS } from '@dnd-kit/utilities'
|
|
24
|
+
|
|
25
|
+
// import { ColumnTable } from "../type";
|
|
26
|
+
|
|
27
|
+
// import { Tooltip } from 'react-tooltip'
|
|
28
|
+
|
|
29
|
+
const TableHeadCell = props => {
|
|
30
|
+
const {
|
|
31
|
+
header,
|
|
32
|
+
getPopupContainer,
|
|
33
|
+
table,
|
|
34
|
+
t,
|
|
35
|
+
columnVirtualizer,
|
|
36
|
+
rowHeaderVirtualizer
|
|
37
|
+
} = props;
|
|
38
|
+
const {
|
|
39
|
+
prefix,
|
|
40
|
+
setSorterChange,
|
|
41
|
+
setFilterChange,
|
|
42
|
+
wrapSettings,
|
|
43
|
+
selectionSettings,
|
|
44
|
+
setIsSelectionChange,
|
|
45
|
+
id,
|
|
46
|
+
locale
|
|
47
|
+
} = (0, _react.useContext)(_useContext.TableContext);
|
|
48
|
+
const isPinned = header.column.getIsPinned();
|
|
49
|
+
const isLastLeftPinnedColumn = isPinned === 'left' && header.column.getIsLastColumn('left');
|
|
50
|
+
const isFirstRightPinnedColumn = isPinned === 'right' && header.column.getIsFirstColumn('right');
|
|
51
|
+
const [selectedKeys, setSelectedKeys] = _react.default.useState([]);
|
|
52
|
+
const [visible, setVisible] = _react.default.useState(false);
|
|
53
|
+
const {
|
|
54
|
+
filterIcon
|
|
55
|
+
} = header.column.columnDef.meta ?? {};
|
|
56
|
+
|
|
57
|
+
// const column = (header.column.columnDef ?? {}) as ColumnTable
|
|
58
|
+
const column = header.column.columnDef;
|
|
59
|
+
const originalColumn = header.column.columnDef.meta ?? {};
|
|
60
|
+
const filtered = (header.column.getFilterValue() ?? []).length > 0;
|
|
61
|
+
const cellContent = (0, _reactTable.flexRender)(header.column.columnDef.header, header.getContext());
|
|
62
|
+
const html = _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, cellContent));
|
|
63
|
+
const hasValue = html.trim().length > 0;
|
|
64
|
+
|
|
65
|
+
// const filtered = header.column.getIsFiltered()
|
|
66
|
+
|
|
67
|
+
// const { attributes, isDragging, listeners, setNodeRef, transform } =
|
|
68
|
+
// useSortable({
|
|
69
|
+
// id: header.column.id,
|
|
70
|
+
// })
|
|
71
|
+
|
|
72
|
+
const style = {
|
|
73
|
+
// opacity: isDragging ? 0.8 : 1,
|
|
74
|
+
// position: 'relative',
|
|
75
|
+
// transform: CSS.Translate.toString(transform), // translate instead of transform to avoid squishing
|
|
76
|
+
transition: 'width transform 0.2s ease-in-out',
|
|
77
|
+
whiteSpace: 'nowrap'
|
|
78
|
+
// width: header.column.getSize(),
|
|
79
|
+
// zIndex: isDragging ? 1 : 0,
|
|
80
|
+
};
|
|
81
|
+
const getDropdownTrigger = () => {
|
|
82
|
+
let iconFilter;
|
|
83
|
+
if (typeof filterIcon === 'function') {
|
|
84
|
+
iconFilter = filterIcon(filtered);
|
|
85
|
+
} else if (filterIcon) {
|
|
86
|
+
iconFilter = filterIcon;
|
|
87
|
+
} else {
|
|
88
|
+
iconFilter = /*#__PURE__*/_react.default.createElement(_becoxyIcons.FilterFill, {
|
|
89
|
+
style: {
|
|
90
|
+
color: filtered ? '#E3165B' : '#283046'
|
|
91
|
+
},
|
|
92
|
+
fontSize: 12
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return /*#__PURE__*/_react.default.createElement("span", {
|
|
96
|
+
role: "button",
|
|
97
|
+
tabIndex: -1,
|
|
98
|
+
className: (0, _classnames.default)(`${prefix}-trigger`, {
|
|
99
|
+
active: filtered
|
|
100
|
+
}),
|
|
101
|
+
onClick: e => {
|
|
102
|
+
e.stopPropagation();
|
|
103
|
+
}
|
|
104
|
+
}, iconFilter);
|
|
105
|
+
};
|
|
106
|
+
const triggerVisible = newVisible => {
|
|
107
|
+
setVisible(newVisible);
|
|
108
|
+
};
|
|
109
|
+
const onVisibleChange = (newVisible, info) => {
|
|
110
|
+
if (info.source === 'trigger') {
|
|
111
|
+
if (newVisible) {
|
|
112
|
+
const filterValue = header.column.getFilterValue() ?? [];
|
|
113
|
+
const operatorValue = header.column.getFilterOperator() ?? (0, _utils.getDefaultOperator)(column?.meta ?? {});
|
|
114
|
+
setSelectedKeys(filterValue);
|
|
115
|
+
header.column.setFilterOperator?.(operatorValue);
|
|
116
|
+
} else {}
|
|
117
|
+
triggerVisible(newVisible);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
const doFilter = type => {
|
|
121
|
+
if (type) {
|
|
122
|
+
header.column.setFilterValue(selectedKeys);
|
|
123
|
+
} else {
|
|
124
|
+
header.column.setFilterValue('');
|
|
125
|
+
setSelectedKeys([]);
|
|
126
|
+
}
|
|
127
|
+
setFilterChange(true);
|
|
128
|
+
triggerVisible(false);
|
|
129
|
+
};
|
|
130
|
+
const mergedDropdownProps = (0, _utils.extendsObject)({
|
|
131
|
+
trigger: ['click'],
|
|
132
|
+
placement: 'bottomRight',
|
|
133
|
+
// placement: direction === 'rtl' ? 'bottomLeft' : 'bottomRight',
|
|
134
|
+
children: getDropdownTrigger(),
|
|
135
|
+
getPopupContainer
|
|
136
|
+
}, {
|
|
137
|
+
// ...filterDropdownProps,
|
|
138
|
+
// rootClassName: classNames(rootClassName, filterDropdownProps.rootClassName),
|
|
139
|
+
open: visible,
|
|
140
|
+
onOpenChange: onVisibleChange,
|
|
141
|
+
destroyPopupOnHide: true,
|
|
142
|
+
dropdownRender: () => {
|
|
143
|
+
const type = (0, _utils.getTypeFilter)(originalColumn);
|
|
144
|
+
const operatorValue = header.column.getFilterOperator() ?? (0, _utils.getDefaultOperator)(originalColumn);
|
|
145
|
+
const operatorOptions = ['Checkbox', 'Dropdown', 'DropTree', 'CheckboxDropdown'].includes(type) ? _constant.booleanOperator : !type || type === 'Text' ? _constant.stringOperator : _constant.numberOperator;
|
|
146
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
147
|
+
// className='ui-rc-table-filter-dropdown'
|
|
148
|
+
|
|
149
|
+
className: (0, _classnames.default)(`${prefix}-grid-filter-dropdown`, {}),
|
|
150
|
+
style: {}
|
|
151
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
152
|
+
style: {
|
|
153
|
+
minWidth: 275,
|
|
154
|
+
padding: '8px'
|
|
155
|
+
}
|
|
156
|
+
}, /*#__PURE__*/_react.default.createElement("div", null), column.meta?.showOperator !== false && column.meta?.typeFilter !== 'DateRange' && column.meta?.typeFilter !== 'NumberRange' && /*#__PURE__*/_react.default.createElement("div", {
|
|
157
|
+
className: 'mb-1'
|
|
158
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
|
|
159
|
+
options: (0, _constant.translateOption)(operatorOptions, t),
|
|
160
|
+
style: {
|
|
161
|
+
width: '100%',
|
|
162
|
+
marginBottom: 8
|
|
163
|
+
},
|
|
164
|
+
value: operatorValue,
|
|
165
|
+
onChange: val => {
|
|
166
|
+
header.column.setFilterOperator(val);
|
|
167
|
+
}
|
|
168
|
+
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
169
|
+
style: {
|
|
170
|
+
marginBottom: 8
|
|
171
|
+
}
|
|
172
|
+
}, (0, _renderFilter.renderFilter)({
|
|
173
|
+
column: column,
|
|
174
|
+
selectedKeys,
|
|
175
|
+
setSelectedKeys
|
|
176
|
+
// selectedKeys: (header.column.getFilterValue() ?? []) as string[],
|
|
177
|
+
// setSelectedKeys: header.column.setFilterValue,
|
|
178
|
+
})), /*#__PURE__*/_react.default.createElement(_antd.Space, {
|
|
179
|
+
style: {
|
|
180
|
+
justifyContent: 'end',
|
|
181
|
+
width: '100%'
|
|
182
|
+
}
|
|
183
|
+
}, /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
184
|
+
type: "primary",
|
|
185
|
+
onClick: () => {
|
|
186
|
+
// header.column.setFilterValue(selectedKeys)
|
|
187
|
+
|
|
188
|
+
doFilter(true);
|
|
189
|
+
},
|
|
190
|
+
size: "small",
|
|
191
|
+
style: {
|
|
192
|
+
width: 90
|
|
193
|
+
}
|
|
194
|
+
}, t ? t('Filter') : 'Filter'), /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
195
|
+
type: "link",
|
|
196
|
+
size: "small",
|
|
197
|
+
onClick: () => {
|
|
198
|
+
// header.column.setFilterValue([])
|
|
199
|
+
// header.column.setFilterOperator('')
|
|
200
|
+
|
|
201
|
+
setSelectedKeys([]);
|
|
202
|
+
doFilter(false);
|
|
203
|
+
}
|
|
204
|
+
}, t ? t('Clear') : 'Clear'))));
|
|
205
|
+
|
|
206
|
+
// if (typeof filterDropdownProps?.dropdownRender === 'function') {
|
|
207
|
+
// return filterDropdownProps.dropdownRender(dropdownContent);
|
|
208
|
+
// }
|
|
209
|
+
// return dropdownContent;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
// if (header.column.id === "#" || header.column.id === "selection_column") {
|
|
214
|
+
// return (
|
|
215
|
+
// <th
|
|
216
|
+
// ref={el => {
|
|
217
|
+
// if (el) columnVirtualizer.measureElement(el)
|
|
218
|
+
// }}
|
|
219
|
+
// data-index={header.id}
|
|
220
|
+
// // ref={setNodeRef}
|
|
221
|
+
// key={header.id}
|
|
222
|
+
// colSpan={header.colSpan}
|
|
223
|
+
// style={{
|
|
224
|
+
// display: 'flex',
|
|
225
|
+
// ...getCommonPinningStyles(header.column),
|
|
226
|
+
// ...style,
|
|
227
|
+
// width: header?.getSize() ?? header.column.getSize()
|
|
228
|
+
// }}
|
|
229
|
+
// >
|
|
230
|
+
|
|
231
|
+
// {header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
|
|
232
|
+
// {/* <div> */}
|
|
233
|
+
|
|
234
|
+
// <div
|
|
235
|
+
// {...{
|
|
236
|
+
// onDoubleClick: () => header.column.resetSize(),
|
|
237
|
+
|
|
238
|
+
// onMouseDown: header.getResizeHandler(),
|
|
239
|
+
// onTouchStart: header.getResizeHandler(),
|
|
240
|
+
|
|
241
|
+
// className: `resizer ${header.column.getIsResizing() ? "isResizing" : ""
|
|
242
|
+
// }`,
|
|
243
|
+
// }}
|
|
244
|
+
// />
|
|
245
|
+
|
|
246
|
+
// {/* </div> */}
|
|
247
|
+
// </th>
|
|
248
|
+
// )
|
|
249
|
+
// }
|
|
250
|
+
|
|
251
|
+
return /*#__PURE__*/_react.default.createElement("th", {
|
|
252
|
+
// ref={setNodeRef}
|
|
253
|
+
className: (0, _classnames.default)(`${prefix}-grid-cell`, {
|
|
254
|
+
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
255
|
+
[`${prefix}-grid-cell-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header'),
|
|
256
|
+
[`${prefix}-grid-cell-fix-left-last`]: isLastLeftPinnedColumn,
|
|
257
|
+
[`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn
|
|
258
|
+
}),
|
|
259
|
+
key: header.id,
|
|
260
|
+
style: {
|
|
261
|
+
display: 'flex',
|
|
262
|
+
width: header.getSize(),
|
|
263
|
+
...(0, _utils.getCommonPinningStyles)(header.column),
|
|
264
|
+
...style
|
|
265
|
+
},
|
|
266
|
+
"data-tooltip-id": `${id}-tooltip-content`,
|
|
267
|
+
"data-tooltip-html": !hasValue ? '' : _server.default.renderToStaticMarkup( /*#__PURE__*/_react.default.createElement("div", null, cellContent))
|
|
268
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
269
|
+
className: (0, _classnames.default)('', {
|
|
270
|
+
[`${prefix}-grid-filter-column`]: header.column.id !== 'selection_column',
|
|
271
|
+
[`${prefix}-grid-selection-column`]: header.column.id === 'selection_column'
|
|
272
|
+
})
|
|
273
|
+
}, header.column.id === 'selection_column' && selectionSettings && selectionSettings.hideSelectAll !== false && selectionSettings.type !== 'single' && selectionSettings.mode !== 'radio' && /*#__PURE__*/_react.default.createElement(_rcMasterUi.Checkbox, {
|
|
274
|
+
checked: table.getIsAllRowsSelected(),
|
|
275
|
+
indeterminate: table.getIsSomeRowsSelected(),
|
|
276
|
+
onChange: e => {
|
|
277
|
+
setIsSelectionChange({
|
|
278
|
+
isChange: true,
|
|
279
|
+
type: 'all',
|
|
280
|
+
rowData: {}
|
|
281
|
+
});
|
|
282
|
+
table.getToggleAllRowsSelectedHandler()(e);
|
|
283
|
+
}
|
|
284
|
+
}), header.column.id !== 'selection_column' && /*#__PURE__*/_react.default.createElement("span", {
|
|
285
|
+
className: "ui-rc-table-column-title",
|
|
286
|
+
style: {
|
|
287
|
+
flex: 1
|
|
288
|
+
}
|
|
289
|
+
}, /*#__PURE__*/_react.default.createElement("div", {
|
|
290
|
+
className: (0, _classnames.default)('', {
|
|
291
|
+
[`${prefix}-grid-cell-ellipsis`]: !wrapSettings || !(wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')),
|
|
292
|
+
[`${prefix}-grid-cell-text-wrap`]: wrapSettings && (wrapSettings.wrapMode === 'Both' || wrapSettings.wrapMode === 'Header')
|
|
293
|
+
})
|
|
294
|
+
}, cellContent)), !_constant.nonActionColumn.includes(header.id) && /*#__PURE__*/_react.default.createElement("span", {
|
|
295
|
+
className: "ui-rc-header-trigger"
|
|
296
|
+
}, header.column.getCanSort() && /*#__PURE__*/_react.default.createElement("div", {
|
|
297
|
+
style: {
|
|
298
|
+
marginInlineEnd: 6,
|
|
299
|
+
cursor: 'pointer'
|
|
300
|
+
},
|
|
301
|
+
onClick: e => {
|
|
302
|
+
setSorterChange(true);
|
|
303
|
+
const toggleSortingHandler = header.column.getToggleSortingHandler();
|
|
304
|
+
if (typeof toggleSortingHandler === 'function') {
|
|
305
|
+
toggleSortingHandler(e);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}, header.column.getIsSorted() ? header.column.getIsSorted() === 'asc' ? /*#__PURE__*/_react.default.createElement(_becoxyIcons.ArrowUp, {
|
|
309
|
+
fontSize: 15,
|
|
310
|
+
color: '#000'
|
|
311
|
+
// data-tooltip-id={`${id}-tooltip-header-trigger`}
|
|
312
|
+
,
|
|
313
|
+
"data-tooltip-id": `${id}-tooltip-content`
|
|
314
|
+
// data-tooltip-content='Nhấp để sắp xếp giảm dần'
|
|
315
|
+
,
|
|
316
|
+
"data-tooltip-content": locale?.triggerDesc ?? 'Click to sort descending'
|
|
317
|
+
}) : /*#__PURE__*/_react.default.createElement(_becoxyIcons.ArrowDown, {
|
|
318
|
+
fontSize: 15,
|
|
319
|
+
color: '#000',
|
|
320
|
+
"data-tooltip-id": `${id}-tooltip-content`
|
|
321
|
+
// data-tooltip-id={`${id}-tooltip-header-trigger`}
|
|
322
|
+
// data-tooltip-content='Nhấp để hủy sắp xếp'
|
|
323
|
+
,
|
|
324
|
+
"data-tooltip-content": locale?.cancelSort ?? 'Click to cancel sorting'
|
|
325
|
+
}) : /*#__PURE__*/_react.default.createElement(_becoxyIcons.SortCancel
|
|
326
|
+
// data-tooltip-id={`${id}-tooltip-header-trigger`}
|
|
327
|
+
, {
|
|
328
|
+
"data-tooltip-id": `${id}-tooltip-content`
|
|
329
|
+
// data-tooltip-content='Nhấp để sắp xếp tăng dần'
|
|
330
|
+
,
|
|
331
|
+
"data-tooltip-content": locale?.triggerAsc ?? 'Click to sort ascending',
|
|
332
|
+
fontSize: 15,
|
|
333
|
+
style: {
|
|
334
|
+
display: 'flex'
|
|
335
|
+
},
|
|
336
|
+
className: (0, _classnames.default)(`ui-rc-table-column-sorter-cancel`, {
|
|
337
|
+
active: true
|
|
338
|
+
})
|
|
339
|
+
})), header.column.getCanFilter() && /*#__PURE__*/_react.default.createElement("span", null, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Dropdown, mergedDropdownProps)))), header.column.getCanResize() && /*#__PURE__*/_react.default.createElement("div", {
|
|
340
|
+
onDoubleClick: () => header.column.resetSize(),
|
|
341
|
+
onMouseDown: header.getResizeHandler(),
|
|
342
|
+
onTouchStart: header.getResizeHandler(),
|
|
343
|
+
onMouseUp: () => {
|
|
344
|
+
requestAnimationFrame(() => {
|
|
345
|
+
columnVirtualizer.measure();
|
|
346
|
+
rowHeaderVirtualizer.measure();
|
|
347
|
+
});
|
|
348
|
+
},
|
|
349
|
+
className: `resizer ${header.column.getIsResizing() ? 'isResizing' : ''}`
|
|
350
|
+
}));
|
|
351
|
+
};
|
|
352
|
+
var _default = exports.default = TableHeadCell;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Column, HeaderGroup, Table } from '@tanstack/react-table';
|
|
2
|
+
import type { VirtualItem, Virtualizer } from '@tanstack/react-virtual';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
interface TableHeadRowProps<T> {
|
|
5
|
+
columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
|
|
6
|
+
rowHeaderVirtualizer: Virtualizer<HTMLDivElement, HTMLTableRowElement>;
|
|
7
|
+
headerGroup: HeaderGroup<T>;
|
|
8
|
+
virtualPaddingLeft: number | undefined;
|
|
9
|
+
virtualPaddingRight: number | undefined;
|
|
10
|
+
table: Table<T>;
|
|
11
|
+
fixedLeftColumns: Column<T, unknown>[];
|
|
12
|
+
fixedRightColumns: Column<T, unknown>[];
|
|
13
|
+
rowHeaderVirtual: VirtualItem;
|
|
14
|
+
}
|
|
15
|
+
declare const TableHeadRow: ({ table, columnVirtualizer, rowHeaderVirtualizer, headerGroup, fixedLeftColumns, fixedRightColumns, rowHeaderVirtual }: TableHeadRowProps<any>) => React.JSX.Element;
|
|
16
|
+
export default TableHeadRow;
|
|
@@ -0,0 +1,84 @@
|
|
|
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 _sortable = require("@dnd-kit/sortable");
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _useContext = require("../useContext");
|
|
11
|
+
var _TableHeadCell = _interopRequireDefault(require("./TableHeadCell"));
|
|
12
|
+
// import type { Person } from "../../tanstack-table/makeData"
|
|
13
|
+
|
|
14
|
+
const TableHeadRow = ({
|
|
15
|
+
table,
|
|
16
|
+
columnVirtualizer,
|
|
17
|
+
rowHeaderVirtualizer,
|
|
18
|
+
headerGroup,
|
|
19
|
+
// virtualPaddingLeft,
|
|
20
|
+
// virtualPaddingRight,
|
|
21
|
+
fixedLeftColumns,
|
|
22
|
+
fixedRightColumns,
|
|
23
|
+
rowHeaderVirtual
|
|
24
|
+
}) => {
|
|
25
|
+
const {
|
|
26
|
+
prefix
|
|
27
|
+
} = _react.default.useContext(_useContext.TableContext);
|
|
28
|
+
|
|
29
|
+
// const virtualColumns = columnVirtualizer.getVirtualItems()
|
|
30
|
+
const virtualColumns = columnVirtualizer.measurementsCache;
|
|
31
|
+
|
|
32
|
+
// console.log('virtualColumns', virtualColumns)
|
|
33
|
+
|
|
34
|
+
const columnOrder = table.getState().columnOrder;
|
|
35
|
+
return /*#__PURE__*/_react.default.createElement("tr", {
|
|
36
|
+
key: headerGroup.id,
|
|
37
|
+
ref: el => {
|
|
38
|
+
if (el) rowHeaderVirtualizer.measureElement(el);
|
|
39
|
+
}
|
|
40
|
+
// data-index={rowHeaderVirtual?.index}
|
|
41
|
+
,
|
|
42
|
+
"data-index": headerGroup.id,
|
|
43
|
+
className: `${prefix}-grid-row`,
|
|
44
|
+
style: {
|
|
45
|
+
display: 'flex',
|
|
46
|
+
width: '100%',
|
|
47
|
+
minHeight: rowHeaderVirtual?.size
|
|
48
|
+
}
|
|
49
|
+
}, /*#__PURE__*/_react.default.createElement(_sortable.SortableContext, {
|
|
50
|
+
items: columnOrder,
|
|
51
|
+
strategy: _sortable.horizontalListSortingStrategy
|
|
52
|
+
}, fixedLeftColumns.length > 0 ? fixedLeftColumns.map(column => {
|
|
53
|
+
return /*#__PURE__*/_react.default.createElement(_TableHeadCell.default, {
|
|
54
|
+
columnVirtualizer: columnVirtualizer,
|
|
55
|
+
rowHeaderVirtualizer: rowHeaderVirtualizer,
|
|
56
|
+
key: column.id,
|
|
57
|
+
table: table,
|
|
58
|
+
header: headerGroup.headers.find(h => h.column.id === column.id)
|
|
59
|
+
// column={column as any}
|
|
60
|
+
});
|
|
61
|
+
}) : null, virtualColumns.map(virtualColumn => {
|
|
62
|
+
const header = headerGroup.headers[virtualColumn.index];
|
|
63
|
+
const isFixed = table.getState().columnPinning.left?.includes(header?.column?.id) || table.getState().columnPinning.right?.includes(header?.column?.id);
|
|
64
|
+
if (header && !isFixed) {
|
|
65
|
+
return /*#__PURE__*/_react.default.createElement(_TableHeadCell.default, {
|
|
66
|
+
key: header.id,
|
|
67
|
+
header: header,
|
|
68
|
+
table: table,
|
|
69
|
+
columnVirtualizer: columnVirtualizer,
|
|
70
|
+
rowHeaderVirtualizer: rowHeaderVirtualizer
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}),
|
|
74
|
+
//fake empty column to the right for virtualization scroll padding
|
|
75
|
+
fixedRightColumns.length > 0 ? fixedRightColumns.map(column => /*#__PURE__*/_react.default.createElement(_TableHeadCell.default, {
|
|
76
|
+
columnVirtualizer: columnVirtualizer,
|
|
77
|
+
rowHeaderVirtualizer: rowHeaderVirtualizer,
|
|
78
|
+
table: table,
|
|
79
|
+
key: column.id,
|
|
80
|
+
header: headerGroup.headers.find(h => h.column.id === column.id)
|
|
81
|
+
// column={column as any}
|
|
82
|
+
})) : null));
|
|
83
|
+
};
|
|
84
|
+
var _default = exports.default = TableHeadRow;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ColumnDef } from "@tanstack/react-table";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import type { IFormat } from "../type";
|
|
4
|
+
type RenderFilterProps<RecordType> = {
|
|
5
|
+
column: ColumnDef<RecordType, unknown>;
|
|
6
|
+
selectedKeys: any[];
|
|
7
|
+
setSelectedKeys: (keys: any[]) => void;
|
|
8
|
+
confirm?: () => void;
|
|
9
|
+
t?: any;
|
|
10
|
+
locale?: any;
|
|
11
|
+
dataSourceFilter?: {
|
|
12
|
+
key: string;
|
|
13
|
+
data: any[];
|
|
14
|
+
}[];
|
|
15
|
+
format?: IFormat;
|
|
16
|
+
buddhistLocale?: any;
|
|
17
|
+
dateRangeLocale?: any;
|
|
18
|
+
};
|
|
19
|
+
export declare const renderFilter: <RecordType>(args: RenderFilterProps<RecordType>) => React.JSX.Element;
|
|
20
|
+
export {};
|