es-grid-template 1.8.56 → 1.8.58

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 (52) hide show
  1. package/es/grid-component/InternalTable.js +12 -5
  2. package/es/grid-component/TableGrid.js +2 -2
  3. package/es/grid-component/hooks/useColumns.d.ts +3 -1
  4. package/es/grid-component/hooks/useColumns.js +2 -1
  5. package/es/grid-component/hooks/utils.d.ts +1 -1
  6. package/es/grid-component/hooks/utils.js +4 -9
  7. package/es/grid-component/type.d.ts +13 -0
  8. package/es/table-component/InternalTable.js +0 -5
  9. package/es/table-component/TableContainer.js +10 -11
  10. package/es/table-component/TableContainerEdit.js +4 -2
  11. package/es/table-component/body/TableBodyCell.js +12 -53
  12. package/es/table-component/body/TableBodyRow.js +7 -12
  13. package/es/table-component/footer/TableFooterCell.js +0 -4
  14. package/es/table-component/footer/TableFooterRow.js +6 -3
  15. package/es/table-component/header/TableHead.js +4 -1
  16. package/es/table-component/header/TableHeadCell2.js +7 -48
  17. package/es/table-component/header/TableHeadGroupCell.js +13 -225
  18. package/es/table-component/header/TableHeadRow.js +7 -19
  19. package/es/table-component/hook/useColumns.js +17 -3
  20. package/es/table-component/hook/utils.js +0 -17
  21. package/es/table-component/style.d.ts +22 -0
  22. package/es/table-component/style.js +48 -0
  23. package/es/table-component/style.scss +33 -71
  24. package/es/table-component/table/Grid.js +14 -7
  25. package/es/table-component/type.d.ts +13 -2
  26. package/es/table-component/useContext.d.ts +4 -1
  27. package/lib/grid-component/InternalTable.js +11 -5
  28. package/lib/grid-component/TableGrid.js +2 -2
  29. package/lib/grid-component/hooks/useColumns.js +2 -1
  30. package/lib/grid-component/hooks/utils.d.ts +1 -1
  31. package/lib/grid-component/hooks/utils.js +4 -9
  32. package/lib/grid-component/type.d.ts +13 -0
  33. package/lib/table-component/InternalTable.js +0 -6
  34. package/lib/table-component/TableContainer.js +10 -14
  35. package/lib/table-component/TableContainerEdit.js +4 -2
  36. package/lib/table-component/body/TableBodyCell.js +12 -53
  37. package/lib/table-component/body/TableBodyRow.js +7 -12
  38. package/lib/table-component/footer/TableFooterCell.js +0 -6
  39. package/lib/table-component/footer/TableFooterRow.js +6 -3
  40. package/lib/table-component/header/TableHead.js +4 -1
  41. package/lib/table-component/header/TableHeadCell2.js +7 -48
  42. package/lib/table-component/header/TableHeadGroupCell.js +11 -223
  43. package/lib/table-component/header/TableHeadRow.js +7 -20
  44. package/lib/table-component/hook/useColumns.js +17 -3
  45. package/lib/table-component/hook/utils.js +0 -17
  46. package/lib/table-component/style.d.ts +22 -0
  47. package/lib/table-component/style.js +55 -0
  48. package/lib/table-component/style.scss +33 -71
  49. package/lib/table-component/table/Grid.js +14 -7
  50. package/lib/table-component/type.d.ts +13 -2
  51. package/lib/table-component/useContext.d.ts +4 -1
  52. package/package.json +1 -1
@@ -8,7 +8,10 @@ updateOrInsert } from "./hooks";
8
8
  import dayjs from "dayjs";
9
9
  import 'dayjs/locale/es';
10
10
  import 'dayjs/locale/vi';
11
- import GridEdit from "./table/GridEdit";
11
+
12
+ // import GridEdit from "./table/GridEdit"
13
+ // import InfiniteTable from "./table/InfiniteTable";
14
+
12
15
  import Grid from "./table/Grid";
13
16
  import en from "rc-master-ui/es/date-picker/locale/en_US";
14
17
  import vi from "rc-master-ui/es/date-picker/locale/vi_VN";
@@ -37,7 +40,6 @@ import { arrayMove, horizontalListSortingStrategy, SortableContext, useSortable
37
40
  // import {CSS} from "@dnd-kit/utilities";
38
41
  import { Resizable } from "react-resizable";
39
42
  import { faker } from "@faker-js/faker";
40
- import InfiniteTable from "./table/InfiniteTable";
41
43
  import useMergedState from "rc-util/es/hooks/useMergedState";
42
44
  import Modal from 'antd/es/modal/Modal';
43
45
  dayjs.extend(customParseFormat);
@@ -186,6 +188,7 @@ const InternalTable = props => {
186
188
  onFilter,
187
189
  onSorter,
188
190
  defaultSorter,
191
+ toolbarItems,
189
192
  ...rest
190
193
  } = props;
191
194
  const id = React.useMemo(() => {
@@ -293,7 +296,7 @@ const InternalTable = props => {
293
296
  const hhh = (totalHeight ?? 0) - (title ? title.offsetHeight : 0) - (header ? header.offsetHeight : 0) - (paginationE ? paginationE.offsetHeight : 0) - (toolbar ? toolbar.offsetHeight : 0) - (summaryE ? summaryE.offsetHeight : 0) - (scrollbar ? scrollbar.offsetHeight : 0);
294
297
  setHeight1(hhh > 0 ? hhh : 0);
295
298
  }
296
- }, [id, isFullScreen, windowSize.innerHeight]);
299
+ }, [id, isFullScreen, windowSize.innerHeight, toolbarItems]);
297
300
  const tableRef = React.useRef(null);
298
301
  React.useEffect(() => {
299
302
  setColumns(propsColumns);
@@ -442,7 +445,8 @@ const InternalTable = props => {
442
445
  wrapSettings: wrapSettings
443
446
  })),
444
447
  // ellipsis: editAble || column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
445
- ellipsis: column.ellipsis !== false || wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
448
+ ellipsis: column.ellipsis !== false && wrapSettings && wrapSettings.wrapMode !== 'Content' && wrapSettings.wrapMode !== 'Both',
449
+ // ellipsis: false,
446
450
  // ellipsis: column.ellipsis !== false,
447
451
 
448
452
  align: column.textAlign ?? column.align,
@@ -910,7 +914,9 @@ const InternalTable = props => {
910
914
  const handleFullScreen = () => {
911
915
  setIsFullScreen(!isFullScreen);
912
916
  };
913
- const TableComponent = infiniteScroll ? InfiniteTable : groupAble ? Group : editAble ? GridEdit : Grid;
917
+
918
+ // const TableComponent = infiniteScroll ? InfiniteTable : (groupAble ? Group : editAble ? GridEdit : Grid)
919
+ const TableComponent = groupAble ? Group : Grid;
914
920
  return /*#__PURE__*/React.createElement(Fragment, null, true && /*#__PURE__*/React.createElement(DndContext, {
915
921
  sensors: sensors,
916
922
  modifiers: [restrictToHorizontalAxis],
@@ -1069,6 +1075,7 @@ const InternalTable = props => {
1069
1075
  commandClick: triggerCommandClick,
1070
1076
  summary: summary,
1071
1077
  pagination: pagination,
1078
+ toolbarItems: toolbarItems,
1072
1079
  scroll: scrollHeight1 - (summary ? 1 : 1) < 0 ? {
1073
1080
  y: 500
1074
1081
  } : {
@@ -62,7 +62,7 @@ const TableGrid = props => {
62
62
  rowHoverable,
63
63
  title,
64
64
  format,
65
- virtual = true,
65
+ // virtual = true,
66
66
  t,
67
67
  lang,
68
68
  contextMenuOpen,
@@ -322,7 +322,7 @@ const TableGrid = props => {
322
322
  'table-none-column-select': selectionSettings?.mode === undefined && selectionSettings?.type !== 'multiple'
323
323
  }, styles.customTable),
324
324
  bordered: true,
325
- virtual: virtual,
325
+ virtual: true,
326
326
  columns: columns,
327
327
  rowKey: rowKey,
328
328
  rowHoverable: rowHoverable,
@@ -15,5 +15,7 @@ interface UseColumnsConfig<RecordType> {
15
15
  rowKey?: any;
16
16
  onMouseHover?: any;
17
17
  }
18
- declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig<RecordType>) => readonly [any];
18
+ declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig<RecordType>) => readonly [
19
+ any
20
+ ];
19
21
  export default useColumns;
@@ -80,7 +80,8 @@ const useColumns = config => {
80
80
  const type = getTypeFilter(column);
81
81
  // const operatorOptions = !type || type === 'Text' ? stringOperator : numberOperator
82
82
  // const operatorOptions = type === 'Checkbox' || type === 'Dropdown' || type === 'DropTree' || ty
83
- const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? booleanOperator : !type || type === 'Text' ? stringOperator : numberOperator;
83
+ // const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? booleanOperator : (!type || type === 'Text' ? stringOperator : numberOperator)
84
+ const operatorOptions = ['Checkbox', 'Dropdown', 'DropTree', 'CheckboxDropdown'].includes(type) ? booleanOperator : !type || type === 'Text' ? stringOperator : numberOperator;
84
85
  return /*#__PURE__*/React.createElement("div", {
85
86
  style: {
86
87
  padding: 8,
@@ -160,7 +160,7 @@ export declare const showDraggingPoint: (selectedCells: any, id?: any) => void;
160
160
  export declare const hideDraggingPoint: (selectedCells: any, id?: any) => void;
161
161
  export declare const isRangeCell: (selectedCells: any, type: string, rowIndex: number, colIndex: number) => boolean;
162
162
  export declare const isSelectedCell: (selectedCells: any, rowIndex: number, colIndex: number) => any;
163
- export declare function groupArrayByColumns(arr: any[], columns: string[] | undefined): any;
163
+ export declare function groupArrayByColumns(data: any[], columns: string[] | undefined): any;
164
164
  export declare const isFormattedNumber: (str: string) => boolean;
165
165
  export declare const detectSeparators: (str: string) => {
166
166
  thousandSeparator: string;
@@ -2341,13 +2341,13 @@ export const isSelectedCell = (selectedCells, rowIndex, colIndex) => {
2341
2341
  const key = `${rowIndex}-${colIndex}`;
2342
2342
  return selectedCells.has(key);
2343
2343
  };
2344
- export function groupArrayByColumns(arr, columns) {
2344
+ export function groupArrayByColumns(data, columns) {
2345
2345
  const result = [];
2346
2346
  const checkEmpty = d => {
2347
2347
  return d === null || d === undefined || d === '';
2348
2348
  };
2349
2349
  if (columns) {
2350
- arr.forEach(item => {
2350
+ data.forEach(item => {
2351
2351
  let currentLevel = result;
2352
2352
  columns.forEach((column, index) => {
2353
2353
  const value = item[column];
@@ -2355,15 +2355,12 @@ export function groupArrayByColumns(arr, columns) {
2355
2355
  if (existingItem) {
2356
2356
  currentLevel = existingItem.children;
2357
2357
  } else {
2358
- // const newItem = {[column]: value, field: column, rowId: !isEmpty(value) ? (value) : newGuid(), parentId: !isEmpty(item[columns[index - 1]]) ? (item[columns[index - 1]]) : null, indent: index, children: [] }
2359
2358
  const newItem = {
2360
2359
  [column]: value,
2361
2360
  field: column,
2362
2361
  rowId: newGuid(),
2363
- // rowId: item[column],
2364
2362
  parentId: !isEmpty(item[columns[index - 1]]) ? item[columns[index - 1]] : null,
2365
- // parentId: item.rowId[index - 1],
2366
- // indent: index,
2363
+ // tự tính tổng rồi điền thuộc tính vào
2367
2364
  children: []
2368
2365
  };
2369
2366
  currentLevel.push(newItem);
@@ -2374,13 +2371,11 @@ export function groupArrayByColumns(arr, columns) {
2374
2371
  ...item,
2375
2372
  rowId: item.id ?? item.rowId,
2376
2373
  parentId: !checkEmpty(columns[columns.length - 1]) ? item[columns[columns.length - 1]] : null
2377
- // parentId: item.rowId[columns.length - 1],
2378
- // indent: columns.length
2379
2374
  });
2380
2375
  });
2381
2376
  return result;
2382
2377
  } else {
2383
- return arr;
2378
+ return data;
2384
2379
  }
2385
2380
  }
2386
2381
  export const isFormattedNumber = str => {
@@ -9,6 +9,7 @@ import type { FieldNames, FilterFunc } from "rc-select/es/Select";
9
9
  import type { ColorPickerProps } from "antd";
10
10
  import type { FixedType } from "rc-base-table/lib/interface";
11
11
  import type { TableLocale } from "rc-master-ui/lib/table/interface";
12
+ import type { Cell, Header, Row } from '@tanstack/react-table';
12
13
  export type IColumnType = "number" | "time" | "date" | "week" | "month" | "file" | "quarter" | "year" | "datetime" | "string" | "boolean" | "checkbox" | "color" | null | undefined;
13
14
  export type AnyObject = Record<PropertyKey, any>;
14
15
  export type SelectMode = 'checkbox' | 'radio' | undefined;
@@ -135,6 +136,10 @@ export type ColumnTable<RecordType = AnyObject> = Omit<RcColumnType<RecordType>,
135
136
  editFromSettings?: IEditFromSettings;
136
137
  fixedType?: FixedType;
137
138
  headerTextWrap?: boolean;
139
+ allowSelection?: boolean | ((rowData: RecordType) => boolean);
140
+ onCellStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, cell: Cell<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
141
+ onCellHeaderStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cell: Header<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
142
+ onCellFooterStyles?: Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'> | ((cellValue: any, cell: Header<RecordType, unknown>) => Omit<React.CSSProperties, 'display' | 'width' | 'minWidth' | 'left' | 'right' | 'position'>);
138
143
  };
139
144
  export type IFormOpen = {
140
145
  value?: any;
@@ -193,6 +198,11 @@ export type Sort = {
193
198
  export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<RecordType>, 'columns' | 'rowSelection' | 'loading' | 'dataSource' | 'summary' | 'pagination' | 'locale'> {
194
199
  editAble?: boolean;
195
200
  infiniteScroll?: boolean;
201
+ theme?: {
202
+ theme?: 'dark' | 'light';
203
+ backgroundColor?: string;
204
+ color?: string;
205
+ };
196
206
  next?: () => void;
197
207
  locale?: Locale;
198
208
  groupAble?: boolean;
@@ -266,6 +276,9 @@ export interface TableProps<RecordType = AnyObject> extends Omit<RcTableProps<Re
266
276
  wrapSettings?: IWrapSettings;
267
277
  actionTemplate?: ReactNode | ReactElement | (() => ReactNode | ReactElement);
268
278
  fullScreen?: boolean;
279
+ onRowStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | ((data: RecordType, row: Row<RecordType>) => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
280
+ onRowHeaderStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
281
+ onRowFooterStyles?: Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'> | (() => Omit<React.CSSProperties, 'display' | 'transform' | 'gridTemplateColumns' | 'height' | 'minHeight'>);
269
282
  }
270
283
  export type PaginationConfig = TablePaginationConfig & {
271
284
  currentPage?: number;
@@ -34,14 +34,9 @@ import { addRowIdArray, convertFlatColumn1, convertToObj, convertToObjTrue,
34
34
  filterDataByColumns, findAllChildrenKeys2, flatColumns2,
35
35
  // filterDataByColumns,
36
36
  getAllRowKey, getDiffent2Array, getFixedFields, getInvisibleColumns, groupArrayByColumns, isTreeArray, updateWidthsByOther } from "./hook/utils";
37
- // import GridEdit from './table/GridEdit'
38
37
  import { convertToTanStackColumns } from "./hook/useColumns";
39
38
  import { convertColumns } from "./hook/convert";
40
39
  import { removeInvisibleColumns } from "../grid-component/hooks";
41
- // import { Modal } from 'antd'
42
- // import { findAllChildrenKeys2 } from '../grid-component/hooks'
43
- // import { columns111 } from '../test-2/columns'
44
-
45
40
  dayjs.extend(customParseFormat);
46
41
 
47
42
  // const MySwal = withReactContent(Swal)
@@ -1,23 +1,12 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- // import type { Dispatch, SetStateAction } from "react";
3
-
4
2
  import React from 'react';
5
- // import TableHead from './header/TableHead'
6
- // import { sumSize } from './hook/utils'
7
-
8
- // import { useVirtualizer } from '@tanstack/react-virtual'
9
-
10
3
  import classNames from 'classnames';
11
- // import TableBody from './body/TableBody'
12
4
  import { TableContext } from "./useContext";
13
5
  import Pagination from 'rc-master-ui/es/pagination';
14
6
  import { Toolbar } from 'rc-master-ui';
15
7
  import { Maximize, Minimize } from 'becoxy-icons';
16
8
  import { ColumnsChoose } from "./ColumnsChoose";
17
- // import TableFooter from './footer/TableFooter'
18
- // import TableBody from './body/TableBody'
19
9
  import { numericFormatter } from 'react-numeric-component';
20
- // import ComponentSpinner from '../grid-component/LoadingSpinner'
21
10
  import TableWrapper from "./table/TableWrapper";
22
11
  import { getTableHeight, sumSize, updateColumnWidthsRecursive } from "./hook/utils";
23
12
  import { useVirtualizer } from '@tanstack/react-virtual';
@@ -76,6 +65,9 @@ const TableContainer = props => {
76
65
  columnSizing,
77
66
  columnSizingInfo,
78
67
  rowClassName,
68
+ onRowStyles,
69
+ onRowFooterStyles,
70
+ onRowHeaderStyles,
79
71
  title
80
72
  } = props;
81
73
  const tableContainerRef = React.useRef(null);
@@ -96,6 +88,10 @@ const TableContainer = props => {
96
88
  React.useEffect(() => {
97
89
  const handleClickOutside = () => {
98
90
  setFocusedCell(undefined);
91
+ setIsSelectionChange(prev => ({
92
+ ...prev,
93
+ isChange: false
94
+ }));
99
95
  };
100
96
  document.addEventListener('mousedown', handleClickOutside);
101
97
  return () => {
@@ -270,6 +266,9 @@ const TableContainer = props => {
270
266
  focusedCell,
271
267
  setFocusedCell,
272
268
  rowClassName,
269
+ onRowStyles,
270
+ onRowFooterStyles,
271
+ onRowHeaderStyles,
273
272
  table,
274
273
  pagination
275
274
  }
@@ -125,7 +125,8 @@ const TableContainerEdit = props => {
125
125
  setColumns,
126
126
  columnSizing,
127
127
  columnSizingInfo,
128
- rowClassName
128
+ rowClassName,
129
+ onRowStyles
129
130
  } = props;
130
131
  const containerRef = React.useRef(null);
131
132
  const bottomToolbarRef = React.useRef(null);
@@ -1895,7 +1896,8 @@ const TableContainerEdit = props => {
1895
1896
  handleCellClick,
1896
1897
  pagination,
1897
1898
  rowClassName,
1898
- rowEditable
1899
+ rowEditable,
1900
+ onRowStyles
1899
1901
  }
1900
1902
  }, /*#__PURE__*/React.createElement(TableWrapper, {
1901
1903
  contextMenuItems: contextMenuItems,
@@ -168,6 +168,7 @@ const TableBodyCell = props => {
168
168
  const [isOpenTooltip, setIsOpenTooltip] = React.useState(false);
169
169
  const record = cell.row.original;
170
170
  const columnMeta = cell.column.columnDef.meta ?? {};
171
+ const cellStyles = typeof columnMeta.onCellStyles === 'function' ? columnMeta.onCellStyles(cell.getValue(), cell) : columnMeta.onCellStyles;
171
172
 
172
173
  // const tooltipContent = (isOpenTooltip === false || columnMeta.type === 'checkbox') ? '' : flexRender(cell.column.columnDef.cell, cell.getContext());
173
174
  const tooltipContent = isOpenTooltip === false ? '' : columnMeta?.tooltipDescription ? typeof columnMeta.tooltipDescription === 'function' ? columnMeta.tooltipDescription({
@@ -180,6 +181,7 @@ const TableBodyCell = props => {
180
181
  const isPinned = cell.column.getIsPinned();
181
182
  const isLastLeftPinnedColumn = isPinned === "left" && cell.column.getIsLastColumn("left");
182
183
  const isFirstRightPinnedColumn = isPinned === "right" && cell.column.getIsFirstColumn("right");
184
+ const enableClick = typeof columnMeta.allowSelection === 'function' ? columnMeta.allowSelection(record) : columnMeta.allowSelection;
183
185
 
184
186
  // const selectRowIds = React.useMemo(() => {
185
187
 
@@ -197,18 +199,13 @@ const TableBodyCell = props => {
197
199
  [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
198
200
  [`${prefix}-grid-cell-text-center`]: columnMeta?.textAlign === 'center',
199
201
  [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
200
- // [`${prefix}-grid-cell-index-selected`]: rowRange?.includes(cell.row.id),
201
- // [`${prefix}-grid-cell-index-selected`]: selectRowIds?.includes(cell.row.id),
202
202
  }),
203
203
  style: {
204
+ ...cellStyles,
204
205
  display: 'flex',
205
- // height: '36px',
206
206
  userSelect: 'none',
207
207
  width: cell.column.getSize(),
208
- // flexBasis: cell.column.getSize(),
209
208
  minWidth: cell.column.getSize(),
210
- // flex: 1,
211
- // maxWidth: cell.column.getSize(),
212
209
  ...getCommonPinningStyles(cell.column)
213
210
  },
214
211
  onClick: e => {
@@ -272,12 +269,10 @@ const TableBodyCell = props => {
272
269
  [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
273
270
  }),
274
271
  style: {
272
+ ...cellStyles,
275
273
  display: 'flex',
276
- // height: '36px',
277
274
  width: cell.column.getSize(),
278
275
  minWidth: cell.column.getSize(),
279
- // flex: 1,
280
- // maxWidth: cell.column.getSize(),
281
276
  ...getCommonPinningStyles(cell.column)
282
277
  }
283
278
  }, renderCommand({
@@ -298,51 +293,16 @@ const TableBodyCell = props => {
298
293
  [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right'
299
294
  }),
300
295
  style: {
296
+ ...cellStyles,
301
297
  display: 'flex',
302
- // height: '36px',
303
298
  minHeight: 36,
304
299
  width: cell.column.getSize(),
305
300
  minWidth: cell.column.getSize(),
306
- // flex: 1,
307
- // maxWidth: cell.column.getSize(),
308
301
  ...getCommonPinningStyles(cell.column)
309
302
  }
310
303
  }, /*#__PURE__*/React.createElement("div", {
311
304
  className: classNames('ui-rc_cell-content', {})
312
- }, cell.column.getIndex() === expandIconColumnIndex && isDataTree && /*#__PURE__*/React.createElement("div", {
313
- className: "ui-rc-table-row-expand-trigger",
314
- style: {
315
- paddingLeft: `${cell.row.depth * 25}px`
316
- }
317
- }, /*#__PURE__*/React.createElement("div", null, cell.row.getCanExpand() ? /*#__PURE__*/React.createElement("button", {
318
- // onClick: row.getToggleExpandedHandler(),
319
- onClick: () => {
320
- const keys = Object.keys(expanded);
321
- // @ts-ignore
322
- const tmp = {
323
- ...expanded
324
- };
325
- if (keys.includes(cell.row.id)) {
326
- delete tmp[cell.row.id];
327
- setExpanded(tmp);
328
- } else {
329
- setExpanded(old => ({
330
- ...old,
331
- [cell.row.id]: true
332
- }));
333
- }
334
- },
335
- style: {
336
- cursor: "pointer"
337
- },
338
- className: "ui-rc-table-row-expand"
339
- }, cell.row.getIsExpanded() ? /*#__PURE__*/React.createElement("span", {
340
- className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-expanded"
341
- }) : /*#__PURE__*/React.createElement("span", {
342
- className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-collapsed"
343
- })) : /*#__PURE__*/React.createElement("span", {
344
- className: "ui-rc-table-row-expand-icon ui-rc-table-row-expand-icon-spaced"
345
- }))), cell.column.id === "selection_column" && renderSelection({
305
+ }, cell.column.id === "selection_column" && renderSelection({
346
306
  cell,
347
307
  table,
348
308
  selectionSettings,
@@ -385,13 +345,11 @@ const TableBodyCell = props => {
385
345
  [`${prefix}-grid-cell-text-right`]: columnMeta?.textAlign === 'right' || columnMeta.type === 'number'
386
346
  }),
387
347
  style: {
348
+ ...cellStyles,
388
349
  display: 'flex',
389
350
  width: cell.column.getSize(),
390
351
  minWidth: cell.column.getSize(),
391
352
  minHeight: 36,
392
- // flex: 1,
393
- // maxWidth: cell.column.getSize(),
394
- // height: '36px',
395
353
  ...getCommonPinningStyles(cell.column)
396
354
  },
397
355
  onMouseEnter: e => {
@@ -466,16 +424,17 @@ const TableBodyCell = props => {
466
424
  // })
467
425
  // }
468
426
  }
469
- },
470
- onKeyUp: () => {}
427
+ }
428
+
429
+ // onKeyUp={() => {
471
430
 
472
- // onDoubleClick={() => { }}
431
+ // }}
473
432
  ,
474
433
 
475
434
  onClick: e => {
476
435
  const selection = window.getSelection();
477
436
  const text = selection ? selection.toString() : "";
478
- if (text.length > 0) {} else {
437
+ if (text.length > 0 || enableClick === false) {} else {
479
438
  if (!selectionSettings || selectionSettings.checkboxOnly !== true) {
480
439
  toggleRowSelection({
481
440
  e,
@@ -27,7 +27,8 @@ const TableBodyRow = ({
27
27
  recordDoubleClick,
28
28
  focusedCell,
29
29
  rowClassName,
30
- rowEditable
30
+ rowEditable,
31
+ onRowStyles
31
32
  } = React.useContext(TableContext);
32
33
  const visibleCells = row.getVisibleCells();
33
34
  const virtualColumns = columnVirtualizer.getVirtualItems();
@@ -39,23 +40,18 @@ const TableBodyRow = ({
39
40
  const virtualRight = virtualPaddingRight ? [virtualPaddingRight] : [];
40
41
  const templateColumns = [...leftTemplate, ...virtualLeft, ...centerTemplate, ...virtualRight, ...rightTemplate];
41
42
  const rowClass = typeof rowClassName === 'function' ? rowClassName(row.original, row.index, row.depth) : rowClassName;
43
+ const rowStyles = typeof onRowStyles === 'function' ? onRowStyles(row.original, row) : onRowStyles;
42
44
  const isRowEditable = rowEditable ? rowEditable(row.original) : true;
43
45
  return /*#__PURE__*/React.createElement("div", {
44
46
  "data-index": virtualRow.index //needed for dynamic row height measurement
45
47
  ,
46
48
  ref: node => rowVirtualizer.measureElement(node) //measure dynamic row height
47
49
  ,
48
- key: row.id
49
- // data-row-key={cell.row.id}
50
- ,
51
- "data-row-key": row.id
52
-
53
- // className={} ui-rc-table-row-selected
54
- ,
50
+ key: row.id,
51
+ "data-row-key": row.id,
55
52
  className: classNames(`${prefix}-grid-row ${rowClass ?? ''}`, {
56
53
  [`${prefix}-grid-row-selected`]: row.getIsSelected(),
57
54
  [`${prefix}-grid-row-focus`]: row.id === focusedCell?.rowId && !editAble
58
- // [`${prefix}-grid-row-focus`]: true,
59
55
  }),
60
56
  style: {
61
57
  // display: 'flex',
@@ -63,12 +59,11 @@ const TableBodyRow = ({
63
59
  // position: 'absolute',
64
60
  transform: `translateY(${virtualRow.start}px)`,
65
61
  //this should always be a `style` as it changes on scroll
66
- // width: '100%',
67
62
  // height: isEditing ? '36px' : undefined,
68
63
  gridTemplateColumns: `${templateColumns.map(n => `${n}fr`).join(" ")}`,
69
- // gridTemplateColumns: `repeat(${centerCOlumns.length + fixedLeftColumns.length + fixedRightColumns.length}, minmax(0, 1fr))`,
70
64
  height: isEditing ? virtualRow.size : undefined,
71
- minHeight: isEditing ? undefined : virtualRow.size
65
+ minHeight: isEditing ? undefined : virtualRow.size,
66
+ ...rowStyles
72
67
  },
73
68
  onDoubleClick: e => {
74
69
  recordDoubleClick?.({
@@ -1,13 +1,9 @@
1
- // import type { VirtualItem, Virtualizer } from "@tanstack/react-virtual";
2
1
  import React, { useContext } from "react";
3
- // import type { Person } from "../makeData";
4
2
  import { checkDecimalSeparator, checkThousandSeparator, getCommonPinningStyles, getFormat, isEmpty } from "../hook/utils";
5
3
  import { TableContext } from "../useContext";
6
4
  import classNames from "classnames";
7
5
  import { sumByField } from "../../grid-component/hooks";
8
6
  import { numericFormatter } from "react-numeric-component";
9
- // import type { Person } from "../../tanstack-table/makeData";
10
-
11
7
  const TableFooterCell = ({
12
8
  column
13
9
  }) => {
@@ -2,6 +2,7 @@
2
2
  // import type { Person } from "../makeData";
3
3
  import TableFooterCell from "./TableFooterCell";
4
4
  import React from "react";
5
+ import { TableContext } from "../useContext";
5
6
  // import type { Person } from "../../tanstack-table/makeData";
6
7
  // import TableHeadCell from "./TableHeadCell";
7
8
 
@@ -20,17 +21,19 @@ const TableFooterRow = ({
20
21
 
21
22
  // const a = table.getVisibleFlatColumns()
22
23
  const visibleColumns = table.getVisibleLeafColumns();
24
+ const {
25
+ onRowFooterStyles
26
+ } = React.useContext(TableContext);
27
+ const rowStyles = typeof onRowFooterStyles === 'function' ? onRowFooterStyles() : onRowFooterStyles;
23
28
 
24
29
  // const
25
30
 
26
31
  return /*#__PURE__*/React.createElement("div", {
27
- // data-index={headerGroup.id}
28
32
  key: headerGroup.id,
29
33
  style: {
34
+ ...rowStyles,
30
35
  display: "grid",
31
36
  width: "100%",
32
- // borderBottom: "1px solid #e0e0e0",
33
- // borderTop: "1px solid #e0e0e0",
34
37
  height: 37,
35
38
  gridTemplateColumns: `${table.getVisibleLeafColumns().map(n => `${n.getSize()}fr`).join(" ")}`
36
39
  },
@@ -24,15 +24,18 @@ const TableHead = ({
24
24
  // fixedRightColumns
25
25
  }) => {
26
26
  const {
27
- prefix
27
+ prefix,
28
+ onRowHeaderStyles
28
29
  } = useContext(TableContext);
29
30
  const headerGroups = table.getFlatHeaders();
30
31
  const leafColumns = table.getVisibleFlatColumns();
31
32
  // const leafColumns11 = table.getIsAllColumnsVisible();
32
33
  const headerDepth = table.getHeaderGroups().length;
34
+ const rowStyles = typeof onRowHeaderStyles === 'function' ? onRowHeaderStyles() : onRowHeaderStyles;
33
35
  return /*#__PURE__*/React.createElement("div", {
34
36
  className: `${prefix}-grid-thead`,
35
37
  style: {
38
+ ...rowStyles,
36
39
  display: 'grid',
37
40
  position: 'sticky',
38
41
  top: 0,
@@ -1,9 +1,5 @@
1
- // import { useSortable } from "@dnd-kit/sortable"
2
-
3
1
  import { flexRender } from '@tanstack/react-table';
4
2
  import React, { useContext } from 'react';
5
- // import { CSS } from '@dnd-kit/utilities'
6
- // import type { Virtualizer } from '@tanstack/react-virtual'
7
3
  import { Button, Space } from 'antd';
8
4
  import { ArrowDown, ArrowUp, FilterFill, SortCancel } from 'becoxy-icons';
9
5
  import classNames from 'classnames';
@@ -13,11 +9,6 @@ import { excludeItems, extendsObject, getCommonPinningStyles, getDefaultOperator
13
9
  import { TableContext } from "../useContext";
14
10
  import { renderFilter } from "./renderFilter";
15
11
  import ReactDOMServer from 'react-dom/server';
16
-
17
- // import { ColumnTable } from "../type";
18
-
19
- // import { Tooltip } from 'react-tooltip'
20
-
21
12
  const TableHeadCell2 = props => {
22
13
  const {
23
14
  column,
@@ -25,9 +16,6 @@ const TableHeadCell2 = props => {
25
16
  getPopupContainer,
26
17
  table,
27
18
  depth,
28
- // t,
29
- // columnVirtualizer,
30
- // rowHeaderVirtualizer,
31
19
  colSpan,
32
20
  rowSpan
33
21
  } = props;
@@ -52,33 +40,16 @@ const TableHeadCell2 = props => {
52
40
  const {
53
41
  filterIcon
54
42
  } = column.columnDef.meta ?? {};
55
-
56
- // const column = (column.columnDef ?? {}) as ColumnTable
57
- // const column = column.columnDef
58
-
59
43
  const originalColumn = column.columnDef.meta ?? {};
44
+ const cellStyles = typeof originalColumn.onCellHeaderStyles === 'function' ? originalColumn.onCellHeaderStyles(header) : originalColumn.onCellHeaderStyles;
60
45
  const filtered = (column.getFilterValue() ?? []).length > 0;
61
46
  const cellContent = flexRender(column.columnDef.header, header.getContext());
62
- // const cellContent = 'aaaa'
63
-
64
47
  const html = ReactDOMServer.renderToStaticMarkup( /*#__PURE__*/React.createElement(React.Fragment, null, cellContent));
65
48
  const hasValue = html.trim().length > 0;
66
-
67
- // const filtered = column.getIsFiltered()
68
-
69
- // const { attributes, isDragging, listeners, setNodeRef, transform } =
70
- // useSortable({
71
- // id: column.id,
72
- // })
73
-
74
49
  const style = {
75
- // opacity: isDragging ? 0.8 : 1,
76
- // position: 'relative',
77
- // transform: CSS.Translate.toString(transform), // translate instead of transform to avoid squishing
78
50
  transition: 'width transform 0.2s ease-in-out',
79
- whiteSpace: 'nowrap'
80
- // width: column.getSize(),
81
- // zIndex: isDragging ? 1 : 0,
51
+ whiteSpace: 'nowrap',
52
+ ...cellStyles
82
53
  };
83
54
  const getDropdownTrigger = () => {
84
55
  let iconFilter;
@@ -232,25 +203,15 @@ const TableHeadCell2 = props => {
232
203
  [`${prefix}-grid-cell-fix-right-first`]: isFirstRightPinnedColumn,
233
204
  [`${prefix}-grid-cell-text-center`]: (originalColumn?.headerTextAlign ?? originalColumn?.textAlign) === 'center',
234
205
  [`${prefix}-grid-cell-text-right`]: (originalColumn?.headerTextAlign ?? originalColumn.textAlign) === 'right'
235
- })
236
- // colSpan={colSpan}
237
- // rowSpan={rowSpan}
238
- ,
239
-
206
+ }),
240
207
  key: column.id,
241
208
  style: {
242
- // display: 'flex',
243
- // width: column.getSize(),
209
+ ...style,
244
210
  minWidth: column.getSize(),
245
- // flex: 1,
246
- // flexGrow: column.getSize(),
247
-
248
211
  gridRow: `${depth + 1} / span ${rowSpan}`,
249
212
  gridColumn: `span ${colSpan}`,
250
- // maxWidth: header.getSize(),
251
213
  ...getCommonPinningStyles(column),
252
- width: 'auto',
253
- ...style
214
+ width: 'auto'
254
215
  },
255
216
  "data-tooltip-id": `${id}-tooltip-content`,
256
217
  "data-tooltip-delay-show": 500,
@@ -261,9 +222,7 @@ const TableHeadCell2 = props => {
261
222
  [`${prefix}-grid-selection-column`]: column.id === 'selection_column'
262
223
  })
263
224
  }, column.id === 'selection_column' && selectionSettings && selectionSettings.hideSelectAll !== true && selectionSettings.type !== 'single' && selectionSettings.mode !== 'radio' && /*#__PURE__*/React.createElement(Checkbox, {
264
- checked: table.getIsAllRowsSelected()
265
- // indeterminate={table.getIsSomeRowsSelected()}
266
- ,
225
+ checked: table.getIsAllRowsSelected(),
267
226
  indeterminate: table.getIsSomePageRowsSelected(),
268
227
  onChange: e => {
269
228
  table.getToggleAllRowsSelectedHandler()(e);