es-grid-template 1.1.8 → 1.2.1
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 +679 -0
- package/assets/index.scss +1006 -0
- package/es/grid-component/ColumnsChoose.d.ts +1 -0
- package/es/grid-component/ColumnsChoose.js +64 -29
- 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.js +148 -244
- package/es/grid-component/TableGrid.d.ts +7 -2
- package/es/grid-component/TableGrid.js +33 -55
- 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 +80 -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 +272 -0
- package/es/grid-component/hooks/utils.d.ts +50 -1
- package/es/grid-component/hooks/utils.js +782 -2
- package/es/grid-component/index.js +3 -1
- package/es/grid-component/styles.scss +354 -63
- package/es/grid-component/table/Grid.d.ts +5 -0
- package/es/grid-component/table/Grid.js +1 -7
- package/es/grid-component/table/GridEdit.d.ts +4 -1
- package/es/grid-component/table/GridEdit.js +768 -264
- 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 +43 -2
- package/lib/grid-component/ColumnsChoose.d.ts +1 -0
- package/lib/grid-component/ColumnsChoose.js +63 -28
- 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.js +142 -244
- package/lib/grid-component/TableGrid.d.ts +7 -2
- package/lib/grid-component/TableGrid.js +27 -53
- 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 +87 -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 +283 -0
- package/lib/grid-component/hooks/utils.d.ts +50 -1
- package/lib/grid-component/hooks/utils.js +809 -5
- package/lib/grid-component/index.js +2 -1
- package/lib/grid-component/styles.scss +354 -63
- package/lib/grid-component/table/Grid.d.ts +5 -0
- package/lib/grid-component/table/Grid.js +1 -7
- package/lib/grid-component/table/GridEdit.d.ts +4 -1
- package/lib/grid-component/table/GridEdit.js +764 -261
- 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 +43 -2
- package/package.json +106 -105
|
@@ -6,28 +6,26 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _react =
|
|
10
|
-
var _rcMasterUi = require("rc-master-ui");
|
|
11
|
-
var _antd = require("antd");
|
|
12
|
-
var _icons = require("@ant-design/icons");
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
10
|
var _reactResizable = require("react-resizable");
|
|
14
11
|
var _customParseFormat = _interopRequireDefault(require("dayjs/plugin/customParseFormat"));
|
|
15
12
|
var _hooks = require("./hooks");
|
|
16
|
-
var _becoxyIcons = require("becoxy-icons");
|
|
17
|
-
var _useColumns = require("./hooks/useColumns");
|
|
18
13
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
19
14
|
require("dayjs/locale/es");
|
|
20
15
|
require("dayjs/locale/vi");
|
|
16
|
+
var _GridEdit = _interopRequireDefault(require("./table/GridEdit"));
|
|
17
|
+
var _Grid = _interopRequireDefault(require("./table/Grid"));
|
|
21
18
|
var _en_US = _interopRequireDefault(require("rc-master-ui/es/date-picker/locale/en_US"));
|
|
22
19
|
var _vi_VN = _interopRequireDefault(require("rc-master-ui/es/date-picker/locale/vi_VN"));
|
|
20
|
+
var _useColumns = _interopRequireDefault(require("./hooks/useColumns"));
|
|
23
21
|
require("./styles.scss");
|
|
24
|
-
var
|
|
25
|
-
var
|
|
26
|
-
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); }
|
|
27
|
-
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; }
|
|
28
|
-
// import useMergedState from "rc-util/lib/hooks/useMergedState";
|
|
29
|
-
|
|
22
|
+
var _columns = require("./hooks/columns");
|
|
23
|
+
var _Group = _interopRequireDefault(require("./table/Group"));
|
|
30
24
|
_dayjs.default.extend(_customParseFormat.default);
|
|
25
|
+
|
|
26
|
+
// const ASCEND = 'ascend';
|
|
27
|
+
// const DESCEND = 'descend';
|
|
28
|
+
|
|
31
29
|
const ResizableTitle = props => {
|
|
32
30
|
const {
|
|
33
31
|
onResize,
|
|
@@ -59,6 +57,7 @@ const ResizableTitle = props => {
|
|
|
59
57
|
const InternalTable = props => {
|
|
60
58
|
const {
|
|
61
59
|
t,
|
|
60
|
+
// columns,
|
|
62
61
|
columns: propsColumns,
|
|
63
62
|
lang,
|
|
64
63
|
locale,
|
|
@@ -67,13 +66,24 @@ const InternalTable = props => {
|
|
|
67
66
|
dataSourceFilter: propDataSourceFilter,
|
|
68
67
|
onFilterClick,
|
|
69
68
|
editAble,
|
|
70
|
-
rowKey,
|
|
69
|
+
rowKey: propRowKey,
|
|
71
70
|
format,
|
|
72
71
|
onDataChange,
|
|
73
72
|
sortMultiple,
|
|
74
|
-
expandable,
|
|
73
|
+
// expandable,
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
onCellPaste,
|
|
76
|
+
clickHeaderToSort = true,
|
|
77
|
+
components,
|
|
78
|
+
onChooseColumns,
|
|
79
|
+
groupAble,
|
|
80
|
+
groupSetting,
|
|
81
|
+
groupColumns,
|
|
75
82
|
...rest
|
|
76
83
|
} = props;
|
|
84
|
+
const rowKey = _react.default.useMemo(() => {
|
|
85
|
+
return editAble ? 'rowId' : propRowKey ?? 'id';
|
|
86
|
+
}, [editAble, propRowKey]);
|
|
77
87
|
const local = lang && lang === 'en' ? _en_US.default : _vi_VN.default;
|
|
78
88
|
const buddhistLocale = {
|
|
79
89
|
...local,
|
|
@@ -81,157 +91,28 @@ const InternalTable = props => {
|
|
|
81
91
|
...local.lang
|
|
82
92
|
}
|
|
83
93
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const tableRef = (0, _react.useRef)(null);
|
|
93
|
-
const [data, setData] = (0, _react.useState)([]);
|
|
94
|
-
const [columns, setColumns] = (0, _react.useState)([]);
|
|
95
|
-
const [isManualUpdate, setIsManualUpdate] = (0, _react.useState)(false);
|
|
96
|
-
// const [expandKeys, setExpandKeys] = useState<string[]>([]);
|
|
97
|
-
const [dataSourceFilter, setDataSourceFilter] = (0, _react.useState)(propDataSourceFilter ?? []);
|
|
98
|
-
(0, _react.useEffect)(() => {
|
|
99
|
-
const rs = propsColumns ? [_rcMasterUi.Table.SELECTION_COLUMN, ...propsColumns] : [];
|
|
100
|
-
// const rs = propsColumns ? [...propsColumns] : []
|
|
101
|
-
setColumns(rs);
|
|
94
|
+
const mergerdData = _react.default.useMemo(() => {
|
|
95
|
+
return (0, _hooks.addRowIdArray)(dataSource);
|
|
96
|
+
}, [dataSource]);
|
|
97
|
+
const [columns, setColumns] = _react.default.useState([]);
|
|
98
|
+
const tableRef = _react.default.useRef(null);
|
|
99
|
+
_react.default.useEffect(() => {
|
|
100
|
+
setColumns(propsColumns);
|
|
102
101
|
}, [propsColumns]);
|
|
103
|
-
(0, _react.useEffect)(() => {
|
|
104
|
-
if (!isManualUpdate) {
|
|
105
|
-
setData(dataSource || []);
|
|
106
|
-
}
|
|
107
|
-
setIsManualUpdate(false);
|
|
108
|
-
}, [dataSource, isManualUpdate]);
|
|
109
102
|
|
|
110
|
-
// const [
|
|
111
|
-
// propsColumns ? [Table.SELECTION_COLUMN, ...propsColumns] : [],
|
|
112
|
-
// {
|
|
113
|
-
// value: propsColumns ? [Table.SELECTION_COLUMN, ...propsColumns] : [],
|
|
114
|
-
// },
|
|
115
|
-
// );
|
|
103
|
+
// const [data, setData] = useState<RecordType[]>([]);
|
|
116
104
|
|
|
117
|
-
//
|
|
118
|
-
const getRowKey = _react.default.useMemo(() => {
|
|
119
|
-
if (typeof rowKey === 'function') {
|
|
120
|
-
return rowKey;
|
|
121
|
-
}
|
|
122
|
-
// @ts-ignore
|
|
123
|
-
return record => record?.[rowKey];
|
|
124
|
-
}, [rowKey]);
|
|
105
|
+
// const [isManualUpdate, setIsManualUpdate] = useState(false);
|
|
125
106
|
|
|
126
107
|
// useEffect(() => {
|
|
127
|
-
//
|
|
128
|
-
//
|
|
129
|
-
//
|
|
108
|
+
// if (!isManualUpdate) {
|
|
109
|
+
// const mergedData = addRowIdArray(dataSource)
|
|
110
|
+
//
|
|
111
|
+
// setData(mergedData || []);
|
|
112
|
+
// }
|
|
113
|
+
// setIsManualUpdate(false);
|
|
114
|
+
// }, [dataSource, isManualUpdate])
|
|
130
115
|
|
|
131
|
-
const handleSearch = (selectedKeys, confirm) => {
|
|
132
|
-
confirm();
|
|
133
|
-
};
|
|
134
|
-
const onFilterCallback = (key, filterDataCallback) => {
|
|
135
|
-
const find = dataSourceFilter.find(it => it.key === key);
|
|
136
|
-
if (find) {
|
|
137
|
-
const newData = (0, _hooks.updateArrayByKey)(dataSourceFilter, {
|
|
138
|
-
key,
|
|
139
|
-
data: filterDataCallback
|
|
140
|
-
}, 'key');
|
|
141
|
-
setDataSourceFilter(newData);
|
|
142
|
-
} else {
|
|
143
|
-
const newData = [...dataSourceFilter, {
|
|
144
|
-
key,
|
|
145
|
-
data: filterDataCallback
|
|
146
|
-
}];
|
|
147
|
-
setDataSourceFilter(newData);
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
const getColumnSearchProps = (0, _react.useCallback)(column => ({
|
|
151
|
-
filterDropdown: ({
|
|
152
|
-
setSelectedKeys,
|
|
153
|
-
selectedKeys,
|
|
154
|
-
confirm,
|
|
155
|
-
// close,
|
|
156
|
-
setOperatorKey,
|
|
157
|
-
operatorKey,
|
|
158
|
-
visible,
|
|
159
|
-
searchValue,
|
|
160
|
-
setSearchValue
|
|
161
|
-
}) => {
|
|
162
|
-
const type = (0, _hooks.getTypeFilter)(column);
|
|
163
|
-
// const operatorOptions = !type || type === 'Text' ? stringOperator : numberOperator
|
|
164
|
-
// const operatorOptions = type === 'Checkbox' || type === 'Dropdown' || type === 'DropTree' || ty
|
|
165
|
-
const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? _hooks.booleanOperator : !type || type === 'Text' ? _hooks.stringOperator : _hooks.numberOperator;
|
|
166
|
-
return /*#__PURE__*/_react.default.createElement("div", {
|
|
167
|
-
style: {
|
|
168
|
-
padding: 8,
|
|
169
|
-
minWidth: 275
|
|
170
|
-
},
|
|
171
|
-
onKeyDown: e => e.stopPropagation()
|
|
172
|
-
}, column?.showOperator !== false && column?.typeFilter !== 'DateRange' && column?.typeFilter !== 'NumberRange' && /*#__PURE__*/_react.default.createElement("div", {
|
|
173
|
-
className: 'mb-1'
|
|
174
|
-
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
|
|
175
|
-
options: (0, _hooks.translateOption)(operatorOptions, t),
|
|
176
|
-
style: {
|
|
177
|
-
width: '100%',
|
|
178
|
-
marginBottom: 8
|
|
179
|
-
},
|
|
180
|
-
value: operatorKey,
|
|
181
|
-
onChange: val => {
|
|
182
|
-
setOperatorKey(val);
|
|
183
|
-
}
|
|
184
|
-
})), /*#__PURE__*/_react.default.createElement("div", {
|
|
185
|
-
style: {
|
|
186
|
-
marginBottom: 8
|
|
187
|
-
}
|
|
188
|
-
}, (0, _useColumns.renderFilter)(column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t)), /*#__PURE__*/_react.default.createElement(_antd.Space, {
|
|
189
|
-
style: {
|
|
190
|
-
justifyContent: 'end',
|
|
191
|
-
width: '100%'
|
|
192
|
-
}
|
|
193
|
-
}, /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
194
|
-
type: "primary",
|
|
195
|
-
onClick: () => {
|
|
196
|
-
confirm({
|
|
197
|
-
closeDropdown: false
|
|
198
|
-
});
|
|
199
|
-
handleSearch(selectedKeys, confirm);
|
|
200
|
-
},
|
|
201
|
-
icon: /*#__PURE__*/_react.default.createElement(_icons.SearchOutlined, null),
|
|
202
|
-
size: "small",
|
|
203
|
-
style: {
|
|
204
|
-
width: 90
|
|
205
|
-
}
|
|
206
|
-
}, t ? t('Filter') : 'Filter'), /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
207
|
-
type: "link",
|
|
208
|
-
size: "small",
|
|
209
|
-
onClick: () => {
|
|
210
|
-
// setSearchValue('')
|
|
211
|
-
setSelectedKeys([]);
|
|
212
|
-
confirm();
|
|
213
|
-
// handleSearch()
|
|
214
|
-
// close()
|
|
215
|
-
}
|
|
216
|
-
}, t ? t("Clear") : 'Clear')));
|
|
217
|
-
},
|
|
218
|
-
filterIcon: filtered => /*#__PURE__*/_react.default.createElement(_becoxyIcons.FilterFill, {
|
|
219
|
-
fontSize: 12,
|
|
220
|
-
onClick: () => {
|
|
221
|
-
onFilterClick?.(column, onFilterCallback);
|
|
222
|
-
},
|
|
223
|
-
style: {
|
|
224
|
-
color: filtered ? '#283046' : undefined
|
|
225
|
-
}
|
|
226
|
-
}),
|
|
227
|
-
filterDropdownProps: {
|
|
228
|
-
onOpenChange(open) {
|
|
229
|
-
if (open) {
|
|
230
|
-
// setTimeout(() => searchInput.current?.select(), 100)
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}), [buddhistLocale, dataSourceFilter, onFilterCallback, onFilterClick, t]);
|
|
235
116
|
const handleResize = column => (e, {
|
|
236
117
|
size
|
|
237
118
|
}) => {
|
|
@@ -242,119 +123,136 @@ const InternalTable = props => {
|
|
|
242
123
|
const newColumns = (0, _hooks.updateArrayByKey)(columns, newColumn, 'field');
|
|
243
124
|
setColumns(newColumns);
|
|
244
125
|
};
|
|
245
|
-
const
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
126
|
+
const [transformSelectionColumns] = (0, _useColumns.default)({
|
|
127
|
+
locale,
|
|
128
|
+
t,
|
|
129
|
+
buddhistLocale,
|
|
130
|
+
dataSourceFilter: propDataSourceFilter,
|
|
131
|
+
format,
|
|
132
|
+
sortMultiple,
|
|
133
|
+
groupAble,
|
|
134
|
+
groupSetting,
|
|
135
|
+
groupColumns,
|
|
136
|
+
handleResize
|
|
137
|
+
});
|
|
138
|
+
const mergedColumns = _react.default.useMemo(() => {
|
|
139
|
+
return transformSelectionColumns(columns);
|
|
140
|
+
}, [columns, transformSelectionColumns]);
|
|
258
141
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
onCell: () => ({
|
|
264
|
-
className: 'cell-number'
|
|
265
|
-
}),
|
|
266
|
-
render: (_, __, rowIndex) => rowIndex + 1
|
|
267
|
-
};
|
|
268
|
-
}
|
|
269
|
-
if (column.field === 'command') {
|
|
270
|
-
return {
|
|
271
|
-
...transformedColumn,
|
|
272
|
-
onCell: () => ({
|
|
273
|
-
className: column.field === 'command' ? "ui-rc-cell-command" : ''
|
|
274
|
-
}),
|
|
275
|
-
onHeaderCell: () => ({
|
|
276
|
-
width: column.width,
|
|
277
|
-
onResize: handleResize(column)
|
|
278
|
-
})
|
|
279
|
-
};
|
|
142
|
+
// ============================ RowKey ============================
|
|
143
|
+
const getRowKey = _react.default.useMemo(() => {
|
|
144
|
+
if (typeof rowKey === 'function') {
|
|
145
|
+
return rowKey;
|
|
280
146
|
}
|
|
281
|
-
return {
|
|
282
|
-
...(column.allowFiltering === false ? {} : {
|
|
283
|
-
...getColumnSearchProps(column)
|
|
284
|
-
}),
|
|
285
|
-
...transformedColumn,
|
|
286
|
-
onFilter: value => {
|
|
287
|
-
return value;
|
|
288
|
-
},
|
|
289
|
-
sorter: column.sorter === false ? undefined : {
|
|
290
|
-
compare: a => a,
|
|
291
|
-
multiple: sortMultiple ? colIndex : undefined
|
|
292
|
-
},
|
|
293
|
-
onHeaderCell: () => ({
|
|
294
|
-
width: column.width,
|
|
295
|
-
onResize: handleResize(column)
|
|
296
|
-
}),
|
|
297
|
-
render: (value, record, rowIndex) => (0, _useColumns.renderContent)(column, value, record, rowIndex, format)
|
|
298
|
-
};
|
|
299
|
-
});
|
|
300
|
-
const transformColumns = _react.default.useCallback(cols => {
|
|
301
147
|
// @ts-ignore
|
|
302
|
-
return
|
|
303
|
-
|
|
304
|
-
if (!column?.field && !column?.key) {
|
|
305
|
-
return column;
|
|
306
|
-
}
|
|
307
|
-
if (find) {
|
|
308
|
-
return {
|
|
309
|
-
...find
|
|
310
|
-
};
|
|
311
|
-
}
|
|
148
|
+
return record => record?.[rowKey];
|
|
149
|
+
}, [rowKey]);
|
|
312
150
|
|
|
313
|
-
|
|
314
|
-
if (column.children?.length) {
|
|
315
|
-
return {
|
|
316
|
-
...column,
|
|
317
|
-
children: transformColumns(column.children)
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}, [convertColumns]);
|
|
322
|
-
const mergedColumns = _react.default.useMemo(() => {
|
|
323
|
-
return transformColumns(columns);
|
|
324
|
-
}, [transformColumns, columns]);
|
|
151
|
+
// const triggerChangeColumns = (newColumns: ColumnsTable<RecordType>) => {
|
|
325
152
|
const triggerChangeColumns = newColumns => {
|
|
326
153
|
setColumns(newColumns);
|
|
154
|
+
onChooseColumns?.({
|
|
155
|
+
showColumns: [],
|
|
156
|
+
columns: [],
|
|
157
|
+
flattenColumns: []
|
|
158
|
+
});
|
|
159
|
+
};
|
|
160
|
+
const triggerGroupColumns = groupedColumns => {
|
|
161
|
+
setColumns((0, _hooks.updateColumnsByGroup)(mergedColumns, groupedColumns));
|
|
162
|
+
if (groupSetting) {
|
|
163
|
+
if (groupSetting.client === false) {
|
|
164
|
+
|
|
165
|
+
// setIsTree(true)
|
|
166
|
+
|
|
167
|
+
// setGroupOpen([])
|
|
168
|
+
|
|
169
|
+
// const dt = ungroupArray(dataSource)
|
|
170
|
+
|
|
171
|
+
// const rs = groupArrayByColumns2(dt, [...value])
|
|
172
|
+
|
|
173
|
+
// setResource([...rs])
|
|
174
|
+
|
|
175
|
+
// if (groupSetting.onGroup) {
|
|
176
|
+
// groupSetting.onGroup({
|
|
177
|
+
// columnGrouped: value,
|
|
178
|
+
// columns: removeColumns(columns as any, value),
|
|
179
|
+
// flattenColumns: convertFlatColumn(removeColumns(columns as any, value)) as any
|
|
180
|
+
//
|
|
181
|
+
// })
|
|
182
|
+
// }
|
|
183
|
+
} else {
|
|
184
|
+
if (groupSetting.onGroup) {
|
|
185
|
+
groupSetting.onGroup({
|
|
186
|
+
columnGrouped: groupedColumns,
|
|
187
|
+
columns: (0, _hooks.removeColumns)(columns, groupedColumns),
|
|
188
|
+
flattenColumns: (0, _columns.flatColumns2)((0, _hooks.removeColumns)(columns, groupedColumns))
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
327
193
|
};
|
|
328
194
|
const triggerChangeData = newData => {
|
|
329
|
-
setIsManualUpdate(true)
|
|
330
|
-
setData(newData)
|
|
195
|
+
// setIsManualUpdate(true)
|
|
196
|
+
// setData(newData)
|
|
331
197
|
// setMergedData(newData)
|
|
332
198
|
onDataChange?.(newData);
|
|
333
199
|
};
|
|
334
|
-
const
|
|
200
|
+
const triggerPaste = (pastedRows, pastedColumnsArray, newData) => {
|
|
201
|
+
const handlePasteCallback = callbackData => {
|
|
202
|
+
const newDataUpdate = (0, _hooks.updateData)(dataSource, callbackData, rowKey);
|
|
203
|
+
triggerChangeData(newDataUpdate);
|
|
204
|
+
onCellPaste?.dataChange?.(newDataUpdate);
|
|
205
|
+
};
|
|
206
|
+
if (onCellPaste && onCellPaste.onPasted) {
|
|
207
|
+
if (onCellPaste.onPasted.length > 1) {
|
|
208
|
+
onCellPaste.onPasted({
|
|
209
|
+
pasteData: pastedRows,
|
|
210
|
+
type: 'onPaste',
|
|
211
|
+
data: dataSource,
|
|
212
|
+
pastedColumns: pastedColumnsArray
|
|
213
|
+
}, handlePasteCallback);
|
|
214
|
+
} else {
|
|
215
|
+
onCellPaste.onPasted({
|
|
216
|
+
pasteData: pastedRows,
|
|
217
|
+
type: 'onPaste',
|
|
218
|
+
data: dataSource,
|
|
219
|
+
pastedColumns: pastedColumnsArray
|
|
220
|
+
}, handlePasteCallback);
|
|
221
|
+
triggerChangeData(newData);
|
|
222
|
+
onCellPaste.dataChange?.(newData);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
const TableComponent = groupAble ? _Group.default : editAble ? _GridEdit.default : _Grid.default;
|
|
335
227
|
return /*#__PURE__*/_react.default.createElement(TableComponent, (0, _extends2.default)({}, rest, {
|
|
336
228
|
t: t,
|
|
337
229
|
locale: locale,
|
|
338
230
|
tableRef: tableRef,
|
|
339
|
-
dataSource:
|
|
340
|
-
//
|
|
231
|
+
dataSource: mergerdData
|
|
232
|
+
// components={components}
|
|
341
233
|
,
|
|
342
234
|
components: {
|
|
343
235
|
header: {
|
|
344
236
|
cell: allowResizing ? ResizableTitle : undefined
|
|
345
237
|
}
|
|
346
238
|
},
|
|
347
|
-
format: format
|
|
348
|
-
columns
|
|
349
|
-
// defaultColumns={mergedColumns}
|
|
239
|
+
format: format
|
|
240
|
+
// columns={columns}
|
|
350
241
|
,
|
|
242
|
+
columns: mergedColumns,
|
|
351
243
|
showSorterTooltip: {
|
|
352
244
|
target: 'sorter-icon'
|
|
353
245
|
},
|
|
354
246
|
triggerChangeColumns: triggerChangeColumns,
|
|
355
247
|
triggerChangeData: triggerChangeData,
|
|
248
|
+
triggerGroupColumns: triggerGroupColumns,
|
|
356
249
|
rowKey: rowKey,
|
|
357
|
-
getRowKey: getRowKey
|
|
250
|
+
getRowKey: getRowKey,
|
|
251
|
+
triggerPaste: triggerPaste,
|
|
252
|
+
clickHeaderToSort: clickHeaderToSort,
|
|
253
|
+
groupSetting: groupSetting,
|
|
254
|
+
groupAble: groupAble,
|
|
255
|
+
groupColumns: groupColumns
|
|
358
256
|
}));
|
|
359
257
|
};
|
|
360
258
|
var _default = exports.default = InternalTable;
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import 'dayjs/locale/es';
|
|
3
3
|
import 'dayjs/locale/vi';
|
|
4
|
-
import type { ColumnsTable, GridTableProps } from "./type";
|
|
4
|
+
import type { ColumnsTable, GetRowKey, GridTableProps } from "./type";
|
|
5
5
|
type GridProps<T> = GridTableProps<T> & {
|
|
6
6
|
triggerChangeColumns?: (columns: ColumnsTable<T>, type: string) => void;
|
|
7
|
-
triggerChangeData?: () => void;
|
|
7
|
+
triggerChangeData?: (newData: T[], type: string) => void;
|
|
8
|
+
triggerGroupColumns?: (groupedColumns: string[]) => void;
|
|
8
9
|
tableRef: any;
|
|
10
|
+
bottomToolbar?: () => React.ReactElement;
|
|
11
|
+
getRowKey: GetRowKey<T>;
|
|
12
|
+
rowSelection?: any;
|
|
13
|
+
groupToolbar?: () => React.ReactNode;
|
|
9
14
|
};
|
|
10
15
|
declare const TableGrid: <RecordType extends object>(props: GridProps<RecordType>) => React.JSX.Element;
|
|
11
16
|
export default TableGrid;
|
|
@@ -16,7 +16,7 @@ var _ContextMenu = _interopRequireDefault(require("./ContextMenu"));
|
|
|
16
16
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
17
17
|
var _hooks = require("./hooks");
|
|
18
18
|
var _antd = require("antd");
|
|
19
|
-
var
|
|
19
|
+
var _columns = require("./hooks/columns");
|
|
20
20
|
var _pagination = _interopRequireDefault(require("rc-master-ui/es/pagination"));
|
|
21
21
|
var _LoadingSpinner = _interopRequireDefault(require("./LoadingSpinner"));
|
|
22
22
|
var _ColumnsChoose = require("./ColumnsChoose");
|
|
@@ -98,7 +98,6 @@ const TableGrid = props => {
|
|
|
98
98
|
locale,
|
|
99
99
|
expandable,
|
|
100
100
|
rowHoverable,
|
|
101
|
-
// mergedData,
|
|
102
101
|
title,
|
|
103
102
|
format,
|
|
104
103
|
virtual = true,
|
|
@@ -123,9 +122,16 @@ const TableGrid = props => {
|
|
|
123
122
|
dataSourceFilter: propDataSourceFilter,
|
|
124
123
|
loading,
|
|
125
124
|
triggerChangeColumns,
|
|
125
|
+
triggerGroupColumns,
|
|
126
126
|
summary,
|
|
127
127
|
showToolbar,
|
|
128
128
|
onSorter,
|
|
129
|
+
bottomToolbar,
|
|
130
|
+
groupSetting,
|
|
131
|
+
groupAble,
|
|
132
|
+
getRowKey,
|
|
133
|
+
groupColumns,
|
|
134
|
+
groupToolbar,
|
|
129
135
|
...rest
|
|
130
136
|
} = props;
|
|
131
137
|
const {
|
|
@@ -140,16 +146,10 @@ const TableGrid = props => {
|
|
|
140
146
|
selectedRowKeys,
|
|
141
147
|
defaultSelectedRowKeys
|
|
142
148
|
} = selectionSettings || {};
|
|
143
|
-
const clickRef =
|
|
144
|
-
const menuRef =
|
|
149
|
+
const clickRef = _react.default.useRef(null);
|
|
150
|
+
const menuRef = _react.default.useRef(null);
|
|
145
151
|
const viewportWidth = window.innerWidth;
|
|
146
152
|
const viewportHeight = window.innerHeight;
|
|
147
|
-
|
|
148
|
-
// const defaultSelected = useMemo(() => {
|
|
149
|
-
// return defaultSelectedRowKeys ?? []
|
|
150
|
-
//
|
|
151
|
-
// }, [defaultSelectedRowKeys])
|
|
152
|
-
|
|
153
153
|
const [menuVisible, setMenuVisible] = _react.default.useState(false);
|
|
154
154
|
const [selectedRowData, setSelectedRowData] = _react.default.useState(null);
|
|
155
155
|
const [position, setPosition] = _react.default.useState({
|
|
@@ -187,7 +187,7 @@ const TableGrid = props => {
|
|
|
187
187
|
}
|
|
188
188
|
return propContextMenuItems;
|
|
189
189
|
}, [propContextMenuItems, contextMenuHidden, selectedRowData]);
|
|
190
|
-
|
|
190
|
+
_react.default.useLayoutEffect(() => {
|
|
191
191
|
setMenuVisible(false);
|
|
192
192
|
}, []);
|
|
193
193
|
const onContextMenu = data => event => {
|
|
@@ -326,7 +326,7 @@ const TableGrid = props => {
|
|
|
326
326
|
spinning: columns && columns.length === 0 || loading === true,
|
|
327
327
|
indicator: /*#__PURE__*/_react.default.createElement(_LoadingSpinner.default, null)
|
|
328
328
|
},
|
|
329
|
-
dataSource: dataSource
|
|
329
|
+
dataSource: columns && columns.length > 0 && loading !== true ? dataSource : []
|
|
330
330
|
// className={styles.customTable}
|
|
331
331
|
,
|
|
332
332
|
className: (0, _classnames.default)(className, {
|
|
@@ -344,12 +344,11 @@ const TableGrid = props => {
|
|
|
344
344
|
onRow: (data, index) => {
|
|
345
345
|
return {
|
|
346
346
|
onDoubleClick: handleRowDoubleClick(data, index),
|
|
347
|
-
// onClick: handleRowClick,
|
|
348
347
|
onClick: handleRowClick(),
|
|
349
348
|
onContextMenu: onContextMenu(data)
|
|
350
349
|
};
|
|
351
350
|
},
|
|
352
|
-
rowSelection: {
|
|
351
|
+
rowSelection: columns && columns.length === 0 ? undefined : {
|
|
353
352
|
...selectionSettings,
|
|
354
353
|
type: selectionSettings?.mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
|
|
355
354
|
columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
|
|
@@ -375,7 +374,7 @@ const TableGrid = props => {
|
|
|
375
374
|
}
|
|
376
375
|
return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary, {
|
|
377
376
|
fixed: true
|
|
378
|
-
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0,
|
|
377
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0, _columns.flatColumns)([_rcMasterUi.Table.SELECTION_COLUMN, ...columns]).filter(col => col.hidden !== true).map((col, index) => {
|
|
379
378
|
const thousandSeparator = col.format?.thousandSeparator ? col.format?.thousandSeparator : format?.thousandSeparator;
|
|
380
379
|
const decimalSeparator = col.format?.decimalSeparator ? col.format?.decimalSeparator : format?.decimalSeparator;
|
|
381
380
|
const dec = col.format?.decimalScale || col.format?.decimalScale === 0 ? col.format?.decimalScale : format?.decimalScale;
|
|
@@ -399,7 +398,7 @@ const TableGrid = props => {
|
|
|
399
398
|
}, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps));
|
|
400
399
|
})));
|
|
401
400
|
},
|
|
402
|
-
pagination: pagination && pagination.onChange ? false : {
|
|
401
|
+
pagination: !pagination || pagination && pagination.onChange ? false : {
|
|
403
402
|
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
|
|
404
403
|
...pagination
|
|
405
404
|
},
|
|
@@ -414,13 +413,13 @@ const TableGrid = props => {
|
|
|
414
413
|
justifyContent: 'space-between',
|
|
415
414
|
alignItems: 'center'
|
|
416
415
|
}
|
|
417
|
-
}, toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar
|
|
416
|
+
}, groupAble && groupToolbar?.(), toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/_react.default.createElement(_rcMasterUi.Toolbar
|
|
418
417
|
// @ts-ignore
|
|
419
418
|
, {
|
|
420
419
|
style: {
|
|
421
|
-
width: `calc(100% - 650px`
|
|
420
|
+
width: pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' ? `calc(100% - 650px - ${groupAble ? 50 : 0}px` : `calc(100% - 25px - ${groupAble ? 50 : 0}px`
|
|
422
421
|
},
|
|
423
|
-
items: toolbarItems ?? [],
|
|
422
|
+
items: (toolbarItems ?? []).filter(it => it.position !== 'Bottom'),
|
|
424
423
|
mode: 'scroll'
|
|
425
424
|
}), /*#__PURE__*/_react.default.createElement("div", {
|
|
426
425
|
style: {
|
|
@@ -439,48 +438,23 @@ const TableGrid = props => {
|
|
|
439
438
|
}, pagination)), showColumnChoose && /*#__PURE__*/_react.default.createElement(_ColumnsChoose.ColumnsChoose, {
|
|
440
439
|
columns: columns,
|
|
441
440
|
t: t,
|
|
441
|
+
columnsGroup: groupColumns,
|
|
442
442
|
triggerChangeColumns: triggerChangeColumns
|
|
443
443
|
}))));
|
|
444
444
|
},
|
|
445
445
|
expandable: {
|
|
446
|
-
|
|
447
|
-
defaultExpandAllRows: true,
|
|
448
|
-
indentSize: 25,
|
|
449
|
-
...expandable,
|
|
450
|
-
expandIcon: args => {
|
|
451
|
-
const {
|
|
452
|
-
record,
|
|
453
|
-
expanded,
|
|
454
|
-
onExpand
|
|
455
|
-
} = args;
|
|
456
|
-
|
|
457
|
-
// @ts-ignore
|
|
458
|
-
if (record?.children?.length > 0 || record?.isChildren) {
|
|
459
|
-
return expanded ? /*#__PURE__*/_react.default.createElement("button", {
|
|
460
|
-
onClick: e => {
|
|
461
|
-
e.preventDefault();
|
|
462
|
-
e.stopPropagation();
|
|
463
|
-
onExpand(record, e);
|
|
464
|
-
},
|
|
465
|
-
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded'
|
|
466
|
-
}) : /*#__PURE__*/_react.default.createElement("button", {
|
|
467
|
-
onClick: e => {
|
|
468
|
-
e.preventDefault();
|
|
469
|
-
e.stopPropagation();
|
|
470
|
-
onExpand(record, e);
|
|
471
|
-
},
|
|
472
|
-
className: 'ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed'
|
|
473
|
-
});
|
|
474
|
-
}
|
|
475
|
-
}
|
|
446
|
+
...expandable
|
|
476
447
|
}
|
|
477
|
-
})), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/_react.default.createElement(_pagination.default
|
|
448
|
+
})), /*#__PURE__*/_react.default.createElement("div", null), pagination && pagination.onChange && !pagination.position && /*#__PURE__*/_react.default.createElement(_pagination.default
|
|
478
449
|
// style={{padding: '0.75rem 1rem'}}
|
|
479
450
|
, (0, _extends2.default)({
|
|
451
|
+
rootClassName: 'pagination-template',
|
|
480
452
|
showSizeChanger: true,
|
|
481
453
|
responsive: true,
|
|
482
|
-
size: 'small'
|
|
483
|
-
|
|
484
|
-
|
|
454
|
+
size: 'small'
|
|
455
|
+
// @ts-ignore
|
|
456
|
+
,
|
|
457
|
+
showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} ${t ? t(pagination?.locale?.items ?? 'items') : 'items'}`
|
|
458
|
+
}, pagination)), bottomToolbar?.()));
|
|
485
459
|
};
|
|
486
460
|
var _default = exports.default = TableGrid;
|
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import type { TableLocale } from "rc-master-ui/lib/table/interface";
|
|
4
4
|
import type { ColumnsTable } from "../../type";
|
|
5
5
|
export declare function flatColumns<RecordType>(columns: ColumnsTable<RecordType>, parentKey?: string): ColumnsTable<RecordType>;
|
|
6
|
-
export declare function flatColumns2<RecordType>(columns: ColumnsTable<RecordType
|
|
6
|
+
export declare function flatColumns2<RecordType>(columns: ColumnsTable<RecordType>): ColumnsTable<RecordType>;
|
|
7
7
|
export declare const getValueCell: <T>(column: ColumnType<T>, value: any, format?: IFormat) => any;
|
|
8
|
-
export declare const renderContent:
|
|
8
|
+
export declare const renderContent: (column: any, value: any, record: any, index: number, format?: IFormat) => React.JSX.Element;
|
|
9
9
|
export declare const renderFilter: <RecordType>(column: ColumnType<RecordType>, selectedKeys: string[], setSelectedKeys: any, confirm: any, visible: boolean, searchValue: string, setSearchValue: any, dataSourceFilter: any[], buddhistLocale: any, locale?: TableLocale, t?: any) => React.JSX.Element;
|