es-grid-template 1.2.6 → 1.2.8
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/AdvanceFilter.d.ts +11 -7
- package/es/grid-component/AdvanceFilter.js +419 -509
- package/es/grid-component/ColumnsChoose.js +2 -1
- package/es/grid-component/ContextMenu.js +2 -1
- package/es/grid-component/EditableCell.d.ts +2 -2
- package/es/grid-component/EditableCell.js +16 -11
- package/es/grid-component/InternalTable.js +128 -2
- package/es/grid-component/TableGrid.js +11 -2
- package/es/grid-component/checkbox-control/index.d.ts +13 -0
- package/es/grid-component/checkbox-control/index.js +40 -0
- package/es/grid-component/hooks/columns/index.d.ts +2 -2
- package/es/grid-component/hooks/columns/index.js +8 -2
- package/es/grid-component/hooks/useColumns.js +5 -2
- package/es/grid-component/hooks/utils.d.ts +6 -5
- package/es/grid-component/hooks/utils.js +8 -2
- package/es/grid-component/styles.scss +13 -3
- package/es/grid-component/table/GridEdit.js +36 -18
- package/es/grid-component/type.d.ts +26 -13
- package/lib/grid-component/AdvanceFilter.d.ts +11 -7
- package/lib/grid-component/AdvanceFilter.js +415 -506
- package/lib/grid-component/ColumnsChoose.js +2 -1
- package/lib/grid-component/ContextMenu.js +2 -1
- package/lib/grid-component/EditableCell.d.ts +2 -2
- package/lib/grid-component/EditableCell.js +16 -11
- package/lib/grid-component/InternalTable.js +127 -1
- package/lib/grid-component/TableGrid.js +11 -2
- package/lib/grid-component/checkbox-control/index.d.ts +13 -0
- package/lib/grid-component/checkbox-control/index.js +48 -0
- package/lib/grid-component/hooks/columns/index.d.ts +2 -2
- package/lib/grid-component/hooks/columns/index.js +8 -2
- package/lib/grid-component/hooks/useColumns.js +5 -2
- package/lib/grid-component/hooks/utils.d.ts +6 -5
- package/lib/grid-component/hooks/utils.js +11 -4
- package/lib/grid-component/styles.scss +13 -3
- package/lib/grid-component/table/GridEdit.js +36 -18
- package/lib/grid-component/type.d.ts +26 -13
- package/package.json +4 -2
|
@@ -545,7 +545,8 @@ const ColumnsChoose = props => {
|
|
|
545
545
|
trigger: "click",
|
|
546
546
|
open: clicked,
|
|
547
547
|
onOpenChange: handleClickChange,
|
|
548
|
-
arrow: false
|
|
548
|
+
arrow: false,
|
|
549
|
+
zIndex: 1065
|
|
549
550
|
}, /*#__PURE__*/_react.default.createElement(_antd.Tooltip, {
|
|
550
551
|
arrow: false,
|
|
551
552
|
title: 'Cài đặt'
|
|
@@ -104,7 +104,8 @@ const ContextMenu = props => {
|
|
|
104
104
|
items: contextMenuItems,
|
|
105
105
|
style: {
|
|
106
106
|
minWidth: 200,
|
|
107
|
-
maxHeight: pos.viewportHeight - 20
|
|
107
|
+
maxHeight: pos.viewportHeight - 20,
|
|
108
|
+
width: 'fit-content'
|
|
108
109
|
},
|
|
109
110
|
rootClassName: 'popup-context-menu',
|
|
110
111
|
onClick: e => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ColumnTable, IFormat } from "./type";
|
|
3
3
|
import type { EditType } from "rc-master-ui";
|
|
4
4
|
interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement> {
|
|
5
5
|
t?: any;
|
|
@@ -10,7 +10,7 @@ interface EditableCellProps<DataType> extends React.HTMLAttributes<HTMLElement>
|
|
|
10
10
|
record: DataType;
|
|
11
11
|
index: number;
|
|
12
12
|
format?: IFormat;
|
|
13
|
-
column:
|
|
13
|
+
column: ColumnTable<DataType>;
|
|
14
14
|
indexRow: number;
|
|
15
15
|
indexCol: number;
|
|
16
16
|
rowKey: any;
|
|
@@ -268,15 +268,15 @@ const EditableCell = props => {
|
|
|
268
268
|
const columnsTable = rr.map(colSelect => {
|
|
269
269
|
return {
|
|
270
270
|
title: colSelect.headerTemplate ? colSelect.headerTemplate : t ? t(colSelect.headerText) : colSelect.headerText,
|
|
271
|
-
dataIndex: colSelect.dataIndex,
|
|
271
|
+
dataIndex: colSelect.field ?? colSelect.dataIndex,
|
|
272
272
|
key: colSelect.dataIndex,
|
|
273
273
|
render: colSelect.template ? (text, recd, ind) => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, colSelect.template?.({
|
|
274
274
|
value: text,
|
|
275
275
|
rowData: recd,
|
|
276
276
|
column: colSelect,
|
|
277
|
-
field: colSelect.
|
|
277
|
+
field: colSelect.field,
|
|
278
278
|
index: ind,
|
|
279
|
-
[colSelect.
|
|
279
|
+
[colSelect.field]: text
|
|
280
280
|
})) : undefined,
|
|
281
281
|
width: colSelect.width,
|
|
282
282
|
ellipsis: true,
|
|
@@ -324,8 +324,9 @@ const EditableCell = props => {
|
|
|
324
324
|
width: '100%',
|
|
325
325
|
height: '100%'
|
|
326
326
|
},
|
|
327
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
328
|
-
autoFocus
|
|
327
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
328
|
+
// autoFocus={true}
|
|
329
|
+
,
|
|
329
330
|
placeholder: t ? t('Select') : 'Select',
|
|
330
331
|
allowClear: column.isClearable ?? false,
|
|
331
332
|
maxTagCount: 'responsive',
|
|
@@ -398,8 +399,10 @@ const EditableCell = props => {
|
|
|
398
399
|
showSearch: true,
|
|
399
400
|
mode: isMulti || selectMode === 'checkbox' ? 'multiple' : undefined,
|
|
400
401
|
valueSelectAble: true,
|
|
401
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
402
|
-
autoFocus
|
|
402
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
403
|
+
// autoFocus={true}
|
|
404
|
+
,
|
|
405
|
+
|
|
403
406
|
style: {
|
|
404
407
|
width: '100%',
|
|
405
408
|
height: '100%'
|
|
@@ -449,8 +452,9 @@ const EditableCell = props => {
|
|
|
449
452
|
});
|
|
450
453
|
},
|
|
451
454
|
showSearch: true,
|
|
452
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
453
|
-
autoFocus
|
|
455
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
456
|
+
// autoFocus={true}
|
|
457
|
+
,
|
|
454
458
|
mode: isMulti || selectMode === 'checkbox' ? 'multiple' : undefined,
|
|
455
459
|
valueSelectAble: true,
|
|
456
460
|
style: {
|
|
@@ -529,8 +533,9 @@ const EditableCell = props => {
|
|
|
529
533
|
treeData: newTreeData,
|
|
530
534
|
placeholder: t ? t('Select') : 'Select',
|
|
531
535
|
treeDefaultExpandAll: true,
|
|
532
|
-
defaultOpen: column.field === cellEditing?.column.field
|
|
533
|
-
autoFocus
|
|
536
|
+
defaultOpen: column.field === cellEditing?.column.field
|
|
537
|
+
// autoFocus={true}
|
|
538
|
+
,
|
|
534
539
|
virtual: true,
|
|
535
540
|
allowClear: true
|
|
536
541
|
// maxTagTextLength={column?.editSelectSettings?.showItems}
|
|
@@ -22,7 +22,10 @@ var _useColumns = _interopRequireDefault(require("./hooks/useColumns"));
|
|
|
22
22
|
require("./styles.scss");
|
|
23
23
|
var _columns = require("./hooks/columns");
|
|
24
24
|
var _Group = _interopRequireDefault(require("./table/Group"));
|
|
25
|
+
var _sweetalert = _interopRequireDefault(require("sweetalert2"));
|
|
26
|
+
var _sweetalert2ReactContent = _interopRequireDefault(require("sweetalert2-react-content"));
|
|
25
27
|
_dayjs.default.extend(_customParseFormat.default);
|
|
28
|
+
const MySwal = (0, _sweetalert2ReactContent.default)(_sweetalert.default);
|
|
26
29
|
|
|
27
30
|
// const ASCEND = 'ascend';
|
|
28
31
|
// const DESCEND = 'descend';
|
|
@@ -80,6 +83,8 @@ const InternalTable = props => {
|
|
|
80
83
|
groupAble,
|
|
81
84
|
groupSetting,
|
|
82
85
|
groupColumns,
|
|
86
|
+
commandClick,
|
|
87
|
+
commandSettings,
|
|
83
88
|
...rest
|
|
84
89
|
} = props;
|
|
85
90
|
const rowKey = _react.default.useMemo(() => {
|
|
@@ -205,6 +210,126 @@ const InternalTable = props => {
|
|
|
205
210
|
// setMergedData(newData)
|
|
206
211
|
onDataChange?.(newData);
|
|
207
212
|
};
|
|
213
|
+
const triggerCommandClick = args => {
|
|
214
|
+
const {
|
|
215
|
+
id,
|
|
216
|
+
rowId,
|
|
217
|
+
rowData,
|
|
218
|
+
index
|
|
219
|
+
} = args;
|
|
220
|
+
const tmpData = [...dataSource];
|
|
221
|
+
if (id === 'DELETE') {
|
|
222
|
+
// bật modal confirm
|
|
223
|
+
if (commandSettings && commandSettings.confirmDialog) {
|
|
224
|
+
MySwal.fire({
|
|
225
|
+
title: t ? t('Confirm') : 'Confirm',
|
|
226
|
+
text: t ? t('Do you want to delete item?') : 'Do you want to delete item?',
|
|
227
|
+
// icon: 'warning',
|
|
228
|
+
allowOutsideClick: false,
|
|
229
|
+
showCancelButton: true,
|
|
230
|
+
confirmButtonText: t ? t('Delete') : 'Delete',
|
|
231
|
+
cancelButtonText: t ? t('Cancel') : 'Cancel',
|
|
232
|
+
customClass: {
|
|
233
|
+
confirmButton: 'be-button btn-primary',
|
|
234
|
+
cancelButton: 'be-button btn-danger ms-1'
|
|
235
|
+
},
|
|
236
|
+
buttonsStyling: false
|
|
237
|
+
}).then(async result => {
|
|
238
|
+
if (result.value) {
|
|
239
|
+
if (!commandSettings || commandSettings && commandSettings.client !== false) {
|
|
240
|
+
// client
|
|
241
|
+
|
|
242
|
+
// kiểm tra dòng hiện tại có parent
|
|
243
|
+
|
|
244
|
+
let newData = [];
|
|
245
|
+
if (rowData?.parentId) {
|
|
246
|
+
const parent = (0, _hooks.findItemByKey)(dataSource, rowKey, rowData.parentId);
|
|
247
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
248
|
+
const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
|
|
249
|
+
childData.splice(Number(findIndex), 1);
|
|
250
|
+
const newRowData = {
|
|
251
|
+
...parent,
|
|
252
|
+
children: childData
|
|
253
|
+
};
|
|
254
|
+
// const newDataSource = updateArrayByKey(tmpData, newRowData, rowKey as string)
|
|
255
|
+
newData = (0, _hooks.updateArrayByKey)(tmpData, newRowData, rowKey);
|
|
256
|
+
} else {
|
|
257
|
+
tmpData.splice(Number(index), 1);
|
|
258
|
+
newData = [...tmpData];
|
|
259
|
+
}
|
|
260
|
+
if (commandClick) {
|
|
261
|
+
commandClick({
|
|
262
|
+
id,
|
|
263
|
+
rowId: rowData.rowId,
|
|
264
|
+
rowData,
|
|
265
|
+
index,
|
|
266
|
+
// rows: [...tmpData]
|
|
267
|
+
rows: [...newData]
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
} else {
|
|
271
|
+
// server ~~ không làm gì
|
|
272
|
+
if (commandClick) {
|
|
273
|
+
commandClick({
|
|
274
|
+
id,
|
|
275
|
+
rowId: rowData.rowId,
|
|
276
|
+
rowData,
|
|
277
|
+
index,
|
|
278
|
+
rows: [...dataSource]
|
|
279
|
+
});
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
} else if (result.dismiss === MySwal.DismissReason.cancel) {}
|
|
283
|
+
});
|
|
284
|
+
} else {
|
|
285
|
+
// -------------------
|
|
286
|
+
|
|
287
|
+
if (!commandSettings || commandSettings && commandSettings.client !== false) {
|
|
288
|
+
// client
|
|
289
|
+
|
|
290
|
+
let newData2 = [];
|
|
291
|
+
if (rowData?.parentId) {
|
|
292
|
+
const parent = (0, _hooks.findItemByKey)(dataSource, rowKey, rowData.parentId);
|
|
293
|
+
const childData = parent?.children ? [...parent.children] : [];
|
|
294
|
+
const findIndex = childData.findIndex(obj => obj[rowKey] === rowData[rowKey]);
|
|
295
|
+
childData.splice(Number(findIndex), 1);
|
|
296
|
+
const newRowData = {
|
|
297
|
+
...parent,
|
|
298
|
+
children: childData
|
|
299
|
+
};
|
|
300
|
+
newData2 = (0, _hooks.updateArrayByKey)(tmpData, newRowData, rowKey);
|
|
301
|
+
} else {
|
|
302
|
+
tmpData.splice(Number(index), 1);
|
|
303
|
+
newData2 = [...tmpData];
|
|
304
|
+
}
|
|
305
|
+
if (commandClick) {
|
|
306
|
+
commandClick({
|
|
307
|
+
id,
|
|
308
|
+
rowId,
|
|
309
|
+
rowData,
|
|
310
|
+
index,
|
|
311
|
+
rows: [...newData2]
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
} else {
|
|
315
|
+
// server
|
|
316
|
+
if (commandClick) {
|
|
317
|
+
commandClick({
|
|
318
|
+
id,
|
|
319
|
+
rowId,
|
|
320
|
+
rowData,
|
|
321
|
+
index,
|
|
322
|
+
rows: [...dataSource]
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
if (commandClick) {
|
|
329
|
+
commandClick(args);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
208
333
|
const triggerPaste = (pastedRows, pastedColumnsArray, newData) => {
|
|
209
334
|
const handlePasteCallback = callbackData => {
|
|
210
335
|
const newDataUpdate = (0, _hooks.updateData)(dataSource, callbackData, rowKey);
|
|
@@ -260,7 +385,8 @@ const InternalTable = props => {
|
|
|
260
385
|
clickHeaderToSort: clickHeaderToSort,
|
|
261
386
|
groupSetting: groupSetting,
|
|
262
387
|
groupAble: groupAble,
|
|
263
|
-
groupColumns: groupColumns
|
|
388
|
+
groupColumns: groupColumns,
|
|
389
|
+
commandClick: triggerCommandClick
|
|
264
390
|
}));
|
|
265
391
|
};
|
|
266
392
|
var _default = exports.default = InternalTable;
|
|
@@ -20,6 +20,7 @@ var _pagination = _interopRequireDefault(require("rc-master-ui/es/pagination"));
|
|
|
20
20
|
var _LoadingSpinner = _interopRequireDefault(require("./LoadingSpinner"));
|
|
21
21
|
var _ColumnsChoose = require("./ColumnsChoose");
|
|
22
22
|
var _useMergedState = _interopRequireDefault(require("rc-util/lib/hooks/useMergedState"));
|
|
23
|
+
var _AdvanceFilter = _interopRequireDefault(require("./AdvanceFilter"));
|
|
23
24
|
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); }
|
|
24
25
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
25
26
|
// import {ConfigProvider} from "antd";
|
|
@@ -112,6 +113,7 @@ const TableGrid = props => {
|
|
|
112
113
|
recordDoubleClick,
|
|
113
114
|
toolbarItems,
|
|
114
115
|
showColumnChoose,
|
|
116
|
+
showAdvanceFilter,
|
|
115
117
|
onFilter,
|
|
116
118
|
selectionSettings,
|
|
117
119
|
rowSelection,
|
|
@@ -403,7 +405,8 @@ const TableGrid = props => {
|
|
|
403
405
|
style: {
|
|
404
406
|
display: 'flex',
|
|
405
407
|
justifyContent: 'space-between',
|
|
406
|
-
alignItems: 'center'
|
|
408
|
+
alignItems: 'center',
|
|
409
|
+
gap: '.75rem'
|
|
407
410
|
}
|
|
408
411
|
}, groupAble && groupToolbar?.(), toolbarItems && toolbarItems?.length > 0 && /*#__PURE__*/_react.default.createElement("div", {
|
|
409
412
|
style: {
|
|
@@ -420,7 +423,8 @@ const TableGrid = props => {
|
|
|
420
423
|
style: {
|
|
421
424
|
display: 'flex',
|
|
422
425
|
justifyContent: 'space-between',
|
|
423
|
-
alignItems: 'center'
|
|
426
|
+
alignItems: 'center',
|
|
427
|
+
gap: '.75rem'
|
|
424
428
|
}
|
|
425
429
|
}, pagination && pagination.onChange && pagination?.position && pagination?.position[0] === 'topRight' && /*#__PURE__*/_react.default.createElement(_pagination.default, (0, _extends2.default)({
|
|
426
430
|
showSizeChanger: true,
|
|
@@ -435,6 +439,11 @@ const TableGrid = props => {
|
|
|
435
439
|
t: t,
|
|
436
440
|
columnsGroup: groupColumns,
|
|
437
441
|
triggerChangeColumns: triggerChangeColumns
|
|
442
|
+
}), showAdvanceFilter && /*#__PURE__*/_react.default.createElement(_AdvanceFilter.default, {
|
|
443
|
+
columns: columns,
|
|
444
|
+
t: t
|
|
445
|
+
// columnsGroup={groupColumns}
|
|
446
|
+
// triggerChangeColumns={triggerChangeColumns}
|
|
438
447
|
}))));
|
|
439
448
|
},
|
|
440
449
|
expandable: {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
type OptionType = {
|
|
3
|
+
value: any;
|
|
4
|
+
label: string;
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
};
|
|
7
|
+
type Props<T> = {
|
|
8
|
+
options: T[];
|
|
9
|
+
value: any[];
|
|
10
|
+
onChange?: (value: any[]) => void;
|
|
11
|
+
};
|
|
12
|
+
declare const CheckboxControl: <T extends OptionType>(props: Props<T>) => React.JSX.Element;
|
|
13
|
+
export default CheckboxControl;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _rcMasterUi = require("rc-master-ui");
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
const CheckboxControl = props => {
|
|
12
|
+
const {
|
|
13
|
+
options,
|
|
14
|
+
value,
|
|
15
|
+
onChange
|
|
16
|
+
} = props;
|
|
17
|
+
const selected = (0, _react.useMemo)(() => {
|
|
18
|
+
return value ? value : [];
|
|
19
|
+
}, [value]);
|
|
20
|
+
const list = (0, _react.useMemo)(() => {
|
|
21
|
+
return options ? options : [];
|
|
22
|
+
}, [options]);
|
|
23
|
+
const onChangeValue = val => {
|
|
24
|
+
const findIndex = selected.findIndex(it => it === val);
|
|
25
|
+
if (findIndex > -1) {
|
|
26
|
+
const newVal = selected.filter(it => it !== val);
|
|
27
|
+
onChange?.(newVal);
|
|
28
|
+
} else {
|
|
29
|
+
const newVal = [...selected, val];
|
|
30
|
+
onChange?.(newVal);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
34
|
+
className: "d-flex flex-column gap-50",
|
|
35
|
+
style: {}
|
|
36
|
+
}, list.map((it, index) => {
|
|
37
|
+
return /*#__PURE__*/_react.default.createElement("div", {
|
|
38
|
+
key: index,
|
|
39
|
+
className: "d-flex align-items-center"
|
|
40
|
+
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Checkbox, {
|
|
41
|
+
checked: selected.includes(it.value),
|
|
42
|
+
type: "checkbox",
|
|
43
|
+
className: "cursor-pointer me-50",
|
|
44
|
+
onChange: () => onChangeValue(it.value)
|
|
45
|
+
}), /*#__PURE__*/_react.default.createElement("span", null, it.label));
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
var _default = exports.default = CheckboxControl;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { ColumnType, IFormat } from "../../type";
|
|
1
|
+
import type { ColumnTable, ColumnType, IFormat } from "../../type";
|
|
2
2
|
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
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: (column:
|
|
8
|
+
export declare const renderContent: (column: ColumnTable, 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;
|
|
@@ -130,7 +130,12 @@ exports.getValueCell = getValueCell;
|
|
|
130
130
|
const renderContent = (column, value, record, index, format) => {
|
|
131
131
|
const cellValue = value instanceof Date ? (0, _utils.getDateString)(column, value) : value;
|
|
132
132
|
const content = getValueCell(column, cellValue, format);
|
|
133
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, column?.template ? typeof column.template === "function" ? column.template(
|
|
133
|
+
return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, column?.template ? typeof column.template === "function" ? column.template({
|
|
134
|
+
value,
|
|
135
|
+
index,
|
|
136
|
+
rowData: record,
|
|
137
|
+
field: column.field
|
|
138
|
+
}) : column.template : content);
|
|
134
139
|
};
|
|
135
140
|
exports.renderContent = renderContent;
|
|
136
141
|
const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, searchValue, setSearchValue, dataSourceFilter, buddhistLocale, locale, t) => {
|
|
@@ -377,8 +382,9 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
|
|
|
377
382
|
className: 'mb-1'
|
|
378
383
|
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select
|
|
379
384
|
// options={translateOption(numberOperator, t)}
|
|
385
|
+
// options={find ? options : column.source ?? []}
|
|
380
386
|
, {
|
|
381
|
-
options:
|
|
387
|
+
options: column.source ? column.source : options ?? [],
|
|
382
388
|
style: {
|
|
383
389
|
width: '100%',
|
|
384
390
|
marginBottom: 8
|
|
@@ -175,7 +175,10 @@ const useColumns = config => {
|
|
|
175
175
|
// title: () => (<span>{t ? t(col.columnGroupText ?? col.headerText ?? col.title) : col.columnGroupText ?? col.headerText ?? col.title}</span>),
|
|
176
176
|
ellipsis: col.ellipsis !== false,
|
|
177
177
|
align: col.textAlign ?? col.align,
|
|
178
|
-
fixed: col.
|
|
178
|
+
fixed: col.fixedType ?? col.fixed,
|
|
179
|
+
isSummary: col.isSummary ?? col.haveSum,
|
|
180
|
+
hidden: col.hidden ?? col.visible === false
|
|
181
|
+
// hidden: true
|
|
179
182
|
};
|
|
180
183
|
if (transformedColumn.children && transformedColumn.children?.length) {
|
|
181
184
|
return {
|
|
@@ -280,7 +283,7 @@ const useColumns = config => {
|
|
|
280
283
|
}
|
|
281
284
|
return (0, _columns.renderContent)(col, value, record, rowIndex, format);
|
|
282
285
|
},
|
|
283
|
-
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ?
|
|
286
|
+
hidden: groupSetting && groupSetting.hiddenColumnGroup === false ? transformedColumn.hidden : groupAble && groupColumns && groupColumns.includes(col.field) ? true : transformedColumn.hidden
|
|
284
287
|
};
|
|
285
288
|
});
|
|
286
289
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type * as React from "react";
|
|
2
2
|
import dayjs from "dayjs";
|
|
3
3
|
import type { EditType, IColumnType, TypeFilter } from "rc-master-ui";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ColumnsType, ColumnTable, GetRowKey } from "../type";
|
|
5
5
|
import type { SelectionSettings } from "../type";
|
|
6
6
|
import type { AnyObject } from "../type";
|
|
7
7
|
import type { Key } from "react";
|
|
@@ -26,8 +26,8 @@ export declare const customWeekStartEndFormat: (value: any, weekFormat: string)
|
|
|
26
26
|
export declare const getTypeFilter: (col: ColumnTable<any>) => TypeFilter;
|
|
27
27
|
export declare const updateArrayByKey: (arr: any[], element: any, key: string) => any[];
|
|
28
28
|
export declare const getDateString: <T>(column: ColumnTable<T>, value: any) => string;
|
|
29
|
-
export declare const getEditType: <T>(column:
|
|
30
|
-
export declare const isDisable: <T>(column:
|
|
29
|
+
export declare const getEditType: <T>(column: ColumnTable<T>, rowData?: any) => EditType;
|
|
30
|
+
export declare const isDisable: <T>(column: ColumnTable<T>, rowData?: any) => boolean;
|
|
31
31
|
export declare const checkFieldKey: (key: string | undefined) => string;
|
|
32
32
|
export declare const convertLabelToTitle: (data: any[]) => any[];
|
|
33
33
|
export declare const convertArrayWithIndent: (inputArray: any[], parentIndent?: number) => any[];
|
|
@@ -64,8 +64,9 @@ export declare function addRows8(arr: any, n: number): {
|
|
|
64
64
|
};
|
|
65
65
|
export declare const transformColumns: <RecordType>(cols: ColumnsTable<RecordType>, convertColumns: any[], t?: any) => ColumnsTable<RecordType>;
|
|
66
66
|
export declare const transformColumns1: <RecordType>(cols: ColumnsTable<RecordType>, sortMultiple?: boolean) => ColumnsTable<RecordType>;
|
|
67
|
-
export declare const removeColumns: <RecordType>(columns:
|
|
67
|
+
export declare const removeColumns: <RecordType>(columns: ColumnTable<RecordType>[], groupColumns: string[]) => ColumnsTable<RecordType>;
|
|
68
68
|
export declare const convertFlatColumn: (array: ColumnsTable) => ColumnsTable[];
|
|
69
69
|
export declare const convertColumns: <RecordType>(cols: ColumnsTable<RecordType>) => ColumnsTable<RecordType>;
|
|
70
70
|
export declare const checkChild: (inputArray: any[]) => boolean;
|
|
71
|
-
export declare const isEditable: <RecordType>(column:
|
|
71
|
+
export declare const isEditable: <RecordType>(column: ColumnTable, rowData: RecordType) => boolean | ((rowData: any) => boolean);
|
|
72
|
+
export declare const isArraysEqual: (arr1: any[], arr2: any[]) => boolean;
|
|
@@ -10,7 +10,7 @@ exports.customWeekStartEndFormat = exports.countItemsBeforeIndex = exports.conve
|
|
|
10
10
|
exports.findAllChildrenKeys = findAllChildrenKeys;
|
|
11
11
|
exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemByKey = void 0;
|
|
12
12
|
exports.getHiddenParentKeys = getHiddenParentKeys;
|
|
13
|
-
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.removeColumns = exports.parseBooleanToValue = exports.newGuid = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isEditable = exports.isDisable = exports.isColor = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
13
|
+
exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.removeColumns = exports.parseBooleanToValue = exports.newGuid = exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = exports.isEmpty = exports.isEditable = exports.isDisable = exports.isColor = exports.isArraysEqual = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
|
|
14
14
|
var _dayjs = _interopRequireDefault(require("dayjs"));
|
|
15
15
|
var _moment = _interopRequireDefault(require("moment/moment"));
|
|
16
16
|
var _uuid = require("uuid");
|
|
@@ -760,7 +760,7 @@ const removeColumns = (columns, groupColumns) => {
|
|
|
760
760
|
const newCol = {
|
|
761
761
|
...column
|
|
762
762
|
};
|
|
763
|
-
if (newCol.
|
|
763
|
+
if (newCol?.children && newCol?.children.length > 0) {
|
|
764
764
|
newCol.children = removeColumns(newCol.children, groupColumns);
|
|
765
765
|
}
|
|
766
766
|
return newCol;
|
|
@@ -795,7 +795,7 @@ const convertColumns = cols => {
|
|
|
795
795
|
// title: () => (<span>{t ? t(col.columnGroupText ?? col.headerText ?? col.title) : col.columnGroupText ?? col.headerText ?? col.title}</span>),
|
|
796
796
|
ellipsis: col.ellipsis !== false,
|
|
797
797
|
align: col.textAlign ?? col.align,
|
|
798
|
-
fixed: col.
|
|
798
|
+
fixed: col.fixedType ?? col.fixed
|
|
799
799
|
};
|
|
800
800
|
if (transformedColumn.children && transformedColumn.children?.length) {
|
|
801
801
|
return {
|
|
@@ -839,4 +839,11 @@ const isEditable = (column, rowData) => {
|
|
|
839
839
|
}
|
|
840
840
|
return column?.editEnable;
|
|
841
841
|
};
|
|
842
|
-
exports.isEditable = isEditable;
|
|
842
|
+
exports.isEditable = isEditable;
|
|
843
|
+
const isArraysEqual = (arr1, arr2) => {
|
|
844
|
+
if (arr1.length !== arr2.length) {
|
|
845
|
+
return false;
|
|
846
|
+
}
|
|
847
|
+
return arr1.every((element, index) => element === arr2[index]);
|
|
848
|
+
};
|
|
849
|
+
exports.isArraysEqual = isArraysEqual;
|
|
@@ -205,6 +205,8 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
205
205
|
border-bottom: 1px solid $tableBorderColor;
|
|
206
206
|
//background: #fff;
|
|
207
207
|
font-weight: 500;
|
|
208
|
+
//line-height: 23px;
|
|
209
|
+
//height: 40px;
|
|
208
210
|
}
|
|
209
211
|
}
|
|
210
212
|
|
|
@@ -336,10 +338,18 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
|
|
|
336
338
|
.#{$prefix}-table-wrapper {
|
|
337
339
|
|
|
338
340
|
.#{$prefix}-table.#{$prefix}-table-small {
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
341
|
+
.ui-rc-table-thead {
|
|
342
|
+
>tr >th.#{$prefix}-table-selection-column{
|
|
343
|
+
//padding-block: 7px;
|
|
344
|
+
padding: 0;
|
|
345
|
+
//padding: 6px 8px;
|
|
346
|
+
}
|
|
342
347
|
}
|
|
348
|
+
//.#{$prefix}-table-selection-column{
|
|
349
|
+
// padding-block: 7px;
|
|
350
|
+
// padding: 0;
|
|
351
|
+
// //padding: 6px 8px;
|
|
352
|
+
//}
|
|
343
353
|
}
|
|
344
354
|
|
|
345
355
|
&.grid-editable {
|