react-better-html 1.1.214 → 1.1.215

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
@@ -4038,6 +4038,7 @@ var filterHover = () => {
4038
4038
 
4039
4039
  // src/components/Chip.tsx
4040
4040
  import { jsx as jsx14 } from "react/jsx-runtime";
4041
+ var borderRadiusOffset = 1.3;
4041
4042
  var ChipComponent = forwardRef9(function Chip({
4042
4043
  text,
4043
4044
  color,
@@ -4062,7 +4063,7 @@ var ChipComponent = forwardRef9(function Chip({
4062
4063
  {
4063
4064
  width: "fit-content",
4064
4065
  backgroundColor: backgroundColor ?? theme2.colors.backgroundSecondary,
4065
- borderRadius: isCircle ? 999 : borderRadius ?? theme2.styles.borderRadius / 1.3,
4066
+ borderRadius: isCircle ? 999 : borderRadius ?? theme2.styles.borderRadius / borderRadiusOffset,
4066
4067
  paddingBlock: theme2.styles.gap / 2,
4067
4068
  paddingInline: theme2.styles.space / 1.5,
4068
4069
  filterHover: onClick || onClickWithValue ? filterHover().z1 : void 0,
@@ -4074,11 +4075,11 @@ var ChipComponent = forwardRef9(function Chip({
4074
4075
  }
4075
4076
  );
4076
4077
  });
4077
- ChipComponent.colored = forwardRef9(function Colored({ color, ...props }, ref) {
4078
+ ChipComponent.colored = forwardRef9(function Colored({ color, withWhiteBackground, ...props }, ref) {
4078
4079
  const theme2 = useTheme();
4079
4080
  const { colorTheme } = useBetterHtmlContextInternal();
4080
4081
  const readyColor = color ?? theme2.colors.textSecondary;
4081
- return /* @__PURE__ */ jsx14(
4082
+ const chip = /* @__PURE__ */ jsx14(
4082
4083
  ChipComponent,
4083
4084
  {
4084
4085
  color: colorTheme === "light" ? darkenColor(readyColor, 0.7) : lightenColor(readyColor, 0.7),
@@ -4088,6 +4089,15 @@ ChipComponent.colored = forwardRef9(function Colored({ color, ...props }, ref) {
4088
4089
  ...props
4089
4090
  }
4090
4091
  );
4092
+ return withWhiteBackground ? /* @__PURE__ */ jsx14(
4093
+ Div_default,
4094
+ {
4095
+ width: "fit-content",
4096
+ backgroundColor: withWhiteBackground ? colorTheme === "light" ? "#ffffff" : "#000000" : void 0,
4097
+ borderRadius: withWhiteBackground ? props.borderRadius ?? theme2.styles.borderRadius / borderRadiusOffset + 0.3 : void 0,
4098
+ children: chip
4099
+ }
4100
+ ) : chip;
4091
4101
  });
4092
4102
  var Chip2 = memo14(ChipComponent);
4093
4103
  Chip2.colored = ChipComponent.colored;
@@ -5723,6 +5733,7 @@ var Label_default = memo15(Label);
5723
5733
  // src/components/Dropdown.tsx
5724
5734
  import { forwardRef as forwardRef10, Fragment as Fragment3, memo as memo16, useCallback as useCallback8, useEffect as useEffect6, useMemo as useMemo4, useRef as useRef4, useState as useState5 } from "react";
5725
5735
  import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
5736
+ import { createElement as createElement2 } from "react";
5726
5737
  var DropdownComponent = forwardRef10(function Dropdown({
5727
5738
  label,
5728
5739
  labelColor,
@@ -5894,7 +5905,7 @@ var DropdownComponent = forwardRef10(function Dropdown({
5894
5905
  role: "option",
5895
5906
  "aria-selected": isSelected,
5896
5907
  "aria-disabled": isDisabled,
5897
- children: renderOption ? renderOption(option, index, isSelected) : /* @__PURE__ */ jsx15(Text_default, { children: option.label })
5908
+ children: renderOption ? renderOption(option, index, isSelected) : /* @__PURE__ */ jsx15(Fragment4, { children: !option.renderType || option.renderType === "default" ? /* @__PURE__ */ jsx15(Text_default, { children: option.label }) : option.renderType === "chip" ? /* @__PURE__ */ jsx15(Chip_default, { text: option.label, ...option.chipProps }) : option.renderType === "chip.colored" ? /* @__PURE__ */ jsx15(Chip_default.colored, { text: option.label, withWhiteBackground: true, ...option.chipProps }) : void 0 })
5898
5909
  }
5899
5910
  ),
5900
5911
  renderOptionDivider ? renderOptionDivider(
@@ -5992,7 +6003,18 @@ var DropdownComponent = forwardRef10(function Dropdown({
5992
6003
  paddingBlock: theme2.styles.gap,
5993
6004
  paddingInline: (theme2.styles.space + theme2.styles.gap) / 2,
5994
6005
  transition: theme2.styles.transition,
5995
- children: /* @__PURE__ */ jsx15(Div_default.row, { width: "100%", flexWrap: "wrap", gap: theme2.styles.gap, children: selectedOption.map((option) => /* @__PURE__ */ jsx15(Chip_default, { text: option.label }, JSON.stringify(option))) })
6006
+ children: /* @__PURE__ */ jsx15(Div_default.row, { width: "100%", flexWrap: "wrap", gap: theme2.styles.gap, children: selectedOption.map((option) => {
6007
+ const ChipComponentTag = !option.renderType || option.renderType === "default" || option.renderType === "chip" ? Chip_default : option.renderType === "chip.colored" ? Chip_default.colored : Chip_default;
6008
+ return /* @__PURE__ */ createElement2(
6009
+ ChipComponentTag,
6010
+ {
6011
+ text: option.label,
6012
+ ...option.renderType === "chip" || option.renderType === "chip.colored" ? option.chipProps : [],
6013
+ withWhiteBackground: option.renderType === "chip.colored",
6014
+ key: JSON.stringify(option)
6015
+ }
6016
+ );
6017
+ }) })
5996
6018
  }
5997
6019
  ) : void 0,
5998
6020
  insideInputFieldAfterComponent: /* @__PURE__ */ jsxs11(Fragment4, { children: [
@@ -8389,7 +8411,7 @@ var TableComponent = forwardRef15(function Table({
8389
8411
  if (filter.min !== void 0 && minDate && itemValue < minDate) return false;
8390
8412
  if (filter.max !== void 0 && maxDate && itemValue > maxDate) return false;
8391
8413
  } else if (column.filter === "list" && filter.type === "list") {
8392
- const itemValue = column.getValueForList?.(item).value ?? (column.type === "text" && column.keyName ? String(item[column.keyName]) : "");
8414
+ const itemValue = column.getItemValue?.(item) ?? (column.type === "text" && column.keyName ? String(item[column.keyName]) : "");
8393
8415
  if (!filter.list?.includes(itemValue)) return false;
8394
8416
  }
8395
8417
  return true;
@@ -8408,32 +8430,17 @@ var TableComponent = forwardRef15(function Table({
8408
8430
  return data.length > 0 && checkedItems.every((checked) => checked) && checkedItems.length === data.length;
8409
8431
  }, [data, checkedItems]);
8410
8432
  const possibleFilterListValues = useMemo9(() => {
8411
- if (!openedFilterColumn) return [];
8412
- return data.reduce((previousValue, currentValue) => {
8413
- const valueFromList = openedFilterColumn.filter === "list" && openedFilterColumn.getValueForList ? openedFilterColumn.getValueForList(currentValue) : void 0;
8414
- const value = valueFromList ? valueFromList.value : openedFilterColumn.type === "text" && openedFilterColumn.keyName ? String(currentValue[openedFilterColumn.keyName]) : void 0;
8415
- const label = valueFromList ? valueFromList.label : value;
8416
- let searchPassed = openedFilterColumn.filter === "list" && openedFilterColumn.withSearch ? false : true;
8417
- if (openedFilterColumn.filter === "list" && openedFilterColumn.withSearch) {
8418
- searchPassed = label?.toString().toLowerCase().includes(filterForm.values.search.toLowerCase()) ?? false;
8419
- }
8420
- if (value !== void 0 && value !== null && value !== "" && searchPassed) {
8421
- if (previousValue.some((item) => item.value === value)) {
8422
- previousValue = previousValue.map(
8423
- (item) => item.value === value ? {
8424
- ...item,
8425
- count: item.count + 1
8426
- } : item
8427
- );
8428
- } else
8429
- previousValue.push({
8430
- label: label?.toString() ?? "",
8431
- value,
8432
- count: 1
8433
- });
8434
- }
8435
- return previousValue;
8436
- }, []);
8433
+ if (!openedFilterColumn || openedFilterColumn.filter !== "list") return [];
8434
+ return openedFilterColumn.list.map((item) => ({
8435
+ ...item,
8436
+ count: data.reduce((previousValue, currentValue) => {
8437
+ const value = openedFilterColumn.getItemValue?.(currentValue) ?? (openedFilterColumn.type === "text" && openedFilterColumn.keyName ? String(currentValue[openedFilterColumn.keyName]) : "");
8438
+ return previousValue + (item.value === value ? 1 : 0);
8439
+ }, 0)
8440
+ })).reduce(
8441
+ (previousValue, currentValue) => !previousValue.some((item) => item.value === currentValue.value) ? [...previousValue, currentValue] : previousValue,
8442
+ []
8443
+ );
8437
8444
  }, [data, openedFilterColumn, filterForm.values.search]);
8438
8445
  const pageCountInternal = pageCount ?? (pageSize !== void 0 ? Math.ceil(dataAfterFilter.length / pageSize) : 1);
8439
8446
  const onClickSelectAllFilterListItems = useCallback13(