react-better-html 1.1.177 → 1.1.179

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.mjs CHANGED
@@ -3472,6 +3472,7 @@ var ModalComponent = forwardRef7(function Modal({
3472
3472
  description,
3473
3473
  descriptionColor,
3474
3474
  headerBackgroundColor,
3475
+ backgroundColor,
3475
3476
  name,
3476
3477
  overflow,
3477
3478
  withoutCloseButton,
@@ -3559,7 +3560,7 @@ var ModalComponent = forwardRef7(function Modal({
3559
3560
  position: "relative",
3560
3561
  width: "100%",
3561
3562
  minHeight: 32 + theme2.styles.space * 2,
3562
- backgroundColor: theme2.colors.backgroundBase,
3563
+ backgroundColor: backgroundColor ?? theme2.colors.backgroundBase,
3563
3564
  borderRadius: theme2.styles.borderRadius * 2,
3564
3565
  padding: !title ? theme2.styles.space : void 0,
3565
3566
  overflow,
@@ -3611,7 +3612,7 @@ var ModalComponent = forwardRef7(function Modal({
3611
3612
  }
3612
3613
  ),
3613
3614
  /* @__PURE__ */ jsx12(Divider_default.horizontal, {})
3614
- ] }) : /* @__PURE__ */ jsx12(Fragment2, { children: !withoutCloseButton && /* @__PURE__ */ jsx12(Div_default, { position: "absolute", top: theme2.styles.space, right: theme2.styles.space, zIndex: 10, children: /* @__PURE__ */ jsx12(Button_default.icon, { icon: "XMark", onClick: onClickClose }) }) }),
3615
+ ] }) : /* @__PURE__ */ jsx12(Fragment2, { children: !withoutCloseButton && /* @__PURE__ */ jsx12(Div_default, { position: "absolute", top: theme2.styles.space, right: theme2.styles.space, zIndex: 10, children: /* @__PURE__ */ jsx12(Button_default.icon, { icon: "XMark", iconColor: titleColor, onClick: onClickClose }) }) }),
3615
3616
  /* @__PURE__ */ jsx12(Div_default, { padding: title ? theme2.styles.space : void 0, children })
3616
3617
  ]
3617
3618
  }
@@ -7837,8 +7838,9 @@ var TableComponent = forwardRef15(function Table({
7837
7838
  const mediaQuery = useMediaQuery();
7838
7839
  const { colorTheme } = useBetterHtmlContextInternal();
7839
7840
  const filterModalRef = useRef6(null);
7840
- const columnsRef = useRef6(columns);
7841
- columnsRef.current = columns;
7841
+ const readyColumns = useMemo8(() => columns.filter((column) => !column.hidden), [columns]);
7842
+ const columnsRef = useRef6(readyColumns);
7843
+ columnsRef.current = readyColumns;
7842
7844
  const [checkedItems, setCheckedItems] = useState9([]);
7843
7845
  const [expandedRows, setExpandedRows] = useState9([]);
7844
7846
  const [currentPage, setCurrentPage] = useState9(1);
@@ -7854,7 +7856,7 @@ var TableComponent = forwardRef15(function Table({
7854
7856
  const [openedFilterColumnIndex, setOpenedFilterColumnIndex] = useState9();
7855
7857
  const [filterListSelectedItems, setFilterListSelectedItems] = useState9();
7856
7858
  const openedFilterData = openedFilterColumnIndex ? filterData[openedFilterColumnIndex] : void 0;
7857
- const openedFilterColumn = openedFilterColumnIndex ? columns[openedFilterColumnIndex] : void 0;
7859
+ const openedFilterColumn = openedFilterColumnIndex ? readyColumns[openedFilterColumnIndex] : void 0;
7858
7860
  const filterForm = useForm({
7859
7861
  defaultValues: {
7860
7862
  min: void 0,
@@ -7882,7 +7884,7 @@ var TableComponent = forwardRef15(function Table({
7882
7884
  filterModalRef.current?.close();
7883
7885
  }
7884
7886
  });
7885
- const expandColumn = useMemo8(() => columns.find((column) => column.type === "expand"), [columns]);
7887
+ const expandColumn = useMemo8(() => readyColumns.find((column) => column.type === "expand"), [readyColumns]);
7886
7888
  const renderCellContent = useCallback11(
7887
7889
  (column, item, itemIndex) => {
7888
7890
  switch (column.type) {
@@ -7985,10 +7987,15 @@ var TableComponent = forwardRef15(function Table({
7985
7987
  }, []);
7986
7988
  const onClickCancelFormFilter = useCallback11(() => {
7987
7989
  if (openedFilterColumnIndex === void 0) return;
7988
- setFilterData((oldValue) => ({
7989
- ...oldValue,
7990
- [openedFilterColumnIndex]: void 0
7991
- }));
7990
+ setFilterData(
7991
+ (oldValue) => Object.entries({
7992
+ ...oldValue,
7993
+ [openedFilterColumnIndex]: void 0
7994
+ }).reduce((previousValue, [key, value]) => {
7995
+ if (value !== void 0) previousValue[parseInt(key)] = value;
7996
+ return previousValue;
7997
+ }, {})
7998
+ );
7992
7999
  filterModalRef.current?.close();
7993
8000
  }, [openedFilterColumnIndex]);
7994
8001
  const onClickFilterListItem = useCallback11(
@@ -8086,11 +8093,11 @@ var TableComponent = forwardRef15(function Table({
8086
8093
  );
8087
8094
  const renderExpandedRow = useCallback11(
8088
8095
  (...props2) => {
8089
- const expandColumn2 = columns.find((column) => column.type === "expand");
8096
+ const expandColumn2 = readyColumns.find((column) => column.type === "expand");
8090
8097
  if (!expandColumn2) return;
8091
8098
  return expandColumn2.render?.(...props2);
8092
8099
  },
8093
- [columns]
8100
+ [readyColumns]
8094
8101
  );
8095
8102
  const dataAfterFilter = useMemo8(
8096
8103
  () => data.filter(
@@ -8240,7 +8247,7 @@ var TableComponent = forwardRef15(function Table({
8240
8247
  containsOverflowComponents,
8241
8248
  withFooter,
8242
8249
  children: [
8243
- /* @__PURE__ */ jsx22("thead", { children: /* @__PURE__ */ jsx22("tr", { className: "isHeader", children: columns.map((column, index) => /* @__PURE__ */ jsx22(
8250
+ /* @__PURE__ */ jsx22("thead", { children: /* @__PURE__ */ jsx22("tr", { className: "isHeader", children: readyColumns.map((column, index) => /* @__PURE__ */ jsx22(
8244
8251
  ThStyledComponent,
8245
8252
  {
8246
8253
  width: column.width ?? (column.type === "image" ? defaultImageWidth : column.type === "checkbox" ? 26 : column.type === "expand" ? 16 : void 0),
@@ -8278,14 +8285,14 @@ var TableComponent = forwardRef15(function Table({
8278
8285
  },
8279
8286
  column.type + column.label + index
8280
8287
  )) }) }),
8281
- /* @__PURE__ */ jsx22("tbody", { children: isLoading ? /* @__PURE__ */ jsx22("tr", { className: "withoutHover", children: /* @__PURE__ */ jsx22("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ jsx22(Loader_default.box, {}) }) }) : dataAfterPagination.length > 0 ? dataAfterPagination.map((item, rowIndex) => /* @__PURE__ */ jsxs18(Fragment6, { children: [
8288
+ /* @__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
8289
  /* @__PURE__ */ jsx22(
8283
8290
  "tr",
8284
8291
  {
8285
8292
  className: isInsideTableExpandRow && onClickRow === void 0 && expandColumn === void 0 ? "withoutHover" : void 0,
8286
8293
  style: getRowStyle?.(item, rowIndex),
8287
8294
  onClick: () => onClickRowElement(item, rowIndex),
8288
- children: columns.map((column, colIndex) => /* @__PURE__ */ jsx22(
8295
+ children: readyColumns.map((column, colIndex) => /* @__PURE__ */ jsx22(
8289
8296
  TdStyledComponent,
8290
8297
  {
8291
8298
  textAlign: column.align,
@@ -8298,9 +8305,9 @@ var TableComponent = forwardRef15(function Table({
8298
8305
  ))
8299
8306
  }
8300
8307
  ),
8301
- expandedRows[rowIndex] && /* @__PURE__ */ jsx22("tr", { className: "withoutHover isExpandRow", children: /* @__PURE__ */ jsx22("td", { colSpan: columns.length, children: renderExpandedRow(item, rowIndex) }) })
8302
- ] }, JSON.stringify(item) + rowIndex)) : /* @__PURE__ */ jsx22("tr", { className: "withoutHover", children: /* @__PURE__ */ jsx22("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ jsx22(Text_default.unknown, { children: noDataItemsMessage }) }) }) }),
8303
- withFooter && /* @__PURE__ */ jsx22("tfoot", { children: /* @__PURE__ */ jsx22("tr", { className: "isFooter", children: /* @__PURE__ */ jsx22("td", { colSpan: columns.length, children: /* @__PURE__ */ jsxs18(
8308
+ expandedRows[rowIndex] && /* @__PURE__ */ jsx22("tr", { className: "withoutHover isExpandRow", children: /* @__PURE__ */ jsx22("td", { colSpan: readyColumns.length, children: renderExpandedRow(item, rowIndex) }) })
8309
+ ] }, 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 }) }) }) }),
8310
+ withFooter && /* @__PURE__ */ jsx22("tfoot", { children: /* @__PURE__ */ jsx22("tr", { className: "isFooter", children: /* @__PURE__ */ jsx22("td", { colSpan: readyColumns.length, children: /* @__PURE__ */ jsxs18(
8304
8311
  Div_default.column,
8305
8312
  {
8306
8313
  position: "relative",