react-table-edit 0.2.7 → 0.2.9

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 (3) hide show
  1. package/dist/index.js +168 -85
  2. package/dist/index.mjs +170 -95
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -45,10 +45,10 @@ module.exports = __toCommonJS(Table_edit_exports);
45
45
  // test-app/src/component/table/index.tsx
46
46
  var import_react12 = require("react");
47
47
  var import_reactstrap8 = require("reactstrap");
48
- var import_classnames9 = __toESM(require("classnames"));
48
+ var import_classnames10 = __toESM(require("classnames"));
49
49
  var import_react_i18next8 = require("react-i18next");
50
50
  var import_react_select2 = __toESM(require("react-select"));
51
- var import_ej2_react_grids2 = require("@syncfusion/ej2-react-grids");
51
+ var import_ej2_react_grids = require("@syncfusion/ej2-react-grids");
52
52
  var import_async = __toESM(require("react-select/async"));
53
53
  var import_becoxy_icons4 = require("becoxy-icons");
54
54
 
@@ -1057,7 +1057,6 @@ var edit_form_default = EditForm;
1057
1057
  var import_react11 = require("react");
1058
1058
  var import_reactstrap7 = require("reactstrap");
1059
1059
  var import_react_i18next7 = require("react-i18next");
1060
- var import_ej2_react_grids = require("@syncfusion/ej2-react-grids");
1061
1060
 
1062
1061
  // test-app/src/component/modal-header/index.tsx
1063
1062
  var import_becoxy_icons2 = require("becoxy-icons");
@@ -1208,16 +1207,18 @@ var Sidebar = (props) => {
1208
1207
  var sidebar_default = Sidebar;
1209
1208
 
1210
1209
  // test-app/src/component/sidebar-setting-column/index.tsx
1210
+ var import_classnames9 = __toESM(require("classnames"));
1211
1211
  var import_jsx_runtime11 = require("react/jsx-runtime");
1212
1212
  var SidebarSetColumn = (props) => {
1213
1213
  const { column, setColumn, openSidebar, handleSidebar } = props;
1214
1214
  const { t } = (0, import_react_i18next7.useTranslation)();
1215
1215
  const [dataSource, setDataSource] = (0, import_react11.useState)([]);
1216
+ const [indexFocus, setIndexFocus] = (0, import_react11.useState)();
1216
1217
  (0, import_react11.useEffect)(() => {
1217
1218
  if (openSidebar) {
1218
- setDataSource([...column]);
1219
+ setDataSource(column.map((e) => ({ ...e })));
1219
1220
  }
1220
- }, [column, openSidebar]);
1221
+ }, [openSidebar]);
1221
1222
  const handleCancel = () => {
1222
1223
  handleSidebar();
1223
1224
  setDataSource([]);
@@ -1230,7 +1231,6 @@ var SidebarSetColumn = (props) => {
1230
1231
  const { innerWidth, innerHeight } = window;
1231
1232
  return { innerWidth, innerHeight };
1232
1233
  };
1233
- const gird = (0, import_react11.useRef)(null);
1234
1234
  const [windowSize, setWindowSize] = (0, import_react11.useState)(getWindowSize());
1235
1235
  (0, import_react11.useEffect)(() => {
1236
1236
  const handleWindowResize = () => {
@@ -1247,7 +1247,7 @@ var SidebarSetColumn = (props) => {
1247
1247
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_reactstrap7.Button, { color: "secondary", onClick: handleCancel, outline: true, children: t("Close") })
1248
1248
  ] });
1249
1249
  };
1250
- const visibleTemplate = (item) => {
1250
+ const visibleTemplate = (item, index) => {
1251
1251
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1252
1252
  import_reactstrap7.Input,
1253
1253
  {
@@ -1258,14 +1258,14 @@ var SidebarSetColumn = (props) => {
1258
1258
  className: " cursor-pointer",
1259
1259
  onChange: (e) => {
1260
1260
  if (dataSource) {
1261
- item.column.dataSource[item.index].visible = e.target.checked;
1262
- setDataSource(item.column.dataSource);
1261
+ dataSource[index].visible = e.target.checked;
1262
+ setDataSource(dataSource);
1263
1263
  }
1264
1264
  }
1265
1265
  }
1266
1266
  );
1267
1267
  };
1268
- const fixColumnTemplate = (item) => {
1268
+ const fixColumnTemplate = (item, index) => {
1269
1269
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1270
1270
  import_reactstrap7.Input,
1271
1271
  {
@@ -1276,15 +1276,15 @@ var SidebarSetColumn = (props) => {
1276
1276
  onChange: (e) => {
1277
1277
  if (dataSource) {
1278
1278
  if (e.target.checked) {
1279
- if (item.index * 2 <= item.column.dataSource.length) {
1280
- item.column.dataSource[item.index].fixedType = "left";
1279
+ if (index * 2 <= dataSource.length) {
1280
+ dataSource[index].fixedType = "left";
1281
1281
  } else {
1282
- item.column.dataSource[item.index].fixedType = "right";
1282
+ dataSource[index].fixedType = "right";
1283
1283
  }
1284
1284
  } else {
1285
- item.column.dataSource[item.index].fixedType = "";
1285
+ dataSource[index].fixedType = void 0;
1286
1286
  }
1287
- setDataSource(item.column.dataSource);
1287
+ setDataSource(dataSource);
1288
1288
  }
1289
1289
  }
1290
1290
  }
@@ -1292,53 +1292,82 @@ var SidebarSetColumn = (props) => {
1292
1292
  };
1293
1293
  const columns = [
1294
1294
  {
1295
- isPrimaryKey: true,
1296
1295
  field: "headerText",
1297
1296
  headerText: "Column name",
1298
1297
  template: (e) => {
1299
1298
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, { children: t(e.headerText) });
1300
1299
  },
1301
1300
  visible: true,
1302
- width: 100,
1303
- maxWidth: 120,
1304
- minWidth: 80
1301
+ width: 175,
1302
+ maxWidth: 200,
1303
+ minWidth: 150
1305
1304
  },
1306
1305
  {
1307
- isPrimaryKey: true,
1306
+ field: "",
1308
1307
  template: visibleTemplate,
1309
1308
  headerText: "Display",
1310
- dataSource,
1309
+ textAlign: "center",
1311
1310
  visible: true,
1312
1311
  width: 100,
1313
1312
  maxWidth: 120,
1314
1313
  minWidth: 80
1315
1314
  },
1316
1315
  {
1317
- isPrimaryKey: true,
1316
+ field: "",
1318
1317
  template: fixColumnTemplate,
1319
1318
  headerText: "Fix the column",
1320
- dataSource,
1319
+ textAlign: "center",
1321
1320
  visible: true,
1322
1321
  width: 100,
1323
1322
  maxWidth: 120,
1324
1323
  minWidth: 80
1325
1324
  },
1326
1325
  {
1327
- isPrimaryKey: true,
1328
1326
  field: "width",
1329
1327
  headerText: "Column width",
1330
- template: (item) => {
1331
- return item.width ? /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
1332
- t(item.width),
1333
- "px"
1334
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_jsx_runtime11.Fragment, {});
1335
- },
1328
+ textAlign: "right",
1336
1329
  visible: true,
1337
1330
  width: 100,
1338
1331
  maxWidth: 120,
1339
1332
  minWidth: 80
1340
1333
  }
1341
1334
  ];
1335
+ const renderHeaderCol = (col, indexCol) => {
1336
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1337
+ import_react11.Fragment,
1338
+ {
1339
+ children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1340
+ "th",
1341
+ {
1342
+ className: (0, import_classnames9.default)(
1343
+ `r-headercell fix-${col.fixedType}`,
1344
+ { "cell-fixed": col.fixedType }
1345
+ ),
1346
+ style: {
1347
+ width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
1348
+ minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
1349
+ top: `${0 * 42}px`,
1350
+ maxWidth: col.maxWidth
1351
+ },
1352
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1353
+ "div",
1354
+ {
1355
+ role: "textbox",
1356
+ title: t(col.headerText ?? ""),
1357
+ style: {
1358
+ height: `${1 * 42}px`,
1359
+ justifyContent: col.textAlign ?? "left"
1360
+ },
1361
+ className: "r-headercell-div",
1362
+ children: t(col.headerText ?? "")
1363
+ }
1364
+ )
1365
+ }
1366
+ )
1367
+ },
1368
+ `header-${indexCol}`
1369
+ );
1370
+ };
1342
1371
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1343
1372
  sidebar_default,
1344
1373
  {
@@ -1347,20 +1376,74 @@ var SidebarSetColumn = (props) => {
1347
1376
  width: 700,
1348
1377
  children: [
1349
1378
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(modal_header_default, { typeModal: "Edit", handleModal: handleCancel, title: "Column setup" }),
1350
- /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(
1351
- import_ej2_react_grids.GridComponent,
1352
- {
1353
- className: "ms-2",
1354
- dataSource,
1355
- ref: gird,
1356
- height: windowSize.innerHeight - 160,
1357
- allowRowDragAndDrop: true,
1358
- children: [
1359
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ej2_react_grids.ColumnsDirective, { children: columns.map((col, index) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ej2_react_grids.ColumnDirective, { ...col, headerText: t(col.headerText) }, index)) }),
1360
- /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_ej2_react_grids.Inject, { services: [import_ej2_react_grids.RowDD, import_ej2_react_grids.Selection, import_ej2_react_grids.CommandColumn] })
1361
- ]
1362
- }
1363
- ),
1379
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "ms-2 react-table-edit", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "r-grid", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "r-gridtable", style: { height: windowSize.innerHeight - 120 }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("table", { style: { width: "100%" }, children: [
1380
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("thead", { className: "r-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tr", { className: "r-row", role: "row", children: columns.map((col, index) => {
1381
+ return renderHeaderCol(col, index);
1382
+ }) }) }),
1383
+ /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("tbody", { className: "r-gridcontent", children: dataSource?.map((row, indexRow) => {
1384
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1385
+ "tr",
1386
+ {
1387
+ className: (0, import_classnames9.default)("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }),
1388
+ children: columns.map((col, indexCol) => {
1389
+ let value = row[col.field];
1390
+ if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
1391
+ value = formartNumberic(row[col.field], ",", ".", col.numericSettings?.fraction, true) ?? 0;
1392
+ }
1393
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_react11.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1394
+ "td",
1395
+ {
1396
+ className: (0, import_classnames9.default)(
1397
+ `r-rowcell fix-${col.fixedType}`,
1398
+ { "cell-fixed": col.fixedType },
1399
+ { "r-active": indexFocus === indexRow }
1400
+ ),
1401
+ style: {
1402
+ padding: 0,
1403
+ textAlign: col.textAlign ? col.textAlign : "left"
1404
+ },
1405
+ onFocus: (e) => {
1406
+ if (indexRow !== indexFocus) {
1407
+ setIndexFocus(indexRow);
1408
+ }
1409
+ e.stopPropagation();
1410
+ },
1411
+ onClick: (e) => {
1412
+ if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
1413
+ if (indexRow !== indexFocus) {
1414
+ setIndexFocus(indexRow);
1415
+ }
1416
+ e.stopPropagation();
1417
+ }
1418
+ },
1419
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1420
+ "div",
1421
+ {
1422
+ className: (0, import_classnames9.default)("r-rowcell-div"),
1423
+ style: {
1424
+ width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
1425
+ },
1426
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1427
+ "div",
1428
+ {
1429
+ className: (0, import_classnames9.default)("r-rowcell-content"),
1430
+ style: {
1431
+ margin: "7px 9px"
1432
+ },
1433
+ children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: "r-cell-text", children: col.template ? col.template(row, indexRow) : value })
1434
+ }
1435
+ )
1436
+ }
1437
+ )
1438
+ },
1439
+ `col-${indexRow}-${indexCol}`
1440
+ ) }, indexCol);
1441
+ })
1442
+ },
1443
+ `row-${indexRow}`
1444
+ );
1445
+ }) })
1446
+ ] }) }) }) }),
1364
1447
  /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1365
1448
  "div",
1366
1449
  {
@@ -1612,7 +1695,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1612
1695
  }
1613
1696
  handleDataChange(row, col, indexRow);
1614
1697
  },
1615
- className: (0, import_classnames9.default)("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1698
+ className: (0, import_classnames10.default)("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1616
1699
  type: "date",
1617
1700
  max: "9999-12-31",
1618
1701
  onKeyDown: (e) => {
@@ -1635,7 +1718,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1635
1718
  }
1636
1719
  handleDataChange(row, col, indexRow);
1637
1720
  },
1638
- className: (0, import_classnames9.default)("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1721
+ className: (0, import_classnames10.default)("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1639
1722
  type: "datetime-local",
1640
1723
  max: "9999-12-31T23:59",
1641
1724
  onKeyDown: (e) => {
@@ -1655,7 +1738,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1655
1738
  if (!valueAsyncSelect && col.selectSettings?.defaultValue) {
1656
1739
  valueAsyncSelect = col.selectSettings?.defaultValue(row);
1657
1740
  }
1658
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: (0, import_classnames9.default)("d-flex select-group", { "is-invalid": col.validate && col.validate(row[col.field], row) }), children: [
1741
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: (0, import_classnames10.default)("d-flex select-group", { "is-invalid": col.validate && col.validate(row[col.field], row) }), children: [
1659
1742
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1660
1743
  import_async.default,
1661
1744
  {
@@ -1675,7 +1758,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1675
1758
  placeholder: t("Select"),
1676
1759
  id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1677
1760
  loadOptions: col.selectSettings?.loadOptions,
1678
- className: (0, import_classnames9.default)("react-select"),
1761
+ className: (0, import_classnames10.default)("react-select"),
1679
1762
  onKeyDown: (e) => {
1680
1763
  if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
1681
1764
  }
@@ -1690,7 +1773,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1690
1773
  col.selectSettings?.handIconGroupClick("right");
1691
1774
  }
1692
1775
  },
1693
- className: (0, import_classnames9.default)("input-group-text", { "d-none": !col.selectSettings?.iconGroup }),
1776
+ className: (0, import_classnames10.default)("input-group-text", { "d-none": !col.selectSettings?.iconGroup }),
1694
1777
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(icon_default, { iconName: col.selectSettings?.iconGroup ?? "", size: 16 })
1695
1778
  }
1696
1779
  )
@@ -1727,7 +1810,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1727
1810
  isClearable: col.selectSettings?.isClearable ?? false,
1728
1811
  classNamePrefix: col.selectSettings?.widthPopup ? `select-${col.selectSettings?.widthPopup}` : "select",
1729
1812
  placeholder: t("Select"),
1730
- className: (0, import_classnames9.default)("react-select", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1813
+ className: (0, import_classnames10.default)("react-select", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1731
1814
  onKeyDown: (e) => {
1732
1815
  if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
1733
1816
  }
@@ -1767,7 +1850,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1767
1850
  parentValue: "parentId",
1768
1851
  child: "children"
1769
1852
  },
1770
- className: (0, import_classnames9.default)("select-tree", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1853
+ className: (0, import_classnames10.default)("select-tree", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1771
1854
  allowFiltering: false,
1772
1855
  value: valueSelectTree,
1773
1856
  popupHeight: 250,
@@ -1824,7 +1907,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1824
1907
  id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1825
1908
  style: { textAlign: col.textAlign, height: 29 },
1826
1909
  defaultValue: formartNumberic(valueCurrency, decimalSeparator, thousandSeparator, col.numericSettings?.fraction),
1827
- className: (0, import_classnames9.default)("border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1910
+ className: (0, import_classnames10.default)("border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1828
1911
  onChange: (val) => {
1829
1912
  let newVal = "";
1830
1913
  const flag = val.target?.value.startsWith("-");
@@ -1959,7 +2042,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1959
2042
  id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1960
2043
  style: { textAlign: col.textAlign, height: 29 },
1961
2044
  defaultValue: isNullOrUndefined(row[col.field]) ? "" : row[col.field],
1962
- className: (0, import_classnames9.default)("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
2045
+ className: (0, import_classnames10.default)("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1963
2046
  onBlur: (val) => {
1964
2047
  if (row[col.field] != val.target?.value) {
1965
2048
  row[col.field] = val.target?.value;
@@ -2003,7 +2086,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2003
2086
  {
2004
2087
  tabIndex: -1,
2005
2088
  style: { padding: "5px", minWidth: 45, height: "100%" },
2006
- className: (0, import_classnames9.default)("command-item", {
2089
+ className: (0, import_classnames10.default)("command-item", {
2007
2090
  "btn-icon": item.tooltip === ""
2008
2091
  }),
2009
2092
  color: item.color ? item.color : "#000",
@@ -2032,7 +2115,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2032
2115
  if (newIndexCol > -1) {
2033
2116
  const element = document.getElementById(`${idTable}-col${newIndexCol}-row${indexRow}`);
2034
2117
  if (element) {
2035
- if (element.className.includes("react-select") || element.className.includes("from-edit")) {
2118
+ if (element.className.includes("react-select") || element.className.includes("form-edit")) {
2036
2119
  element.getElementsByTagName("input")[0]?.focus();
2037
2120
  } else {
2038
2121
  element.focus();
@@ -2053,7 +2136,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2053
2136
  if (newIndexCol > -1) {
2054
2137
  const element = document.getElementById(`${idTable}-col${newIndexCol}-row${indexRow}`);
2055
2138
  if (element) {
2056
- if (element.className.includes("react-select") || element.className.includes("from-edit")) {
2139
+ if (element.className.includes("react-select") || element.className.includes("form-edit")) {
2057
2140
  element.getElementsByTagName("input")[0]?.focus();
2058
2141
  } else {
2059
2142
  element.focus();
@@ -2071,7 +2154,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2071
2154
  setTimeout(() => {
2072
2155
  const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow - 1}`);
2073
2156
  if (element2) {
2074
- if (element2.className.includes("react-select") || element2.className.includes("from-edit")) {
2157
+ if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
2075
2158
  element2.getElementsByTagName("input")[0]?.focus();
2076
2159
  } else {
2077
2160
  element2.focus();
@@ -2091,7 +2174,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2091
2174
  setTimeout(() => {
2092
2175
  const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
2093
2176
  if (element2) {
2094
- if (element2.className.includes("react-select") || element2.className.includes("from-edit")) {
2177
+ if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
2095
2178
  element2.getElementsByTagName("input")[0]?.focus();
2096
2179
  } else {
2097
2180
  element2.focus();
@@ -2119,7 +2202,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2119
2202
  setTimeout(() => {
2120
2203
  const element = document.getElementById(`${idTable}-col${columnFistEdit}-row${indexRow + 1}`);
2121
2204
  if (element) {
2122
- if (element.className.includes("react-select") || element.className.includes("from-edit")) {
2205
+ if (element.className.includes("react-select") || element.className.includes("form-edit")) {
2123
2206
  element.getElementsByTagName("input")[0]?.focus();
2124
2207
  } else {
2125
2208
  element.focus();
@@ -2137,7 +2220,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2137
2220
  setTimeout(() => {
2138
2221
  const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
2139
2222
  if (element2) {
2140
- if (element2.className.includes("react-select") || element2.className.includes("from-edit")) {
2223
+ if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
2141
2224
  element2.getElementsByTagName("input")[0]?.focus();
2142
2225
  } else {
2143
2226
  element2.focus();
@@ -2187,7 +2270,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2187
2270
  tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
2188
2271
  const element = document.getElementById(`${idTable}-col${columnFistEdit}-row${dataSource?.length + 1}`);
2189
2272
  if (element && !(element.getElementsByClassName("select__control--menu-is-open").length > 0 || element.getElementsByClassName("select-100__control--menu-is-open").length > 0 || element.getElementsByClassName("select-200__control--menu-is-open").length > 0 || element.getElementsByClassName("select-300__control--menu-is-open").length > 0 || element.getElementsByClassName("select-400__control--menu-is-open").length > 0 || element.getElementsByClassName("select-500__control--menu-is-open").length > 0)) {
2190
- if (element.className.includes("react-select") || element.className.includes("from-edit")) {
2273
+ if (element.className.includes("react-select") || element.className.includes("form-edit")) {
2191
2274
  element.getElementsByTagName("input")[0]?.focus();
2192
2275
  } else {
2193
2276
  element.focus();
@@ -2268,7 +2351,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2268
2351
  const changeDataSource = (data, haveNew = false) => {
2269
2352
  if (!editDisable && !addDisable && setDataSource) {
2270
2353
  if (haveNew) {
2271
- data.push(defaultValue ? { ...defaultValue, "fieldKey": generateUUID() } : {});
2354
+ data.push(defaultValue ? { ...defaultValue, [fieldKey]: generateUUID() } : {});
2272
2355
  }
2273
2356
  }
2274
2357
  setDataSource([...data]);
@@ -2320,7 +2403,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2320
2403
  return col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2321
2404
  "td",
2322
2405
  {
2323
- className: (0, import_classnames9.default)(
2406
+ className: (0, import_classnames10.default)(
2324
2407
  `r-rowcell p-0 fix-${col.fixedType}`,
2325
2408
  { "cell-fixed": col.fixedType },
2326
2409
  { "r-active": isSelected && editDisable || indexFocus === indexRow }
@@ -2338,7 +2421,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2338
2421
  return col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2339
2422
  "td",
2340
2423
  {
2341
- className: (0, import_classnames9.default)(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
2424
+ className: (0, import_classnames10.default)(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
2342
2425
  tabIndex: Number(`${indexRow}${indexCol}`),
2343
2426
  style: {
2344
2427
  left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
@@ -2390,7 +2473,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2390
2473
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2391
2474
  "td",
2392
2475
  {
2393
- className: (0, import_classnames9.default)(
2476
+ className: (0, import_classnames10.default)(
2394
2477
  `r-rowcell p-0 fix-${col.fixedType}`,
2395
2478
  { "cell-fixed": col.fixedType },
2396
2479
  { "r-active": isSelected && editDisable || indexFocus === indexRow }
@@ -2454,7 +2537,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2454
2537
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2455
2538
  "td",
2456
2539
  {
2457
- className: (0, import_classnames9.default)(
2540
+ className: (0, import_classnames10.default)(
2458
2541
  `r-rowcell fix-${col.fixedType}`,
2459
2542
  { "cell-fixed": col.fixedType },
2460
2543
  { "r-active": isSelected && editDisable || indexFocus === indexRow }
@@ -2499,7 +2582,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2499
2582
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2500
2583
  "div",
2501
2584
  {
2502
- className: (0, import_classnames9.default)("r-rowcell-div"),
2585
+ className: (0, import_classnames10.default)("r-rowcell-div"),
2503
2586
  style: {
2504
2587
  width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
2505
2588
  },
@@ -2507,7 +2590,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2507
2590
  "div",
2508
2591
  {
2509
2592
  id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "",
2510
- className: (0, import_classnames9.default)("r-rowcell-content", { "r-is-invalid": errorMessage }),
2593
+ className: (0, import_classnames10.default)("r-rowcell-content", { "r-is-invalid": errorMessage }),
2511
2594
  style: {
2512
2595
  margin: typeDis === 1 ? 2 : !errorMessage ? "7px 9px" : 2
2513
2596
  },
@@ -2524,7 +2607,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2524
2607
  children: typeDis === 2 ? col.template(row, indexRow) : value
2525
2608
  }
2526
2609
  ),
2527
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "icon-table", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ej2_react_popups.TooltipComponent, { className: (0, import_classnames9.default)("cursor-pointer text-primary", { "d-none": !errorMessage }), content: errorMessage?.toString() ?? "", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_becoxy_icons4.AlertCircle, { fontSize: 15.5 }) }) })
2610
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "icon-table", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_ej2_react_popups.TooltipComponent, { className: (0, import_classnames10.default)("cursor-pointer text-primary", { "d-none": !errorMessage }), content: errorMessage?.toString() ?? "", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_becoxy_icons4.AlertCircle, { fontSize: 15.5 }) }) })
2528
2611
  ]
2529
2612
  }
2530
2613
  )
@@ -2542,7 +2625,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2542
2625
  {
2543
2626
  rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
2544
2627
  colSpan: col.columns?.length ?? 1,
2545
- className: (0, import_classnames9.default)(
2628
+ className: (0, import_classnames10.default)(
2546
2629
  `r-headercell fix-${col.fixedType}`,
2547
2630
  { "cell-fixed": col.fixedType }
2548
2631
  ),
@@ -2561,13 +2644,13 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2561
2644
  height: `${(col.rowspan ?? 1) * 42}px`,
2562
2645
  justifyContent: col.textAlign ?? "left"
2563
2646
  },
2564
- className: (0, import_classnames9.default)("r-headercell-div"),
2647
+ className: (0, import_classnames10.default)("r-headercell-div"),
2565
2648
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2566
2649
  import_reactstrap8.Input,
2567
2650
  {
2568
2651
  checked: selectedRows?.length >= dataSource?.length && dataSource?.length > 0,
2569
2652
  type: "checkbox",
2570
- className: (0, import_classnames9.default)("cursor-pointer", { "d-none": !isMulti }),
2653
+ className: (0, import_classnames10.default)("cursor-pointer", { "d-none": !isMulti }),
2571
2654
  style: { textAlign: col.textAlign ?? "left", marginTop: 6 },
2572
2655
  onChange: (e) => {
2573
2656
  if (selectEnable) {
@@ -2596,7 +2679,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2596
2679
  {
2597
2680
  rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
2598
2681
  colSpan: col.columns?.length ?? 1,
2599
- className: (0, import_classnames9.default)(
2682
+ className: (0, import_classnames10.default)(
2600
2683
  `r-headercell fix-${col.fixedType}`,
2601
2684
  { "cell-fixed": col.fixedType }
2602
2685
  ),
@@ -2634,7 +2717,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2634
2717
  {
2635
2718
  rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
2636
2719
  colSpan: col.columns?.length ?? 1,
2637
- className: (0, import_classnames9.default)(
2720
+ className: (0, import_classnames10.default)(
2638
2721
  `r-headercell fix-${col.fixedType}`,
2639
2722
  { "cell-fixed": col.fixedType }
2640
2723
  ),
@@ -2670,7 +2753,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2670
2753
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2671
2754
  "td",
2672
2755
  {
2673
- className: (0, import_classnames9.default)(
2756
+ className: (0, import_classnames10.default)(
2674
2757
  `p-0 px-50 r-footer fix-${col.fixedType}`,
2675
2758
  { "cell-fixed": col.fixedType }
2676
2759
  ),
@@ -2704,15 +2787,15 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2704
2787
  const renderToolbarBottom = () => {
2705
2788
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { id: "table_custom_bottom_toolbar", className: "r-toolbar r-toolbar-bottom", role: "toolbar", "aria-disabled": "false", "aria-haspopup": "false", "aria-orientation": "horizontal", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "r-toolbar-items", children: [
2706
2789
  /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "r-toolbar-left", children: [
2707
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("r-toolbar-item", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: handleAdd, className: "d-flex", children: t("Add item") }) }),
2790
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames10.default)("r-toolbar-item", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: handleAdd, className: "d-flex", children: t("Add item") }) }),
2708
2791
  (indexFocus ?? -1) > -1 ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
2709
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("r-toolbar-item", { "d-none": editDisable || addDisable || duplicateDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: () => {
2792
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames10.default)("r-toolbar-item", { "d-none": editDisable || addDisable || duplicateDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: () => {
2710
2793
  handleDuplicate(dataSource[indexFocus ?? -1], indexFocus ?? -1);
2711
2794
  }, className: "d-flex", children: t("Duplicate") }) }),
2712
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("r-toolbar-item", { "d-none": editDisable || addDisable || insertBeforeDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: handleInsertBefore, className: "d-flex", children: t("Insert item before") }) }),
2713
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("r-toolbar-item", { "d-none": editDisable || addDisable || insertAfterDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: handleInsertAfter, className: "d-flex", children: t("Insert item after") }) })
2795
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames10.default)("r-toolbar-item", { "d-none": editDisable || addDisable || insertBeforeDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: handleInsertBefore, className: "d-flex", children: t("Insert item before") }) }),
2796
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames10.default)("r-toolbar-item", { "d-none": editDisable || addDisable || insertAfterDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "success", outline: true, onClick: handleInsertAfter, className: "d-flex", children: t("Insert item after") }) })
2714
2797
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: " " }),
2715
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("r-toolbar-item", { "d-none": editDisable || addDisable || deleteAllDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "primary", outline: true, onClick: handleDeleteAll, className: "d-flex", children: t("Delete all item") }) }),
2798
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames10.default)("r-toolbar-item", { "d-none": editDisable || addDisable || deleteAllDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.Button, { color: "primary", outline: true, onClick: handleDeleteAll, className: "d-flex", children: t("Delete all item") }) }),
2716
2799
  toolbarBottomOptions?.map((item, index) => {
2717
2800
  return item.align === "left" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-left-${index}`) : "";
2718
2801
  })
@@ -2724,8 +2807,8 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2724
2807
  toolbarBottomOptions?.map((item, index) => {
2725
2808
  return item.align === "right" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-right-${index}`) : "";
2726
2809
  }),
2727
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("r-toolbar-item me-25", { "d-none": headerColumns.length > 1 }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_becoxy_icons4.Settings, { className: "text-primary cursor-pointer", onClick: () => setOpenPopupSetupColumn(true) }) }),
2728
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames9.default)("r-toolbar-item me-25", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_reactstrap8.UncontrolledDropdown, { className: "dropdown-user nav-item", children: [
2810
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames10.default)("r-toolbar-item me-25", { "d-none": headerColumns.length > 1 }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_becoxy_icons4.Settings, { className: "text-primary cursor-pointer", onClick: () => setOpenPopupSetupColumn(true) }) }),
2811
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames10.default)("r-toolbar-item me-25", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_reactstrap8.UncontrolledDropdown, { className: "dropdown-user nav-item", children: [
2729
2812
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.DropdownToggle, { href: "/", tag: "a", color: "info", onClick: (e) => e.preventDefault(), children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_becoxy_icons4.Info, { className: "cursor-pointer" }) }),
2730
2813
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_reactstrap8.DropdownMenu, { children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "d-flex flex-column p-50 py-25", children: [
2731
2814
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + D \u0111\u1EC3 nh\xE2n b\u1EA3n" }),
@@ -2752,7 +2835,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2752
2835
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2753
2836
  "tr",
2754
2837
  {
2755
- className: (0, import_classnames9.default)("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }),
2838
+ className: (0, import_classnames10.default)("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }),
2756
2839
  children: contentColumns.map((col, indexCol) => {
2757
2840
  return renderContentCol(col, row, indexRow, indexCol, isSelected);
2758
2841
  })
@@ -2767,7 +2850,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2767
2850
  showBottomToolbar ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: renderToolbarBottom() }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {})
2768
2851
  ] }),
2769
2852
  allowPaging ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2770
- import_ej2_react_grids2.PagerComponent,
2853
+ import_ej2_react_grids.PagerComponent,
2771
2854
  {
2772
2855
  locale: lang,
2773
2856
  click: onChangePage,
@@ -2787,7 +2870,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2787
2870
  setOpenPopupSetupColumn(!openPopupSetupColumn);
2788
2871
  },
2789
2872
  openSidebar: openPopupSetupColumn,
2790
- column: contentColumns,
2873
+ column: [...contentColumns],
2791
2874
  setColumn: setContentColumns
2792
2875
  }
2793
2876
  )
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // test-app/src/component/table/index.tsx
2
- import { Fragment as Fragment12, forwardRef as forwardRef2, useEffect as useEffect5, useImperativeHandle, useRef as useRef3, useState as useState5 } from "react";
2
+ import { Fragment as Fragment12, forwardRef as forwardRef2, useEffect as useEffect5, useImperativeHandle, useRef as useRef2, useState as useState5 } from "react";
3
3
  import { Button as Button3, DropdownMenu as DropdownMenu2, DropdownToggle as DropdownToggle2, Input as Input6, UncontrolledDropdown } from "reactstrap";
4
- import classnames5 from "classnames";
4
+ import classnames6 from "classnames";
5
5
  import { useTranslation as useTranslation8 } from "react-i18next";
6
6
  import Select2 from "react-select";
7
7
  import { PagerComponent } from "@syncfusion/ej2-react-grids";
@@ -1020,18 +1020,9 @@ var EditForm = forwardRef((props, ref) => {
1020
1020
  var edit_form_default = EditForm;
1021
1021
 
1022
1022
  // test-app/src/component/sidebar-setting-column/index.tsx
1023
- import { Fragment as Fragment10, useEffect as useEffect4, useRef as useRef2, useState as useState4 } from "react";
1023
+ import { Fragment as Fragment10, useEffect as useEffect4, useState as useState4 } from "react";
1024
1024
  import { Button as Button2, Input as Input5 } from "reactstrap";
1025
1025
  import { useTranslation as useTranslation7 } from "react-i18next";
1026
- import {
1027
- GridComponent,
1028
- ColumnsDirective,
1029
- ColumnDirective,
1030
- Selection,
1031
- RowDD,
1032
- Inject,
1033
- CommandColumn
1034
- } from "@syncfusion/ej2-react-grids";
1035
1026
 
1036
1027
  // test-app/src/component/modal-header/index.tsx
1037
1028
  import { Edit, Info, Plus, X as X2 } from "becoxy-icons";
@@ -1182,16 +1173,18 @@ var Sidebar = (props) => {
1182
1173
  var sidebar_default = Sidebar;
1183
1174
 
1184
1175
  // test-app/src/component/sidebar-setting-column/index.tsx
1176
+ import classnames5 from "classnames";
1185
1177
  import { Fragment as Fragment11, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1186
1178
  var SidebarSetColumn = (props) => {
1187
1179
  const { column, setColumn, openSidebar, handleSidebar } = props;
1188
1180
  const { t } = useTranslation7();
1189
1181
  const [dataSource, setDataSource] = useState4([]);
1182
+ const [indexFocus, setIndexFocus] = useState4();
1190
1183
  useEffect4(() => {
1191
1184
  if (openSidebar) {
1192
- setDataSource([...column]);
1185
+ setDataSource(column.map((e) => ({ ...e })));
1193
1186
  }
1194
- }, [column, openSidebar]);
1187
+ }, [openSidebar]);
1195
1188
  const handleCancel = () => {
1196
1189
  handleSidebar();
1197
1190
  setDataSource([]);
@@ -1204,7 +1197,6 @@ var SidebarSetColumn = (props) => {
1204
1197
  const { innerWidth, innerHeight } = window;
1205
1198
  return { innerWidth, innerHeight };
1206
1199
  };
1207
- const gird = useRef2(null);
1208
1200
  const [windowSize, setWindowSize] = useState4(getWindowSize());
1209
1201
  useEffect4(() => {
1210
1202
  const handleWindowResize = () => {
@@ -1221,7 +1213,7 @@ var SidebarSetColumn = (props) => {
1221
1213
  /* @__PURE__ */ jsx11(Button2, { color: "secondary", onClick: handleCancel, outline: true, children: t("Close") })
1222
1214
  ] });
1223
1215
  };
1224
- const visibleTemplate = (item) => {
1216
+ const visibleTemplate = (item, index) => {
1225
1217
  return /* @__PURE__ */ jsx11(
1226
1218
  Input5,
1227
1219
  {
@@ -1232,14 +1224,14 @@ var SidebarSetColumn = (props) => {
1232
1224
  className: " cursor-pointer",
1233
1225
  onChange: (e) => {
1234
1226
  if (dataSource) {
1235
- item.column.dataSource[item.index].visible = e.target.checked;
1236
- setDataSource(item.column.dataSource);
1227
+ dataSource[index].visible = e.target.checked;
1228
+ setDataSource(dataSource);
1237
1229
  }
1238
1230
  }
1239
1231
  }
1240
1232
  );
1241
1233
  };
1242
- const fixColumnTemplate = (item) => {
1234
+ const fixColumnTemplate = (item, index) => {
1243
1235
  return /* @__PURE__ */ jsx11(
1244
1236
  Input5,
1245
1237
  {
@@ -1250,15 +1242,15 @@ var SidebarSetColumn = (props) => {
1250
1242
  onChange: (e) => {
1251
1243
  if (dataSource) {
1252
1244
  if (e.target.checked) {
1253
- if (item.index * 2 <= item.column.dataSource.length) {
1254
- item.column.dataSource[item.index].fixedType = "left";
1245
+ if (index * 2 <= dataSource.length) {
1246
+ dataSource[index].fixedType = "left";
1255
1247
  } else {
1256
- item.column.dataSource[item.index].fixedType = "right";
1248
+ dataSource[index].fixedType = "right";
1257
1249
  }
1258
1250
  } else {
1259
- item.column.dataSource[item.index].fixedType = "";
1251
+ dataSource[index].fixedType = void 0;
1260
1252
  }
1261
- setDataSource(item.column.dataSource);
1253
+ setDataSource(dataSource);
1262
1254
  }
1263
1255
  }
1264
1256
  }
@@ -1266,53 +1258,82 @@ var SidebarSetColumn = (props) => {
1266
1258
  };
1267
1259
  const columns = [
1268
1260
  {
1269
- isPrimaryKey: true,
1270
1261
  field: "headerText",
1271
1262
  headerText: "Column name",
1272
1263
  template: (e) => {
1273
1264
  return /* @__PURE__ */ jsx11(Fragment11, { children: t(e.headerText) });
1274
1265
  },
1275
1266
  visible: true,
1276
- width: 100,
1277
- maxWidth: 120,
1278
- minWidth: 80
1267
+ width: 175,
1268
+ maxWidth: 200,
1269
+ minWidth: 150
1279
1270
  },
1280
1271
  {
1281
- isPrimaryKey: true,
1272
+ field: "",
1282
1273
  template: visibleTemplate,
1283
1274
  headerText: "Display",
1284
- dataSource,
1275
+ textAlign: "center",
1285
1276
  visible: true,
1286
1277
  width: 100,
1287
1278
  maxWidth: 120,
1288
1279
  minWidth: 80
1289
1280
  },
1290
1281
  {
1291
- isPrimaryKey: true,
1282
+ field: "",
1292
1283
  template: fixColumnTemplate,
1293
1284
  headerText: "Fix the column",
1294
- dataSource,
1285
+ textAlign: "center",
1295
1286
  visible: true,
1296
1287
  width: 100,
1297
1288
  maxWidth: 120,
1298
1289
  minWidth: 80
1299
1290
  },
1300
1291
  {
1301
- isPrimaryKey: true,
1302
1292
  field: "width",
1303
1293
  headerText: "Column width",
1304
- template: (item) => {
1305
- return item.width ? /* @__PURE__ */ jsxs10(Fragment11, { children: [
1306
- t(item.width),
1307
- "px"
1308
- ] }) : /* @__PURE__ */ jsx11(Fragment11, {});
1309
- },
1294
+ textAlign: "right",
1310
1295
  visible: true,
1311
1296
  width: 100,
1312
1297
  maxWidth: 120,
1313
1298
  minWidth: 80
1314
1299
  }
1315
1300
  ];
1301
+ const renderHeaderCol = (col, indexCol) => {
1302
+ return /* @__PURE__ */ jsx11(
1303
+ Fragment10,
1304
+ {
1305
+ children: col.visible !== false && /* @__PURE__ */ jsx11(
1306
+ "th",
1307
+ {
1308
+ className: classnames5(
1309
+ `r-headercell fix-${col.fixedType}`,
1310
+ { "cell-fixed": col.fixedType }
1311
+ ),
1312
+ style: {
1313
+ width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
1314
+ minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
1315
+ top: `${0 * 42}px`,
1316
+ maxWidth: col.maxWidth
1317
+ },
1318
+ children: /* @__PURE__ */ jsx11(
1319
+ "div",
1320
+ {
1321
+ role: "textbox",
1322
+ title: t(col.headerText ?? ""),
1323
+ style: {
1324
+ height: `${1 * 42}px`,
1325
+ justifyContent: col.textAlign ?? "left"
1326
+ },
1327
+ className: "r-headercell-div",
1328
+ children: t(col.headerText ?? "")
1329
+ }
1330
+ )
1331
+ }
1332
+ )
1333
+ },
1334
+ `header-${indexCol}`
1335
+ );
1336
+ };
1316
1337
  return /* @__PURE__ */ jsxs10(
1317
1338
  sidebar_default,
1318
1339
  {
@@ -1321,20 +1342,74 @@ var SidebarSetColumn = (props) => {
1321
1342
  width: 700,
1322
1343
  children: [
1323
1344
  /* @__PURE__ */ jsx11(modal_header_default, { typeModal: "Edit", handleModal: handleCancel, title: "Column setup" }),
1324
- /* @__PURE__ */ jsxs10(
1325
- GridComponent,
1326
- {
1327
- className: "ms-2",
1328
- dataSource,
1329
- ref: gird,
1330
- height: windowSize.innerHeight - 160,
1331
- allowRowDragAndDrop: true,
1332
- children: [
1333
- /* @__PURE__ */ jsx11(ColumnsDirective, { children: columns.map((col, index) => /* @__PURE__ */ jsx11(ColumnDirective, { ...col, headerText: t(col.headerText) }, index)) }),
1334
- /* @__PURE__ */ jsx11(Inject, { services: [RowDD, Selection, CommandColumn] })
1335
- ]
1336
- }
1337
- ),
1345
+ /* @__PURE__ */ jsx11("div", { className: "ms-2 react-table-edit", children: /* @__PURE__ */ jsx11("div", { className: "r-grid", children: /* @__PURE__ */ jsx11("div", { className: "r-gridtable", style: { height: windowSize.innerHeight - 120 }, children: /* @__PURE__ */ jsxs10("table", { style: { width: "100%" }, children: [
1346
+ /* @__PURE__ */ jsx11("thead", { className: "r-gridheader", children: /* @__PURE__ */ jsx11("tr", { className: "r-row", role: "row", children: columns.map((col, index) => {
1347
+ return renderHeaderCol(col, index);
1348
+ }) }) }),
1349
+ /* @__PURE__ */ jsx11("tbody", { className: "r-gridcontent", children: dataSource?.map((row, indexRow) => {
1350
+ return /* @__PURE__ */ jsx11(
1351
+ "tr",
1352
+ {
1353
+ className: classnames5("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }),
1354
+ children: columns.map((col, indexCol) => {
1355
+ let value = row[col.field];
1356
+ if (col.editType === "numeric" || col.editTypeCondition && col.editTypeCondition(row) === "numeric") {
1357
+ value = formartNumberic(row[col.field], ",", ".", col.numericSettings?.fraction, true) ?? 0;
1358
+ }
1359
+ return /* @__PURE__ */ jsx11(Fragment10, { children: col.visible !== false && /* @__PURE__ */ jsx11(
1360
+ "td",
1361
+ {
1362
+ className: classnames5(
1363
+ `r-rowcell fix-${col.fixedType}`,
1364
+ { "cell-fixed": col.fixedType },
1365
+ { "r-active": indexFocus === indexRow }
1366
+ ),
1367
+ style: {
1368
+ padding: 0,
1369
+ textAlign: col.textAlign ? col.textAlign : "left"
1370
+ },
1371
+ onFocus: (e) => {
1372
+ if (indexRow !== indexFocus) {
1373
+ setIndexFocus(indexRow);
1374
+ }
1375
+ e.stopPropagation();
1376
+ },
1377
+ onClick: (e) => {
1378
+ if (e.target.nodeName === "DIV" || e.target.nodeName === "TD") {
1379
+ if (indexRow !== indexFocus) {
1380
+ setIndexFocus(indexRow);
1381
+ }
1382
+ e.stopPropagation();
1383
+ }
1384
+ },
1385
+ children: /* @__PURE__ */ jsx11(
1386
+ "div",
1387
+ {
1388
+ className: classnames5("r-rowcell-div"),
1389
+ style: {
1390
+ width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
1391
+ },
1392
+ children: /* @__PURE__ */ jsx11(
1393
+ "div",
1394
+ {
1395
+ className: classnames5("r-rowcell-content"),
1396
+ style: {
1397
+ margin: "7px 9px"
1398
+ },
1399
+ children: /* @__PURE__ */ jsx11("div", { className: "r-cell-text", children: col.template ? col.template(row, indexRow) : value })
1400
+ }
1401
+ )
1402
+ }
1403
+ )
1404
+ },
1405
+ `col-${indexRow}-${indexCol}`
1406
+ ) }, indexCol);
1407
+ })
1408
+ },
1409
+ `row-${indexRow}`
1410
+ );
1411
+ }) })
1412
+ ] }) }) }) }),
1338
1413
  /* @__PURE__ */ jsx11(
1339
1414
  "div",
1340
1415
  {
@@ -1410,8 +1485,8 @@ var TableEdit = forwardRef2((props, ref) => {
1410
1485
  const [objWidthFix, setObjWidthFix] = useState5({});
1411
1486
  const [openPopupTree, setOpenPopupTree] = useState5(false);
1412
1487
  const [openPopupSetupColumn, setOpenPopupSetupColumn] = useState5(false);
1413
- const tableElement = useRef3(null);
1414
- const gridRef = useRef3();
1488
+ const tableElement = useRef2(null);
1489
+ const gridRef = useRef2();
1415
1490
  const lag = window.localStorage.getItem("i18nextLng");
1416
1491
  const lang = lag ? lag : "vi";
1417
1492
  const fieldKey = columns.find((item) => item.isPrimarykey === true)?.field ?? "id";
@@ -1586,7 +1661,7 @@ var TableEdit = forwardRef2((props, ref) => {
1586
1661
  }
1587
1662
  handleDataChange(row, col, indexRow);
1588
1663
  },
1589
- className: classnames5("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1664
+ className: classnames6("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1590
1665
  type: "date",
1591
1666
  max: "9999-12-31",
1592
1667
  onKeyDown: (e) => {
@@ -1609,7 +1684,7 @@ var TableEdit = forwardRef2((props, ref) => {
1609
1684
  }
1610
1685
  handleDataChange(row, col, indexRow);
1611
1686
  },
1612
- className: classnames5("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1687
+ className: classnames6("border-0 rounded-0", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1613
1688
  type: "datetime-local",
1614
1689
  max: "9999-12-31T23:59",
1615
1690
  onKeyDown: (e) => {
@@ -1629,7 +1704,7 @@ var TableEdit = forwardRef2((props, ref) => {
1629
1704
  if (!valueAsyncSelect && col.selectSettings?.defaultValue) {
1630
1705
  valueAsyncSelect = col.selectSettings?.defaultValue(row);
1631
1706
  }
1632
- return /* @__PURE__ */ jsxs11("div", { className: classnames5("d-flex select-group", { "is-invalid": col.validate && col.validate(row[col.field], row) }), children: [
1707
+ return /* @__PURE__ */ jsxs11("div", { className: classnames6("d-flex select-group", { "is-invalid": col.validate && col.validate(row[col.field], row) }), children: [
1633
1708
  /* @__PURE__ */ jsx12(
1634
1709
  AsyncSelect,
1635
1710
  {
@@ -1649,7 +1724,7 @@ var TableEdit = forwardRef2((props, ref) => {
1649
1724
  placeholder: t("Select"),
1650
1725
  id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1651
1726
  loadOptions: col.selectSettings?.loadOptions,
1652
- className: classnames5("react-select"),
1727
+ className: classnames6("react-select"),
1653
1728
  onKeyDown: (e) => {
1654
1729
  if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
1655
1730
  }
@@ -1664,7 +1739,7 @@ var TableEdit = forwardRef2((props, ref) => {
1664
1739
  col.selectSettings?.handIconGroupClick("right");
1665
1740
  }
1666
1741
  },
1667
- className: classnames5("input-group-text", { "d-none": !col.selectSettings?.iconGroup }),
1742
+ className: classnames6("input-group-text", { "d-none": !col.selectSettings?.iconGroup }),
1668
1743
  children: /* @__PURE__ */ jsx12(icon_default, { iconName: col.selectSettings?.iconGroup ?? "", size: 16 })
1669
1744
  }
1670
1745
  )
@@ -1701,7 +1776,7 @@ var TableEdit = forwardRef2((props, ref) => {
1701
1776
  isClearable: col.selectSettings?.isClearable ?? false,
1702
1777
  classNamePrefix: col.selectSettings?.widthPopup ? `select-${col.selectSettings?.widthPopup}` : "select",
1703
1778
  placeholder: t("Select"),
1704
- className: classnames5("react-select", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1779
+ className: classnames6("react-select", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1705
1780
  onKeyDown: (e) => {
1706
1781
  if (checkKeyDown(e, row, col, indexRow + 1, indexCol + 1)) {
1707
1782
  }
@@ -1741,7 +1816,7 @@ var TableEdit = forwardRef2((props, ref) => {
1741
1816
  parentValue: "parentId",
1742
1817
  child: "children"
1743
1818
  },
1744
- className: classnames5("select-tree", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1819
+ className: classnames6("select-tree", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1745
1820
  allowFiltering: false,
1746
1821
  value: valueSelectTree,
1747
1822
  popupHeight: 250,
@@ -1798,7 +1873,7 @@ var TableEdit = forwardRef2((props, ref) => {
1798
1873
  id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1799
1874
  style: { textAlign: col.textAlign, height: 29 },
1800
1875
  defaultValue: formartNumberic(valueCurrency, decimalSeparator, thousandSeparator, col.numericSettings?.fraction),
1801
- className: classnames5("border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1876
+ className: classnames6("border-0 rounded-0 input-numeric", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1802
1877
  onChange: (val) => {
1803
1878
  let newVal = "";
1804
1879
  const flag = val.target?.value.startsWith("-");
@@ -1933,7 +2008,7 @@ var TableEdit = forwardRef2((props, ref) => {
1933
2008
  id: `${idTable}-col${indexCol + 1}-row${indexRow + 1}`,
1934
2009
  style: { textAlign: col.textAlign, height: 29 },
1935
2010
  defaultValue: isNullOrUndefined(row[col.field]) ? "" : row[col.field],
1936
- className: classnames5("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
2011
+ className: classnames6("border-0 rounded-0 input-element", { "is-invalid": col.validate && col.validate(row[col.field], row) }),
1937
2012
  onBlur: (val) => {
1938
2013
  if (row[col.field] != val.target?.value) {
1939
2014
  row[col.field] = val.target?.value;
@@ -1977,7 +2052,7 @@ var TableEdit = forwardRef2((props, ref) => {
1977
2052
  {
1978
2053
  tabIndex: -1,
1979
2054
  style: { padding: "5px", minWidth: 45, height: "100%" },
1980
- className: classnames5("command-item", {
2055
+ className: classnames6("command-item", {
1981
2056
  "btn-icon": item.tooltip === ""
1982
2057
  }),
1983
2058
  color: item.color ? item.color : "#000",
@@ -2006,7 +2081,7 @@ var TableEdit = forwardRef2((props, ref) => {
2006
2081
  if (newIndexCol > -1) {
2007
2082
  const element = document.getElementById(`${idTable}-col${newIndexCol}-row${indexRow}`);
2008
2083
  if (element) {
2009
- if (element.className.includes("react-select") || element.className.includes("from-edit")) {
2084
+ if (element.className.includes("react-select") || element.className.includes("form-edit")) {
2010
2085
  element.getElementsByTagName("input")[0]?.focus();
2011
2086
  } else {
2012
2087
  element.focus();
@@ -2027,7 +2102,7 @@ var TableEdit = forwardRef2((props, ref) => {
2027
2102
  if (newIndexCol > -1) {
2028
2103
  const element = document.getElementById(`${idTable}-col${newIndexCol}-row${indexRow}`);
2029
2104
  if (element) {
2030
- if (element.className.includes("react-select") || element.className.includes("from-edit")) {
2105
+ if (element.className.includes("react-select") || element.className.includes("form-edit")) {
2031
2106
  element.getElementsByTagName("input")[0]?.focus();
2032
2107
  } else {
2033
2108
  element.focus();
@@ -2045,7 +2120,7 @@ var TableEdit = forwardRef2((props, ref) => {
2045
2120
  setTimeout(() => {
2046
2121
  const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow - 1}`);
2047
2122
  if (element2) {
2048
- if (element2.className.includes("react-select") || element2.className.includes("from-edit")) {
2123
+ if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
2049
2124
  element2.getElementsByTagName("input")[0]?.focus();
2050
2125
  } else {
2051
2126
  element2.focus();
@@ -2065,7 +2140,7 @@ var TableEdit = forwardRef2((props, ref) => {
2065
2140
  setTimeout(() => {
2066
2141
  const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
2067
2142
  if (element2) {
2068
- if (element2.className.includes("react-select") || element2.className.includes("from-edit")) {
2143
+ if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
2069
2144
  element2.getElementsByTagName("input")[0]?.focus();
2070
2145
  } else {
2071
2146
  element2.focus();
@@ -2093,7 +2168,7 @@ var TableEdit = forwardRef2((props, ref) => {
2093
2168
  setTimeout(() => {
2094
2169
  const element = document.getElementById(`${idTable}-col${columnFistEdit}-row${indexRow + 1}`);
2095
2170
  if (element) {
2096
- if (element.className.includes("react-select") || element.className.includes("from-edit")) {
2171
+ if (element.className.includes("react-select") || element.className.includes("form-edit")) {
2097
2172
  element.getElementsByTagName("input")[0]?.focus();
2098
2173
  } else {
2099
2174
  element.focus();
@@ -2111,7 +2186,7 @@ var TableEdit = forwardRef2((props, ref) => {
2111
2186
  setTimeout(() => {
2112
2187
  const element2 = document.getElementById(`${idTable}-col${indexCol}-row${indexRow + 1}`);
2113
2188
  if (element2) {
2114
- if (element2.className.includes("react-select") || element2.className.includes("from-edit")) {
2189
+ if (element2.className.includes("react-select") || element2.className.includes("form-edit")) {
2115
2190
  element2.getElementsByTagName("input")[0]?.focus();
2116
2191
  } else {
2117
2192
  element2.focus();
@@ -2161,7 +2236,7 @@ var TableEdit = forwardRef2((props, ref) => {
2161
2236
  tableElement.current?.scrollTo(0, tableElement.current.scrollHeight);
2162
2237
  const element = document.getElementById(`${idTable}-col${columnFistEdit}-row${dataSource?.length + 1}`);
2163
2238
  if (element && !(element.getElementsByClassName("select__control--menu-is-open").length > 0 || element.getElementsByClassName("select-100__control--menu-is-open").length > 0 || element.getElementsByClassName("select-200__control--menu-is-open").length > 0 || element.getElementsByClassName("select-300__control--menu-is-open").length > 0 || element.getElementsByClassName("select-400__control--menu-is-open").length > 0 || element.getElementsByClassName("select-500__control--menu-is-open").length > 0)) {
2164
- if (element.className.includes("react-select") || element.className.includes("from-edit")) {
2239
+ if (element.className.includes("react-select") || element.className.includes("form-edit")) {
2165
2240
  element.getElementsByTagName("input")[0]?.focus();
2166
2241
  } else {
2167
2242
  element.focus();
@@ -2242,7 +2317,7 @@ var TableEdit = forwardRef2((props, ref) => {
2242
2317
  const changeDataSource = (data, haveNew = false) => {
2243
2318
  if (!editDisable && !addDisable && setDataSource) {
2244
2319
  if (haveNew) {
2245
- data.push(defaultValue ? { ...defaultValue, "fieldKey": generateUUID() } : {});
2320
+ data.push(defaultValue ? { ...defaultValue, [fieldKey]: generateUUID() } : {});
2246
2321
  }
2247
2322
  }
2248
2323
  setDataSource([...data]);
@@ -2294,7 +2369,7 @@ var TableEdit = forwardRef2((props, ref) => {
2294
2369
  return col.visible !== false && /* @__PURE__ */ jsx12(
2295
2370
  "td",
2296
2371
  {
2297
- className: classnames5(
2372
+ className: classnames6(
2298
2373
  `r-rowcell p-0 fix-${col.fixedType}`,
2299
2374
  { "cell-fixed": col.fixedType },
2300
2375
  { "r-active": isSelected && editDisable || indexFocus === indexRow }
@@ -2312,7 +2387,7 @@ var TableEdit = forwardRef2((props, ref) => {
2312
2387
  return col.visible !== false && /* @__PURE__ */ jsx12(
2313
2388
  "td",
2314
2389
  {
2315
- className: classnames5(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
2390
+ className: classnames6(`r-rowcell p-0 cursor-pointer fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "r-active": isSelected && editDisable || indexFocus === indexRow }),
2316
2391
  tabIndex: Number(`${indexRow}${indexCol}`),
2317
2392
  style: {
2318
2393
  left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
@@ -2364,7 +2439,7 @@ var TableEdit = forwardRef2((props, ref) => {
2364
2439
  return /* @__PURE__ */ jsx12(
2365
2440
  "td",
2366
2441
  {
2367
- className: classnames5(
2442
+ className: classnames6(
2368
2443
  `r-rowcell p-0 fix-${col.fixedType}`,
2369
2444
  { "cell-fixed": col.fixedType },
2370
2445
  { "r-active": isSelected && editDisable || indexFocus === indexRow }
@@ -2428,7 +2503,7 @@ var TableEdit = forwardRef2((props, ref) => {
2428
2503
  return /* @__PURE__ */ jsx12(Fragment12, { children: col.visible !== false && /* @__PURE__ */ jsx12(
2429
2504
  "td",
2430
2505
  {
2431
- className: classnames5(
2506
+ className: classnames6(
2432
2507
  `r-rowcell fix-${col.fixedType}`,
2433
2508
  { "cell-fixed": col.fixedType },
2434
2509
  { "r-active": isSelected && editDisable || indexFocus === indexRow }
@@ -2473,7 +2548,7 @@ var TableEdit = forwardRef2((props, ref) => {
2473
2548
  children: /* @__PURE__ */ jsx12(
2474
2549
  "div",
2475
2550
  {
2476
- className: classnames5("r-rowcell-div"),
2551
+ className: classnames6("r-rowcell-div"),
2477
2552
  style: {
2478
2553
  width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : "auto"
2479
2554
  },
@@ -2481,7 +2556,7 @@ var TableEdit = forwardRef2((props, ref) => {
2481
2556
  "div",
2482
2557
  {
2483
2558
  id: indexFocus === indexRow && typeDis !== 1 ? `${idTable}-col${indexCol + 1}-row${indexRow + 1}` : "",
2484
- className: classnames5("r-rowcell-content", { "r-is-invalid": errorMessage }),
2559
+ className: classnames6("r-rowcell-content", { "r-is-invalid": errorMessage }),
2485
2560
  style: {
2486
2561
  margin: typeDis === 1 ? 2 : !errorMessage ? "7px 9px" : 2
2487
2562
  },
@@ -2498,7 +2573,7 @@ var TableEdit = forwardRef2((props, ref) => {
2498
2573
  children: typeDis === 2 ? col.template(row, indexRow) : value
2499
2574
  }
2500
2575
  ),
2501
- /* @__PURE__ */ jsx12("span", { className: "icon-table", children: /* @__PURE__ */ jsx12(TooltipComponent, { className: classnames5("cursor-pointer text-primary", { "d-none": !errorMessage }), content: errorMessage?.toString() ?? "", children: /* @__PURE__ */ jsx12(AlertCircle, { fontSize: 15.5 }) }) })
2576
+ /* @__PURE__ */ jsx12("span", { className: "icon-table", children: /* @__PURE__ */ jsx12(TooltipComponent, { className: classnames6("cursor-pointer text-primary", { "d-none": !errorMessage }), content: errorMessage?.toString() ?? "", children: /* @__PURE__ */ jsx12(AlertCircle, { fontSize: 15.5 }) }) })
2502
2577
  ]
2503
2578
  }
2504
2579
  )
@@ -2516,7 +2591,7 @@ var TableEdit = forwardRef2((props, ref) => {
2516
2591
  {
2517
2592
  rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
2518
2593
  colSpan: col.columns?.length ?? 1,
2519
- className: classnames5(
2594
+ className: classnames6(
2520
2595
  `r-headercell fix-${col.fixedType}`,
2521
2596
  { "cell-fixed": col.fixedType }
2522
2597
  ),
@@ -2535,13 +2610,13 @@ var TableEdit = forwardRef2((props, ref) => {
2535
2610
  height: `${(col.rowspan ?? 1) * 42}px`,
2536
2611
  justifyContent: col.textAlign ?? "left"
2537
2612
  },
2538
- className: classnames5("r-headercell-div"),
2613
+ className: classnames6("r-headercell-div"),
2539
2614
  children: /* @__PURE__ */ jsx12(
2540
2615
  Input6,
2541
2616
  {
2542
2617
  checked: selectedRows?.length >= dataSource?.length && dataSource?.length > 0,
2543
2618
  type: "checkbox",
2544
- className: classnames5("cursor-pointer", { "d-none": !isMulti }),
2619
+ className: classnames6("cursor-pointer", { "d-none": !isMulti }),
2545
2620
  style: { textAlign: col.textAlign ?? "left", marginTop: 6 },
2546
2621
  onChange: (e) => {
2547
2622
  if (selectEnable) {
@@ -2570,7 +2645,7 @@ var TableEdit = forwardRef2((props, ref) => {
2570
2645
  {
2571
2646
  rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
2572
2647
  colSpan: col.columns?.length ?? 1,
2573
- className: classnames5(
2648
+ className: classnames6(
2574
2649
  `r-headercell fix-${col.fixedType}`,
2575
2650
  { "cell-fixed": col.fixedType }
2576
2651
  ),
@@ -2608,7 +2683,7 @@ var TableEdit = forwardRef2((props, ref) => {
2608
2683
  {
2609
2684
  rowSpan: col.rowspan !== 1 ? col.rowspan : void 0,
2610
2685
  colSpan: col.columns?.length ?? 1,
2611
- className: classnames5(
2686
+ className: classnames6(
2612
2687
  `r-headercell fix-${col.fixedType}`,
2613
2688
  { "cell-fixed": col.fixedType }
2614
2689
  ),
@@ -2644,7 +2719,7 @@ var TableEdit = forwardRef2((props, ref) => {
2644
2719
  return /* @__PURE__ */ jsx12(Fragment12, { children: col.visible !== false && /* @__PURE__ */ jsx12(
2645
2720
  "td",
2646
2721
  {
2647
- className: classnames5(
2722
+ className: classnames6(
2648
2723
  `p-0 px-50 r-footer fix-${col.fixedType}`,
2649
2724
  { "cell-fixed": col.fixedType }
2650
2725
  ),
@@ -2678,15 +2753,15 @@ var TableEdit = forwardRef2((props, ref) => {
2678
2753
  const renderToolbarBottom = () => {
2679
2754
  return /* @__PURE__ */ jsx12("div", { id: "table_custom_bottom_toolbar", className: "r-toolbar r-toolbar-bottom", role: "toolbar", "aria-disabled": "false", "aria-haspopup": "false", "aria-orientation": "horizontal", children: /* @__PURE__ */ jsxs11("div", { className: "r-toolbar-items", children: [
2680
2755
  /* @__PURE__ */ jsxs11("div", { className: "r-toolbar-left", children: [
2681
- /* @__PURE__ */ jsx12("div", { className: classnames5("r-toolbar-item", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "success", outline: true, onClick: handleAdd, className: "d-flex", children: t("Add item") }) }),
2756
+ /* @__PURE__ */ jsx12("div", { className: classnames6("r-toolbar-item", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "success", outline: true, onClick: handleAdd, className: "d-flex", children: t("Add item") }) }),
2682
2757
  (indexFocus ?? -1) > -1 ? /* @__PURE__ */ jsxs11(Fragment13, { children: [
2683
- /* @__PURE__ */ jsx12("div", { className: classnames5("r-toolbar-item", { "d-none": editDisable || addDisable || duplicateDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "success", outline: true, onClick: () => {
2758
+ /* @__PURE__ */ jsx12("div", { className: classnames6("r-toolbar-item", { "d-none": editDisable || addDisable || duplicateDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "success", outline: true, onClick: () => {
2684
2759
  handleDuplicate(dataSource[indexFocus ?? -1], indexFocus ?? -1);
2685
2760
  }, className: "d-flex", children: t("Duplicate") }) }),
2686
- /* @__PURE__ */ jsx12("div", { className: classnames5("r-toolbar-item", { "d-none": editDisable || addDisable || insertBeforeDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "success", outline: true, onClick: handleInsertBefore, className: "d-flex", children: t("Insert item before") }) }),
2687
- /* @__PURE__ */ jsx12("div", { className: classnames5("r-toolbar-item", { "d-none": editDisable || addDisable || insertAfterDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "success", outline: true, onClick: handleInsertAfter, className: "d-flex", children: t("Insert item after") }) })
2761
+ /* @__PURE__ */ jsx12("div", { className: classnames6("r-toolbar-item", { "d-none": editDisable || addDisable || insertBeforeDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "success", outline: true, onClick: handleInsertBefore, className: "d-flex", children: t("Insert item before") }) }),
2762
+ /* @__PURE__ */ jsx12("div", { className: classnames6("r-toolbar-item", { "d-none": editDisable || addDisable || insertAfterDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "success", outline: true, onClick: handleInsertAfter, className: "d-flex", children: t("Insert item after") }) })
2688
2763
  ] }) : /* @__PURE__ */ jsx12(Fragment13, { children: " " }),
2689
- /* @__PURE__ */ jsx12("div", { className: classnames5("r-toolbar-item", { "d-none": editDisable || addDisable || deleteAllDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "primary", outline: true, onClick: handleDeleteAll, className: "d-flex", children: t("Delete all item") }) }),
2764
+ /* @__PURE__ */ jsx12("div", { className: classnames6("r-toolbar-item", { "d-none": editDisable || addDisable || deleteAllDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "primary", outline: true, onClick: handleDeleteAll, className: "d-flex", children: t("Delete all item") }) }),
2690
2765
  toolbarBottomOptions?.map((item, index) => {
2691
2766
  return item.align === "left" ? /* @__PURE__ */ jsx12("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-left-${index}`) : "";
2692
2767
  })
@@ -2698,8 +2773,8 @@ var TableEdit = forwardRef2((props, ref) => {
2698
2773
  toolbarBottomOptions?.map((item, index) => {
2699
2774
  return item.align === "right" ? /* @__PURE__ */ jsx12("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-right-${index}`) : "";
2700
2775
  }),
2701
- /* @__PURE__ */ jsx12("div", { className: classnames5("r-toolbar-item me-25", { "d-none": headerColumns.length > 1 }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Settings, { className: "text-primary cursor-pointer", onClick: () => setOpenPopupSetupColumn(true) }) }),
2702
- /* @__PURE__ */ jsx12("div", { className: classnames5("r-toolbar-item me-25", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsxs11(UncontrolledDropdown, { className: "dropdown-user nav-item", children: [
2776
+ /* @__PURE__ */ jsx12("div", { className: classnames6("r-toolbar-item me-25", { "d-none": headerColumns.length > 1 }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Settings, { className: "text-primary cursor-pointer", onClick: () => setOpenPopupSetupColumn(true) }) }),
2777
+ /* @__PURE__ */ jsx12("div", { className: classnames6("r-toolbar-item me-25", { "d-none": editDisable || addDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsxs11(UncontrolledDropdown, { className: "dropdown-user nav-item", children: [
2703
2778
  /* @__PURE__ */ jsx12(DropdownToggle2, { href: "/", tag: "a", color: "info", onClick: (e) => e.preventDefault(), children: /* @__PURE__ */ jsx12(Info2, { className: "cursor-pointer" }) }),
2704
2779
  /* @__PURE__ */ jsx12(DropdownMenu2, { children: /* @__PURE__ */ jsxs11("div", { className: "d-flex flex-column p-50 py-25", children: [
2705
2780
  /* @__PURE__ */ jsx12("div", { style: { fontSize: 13 }, children: "Nh\u1EA5n v\xE0o c\u1ED9t STT \u0111\u1EC3 ch\u1ECDn h\xE0ng v\xE0 nh\u1EA5n Ctrl + D \u0111\u1EC3 nh\xE2n b\u1EA3n" }),
@@ -2726,7 +2801,7 @@ var TableEdit = forwardRef2((props, ref) => {
2726
2801
  return /* @__PURE__ */ jsx12(
2727
2802
  "tr",
2728
2803
  {
2729
- className: classnames5("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }),
2804
+ className: classnames6("r-row", { "last-row": indexRow === dataSource.length - 1 }, { "fisrt-row": indexRow === 0 }),
2730
2805
  children: contentColumns.map((col, indexCol) => {
2731
2806
  return renderContentCol(col, row, indexRow, indexCol, isSelected);
2732
2807
  })
@@ -2761,7 +2836,7 @@ var TableEdit = forwardRef2((props, ref) => {
2761
2836
  setOpenPopupSetupColumn(!openPopupSetupColumn);
2762
2837
  },
2763
2838
  openSidebar: openPopupSetupColumn,
2764
- column: contentColumns,
2839
+ column: [...contentColumns],
2765
2840
  setColumn: setContentColumns
2766
2841
  }
2767
2842
  )
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-table-edit",
3
3
  "license": "MIT",
4
- "version": "0.2.7",
4
+ "version": "0.2.9",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",