react-better-html 1.1.177 → 1.1.178
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +22 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +22 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7837,8 +7837,9 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7837
7837
|
const mediaQuery = useMediaQuery();
|
|
7838
7838
|
const { colorTheme } = useBetterHtmlContextInternal();
|
|
7839
7839
|
const filterModalRef = useRef6(null);
|
|
7840
|
-
const
|
|
7841
|
-
columnsRef
|
|
7840
|
+
const readyColumns = useMemo8(() => columns.filter((column) => !column.hidden), [columns]);
|
|
7841
|
+
const columnsRef = useRef6(readyColumns);
|
|
7842
|
+
columnsRef.current = readyColumns;
|
|
7842
7843
|
const [checkedItems, setCheckedItems] = useState9([]);
|
|
7843
7844
|
const [expandedRows, setExpandedRows] = useState9([]);
|
|
7844
7845
|
const [currentPage, setCurrentPage] = useState9(1);
|
|
@@ -7854,7 +7855,7 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7854
7855
|
const [openedFilterColumnIndex, setOpenedFilterColumnIndex] = useState9();
|
|
7855
7856
|
const [filterListSelectedItems, setFilterListSelectedItems] = useState9();
|
|
7856
7857
|
const openedFilterData = openedFilterColumnIndex ? filterData[openedFilterColumnIndex] : void 0;
|
|
7857
|
-
const openedFilterColumn = openedFilterColumnIndex ?
|
|
7858
|
+
const openedFilterColumn = openedFilterColumnIndex ? readyColumns[openedFilterColumnIndex] : void 0;
|
|
7858
7859
|
const filterForm = useForm({
|
|
7859
7860
|
defaultValues: {
|
|
7860
7861
|
min: void 0,
|
|
@@ -7882,7 +7883,7 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7882
7883
|
filterModalRef.current?.close();
|
|
7883
7884
|
}
|
|
7884
7885
|
});
|
|
7885
|
-
const expandColumn = useMemo8(() =>
|
|
7886
|
+
const expandColumn = useMemo8(() => readyColumns.find((column) => column.type === "expand"), [readyColumns]);
|
|
7886
7887
|
const renderCellContent = useCallback11(
|
|
7887
7888
|
(column, item, itemIndex) => {
|
|
7888
7889
|
switch (column.type) {
|
|
@@ -7985,10 +7986,15 @@ var TableComponent = forwardRef15(function Table({
|
|
|
7985
7986
|
}, []);
|
|
7986
7987
|
const onClickCancelFormFilter = useCallback11(() => {
|
|
7987
7988
|
if (openedFilterColumnIndex === void 0) return;
|
|
7988
|
-
setFilterData(
|
|
7989
|
-
|
|
7990
|
-
|
|
7991
|
-
|
|
7989
|
+
setFilterData(
|
|
7990
|
+
(oldValue) => Object.entries({
|
|
7991
|
+
...oldValue,
|
|
7992
|
+
[openedFilterColumnIndex]: void 0
|
|
7993
|
+
}).reduce((previousValue, [key, value]) => {
|
|
7994
|
+
if (value !== void 0) previousValue[parseInt(key)] = value;
|
|
7995
|
+
return previousValue;
|
|
7996
|
+
}, {})
|
|
7997
|
+
);
|
|
7992
7998
|
filterModalRef.current?.close();
|
|
7993
7999
|
}, [openedFilterColumnIndex]);
|
|
7994
8000
|
const onClickFilterListItem = useCallback11(
|
|
@@ -8086,11 +8092,11 @@ var TableComponent = forwardRef15(function Table({
|
|
|
8086
8092
|
);
|
|
8087
8093
|
const renderExpandedRow = useCallback11(
|
|
8088
8094
|
(...props2) => {
|
|
8089
|
-
const expandColumn2 =
|
|
8095
|
+
const expandColumn2 = readyColumns.find((column) => column.type === "expand");
|
|
8090
8096
|
if (!expandColumn2) return;
|
|
8091
8097
|
return expandColumn2.render?.(...props2);
|
|
8092
8098
|
},
|
|
8093
|
-
[
|
|
8099
|
+
[readyColumns]
|
|
8094
8100
|
);
|
|
8095
8101
|
const dataAfterFilter = useMemo8(
|
|
8096
8102
|
() => data.filter(
|
|
@@ -8240,7 +8246,7 @@ var TableComponent = forwardRef15(function Table({
|
|
|
8240
8246
|
containsOverflowComponents,
|
|
8241
8247
|
withFooter,
|
|
8242
8248
|
children: [
|
|
8243
|
-
/* @__PURE__ */ jsx22("thead", { children: /* @__PURE__ */ jsx22("tr", { className: "isHeader", children:
|
|
8249
|
+
/* @__PURE__ */ jsx22("thead", { children: /* @__PURE__ */ jsx22("tr", { className: "isHeader", children: readyColumns.map((column, index) => /* @__PURE__ */ jsx22(
|
|
8244
8250
|
ThStyledComponent,
|
|
8245
8251
|
{
|
|
8246
8252
|
width: column.width ?? (column.type === "image" ? defaultImageWidth : column.type === "checkbox" ? 26 : column.type === "expand" ? 16 : void 0),
|
|
@@ -8278,14 +8284,14 @@ var TableComponent = forwardRef15(function Table({
|
|
|
8278
8284
|
},
|
|
8279
8285
|
column.type + column.label + index
|
|
8280
8286
|
)) }) }),
|
|
8281
|
-
/* @__PURE__ */ jsx22("tbody", { children: isLoading ? /* @__PURE__ */ jsx22("tr", { className: "withoutHover", children: /* @__PURE__ */ jsx22("td", { className: "noData", colSpan:
|
|
8287
|
+
/* @__PURE__ */ jsx22("tbody", { children: isLoading ? /* @__PURE__ */ jsx22("tr", { className: "withoutHover", children: /* @__PURE__ */ jsx22("td", { className: "noData", colSpan: readyColumns.length, children: /* @__PURE__ */ jsx22(Loader_default.box, {}) }) }) : dataAfterPagination.length > 0 ? dataAfterPagination.map((item, rowIndex) => /* @__PURE__ */ jsxs18(Fragment6, { children: [
|
|
8282
8288
|
/* @__PURE__ */ jsx22(
|
|
8283
8289
|
"tr",
|
|
8284
8290
|
{
|
|
8285
8291
|
className: isInsideTableExpandRow && onClickRow === void 0 && expandColumn === void 0 ? "withoutHover" : void 0,
|
|
8286
8292
|
style: getRowStyle?.(item, rowIndex),
|
|
8287
8293
|
onClick: () => onClickRowElement(item, rowIndex),
|
|
8288
|
-
children:
|
|
8294
|
+
children: readyColumns.map((column, colIndex) => /* @__PURE__ */ jsx22(
|
|
8289
8295
|
TdStyledComponent,
|
|
8290
8296
|
{
|
|
8291
8297
|
textAlign: column.align,
|
|
@@ -8298,9 +8304,9 @@ var TableComponent = forwardRef15(function Table({
|
|
|
8298
8304
|
))
|
|
8299
8305
|
}
|
|
8300
8306
|
),
|
|
8301
|
-
expandedRows[rowIndex] && /* @__PURE__ */ jsx22("tr", { className: "withoutHover isExpandRow", children: /* @__PURE__ */ jsx22("td", { colSpan:
|
|
8302
|
-
] }, JSON.stringify(item) + rowIndex)) : /* @__PURE__ */ jsx22("tr", { className: "withoutHover", children: /* @__PURE__ */ jsx22("td", { className: "noData", colSpan:
|
|
8303
|
-
withFooter && /* @__PURE__ */ jsx22("tfoot", { children: /* @__PURE__ */ jsx22("tr", { className: "isFooter", children: /* @__PURE__ */ jsx22("td", { colSpan:
|
|
8307
|
+
expandedRows[rowIndex] && /* @__PURE__ */ jsx22("tr", { className: "withoutHover isExpandRow", children: /* @__PURE__ */ jsx22("td", { colSpan: readyColumns.length, children: renderExpandedRow(item, rowIndex) }) })
|
|
8308
|
+
] }, JSON.stringify(item) + rowIndex)) : /* @__PURE__ */ jsx22("tr", { className: "withoutHover", children: /* @__PURE__ */ jsx22("td", { className: "noData", colSpan: readyColumns.length, children: /* @__PURE__ */ jsx22(Text_default.unknown, { children: noDataItemsMessage }) }) }) }),
|
|
8309
|
+
withFooter && /* @__PURE__ */ jsx22("tfoot", { children: /* @__PURE__ */ jsx22("tr", { className: "isFooter", children: /* @__PURE__ */ jsx22("td", { colSpan: readyColumns.length, children: /* @__PURE__ */ jsxs18(
|
|
8304
8310
|
Div_default.column,
|
|
8305
8311
|
{
|
|
8306
8312
|
position: "relative",
|