react-better-html 1.1.224 → 1.1.226

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
@@ -460,6 +460,7 @@ type ButtonComponent = {
460
460
  icon: IconName | AnyOtherString;
461
461
  /** @default 16 */
462
462
  size?: number;
463
+ buttonSize?: number;
463
464
  /** @default "#000000" */
464
465
  backgroundButtonColor?: string;
465
466
  }) => React.ReactElement;
@@ -587,7 +588,9 @@ declare const PageHolder: typeof PageHolderComponent & {
587
588
  };
588
589
 
589
590
  type ChipProps<Value = unknown> = {
590
- text: string;
591
+ text: string | React.ReactNode;
592
+ beforeText?: React.ReactNode;
593
+ afterText?: React.ReactNode;
591
594
  /** @default theme.colors.textPrimary */
592
595
  color?: string;
593
596
  /** @default backgroundSecondary */
@@ -599,7 +602,7 @@ type ChipProps<Value = unknown> = {
599
602
  value?: Value;
600
603
  onClick?: (event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void;
601
604
  onClickWithValue?: (value: Value) => void;
602
- } & Pick<DivProps, "border" | "borderColor" | "borderWidth" | "borderStyle"> & Pick<TextProps, "fontFamily" | "fontSize" | "fontWeight" | "fontStyle">;
605
+ } & Pick<DivProps, "border" | "borderColor" | "borderWidth" | "borderStyle" | keyof ComponentPaddingProps | "transition" | "height"> & Pick<TextProps, "fontFamily" | "fontSize" | "fontWeight" | "fontStyle">;
603
606
  type ChipComponentType = {
604
607
  <Value>(props: ComponentPropWithRef<HTMLDivElement, ChipProps<Value>>): React.ReactElement;
605
608
  colored: <Value>(props: ComponentPropWithRef<HTMLDivElement, OmitProps<ChipProps<Value>, "color" | "backgroundColor"> & {
package/dist/index.d.ts CHANGED
@@ -460,6 +460,7 @@ type ButtonComponent = {
460
460
  icon: IconName | AnyOtherString;
461
461
  /** @default 16 */
462
462
  size?: number;
463
+ buttonSize?: number;
463
464
  /** @default "#000000" */
464
465
  backgroundButtonColor?: string;
465
466
  }) => React.ReactElement;
@@ -587,7 +588,9 @@ declare const PageHolder: typeof PageHolderComponent & {
587
588
  };
588
589
 
589
590
  type ChipProps<Value = unknown> = {
590
- text: string;
591
+ text: string | React.ReactNode;
592
+ beforeText?: React.ReactNode;
593
+ afterText?: React.ReactNode;
591
594
  /** @default theme.colors.textPrimary */
592
595
  color?: string;
593
596
  /** @default backgroundSecondary */
@@ -599,7 +602,7 @@ type ChipProps<Value = unknown> = {
599
602
  value?: Value;
600
603
  onClick?: (event: React.MouseEvent<HTMLDivElement, globalThis.MouseEvent>) => void;
601
604
  onClickWithValue?: (value: Value) => void;
602
- } & Pick<DivProps, "border" | "borderColor" | "borderWidth" | "borderStyle"> & Pick<TextProps, "fontFamily" | "fontSize" | "fontWeight" | "fontStyle">;
605
+ } & Pick<DivProps, "border" | "borderColor" | "borderWidth" | "borderStyle" | keyof ComponentPaddingProps | "transition" | "height"> & Pick<TextProps, "fontFamily" | "fontSize" | "fontWeight" | "fontStyle">;
603
606
  type ChipComponentType = {
604
607
  <Value>(props: ComponentPropWithRef<HTMLDivElement, ChipProps<Value>>): React.ReactElement;
605
608
  colored: <Value>(props: ComponentPropWithRef<HTMLDivElement, OmitProps<ChipProps<Value>, "color" | "backgroundColor"> & {
package/dist/index.js CHANGED
@@ -2006,16 +2006,16 @@ var ButtonElement = import_styled_components6.default.button.withConfig({
2006
2006
  opacity: 0.6;
2007
2007
  cursor: not-allowed;
2008
2008
  ` : !props.isLoading ? import_styled_components6.css`
2009
- cursor: pointer;
2009
+ cursor: pointer;
2010
2010
 
2011
- &:not(.secondary):hover {
2012
- filter: ${props.colorTheme === "dark" ? "brightness(1.2)" : "brightness(0.9)"};
2013
- }
2011
+ &:not(.secondary):hover {
2012
+ filter: ${props.colorTheme === "dark" ? "brightness(1.2)" : "brightness(0.9)"};
2013
+ }
2014
2014
 
2015
- &.secondary:hover {
2016
- border-color: ${props.theme.colors.primary};
2017
- }
2018
- ` : ""}
2015
+ &.secondary:hover {
2016
+ border-color: ${props.theme.colors.primary};
2017
+ }
2018
+ ` : ""}
2019
2019
 
2020
2020
  &.secondary {
2021
2021
  padding-block: ${(props) => props.isSmall ? props.theme.styles.gap : (props.theme.styles.space + props.theme.styles.gap) / 2}px;
@@ -2074,14 +2074,22 @@ var ButtonComponent = function Button({
2074
2074
  },
2075
2075
  [onClick, onClickWithValue, value]
2076
2076
  );
2077
- const iconComponent = icon ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Div_default.row, { height: 20, alignItems: "center", justifyContent: "center", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2078
- Icon_default,
2077
+ const iconComponent = icon ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2078
+ Div_default.row,
2079
2079
  {
2080
- name: icon,
2081
- color: iconColor ?? props.color ?? theme2.colors.base,
2082
- size: iconSize ?? parseInt(style.fontSize?.toString() ?? "16")
2080
+ height: iconSize ?? parseInt(style.fontSize?.toString() ?? "16"),
2081
+ alignItems: "center",
2082
+ justifyContent: "center",
2083
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2084
+ Icon_default,
2085
+ {
2086
+ name: icon,
2087
+ color: iconColor ?? props.color ?? theme2.colors.base,
2088
+ size: iconSize ?? parseInt(style.fontSize?.toString() ?? "16")
2089
+ }
2090
+ )
2083
2091
  }
2084
- ) }) : void 0;
2092
+ ) : void 0;
2085
2093
  const imageComponent = image ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2086
2094
  Image_default,
2087
2095
  {
@@ -2186,17 +2194,17 @@ ButtonComponent.destructive = function Destructive(props) {
2186
2194
  }
2187
2195
  );
2188
2196
  };
2189
- ButtonComponent.icon = function Icon3({ size = 16, backgroundButtonColor, ...props }) {
2197
+ ButtonComponent.icon = function Icon3({ size = 16, buttonSize, backgroundButtonColor, ...props }) {
2190
2198
  const theme2 = (0, import_react_better_core9.useTheme)();
2191
2199
  const betterHtmlContext2 = useBetterHtmlContextInternal();
2192
- const buttonSize = size + theme2.styles.space;
2200
+ const readyButtonSize = buttonSize ?? size + theme2.styles.space;
2193
2201
  const backgroundButtonColorReady = backgroundButtonColor ?? theme2.colors.textPrimary;
2194
2202
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
2195
2203
  ButtonComponent,
2196
2204
  {
2197
2205
  ...betterHtmlContext2.components.button?.style?.icon,
2198
- width: buttonSize,
2199
- height: buttonSize,
2206
+ width: readyButtonSize,
2207
+ height: readyButtonSize,
2200
2208
  color: theme2.colors.textPrimary,
2201
2209
  backgroundColor: backgroundButtonColorReady + "00",
2202
2210
  backgroundImage: "none",
@@ -3404,6 +3412,8 @@ var import_jsx_runtime14 = require("react/jsx-runtime");
3404
3412
  var borderRadiusOffset = 1.3;
3405
3413
  var ChipComponent = (0, import_react16.forwardRef)(function Chip({
3406
3414
  text,
3415
+ beforeText,
3416
+ afterText,
3407
3417
  color,
3408
3418
  backgroundColor,
3409
3419
  borderRadius,
@@ -3434,7 +3444,11 @@ var ChipComponent = (0, import_react16.forwardRef)(function Chip({
3434
3444
  cursor: onClick || onClickWithValue ? "pointer" : void 0,
3435
3445
  ...props,
3436
3446
  ref,
3437
- children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text_default, { color: color ?? theme2.colors.textPrimary, children: text })
3447
+ children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Div_default.row, { height: "100%", alignItems: "center", gap: theme2.styles.gap, children: [
3448
+ beforeText,
3449
+ typeof text === "string" ? /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Text_default, { color: color ?? theme2.colors.textPrimary, children: text }) : text,
3450
+ afterText
3451
+ ] })
3438
3452
  }
3439
3453
  );
3440
3454
  });
@@ -3734,7 +3748,7 @@ var DropdownComponent = (0, import_react18.forwardRef)(function Dropdown({
3734
3748
  if (!withDebounce) return;
3735
3749
  onChangeSearch?.(debouncedSearchQuery);
3736
3750
  }, [withDebounce, onChangeSearch, debouncedSearchQuery]);
3737
- const displayValue = (withSearch && isFocused && searchQuery.length > 0 ? searchQuery : !Array.isArray(selectedOption) ? selectedOption?.label : void 0) ?? "";
3751
+ const displayValue = (withSearch && isFocused ? searchQuery : !Array.isArray(selectedOption) ? selectedOption?.label : void 0) ?? "";
3738
3752
  const withClearButton = isOpen && (Array.isArray(selectedOption) ? selectedOption.length > 0 : selectedOption);
3739
3753
  const readyPlaceholder = placeholder ?? `Select ${!withMultiselect ? "an " : ""}${label?.toLowerCase() ?? (0, import_react_better_core17.getPluralWord)("option", withMultiselect ? 2 : 1)}`;
3740
3754
  return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Div_default.column, { width: "100%", position: "relative", userSelect: "none", ...props, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
@@ -3755,7 +3769,7 @@ var DropdownComponent = (0, import_react18.forwardRef)(function Dropdown({
3755
3769
  leftIcon,
3756
3770
  autoComplete: "off",
3757
3771
  className: `react-better-html-dropdown${Array.isArray(selectedOption) && selectedOption.length > 0 ? " react-better-html-dropdown-multiselect" : ""}${isOpen ? " react-better-html-dropdown-open" : ""}${isOpenLate ? " react-better-html-dropdown-open-late" : ""}${inputFieldClassName ? ` ${inputFieldClassName}` : ""}`,
3758
- onClick: !disabled ? setIsOpen.toggle : void 0,
3772
+ onClick: !disabled ? withMultiselect ? setIsOpen.setTrue : setIsOpen.toggle : void 0,
3759
3773
  onFocus: setIsFocused.setTrue,
3760
3774
  onBlur: setIsFocused.setFalse,
3761
3775
  onKeyDown: onKeyDownInputField,
@@ -3775,10 +3789,25 @@ var DropdownComponent = (0, import_react18.forwardRef)(function Dropdown({
3775
3789
  transition: theme2.styles.transition,
3776
3790
  children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Div_default.row, { width: "100%", flexWrap: "wrap", gap: theme2.styles.gap, children: selectedOption.map((option) => {
3777
3791
  const ChipComponentTag = !option.renderType || option.renderType === "default" || option.renderType === "chip" ? Chip_default : option.renderType === "chip.colored" ? Chip_default.colored : Chip_default;
3792
+ const withXButton = isFocused || isOpen;
3778
3793
  return /* @__PURE__ */ (0, import_react19.createElement)(
3779
3794
  ChipComponentTag,
3780
3795
  {
3781
3796
  text: option.label,
3797
+ afterText: withXButton && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
3798
+ Button_default.icon,
3799
+ {
3800
+ icon: "XMark",
3801
+ color: theme2.colors.textSecondary,
3802
+ size: 14,
3803
+ buttonSize: 20,
3804
+ value: option,
3805
+ onClickWithValue: onClickOption
3806
+ }
3807
+ ),
3808
+ height: 20 + theme2.styles.gap,
3809
+ paddingRight: withXButton ? theme2.styles.gap / 2 : void 0,
3810
+ transition: "none",
3782
3811
  ...option.renderType === "chip" || option.renderType === "chip.colored" ? option.chipProps : [],
3783
3812
  withWhiteBackground: option.renderType === "chip.colored",
3784
3813
  key: JSON.stringify(option)