react-better-html 1.1.123 → 1.1.124

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
@@ -5892,8 +5892,48 @@ InputFieldComponent.password = forwardRef11(function Password({ ...props }, ref)
5892
5892
  }
5893
5893
  );
5894
5894
  });
5895
- InputFieldComponent.search = forwardRef11(function Search({ ...props }, ref) {
5896
- return /* @__PURE__ */ jsx15(InputFieldComponent, { leftIcon: "magnifyingGlass", placeholder: "Search...", ref, ...props });
5895
+ InputFieldComponent.search = forwardRef11(function Search({ value, onChangeValue, onFocus, onBlur, ...props }, ref) {
5896
+ const [inputFieldValue, setInputFieldValue] = useState6(value?.toString() ?? "");
5897
+ const [inputFieldFocused, setInputFieldFocused] = useBooleanState();
5898
+ const onChangeValueElement = useCallback8(
5899
+ (value2) => {
5900
+ setInputFieldValue(value2);
5901
+ onChangeValue?.(value2);
5902
+ },
5903
+ [onChangeValue]
5904
+ );
5905
+ const onFocusElement = useCallback8(
5906
+ (event) => {
5907
+ setInputFieldFocused.setTrue();
5908
+ onFocus?.(event);
5909
+ },
5910
+ [onFocus]
5911
+ );
5912
+ const onBlurElement = useCallback8(
5913
+ (event) => {
5914
+ setTimeout(() => setInputFieldFocused.setFalse(), 0.1 * 1e3);
5915
+ onBlur?.(event);
5916
+ },
5917
+ [onBlur]
5918
+ );
5919
+ const onClickRightIcon = useCallback8(() => {
5920
+ onChangeValueElement("");
5921
+ }, [onChangeValueElement]);
5922
+ return /* @__PURE__ */ jsx15(
5923
+ InputFieldComponent,
5924
+ {
5925
+ leftIcon: "magnifyingGlass",
5926
+ placeholder: "Search...",
5927
+ rightIcon: inputFieldValue.length > 0 && inputFieldFocused ? "XMark" : void 0,
5928
+ onClickRightIcon,
5929
+ value: inputFieldValue,
5930
+ onChangeValue: onChangeValueElement,
5931
+ onFocus: onFocusElement,
5932
+ onBlur: onBlurElement,
5933
+ ref,
5934
+ ...props
5935
+ }
5936
+ );
5897
5937
  });
5898
5938
  InputFieldComponent.phoneNumber = forwardRef11(function PhoneNumber({ label, value, onChangeValue, labelColor, id, ...props }, ref) {
5899
5939
  const theme2 = useTheme();
@@ -6971,7 +7011,8 @@ var TableComponent = forwardRef15(function Table({
6971
7011
  const filterForm = useForm({
6972
7012
  defaultValues: {
6973
7013
  min: void 0,
6974
- max: void 0
7014
+ max: void 0,
7015
+ search: ""
6975
7016
  },
6976
7017
  onSubmit: (values) => {
6977
7018
  if (!openedFilterColumn?.filter) return;
@@ -6986,10 +7027,10 @@ var TableComponent = forwardRef15(function Table({
6986
7027
  type: openedFilterColumn.filter,
6987
7028
  min: values.min,
6988
7029
  max: values.max
6989
- } : openedFilterColumn.filter === "list" ? {
7030
+ } : openedFilterColumn.filter === "list" ? filterListSelectedItems && filterListSelectedItems.length > 0 ? {
6990
7031
  type: openedFilterColumn.filter,
6991
7032
  list: filterListSelectedItems
6992
- } : void 0
7033
+ } : void 0 : void 0
6993
7034
  }));
6994
7035
  filterModalRef.current?.close();
6995
7036
  }
@@ -7242,7 +7283,12 @@ var TableComponent = forwardRef15(function Table({
7242
7283
  return data.reduce((previousValue, currentValue) => {
7243
7284
  const valueFromList = openedFilterColumn.filter === "list" && openedFilterColumn.getValueForList ? openedFilterColumn.getValueForList(currentValue) : void 0;
7244
7285
  const value = valueFromList ? valueFromList.value : openedFilterColumn.type === "text" && openedFilterColumn.keyName ? String(currentValue[openedFilterColumn.keyName]) : void 0;
7245
- if (value !== void 0) {
7286
+ const label = valueFromList ? valueFromList.label : value;
7287
+ let searchPassed = openedFilterColumn.filter === "list" && openedFilterColumn.withSearch ? false : true;
7288
+ if (openedFilterColumn.filter === "list" && openedFilterColumn.withSearch) {
7289
+ searchPassed = label?.toLowerCase().includes(filterForm.values.search.toLowerCase()) ?? false;
7290
+ }
7291
+ if (value !== void 0 && value !== null && value !== "" && searchPassed) {
7246
7292
  if (previousValue.some((item) => item.value === value)) {
7247
7293
  previousValue = previousValue.map(
7248
7294
  (item) => item.value === value ? {
@@ -7252,14 +7298,14 @@ var TableComponent = forwardRef15(function Table({
7252
7298
  );
7253
7299
  } else
7254
7300
  previousValue.push({
7255
- label: valueFromList ? valueFromList.label : value,
7301
+ label,
7256
7302
  value,
7257
7303
  count: 1
7258
7304
  });
7259
7305
  }
7260
7306
  return previousValue;
7261
7307
  }, []);
7262
- }, [data, openedFilterColumn]);
7308
+ }, [data, openedFilterColumn, filterForm.values.search]);
7263
7309
  const pageCountInternal = pageCount ?? (pageSize !== void 0 ? Math.ceil(dataAfterFilter.length / pageSize) : 1);
7264
7310
  const paginationItems = useMemo7(() => {
7265
7311
  const halfRange = Math.floor(maximumVisiblePages / 2);
@@ -7529,9 +7575,10 @@ var TableComponent = forwardRef15(function Table({
7529
7575
  ] })
7530
7576
  ]
7531
7577
  }
7532
- ) : openedFilterColumn.filter === "list" ? /* @__PURE__ */ jsx20(
7578
+ ) : openedFilterColumn.filter === "list" ? /* @__PURE__ */ jsxs16(
7533
7579
  Form_default,
7534
7580
  {
7581
+ gap: theme2.styles.space,
7535
7582
  submitButtonText: "Filter",
7536
7583
  cancelButtonText: "Clear",
7537
7584
  renderActionButtons: /* @__PURE__ */ jsxs16(Div_default.row, { marginRight: "auto", alignItems: "center", gap: theme2.styles.gap, children: [
@@ -7539,6 +7586,7 @@ var TableComponent = forwardRef15(function Table({
7539
7586
  Button_default.secondary,
7540
7587
  {
7541
7588
  text: "Select All",
7589
+ isSmall: true,
7542
7590
  disabled: possibleFilterListValues.length === filterListSelectedItems?.length,
7543
7591
  onClick: onClickSelectAllFilterListItems
7544
7592
  }
@@ -7547,6 +7595,7 @@ var TableComponent = forwardRef15(function Table({
7547
7595
  Button_default.secondary,
7548
7596
  {
7549
7597
  text: "Deselect All",
7598
+ isSmall: true,
7550
7599
  disabled: !filterListSelectedItems?.length,
7551
7600
  onClick: onClickDeselectAllFilterListItems
7552
7601
  }
@@ -7554,36 +7603,47 @@ var TableComponent = forwardRef15(function Table({
7554
7603
  ] }),
7555
7604
  onClickCancel: openedFilterData ? onClickCancelFormFilter : void 0,
7556
7605
  onSubmit: filterForm.onSubmit,
7557
- children: /* @__PURE__ */ jsxs16(Div_default.column, { gap: theme2.styles.gap / 2, marginBottom: theme2.styles.space, children: [
7558
- /* @__PURE__ */ jsx20(Label_default, { text: "Possible values" }),
7559
- /* @__PURE__ */ jsx20(Div_default.row, { flexWrap: "wrap", gap: theme2.styles.gap, children: possibleFilterListValues.map((value) => {
7560
- const isActive = filterListSelectedItems?.includes(value.value);
7561
- return /* @__PURE__ */ jsx20(
7562
- Div_default.box,
7563
- {
7564
- isActive,
7565
- value: value.value,
7566
- onClickWithValue: onClickFilterListItem,
7567
- children: /* @__PURE__ */ jsxs16(Div_default.row, { alignItems: "center", gap: theme2.styles.gap / 2, children: [
7568
- /* @__PURE__ */ jsx20(Text_default, { children: value.label ?? value.value }),
7569
- openedFilterColumn.withTotalNumber && /* @__PURE__ */ jsxs16(
7570
- Text_default,
7571
- {
7572
- fontSize: 14,
7573
- color: isActive ? theme2.colors.base + "c0" : theme2.colors.textSecondary,
7574
- children: [
7575
- "(",
7576
- value.count,
7577
- ")"
7578
- ]
7579
- }
7580
- )
7581
- ] })
7582
- },
7583
- value.value
7584
- );
7585
- }) })
7586
- ] })
7606
+ children: [
7607
+ openedFilterColumn?.withSearch && /* @__PURE__ */ jsx20(FormRow_default, { oneItemOnly: true, children: /* @__PURE__ */ jsx20(
7608
+ InputField_default.search,
7609
+ {
7610
+ label: "Search",
7611
+ autoComplete: "off",
7612
+ ...filterForm.getInputFieldProps("search")
7613
+ }
7614
+ ) }),
7615
+ /* @__PURE__ */ jsxs16(Div_default.column, { gap: theme2.styles.gap / 2, children: [
7616
+ /* @__PURE__ */ jsx20(Label_default, { text: "Possible values" }),
7617
+ /* @__PURE__ */ jsx20(Div_default.row, { flexWrap: "wrap", gap: theme2.styles.gap, children: possibleFilterListValues.length > 0 ? possibleFilterListValues.map((value) => {
7618
+ const isActive = filterListSelectedItems?.includes(value.value);
7619
+ return /* @__PURE__ */ jsx20(
7620
+ Div_default.box,
7621
+ {
7622
+ isActive,
7623
+ value: value.value,
7624
+ onClickWithValue: onClickFilterListItem,
7625
+ children: /* @__PURE__ */ jsxs16(Div_default.row, { alignItems: "center", gap: theme2.styles.gap / 2, children: [
7626
+ /* @__PURE__ */ jsx20(Text_default, { children: value.label ?? value.value }),
7627
+ openedFilterColumn.withTotalNumber && /* @__PURE__ */ jsxs16(
7628
+ Text_default,
7629
+ {
7630
+ fontSize: 14,
7631
+ color: isActive ? theme2.colors.base + "c0" : theme2.colors.textSecondary,
7632
+ children: [
7633
+ "(",
7634
+ value.count,
7635
+ ")"
7636
+ ]
7637
+ }
7638
+ )
7639
+ ] })
7640
+ },
7641
+ value.value
7642
+ );
7643
+ }) : /* @__PURE__ */ jsx20(Text_default.unknown, { children: "No values" }) })
7644
+ ] }),
7645
+ /* @__PURE__ */ jsx20(Div_default, {})
7646
+ ]
7587
7647
  }
7588
7648
  ) : /* @__PURE__ */ jsx20(Text_default.unknown, { children: "Unknown filter" }) : /* @__PURE__ */ jsx20(Loader_default.box, {})
7589
7649
  }