es-grid-template 1.6.1 → 1.6.3

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.
@@ -25,6 +25,7 @@ export const EditForm = props => {
25
25
  menuWidth,
26
26
  // classNamePrefix,
27
27
  onChange,
28
+ rowData,
28
29
  // onKeyDown,
29
30
  t,
30
31
  cellFocus,
@@ -314,7 +315,8 @@ export const EditForm = props => {
314
315
  value,
315
316
  setValue,
316
317
  getValues,
317
- reset
318
+ reset,
319
+ rowData
318
320
  });
319
321
  }
320
322
  } else {
@@ -323,7 +325,8 @@ export const EditForm = props => {
323
325
  value,
324
326
  setValue,
325
327
  getValues,
326
- reset
328
+ reset,
329
+ rowData
327
330
  });
328
331
  }
329
332
  }
@@ -3,7 +3,9 @@ import React, { createContext, Fragment, useCallback, useContext, useState } fro
3
3
  // import {Resizable} from "react-resizable";
4
4
  import 'react-resizable/css/styles.css';
5
5
  import customParseFormat from 'dayjs/plugin/customParseFormat';
6
- import { addRowIdArray, booleanOperator, convertFilters, convertFlatColumn, filterDataByColumns4, findItemByKey, findItemPath, getAllRowKey, getFormat, getTypeFilter, groupArrayByColumns, numberOperator, removeColumns, removeInvisibleColumns, stringOperator, translateOption, updateArrayByKey, updateColumnsByGroup, updateData } from "./hooks";
6
+ import { addRowIdArray, booleanOperator, convertFilters, convertFlatColumn, filterDataByColumns4, findItemByKey, findItemPath, flattenArray, getAllRowKey, getFormat, getTypeFilter, groupArrayByColumns, numberOperator, removeColumns, removeInvisibleColumns, stringOperator, translateOption, unFlattenData, updateArrayByKey, updateColumnsByGroup,
7
+ // updateData,
8
+ updateOrInsert } from "./hooks";
7
9
  import dayjs from "dayjs";
8
10
  import 'dayjs/locale/es';
9
11
  import 'dayjs/locale/vi';
@@ -326,7 +328,9 @@ const InternalTable = props => {
326
328
  setSearchValue
327
329
  }) => {
328
330
  const type = getTypeFilter(column);
329
- const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? booleanOperator : !type || type === 'Text' ? stringOperator : numberOperator;
331
+ // const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? booleanOperator : (!type || type === 'Text' ? stringOperator : numberOperator)
332
+
333
+ const operatorOptions = ['Checkbox', 'Dropdown', 'DropTree', 'CheckboxDropdown'].includes(type) ? booleanOperator : !type || type === 'Text' ? stringOperator : numberOperator;
330
334
  return /*#__PURE__*/React.createElement("div", {
331
335
  style: {
332
336
  padding: 8,
@@ -825,8 +829,11 @@ const InternalTable = props => {
825
829
  };
826
830
  const triggerPaste = (pastedRows, pastedColumnsArray, newData, copyRows) => {
827
831
  const handlePasteCallback = callbackData => {
828
- const newDataUpdate = updateData(mergedData, callbackData, rowKey);
829
- triggerChangeData(newDataUpdate);
832
+ // const newDataUpdate = updateData(mergedData, callbackData, rowKey as any)
833
+
834
+ const rsFilterData = updateOrInsert(flattenArray([...mergedData]), callbackData);
835
+ const rs = unFlattenData(rsFilterData);
836
+ triggerChangeData(rs);
830
837
 
831
838
  // onCellPaste?.dataChange?.(newDataUpdate)
832
839
  };
@@ -1,4 +1,5 @@
1
- import React, { HTMLInputTypeAttribute } from "react";
1
+ import type { HTMLInputTypeAttribute } from "react";
2
+ import React from "react";
2
3
  interface IFFormInput {
3
4
  id?: any;
4
5
  control: any;
@@ -15,7 +15,5 @@ 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 [
19
- any
20
- ];
18
+ declare const useColumns: <RecordType extends AnyObject = AnyObject>(config: UseColumnsConfig<RecordType>) => readonly [any];
21
19
  export default useColumns;
@@ -1371,7 +1371,7 @@ const GridEdit = props => {
1371
1371
  const pasteData = e.clipboardData.getData("text/plain");
1372
1372
 
1373
1373
  // Chuyển đổi dữ liệu từ clipboard thành mảng
1374
- const rowsPasted = pasteData.split("\n").map(row =>
1374
+ const rowsPasted = pasteData.split("\n").filter(row => row !== '').map(row =>
1375
1375
  // const rows = pasteData.split("\n").map((row: any) =>
1376
1376
  row.replace(/\r/g, "").split("\t"));
1377
1377
  if (rowsPasted.length > (onCellPaste?.maxRowsPaste ?? 200)) {
@@ -141,6 +141,7 @@ export type IFormOpen = {
141
141
  setValue?: any;
142
142
  getValues?: any;
143
143
  reset?: any;
144
+ rowData?: any;
144
145
  };
145
146
  export type IEditFromSettings = {
146
147
  fieldKey: string;
@@ -34,6 +34,7 @@ const EditForm = props => {
34
34
  menuWidth,
35
35
  // classNamePrefix,
36
36
  onChange,
37
+ rowData,
37
38
  // onKeyDown,
38
39
  t,
39
40
  cellFocus,
@@ -323,7 +324,8 @@ const EditForm = props => {
323
324
  value,
324
325
  setValue,
325
326
  getValues,
326
- reset
327
+ reset,
328
+ rowData
327
329
  });
328
330
  }
329
331
  } else {
@@ -332,7 +334,8 @@ const EditForm = props => {
332
334
  value,
333
335
  setValue,
334
336
  getValues,
335
- reset
337
+ reset,
338
+ rowData
336
339
  });
337
340
  }
338
341
  }
@@ -337,7 +337,9 @@ const InternalTable = props => {
337
337
  setSearchValue
338
338
  }) => {
339
339
  const type = (0, _hooks.getTypeFilter)(column);
340
- const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? _hooks.booleanOperator : !type || type === 'Text' ? _hooks.stringOperator : _hooks.numberOperator;
340
+ // const operatorOptions = type === ('Checkbox' || 'Dropdown' || 'DropTree' || 'CheckboxDropdown') ? booleanOperator : (!type || type === 'Text' ? stringOperator : numberOperator)
341
+
342
+ const operatorOptions = ['Checkbox', 'Dropdown', 'DropTree', 'CheckboxDropdown'].includes(type) ? _hooks.booleanOperator : !type || type === 'Text' ? _hooks.stringOperator : _hooks.numberOperator;
341
343
  return /*#__PURE__*/_react.default.createElement("div", {
342
344
  style: {
343
345
  padding: 8,
@@ -836,8 +838,11 @@ const InternalTable = props => {
836
838
  };
837
839
  const triggerPaste = (pastedRows, pastedColumnsArray, newData, copyRows) => {
838
840
  const handlePasteCallback = callbackData => {
839
- const newDataUpdate = (0, _hooks.updateData)(mergedData, callbackData, rowKey);
840
- triggerChangeData(newDataUpdate);
841
+ // const newDataUpdate = updateData(mergedData, callbackData, rowKey as any)
842
+
843
+ const rsFilterData = (0, _hooks.updateOrInsert)((0, _hooks.flattenArray)([...mergedData]), callbackData);
844
+ const rs = (0, _hooks.unFlattenData)(rsFilterData);
845
+ triggerChangeData(rs);
841
846
 
842
847
  // onCellPaste?.dataChange?.(newDataUpdate)
843
848
  };
@@ -1,4 +1,5 @@
1
- import React, { HTMLInputTypeAttribute } from "react";
1
+ import type { HTMLInputTypeAttribute } from "react";
2
+ import React from "react";
2
3
  interface IFFormInput {
3
4
  id?: any;
4
5
  control: any;
@@ -1368,7 +1368,7 @@ const GridEdit = props => {
1368
1368
  const pasteData = e.clipboardData.getData("text/plain");
1369
1369
 
1370
1370
  // Chuyển đổi dữ liệu từ clipboard thành mảng
1371
- const rowsPasted = pasteData.split("\n").map(row =>
1371
+ const rowsPasted = pasteData.split("\n").filter(row => row !== '').map(row =>
1372
1372
  // const rows = pasteData.split("\n").map((row: any) =>
1373
1373
  row.replace(/\r/g, "").split("\t"));
1374
1374
  if (rowsPasted.length > (onCellPaste?.maxRowsPaste ?? 200)) {
@@ -141,6 +141,7 @@ export type IFormOpen = {
141
141
  setValue?: any;
142
142
  getValues?: any;
143
143
  reset?: any;
144
+ rowData?: any;
144
145
  };
145
146
  export type IEditFromSettings = {
146
147
  fieldKey: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-grid-template",
3
- "version": "1.6.1",
3
+ "version": "1.6.3",
4
4
  "description": "es-grid-template",
5
5
  "keywords": [
6
6
  "react",
@@ -62,7 +62,7 @@
62
62
  "rc-checkbox": "^3.5.0",
63
63
  "rc-dropdown": "^4.2.1",
64
64
  "rc-field-form": "^2.6.0",
65
- "rc-master-ui": "^1.1.37",
65
+ "rc-master-ui": "^1.1.38",
66
66
  "rc-select": "^14.16.3",
67
67
  "rc-tooltip": "^6.3.0",
68
68
  "rc-tree": "^5.10.1",
@@ -78,8 +78,8 @@
78
78
  "sweetalert2": "^11.4.14",
79
79
  "sweetalert2-react-content": "^5.0.0",
80
80
  "throttle-debounce": "^5.0.2",
81
- "yup": "^1.6.1",
82
- "vitest": "^2.0.5"
81
+ "vitest": "^2.0.5",
82
+ "yup": "^1.6.1"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@babel/cli": "^7.26.4",