es-grid-template 1.1.7 → 1.1.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/InternalTable.js +89 -106
- package/es/grid-component/TableGrid.js +6 -3
- package/es/grid-component/hooks/constant.js +14 -14
- package/es/grid-component/hooks/useColumns/index.d.ts +5 -3
- package/es/grid-component/hooks/useColumns/index.js +29 -1
- package/es/grid-component/hooks/utils.d.ts +1 -1
- package/es/grid-component/hooks/utils.js +1 -1
- package/es/grid-component/styles.scss +715 -701
- package/es/grid-component/table/Grid.js +3 -1
- package/es/grid-component/table/GridEdit.js +134 -163
- package/es/grid-component/type.d.ts +1 -1
- package/lib/grid-component/InternalTable.js +87 -102
- package/lib/grid-component/TableGrid.js +6 -3
- package/lib/grid-component/hooks/constant.js +14 -14
- package/lib/grid-component/hooks/useColumns/index.d.ts +5 -3
- package/lib/grid-component/hooks/useColumns/index.js +30 -1
- package/lib/grid-component/hooks/utils.d.ts +1 -1
- package/lib/grid-component/hooks/utils.js +1 -1
- package/lib/grid-component/styles.scss +715 -701
- package/lib/grid-component/table/Grid.js +3 -1
- package/lib/grid-component/table/GridEdit.js +132 -162
- package/lib/grid-component/type.d.ts +1 -1
- package/package.json +105 -105
|
@@ -10,6 +10,7 @@ const Grid = props => {
|
|
|
10
10
|
const {
|
|
11
11
|
height,
|
|
12
12
|
style,
|
|
13
|
+
rowHoverable,
|
|
13
14
|
...rest
|
|
14
15
|
} = props;
|
|
15
16
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
|
|
@@ -21,7 +22,8 @@ const Grid = props => {
|
|
|
21
22
|
style: {
|
|
22
23
|
...style,
|
|
23
24
|
minHeight: height
|
|
24
|
-
}
|
|
25
|
+
},
|
|
26
|
+
rowHoverable: rowHoverable ?? true
|
|
25
27
|
}))));
|
|
26
28
|
};
|
|
27
29
|
export default Grid;
|
|
@@ -5,7 +5,7 @@ import classNames from "classnames";
|
|
|
5
5
|
import { Form } from "antd";
|
|
6
6
|
import { useForm } from 'react-hook-form';
|
|
7
7
|
import { Toaster } from "react-hot-toast";
|
|
8
|
-
import { renderContent } from "../hooks/useColumns";
|
|
8
|
+
import { flatColumns, renderContent } from "../hooks/useColumns";
|
|
9
9
|
import EditableCell from "../EditableCell";
|
|
10
10
|
import { GridStyle } from "../GridStyle";
|
|
11
11
|
import { TableContext } from "../useContext";
|
|
@@ -15,7 +15,9 @@ import 'dayjs/locale/vi';
|
|
|
15
15
|
import TableGrid from "../TableGrid";
|
|
16
16
|
import { getEditType, isObjEmpty, totalFixedWidth } from "../hooks";
|
|
17
17
|
import Message from "../../Message/Message";
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
// import Command from "../Command";
|
|
20
|
+
|
|
19
21
|
dayjs.extend(customParseFormat);
|
|
20
22
|
const toast = 'top-right';
|
|
21
23
|
const GridEdit = props => {
|
|
@@ -574,175 +576,144 @@ const GridEdit = props => {
|
|
|
574
576
|
}
|
|
575
577
|
}
|
|
576
578
|
};
|
|
577
|
-
const
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
if (col.children) {
|
|
584
|
-
return {
|
|
585
|
-
...col,
|
|
586
|
-
children: addResizeHandlers(col.children, currentPath)
|
|
587
|
-
};
|
|
588
|
-
}
|
|
589
|
-
if (col.dataIndex === 'index' || col.field === 'index' || col.dataIndex === '#' || col.dataIndex === '#') {
|
|
590
|
-
return {
|
|
591
|
-
...col,
|
|
592
|
-
className: 'rc-ui-cell-editable',
|
|
593
|
-
render: (value, record, rowIndex) => {
|
|
594
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
595
|
-
className: classNames('ui-rc_cell-content ui-rc_cell-content--index', {
|
|
596
|
-
selected: rowsSelected.has(`${rowIndex}-${colIndex}`),
|
|
597
|
-
focus: selectedCells && Array.from(selectedCells).some(item => item.startsWith(`${rowIndex}-`))
|
|
598
|
-
}),
|
|
599
|
-
onMouseDown: event => handleMouseDownColIndex(rowIndex, colIndex, event),
|
|
600
|
-
onMouseEnter: event => handleMouseEnterColIndex(rowIndex, colIndex, event),
|
|
601
|
-
onClick: () => handleClickRowHeader(rowIndex, colIndex)
|
|
602
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
603
|
-
className: 'ui-rc_content'
|
|
604
|
-
}, rowIndex + 1));
|
|
605
|
-
}
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
if (col.dataIndex === 'command' || col.field === 'command') {
|
|
609
|
-
return {
|
|
610
|
-
...col,
|
|
611
|
-
title: col.headerText ?? col.title,
|
|
612
|
-
ellipsis: col.ellipsis !== false,
|
|
613
|
-
onCell: () => ({
|
|
614
|
-
className: 'ui-rc-cell-command'
|
|
615
|
-
}),
|
|
616
|
-
// render: (value: any, record: any, rowIndex: number) => {
|
|
617
|
-
render: () => {
|
|
618
|
-
return /*#__PURE__*/React.createElement("div", {
|
|
619
|
-
className: classNames('ui-rc-cell-command__content', {})
|
|
620
|
-
}, col.commandItems && col.commandItems?.map((item, indexComm) => {
|
|
621
|
-
if (item.visible !== false) {
|
|
622
|
-
// return (
|
|
623
|
-
// <span>{item.title}</span>
|
|
624
|
-
// )
|
|
625
|
-
|
|
626
|
-
return /*#__PURE__*/React.createElement(Command, {
|
|
627
|
-
key: `command-${indexComm}`,
|
|
628
|
-
item: item,
|
|
629
|
-
onClick: e => {
|
|
630
|
-
e.preventDefault();
|
|
631
|
-
// handleCommandClick({command: item, rowData: record, index: rowIndex})
|
|
632
|
-
}
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
}));
|
|
636
|
-
}
|
|
637
|
-
};
|
|
638
|
-
}
|
|
579
|
+
const convertColumns = flatColumns(columns).map((column, colIndex) => {
|
|
580
|
+
if (!column?.field && !column?.key) {
|
|
581
|
+
return column;
|
|
582
|
+
}
|
|
583
|
+
if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
|
|
639
584
|
return {
|
|
640
|
-
...
|
|
641
|
-
|
|
642
|
-
onKeyDown: event => {
|
|
643
|
-
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
644
|
-
if (!isEditing(record) && record[rowKey] !== editingKey) {
|
|
645
|
-
handleEdit(record, col, col.editType, event);
|
|
646
|
-
}
|
|
647
|
-
if (editingKey && editingKey !== '' && (rowIndex ?? 0) + 1 < dataSource.length && event.key === 'Enter') {
|
|
648
|
-
handleFocusCell((rowIndex ?? 0) + 1, colIndex, col, 'vertical', event);
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
if (event.key === 'Tab') {
|
|
652
|
-
if (colIndex + 1 !== cols.length) {
|
|
653
|
-
handleFocusCell(rowIndex, colIndex + 1, col, 'horizontal', event);
|
|
654
|
-
} else {
|
|
655
|
-
event.stopPropagation();
|
|
656
|
-
event.preventDefault();
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
if (event.key === 'ArrowRight' && colIndex + 1 !== cols.length) {
|
|
660
|
-
if (editingKey !== '') {} else {
|
|
661
|
-
handleFocusCell(rowIndex, colIndex + 1, col, 'horizontal', event);
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
if (event.key === 'ArrowLeft' && colIndex > 0) {
|
|
665
|
-
if (!col.dataIndex && !col.key || col.field === 'index' || col.field === '#' || col.dataIndex === 'index' || col.dataIndex === '#') {
|
|
666
|
-
event.stopPropagation();
|
|
667
|
-
event.preventDefault();
|
|
668
|
-
} else {
|
|
669
|
-
if (editingKey !== '') {} else {
|
|
670
|
-
handleFocusCell(rowIndex, colIndex - 1, col, 'horizontal', event);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
if (event.key === 'ArrowDown' && (rowIndex ?? 0) + 1 < dataSource.length) {
|
|
675
|
-
handleFocusCell((rowIndex ?? 0) + 1, colIndex, col, 'vertical', event);
|
|
676
|
-
}
|
|
677
|
-
if (event.key === 'ArrowUp' && (rowIndex ?? 0) > 0) {
|
|
678
|
-
handleFocusCell((rowIndex ?? 0) - 1, colIndex, col, 'vertical', event);
|
|
679
|
-
}
|
|
680
|
-
},
|
|
681
|
-
onPaste: event => {
|
|
682
|
-
if (editingKey === '') {
|
|
683
|
-
handlePaste(event, colIndex, rowIndex);
|
|
684
|
-
event.preventDefault();
|
|
685
|
-
}
|
|
686
|
-
},
|
|
687
|
-
onCopy: e => {
|
|
688
|
-
if (editingKey === '') {
|
|
689
|
-
handleCopy(e);
|
|
690
|
-
e.preventDefault();
|
|
691
|
-
}
|
|
692
|
-
},
|
|
693
|
-
onDoubleClick: event => {
|
|
694
|
-
if (!isEditing(record) && record[rowKey] !== editingKey) {
|
|
695
|
-
handleEdit(record, col, col.editType, event);
|
|
696
|
-
}
|
|
697
|
-
},
|
|
698
|
-
// onMouseDown: (event) => {
|
|
699
|
-
// handleMouseDown(rowIndex, colIndex, event)
|
|
700
|
-
// },
|
|
701
|
-
//
|
|
702
|
-
// onMouseEnter: () => {
|
|
703
|
-
// handleMouseEnter(rowIndex, colIndex)
|
|
704
|
-
// },
|
|
705
|
-
|
|
706
|
-
onClick: () => {
|
|
707
|
-
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
708
|
-
setEditingKey('');
|
|
709
|
-
}
|
|
710
|
-
},
|
|
711
|
-
className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
|
|
712
|
-
record,
|
|
713
|
-
column: col,
|
|
714
|
-
editType: getEditType(col, record),
|
|
715
|
-
dataIndex: col.dataIndex,
|
|
716
|
-
title: col.title,
|
|
717
|
-
'data-col-index': colIndex,
|
|
718
|
-
'data-row-index': rowIndex,
|
|
719
|
-
// colIndex: colIndex,
|
|
720
|
-
indexCol: colIndex,
|
|
721
|
-
indexRow: rowIndex,
|
|
722
|
-
editing: isEditing(record),
|
|
723
|
-
tabIndex: (rowIndex ?? 0) * columns.length + colIndex
|
|
724
|
-
}),
|
|
725
|
-
// onHeaderCell: (data) => ({
|
|
726
|
-
// ...col.onHeaderCell(),
|
|
727
|
-
// onClick: () => {
|
|
728
|
-
// handleClickColHeader(data as ColumnTable, colIndex)
|
|
729
|
-
// }
|
|
730
|
-
// }),
|
|
585
|
+
...column,
|
|
586
|
+
className: 'rc-ui-cell-editable',
|
|
731
587
|
render: (value, record, rowIndex) => {
|
|
732
588
|
return /*#__PURE__*/React.createElement("div", {
|
|
733
|
-
className: classNames('ui-rc_cell-content', {
|
|
734
|
-
selected:
|
|
589
|
+
className: classNames('ui-rc_cell-content ui-rc_cell-content--index', {
|
|
590
|
+
selected: rowsSelected.has(`${rowIndex}-${colIndex}`),
|
|
591
|
+
focus: selectedCells && Array.from(selectedCells).some(item => item.startsWith(`${rowIndex}-`))
|
|
735
592
|
}),
|
|
736
|
-
onMouseDown: event =>
|
|
737
|
-
onMouseEnter:
|
|
593
|
+
onMouseDown: event => handleMouseDownColIndex(rowIndex, colIndex, event),
|
|
594
|
+
onMouseEnter: event => handleMouseEnterColIndex(rowIndex, colIndex, event),
|
|
595
|
+
onClick: () => handleClickRowHeader(rowIndex, colIndex)
|
|
738
596
|
}, /*#__PURE__*/React.createElement("div", {
|
|
739
597
|
className: 'ui-rc_content'
|
|
740
|
-
},
|
|
598
|
+
}, rowIndex + 1));
|
|
741
599
|
}
|
|
742
600
|
};
|
|
601
|
+
}
|
|
602
|
+
return {
|
|
603
|
+
...column,
|
|
604
|
+
// editType: getEditType(column, record),
|
|
605
|
+
onCell: (record, rowIndex) => ({
|
|
606
|
+
onKeyDown: event => {
|
|
607
|
+
if (event.key.length === 1 && !event.ctrlKey && !event.metaKey || event.key === 'Enter') {
|
|
608
|
+
if (!isEditing(record) && record[rowKey] !== editingKey) {
|
|
609
|
+
handleEdit(record, column, column.editType, event);
|
|
610
|
+
}
|
|
611
|
+
if (editingKey && editingKey !== '' && (rowIndex ?? 0) + 1 < dataSource.length && event.key === 'Enter') {
|
|
612
|
+
handleFocusCell((rowIndex ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
if (event.key === 'Tab') {
|
|
616
|
+
if (colIndex + 1 !== columns.length) {
|
|
617
|
+
handleFocusCell(rowIndex, colIndex + 1, column, 'horizontal', event);
|
|
618
|
+
} else {
|
|
619
|
+
event.stopPropagation();
|
|
620
|
+
event.preventDefault();
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
if (event.key === 'ArrowRight' && colIndex + 1 !== columns.length) {
|
|
624
|
+
if (editingKey !== '') {} else {
|
|
625
|
+
handleFocusCell(rowIndex, colIndex + 1, column, 'horizontal', event);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
if (event.key === 'ArrowLeft' && colIndex > 0) {
|
|
629
|
+
if (!column.dataIndex && !column.key || column.field === 'index' || column.field === '#' || column.dataIndex === 'index' || column.dataIndex === '#') {
|
|
630
|
+
event.stopPropagation();
|
|
631
|
+
event.preventDefault();
|
|
632
|
+
} else {
|
|
633
|
+
if (editingKey !== '') {} else {
|
|
634
|
+
handleFocusCell(rowIndex, colIndex - 1, column, 'horizontal', event);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (event.key === 'ArrowDown' && (rowIndex ?? 0) + 1 < dataSource.length) {
|
|
639
|
+
handleFocusCell((rowIndex ?? 0) + 1, colIndex, column, 'vertical', event);
|
|
640
|
+
}
|
|
641
|
+
if (event.key === 'ArrowUp' && (rowIndex ?? 0) > 0) {
|
|
642
|
+
handleFocusCell((rowIndex ?? 0) - 1, colIndex, column, 'vertical', event);
|
|
643
|
+
}
|
|
644
|
+
},
|
|
645
|
+
onPaste: event => {
|
|
646
|
+
if (editingKey === '') {
|
|
647
|
+
handlePaste(event, colIndex, rowIndex);
|
|
648
|
+
event.preventDefault();
|
|
649
|
+
}
|
|
650
|
+
},
|
|
651
|
+
onCopy: e => {
|
|
652
|
+
if (editingKey === '') {
|
|
653
|
+
handleCopy(e);
|
|
654
|
+
e.preventDefault();
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
onDoubleClick: event => {
|
|
658
|
+
if (!isEditing(record) && record[rowKey] !== editingKey) {
|
|
659
|
+
handleEdit(record, column, getEditType(column, record), event);
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
onClick: () => {
|
|
663
|
+
if (record[rowKey] !== editingKey && editingKey !== '') {
|
|
664
|
+
setEditingKey('');
|
|
665
|
+
}
|
|
666
|
+
},
|
|
667
|
+
className: isEditing(record) ? 'rc-ui-cell-editable cell-editing' : 'rc-ui-cell-editable cell-editable',
|
|
668
|
+
record,
|
|
669
|
+
column: column,
|
|
670
|
+
editType: getEditType(column, record),
|
|
671
|
+
dataIndex: column.dataIndex,
|
|
672
|
+
title: column.title,
|
|
673
|
+
'data-col-index': colIndex,
|
|
674
|
+
'data-row-index': rowIndex,
|
|
675
|
+
// colIndex: colIndex,
|
|
676
|
+
indexCol: colIndex,
|
|
677
|
+
indexRow: rowIndex,
|
|
678
|
+
editing: isEditing(record),
|
|
679
|
+
tabIndex: (rowIndex ?? 0) * columns.length + colIndex
|
|
680
|
+
}),
|
|
681
|
+
render: (value, record, rowIndex) => {
|
|
682
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
683
|
+
className: classNames('ui-rc_cell-content', {
|
|
684
|
+
selected: selectedCells.has(`${rowIndex}-${colIndex}`)
|
|
685
|
+
}),
|
|
686
|
+
onMouseDown: event => handleMouseDown(rowIndex, colIndex, event),
|
|
687
|
+
onMouseEnter: () => handleMouseEnter(rowIndex, colIndex)
|
|
688
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
689
|
+
className: 'ui-rc_content'
|
|
690
|
+
}, renderContent(column, value, record, rowIndex, format)));
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
});
|
|
694
|
+
const transformColumns = React.useCallback(cols => {
|
|
695
|
+
// @ts-ignore
|
|
696
|
+
return cols.map(column => {
|
|
697
|
+
const find = convertColumns.find(it => it.key === column.key);
|
|
698
|
+
if (!column?.field && !column?.key) {
|
|
699
|
+
return column;
|
|
700
|
+
}
|
|
701
|
+
if (find) {
|
|
702
|
+
return {
|
|
703
|
+
...find
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// Xử lý đệ quy cho children
|
|
708
|
+
if (column.children?.length) {
|
|
709
|
+
return {
|
|
710
|
+
...column,
|
|
711
|
+
children: transformColumns(column.children)
|
|
712
|
+
};
|
|
713
|
+
}
|
|
743
714
|
});
|
|
744
|
-
};
|
|
745
|
-
const
|
|
715
|
+
}, [convertColumns]);
|
|
716
|
+
const mergedColumns = React.useMemo(() => transformColumns(columns ?? []), [transformColumns, columns]);
|
|
746
717
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
|
|
747
718
|
heightTable: height,
|
|
748
719
|
style: {
|
|
@@ -774,7 +745,7 @@ const GridEdit = props => {
|
|
|
774
745
|
},
|
|
775
746
|
className: classNames(className, 'grid-editable'),
|
|
776
747
|
rowKey: rowKey,
|
|
777
|
-
columns:
|
|
748
|
+
columns: mergedColumns,
|
|
778
749
|
showSorterTooltip: {
|
|
779
750
|
target: 'sorter-icon'
|
|
780
751
|
},
|
|
@@ -104,7 +104,7 @@ export type ColumnType<RecordType> = Omit<RcColumnType<RecordType>, 'headerTempl
|
|
|
104
104
|
children?: ColumnType<RecordType>[];
|
|
105
105
|
};
|
|
106
106
|
export type ColumnEditType<RecordType> = Omit<ColumnType<RecordType>, 'children'> & {
|
|
107
|
-
editType?: EditType | ((rowData?:
|
|
107
|
+
editType?: EditType | ((rowData?: RecordType) => EditType);
|
|
108
108
|
disable?: boolean | ((rowData: any) => boolean);
|
|
109
109
|
isClearable?: boolean;
|
|
110
110
|
maxDate?: any;
|
|
@@ -89,8 +89,6 @@ const InternalTable = props => {
|
|
|
89
89
|
// },
|
|
90
90
|
// );
|
|
91
91
|
|
|
92
|
-
// console.log('mergedColumns', mergedColumns)
|
|
93
|
-
|
|
94
92
|
const tableRef = (0, _react.useRef)(null);
|
|
95
93
|
const [data, setData] = (0, _react.useState)([]);
|
|
96
94
|
const [columns, setColumns] = (0, _react.useState)([]);
|
|
@@ -154,13 +152,17 @@ const InternalTable = props => {
|
|
|
154
152
|
setSelectedKeys,
|
|
155
153
|
selectedKeys,
|
|
156
154
|
confirm,
|
|
157
|
-
close,
|
|
155
|
+
// close,
|
|
158
156
|
setOperatorKey,
|
|
159
157
|
operatorKey,
|
|
160
158
|
visible,
|
|
161
159
|
searchValue,
|
|
162
160
|
setSearchValue
|
|
163
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;
|
|
164
166
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
165
167
|
style: {
|
|
166
168
|
padding: 8,
|
|
@@ -170,7 +172,7 @@ const InternalTable = props => {
|
|
|
170
172
|
}, column?.showOperator !== false && column?.typeFilter !== 'DateRange' && column?.typeFilter !== 'NumberRange' && /*#__PURE__*/_react.default.createElement("div", {
|
|
171
173
|
className: 'mb-1'
|
|
172
174
|
}, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Select, {
|
|
173
|
-
options: (0, _hooks.translateOption)(
|
|
175
|
+
options: (0, _hooks.translateOption)(operatorOptions, t),
|
|
174
176
|
style: {
|
|
175
177
|
width: '100%',
|
|
176
178
|
marginBottom: 8
|
|
@@ -201,13 +203,17 @@ const InternalTable = props => {
|
|
|
201
203
|
style: {
|
|
202
204
|
width: 90
|
|
203
205
|
}
|
|
204
|
-
},
|
|
206
|
+
}, t ? t('Filter') : 'Filter'), /*#__PURE__*/_react.default.createElement(_antd.Button, {
|
|
205
207
|
type: "link",
|
|
206
208
|
size: "small",
|
|
207
209
|
onClick: () => {
|
|
208
|
-
|
|
210
|
+
// setSearchValue('')
|
|
211
|
+
setSelectedKeys([]);
|
|
212
|
+
confirm();
|
|
213
|
+
// handleSearch()
|
|
214
|
+
// close()
|
|
209
215
|
}
|
|
210
|
-
}, "
|
|
216
|
+
}, t ? t("Clear") : 'Clear')));
|
|
211
217
|
},
|
|
212
218
|
filterIcon: filtered => /*#__PURE__*/_react.default.createElement(_becoxyIcons.FilterFill, {
|
|
213
219
|
fontSize: 12,
|
|
@@ -226,117 +232,96 @@ const InternalTable = props => {
|
|
|
226
232
|
}
|
|
227
233
|
}
|
|
228
234
|
}), [buddhistLocale, dataSourceFilter, onFilterCallback, onFilterClick, t]);
|
|
229
|
-
const handleResize =
|
|
235
|
+
const handleResize = column => (e, {
|
|
230
236
|
size
|
|
231
237
|
}) => {
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
if (idx === currentIndex) {
|
|
236
|
-
if (restPath.length === 0) {
|
|
237
|
-
// Cập nhật width của cột cuối cùng trong path
|
|
238
|
-
// return { ...col, width: size.width }
|
|
239
|
-
|
|
240
|
-
// Kiểm tra minWidth trước khi cập nhật width
|
|
241
|
-
if (col.minWidth && size.width < col.minWidth) {
|
|
242
|
-
e.preventDefault();
|
|
243
|
-
return col; // Không cập nhật nếu nhỏ hơn minWidth
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// Kiểm tra minWidth trước khi cập nhật width
|
|
247
|
-
if (col.maxWidth && size.width > col.maxWidth) {
|
|
248
|
-
e.preventDefault();
|
|
249
|
-
return col; // Không cập nhật nếu nhỏ hơn minWidth
|
|
250
|
-
}
|
|
251
|
-
return {
|
|
252
|
-
...col,
|
|
253
|
-
width: size.width
|
|
254
|
-
};
|
|
255
|
-
} else if (col.children) {
|
|
256
|
-
// Tiếp tục cập nhật các cấp con
|
|
257
|
-
return {
|
|
258
|
-
...col,
|
|
259
|
-
children: updateColumns(col.children, restPath)
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
// e.preventDefault()
|
|
264
|
-
return col;
|
|
265
|
-
});
|
|
238
|
+
const newColumn = {
|
|
239
|
+
...column,
|
|
240
|
+
width: size.width
|
|
266
241
|
};
|
|
267
|
-
|
|
242
|
+
const newColumns = (0, _hooks.updateArrayByKey)(columns, newColumn, 'field');
|
|
243
|
+
setColumns(newColumns);
|
|
268
244
|
};
|
|
269
|
-
const
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
245
|
+
const convertColumns = (0, _useColumns.flatColumns2)(columns).map((column, colIndex) => {
|
|
246
|
+
if (!column?.dataIndex && !column.key && !column.field) {
|
|
247
|
+
return column;
|
|
248
|
+
}
|
|
249
|
+
const transformedColumn = {
|
|
250
|
+
...column,
|
|
251
|
+
dataIndex: column.field ?? column.dataIndex,
|
|
252
|
+
key: column.field ?? column.dataIndex ?? column.key,
|
|
253
|
+
title: t ? t(column.headerText ?? column.title) : column.headerText ?? column.title,
|
|
254
|
+
ellipsis: column.ellipsis !== false,
|
|
255
|
+
align: column.textAlign ?? column.align,
|
|
256
|
+
fixed: column.frozen ? column.frozen.toLowerCase() : column.fixed
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
// @ts-ignore
|
|
260
|
+
if (["index", "#"].includes(transformedColumn.dataIndex)) {
|
|
261
|
+
return {
|
|
262
|
+
...transformedColumn,
|
|
263
|
+
onCell: () => ({
|
|
264
|
+
className: 'cell-number'
|
|
265
|
+
}),
|
|
266
|
+
render: (_, __, rowIndex) => rowIndex + 1
|
|
284
267
|
};
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
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
|
+
};
|
|
280
|
+
}
|
|
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
|
+
// @ts-ignore
|
|
302
|
+
return cols.map(column => {
|
|
303
|
+
const find = convertColumns.find(it => it.key === column.field);
|
|
304
|
+
if (!column?.field && !column?.key) {
|
|
305
|
+
return column;
|
|
290
306
|
}
|
|
291
|
-
|
|
292
|
-
// @ts-ignore
|
|
293
|
-
if (["index", "#"].includes(transformedColumn.dataIndex)) {
|
|
307
|
+
if (find) {
|
|
294
308
|
return {
|
|
295
|
-
...
|
|
296
|
-
onCell: () => ({
|
|
297
|
-
className: 'cell-number'
|
|
298
|
-
}),
|
|
299
|
-
render: (_, __, rowIndex) => rowIndex + 1
|
|
309
|
+
...find
|
|
300
310
|
};
|
|
301
311
|
}
|
|
302
|
-
|
|
312
|
+
|
|
313
|
+
// Xử lý đệ quy cho children
|
|
314
|
+
if (column.children?.length) {
|
|
303
315
|
return {
|
|
304
|
-
...
|
|
305
|
-
|
|
306
|
-
className: col.field === 'command' ? "ui-rc-cell-command" : ''
|
|
307
|
-
}),
|
|
308
|
-
onHeaderCell: () => ({
|
|
309
|
-
width: col.width,
|
|
310
|
-
onResize: handleResize(currentPath)
|
|
311
|
-
})
|
|
316
|
+
...column,
|
|
317
|
+
children: transformColumns(column.children)
|
|
312
318
|
};
|
|
313
319
|
}
|
|
314
|
-
return {
|
|
315
|
-
...(col.allowFiltering === false ? {} : {
|
|
316
|
-
...getColumnSearchProps(col)
|
|
317
|
-
}),
|
|
318
|
-
...transformedColumn,
|
|
319
|
-
onFilter: value => {
|
|
320
|
-
return value;
|
|
321
|
-
},
|
|
322
|
-
sorter: col.sorter === false ? undefined : {
|
|
323
|
-
compare: a => a,
|
|
324
|
-
multiple: sortMultiple ? index : undefined
|
|
325
|
-
},
|
|
326
|
-
onHeaderCell: () => ({
|
|
327
|
-
width: col.width,
|
|
328
|
-
onResize: handleResize(currentPath)
|
|
329
|
-
}),
|
|
330
|
-
render: (value, record, rowIndex) => (0, _useColumns.renderContent)(col, value, record, rowIndex, format)
|
|
331
|
-
};
|
|
332
320
|
});
|
|
333
|
-
}, [
|
|
321
|
+
}, [convertColumns]);
|
|
334
322
|
const mergedColumns = _react.default.useMemo(() => {
|
|
335
323
|
return transformColumns(columns);
|
|
336
324
|
}, [transformColumns, columns]);
|
|
337
|
-
|
|
338
|
-
// console.log('mergedColumns', mergedColumns)
|
|
339
|
-
|
|
340
325
|
const triggerChangeColumns = newColumns => {
|
|
341
326
|
setColumns(newColumns);
|
|
342
327
|
};
|
|
@@ -97,6 +97,7 @@ const TableGrid = props => {
|
|
|
97
97
|
dataSource,
|
|
98
98
|
locale,
|
|
99
99
|
expandable,
|
|
100
|
+
rowHoverable,
|
|
100
101
|
// mergedData,
|
|
101
102
|
title,
|
|
102
103
|
format,
|
|
@@ -335,7 +336,7 @@ const TableGrid = props => {
|
|
|
335
336
|
virtual: virtual,
|
|
336
337
|
columns: columns,
|
|
337
338
|
rowKey: rowKey,
|
|
338
|
-
rowHoverable:
|
|
339
|
+
rowHoverable: rowHoverable,
|
|
339
340
|
size: "small",
|
|
340
341
|
scroll: scroll ? scroll : {
|
|
341
342
|
y: 500
|
|
@@ -357,7 +358,9 @@ const TableGrid = props => {
|
|
|
357
358
|
selectedRowKeys: mergedSelectedKeys,
|
|
358
359
|
defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
|
|
359
360
|
preserveSelectedRowKeys: true,
|
|
360
|
-
...rowSelection,
|
|
361
|
+
// ...rowSelection,
|
|
362
|
+
// checkStrictly: false,
|
|
363
|
+
|
|
361
364
|
hideSelectAll: !type || type === 'single' || selectionSettings?.mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
|
|
362
365
|
},
|
|
363
366
|
onScroll: () => {
|
|
@@ -452,7 +455,7 @@ const TableGrid = props => {
|
|
|
452
455
|
} = args;
|
|
453
456
|
|
|
454
457
|
// @ts-ignore
|
|
455
|
-
if (record?.children
|
|
458
|
+
if (record?.children?.length > 0 || record?.isChildren) {
|
|
456
459
|
return expanded ? /*#__PURE__*/_react.default.createElement("button", {
|
|
457
460
|
onClick: e => {
|
|
458
461
|
e.preventDefault();
|