react-table-edit 0.3.4 → 0.3.6

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.
package/dist/index.js CHANGED
@@ -1549,7 +1549,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1549
1549
  let letfWidthFix = 0;
1550
1550
  let rightWidthFix = 0;
1551
1551
  contentColumns.forEach((item, index) => {
1552
- if (headerColumns.length === 1 && headerColumns[0].length === contentColumns.length) {
1552
+ if (levelCol === 1) {
1553
1553
  headerColumns[0][index].visible = item.visible;
1554
1554
  headerColumns[0][index].fixedType = item.fixedType;
1555
1555
  }
@@ -1569,7 +1569,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1569
1569
  indexlast = index;
1570
1570
  }
1571
1571
  });
1572
- if (headerColumns.length === 1 && headerColumns[0].length === contentColumns.length) {
1572
+ if (levelCol === 1) {
1573
1573
  setHeaderColumns([...headerColumns]);
1574
1574
  }
1575
1575
  setObjWidthFix(objWidthFix);
@@ -1594,14 +1594,17 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
1594
1594
  setContentColumns(arrContentColumns);
1595
1595
  }, [columns]);
1596
1596
  const getNestedChildren = (array, arrHeaderColumns, arrContentColumns, level, maxLevelRow) => {
1597
- array.forEach((item, index) => {
1598
- const ele = { ...item, visible: item.invisibleDisable ? item.visible : contentColumns[index]?.visible ?? item.visible, rowspan: 1, index: 0 };
1597
+ array.forEach((item) => {
1598
+ const ele = { ...item, visible: item.visible, rowspan: 1, index: 0 };
1599
1599
  if (item.columns && item.columns?.length > 0) {
1600
1600
  const countLevel = getNestedChildren(item.columns, arrHeaderColumns, arrContentColumns, level + 1, maxLevelRow);
1601
1601
  arrHeaderColumns[maxLevelRow - 1 - countLevel].push(ele);
1602
1602
  } else {
1603
1603
  ele.rowspan = maxLevelRow - level;
1604
1604
  ele.index = arrContentColumns.length;
1605
+ if (maxLevelRow === 1) {
1606
+ ele.visible = item.invisibleDisable ? item.visible : contentColumns[arrContentColumns.length]?.visible ?? item.visible;
1607
+ }
1605
1608
  arrHeaderColumns[level].push(ele);
1606
1609
  arrContentColumns.push(ele);
1607
1610
  }
@@ -2653,7 +2656,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2653
2656
  left: col.fixedType === "left" ? objWidthFix[col.index ?? 0] : void 0,
2654
2657
  right: col.fixedType === "right" ? objWidthFix[col.index ?? 0] : void 0,
2655
2658
  width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2656
- minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2659
+ minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
2657
2660
  maxWidth: col.maxWidth
2658
2661
  },
2659
2662
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
@@ -2742,7 +2745,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2742
2745
  ),
2743
2746
  style: {
2744
2747
  width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2745
- minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2748
+ minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
2746
2749
  top: `${indexParent * 42}px`,
2747
2750
  left: col.fixedType === "left" ? objWidthFix[col.index ?? 0] : void 0,
2748
2751
  right: col.fixedType === "right" ? objWidthFix[col.index ?? 0] : void 0,
@@ -2780,7 +2783,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2780
2783
  left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2781
2784
  right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
2782
2785
  width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2783
- minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2786
+ minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
2784
2787
  maxWidth: col.maxWidth,
2785
2788
  textAlign: col.textAlign ? col.textAlign : "left"
2786
2789
  },
@@ -2814,7 +2817,7 @@ var TableEdit = (0, import_react12.forwardRef)((props, ref) => {
2814
2817
  /* @__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") }) }),
2815
2818
  /* @__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") }) })
2816
2819
  ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: " " }),
2817
- /* @__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") }) }),
2820
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: (0, import_classnames10.default)("r-toolbar-item", { "d-none": editDisable || 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") }) }),
2818
2821
  toolbarBottomOptions?.map((item, index) => {
2819
2822
  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}`) : "";
2820
2823
  })
package/dist/index.mjs CHANGED
@@ -1508,7 +1508,7 @@ var TableEdit = forwardRef2((props, ref) => {
1508
1508
  let letfWidthFix = 0;
1509
1509
  let rightWidthFix = 0;
1510
1510
  contentColumns.forEach((item, index) => {
1511
- if (headerColumns.length === 1 && headerColumns[0].length === contentColumns.length) {
1511
+ if (levelCol === 1) {
1512
1512
  headerColumns[0][index].visible = item.visible;
1513
1513
  headerColumns[0][index].fixedType = item.fixedType;
1514
1514
  }
@@ -1528,7 +1528,7 @@ var TableEdit = forwardRef2((props, ref) => {
1528
1528
  indexlast = index;
1529
1529
  }
1530
1530
  });
1531
- if (headerColumns.length === 1 && headerColumns[0].length === contentColumns.length) {
1531
+ if (levelCol === 1) {
1532
1532
  setHeaderColumns([...headerColumns]);
1533
1533
  }
1534
1534
  setObjWidthFix(objWidthFix);
@@ -1553,14 +1553,17 @@ var TableEdit = forwardRef2((props, ref) => {
1553
1553
  setContentColumns(arrContentColumns);
1554
1554
  }, [columns]);
1555
1555
  const getNestedChildren = (array, arrHeaderColumns, arrContentColumns, level, maxLevelRow) => {
1556
- array.forEach((item, index) => {
1557
- const ele = { ...item, visible: item.invisibleDisable ? item.visible : contentColumns[index]?.visible ?? item.visible, rowspan: 1, index: 0 };
1556
+ array.forEach((item) => {
1557
+ const ele = { ...item, visible: item.visible, rowspan: 1, index: 0 };
1558
1558
  if (item.columns && item.columns?.length > 0) {
1559
1559
  const countLevel = getNestedChildren(item.columns, arrHeaderColumns, arrContentColumns, level + 1, maxLevelRow);
1560
1560
  arrHeaderColumns[maxLevelRow - 1 - countLevel].push(ele);
1561
1561
  } else {
1562
1562
  ele.rowspan = maxLevelRow - level;
1563
1563
  ele.index = arrContentColumns.length;
1564
+ if (maxLevelRow === 1) {
1565
+ ele.visible = item.invisibleDisable ? item.visible : contentColumns[arrContentColumns.length]?.visible ?? item.visible;
1566
+ }
1564
1567
  arrHeaderColumns[level].push(ele);
1565
1568
  arrContentColumns.push(ele);
1566
1569
  }
@@ -2612,7 +2615,7 @@ var TableEdit = forwardRef2((props, ref) => {
2612
2615
  left: col.fixedType === "left" ? objWidthFix[col.index ?? 0] : void 0,
2613
2616
  right: col.fixedType === "right" ? objWidthFix[col.index ?? 0] : void 0,
2614
2617
  width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2615
- minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2618
+ minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
2616
2619
  maxWidth: col.maxWidth
2617
2620
  },
2618
2621
  children: /* @__PURE__ */ jsx12(
@@ -2701,7 +2704,7 @@ var TableEdit = forwardRef2((props, ref) => {
2701
2704
  ),
2702
2705
  style: {
2703
2706
  width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2704
- minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2707
+ minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
2705
2708
  top: `${indexParent * 42}px`,
2706
2709
  left: col.fixedType === "left" ? objWidthFix[col.index ?? 0] : void 0,
2707
2710
  right: col.fixedType === "right" ? objWidthFix[col.index ?? 0] : void 0,
@@ -2739,7 +2742,7 @@ var TableEdit = forwardRef2((props, ref) => {
2739
2742
  left: col.fixedType === "left" ? objWidthFix[indexCol] : void 0,
2740
2743
  right: col.fixedType === "right" ? objWidthFix[indexCol] : void 0,
2741
2744
  width: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2742
- minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.width,
2745
+ minWidth: col.fixedType ? Number(col.maxWidth ? col.maxWidth : col.width ? col.width : col.minWidth ?? "auto") : col.minWidth,
2743
2746
  maxWidth: col.maxWidth,
2744
2747
  textAlign: col.textAlign ? col.textAlign : "left"
2745
2748
  },
@@ -2773,7 +2776,7 @@ var TableEdit = forwardRef2((props, ref) => {
2773
2776
  /* @__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") }) }),
2774
2777
  /* @__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") }) })
2775
2778
  ] }) : /* @__PURE__ */ jsx12(Fragment13, { children: " " }),
2776
- /* @__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") }) }),
2779
+ /* @__PURE__ */ jsx12("div", { className: classnames6("r-toolbar-item", { "d-none": editDisable || deleteAllDisable }), "aria-disabled": "false", children: /* @__PURE__ */ jsx12(Button3, { color: "primary", outline: true, onClick: handleDeleteAll, className: "d-flex", children: t("Delete all item") }) }),
2777
2780
  toolbarBottomOptions?.map((item, index) => {
2778
2781
  return item.align === "left" ? /* @__PURE__ */ jsx12("div", { className: "r-toolbar-item", "aria-disabled": "false", children: item.template() }, `toolbar-bottom-left-${index}`) : "";
2779
2782
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-table-edit",
3
3
  "license": "MIT",
4
- "version": "0.3.4",
4
+ "version": "0.3.6",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
7
7
  "types": "dist/index.d.ts",