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 CHANGED
@@ -755,6 +755,7 @@ type ListFilter<DataItem> = {
755
755
  getValueForList?: (item: DataItem) => OmitProps<ListFilterValue, "count">;
756
756
  };
757
757
  type TableColumn<DataItem> = {
758
+ hidden?: boolean;
758
759
  label?: string;
759
760
  /** @requires label */
760
761
  renderLabel?: (label: string) => React.ReactNode;
package/dist/index.d.ts CHANGED
@@ -755,6 +755,7 @@ type ListFilter<DataItem> = {
755
755
  getValueForList?: (item: DataItem) => OmitProps<ListFilterValue, "count">;
756
756
  };
757
757
  type TableColumn<DataItem> = {
758
+ hidden?: boolean;
758
759
  label?: string;
759
760
  /** @requires label */
760
761
  renderLabel?: (label: string) => React.ReactNode;
package/dist/index.js CHANGED
@@ -7921,8 +7921,9 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
7921
7921
  const mediaQuery = useMediaQuery();
7922
7922
  const { colorTheme } = useBetterHtmlContextInternal();
7923
7923
  const filterModalRef = (0, import_react25.useRef)(null);
7924
- const columnsRef = (0, import_react25.useRef)(columns);
7925
- columnsRef.current = columns;
7924
+ const readyColumns = (0, import_react25.useMemo)(() => columns.filter((column) => !column.hidden), [columns]);
7925
+ const columnsRef = (0, import_react25.useRef)(readyColumns);
7926
+ columnsRef.current = readyColumns;
7926
7927
  const [checkedItems, setCheckedItems] = (0, import_react25.useState)([]);
7927
7928
  const [expandedRows, setExpandedRows] = (0, import_react25.useState)([]);
7928
7929
  const [currentPage, setCurrentPage] = (0, import_react25.useState)(1);
@@ -7938,7 +7939,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
7938
7939
  const [openedFilterColumnIndex, setOpenedFilterColumnIndex] = (0, import_react25.useState)();
7939
7940
  const [filterListSelectedItems, setFilterListSelectedItems] = (0, import_react25.useState)();
7940
7941
  const openedFilterData = openedFilterColumnIndex ? filterData[openedFilterColumnIndex] : void 0;
7941
- const openedFilterColumn = openedFilterColumnIndex ? columns[openedFilterColumnIndex] : void 0;
7942
+ const openedFilterColumn = openedFilterColumnIndex ? readyColumns[openedFilterColumnIndex] : void 0;
7942
7943
  const filterForm = useForm({
7943
7944
  defaultValues: {
7944
7945
  min: void 0,
@@ -7966,7 +7967,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
7966
7967
  filterModalRef.current?.close();
7967
7968
  }
7968
7969
  });
7969
- const expandColumn = (0, import_react25.useMemo)(() => columns.find((column) => column.type === "expand"), [columns]);
7970
+ const expandColumn = (0, import_react25.useMemo)(() => readyColumns.find((column) => column.type === "expand"), [readyColumns]);
7970
7971
  const renderCellContent = (0, import_react25.useCallback)(
7971
7972
  (column, item, itemIndex) => {
7972
7973
  switch (column.type) {
@@ -8069,10 +8070,15 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8069
8070
  }, []);
8070
8071
  const onClickCancelFormFilter = (0, import_react25.useCallback)(() => {
8071
8072
  if (openedFilterColumnIndex === void 0) return;
8072
- setFilterData((oldValue) => ({
8073
- ...oldValue,
8074
- [openedFilterColumnIndex]: void 0
8075
- }));
8073
+ setFilterData(
8074
+ (oldValue) => Object.entries({
8075
+ ...oldValue,
8076
+ [openedFilterColumnIndex]: void 0
8077
+ }).reduce((previousValue, [key, value]) => {
8078
+ if (value !== void 0) previousValue[parseInt(key)] = value;
8079
+ return previousValue;
8080
+ }, {})
8081
+ );
8076
8082
  filterModalRef.current?.close();
8077
8083
  }, [openedFilterColumnIndex]);
8078
8084
  const onClickFilterListItem = (0, import_react25.useCallback)(
@@ -8170,11 +8176,11 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8170
8176
  );
8171
8177
  const renderExpandedRow = (0, import_react25.useCallback)(
8172
8178
  (...props2) => {
8173
- const expandColumn2 = columns.find((column) => column.type === "expand");
8179
+ const expandColumn2 = readyColumns.find((column) => column.type === "expand");
8174
8180
  if (!expandColumn2) return;
8175
8181
  return expandColumn2.render?.(...props2);
8176
8182
  },
8177
- [columns]
8183
+ [readyColumns]
8178
8184
  );
8179
8185
  const dataAfterFilter = (0, import_react25.useMemo)(
8180
8186
  () => data.filter(
@@ -8324,7 +8330,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8324
8330
  containsOverflowComponents,
8325
8331
  withFooter,
8326
8332
  children: [
8327
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tr", { className: "isHeader", children: columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8333
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tr", { className: "isHeader", children: readyColumns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8328
8334
  ThStyledComponent,
8329
8335
  {
8330
8336
  width: column.width ?? (column.type === "image" ? defaultImageWidth : column.type === "checkbox" ? 26 : column.type === "expand" ? 16 : void 0),
@@ -8362,14 +8368,14 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8362
8368
  },
8363
8369
  column.type + column.label + index
8364
8370
  )) }) }),
8365
- /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tbody", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tr", { className: "withoutHover", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Loader_default.box, {}) }) }) : dataAfterPagination.length > 0 ? dataAfterPagination.map((item, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_react25.Fragment, { children: [
8371
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tbody", { children: isLoading ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tr", { className: "withoutHover", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("td", { className: "noData", colSpan: readyColumns.length, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Loader_default.box, {}) }) }) : dataAfterPagination.length > 0 ? dataAfterPagination.map((item, rowIndex) => /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_react25.Fragment, { children: [
8366
8372
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8367
8373
  "tr",
8368
8374
  {
8369
8375
  className: isInsideTableExpandRow && onClickRow === void 0 && expandColumn === void 0 ? "withoutHover" : void 0,
8370
8376
  style: getRowStyle?.(item, rowIndex),
8371
8377
  onClick: () => onClickRowElement(item, rowIndex),
8372
- children: columns.map((column, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8378
+ children: readyColumns.map((column, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8373
8379
  TdStyledComponent,
8374
8380
  {
8375
8381
  textAlign: column.align,
@@ -8382,9 +8388,9 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8382
8388
  ))
8383
8389
  }
8384
8390
  ),
8385
- expandedRows[rowIndex] && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tr", { className: "withoutHover isExpandRow", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("td", { colSpan: columns.length, children: renderExpandedRow(item, rowIndex) }) })
8386
- ] }, JSON.stringify(item) + rowIndex)) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tr", { className: "withoutHover", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("td", { className: "noData", colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Text_default.unknown, { children: noDataItemsMessage }) }) }) }),
8387
- withFooter && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tfoot", { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tr", { className: "isFooter", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("td", { colSpan: columns.length, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
8391
+ expandedRows[rowIndex] && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tr", { className: "withoutHover isExpandRow", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("td", { colSpan: readyColumns.length, children: renderExpandedRow(item, rowIndex) }) })
8392
+ ] }, JSON.stringify(item) + rowIndex)) : /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tr", { className: "withoutHover", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("td", { className: "noData", colSpan: readyColumns.length, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Text_default.unknown, { children: noDataItemsMessage }) }) }) }),
8393
+ withFooter && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tfoot", { children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("tr", { className: "isFooter", children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("td", { colSpan: readyColumns.length, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
8388
8394
  Div_default.column,
8389
8395
  {
8390
8396
  position: "relative",