es-grid-template 1.7.27 → 1.7.28

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.
Files changed (85) hide show
  1. package/es/grid-component/InternalTable.js +31 -36
  2. package/es/grid-component/TempTable.d.ts +4 -0
  3. package/es/grid-component/TempTable.js +21 -0
  4. package/es/grid-component/hooks/columns/index.js +3 -1
  5. package/es/grid-component/index.d.ts +2 -2
  6. package/es/grid-component/index.js +6 -4
  7. package/es/grid-component/styles.scss +0 -1
  8. package/es/grid-component/table/GridEdit.js +112 -96
  9. package/es/grid-component/type.d.ts +7 -1
  10. package/es/table-component/InternalTable.js +100 -127
  11. package/es/table-component/TableContainer.d.ts +6 -0
  12. package/es/table-component/TableContainer.js +74 -70
  13. package/es/table-component/TableContainerEdit.d.ts +4 -0
  14. package/es/table-component/TableContainerEdit.js +353 -81
  15. package/es/table-component/body/TableBody.d.ts +2 -8
  16. package/es/table-component/body/TableBody.js +1 -0
  17. package/es/table-component/body/TableBodyCell.d.ts +1 -1
  18. package/es/table-component/body/TableBodyCell.js +25 -13
  19. package/es/table-component/body/TableBodyCellEdit.d.ts +1 -1
  20. package/es/table-component/body/TableBodyCellEdit.js +24 -10
  21. package/es/table-component/body/TableBodyRow.d.ts +3 -3
  22. package/es/table-component/body/TableBodyRow.js +4 -6
  23. package/es/table-component/footer/TableFooter.d.ts +2 -8
  24. package/es/table-component/footer/TableFooter.js +14 -13
  25. package/es/table-component/footer/TableFooterCell.d.ts +3 -6
  26. package/es/table-component/footer/TableFooterCell.js +12 -10
  27. package/es/table-component/footer/TableFooterRow.d.ts +2 -8
  28. package/es/table-component/footer/TableFooterRow.js +23 -48
  29. package/es/table-component/header/TableHead.d.ts +4 -3
  30. package/es/table-component/header/TableHead.js +3 -61
  31. package/es/table-component/header/TableHeadCell.d.ts +0 -3
  32. package/es/table-component/header/TableHeadCell.js +10 -9
  33. package/es/table-component/header/TableHeadRow.d.ts +6 -6
  34. package/es/table-component/header/TableHeadRow.js +10 -32
  35. package/es/table-component/style.scss +24 -2
  36. package/es/table-component/table/Grid.d.ts +1 -0
  37. package/es/table-component/table/Grid.js +6 -3
  38. package/es/table-component/table/TableWrapper.d.ts +32 -0
  39. package/es/table-component/table/TableWrapper.js +242 -0
  40. package/es/table-component/type.d.ts +4 -4
  41. package/es/table-component/useContext.d.ts +4 -0
  42. package/es/table-component/useContext.js +4 -0
  43. package/lib/grid-component/InternalTable.js +30 -35
  44. package/lib/grid-component/TempTable.d.ts +4 -0
  45. package/lib/grid-component/TempTable.js +30 -0
  46. package/lib/grid-component/hooks/columns/index.js +3 -1
  47. package/lib/grid-component/index.d.ts +2 -2
  48. package/lib/grid-component/index.js +5 -3
  49. package/lib/grid-component/styles.scss +0 -1
  50. package/lib/grid-component/table/GridEdit.js +112 -96
  51. package/lib/grid-component/type.d.ts +7 -1
  52. package/lib/table-component/InternalTable.js +101 -127
  53. package/lib/table-component/TableContainer.d.ts +6 -0
  54. package/lib/table-component/TableContainer.js +76 -70
  55. package/lib/table-component/TableContainerEdit.d.ts +4 -0
  56. package/lib/table-component/TableContainerEdit.js +349 -79
  57. package/lib/table-component/body/TableBody.d.ts +2 -8
  58. package/lib/table-component/body/TableBody.js +2 -0
  59. package/lib/table-component/body/TableBodyCell.d.ts +1 -1
  60. package/lib/table-component/body/TableBodyCell.js +25 -13
  61. package/lib/table-component/body/TableBodyCellEdit.d.ts +1 -1
  62. package/lib/table-component/body/TableBodyCellEdit.js +24 -10
  63. package/lib/table-component/body/TableBodyRow.d.ts +3 -3
  64. package/lib/table-component/body/TableBodyRow.js +4 -6
  65. package/lib/table-component/footer/TableFooter.d.ts +2 -8
  66. package/lib/table-component/footer/TableFooter.js +15 -13
  67. package/lib/table-component/footer/TableFooterCell.d.ts +3 -6
  68. package/lib/table-component/footer/TableFooterCell.js +13 -10
  69. package/lib/table-component/footer/TableFooterRow.d.ts +2 -8
  70. package/lib/table-component/footer/TableFooterRow.js +23 -48
  71. package/lib/table-component/header/TableHead.d.ts +4 -3
  72. package/lib/table-component/header/TableHead.js +3 -61
  73. package/lib/table-component/header/TableHeadCell.d.ts +0 -3
  74. package/lib/table-component/header/TableHeadCell.js +10 -8
  75. package/lib/table-component/header/TableHeadRow.d.ts +6 -6
  76. package/lib/table-component/header/TableHeadRow.js +10 -32
  77. package/lib/table-component/style.scss +24 -2
  78. package/lib/table-component/table/Grid.d.ts +1 -0
  79. package/lib/table-component/table/Grid.js +6 -3
  80. package/lib/table-component/table/TableWrapper.d.ts +32 -0
  81. package/lib/table-component/table/TableWrapper.js +251 -0
  82. package/lib/table-component/type.d.ts +4 -4
  83. package/lib/table-component/useContext.d.ts +4 -0
  84. package/lib/table-component/useContext.js +4 -0
  85. package/package.json +1 -1
@@ -53,16 +53,17 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
53
53
 
54
54
  }
55
55
 
56
- &.#{$prefix}-grid-cell-text-right {
56
+ &.#{$prefix}-grid-cell-text-right {
57
57
  justify-content: flex-end;
58
58
  text-align: right;
59
59
 
60
60
  }
61
-
61
+
62
62
 
63
63
 
64
64
  &.#{$prefix}-grid-cell-ellipsis {
65
65
 
66
+
66
67
  .ui-rc_cell-content {
67
68
  width: 100%;
68
69
  overflow: hidden;
@@ -98,6 +99,7 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
98
99
 
99
100
  }
100
101
 
102
+
101
103
 
102
104
  &.#{$prefix}-grid-cell-wrap {
103
105
  white-space: normal;
@@ -258,6 +260,16 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
258
260
 
259
261
  background-color: $body-color;
260
262
 
263
+ &.#{$prefix}-grid-cell-ellipsis:not(:has(>.ui-rc_cell-content)) {
264
+ overflow: hidden;
265
+ white-space: nowrap;
266
+ text-overflow: ellipsis;
267
+ word-break: keep-all;
268
+
269
+ }
270
+
271
+
272
+
261
273
  &.cell-editable {
262
274
 
263
275
  // padding: 0;
@@ -775,6 +787,16 @@ $fontFamily: "Montserrat", Helvetica, Arial, serif !default;
775
787
  }
776
788
  }
777
789
 
790
+ .spinner-loading {
791
+ position: absolute;
792
+ top: 0;
793
+ left: 0;
794
+ width: 100%;
795
+ height: 100%;
796
+ z-index: 4;
797
+ background-color: #ffffff80;
798
+ }
799
+
778
800
 
779
801
 
780
802
  }
@@ -21,6 +21,7 @@ type Props<T> = Omit<TableProps<T>, 'columns'> & {
21
21
  triggerSorter: Dispatch<SetStateAction<Sorter[]>>;
22
22
  onContextMenu?: (data: T) => (event: any) => void;
23
23
  triggerChangeColumns?: (args: any, keys: any) => void;
24
+ windowSize: any;
24
25
  };
25
26
  declare const Grid: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
26
27
  export default Grid;
@@ -45,6 +45,7 @@ const Grid = props => {
45
45
  height = 700,
46
46
  editAble,
47
47
  triggerChangeColumns,
48
+ infiniteScroll,
48
49
  ...rest
49
50
  } = props;
50
51
  const [columnResizeMode] = React.useState('onChange');
@@ -78,7 +79,8 @@ const Grid = props => {
78
79
  expanded,
79
80
  columnPinning,
80
81
  columnVisibility: columnHidden,
81
- pagination: pagination ? paginationState : undefined,
82
+ pagination: pagination && !infiniteScroll ? paginationState : undefined,
83
+ // pagination: pagination ? paginationState : undefined,
82
84
  grouping,
83
85
  columnSizing,
84
86
  columnOrder,
@@ -120,7 +122,7 @@ const Grid = props => {
120
122
  getGroupedRowModel: getGroupedRowModel(),
121
123
  // onExpandedChange: setExpanded,
122
124
  getExpandedRowModel: getExpandedRowModel(),
123
- getPaginationRowModel: pagination ? getPaginationRowModel() : undefined,
125
+ getPaginationRowModel: pagination && !infiniteScroll ? getPaginationRowModel() : undefined,
124
126
  onPaginationChange: setPagination
125
127
 
126
128
  // onColumnVisibilityChange: setColumnVisibility,
@@ -230,7 +232,8 @@ const Grid = props => {
230
232
  triggerChangeColumns: triggerChangeColumns,
231
233
  columnHidden: columnHidden,
232
234
  setExpanded: setExpanded,
233
- expanded: expanded
235
+ expanded: expanded,
236
+ infiniteScroll: infiniteScroll
234
237
  }))));
235
238
  };
236
239
  export default Grid;
@@ -0,0 +1,32 @@
1
+ import { type Table } from "@tanstack/react-table";
2
+ import type { CommandClick, ContextInfo, ContextMenuItem, PaginationConfig } from "../type";
3
+ import React from "react";
4
+ import type { Virtualizer } from "@tanstack/react-virtual";
5
+ import type { Column } from "@tanstack/react-table";
6
+ type Props<T> = {
7
+ prefix: string;
8
+ id: string;
9
+ tableContainerRef: React.RefObject<HTMLDivElement>;
10
+ height: number;
11
+ table: Table<T>;
12
+ summary?: boolean;
13
+ loading?: boolean;
14
+ commandClick?: (args: Omit<CommandClick<T>, 'rows'>) => void;
15
+ editAble?: boolean;
16
+ contextMenuItems?: ContextMenuItem[];
17
+ showEmptyText?: boolean;
18
+ contextMenuClick?: any;
19
+ contextMenuOpen?: (args: Omit<ContextInfo<T>, 'item'>) => void;
20
+ contextMenuHidden?: string[] | ((args?: Omit<ContextInfo<T>, 'item' | 'event'>) => string[]);
21
+ next?: () => void;
22
+ dataSource: T[];
23
+ pagination?: false | PaginationConfig;
24
+ infiniteScroll?: boolean;
25
+ columnVirtualizer: Virtualizer<HTMLDivElement, HTMLTableCellElement>;
26
+ virtualPaddingLeft: number | undefined;
27
+ virtualPaddingRight: number | undefined;
28
+ fixedLeftColumns: Column<T, unknown>[];
29
+ fixedRightColumns: Column<T, unknown>[];
30
+ };
31
+ declare const TableWrapper: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
32
+ export default TableWrapper;
@@ -0,0 +1,242 @@
1
+ import classNames from "classnames";
2
+ import TableHead from "../header/TableHead";
3
+ import TableBody from "../body/TableBody";
4
+ import TableFooter from "../footer/TableFooter";
5
+ import ComponentSpinner from "../../grid-component/LoadingSpinner";
6
+ import { Tooltip } from "react-tooltip";
7
+ import ContextMenu from "../ContextMenu";
8
+ import React, { useContext } from "react";
9
+ import { TableContext } from "../useContext";
10
+ const TableWrapper = props => {
11
+ const {
12
+ id,
13
+ prefix,
14
+ tableContainerRef,
15
+ height,
16
+ summary,
17
+ table,
18
+ loading,
19
+ commandClick,
20
+ editAble,
21
+ contextMenuItems: propContextMenuItems,
22
+ contextMenuHidden,
23
+ showEmptyText,
24
+ contextMenuClick,
25
+ contextMenuOpen,
26
+ next,
27
+ dataSource,
28
+ pagination,
29
+ infiniteScroll,
30
+ columnVirtualizer,
31
+ fixedLeftColumns,
32
+ fixedRightColumns,
33
+ virtualPaddingLeft,
34
+ virtualPaddingRight
35
+ } = props;
36
+ const menuRef = React.useRef(null);
37
+ const loadingRef = React.useRef(false);
38
+ const hasMoreRef = React.useRef(true);
39
+ const {
40
+ windowSize
41
+ } = useContext(TableContext);
42
+ const {
43
+ currentPage,
44
+ pageSize,
45
+ total
46
+ } = pagination ?? {};
47
+ const [menuVisible, setMenuVisible] = React.useState(false);
48
+ const [selectedRowData, setSelectedRowData] = React.useState(null);
49
+ const [position, setPosition] = React.useState({
50
+ x: 0,
51
+ y: 0,
52
+ viewportWidth: windowSize.innerWidth,
53
+ viewportHeight: windowSize.innerHeight
54
+ });
55
+ const contextMenuItems = React.useMemo(() => {
56
+ if (typeof contextMenuHidden === 'function' && propContextMenuItems && selectedRowData) {
57
+ const hiddenItems = contextMenuHidden({
58
+ rowInfo: {
59
+ rowData: selectedRowData
60
+ }
61
+ });
62
+ return propContextMenuItems.filter(item => !hiddenItems.includes(item?.key));
63
+ }
64
+ if (contextMenuHidden && typeof contextMenuHidden !== 'function' && propContextMenuItems) {
65
+ return propContextMenuItems.filter(item => !contextMenuHidden.includes(item?.key));
66
+ }
67
+ return propContextMenuItems;
68
+ }, [propContextMenuItems, contextMenuHidden, selectedRowData]);
69
+ const loadData = page => {
70
+ if (!hasMoreRef.current || loadingRef.current || loading) return;
71
+ loadingRef.current = true;
72
+ setTimeout(() => {
73
+ next?.();
74
+ if (page * pageSize >= total) {
75
+ hasMoreRef.current = false;
76
+ }
77
+ loadingRef.current = false;
78
+ }, 10);
79
+ };
80
+ const handleNext = () => {
81
+ loadData(currentPage + 1);
82
+ };
83
+ const handleScroll = e => {
84
+ if (infiniteScroll) {
85
+ if (loadingRef.current || loading || dataSource?.length === 0) {
86
+ e.stopPropagation();
87
+ e.preventDefault();
88
+ return;
89
+ }
90
+ const {
91
+ scrollHeight: tbScrollHeight,
92
+ scrollTop,
93
+ clientHeight
94
+ } = e.currentTarget;
95
+ const isEnd = scrollTop + clientHeight >= tbScrollHeight - 50;
96
+ if (isEnd && !loadingRef.current && hasMoreRef.current && dataSource?.length > 0) {
97
+ handleNext();
98
+ }
99
+ }
100
+ if (e.target.scrollLeft >= 0 && e.target.scrollLeft + e.target.clientWidth < e.target.scrollWidth) {
101
+ e.target.classList.add('ui-rc-table-ping-right');
102
+ } else {
103
+ e.target.classList.remove('ui-rc-table-ping-right');
104
+ }
105
+ if ((e.target.scrollLeft ?? 0) > 0) {
106
+ e.target.classList.add('ui-rc-table-ping-left');
107
+ } else {
108
+ e.target.classList.remove('ui-rc-table-ping-left');
109
+ }
110
+ };
111
+ const onContextMenu = data => event => {
112
+ event.preventDefault(); // Ngăn chặn menu mặc định của trình duyệt
113
+
114
+ setSelectedRowData(data);
115
+ contextMenuOpen?.({
116
+ rowInfo: {
117
+ rowData: data
118
+ },
119
+ event
120
+ });
121
+ setMenuVisible(true);
122
+
123
+ // Đợi DOM cập nhật và lấy kích thước menu
124
+ setTimeout(() => {
125
+ const menuElement = menuRef.current; // Lấy menu từ DOM
126
+ const menuWidth = menuElement?.offsetWidth || 200; // Mặc định 200px nếu chưa render
127
+ const menuHeight = menuElement?.offsetHeight; // Mặc định 450px nếu chưa render
128
+
129
+ // Điều chỉnh vị trí menu
130
+ let x = event.clientX;
131
+ let y = event.clientY;
132
+ if (x + menuWidth > windowSize.innerWidth) {
133
+ x = x - menuWidth - 10; // Cách cạnh phải 10px
134
+ }
135
+ if (y + menuHeight > windowSize.innerHeight) {
136
+ if (y < menuHeight) {
137
+ y = 10;
138
+ } else {
139
+ y = y - 10 - menuHeight; // Cách cạnh dưới 10px
140
+ }
141
+ }
142
+ setPosition(prevState => ({
143
+ ...prevState,
144
+ x,
145
+ y
146
+ }));
147
+ }, 100);
148
+ if (!menuVisible) {
149
+ document.addEventListener(`click`, function onClickOutside(e) {
150
+ const element = e.target;
151
+ const menuContainer = document.querySelector('.popup-context-menu');
152
+ const isInsideContainer = element.closest('.popup-context-menu') && menuContainer;
153
+ if (isInsideContainer) {
154
+ return;
155
+ }
156
+ setMenuVisible(false);
157
+ setPosition(prevState => ({
158
+ ...prevState,
159
+ x: undefined,
160
+ y: undefined
161
+ }));
162
+ document.removeEventListener(`click`, onClickOutside);
163
+ });
164
+ }
165
+ };
166
+ return /*#__PURE__*/React.createElement("div", {
167
+ style: {
168
+ position: 'relative'
169
+ }
170
+ }, /*#__PURE__*/React.createElement("div", {
171
+ className: classNames(`${prefix}-grid-container`, {
172
+ 'ui-rc-table-ping-right': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) >= 0 && (tableContainerRef.current?.scrollLeft ?? 0) + (tableContainerRef.current?.clientWidth ?? 0) < (tableContainerRef.current?.scrollWidth ?? 0),
173
+ 'ui-rc-table-ping-left': tableContainerRef && (tableContainerRef.current?.scrollLeft ?? 0) > 0
174
+ }),
175
+ id: id,
176
+ ref: tableContainerRef,
177
+ style: {
178
+ overflow: 'auto',
179
+ //our scrollable table container
180
+ position: 'relative',
181
+ //needed for sticky header
182
+ // height: tableHeight ?? '500px' //should be a fixed height
183
+ maxHeight: height //should be a fixed height
184
+ // minWidth: table.getTotalSize()
185
+ }
186
+ // onScroll={infiniteScroll ? handleScroll : undefined}
187
+ ,
188
+ onScroll: handleScroll
189
+ }, /*#__PURE__*/React.createElement("table", {
190
+ style: {
191
+ display: 'grid'
192
+ // minWidth: table.getTotalSize()
193
+ }
194
+ }, /*#__PURE__*/React.createElement(TableHead, {
195
+ tableContainerRef: tableContainerRef,
196
+ table: table,
197
+ columnVirtualizer: columnVirtualizer,
198
+ virtualPaddingLeft: virtualPaddingLeft,
199
+ virtualPaddingRight: virtualPaddingRight,
200
+ fixedLeftColumns: fixedLeftColumns,
201
+ fixedRightColumns: fixedRightColumns
202
+ }), /*#__PURE__*/React.createElement(TableBody, {
203
+ tableId: id,
204
+ table: table,
205
+ tableContainerRef: tableContainerRef,
206
+ commandClick: commandClick,
207
+ editAble: editAble,
208
+ contextMenuItems: contextMenuItems,
209
+ showEmptyText: showEmptyText,
210
+ onContextMenu: onContextMenu,
211
+ columnVirtualizer: columnVirtualizer,
212
+ virtualPaddingLeft: virtualPaddingLeft,
213
+ virtualPaddingRight: virtualPaddingRight,
214
+ fixedLeftColumns: fixedLeftColumns,
215
+ fixedRightColumns: fixedRightColumns
216
+ }), summary && /*#__PURE__*/React.createElement(TableFooter
217
+ // columnVirtualizer={columnVirtualizer}
218
+ , {
219
+ table: table
220
+ // virtualPaddingLeft={virtualPaddingLeft}
221
+ // virtualPaddingRight={virtualPaddingRight}
222
+ // fixedLeftColumns={fixedLeftColumns}
223
+ // fixedRightColumns={fixedRightColumns}
224
+ }))), loading && /*#__PURE__*/React.createElement("div", {
225
+ className: "spinner-loading"
226
+ }, /*#__PURE__*/React.createElement(ComponentSpinner, null)), /*#__PURE__*/React.createElement(Tooltip, {
227
+ id: `${id}-tooltip-content`,
228
+ style: {
229
+ zIndex: 1999,
230
+ maxWidth: 450
231
+ }
232
+ }), menuVisible && /*#__PURE__*/React.createElement(ContextMenu, {
233
+ open: menuVisible,
234
+ pos: position,
235
+ setOpen: setMenuVisible,
236
+ menuRef: menuRef,
237
+ contextMenuItems: contextMenuItems,
238
+ contextMenuClick: contextMenuClick,
239
+ rowData: selectedRowData
240
+ }));
241
+ };
242
+ export default TableWrapper;
@@ -220,7 +220,7 @@ export type TableProps<RecordType = AnyObject> = {
220
220
  showToolbar?: boolean;
221
221
  onDataChange?: (data: RecordType[]) => void;
222
222
  defaultValue?: AnyObject | (() => AnyObject);
223
- summary?: boolean | ((data: readonly RecordType[]) => React.ReactNode);
223
+ summary?: boolean;
224
224
  showEmptyText?: boolean;
225
225
  commandSettings?: CommandSettings;
226
226
  onCellPaste?: ICellPasteModel<RecordType>;
@@ -236,7 +236,7 @@ export type TableProps<RecordType = AnyObject> = {
236
236
  }) => void;
237
237
  wrapSettings?: IWrapSettings;
238
238
  actionTemplate?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
239
- commandClick?: (args: CommandClick) => void;
239
+ commandClick?: (args: CommandClick<RecordType>) => void;
240
240
  expandable?: ExpandableConfig<RecordType>;
241
241
  fullScreen?: boolean;
242
242
  };
@@ -270,12 +270,12 @@ export interface RenderExpandIconProps<RecordType> {
270
270
  export type TriggerEventHandler<RecordType> = (record: RecordType, event: React.MouseEvent<HTMLElement>) => void;
271
271
  export type RowClassName<RecordType> = (record: RecordType, index: number, indent: number) => string;
272
272
  export type ExpandedRowRender<ValueType> = (record: ValueType, index: number, indent: number, expanded: boolean) => React.ReactNode;
273
- export type CommandClick = {
273
+ export type CommandClick<T> = {
274
274
  id: string;
275
275
  rowId: string;
276
276
  rowData: any;
277
277
  index: number;
278
- rows?: any[];
278
+ rows: T[];
279
279
  };
280
280
  export type IEditSelectSettings = {
281
281
  fieldKey?: string;
@@ -27,6 +27,10 @@ export interface IContext<T> {
27
27
  setFilterChange: Dispatch<SetStateAction<boolean>>;
28
28
  onContextMenu?: (data: T) => (event: any) => void;
29
29
  locale?: Locale;
30
+ windowSize: {
31
+ innerHeight: number;
32
+ innerWidth: number;
33
+ };
30
34
  control?: any;
31
35
  errors?: any;
32
36
  handleSubmit?: any;
@@ -6,6 +6,10 @@ export const TableContext = /*#__PURE__*/createContext({
6
6
  dataSource: [],
7
7
  originData: [],
8
8
  expanded: {},
9
+ windowSize: {
10
+ innerHeight: 0,
11
+ innerWidth: 0
12
+ },
9
13
  // triggerFilter: () => { },
10
14
 
11
15
  setIsSelectionChange: () => {},
@@ -193,6 +193,7 @@ const InternalTable = props => {
193
193
  wrapSettings,
194
194
  onFilter,
195
195
  onSorter,
196
+ defaultSorter,
196
197
  ...rest
197
198
  } = props;
198
199
  const id = _react.default.useMemo(() => {
@@ -306,6 +307,7 @@ const InternalTable = props => {
306
307
  setColumns(propsColumns);
307
308
  }, [propsColumns]);
308
309
  const handleOnFilter = queries => {
310
+ console.log('queries', queries);
309
311
  if (onFilter) {
310
312
  onFilter?.((0, _hooks.convertFilters)(queries));
311
313
  } else {
@@ -338,30 +340,6 @@ const InternalTable = props => {
338
340
  // @ts-ignore
339
341
  return record => record?.[rowKey];
340
342
  }, [rowKey]);
341
-
342
- // const [transformSelectionColumns] = useColumns<RecordType>(
343
- // {
344
- // locale,
345
- // t,
346
- // rowKey,
347
- // // dataSource: mergerdData,
348
- // dataSource,
349
- // buddhistLocale,
350
- // dataSourceFilter: propDataSourceFilter,
351
- // format,
352
- // sortMultiple,
353
- // groupAble,
354
- // groupSetting,
355
- // groupColumns,
356
- // handleResize,
357
- // // onMouseHover
358
- // },
359
- // );
360
-
361
- // const mergedColumns: any = React.useMemo(() => {
362
- // return transformSelectionColumns(columns)
363
- // }, [columns, transformSelectionColumns])
364
-
365
343
  const firstNonGroupColumn = (0, _columns.flatColumns2)(columns).find(col => col.field && col.field !== '#' && !groupColumns?.includes(col.field) && col.hidden !== true);
366
344
  const nonGroupColumns = (0, _columns.flatColumns2)(columns).filter(col => col.field && col.field !== '#' && !groupColumns?.includes(col.field) && col.hidden !== true);
367
345
  const getColumnSearchProps = (0, _react.useCallback)(column => ({
@@ -375,6 +353,8 @@ const InternalTable = props => {
375
353
  searchValue,
376
354
  setSearchValue
377
355
  }) => {
356
+ // console.log('selectedKeys', selectedKeys)
357
+
378
358
  const type = (0, _hooks.getTypeFilter)(column);
379
359
  // const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? booleanOperator : (!type || type === 'Text' ? stringOperator : numberOperator)
380
360
 
@@ -410,6 +390,10 @@ const InternalTable = props => {
410
390
  type: "primary",
411
391
  onClick: () => {
412
392
  // confirm({closeDropdown: false})
393
+ const typeFilter = (0, _hooks.getTypeFilter)(column);
394
+ if ((!typeFilter || typeFilter === 'Text') && (0, _hooks.isNullOrUndefined)(selectedKeys[0])) {
395
+ setSelectedKeys(['']);
396
+ }
413
397
  confirm();
414
398
  // handleSearch(selectedKeys as string[], confirm)
415
399
  },
@@ -468,7 +452,9 @@ const InternalTable = props => {
468
452
  id: id,
469
453
  wrapSettings: wrapSettings
470
454
  })),
471
- ellipsis: column.ellipsis !== false,
455
+ ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
456
+ // ellipsis: column.ellipsis !== false,
457
+
472
458
  align: column.textAlign ?? column.align,
473
459
  fixed: column.fixedType ?? column.fixed,
474
460
  isSummary: column.isSummary ?? column.haveSum,
@@ -527,15 +513,19 @@ const InternalTable = props => {
527
513
  ...(transformedColumn.allowFiltering === false ? {} : {
528
514
  ...getColumnSearchProps(column)
529
515
  }),
530
- sorter: column.sorter === false ? undefined : {
531
- // @ts-ignore
532
- compare: (a, b) => onSorter ? a : a[column.field] - b[column.field],
533
- multiple: sortMultiple ? colIndex : undefined
534
- },
516
+ // sorter: (column.sorter === false ? undefined : {
517
+ // // @ts-ignore
518
+ // compare: (a: any, b: any) => onSorter ? a : a[column.field] - b[column.field],
519
+ // multiple: sortMultiple ? colIndex : undefined
520
+
521
+ // }),
522
+ // @ts-ignore
523
+ sorter: (a, b) => a[column.field] - b[column.field],
535
524
  sortIcon: args => {
536
525
  const {
537
526
  sortOrder
538
527
  } = args;
528
+ console.log('sortOrder', sortOrder);
539
529
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, !sortOrder && /*#__PURE__*/_react.default.createElement(_becoxyIcons.SortCancel, {
540
530
  fontSize: 15,
541
531
  style: {
@@ -574,7 +564,8 @@ const InternalTable = props => {
574
564
  id: `${column.field}`,
575
565
  width: column.width,
576
566
  onResize: handleResize?.(column),
577
- className: column.headerTextAlign === 'center' ? 'head-align-center' : column.headerTextAlign === 'right' ? 'head-align-right' : ''
567
+ className: `${column.headerTextAlign === 'center' ? 'head-align-center' : column.headerTextAlign === 'right' ? 'head-align-right' : ''}
568
+ ${wrapSettings && wrapSettings.wrapMode === 'Content' ? 'ui-rc-table-cell-ellipsis' : ''}`
578
569
  }),
579
570
  onCell: (data, index) => {
580
571
  return {
@@ -611,10 +602,11 @@ const InternalTable = props => {
611
602
  }
612
603
  return (0, _columns.renderContent)(column, value, record, rowIndex, colIndex, false, cellFormat);
613
604
  },
605
+ defaultSortOrder: 'ascend',
614
606
  hidden: groupSetting && groupSetting.hiddenColumnGroup === false ? transformedColumn.hidden : groupAble && groupColumns && groupColumns.includes(column.field) ? true : transformedColumn.hidden
615
607
  };
616
608
  });
617
- }, [columns, t, id, wrapSettings, getColumnSearchProps, sortMultiple, groupSetting, groupAble, groupColumns, mergedData, filterStates, mergedFilterKeys, pagination, handleResize, firstNonGroupColumn?.field, nonGroupColumns, format]);
609
+ }, [columns, t, id, wrapSettings, editAble, getColumnSearchProps, groupSetting, groupAble, groupColumns, mergedData, filterStates, mergedFilterKeys, pagination, handleResize, firstNonGroupColumn?.field, nonGroupColumns, format]);
618
610
  const transformColumns = _react.default.useCallback(cols => {
619
611
  return cols.map(column => {
620
612
  const find = convertColumns.find(it => it.field === column.field);
@@ -635,11 +627,13 @@ const InternalTable = props => {
635
627
  id: id,
636
628
  wrapSettings: wrapSettings
637
629
  })),
638
- ellipsis: column.ellipsis !== false,
630
+ // ellipsis: column.ellipsis !== false,
631
+ ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
639
632
  align: column.textAlign ?? column.align,
640
633
  fixed: column.fixedType ?? column.fixed,
641
634
  isSummary: column.isSummary ?? column.haveSum,
642
- hidden: column.hidden ?? column.visible === false
635
+ hidden: column.hidden ?? column.visible === false,
636
+ defaultSortOrder: 'ascend'
643
637
  };
644
638
 
645
639
  // Xử lý đệ quy cho children
@@ -662,7 +656,7 @@ const InternalTable = props => {
662
656
  };
663
657
  }
664
658
  });
665
- }, [convertColumns, id, t, wrapSettings]);
659
+ }, [convertColumns, editAble, id, t, wrapSettings]);
666
660
  const mergedColumns = _react.default.useMemo(() => {
667
661
  return transformColumns(columns);
668
662
  }, [columns, transformColumns]);
@@ -914,6 +908,7 @@ const InternalTable = props => {
914
908
  }
915
909
  };
916
910
  const handleChange = (paging, filters, sorter) => {
911
+ console.log('sorter', sorter);
917
912
  onSorter?.(sorter);
918
913
  };
919
914
 
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import type { GridTableProps } from "./type";
3
+ declare const TempTable: <RecordType extends object>(props: GridTableProps<RecordType>) => React.JSX.Element;
4
+ export default TempTable;
@@ -0,0 +1,30 @@
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 _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _tableComponent = _interopRequireDefault(require("../table-component"));
11
+ var _InternalTable = _interopRequireDefault(require("./InternalTable"));
12
+ 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); }
13
+ 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; }
14
+ const TempTable = props => {
15
+ const {
16
+ infiniteScroll,
17
+ groupAble,
18
+ editAble,
19
+ ...rest
20
+ } = props;
21
+ const TabComponent = groupAble ? _InternalTable.default : _tableComponent.default;
22
+ // const TabComponent = editAble ? Table : InternalTable
23
+
24
+ return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(TabComponent, (0, _extends2.default)({}, rest, {
25
+ infiniteScroll: infiniteScroll,
26
+ groupAble: groupAble,
27
+ editAble: editAble
28
+ })));
29
+ };
30
+ var _default = exports.default = TempTable;
@@ -513,7 +513,9 @@ const renderFilter = (column, selectedKeys, setSelectedKeys, confirm, visible, s
513
513
  }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Input, {
514
514
  placeholder: t ? t('Search') : `Search`,
515
515
  value: selectedKeys[0],
516
- onChange: e => setSelectedKeys(e.target.value ? [e.target.value] : [])
516
+ onChange: e => {
517
+ setSelectedKeys(e.target.value ? [e.target.value] : ['']);
518
+ }
517
519
  // onPressEnter={() => handleSearch(selectedKeys as string[], confirm)}
518
520
  ,
519
521
  onPressEnter: () => confirm(),
@@ -1,5 +1,5 @@
1
- import InternalTable from './InternalTable';
1
+ import TempTable from './TempTable';
2
2
  import type { ColumnsTable, TableProps, ColumnTable, CommandItem, ContextMenuItem } from './type';
3
3
  import type { ToolbarItem } from "rc-master-ui/es/toolbar";
4
4
  export type { ColumnsTable, TableProps, ColumnTable, ToolbarItem, CommandItem, ContextMenuItem };
5
- export default InternalTable;
5
+ export default TempTable;
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.default = void 0;
8
- var _InternalTable = _interopRequireDefault(require("./InternalTable"));
9
- // import ConvertColumnTable from './ConvertColumnTable'
10
- var _default = exports.default = _InternalTable.default; // export default ConvertColumnTable
8
+ var _TempTable = _interopRequireDefault(require("./TempTable"));
9
+ // import InternalTable from './InternalTable'
10
+ //
11
+ // export default InternalTable
12
+ var _default = exports.default = _TempTable.default;
@@ -1433,7 +1433,6 @@ $fontFamily: "Montserrat",Helvetica,Arial,serif !default;
1433
1433
  .rc-fullscreen {
1434
1434
  background-color: #ffffff85;
1435
1435
  }
1436
-
1437
1436
  .be-popup-container {
1438
1437
  z-index: 1070 !important;
1439
1438
  }