es-grid-template 1.4.3 → 1.4.5

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.
@@ -10,6 +10,7 @@ type Props<T> = GridTableProps<T> & {
10
10
  triggerPaste?: (pastedRows: T[], pastedColumnsArray: string[], newData: T[]) => void;
11
11
  triggerFilter?: (queries: any) => void;
12
12
  setTooltipContent?: any;
13
+ scrollHeight?: number;
13
14
  };
14
15
  declare const Group: <RecordType extends object>(props: Props<RecordType>) => React.JSX.Element;
15
16
  export default Group;
@@ -11,8 +11,10 @@ import { Collapse2, Expand2 } from "becoxy-icons";
11
11
  const Group = props => {
12
12
  const {
13
13
  t,
14
+ id,
14
15
  columns,
15
16
  height,
17
+ scrollHeight,
16
18
  style,
17
19
  rowHoverable,
18
20
  groupAble,
@@ -97,11 +99,14 @@ const Group = props => {
97
99
  };
98
100
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
99
101
  $heightTable: height,
102
+ $heightScroll: scrollHeight,
100
103
  style: {
101
104
  position: 'relative'
102
- }
105
+ },
106
+ id: id
103
107
  }, /*#__PURE__*/React.createElement(TableGrid, _extends({}, rest, {
104
108
  t: t,
109
+ id: id,
105
110
  columns: columns,
106
111
  style: {
107
112
  ...style,
@@ -1,6 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  interface GridProps {
3
- $heightTable?: number | string;
3
+ $heightTable?: number;
4
+ $heightScroll?: number;
4
5
  }
5
6
  export declare const GridStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components/dist/types").Substitute<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, GridProps>> & string;
6
7
  export {};
@@ -9,4 +9,4 @@ var _styledComponents = _interopRequireDefault(require("styled-components"));
9
9
  const GridStyle = exports.GridStyle = _styledComponents.default.div.withConfig({
10
10
  displayName: "GridStyle",
11
11
  componentId: "es-grid-template__sc-sueu2e-0"
12
- })([".ui-rc-table-container{min-height:", ";}.ui-rc-toolbar-bottom{position:relative;padding:.25rem 1rem;background-color:#ffffff;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}.toolbar-button{border-radius:0;.ant-btn{border-radius:0;}}}.ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;background-color:#ffffff;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;visibility:visible;right:0;}&.pagination-template{position:relative;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}}}.react-resizable{position:relative;background-clip:padding-box;}.rc-resizable-handle{position:absolute;right:0px;bottom:0;z-index:1;width:5px;height:100%;cursor:col-resize;&.none{cursor:auto;display:none;}}"], props => props.$heightTable ? typeof props.$heightTable === 'string' ? props.$heightTable : `${props.$heightTable}px` : undefined);
12
+ })(["height:", ";.ui-rc-table.ui-rc-table-virtual.ui-rc-table-scroll-horizontal{.ui-rc-table-container{padding-bottom:8px;border-bottom:1px solid #e0e0e0;}}.ui-rc-table-container{.ui-rc-table-tbody-virtual.ui-rc-table-tbody{min-height:", ";}}.ui-rc-toolbar-bottom{position:relative;padding:.25rem 1rem;background-color:#ffffff;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}.toolbar-button{border-radius:0;.ant-btn{border-radius:0;}}}.ui-rc-pagination{border-bottom:1px solid #e0e0e0;border-top:1px solid #e0e0e0;margin:0;padding:.75rem 1rem;background-color:#ffffff;.ui-rc-pagination-total-text{order:2;margin-left:auto;}&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:50px;bottom:0;visibility:visible;right:0;}&.pagination-template{position:relative;&::before{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;left:0;}&::after{content:\"\";position:absolute;border-left:1px solid #e0e0e0;height:100%;bottom:0;visibility:visible;right:0;}}}.react-resizable{position:relative;background-clip:padding-box;}.rc-resizable-handle{position:absolute;right:0px;bottom:0;z-index:1;width:5px;height:100%;cursor:col-resize;&.none{cursor:auto;display:none;}}"], props => props.$heightTable ? `${props.$heightTable}px` : undefined, props => props.$heightScroll ? `${props.$heightScroll}px` : undefined);
@@ -33,6 +33,7 @@ var _modifiers = require("@dnd-kit/modifiers");
33
33
  var _core = require("@dnd-kit/core");
34
34
  var _sortable = require("@dnd-kit/sortable");
35
35
  var _reactResizable = require("react-resizable");
36
+ var _faker = require("@faker-js/faker");
36
37
  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); }
37
38
  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; }
38
39
  // import {Resizable} from "react-resizable";
@@ -153,6 +154,7 @@ const SortableHeaderCell = ({
153
154
  const InternalTable = props => {
154
155
  const {
155
156
  t,
157
+ id: tableId,
156
158
  // columns,
157
159
  columns: propsColumns,
158
160
  lang,
@@ -179,11 +181,37 @@ const InternalTable = props => {
179
181
  commandClick,
180
182
  commandSettings,
181
183
  pagination,
184
+ height: propsHeight,
185
+ summary,
182
186
  ...rest
183
187
  } = props;
188
+ const id = _react.default.useMemo(() => {
189
+ return tableId ?? _faker.faker.string.alpha(20);
190
+ // return tableId ?? newGuid()
191
+ }, [tableId]);
184
192
  const rowKey = _react.default.useMemo(() => {
185
193
  return propRowKey ?? 'rowId';
186
194
  }, [propRowKey]);
195
+ const [scrollHeight, setHeight] = (0, _react.useState)(0);
196
+
197
+ // const heightt = React.useMemo(() => {
198
+ //
199
+ // const table = document.querySelector(`#${id}`)
200
+ // console.log('table', table)
201
+ //
202
+ // const title: any = table?.querySelector(`.ui-rc-table-title`)
203
+ //
204
+ // console.log('title', title)
205
+ //
206
+ // if (title) {
207
+ // const titleHeight = title.offsetHeight;
208
+ // console.log('Chiều cao:', titleHeight);
209
+ // }
210
+ //
211
+ // return (height ?? 0) - (title ? title.offsetHeight : 0)
212
+ //
213
+ // }, [height, id])
214
+
187
215
  const local = lang && lang === 'en' ? _en_US.default : _vi_VN.default;
188
216
  const buddhistLocale = {
189
217
  ...local,
@@ -205,6 +233,19 @@ const InternalTable = props => {
205
233
  return (0, _hooks.addRowIdArray)(dataSource);
206
234
  }, [dataSource]);
207
235
  const [columns, setColumns] = _react.default.useState([]);
236
+ _react.default.useEffect(() => {
237
+ // setTimeout(() => {
238
+ const table = document.querySelector(`#${id}`);
239
+ const title = table?.querySelector(`.ui-rc-table-title`);
240
+ const header = table?.querySelector(`.ui-rc-table-header`);
241
+ const paginationE = table?.querySelector(`.ui-rc-pagination`);
242
+ const toolbar = table?.querySelector(`.ui-rc-toolbar-bottom`);
243
+ const summaryE = table?.querySelector(`.ui-rc-table-summary`);
244
+ const scrollbar = table?.querySelector(`.ui-rc-table-tbody-virtual-scrollbar.ui-rc-table-tbody-virtual-scrollbar-horizontal`);
245
+ const hhh = (propsHeight ?? 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);
246
+ setHeight(hhh);
247
+ // })
248
+ }, [id, propsHeight, columns]);
208
249
  const tableRef = _react.default.useRef(null);
209
250
  _react.default.useEffect(() => {
210
251
  setColumns(propsColumns);
@@ -363,6 +404,12 @@ const InternalTable = props => {
363
404
  if (transformedColumn.field === '#') {
364
405
  return {
365
406
  ...transformedColumn,
407
+ title: () => /*#__PURE__*/_react.default.createElement(_HeaderContent.default, {
408
+ column: {
409
+ ...column
410
+ },
411
+ t: t
412
+ }),
366
413
  onCell: () => ({
367
414
  className: 'cell-number'
368
415
  }),
@@ -377,6 +424,12 @@ const InternalTable = props => {
377
424
  if (transformedColumn.field === 'command') {
378
425
  return {
379
426
  ...transformedColumn,
427
+ title: () => /*#__PURE__*/_react.default.createElement(_HeaderContent.default, {
428
+ column: {
429
+ ...column
430
+ },
431
+ t: t
432
+ }),
380
433
  onCell: () => ({
381
434
  className: 'cell-number',
382
435
  style: {
@@ -482,26 +535,46 @@ const InternalTable = props => {
482
535
  if (column === SELECTION_COLUMN) {
483
536
  return SELECTION_COLUMN;
484
537
  }
485
- if (find) {
538
+ const tmpColumn = {
539
+ ...column,
540
+ dataIndex: column.field ?? column.dataIndex,
541
+ key: column.field ?? column.key,
542
+ title: /*#__PURE__*/_react.default.createElement(SortableHeaderCell, {
543
+ columnKey: column.field
544
+ }, /*#__PURE__*/_react.default.createElement(_HeaderContent.default, {
545
+ column: {
546
+ ...column
547
+ },
548
+ t: t
549
+ })),
550
+ ellipsis: column.ellipsis !== false,
551
+ align: column.textAlign ?? column.align,
552
+ fixed: column.fixedType ?? column.fixed,
553
+ isSummary: column.isSummary ?? column.haveSum,
554
+ hidden: column.hidden ?? column.visible === false
555
+ };
556
+
557
+ // Xử lý đệ quy cho children
558
+ if (column.children?.length) {
486
559
  return {
487
- ...find
560
+ ...column,
561
+ ...tmpColumn,
562
+ children: transformColumns(column.children)
488
563
  };
489
564
  }
490
- if (!find) {
565
+ if (find) {
491
566
  return {
492
- ...column
567
+ ...find
493
568
  };
494
569
  }
495
-
496
- // Xử lý đệ quy cho children
497
- if (column.children?.length) {
570
+ if (!find) {
498
571
  return {
499
572
  ...column,
500
- children: transformColumns(column.children)
573
+ ...tmpColumn
501
574
  };
502
575
  }
503
576
  });
504
- }, [convertColumns]);
577
+ }, [convertColumns, t]);
505
578
  const mergedColumns = _react.default.useMemo(() => {
506
579
  return transformColumns(columns);
507
580
  }, [columns, transformColumns]);
@@ -595,13 +668,13 @@ const InternalTable = props => {
595
668
  };
596
669
  const triggerCommandClick = args => {
597
670
  const {
598
- id,
671
+ id: idCommand,
599
672
  rowId,
600
673
  rowData,
601
674
  index
602
675
  } = args;
603
676
  const tmpData = [...mergedData];
604
- if (id === 'DELETE') {
677
+ if (idCommand === 'DELETE') {
605
678
  // bật modal confirm
606
679
  if (commandSettings && commandSettings.confirmDialog) {
607
680
  MySwal.fire({
@@ -687,7 +760,7 @@ const InternalTable = props => {
687
760
  }
688
761
  if (commandClick) {
689
762
  commandClick({
690
- id,
763
+ id: idCommand,
691
764
  rowId,
692
765
  rowData,
693
766
  index,
@@ -698,7 +771,7 @@ const InternalTable = props => {
698
771
  // server
699
772
  if (commandClick) {
700
773
  commandClick({
701
- id,
774
+ id: idCommand,
702
775
  rowId,
703
776
  rowData,
704
777
  index,
@@ -759,6 +832,7 @@ const InternalTable = props => {
759
832
  value: dragIndex
760
833
  }, /*#__PURE__*/_react.default.createElement(TableComponent, (0, _extends2.default)({}, rest, {
761
834
  t: t,
835
+ id: id,
762
836
  locale: locale,
763
837
  tableRef: tableRef,
764
838
  dataSource: mergedData,
@@ -778,7 +852,17 @@ const InternalTable = props => {
778
852
  groupAble: groupAble,
779
853
  groupColumns: groupColumns,
780
854
  commandClick: triggerCommandClick,
781
- pagination: pagination,
855
+ summary: summary,
856
+ pagination: pagination
857
+ // scroll={{ y: 300 - 41 - 7 }} // scroll height auto, không quá 600
858
+ // scroll={{ y: scrollHeight - (summary ? 0 : 7) }} // scroll height auto, không quá 600
859
+ ,
860
+ scroll: {
861
+ y: scrollHeight - (summary ? 0 : 0)
862
+ } // scroll height auto, không quá 600
863
+ ,
864
+ height: propsHeight,
865
+ scrollHeight: scrollHeight,
782
866
  components: {
783
867
  header: {
784
868
  cell: ResizableTitle
@@ -38,8 +38,8 @@ const HeaderContent = props => {
38
38
  return columnGroupText ?? headerText;
39
39
  }, [columnGroupText, headerText]);
40
40
  const tooltip = _react.default.useMemo(() => {
41
- return headerTooltip ?? columnGroupText ?? headerText;
42
- }, [columnGroupText, headerText, headerTooltip]);
41
+ return headerTooltip ?? t ? t(columnGroupText ?? headerText) : columnGroupText ?? headerText;
42
+ }, [columnGroupText, headerText, headerTooltip, t]);
43
43
  //
44
44
  //
45
45
  // const [isOpen, setIsOpen] = useState(false)
@@ -76,9 +76,7 @@ const HeaderContent = props => {
76
76
  // style={{flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', wordBreak: 'keep-all'}}
77
77
  // style={{flex: 1}}
78
78
  className: (0, _classnames.default)('', {}),
79
- "data-tooltip-id": "tooltip-header"
80
- // data-tooltip-id="tooltip-cell-content"
81
- ,
79
+ "data-tooltip-id": "tooltip-header",
82
80
  "data-tooltip-content": tooltip,
83
81
  "data-tooltip-offset": 16
84
82
  }, headerTemplate ? (0, _utils.getTemplate)(headerTemplate) : t ? t(text) : text));
@@ -287,8 +287,7 @@ const useColumns = config => {
287
287
  className: (0, _classnames.default)(transformedColumn?.onCell?.(data, index).className ?? '', {
288
288
  'cell-group': groupColumns && data.children,
289
289
  'cell-group-fixed': groupColumns && data.children && col.field === firstNonGroupColumn?.field
290
- }),
291
- 'data-tooltip-id': "tooltip-cell-content"
290
+ })
292
291
  // onMouseEnter: () => {
293
292
  // onMouseHover(data, col as any)
294
293
  // },
@@ -121,12 +121,14 @@ export declare const sortedSetASC: (setValue: any) => Set<unknown>;
121
121
  export declare const sortedSetDSC: (setValue: any) => Set<unknown>;
122
122
  export declare function getBottomRowCells(cellSet: any): any[];
123
123
  export declare function getCellsByPosition(cellSet: any, position?: string): any[];
124
- export declare const addBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
124
+ export declare const addBorderClass: (selectedCells: any, type: string, className: string, id?: string, nextCellRight?: boolean) => void;
125
125
  export declare const removeBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
126
126
  export declare const removeBorderClass2: (className: string, id?: string) => void;
127
127
  export declare const onAddBgSelectedCell: (selectedCells: any, id?: string, isFocusCellIndex?: boolean) => void;
128
- export declare const onAddBorderSelectedCell: (selectedCells: any, id?: string) => void;
129
128
  export declare const onRemoveBgSelectedCell: (selectedCells: any, id?: string, rowsSelected?: any) => void;
129
+ export declare const onAddBgCellIndex: (selectedCells: any, id?: string, isFocusCellIndex?: boolean) => void;
130
+ export declare const onRemoveBgCellIndex: (selectedCells: any, id?: string, rowsSelected?: any) => void;
131
+ export declare const onAddBorderSelectedCell: (selectedCells: any, id?: string) => void;
130
132
  export declare const onRemoveBorderSelectedCell: (selectedCells: any, id?: string) => void;
131
133
  export declare const addClassBorderPasteCell: (pasteCells: any, type: 'up' | 'down', id?: string) => void;
132
134
  export declare const removeClassBorderPasteCell: (pasteCells: any, type: 'up' | 'down', id?: string) => void;
@@ -134,3 +136,5 @@ export declare const addClassCellIndexSelected: (rowsSelected: any, id?: string)
134
136
  export declare const removeClassCellIndexSelected: (rowsSelected: any, id?: string) => void;
135
137
  export declare const showDraggingPoint: (selectedCells: any, id?: any) => void;
136
138
  export declare const hideDraggingPoint: (selectedCells: any, id?: any) => void;
139
+ export declare const isRangeCell: (selectedCells: any, type: string, rowIndex: number, colIndex: number) => boolean;
140
+ export declare const isSelectedCell: (selectedCells: any, rowIndex: number, colIndex: number) => any;