es-grid-template 1.3.6 → 1.3.7

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.
@@ -96,7 +96,7 @@ const Group = props => {
96
96
  })));
97
97
  };
98
98
  return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(GridStyle, {
99
- heightTable: height,
99
+ $heightTable: height,
100
100
  style: {
101
101
  position: 'relative'
102
102
  }
@@ -1,4 +1,6 @@
1
1
  /// <reference types="react" />
2
- 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>, {
3
- heightTable?: number | string;
4
- }>> & string;
2
+ interface GridProps {
3
+ $heightTable?: number | string;
4
+ }
5
+ 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
+ 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
+ })([".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);
@@ -24,6 +24,8 @@ var _AdvanceFilter = _interopRequireDefault(require("./AdvanceFilter"));
24
24
  var _reactTooltip = require("react-tooltip");
25
25
  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); }
26
26
  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; }
27
+ // import Table from "../../core/table"
28
+
27
29
  // import {ConfigProvider} from "antd";
28
30
 
29
31
  const convertFilters = filters => {
@@ -366,8 +368,10 @@ const TableGrid = props => {
366
368
  loading: {
367
369
  spinning: columns && columns.length === 0 || loading === true,
368
370
  indicator: /*#__PURE__*/_react.default.createElement(_LoadingSpinner.default, null)
369
- },
370
- dataSource: columns && columns.length > 0 ? (0, _hooks.filterDataByColumns3)(dataSource, filterStates) : []
371
+ }
372
+ // dataSource={columns && columns.length > 0 ? filterDataByColumns3(dataSource, filterStates) : []}
373
+ ,
374
+ dataSource: columns && columns.length > 0 ? (0, _hooks.filterDataByColumns4)(dataSource, filterStates) : []
371
375
  // dataSource={columns && columns.length > 0 && loading !== true ? dataSource : []}
372
376
  // className={styles.customTable}
373
377
  ,
@@ -392,17 +396,16 @@ const TableGrid = props => {
392
396
  },
393
397
  rowSelection: columns && columns.length === 0 ? undefined : {
394
398
  ...selectionSettings,
395
- type: selectionSettings?.mode === 'checkbox' || type === 'multiple' ? 'checkbox' : "radio",
396
- columnWidth: !mode ? 0.0000001 : columnWidth ?? 50,
399
+ // type: selectionSettings?.mode,
400
+ type: mode,
401
+ columnWidth: columnWidth ?? 50,
397
402
  onChange: onSelectChange,
398
403
  // selectedRowKeys: mode === 'checkbox' && type === 'single' ? selectedRowKeys : undefined,
399
404
  selectedRowKeys: mergedSelectedKeys,
400
- defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
405
+ // defaultSelectedRowKeys: selectionSettings?.defaultSelectedRowKeys,
406
+ defaultSelectedRowKeys: defaultSelectedRowKeys,
401
407
  preserveSelectedRowKeys: true,
402
- // ...rowSelection,
403
- // checkStrictly: false,
404
-
405
- hideSelectAll: !type || type === 'single' || selectionSettings?.mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
408
+ hideSelectAll: !type || type === 'single' || mode === 'radio' ? true : hideSelectAll ?? type !== 'multiple'
406
409
  }
407
410
 
408
411
  // onScroll={() => {
@@ -419,7 +422,7 @@ const TableGrid = props => {
419
422
  }
420
423
  return /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary, {
421
424
  fixed: true
422
- }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0, _columns.flatColumns)([_rcMasterUi.Table.SELECTION_COLUMN, ...columns]).filter(col => col.hidden !== true).map((col, index) => {
425
+ }, /*#__PURE__*/_react.default.createElement(_rcMasterUi.Table.Summary.Row, null, (0, _columns.flatColumns)(!!mode ? [_rcMasterUi.Table.SELECTION_COLUMN, ...columns] : [...columns]).filter(col => col.hidden !== true).map((col, index) => {
423
426
  const thousandSeparator = col.format?.thousandSeparator ? col.format?.thousandSeparator : format?.thousandSeparator;
424
427
  const decimalSeparator = col.format?.decimalSeparator ? col.format?.decimalSeparator : format?.decimalSeparator;
425
428
  const dec = col.format?.decimalScale || col.format?.decimalScale === 0 ? col.format?.decimalScale : format?.decimalScale;
@@ -443,7 +446,7 @@ const TableGrid = props => {
443
446
  }, col.summaryTemplate ? col.summaryTemplate(cellValue, col.key) : (0, _reactNumericComponent.numericFormatter)(cellValue, numericFormatProps));
444
447
  })));
445
448
  },
446
- pagination: !pagination || pagination && pagination.onChange ? false : {
449
+ pagination: !pagination || pagination && pagination?.onChange ? false : {
447
450
  showTotal: (total, range) => `${range[0]}-${range[1]} / ${total} items`,
448
451
  ...pagination
449
452
  },
@@ -88,7 +88,7 @@ const getValueCell = (column, value, format) => {
88
88
  // const contentNumber = !isEmpty(value) ? ((dec || dec === 0) ? parseFloat(Number(value).toFixed(dec)).toString() : value.toString()) : '0'
89
89
 
90
90
  const tmpval = typeof value === 'string' ? Number(value) : value;
91
- const contentNumber = !(0, _utils.isEmpty)(value) ? dec || dec === 0 ? tmpval.toFixed(dec) : tmpval.toString() : '0';
91
+ const contentNumber = !(0, _utils.isEmpty)(value) ? dec || dec === 0 ? parseFloat(tmpval.toFixed(dec)).toString() : tmpval.toString() : '0';
92
92
  const numericFormatProps = {
93
93
  thousandSeparator: (0, _utils.checkThousandSeparator)(thousandSeparator, decimalSeparator),
94
94
  decimalSeparator: (0, _utils.checkDecimalSeparator)(thousandSeparator, decimalSeparator),
@@ -165,8 +165,8 @@ const useColumns = config => {
165
165
  const transformColumns = (0, _react.useCallback)(columns => {
166
166
  // >>>>>>>>>>> Support selection
167
167
  const cloneColumns = [...columns];
168
- const firstNonGroupColumn = (0, _columns.flatColumns2)(cloneColumns).find(col => col.field && col.field !== '#' && col.field !== 'index' && !groupColumns?.includes(col.field) && col.hidden !== true);
169
- const nonGroupColumns = (0, _columns.flatColumns2)(cloneColumns).filter(col => col.field && col.field !== '#' && col.field !== 'index' && !groupColumns?.includes(col.field) && col.hidden !== true);
168
+ const firstNonGroupColumn = (0, _columns.flatColumns2)(cloneColumns).find(col => col.field && col.field !== '#' && !groupColumns?.includes(col.field) && col.hidden !== true);
169
+ const nonGroupColumns = (0, _columns.flatColumns2)(cloneColumns).filter(col => col.field && col.field !== '#' && !groupColumns?.includes(col.field) && col.hidden !== true);
170
170
 
171
171
  // ===================== Render =====================
172
172
 
@@ -202,19 +202,18 @@ const useColumns = config => {
202
202
  children: convertColumns(transformedColumn.children)
203
203
  };
204
204
  }
205
- if (["index", "#"].includes(col.field)) {
205
+ if (transformedColumn.field === '#') {
206
206
  return {
207
207
  ...transformedColumn,
208
208
  onCell: () => ({
209
209
  className: 'cell-number'
210
210
  }),
211
211
  render: (val, record) => {
212
- // return rowIndex + 1
213
212
  return (0, _utils.findItemPath)(dataSource, record, rowKey);
214
213
  }
215
214
  };
216
215
  }
217
- if (col.field === 'command') {
216
+ if (transformedColumn.field === 'command') {
218
217
  return {
219
218
  ...transformedColumn,
220
219
  onCell: () => ({
@@ -300,6 +299,9 @@ const useColumns = config => {
300
299
  }
301
300
  if (col.field === firstNonGroupColumn?.field && record.children) {
302
301
  const currentGroupColumn = (0, _columns.flatColumns2)(cols).find(it => it.field === record.field);
302
+ if (currentGroupColumn?.template) {
303
+ return (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, format);
304
+ }
303
305
  return /*#__PURE__*/React.createElement("span", null, currentGroupColumn?.headerText, ": ", (0, _columns.renderContent)(currentGroupColumn, record[record.field], record, rowIndex, format));
304
306
  }
305
307
  return (0, _columns.renderContent)(col, value, record, rowIndex, format);
@@ -83,6 +83,8 @@ export declare const filterDataByColumns: (data: any[], queries: any) => any[];
83
83
  export declare const filterDataByColumns2: (data: any[], queries: any) => any[];
84
84
  export declare const removeFieldRecursive: (data: any[], field: string) => any[];
85
85
  export declare const filterDataByColumns3: (data: any[], queries: any[]) => any[];
86
+ export declare const shouldInclude: (item: any, queries: any[]) => any;
87
+ export declare function filterDataByColumns4(data: any[], queries: any[]): any[];
86
88
  export declare function isDateString(str: any): boolean;
87
89
  export declare function compareDates(date1: any, date2: any): boolean;
88
90
  export declare function compareDate(itemValue: any, value: any): boolean;
@@ -102,5 +104,15 @@ export declare function isBottomMostInRanges(rowIndex: number, colIndex: number,
102
104
  export declare const mergedSets: (arr: any[]) => Set<unknown>;
103
105
  export declare const sortedSetASC: (setValue: any) => Set<unknown>;
104
106
  export declare const sortedSetDSC: (setValue: any) => Set<unknown>;
105
- export declare const onAddClassSelectedCell: (selectedCells: any, id?: string) => void;
106
- export declare const onRemoveClassSelectedCell: (selectedCells: any, id?: string) => void;
107
+ export declare function getBottomRowCells(cellSet: any): any[];
108
+ export declare function getCellsByPosition(cellSet: any, position?: string): any[];
109
+ export declare const addBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
110
+ export declare const removeBorderClass: (selectedCells: any, type: string, className: string, id?: string) => void;
111
+ export declare const onAddClassBgSelectedCell: (selectedCells: any, id?: string) => void;
112
+ export declare const onRemoveClassSelectedCell: (selectedCells: any, id?: string, rowsSelected?: any) => void;
113
+ export declare const addClassBorderPasteCell: (pasteCells: any, type: 'up' | 'down', id?: string) => void;
114
+ export declare const removeClassBorderPasteCell: (pasteCells: any, type: 'up' | 'down', id?: string) => void;
115
+ export declare const addClassCellIndexSelected: (rowsSelected: any, id?: string) => void;
116
+ export declare const removeClassCellIndexSelected: (rowsSelected: any, id?: string) => void;
117
+ export declare const showDraggingPoint: (selectedCells: any, id?: any) => void;
118
+ export declare const hideDraggingPoint: (selectedCells: any, id?: any) => void;
@@ -4,17 +4,21 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.addRowIdArray = void 0;
7
+ exports.addRowIdArray = exports.addClassCellIndexSelected = exports.addClassBorderPasteCell = exports.addBorderClass = void 0;
8
8
  exports.addRows8 = addRows8;
9
9
  exports.addRowsUp = addRowsUp;
10
10
  exports.checkThousandSeparator = exports.checkFieldKey = exports.checkDecimalSeparator = exports.checkChild = exports.buildConnectedRegions = void 0;
11
11
  exports.compareDate = compareDate;
12
12
  exports.compareDates = compareDates;
13
13
  exports.filterDataByColumns3 = exports.filterDataByColumns2 = exports.filterDataByColumns = exports.editAbleColumns = exports.customWeekStartEndFormat = exports.countItemsBeforeIndex = exports.convertLabelToTitle = exports.convertFlatColumn = exports.convertDayjsToDate = exports.convertDateToDayjs = exports.convertColumns = exports.convertArrayWithIndent = void 0;
14
+ exports.filterDataByColumns4 = filterDataByColumns4;
14
15
  exports.findAllChildrenKeys = findAllChildrenKeys;
15
- exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemPath = exports.findItemByKey = void 0;
16
+ exports.getAllVisibleKeys = exports.genPresets = exports.flattenData = exports.flattenArray = exports.findItemPath = exports.findItemByKey = void 0;
17
+ exports.getBottomRowCells = getBottomRowCells;
18
+ exports.getCellsByPosition = getCellsByPosition;
19
+ exports.getFirstSelectCell = exports.getEditType = exports.getDefaultValue = exports.getDatepickerFormat = exports.getDateString = exports.getColumnsVisible = void 0;
16
20
  exports.getHiddenParentKeys = getHiddenParentKeys;
17
- exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
21
+ exports.hideDraggingPoint = exports.getVisibleColumnKeys = exports.getTypeFilter = exports.getTemplate = exports.getRowsPasteIndex = exports.getRowNumber = exports.getLastSelectCell = void 0;
18
22
  exports.invalidDate = invalidDate;
19
23
  exports.isArraysEqual = void 0;
20
24
  exports.isBottomMostInRanges = isBottomMostInRanges;
@@ -24,7 +28,7 @@ exports.isEmpty = exports.isEditable = exports.isDisable = void 0;
24
28
  exports.isEqualSet = isEqualSet;
25
29
  exports.isObjEmpty = exports.isNullOrUndefined = exports.isNameColor = void 0;
26
30
  exports.isRightMostInRegion = isRightMostInRegion;
27
- exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sortedSetDSC = exports.sortedSetASC = exports.removeFieldRecursive = exports.removeColumns = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveClassSelectedCell = exports.onAddClassSelectedCell = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = void 0;
31
+ exports.updateData = exports.updateColumnsByGroup = exports.updateColumns = exports.updateArrayByKey = exports.transformColumns1 = exports.transformColumns = exports.totalFixedWidth = exports.sumDataByField = exports.sortedSetDSC = exports.sortedSetASC = exports.showDraggingPoint = exports.shouldInclude = exports.removeFieldRecursive = exports.removeColumns = exports.removeClassCellIndexSelected = exports.removeClassBorderPasteCell = exports.removeBorderClass = exports.parseCells = exports.parseBooleanToValue = exports.onRemoveClassSelectedCell = exports.onAddClassBgSelectedCell = exports.newGuid = exports.mergedSets = exports.isTopMostInRegion = void 0;
28
32
  var _dayjs = _interopRequireDefault(require("dayjs"));
29
33
  var _moment = _interopRequireDefault(require("moment/moment"));
30
34
  var _uuid = require("uuid");
@@ -369,7 +373,7 @@ const totalFixedWidth = (columns, type, selectionSettings) => {
369
373
  const width = typeof column.width === 'number' ? column.width : parseInt(column.width, 10) || 0; // Chuyển từ chuỗi sang số, nếu không hợp lệ thì lấy 0
370
374
  return sum + width;
371
375
  }, 0);
372
- const selectColumnWidth = !selectionSettings?.mode ? 0.0000001 : typeof selectionSettings?.columnWidth === 'number' ? selectionSettings?.columnWidth : parseInt(selectionSettings?.columnWidth, 10) || 50;
376
+ const selectColumnWidth = !selectionSettings?.mode ? 0 : typeof selectionSettings?.columnWidth === 'number' ? selectionSettings?.columnWidth : parseInt(selectionSettings?.columnWidth, 10) || 50;
373
377
  return totalFixedLeftWidth + selectColumnWidth;
374
378
  };
375
379
  exports.totalFixedWidth = totalFixedWidth;
@@ -809,8 +813,8 @@ function addRowsUp(array, n) {
809
813
  {
810
814
  // Lấy giá trị cuối, chuyển về date, cộng thêm (i+1)*step, chuyển lại về định dạng ISO
811
815
 
812
- const lastDate = new Date(array[m - 1][j]);
813
- const newTime = lastDate.getTime() - (i + 1) * steps[j] * -1;
816
+ const lastDate = new Date(arr[m - 1][j]);
817
+ const newTime = m === 1 ? lastDate.getTime() - (i + 1) * steps[j] : lastDate.getTime() - (i + 1) * steps[j] * -1;
814
818
  newValue = (0, _moment.default)(new Date(newTime)).format();
815
819
  }
816
820
  break;
@@ -863,7 +867,7 @@ const transformColumns1 = (cols, sortMultiple) => {
863
867
  if (!column?.field && !column?.key) {
864
868
  return _rcMasterUi.Table.SELECTION_COLUMN;
865
869
  }
866
- if (column.dataIndex === 'index' || column.field === 'index' || column.dataIndex === '#' || column.dataIndex === '#') {
870
+ if (column.dataIndex === '#' || column.dataIndex === '#') {
867
871
  return {
868
872
  ...column
869
873
  };
@@ -1246,6 +1250,93 @@ const filterDataByColumns3 = (data, queries) => {
1246
1250
  return result;
1247
1251
  });
1248
1252
  };
1253
+ exports.filterDataByColumns3 = filterDataByColumns3;
1254
+ const shouldInclude = (item, queries) => {
1255
+ if (item.isFilterState === true) {
1256
+ return true;
1257
+ }
1258
+ let result = null;
1259
+ for (const query of queries) {
1260
+ const {
1261
+ field,
1262
+ value,
1263
+ operator,
1264
+ predicate
1265
+ } = query;
1266
+ const itemValue = item[field];
1267
+ let condition = false;
1268
+ const isDateComparison = isDate(itemValue) || isDateString(value);
1269
+ const itemDate = isDateComparison ? new Date(itemValue) : null;
1270
+ const queryDate = isDateComparison ? parseToDate(value) : null;
1271
+ const itemStr = itemValue?.toString().toLowerCase?.();
1272
+ const queryStr = value?.toString().toLowerCase?.();
1273
+ switch (operator.toLowerCase()) {
1274
+ case "equal":
1275
+ condition = isDateComparison ? compareDates(itemDate, queryDate) : itemValue === value;
1276
+ break;
1277
+ case "notequal":
1278
+ condition = isDateComparison ? !compareDates(itemDate, queryDate) : itemValue !== value;
1279
+ break;
1280
+ case "greaterthan":
1281
+ // @ts-ignore
1282
+ condition = isDateComparison ? itemDate > queryDate : itemValue > value;
1283
+
1284
+ // condition = isDateComparison ? invalidDate(itemDate) && invalidDate(queryDate) && itemDate > queryDate : itemValue > value;
1285
+ break;
1286
+ case "greaterthanorequal":
1287
+ // @ts-ignore
1288
+ condition = isDateComparison ? itemDate >= queryDate : itemValue >= value;
1289
+ break;
1290
+ case "lessthan":
1291
+ // @ts-ignore
1292
+ condition = isDateComparison ? itemDate < queryDate : itemValue < value;
1293
+ break;
1294
+ case "lessthanorequal":
1295
+ // @ts-ignore
1296
+ condition = isDateComparison ? itemDate <= queryDate : itemValue <= value;
1297
+ break;
1298
+ case "contains":
1299
+ condition = itemStr?.includes(queryStr);
1300
+ break;
1301
+ case "startswith":
1302
+ condition = itemStr?.startsWith(queryStr);
1303
+ break;
1304
+ case "endswith":
1305
+ condition = itemStr?.endsWith(queryStr);
1306
+ break;
1307
+ default:
1308
+ console.warn(`Unknown operator: ${operator}`);
1309
+ break;
1310
+ }
1311
+ if (predicate === "and") {
1312
+ result = result === null ? condition : result && condition;
1313
+ } else if (predicate === "or") {
1314
+ result = result === null ? condition : result || condition;
1315
+ }
1316
+ }
1317
+ return result;
1318
+ };
1319
+ exports.shouldInclude = shouldInclude;
1320
+ function filterDataByColumns4(data, queries) {
1321
+ if (!queries || queries.length === 0) {
1322
+ return data;
1323
+ }
1324
+ return data.map(item => {
1325
+ const newItem = {
1326
+ ...item
1327
+ };
1328
+ if (Array.isArray(item.children)) {
1329
+ newItem.children = filterDataByColumns4(item.children, queries);
1330
+ }
1331
+ const isSelfMatched = shouldInclude(item, queries);
1332
+
1333
+ // Nếu chính item thỏa hoặc có con thỏa → giữ lại
1334
+ if (isSelfMatched || newItem.children && newItem.children.length > 0) {
1335
+ return newItem;
1336
+ }
1337
+ return null; // loại bỏ node không phù hợp
1338
+ }).filter(Boolean); // xóa các null
1339
+ }
1249
1340
 
1250
1341
  // ======= Helper functions ========
1251
1342
 
@@ -1253,7 +1344,7 @@ const filterDataByColumns3 = (data, queries) => {
1253
1344
  // function isDate(value: any) {
1254
1345
  // return value instanceof Date || !isNaN(Date.parse(value));
1255
1346
  // }
1256
- exports.filterDataByColumns3 = filterDataByColumns3;
1347
+
1257
1348
  function isDate(value) {
1258
1349
  if (value instanceof Date) {
1259
1350
  return !isNaN(value.getTime());
@@ -1442,31 +1533,152 @@ const sortedSetDSC = setValue => {
1442
1533
  return new Set(sorted);
1443
1534
  };
1444
1535
  exports.sortedSetDSC = sortedSetDSC;
1445
- const onAddClassSelectedCell = (selectedCells, id) => {
1536
+ function getBottomRowCells(cellSet) {
1537
+ const cells = Array.from(cellSet).map(key => {
1538
+ const [row, col] = key.split('-').map(Number);
1539
+ return {
1540
+ row,
1541
+ col,
1542
+ key
1543
+ };
1544
+ });
1545
+ const maxRow = Math.max(...cells.map(c => c.row));
1546
+ return cells.filter(c => c.row === maxRow).map(c => c.key);
1547
+ }
1548
+ function getCellsByPosition(cellSet, position = "bottom") {
1549
+ const cells = Array.from(cellSet).map(key => {
1550
+ const [row, col] = key.split("-").map(Number);
1551
+ return {
1552
+ row,
1553
+ col,
1554
+ key
1555
+ };
1556
+ });
1557
+ switch (position) {
1558
+ case "top":
1559
+ {
1560
+ // const minRow = Math.min(...cells.map(c => c.row));
1561
+ // return cells.filter(c => c.row === minRow).map(c => c.key);
1562
+
1563
+ // const rows = cells.map(c => c.row).filter(r => r > 0);
1564
+ // if (rows.length === 0) return [];
1565
+ // const minRow = Math.min(...rows);
1566
+ // return cells.filter(c => c.row === minRow).map(c => c.key);
1567
+
1568
+ const minRow = Math.min(...cells.map(c => c.row));
1569
+ if (minRow === 0) return []; // Bỏ qua nếu rowIndex = 0
1570
+
1571
+ return cells.filter(c => c.row === minRow).map(c => `${c.row - 1}-${c.col}`);
1572
+ }
1573
+ case "bottom":
1574
+ {
1575
+ const maxRow = Math.max(...cells.map(c => c.row));
1576
+ return cells.filter(c => c.row === maxRow).map(c => c.key);
1577
+ }
1578
+ case "left":
1579
+ {
1580
+ // const minCol = Math.min(...cells.map(c => c.col));
1581
+ // return cells.filter(c => c.col === minCol).map(c => c.key);
1582
+
1583
+ // const cols = cells.map(c => c.col).filter(c => c > 0);
1584
+ // if (cols.length === 0) return [];
1585
+ // const minCol = Math.min(...cols);
1586
+ // return cells.filter(c => c.col === minCol).map(c => c.key);
1587
+
1588
+ const minCol = Math.min(...cells.map(c => c.col));
1589
+ if (minCol === 0) return []; // Bỏ qua nếu colIndex = 0
1590
+
1591
+ // Trả về các ô cùng row, nhưng ở cột bên trái
1592
+ return cells.filter(c => c.col === minCol).map(c => `${c.row}-${c.col - 1}`);
1593
+ }
1594
+ case "right":
1595
+ {
1596
+ const maxCol = Math.max(...cells.map(c => c.col));
1597
+ return cells.filter(c => c.col === maxCol).map(c => c.key);
1598
+ }
1599
+ default:
1600
+ return [];
1601
+ }
1602
+ }
1603
+ const addBorderClass = (selectedCells, type, className, id) => {
1604
+ const table = document.querySelector(`#${id}`);
1605
+ const typeCells = getCellsByPosition(selectedCells, type);
1606
+ const selectorsCells = typeCells.map(pos => {
1607
+ const [row, col] = pos.split('-');
1608
+ return `[data-row-index="${row}"][data-col-index="${col}"]`;
1609
+ });
1610
+ const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
1611
+ if (cellsFilter && cellsFilter.length > 0) {
1612
+ cellsFilter.forEach(cell => {
1613
+ cell.classList.add(className);
1614
+ });
1615
+ }
1616
+ };
1617
+ exports.addBorderClass = addBorderClass;
1618
+ const removeBorderClass = (selectedCells, type, className, id) => {
1619
+ const table = document.querySelector(`#${id}`);
1620
+ const typeCells = getCellsByPosition(selectedCells, type);
1621
+ const selectorsCells = typeCells.map(pos => {
1622
+ const [row, col] = pos.split('-');
1623
+ return `[data-row-index="${row}"][data-col-index="${col}"]`;
1624
+ });
1625
+ const cellsFilter = typeCells.length > 0 ? table?.querySelectorAll(selectorsCells.join(',')) : null;
1626
+ if (cellsFilter && cellsFilter.length > 0) {
1627
+ cellsFilter.forEach(cell => {
1628
+ cell.classList.remove(className);
1629
+ });
1630
+ }
1631
+ };
1632
+ exports.removeBorderClass = removeBorderClass;
1633
+ const onAddClassBgSelectedCell = (selectedCells, id) => {
1446
1634
  const selectors = Array.from(selectedCells).map(pos => {
1447
1635
  const [row1, col1] = pos.split('-');
1448
1636
  return `[data-row-index="${row1}"][data-col-index="${col1}"]`;
1449
1637
  });
1450
-
1451
- // const cells = document.querySelectorAll(selectors.join(','));
1452
-
1453
1638
  const table = document.querySelector(`#${id}`);
1454
- console.log('table', table);
1455
- const cells = table?.querySelectorAll(selectors.join(','));
1639
+ const cells = table && selectors.length > 0 ? table?.querySelectorAll(selectors.join(',')) : null;
1456
1640
  if (cells) {
1457
1641
  cells.forEach(cell => {
1458
1642
  cell.classList.add('selected');
1459
1643
  });
1460
1644
  }
1645
+ const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
1646
+ const rowsSelectors = rowsArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1647
+ const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
1648
+ if (cellsIndex) {
1649
+ cellsIndex.forEach(cell => {
1650
+ cell.classList.add('focus');
1651
+ });
1652
+ }
1653
+
1654
+ // tăng z-index để hiển thị round point paste
1655
+ const row = getLastSelectCell(selectedCells).row;
1656
+ const col = getLastSelectCell(selectedCells).col;
1657
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1658
+ if (cell) {
1659
+ cell.style.zIndex = 1;
1660
+ }
1661
+ if (cell && cell.classList.contains('ui-rc-table-cell-fix-left')) {
1662
+ cell.style.zIndex = 3;
1663
+ }
1664
+
1665
+ // thêm class border selected
1666
+
1667
+ addBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
1668
+ addBorderClass(selectedCells, 'right', 'cell-border-right', id);
1669
+ addBorderClass(selectedCells, 'top', 'cell-border-top', id);
1670
+ addBorderClass(selectedCells, 'left', 'cell-border-left', id);
1461
1671
  };
1462
- exports.onAddClassSelectedCell = onAddClassSelectedCell;
1463
- const onRemoveClassSelectedCell = (selectedCells, id) => {
1672
+ exports.onAddClassBgSelectedCell = onAddClassBgSelectedCell;
1673
+ const onRemoveClassSelectedCell = (selectedCells, id, rowsSelected) => {
1464
1674
  const selectors = Array.from(selectedCells).map(pos => {
1465
1675
  const [row, col] = pos.split('-');
1466
1676
  return `[data-row-index="${row}"][data-col-index="${col}"]`;
1467
1677
  });
1678
+ const rowsArray = [...new Set([...selectedCells].map(item => item.split("-")[0]))];
1679
+ const rowsSelectors = rowsArray.map(row => `.rc-ui-cell-index[data-row-index="${row}"]`).join(", ");
1468
1680
  const table = document.querySelector(`#${id}`);
1469
- const cells = table?.querySelectorAll(selectors.join(','));
1681
+ const cells = table && selectors.length > 0 ? table?.querySelectorAll(selectors.join(',')) : null;
1470
1682
  // const cells = table?.querySelectorAll(selectors.join(','))
1471
1683
 
1472
1684
  // const cells = table?.querySelectorAll('.ui-rc-table-cell.selected');
@@ -1476,5 +1688,127 @@ const onRemoveClassSelectedCell = (selectedCells, id) => {
1476
1688
  cell.classList.remove('selected');
1477
1689
  });
1478
1690
  }
1691
+ const cellsIndex = table && rowsSelectors.length > 0 ? table?.querySelectorAll(rowsSelectors) : null;
1692
+ if (cellsIndex) {
1693
+ cellsIndex.forEach(cell => {
1694
+ cell.classList.remove('focus');
1695
+ });
1696
+ }
1697
+
1698
+ // xóa class selected ô STT
1699
+
1700
+ if (rowsSelected && rowsSelected.size > 0) {
1701
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1702
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1703
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1704
+ if (cellsSelectedIndex) {
1705
+ cellsSelectedIndex.forEach(cell => {
1706
+ cell.classList.remove('selected');
1707
+ });
1708
+ }
1709
+ }
1710
+
1711
+ // xóa z-index về mặc định
1712
+
1713
+ const row = getLastSelectCell(selectedCells).row;
1714
+ const col = getLastSelectCell(selectedCells).col;
1715
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1716
+ if (cell) {
1717
+ cell.style.zIndex = 0;
1718
+ }
1719
+ if (cell && cell.classList.contains('ui-rc-table-cell-fix-left')) {
1720
+ cell.style.zIndex = 2;
1721
+ }
1722
+
1723
+ // remove class border
1724
+
1725
+ removeBorderClass(selectedCells, 'bottom', 'cell-border-bottom', id);
1726
+ removeBorderClass(selectedCells, 'right', 'cell-border-right', id);
1727
+ removeBorderClass(selectedCells, 'top', 'cell-border-top', id);
1728
+ removeBorderClass(selectedCells, 'left', 'cell-border-left', id);
1729
+ };
1730
+ exports.onRemoveClassSelectedCell = onRemoveClassSelectedCell;
1731
+ const addClassBorderPasteCell = (pasteCells, type, id) => {
1732
+ // thêm class border
1733
+
1734
+ addBorderClass(pasteCells, 'right', 'cell-paste-border-right', id);
1735
+ addBorderClass(pasteCells, 'left', 'cell-paste-border-left', id);
1736
+ if (type === 'up') {
1737
+ addBorderClass(pasteCells, 'top', 'cell-paste-border-top', id);
1738
+ }
1739
+ if (type === 'down') {
1740
+ addBorderClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
1741
+ }
1742
+ };
1743
+ exports.addClassBorderPasteCell = addClassBorderPasteCell;
1744
+ const removeClassBorderPasteCell = (pasteCells, type, id) => {
1745
+ // remove class border
1746
+
1747
+ removeBorderClass(pasteCells, 'bottom', 'cell-paste-border-bottom', id);
1748
+ removeBorderClass(pasteCells, 'right', 'cell-paste-border-right', id);
1749
+ removeBorderClass(pasteCells, 'top', 'cell-paste-border-top', id);
1750
+ removeBorderClass(pasteCells, 'left', 'cell-paste-border-left', id);
1751
+ };
1752
+ exports.removeClassBorderPasteCell = removeClassBorderPasteCell;
1753
+ const addClassCellIndexSelected = (rowsSelected, id) => {
1754
+ // thêm class selected vào ô STT
1755
+ const table = document.querySelector(`#${id}`);
1756
+ if (rowsSelected && rowsSelected.size > 0) {
1757
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1758
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1759
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1760
+ if (cellsSelectedIndex) {
1761
+ cellsSelectedIndex.forEach(cell => {
1762
+ cell.classList.add('selected');
1763
+ });
1764
+ }
1765
+ }
1766
+ };
1767
+ exports.addClassCellIndexSelected = addClassCellIndexSelected;
1768
+ const removeClassCellIndexSelected = (rowsSelected, id) => {
1769
+ // thêm class selected vào ô STT
1770
+ const table = document.querySelector(`#${id}`);
1771
+ if (rowsSelected && rowsSelected.size > 0) {
1772
+ const rowsSelectedArray = [...new Set([...rowsSelected].map(item => item.split("-")[0]))];
1773
+ const rowsSelectedSelectors = rowsSelectedArray.map(r => `.rc-ui-cell-index[data-row-index="${r}"]`).join(", ");
1774
+ const cellsSelectedIndex = table && rowsSelectedSelectors.length > 0 ? table?.querySelectorAll(rowsSelectedSelectors) : null;
1775
+ if (cellsSelectedIndex) {
1776
+ cellsSelectedIndex.forEach(cell => {
1777
+ cell.classList.remove('selected');
1778
+ });
1779
+ }
1780
+ }
1781
+ };
1782
+ exports.removeClassCellIndexSelected = removeClassCellIndexSelected;
1783
+ const showDraggingPoint = (selectedCells, id) => {
1784
+ const row = getLastSelectCell(selectedCells).row;
1785
+ const col = getLastSelectCell(selectedCells).col;
1786
+ const table = document.querySelector(`#${id}`);
1787
+ const cell = table?.querySelector(`.ui-rc-table-cell[data-row-index="${row}"][data-col-index="${col}"]`);
1788
+ const point = cell?.querySelector('.dragging-point');
1789
+ if (point) {
1790
+ point.classList.add('show');
1791
+ point.classList.remove('hidden');
1792
+ }
1793
+ };
1794
+ exports.showDraggingPoint = showDraggingPoint;
1795
+ const hideDraggingPoint = (selectedCells, id) => {
1796
+ const table = document.querySelector(`#${id}`);
1797
+
1798
+ // const point = table?.querySelector('.dragging-point.show')
1799
+ // const points = document.querySelectorAll('.dragging-point.show')
1800
+ const points = table?.querySelectorAll('.dragging-point.show');
1801
+
1802
+ // if (point) {
1803
+ // point.classList.add('hidden')
1804
+ // point.classList.remove('show')
1805
+ // }
1806
+
1807
+ if (points && points.length > 0) {
1808
+ points.forEach(cell => {
1809
+ cell.classList.add('hidden');
1810
+ cell.classList.remove('show');
1811
+ });
1812
+ }
1479
1813
  };
1480
- exports.onRemoveClassSelectedCell = onRemoveClassSelectedCell;
1814
+ exports.hideDraggingPoint = hideDraggingPoint;