react-table-edit 0.0.1 → 0.0.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.
Files changed (3) hide show
  1. package/dist/index.js +104 -63
  2. package/dist/index.mjs +104 -63
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -42,7 +42,7 @@ __export(Table_edit_exports, {
42
42
  });
43
43
  module.exports = __toCommonJS(Table_edit_exports);
44
44
 
45
- // test-app/component/table/index.tsx
45
+ // test-app/src/component/table/index.tsx
46
46
  var import_react12 = require("react");
47
47
  var import_reactstrap8 = require("reactstrap");
48
48
  var import_classnames9 = __toESM(require("classnames"));
@@ -52,7 +52,7 @@ var import_ej2_react_grids2 = 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
 
55
- // test-app/component/react-input/index.tsx
55
+ // test-app/src/component/react-input/index.tsx
56
56
  var import_becoxy_icons = require("becoxy-icons");
57
57
  var import_classnames = __toESM(require("classnames"));
58
58
  var import_react = require("react");
@@ -84,7 +84,7 @@ var ReactInput = (props) => {
84
84
  };
85
85
  var react_input_default = ReactInput;
86
86
 
87
- // test-app/component/notifications.tsx
87
+ // test-app/src/component/notifications.tsx
88
88
  var import_react2 = require("react");
89
89
  var import_sweetalert2 = __toESM(require("sweetalert2"));
90
90
  var import_sweetalert2_react_content = __toESM(require("sweetalert2-react-content"));
@@ -219,7 +219,7 @@ var messageBoxConfirm2 = async (t, data, data2, message) => {
219
219
  });
220
220
  };
221
221
 
222
- // test-app/component/utils.ts
222
+ // test-app/src/component/utils.ts
223
223
  var import_react3 = require("react");
224
224
  var useOnClickOutside = (ref, handler) => {
225
225
  (0, import_react3.useEffect)(
@@ -296,7 +296,7 @@ var formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10,
296
296
  }
297
297
  };
298
298
 
299
- // test-app/component/icon/index.tsx
299
+ // test-app/src/component/icon/index.tsx
300
300
  var Icon = __toESM(require("becoxy-icons"));
301
301
  var import_react4 = require("react");
302
302
  var import_jsx_runtime3 = require("react/jsx-runtime");
@@ -311,11 +311,11 @@ var IconCustom = (props) => {
311
311
  };
312
312
  var icon_default = IconCustom;
313
313
 
314
- // test-app/component/table/index.tsx
314
+ // test-app/src/component/table/index.tsx
315
315
  var import_moment = __toESM(require("moment"));
316
316
  var import_ej2_react_dropdowns = require("@syncfusion/ej2-react-dropdowns");
317
317
 
318
- // test-app/component/edit-form/index.tsx
318
+ // test-app/src/component/edit-form/index.tsx
319
319
  var import_react9 = require("react");
320
320
  var import_reactstrap6 = require("reactstrap");
321
321
  var import_react_hook_form5 = require("react-hook-form");
@@ -323,7 +323,7 @@ var import_yup = require("@hookform/resolvers/yup");
323
323
  var import_react_i18next5 = require("react-i18next");
324
324
  var import_classnames6 = __toESM(require("classnames"));
325
325
 
326
- // test-app/component/input-text/index.tsx
326
+ // test-app/src/component/input-text/index.tsx
327
327
  var import_react_hook_form = require("react-hook-form");
328
328
  var import_reactstrap2 = require("reactstrap");
329
329
  var import_classnames2 = __toESM(require("classnames"));
@@ -414,7 +414,7 @@ var TextInput = (props) => {
414
414
  };
415
415
  var input_text_default = TextInput;
416
416
 
417
- // test-app/component/select/index.tsx
417
+ // test-app/src/component/select/index.tsx
418
418
  var import_react_hook_form2 = require("react-hook-form");
419
419
  var import_reactstrap3 = require("reactstrap");
420
420
  var import_react_select = __toESM(require("react-select"));
@@ -503,7 +503,7 @@ var SelectBox = (props) => {
503
503
  };
504
504
  var select_default = SelectBox;
505
505
 
506
- // test-app/component/creactable-select/index.tsx
506
+ // test-app/src/component/creactable-select/index.tsx
507
507
  var import_react_hook_form3 = require("react-hook-form");
508
508
  var import_reactstrap4 = require("reactstrap");
509
509
  var import_classnames4 = __toESM(require("classnames"));
@@ -574,7 +574,7 @@ var CreatableSelectBox = (props) => {
574
574
  };
575
575
  var creactable_select_default = CreatableSelectBox;
576
576
 
577
- // test-app/component/input-number/index.tsx
577
+ // test-app/src/component/input-number/index.tsx
578
578
  var import_react_hook_form4 = require("react-hook-form");
579
579
  var import_reactstrap5 = require("reactstrap");
580
580
  var import_classnames5 = __toESM(require("classnames"));
@@ -708,7 +708,7 @@ var NumberInput = (props) => {
708
708
  };
709
709
  var input_number_default = NumberInput;
710
710
 
711
- // test-app/component/edit-form/index.tsx
711
+ // test-app/src/component/edit-form/index.tsx
712
712
  var import_jsx_runtime8 = require("react/jsx-runtime");
713
713
  var defaultWidth = 200;
714
714
  var EditForm = (0, import_react9.forwardRef)((props, ref) => {
@@ -1043,13 +1043,13 @@ var EditForm = (0, import_react9.forwardRef)((props, ref) => {
1043
1043
  });
1044
1044
  var edit_form_default = EditForm;
1045
1045
 
1046
- // test-app/component/sidebar-setting-column/index.tsx
1046
+ // test-app/src/component/sidebar-setting-column/index.tsx
1047
1047
  var import_react11 = require("react");
1048
1048
  var import_reactstrap7 = require("reactstrap");
1049
1049
  var import_react_i18next7 = require("react-i18next");
1050
1050
  var import_ej2_react_grids = require("@syncfusion/ej2-react-grids");
1051
1051
 
1052
- // test-app/component/modal-header/index.tsx
1052
+ // test-app/src/component/modal-header/index.tsx
1053
1053
  var import_becoxy_icons2 = require("becoxy-icons");
1054
1054
  var import_classnames7 = __toESM(require("classnames"));
1055
1055
  var import_react_i18next6 = require("react-i18next");
@@ -1093,7 +1093,7 @@ var ModalHeader = (props) => {
1093
1093
  };
1094
1094
  var modal_header_default = ModalHeader;
1095
1095
 
1096
- // test-app/component/sidebar/index.tsx
1096
+ // test-app/src/component/sidebar/index.tsx
1097
1097
  var import_becoxy_icons3 = require("becoxy-icons");
1098
1098
  var import_classnames8 = __toESM(require("classnames"));
1099
1099
  var import_react10 = require("react");
@@ -1197,7 +1197,7 @@ var Sidebar = (props) => {
1197
1197
  };
1198
1198
  var sidebar_default = Sidebar;
1199
1199
 
1200
- // test-app/component/sidebar-setting-column/index.tsx
1200
+ // test-app/src/component/sidebar-setting-column/index.tsx
1201
1201
  var import_jsx_runtime11 = require("react/jsx-runtime");
1202
1202
  var SidebarSetColumn = (props) => {
1203
1203
  const { column, setColumn, openSidebar, handleSidebar } = props;
@@ -1207,7 +1207,7 @@ var SidebarSetColumn = (props) => {
1207
1207
  if (openSidebar) {
1208
1208
  setDataSource([...column]);
1209
1209
  }
1210
- }, [openSidebar]);
1210
+ }, [column, openSidebar]);
1211
1211
  const handleCancel = () => {
1212
1212
  handleSidebar();
1213
1213
  setDataSource([]);
@@ -1365,7 +1365,7 @@ var SidebarSetColumn = (props) => {
1365
1365
  };
1366
1366
  var sidebar_setting_column_default = SidebarSetColumn;
1367
1367
 
1368
- // test-app/component/table/index.tsx
1368
+ // test-app/src/component/table/index.tsx
1369
1369
  var import_ej2_react_popups = require("@syncfusion/ej2-react-popups");
1370
1370
  var import_jsx_runtime12 = require("react/jsx-runtime");
1371
1371
  var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
@@ -1417,7 +1417,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1417
1417
  const [refreshRow, setRefreshRow] = (0, import_react12.useState)(false);
1418
1418
  const [indexFocus, setIndexFocus] = (0, import_react12.useState)();
1419
1419
  const [selectedRows, setSelectedRows] = (0, import_react12.useState)([]);
1420
- const [tableColumns, setTableColumns] = (0, import_react12.useState)([...columns]);
1420
+ const [tableColumns, setTableColumns] = (0, import_react12.useState)([]);
1421
1421
  const [columnFistEdit, setColumnFistEdit] = (0, import_react12.useState)(0);
1422
1422
  const [columnLastEdit, setColumnlastEdit] = (0, import_react12.useState)(0);
1423
1423
  const [objWidthFix, setObjWidthFix] = (0, import_react12.useState)({});
@@ -1470,17 +1470,36 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1470
1470
  dataSourceChange(dataSource);
1471
1471
  }
1472
1472
  if (rowChange) {
1473
- await rowChange(row, indexRow, col.field);
1474
- for (let index = 0; index <= tableColumns.length; index++) {
1475
- if (!editDisable && indexFocus === indexRow && (!col.disabledCondition || !col.disabledCondition(row)) && tableColumns[index] && tableColumns[index].editEnable) {
1476
- const element = document.getElementById(`${idTable}-col${index + 1}-row${indexRow + 1}`);
1477
- if (element) {
1478
- if (element.className.includes("input-element")) {
1479
- element.value = row[tableColumns[index].field] ?? "";
1480
- } else if (element.className.includes("input-numeric")) {
1481
- element.value = row[tableColumns[index].field] ? formartNumberic(row[tableColumns[index].field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction) : 0;
1482
- } else if (element.className.includes("input-checkbox")) {
1483
- element.checked = row[tableColumns[index].field] ?? false;
1473
+ const rs = rowChange(row, indexRow, col.field);
1474
+ if (rs && rs?.then) {
1475
+ rs.then(() => {
1476
+ for (let index = 0; index <= tableColumns.length; index++) {
1477
+ if (!editDisable && indexFocus === indexRow && (!col.disabledCondition || !col.disabledCondition(row)) && tableColumns[index] && tableColumns[index].editEnable) {
1478
+ const element = document.getElementById(`${idTable}-col${index + 1}-row${indexRow + 1}`);
1479
+ if (element) {
1480
+ if (element.className.includes("input-element")) {
1481
+ element.value = row[tableColumns[index].field] ?? "";
1482
+ } else if (element.className.includes("input-numeric")) {
1483
+ element.value = row[tableColumns[index].field] ? formartNumberic(row[tableColumns[index].field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction) : 0;
1484
+ } else if (element.className.includes("input-checkbox")) {
1485
+ element.checked = row[tableColumns[index].field] ?? false;
1486
+ }
1487
+ }
1488
+ }
1489
+ }
1490
+ });
1491
+ } else {
1492
+ for (let index = 0; index <= tableColumns.length; index++) {
1493
+ if (!editDisable && indexFocus === indexRow && (!col.disabledCondition || !col.disabledCondition(row)) && tableColumns[index] && tableColumns[index].editEnable) {
1494
+ const element = document.getElementById(`${idTable}-col${index + 1}-row${indexRow + 1}`);
1495
+ if (element) {
1496
+ if (element.className.includes("input-element")) {
1497
+ element.value = row[tableColumns[index].field] ?? "";
1498
+ } else if (element.className.includes("input-numeric")) {
1499
+ element.value = row[tableColumns[index].field] ? formartNumberic(row[tableColumns[index].field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction) : 0;
1500
+ } else if (element.className.includes("input-checkbox")) {
1501
+ element.checked = row[tableColumns[index].field] ?? false;
1502
+ }
1484
1503
  }
1485
1504
  }
1486
1505
  }
@@ -2233,7 +2252,11 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2233
2252
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2234
2253
  "td",
2235
2254
  {
2236
- className: (0, import_classnames9.default)(`e-rowcell p-0 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "e-active": isSelected && editDisable || indexFocus === indexRow }),
2255
+ className: (0, import_classnames9.default)(
2256
+ `e-rowcell p-0 fix-${col.fixedType}`,
2257
+ { "cell-fixed": col.fixedType },
2258
+ { "e-active": isSelected && editDisable || indexFocus === indexRow }
2259
+ ),
2237
2260
  style: {
2238
2261
  width: col.width,
2239
2262
  minWidth: col.minWidth,
@@ -2307,7 +2330,11 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2307
2330
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2308
2331
  "td",
2309
2332
  {
2310
- className: (0, import_classnames9.default)(`e-rowcell p-0 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "e-active": isSelected && editDisable || indexFocus === indexRow }),
2333
+ className: (0, import_classnames9.default)(
2334
+ `e-rowcell p-0 fix-${col.fixedType}`,
2335
+ { "cell-fixed": col.fixedType },
2336
+ { "e-active": isSelected && editDisable || indexFocus === indexRow }
2337
+ ),
2311
2338
  style: {
2312
2339
  width: col.width,
2313
2340
  minWidth: col.minWidth,
@@ -2370,7 +2397,11 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2370
2397
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2371
2398
  "td",
2372
2399
  {
2373
- className: (0, import_classnames9.default)(`e-rowcell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "e-active": isSelected && editDisable || indexFocus === indexRow }),
2400
+ className: (0, import_classnames9.default)(
2401
+ `e-rowcell fix-${col.fixedType}`,
2402
+ { "cell-fixed": col.fixedType },
2403
+ { "e-active": isSelected && editDisable || indexFocus === indexRow }
2404
+ ),
2374
2405
  style: {
2375
2406
  left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2376
2407
  right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
@@ -2431,7 +2462,10 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2431
2462
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2432
2463
  "th",
2433
2464
  {
2434
- className: (0, import_classnames9.default)(`e-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2465
+ className: (0, import_classnames9.default)(
2466
+ `e-headercell fix-${col.fixedType}`,
2467
+ { "cell-fixed": col.fixedType }
2468
+ ),
2435
2469
  style: {
2436
2470
  width: col.width,
2437
2471
  padding: 0,
@@ -2477,7 +2511,10 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2477
2511
  children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2478
2512
  "th",
2479
2513
  {
2480
- className: (0, import_classnames9.default)(`e-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2514
+ className: (0, import_classnames9.default)(
2515
+ `e-headercell fix-${col.fixedType}`,
2516
+ { "cell-fixed": col.fixedType }
2517
+ ),
2481
2518
  style: {
2482
2519
  padding: 0,
2483
2520
  width: 40,
@@ -2507,7 +2544,10 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2507
2544
  children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2508
2545
  "th",
2509
2546
  {
2510
- className: (0, import_classnames9.default)(`e-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2547
+ className: (0, import_classnames9.default)(
2548
+ `e-headercell fix-${col.fixedType}`,
2549
+ { "cell-fixed": col.fixedType }
2550
+ ),
2511
2551
  style: {
2512
2552
  width: col.width,
2513
2553
  padding: 0,
@@ -2536,7 +2576,10 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2536
2576
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_react12.Fragment, { children: col.visible !== false && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2537
2577
  "td",
2538
2578
  {
2539
- className: (0, import_classnames9.default)(`e-summarycell p-0 px-50 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2579
+ className: (0, import_classnames9.default)(
2580
+ `e-summarycell p-0 px-50 fix-${col.fixedType}`,
2581
+ { "cell-fixed": col.fixedType }
2582
+ ),
2540
2583
  style: {
2541
2584
  height: 30,
2542
2585
  fontSize: 14,
@@ -2605,33 +2648,31 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2605
2648
  ] }) });
2606
2649
  };
2607
2650
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_react12.Fragment, { children: [
2608
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "table-edit-custom", children: [
2609
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "e-grid e-default e-bothlines", children: [
2651
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "react-table-edit", children: [
2652
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "e-grid e-default e-bothlines", ref: gridRef, children: [
2610
2653
  showTopToolbar ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: renderToolbarTop() }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {}),
2611
- /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { ref: gridRef, children: [
2612
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-gridcontent", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: tableElement, className: "e-content", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { style: { width: "100%" }, children: [
2613
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("thead", { className: "e-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: "e-row", role: "row", children: tableColumns.map((col, index) => {
2614
- return renderHeaderCol(col, index);
2615
- }) }) }),
2616
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: "rowgroup", style: { overflowY: "scroll" }, children: dataSource?.map((row, indexRow) => {
2617
- const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
2618
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2619
- "tr",
2620
- {
2621
- className: "e-row",
2622
- children: tableColumns.map((col, indexCol) => {
2623
- return renderContentCol(col, row, indexRow, indexCol, isSelected);
2624
- })
2625
- },
2626
- `row-${indexRow}`
2627
- );
2628
- }) }),
2629
- /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tfoot", { className: "e-gridfoot", children: haveSum == true ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: "e-row", children: tableColumns.map((col, index) => {
2630
- return renderFooterCol(col, index);
2631
- }) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {}) })
2632
- ] }) }) }),
2633
- showBottomToolbar ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: renderToolbarBottom() }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {})
2634
- ] })
2654
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "e-gridcontent", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { ref: tableElement, className: "e-content", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("table", { style: { width: "100%" }, children: [
2655
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("thead", { className: "e-gridheader", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: "e-row", role: "row", children: tableColumns.map((col, index) => {
2656
+ return renderHeaderCol(col, index);
2657
+ }) }) }),
2658
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tbody", { className: "e-gridcontent", style: { overflowY: "scroll" }, children: dataSource?.map((row, indexRow) => {
2659
+ const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
2660
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2661
+ "tr",
2662
+ {
2663
+ className: "e-row",
2664
+ children: tableColumns.map((col, indexCol) => {
2665
+ return renderContentCol(col, row, indexRow, indexCol, isSelected);
2666
+ })
2667
+ },
2668
+ `row-${indexRow}`
2669
+ );
2670
+ }) }),
2671
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tfoot", { className: "e-gridfoot", children: haveSum == true ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("tr", { className: "e-row", children: tableColumns.map((col, index) => {
2672
+ return renderFooterCol(col, index);
2673
+ }) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {}) })
2674
+ ] }) }) }),
2675
+ showBottomToolbar ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: renderToolbarBottom() }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, {})
2635
2676
  ] }),
2636
2677
  allowPaging ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2637
2678
  import_ej2_react_grids2.PagerComponent,
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- // test-app/component/table/index.tsx
1
+ // test-app/src/component/table/index.tsx
2
2
  import { Fragment as Fragment12, forwardRef as forwardRef2, useEffect as useEffect5, useImperativeHandle, useRef as useRef3, useState as useState5 } from "react";
3
3
  import { Button as Button3, DropdownMenu as DropdownMenu2, DropdownToggle as DropdownToggle2, Input as Input6, UncontrolledDropdown } from "reactstrap";
4
4
  import classnames5 from "classnames";
@@ -8,7 +8,7 @@ import { PagerComponent } from "@syncfusion/ej2-react-grids";
8
8
  import AsyncSelect from "react-select/async";
9
9
  import { AlertCircle, Info as Info2, Settings } from "becoxy-icons";
10
10
 
11
- // test-app/component/react-input/index.tsx
11
+ // test-app/src/component/react-input/index.tsx
12
12
  import { X } from "becoxy-icons";
13
13
  import classNames from "classnames";
14
14
  import { Fragment, useState } from "react";
@@ -40,7 +40,7 @@ var ReactInput = (props) => {
40
40
  };
41
41
  var react_input_default = ReactInput;
42
42
 
43
- // test-app/component/notifications.tsx
43
+ // test-app/src/component/notifications.tsx
44
44
  import { Fragment as Fragment2 } from "react";
45
45
  import Swal from "sweetalert2";
46
46
  import withReactContent from "sweetalert2-react-content";
@@ -175,7 +175,7 @@ var messageBoxConfirm2 = async (t, data, data2, message) => {
175
175
  });
176
176
  };
177
177
 
178
- // test-app/component/utils.ts
178
+ // test-app/src/component/utils.ts
179
179
  import { useEffect } from "react";
180
180
  var useOnClickOutside = (ref, handler) => {
181
181
  useEffect(
@@ -252,7 +252,7 @@ var formartNumberic = (str, decimalSeparator, thousandSeparator, fraction = 10,
252
252
  }
253
253
  };
254
254
 
255
- // test-app/component/icon/index.tsx
255
+ // test-app/src/component/icon/index.tsx
256
256
  import * as Icon from "becoxy-icons";
257
257
  import { Fragment as Fragment3 } from "react";
258
258
  import { jsx as jsx3 } from "react/jsx-runtime";
@@ -267,11 +267,11 @@ var IconCustom = (props) => {
267
267
  };
268
268
  var icon_default = IconCustom;
269
269
 
270
- // test-app/component/table/index.tsx
270
+ // test-app/src/component/table/index.tsx
271
271
  import moment from "moment";
272
272
  import { DropDownTreeComponent } from "@syncfusion/ej2-react-dropdowns";
273
273
 
274
- // test-app/component/edit-form/index.tsx
274
+ // test-app/src/component/edit-form/index.tsx
275
275
  import { forwardRef, useEffect as useEffect2, useRef, useState as useState2 } from "react";
276
276
  import {
277
277
  DropdownItem,
@@ -289,7 +289,7 @@ import { yupResolver } from "@hookform/resolvers/yup";
289
289
  import { useTranslation as useTranslation5 } from "react-i18next";
290
290
  import classNames2 from "classnames";
291
291
 
292
- // test-app/component/input-text/index.tsx
292
+ // test-app/src/component/input-text/index.tsx
293
293
  import { Controller } from "react-hook-form";
294
294
  import { Input as Input2, Label, FormFeedback } from "reactstrap";
295
295
  import classnames from "classnames";
@@ -380,7 +380,7 @@ var TextInput = (props) => {
380
380
  };
381
381
  var input_text_default = TextInput;
382
382
 
383
- // test-app/component/select/index.tsx
383
+ // test-app/src/component/select/index.tsx
384
384
  import { Controller as Controller2 } from "react-hook-form";
385
385
  import { Label as Label2, FormFeedback as FormFeedback2 } from "reactstrap";
386
386
  import Select from "react-select";
@@ -469,7 +469,7 @@ var SelectBox = (props) => {
469
469
  };
470
470
  var select_default = SelectBox;
471
471
 
472
- // test-app/component/creactable-select/index.tsx
472
+ // test-app/src/component/creactable-select/index.tsx
473
473
  import { Controller as Controller3 } from "react-hook-form";
474
474
  import { Label as Label3, FormFeedback as FormFeedback3 } from "reactstrap";
475
475
  import classnames3 from "classnames";
@@ -540,7 +540,7 @@ var CreatableSelectBox = (props) => {
540
540
  };
541
541
  var creactable_select_default = CreatableSelectBox;
542
542
 
543
- // test-app/component/input-number/index.tsx
543
+ // test-app/src/component/input-number/index.tsx
544
544
  import { Controller as Controller4 } from "react-hook-form";
545
545
  import { Input as Input3, Label as Label4, FormFeedback as FormFeedback4 } from "reactstrap";
546
546
  import classnames4 from "classnames";
@@ -674,7 +674,7 @@ var NumberInput = (props) => {
674
674
  };
675
675
  var input_number_default = NumberInput;
676
676
 
677
- // test-app/component/edit-form/index.tsx
677
+ // test-app/src/component/edit-form/index.tsx
678
678
  import { Fragment as Fragment8, jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
679
679
  var defaultWidth = 200;
680
680
  var EditForm = forwardRef((props, ref) => {
@@ -1009,7 +1009,7 @@ var EditForm = forwardRef((props, ref) => {
1009
1009
  });
1010
1010
  var edit_form_default = EditForm;
1011
1011
 
1012
- // test-app/component/sidebar-setting-column/index.tsx
1012
+ // test-app/src/component/sidebar-setting-column/index.tsx
1013
1013
  import { Fragment as Fragment10, useEffect as useEffect4, useRef as useRef2, useState as useState4 } from "react";
1014
1014
  import { Button as Button2, Input as Input5 } from "reactstrap";
1015
1015
  import { useTranslation as useTranslation7 } from "react-i18next";
@@ -1023,7 +1023,7 @@ import {
1023
1023
  CommandColumn
1024
1024
  } from "@syncfusion/ej2-react-grids";
1025
1025
 
1026
- // test-app/component/modal-header/index.tsx
1026
+ // test-app/src/component/modal-header/index.tsx
1027
1027
  import { Edit, Info, Plus, X as X2 } from "becoxy-icons";
1028
1028
  import classNames3 from "classnames";
1029
1029
  import { useTranslation as useTranslation6 } from "react-i18next";
@@ -1067,7 +1067,7 @@ var ModalHeader = (props) => {
1067
1067
  };
1068
1068
  var modal_header_default = ModalHeader;
1069
1069
 
1070
- // test-app/component/sidebar/index.tsx
1070
+ // test-app/src/component/sidebar/index.tsx
1071
1071
  import { ChevronLeft, ChevronRight } from "becoxy-icons";
1072
1072
  import classNames4 from "classnames";
1073
1073
  import { useEffect as useEffect3, useState as useState3 } from "react";
@@ -1171,7 +1171,7 @@ var Sidebar = (props) => {
1171
1171
  };
1172
1172
  var sidebar_default = Sidebar;
1173
1173
 
1174
- // test-app/component/sidebar-setting-column/index.tsx
1174
+ // test-app/src/component/sidebar-setting-column/index.tsx
1175
1175
  import { Fragment as Fragment11, jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
1176
1176
  var SidebarSetColumn = (props) => {
1177
1177
  const { column, setColumn, openSidebar, handleSidebar } = props;
@@ -1181,7 +1181,7 @@ var SidebarSetColumn = (props) => {
1181
1181
  if (openSidebar) {
1182
1182
  setDataSource([...column]);
1183
1183
  }
1184
- }, [openSidebar]);
1184
+ }, [column, openSidebar]);
1185
1185
  const handleCancel = () => {
1186
1186
  handleSidebar();
1187
1187
  setDataSource([]);
@@ -1339,7 +1339,7 @@ var SidebarSetColumn = (props) => {
1339
1339
  };
1340
1340
  var sidebar_setting_column_default = SidebarSetColumn;
1341
1341
 
1342
- // test-app/component/table/index.tsx
1342
+ // test-app/src/component/table/index.tsx
1343
1343
  import { TooltipComponent } from "@syncfusion/ej2-react-popups";
1344
1344
  import { Fragment as Fragment13, jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
1345
1345
  var TableEdit = forwardRef2((props, ref) => {
@@ -1391,7 +1391,7 @@ var TableEdit = forwardRef2((props, ref) => {
1391
1391
  const [refreshRow, setRefreshRow] = useState5(false);
1392
1392
  const [indexFocus, setIndexFocus] = useState5();
1393
1393
  const [selectedRows, setSelectedRows] = useState5([]);
1394
- const [tableColumns, setTableColumns] = useState5([...columns]);
1394
+ const [tableColumns, setTableColumns] = useState5([]);
1395
1395
  const [columnFistEdit, setColumnFistEdit] = useState5(0);
1396
1396
  const [columnLastEdit, setColumnlastEdit] = useState5(0);
1397
1397
  const [objWidthFix, setObjWidthFix] = useState5({});
@@ -1444,17 +1444,36 @@ var TableEdit = forwardRef2((props, ref) => {
1444
1444
  dataSourceChange(dataSource);
1445
1445
  }
1446
1446
  if (rowChange) {
1447
- await rowChange(row, indexRow, col.field);
1448
- for (let index = 0; index <= tableColumns.length; index++) {
1449
- if (!editDisable && indexFocus === indexRow && (!col.disabledCondition || !col.disabledCondition(row)) && tableColumns[index] && tableColumns[index].editEnable) {
1450
- const element = document.getElementById(`${idTable}-col${index + 1}-row${indexRow + 1}`);
1451
- if (element) {
1452
- if (element.className.includes("input-element")) {
1453
- element.value = row[tableColumns[index].field] ?? "";
1454
- } else if (element.className.includes("input-numeric")) {
1455
- element.value = row[tableColumns[index].field] ? formartNumberic(row[tableColumns[index].field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction) : 0;
1456
- } else if (element.className.includes("input-checkbox")) {
1457
- element.checked = row[tableColumns[index].field] ?? false;
1447
+ const rs = rowChange(row, indexRow, col.field);
1448
+ if (rs && rs?.then) {
1449
+ rs.then(() => {
1450
+ for (let index = 0; index <= tableColumns.length; index++) {
1451
+ if (!editDisable && indexFocus === indexRow && (!col.disabledCondition || !col.disabledCondition(row)) && tableColumns[index] && tableColumns[index].editEnable) {
1452
+ const element = document.getElementById(`${idTable}-col${index + 1}-row${indexRow + 1}`);
1453
+ if (element) {
1454
+ if (element.className.includes("input-element")) {
1455
+ element.value = row[tableColumns[index].field] ?? "";
1456
+ } else if (element.className.includes("input-numeric")) {
1457
+ element.value = row[tableColumns[index].field] ? formartNumberic(row[tableColumns[index].field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction) : 0;
1458
+ } else if (element.className.includes("input-checkbox")) {
1459
+ element.checked = row[tableColumns[index].field] ?? false;
1460
+ }
1461
+ }
1462
+ }
1463
+ }
1464
+ });
1465
+ } else {
1466
+ for (let index = 0; index <= tableColumns.length; index++) {
1467
+ if (!editDisable && indexFocus === indexRow && (!col.disabledCondition || !col.disabledCondition(row)) && tableColumns[index] && tableColumns[index].editEnable) {
1468
+ const element = document.getElementById(`${idTable}-col${index + 1}-row${indexRow + 1}`);
1469
+ if (element) {
1470
+ if (element.className.includes("input-element")) {
1471
+ element.value = row[tableColumns[index].field] ?? "";
1472
+ } else if (element.className.includes("input-numeric")) {
1473
+ element.value = row[tableColumns[index].field] ? formartNumberic(row[tableColumns[index].field], decimalSeparator, thousandSeparator, col.numericSettings?.fraction) : 0;
1474
+ } else if (element.className.includes("input-checkbox")) {
1475
+ element.checked = row[tableColumns[index].field] ?? false;
1476
+ }
1458
1477
  }
1459
1478
  }
1460
1479
  }
@@ -2207,7 +2226,11 @@ var TableEdit = forwardRef2((props, ref) => {
2207
2226
  return /* @__PURE__ */ jsx12(
2208
2227
  "td",
2209
2228
  {
2210
- className: classnames5(`e-rowcell p-0 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "e-active": isSelected && editDisable || indexFocus === indexRow }),
2229
+ className: classnames5(
2230
+ `e-rowcell p-0 fix-${col.fixedType}`,
2231
+ { "cell-fixed": col.fixedType },
2232
+ { "e-active": isSelected && editDisable || indexFocus === indexRow }
2233
+ ),
2211
2234
  style: {
2212
2235
  width: col.width,
2213
2236
  minWidth: col.minWidth,
@@ -2281,7 +2304,11 @@ var TableEdit = forwardRef2((props, ref) => {
2281
2304
  return /* @__PURE__ */ jsx12(
2282
2305
  "td",
2283
2306
  {
2284
- className: classnames5(`e-rowcell p-0 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "e-active": isSelected && editDisable || indexFocus === indexRow }),
2307
+ className: classnames5(
2308
+ `e-rowcell p-0 fix-${col.fixedType}`,
2309
+ { "cell-fixed": col.fixedType },
2310
+ { "e-active": isSelected && editDisable || indexFocus === indexRow }
2311
+ ),
2285
2312
  style: {
2286
2313
  width: col.width,
2287
2314
  minWidth: col.minWidth,
@@ -2344,7 +2371,11 @@ var TableEdit = forwardRef2((props, ref) => {
2344
2371
  return /* @__PURE__ */ jsx12(Fragment12, { children: col.visible !== false && /* @__PURE__ */ jsx12(
2345
2372
  "td",
2346
2373
  {
2347
- className: classnames5(`e-rowcell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }, { "e-active": isSelected && editDisable || indexFocus === indexRow }),
2374
+ className: classnames5(
2375
+ `e-rowcell fix-${col.fixedType}`,
2376
+ { "cell-fixed": col.fixedType },
2377
+ { "e-active": isSelected && editDisable || indexFocus === indexRow }
2378
+ ),
2348
2379
  style: {
2349
2380
  left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2350
2381
  right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
@@ -2405,7 +2436,10 @@ var TableEdit = forwardRef2((props, ref) => {
2405
2436
  return /* @__PURE__ */ jsx12(Fragment12, { children: col.visible !== false && /* @__PURE__ */ jsx12(
2406
2437
  "th",
2407
2438
  {
2408
- className: classnames5(`e-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2439
+ className: classnames5(
2440
+ `e-headercell fix-${col.fixedType}`,
2441
+ { "cell-fixed": col.fixedType }
2442
+ ),
2409
2443
  style: {
2410
2444
  width: col.width,
2411
2445
  padding: 0,
@@ -2451,7 +2485,10 @@ var TableEdit = forwardRef2((props, ref) => {
2451
2485
  children: col.visible !== false && /* @__PURE__ */ jsx12(
2452
2486
  "th",
2453
2487
  {
2454
- className: classnames5(`e-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2488
+ className: classnames5(
2489
+ `e-headercell fix-${col.fixedType}`,
2490
+ { "cell-fixed": col.fixedType }
2491
+ ),
2455
2492
  style: {
2456
2493
  padding: 0,
2457
2494
  width: 40,
@@ -2481,7 +2518,10 @@ var TableEdit = forwardRef2((props, ref) => {
2481
2518
  children: col.visible !== false && /* @__PURE__ */ jsx12(
2482
2519
  "th",
2483
2520
  {
2484
- className: classnames5(`e-headercell fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2521
+ className: classnames5(
2522
+ `e-headercell fix-${col.fixedType}`,
2523
+ { "cell-fixed": col.fixedType }
2524
+ ),
2485
2525
  style: {
2486
2526
  width: col.width,
2487
2527
  padding: 0,
@@ -2510,7 +2550,10 @@ var TableEdit = forwardRef2((props, ref) => {
2510
2550
  return /* @__PURE__ */ jsx12(Fragment12, { children: col.visible !== false && /* @__PURE__ */ jsx12(
2511
2551
  "td",
2512
2552
  {
2513
- className: classnames5(`e-summarycell p-0 px-50 fix-${col.fixedType}`, { "cell-fixed": col.fixedType }),
2553
+ className: classnames5(
2554
+ `e-summarycell p-0 px-50 fix-${col.fixedType}`,
2555
+ { "cell-fixed": col.fixedType }
2556
+ ),
2514
2557
  style: {
2515
2558
  height: 30,
2516
2559
  fontSize: 14,
@@ -2579,33 +2622,31 @@ var TableEdit = forwardRef2((props, ref) => {
2579
2622
  ] }) });
2580
2623
  };
2581
2624
  return /* @__PURE__ */ jsxs11(Fragment12, { children: [
2582
- /* @__PURE__ */ jsxs11("div", { className: "table-edit-custom", children: [
2583
- /* @__PURE__ */ jsxs11("div", { className: "e-grid e-default e-bothlines", children: [
2625
+ /* @__PURE__ */ jsxs11("div", { className: "react-table-edit", children: [
2626
+ /* @__PURE__ */ jsxs11("div", { className: "e-grid e-default e-bothlines", ref: gridRef, children: [
2584
2627
  showTopToolbar ? /* @__PURE__ */ jsx12(Fragment13, { children: renderToolbarTop() }) : /* @__PURE__ */ jsx12(Fragment13, {}),
2585
- /* @__PURE__ */ jsxs11("div", { ref: gridRef, children: [
2586
- /* @__PURE__ */ jsx12("div", { className: "e-gridcontent", children: /* @__PURE__ */ jsx12("div", { ref: tableElement, className: "e-content", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: /* @__PURE__ */ jsxs11("table", { style: { width: "100%" }, children: [
2587
- /* @__PURE__ */ jsx12("thead", { className: "e-gridheader", children: /* @__PURE__ */ jsx12("tr", { className: "e-row", role: "row", children: tableColumns.map((col, index) => {
2588
- return renderHeaderCol(col, index);
2589
- }) }) }),
2590
- /* @__PURE__ */ jsx12("tbody", { className: "rowgroup", style: { overflowY: "scroll" }, children: dataSource?.map((row, indexRow) => {
2591
- const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
2592
- return /* @__PURE__ */ jsx12(
2593
- "tr",
2594
- {
2595
- className: "e-row",
2596
- children: tableColumns.map((col, indexCol) => {
2597
- return renderContentCol(col, row, indexRow, indexCol, isSelected);
2598
- })
2599
- },
2600
- `row-${indexRow}`
2601
- );
2602
- }) }),
2603
- /* @__PURE__ */ jsx12("tfoot", { className: "e-gridfoot", children: haveSum == true ? /* @__PURE__ */ jsx12("tr", { className: "e-row", children: tableColumns.map((col, index) => {
2604
- return renderFooterCol(col, index);
2605
- }) }) : /* @__PURE__ */ jsx12(Fragment13, {}) })
2606
- ] }) }) }),
2607
- showBottomToolbar ? /* @__PURE__ */ jsx12(Fragment13, { children: renderToolbarBottom() }) : /* @__PURE__ */ jsx12(Fragment13, {})
2608
- ] })
2628
+ /* @__PURE__ */ jsx12("div", { className: "e-gridcontent", children: /* @__PURE__ */ jsx12("div", { ref: tableElement, className: "e-content", style: { height: `${height ? `${height}px` : "auto"}`, minHeight: `${minHeight ? `${minHeight}px` : ""}`, maxHeight: `${maxHeight ? `${maxHeight}px` : "400px"}` }, children: /* @__PURE__ */ jsxs11("table", { style: { width: "100%" }, children: [
2629
+ /* @__PURE__ */ jsx12("thead", { className: "e-gridheader", children: /* @__PURE__ */ jsx12("tr", { className: "e-row", role: "row", children: tableColumns.map((col, index) => {
2630
+ return renderHeaderCol(col, index);
2631
+ }) }) }),
2632
+ /* @__PURE__ */ jsx12("tbody", { className: "e-gridcontent", style: { overflowY: "scroll" }, children: dataSource?.map((row, indexRow) => {
2633
+ const isSelected = selectedRows?.some((x) => x[fieldKey] === row[fieldKey]);
2634
+ return /* @__PURE__ */ jsx12(
2635
+ "tr",
2636
+ {
2637
+ className: "e-row",
2638
+ children: tableColumns.map((col, indexCol) => {
2639
+ return renderContentCol(col, row, indexRow, indexCol, isSelected);
2640
+ })
2641
+ },
2642
+ `row-${indexRow}`
2643
+ );
2644
+ }) }),
2645
+ /* @__PURE__ */ jsx12("tfoot", { className: "e-gridfoot", children: haveSum == true ? /* @__PURE__ */ jsx12("tr", { className: "e-row", children: tableColumns.map((col, index) => {
2646
+ return renderFooterCol(col, index);
2647
+ }) }) : /* @__PURE__ */ jsx12(Fragment13, {}) })
2648
+ ] }) }) }),
2649
+ showBottomToolbar ? /* @__PURE__ */ jsx12(Fragment13, { children: renderToolbarBottom() }) : /* @__PURE__ */ jsx12(Fragment13, {})
2609
2650
  ] }),
2610
2651
  allowPaging ? /* @__PURE__ */ jsx12(
2611
2652
  PagerComponent,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-table-edit",
3
3
  "license": "MIT",
4
- "version": "0.0.1",
4
+ "version": "0.0.3",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",