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.d.mts CHANGED
@@ -300,10 +300,11 @@ type ModalProps = {
300
300
  * */
301
301
  maxWidth?: number;
302
302
  title?: string;
303
- titleColor?: string;
303
+ titleColor?: React.CSSProperties["color"];
304
304
  description?: string;
305
- descriptionColor?: string;
306
- headerBackgroundColor?: string;
305
+ descriptionColor?: React.CSSProperties["color"];
306
+ headerBackgroundColor?: React.CSSProperties["backgroundColor"];
307
+ backgroundColor?: React.CSSProperties["backgroundColor"];
307
308
  /** @requires ReactRouterDomPlugin */
308
309
  name?: string;
309
310
  overflow?: React.CSSProperties["overflow"];
@@ -755,6 +756,7 @@ type ListFilter<DataItem> = {
755
756
  getValueForList?: (item: DataItem) => OmitProps<ListFilterValue, "count">;
756
757
  };
757
758
  type TableColumn<DataItem> = {
759
+ hidden?: boolean;
758
760
  label?: string;
759
761
  /** @requires label */
760
762
  renderLabel?: (label: string) => React.ReactNode;
package/dist/index.d.ts CHANGED
@@ -300,10 +300,11 @@ type ModalProps = {
300
300
  * */
301
301
  maxWidth?: number;
302
302
  title?: string;
303
- titleColor?: string;
303
+ titleColor?: React.CSSProperties["color"];
304
304
  description?: string;
305
- descriptionColor?: string;
306
- headerBackgroundColor?: string;
305
+ descriptionColor?: React.CSSProperties["color"];
306
+ headerBackgroundColor?: React.CSSProperties["backgroundColor"];
307
+ backgroundColor?: React.CSSProperties["backgroundColor"];
307
308
  /** @requires ReactRouterDomPlugin */
308
309
  name?: string;
309
310
  overflow?: React.CSSProperties["overflow"];
@@ -755,6 +756,7 @@ type ListFilter<DataItem> = {
755
756
  getValueForList?: (item: DataItem) => OmitProps<ListFilterValue, "count">;
756
757
  };
757
758
  type TableColumn<DataItem> = {
759
+ hidden?: boolean;
758
760
  label?: string;
759
761
  /** @requires label */
760
762
  renderLabel?: (label: string) => React.ReactNode;
package/dist/index.js CHANGED
@@ -3566,6 +3566,7 @@ var ModalComponent = (0, import_react14.forwardRef)(function Modal({
3566
3566
  description,
3567
3567
  descriptionColor,
3568
3568
  headerBackgroundColor,
3569
+ backgroundColor,
3569
3570
  name,
3570
3571
  overflow,
3571
3572
  withoutCloseButton,
@@ -3653,7 +3654,7 @@ var ModalComponent = (0, import_react14.forwardRef)(function Modal({
3653
3654
  position: "relative",
3654
3655
  width: "100%",
3655
3656
  minHeight: 32 + theme2.styles.space * 2,
3656
- backgroundColor: theme2.colors.backgroundBase,
3657
+ backgroundColor: backgroundColor ?? theme2.colors.backgroundBase,
3657
3658
  borderRadius: theme2.styles.borderRadius * 2,
3658
3659
  padding: !title ? theme2.styles.space : void 0,
3659
3660
  overflow,
@@ -3705,7 +3706,7 @@ var ModalComponent = (0, import_react14.forwardRef)(function Modal({
3705
3706
  }
3706
3707
  ),
3707
3708
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Divider_default.horizontal, {})
3708
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: !withoutCloseButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Div_default, { position: "absolute", top: theme2.styles.space, right: theme2.styles.space, zIndex: 10, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button_default.icon, { icon: "XMark", onClick: onClickClose }) }) }),
3709
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: !withoutCloseButton && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Div_default, { position: "absolute", top: theme2.styles.space, right: theme2.styles.space, zIndex: 10, children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Button_default.icon, { icon: "XMark", iconColor: titleColor, onClick: onClickClose }) }) }),
3709
3710
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Div_default, { padding: title ? theme2.styles.space : void 0, children })
3710
3711
  ]
3711
3712
  }
@@ -7921,8 +7922,9 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
7921
7922
  const mediaQuery = useMediaQuery();
7922
7923
  const { colorTheme } = useBetterHtmlContextInternal();
7923
7924
  const filterModalRef = (0, import_react25.useRef)(null);
7924
- const columnsRef = (0, import_react25.useRef)(columns);
7925
- columnsRef.current = columns;
7925
+ const readyColumns = (0, import_react25.useMemo)(() => columns.filter((column) => !column.hidden), [columns]);
7926
+ const columnsRef = (0, import_react25.useRef)(readyColumns);
7927
+ columnsRef.current = readyColumns;
7926
7928
  const [checkedItems, setCheckedItems] = (0, import_react25.useState)([]);
7927
7929
  const [expandedRows, setExpandedRows] = (0, import_react25.useState)([]);
7928
7930
  const [currentPage, setCurrentPage] = (0, import_react25.useState)(1);
@@ -7938,7 +7940,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
7938
7940
  const [openedFilterColumnIndex, setOpenedFilterColumnIndex] = (0, import_react25.useState)();
7939
7941
  const [filterListSelectedItems, setFilterListSelectedItems] = (0, import_react25.useState)();
7940
7942
  const openedFilterData = openedFilterColumnIndex ? filterData[openedFilterColumnIndex] : void 0;
7941
- const openedFilterColumn = openedFilterColumnIndex ? columns[openedFilterColumnIndex] : void 0;
7943
+ const openedFilterColumn = openedFilterColumnIndex ? readyColumns[openedFilterColumnIndex] : void 0;
7942
7944
  const filterForm = useForm({
7943
7945
  defaultValues: {
7944
7946
  min: void 0,
@@ -7966,7 +7968,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
7966
7968
  filterModalRef.current?.close();
7967
7969
  }
7968
7970
  });
7969
- const expandColumn = (0, import_react25.useMemo)(() => columns.find((column) => column.type === "expand"), [columns]);
7971
+ const expandColumn = (0, import_react25.useMemo)(() => readyColumns.find((column) => column.type === "expand"), [readyColumns]);
7970
7972
  const renderCellContent = (0, import_react25.useCallback)(
7971
7973
  (column, item, itemIndex) => {
7972
7974
  switch (column.type) {
@@ -8069,10 +8071,15 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8069
8071
  }, []);
8070
8072
  const onClickCancelFormFilter = (0, import_react25.useCallback)(() => {
8071
8073
  if (openedFilterColumnIndex === void 0) return;
8072
- setFilterData((oldValue) => ({
8073
- ...oldValue,
8074
- [openedFilterColumnIndex]: void 0
8075
- }));
8074
+ setFilterData(
8075
+ (oldValue) => Object.entries({
8076
+ ...oldValue,
8077
+ [openedFilterColumnIndex]: void 0
8078
+ }).reduce((previousValue, [key, value]) => {
8079
+ if (value !== void 0) previousValue[parseInt(key)] = value;
8080
+ return previousValue;
8081
+ }, {})
8082
+ );
8076
8083
  filterModalRef.current?.close();
8077
8084
  }, [openedFilterColumnIndex]);
8078
8085
  const onClickFilterListItem = (0, import_react25.useCallback)(
@@ -8170,11 +8177,11 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8170
8177
  );
8171
8178
  const renderExpandedRow = (0, import_react25.useCallback)(
8172
8179
  (...props2) => {
8173
- const expandColumn2 = columns.find((column) => column.type === "expand");
8180
+ const expandColumn2 = readyColumns.find((column) => column.type === "expand");
8174
8181
  if (!expandColumn2) return;
8175
8182
  return expandColumn2.render?.(...props2);
8176
8183
  },
8177
- [columns]
8184
+ [readyColumns]
8178
8185
  );
8179
8186
  const dataAfterFilter = (0, import_react25.useMemo)(
8180
8187
  () => data.filter(
@@ -8324,7 +8331,7 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8324
8331
  containsOverflowComponents,
8325
8332
  withFooter,
8326
8333
  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)(
8334
+ /* @__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
8335
  ThStyledComponent,
8329
8336
  {
8330
8337
  width: column.width ?? (column.type === "image" ? defaultImageWidth : column.type === "checkbox" ? 26 : column.type === "expand" ? 16 : void 0),
@@ -8362,14 +8369,14 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8362
8369
  },
8363
8370
  column.type + column.label + index
8364
8371
  )) }) }),
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: [
8372
+ /* @__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
8373
  /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8367
8374
  "tr",
8368
8375
  {
8369
8376
  className: isInsideTableExpandRow && onClickRow === void 0 && expandColumn === void 0 ? "withoutHover" : void 0,
8370
8377
  style: getRowStyle?.(item, rowIndex),
8371
8378
  onClick: () => onClickRowElement(item, rowIndex),
8372
- children: columns.map((column, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8379
+ children: readyColumns.map((column, colIndex) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
8373
8380
  TdStyledComponent,
8374
8381
  {
8375
8382
  textAlign: column.align,
@@ -8382,9 +8389,9 @@ var TableComponent = (0, import_react25.forwardRef)(function Table({
8382
8389
  ))
8383
8390
  }
8384
8391
  ),
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)(
8392
+ 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) }) })
8393
+ ] }, 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 }) }) }) }),
8394
+ 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
8395
  Div_default.column,
8389
8396
  {
8390
8397
  position: "relative",