react-better-html 1.1.173 → 1.1.175

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
@@ -3603,14 +3603,15 @@ var ModalComponent = forwardRef7(function Modal({
3603
3603
  marginTop: 1,
3604
3604
  iconColor: titleColor,
3605
3605
  onClick: onClickClose,
3606
- transition: theme2.styles.transition
3606
+ transition: theme2.styles.transition,
3607
+ zIndex: 10
3607
3608
  }
3608
3609
  )
3609
3610
  ]
3610
3611
  }
3611
3612
  ),
3612
3613
  /* @__PURE__ */ jsx12(Divider_default.horizontal, {})
3613
- ] }) : /* @__PURE__ */ jsx12(Fragment2, { children: !withoutCloseButton && /* @__PURE__ */ jsx12(Div_default, { position: "absolute", top: theme2.styles.space, right: theme2.styles.space, children: /* @__PURE__ */ jsx12(Button_default.icon, { icon: "XMark", onClick: onClickClose }) }) }),
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 }) }) }),
3614
3615
  /* @__PURE__ */ jsx12(Div_default, { padding: title ? theme2.styles.space : void 0, children })
3615
3616
  ]
3616
3617
  }
@@ -5803,6 +5804,9 @@ var DropdownComponent = forwardRef10(function Dropdown({
5803
5804
  ] }),
5804
5805
  [filteredOptions, value, focusedOptionIndex, theme2.colors, onClickOption, renderOption, renderOptionDivider]
5805
5806
  );
5807
+ useEffect6(() => {
5808
+ setInternalValue(controlledValue);
5809
+ }, [controlledValue]);
5806
5810
  useEffect6(() => {
5807
5811
  if (isOpen) {
5808
5812
  setIsOpenLate.setTrue();
@@ -5838,7 +5842,7 @@ var DropdownComponent = forwardRef10(function Dropdown({
5838
5842
  }, [withDebounce, onChangeSearch, debouncedSearchQuery]);
5839
5843
  const displayValue = withSearch && isFocused ? searchQuery : selectedOption?.label ?? "";
5840
5844
  const withClearButton = isOpen && selectedOption;
5841
- const readyPlaceholder = placeholder ? placeholder : `Select an ${label?.toLowerCase() ?? "option"}`;
5845
+ const readyPlaceholder = placeholder ?? `Select an ${label?.toLowerCase() ?? "option"}`;
5842
5846
  return /* @__PURE__ */ jsx15(Div_default.column, { width: "100%", position: "relative", userSelect: "none", ...props, children: /* @__PURE__ */ jsxs11(Div_default.row, { position: "relative", width: "100%", children: [
5843
5847
  /* @__PURE__ */ jsx15(
5844
5848
  InputField_default,
@@ -7805,6 +7809,7 @@ var filterPresetsText = {
7805
7809
  nextYear: "Next year"
7806
7810
  };
7807
7811
  var TableComponent = forwardRef15(function Table({
7812
+ name,
7808
7813
  columns,
7809
7814
  data,
7810
7815
  isStriped,
@@ -7816,6 +7821,8 @@ var TableComponent = forwardRef15(function Table({
7816
7821
  isInsideTableExpandRow,
7817
7822
  containsOverflowComponents,
7818
7823
  wrapperComponentRef,
7824
+ memoizeFilters,
7825
+ memoizeFiltersLifespan = 72e5,
7819
7826
  getRowStyle,
7820
7827
  onClickRow,
7821
7828
  onClickAllCheckboxes,
@@ -7833,7 +7840,15 @@ var TableComponent = forwardRef15(function Table({
7833
7840
  const [checkedItems, setCheckedItems] = useState9([]);
7834
7841
  const [expandedRows, setExpandedRows] = useState9([]);
7835
7842
  const [currentPage, setCurrentPage] = useState9(1);
7836
- const [filterData, setFilterData] = useState9({});
7843
+ const [filterData, setFilterData] = useState9(() => {
7844
+ if (!memoizeFilters || !name) return {};
7845
+ const localStorageData = JSON.parse(localStorage.getItem(`react-better-html-table-filters-${name}`) || "{}");
7846
+ const timestamp = localStorageData.timestamp;
7847
+ const data2 = localStorageData.data ?? {};
7848
+ const timeDiff = Date.now() - timestamp;
7849
+ if (timeDiff > memoizeFiltersLifespan) return {};
7850
+ return data2;
7851
+ });
7837
7852
  const [openedFilterColumnIndex, setOpenedFilterColumnIndex] = useState9();
7838
7853
  const [filterListSelectedItems, setFilterListSelectedItems] = useState9();
7839
7854
  const openedFilterData = openedFilterColumnIndex ? filterData[openedFilterColumnIndex] : void 0;
@@ -8088,6 +8103,10 @@ var TableComponent = forwardRef15(function Table({
8088
8103
  } else if (column.filter === "date" && filter.type === "date" || column.filter === "date-time" && filter.type === "date-time") {
8089
8104
  const minDate = filter.min ? new Date(filter.min) : void 0;
8090
8105
  const maxDate = filter.max ? new Date(filter.max) : void 0;
8106
+ if (column.filter === "date") {
8107
+ minDate?.setHours(0, 0, 0, 0);
8108
+ maxDate?.setHours(23, 59, 59, 999);
8109
+ }
8091
8110
  const itemValue = column.getValue?.(item) ?? new Date(column.type === "text" && column.keyName ? String(item[column.keyName]) : "");
8092
8111
  if (filter.min !== void 0 && minDate && itemValue < minDate) return false;
8093
8112
  if (filter.max !== void 0 && maxDate && itemValue > maxDate) return false;
@@ -8171,6 +8190,17 @@ var TableComponent = forwardRef15(function Table({
8171
8190
  useEffect10(() => {
8172
8191
  onChangeFilter?.(filterData);
8173
8192
  }, [onChangeFilter, filterData]);
8193
+ useEffect10(() => {
8194
+ if (!memoizeFilters) return;
8195
+ if (!name) return;
8196
+ localStorage.setItem(
8197
+ `react-better-html-table-filters-${name}`,
8198
+ JSON.stringify({
8199
+ timestamp: Date.now(),
8200
+ data: filterData
8201
+ })
8202
+ );
8203
+ }, [memoizeFilters, name, filterData]);
8174
8204
  useEffect10(() => {
8175
8205
  onChangeFilterDataValue?.(dataAfterFilter);
8176
8206
  }, [onChangeFilterDataValue, dataAfterFilter]);