@bubo-squared/ui-framework 0.2.23 → 0.2.24

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.cjs CHANGED
@@ -148,6 +148,10 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
148
148
  destructive: [
149
149
  "btn-destructive",
150
150
  "focus-ring-error"
151
+ ],
152
+ "destructive-outline": [
153
+ "btn-destructive-outline",
154
+ "focus-ring-error-outline"
151
155
  ]
152
156
  },
153
157
  size: {
@@ -2032,7 +2036,7 @@ var import_class_variance_authority15 = require("class-variance-authority");
2032
2036
  var import_icons8 = require("@bubo-squared/icons");
2033
2037
  var import_jsx_runtime26 = require("react/jsx-runtime");
2034
2038
  var selectTriggerVariants = (0, import_class_variance_authority15.cva)(
2035
- "group flex w-full items-center justify-between rounded-4 border bg-(--background-primary) p-2 text-left transition-colors cursor-pointer hover:bg-(--background-primary-hover) disabled:bg-(--background-primary-disabled) disabled:text-primary-disabled disabled:cursor-default",
2039
+ "group flex w-full items-center justify-between rounded-4 border bg-(--background-primary) p-2 text-left transition-[background-color] cursor-pointer hover:bg-(--background-primary-hover) disabled:bg-(--background-primary-disabled) disabled:text-primary-disabled disabled:cursor-default",
2036
2040
  {
2037
2041
  variants: {
2038
2042
  size: {
@@ -2872,7 +2876,7 @@ var countryOptionVariants = (0, import_class_variance_authority18.cva)(
2872
2876
  }
2873
2877
  );
2874
2878
  var PhoneInput = React31.forwardRef(
2875
- (props, ref) => {
2879
+ (props, forwardedRef) => {
2876
2880
  const {
2877
2881
  className,
2878
2882
  onChange,
@@ -2886,6 +2890,11 @@ var PhoneInput = React31.forwardRef(
2886
2890
  status = "default",
2887
2891
  ...rest
2888
2892
  } = props;
2893
+ const wrapperRef = React31.useRef(null);
2894
+ const focusNumberInput = React31.useCallback(() => {
2895
+ const el = wrapperRef.current?.querySelector("input");
2896
+ el?.focus();
2897
+ }, []);
2889
2898
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2890
2899
  Field,
2891
2900
  {
@@ -2895,16 +2904,29 @@ var PhoneInput = React31.forwardRef(
2895
2904
  status,
2896
2905
  disabled,
2897
2906
  className,
2898
- children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: cn("w-full", wrapperStatusClass[status]), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2907
+ children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { ref: wrapperRef, className: cn("w-full", wrapperStatusClass[status]), children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2899
2908
  RPNInput.default,
2900
2909
  {
2901
- ref,
2910
+ ref: forwardedRef,
2902
2911
  className: cn(
2903
2912
  sizeBase({ size }),
2904
2913
  inputTextVariants2({ size, disabled })
2905
2914
  ),
2906
2915
  flagComponent: FlagComponent,
2907
- countrySelectComponent: (countrySelectProps) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(CountrySelect, { ...countrySelectProps, size }),
2916
+ countrySelectComponent: (countrySelectProps) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
2917
+ CountrySelect,
2918
+ {
2919
+ ...countrySelectProps,
2920
+ size,
2921
+ onAfterSelect: () => {
2922
+ requestAnimationFrame(() => {
2923
+ requestAnimationFrame(() => {
2924
+ focusNumberInput();
2925
+ });
2926
+ });
2927
+ }
2928
+ }
2929
+ ),
2908
2930
  inputComponent: InputComponent,
2909
2931
  smartCaret: false,
2910
2932
  value: value || void 0,
@@ -2939,7 +2961,8 @@ var CountrySelect = ({
2939
2961
  value: selectedCountry,
2940
2962
  options: countryList,
2941
2963
  onChange,
2942
- size = "md"
2964
+ size = "md",
2965
+ onAfterSelect
2943
2966
  }) => {
2944
2967
  const scrollAreaRef = React31.useRef(null);
2945
2968
  const [searchValue, setSearchValue] = React31.useState("");
@@ -3023,7 +3046,10 @@ var CountrySelect = ({
3023
3046
  countryName: label,
3024
3047
  selectedCountry,
3025
3048
  onChange,
3026
- onSelectComplete: () => setIsOpen(false),
3049
+ onSelectComplete: () => {
3050
+ setIsOpen(false);
3051
+ onAfterSelect?.();
3052
+ },
3027
3053
  size
3028
3054
  },
3029
3055
  value
@@ -3625,15 +3651,27 @@ var Slider = React35.forwardRef((props, forwardedRef) => {
3625
3651
  }
3626
3652
  return rounded.toFixed(2);
3627
3653
  };
3628
- const formatDisplayValue = (val) => {
3654
+ const formatFallbackText = (val) => {
3629
3655
  const value2 = val ?? min;
3630
- if (tooltipFormatter) return tooltipFormatter(value2);
3631
3656
  if (showPercentage) {
3632
3657
  const percent = valueToPercent(value2);
3633
3658
  return `${formatNumber(percent)}%`;
3634
3659
  }
3635
3660
  return formatNumber(value2);
3636
3661
  };
3662
+ const formatDisplayNode = (val) => {
3663
+ const value2 = val ?? min;
3664
+ if (tooltipFormatter) return tooltipFormatter(value2);
3665
+ return formatFallbackText(value2);
3666
+ };
3667
+ const formatAriaValueText = (val) => {
3668
+ const fallback = formatFallbackText(val);
3669
+ if (!tooltipFormatter) return fallback;
3670
+ const node = tooltipFormatter(val ?? min);
3671
+ if (typeof node === "string") return node;
3672
+ if (typeof node === "number") return String(node);
3673
+ return fallback;
3674
+ };
3637
3675
  const formatNumericLabel = () => {
3638
3676
  if (isRange && secondary !== void 0) {
3639
3677
  if (!tooltipFormatter && showPercentage && display === "numeric") {
@@ -3641,14 +3679,18 @@ var Slider = React35.forwardRef((props, forwardedRef) => {
3641
3679
  const second = formatNumber(valueToPercent(secondary));
3642
3680
  return `${first} - ${second}`;
3643
3681
  }
3644
- return `${formatDisplayValue(primary)} - ${formatDisplayValue(secondary)}`;
3682
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_jsx_runtime37.Fragment, { children: [
3683
+ formatDisplayNode(primary),
3684
+ " - ",
3685
+ formatDisplayNode(secondary)
3686
+ ] });
3645
3687
  }
3646
- return formatDisplayValue(primary);
3688
+ return formatDisplayNode(primary);
3647
3689
  };
3648
3690
  const trackHeight = 32;
3649
3691
  const thumbWidth = 18;
3650
3692
  const thumbRadius = thumbWidth / 2;
3651
- const renderHandle = (index, percent, ariaValueText) => {
3693
+ const renderHandle = (index, percent, tooltipContent, ariaValueText) => {
3652
3694
  const val = index === 0 ? primary : secondary;
3653
3695
  const isDragging = draggingThumbIndex === index;
3654
3696
  const isTooltipVisible = showTooltip && (hoveredThumbIndex === index || draggingThumbIndex === index || focusedThumbIndex === index);
@@ -3701,7 +3743,7 @@ var Slider = React35.forwardRef((props, forwardedRef) => {
3701
3743
  return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
3702
3744
  Tooltip,
3703
3745
  {
3704
- title: ariaValueText,
3746
+ title: tooltipContent,
3705
3747
  placement: tooltipPlacement === "top" ? "top" : "bottom",
3706
3748
  offset: 8,
3707
3749
  open: isTooltipVisible,
@@ -3763,8 +3805,18 @@ var Slider = React35.forwardRef((props, forwardedRef) => {
3763
3805
  }
3764
3806
  }
3765
3807
  ),
3766
- renderHandle(0, primaryPercent, formatDisplayValue(primary)),
3767
- isRange && secondary !== void 0 && renderHandle(1, secondaryPercent, formatDisplayValue(secondary))
3808
+ renderHandle(
3809
+ 0,
3810
+ primaryPercent,
3811
+ formatDisplayNode(primary),
3812
+ formatAriaValueText(primary)
3813
+ ),
3814
+ isRange && secondary !== void 0 && renderHandle(
3815
+ 1,
3816
+ secondaryPercent,
3817
+ formatDisplayNode(secondary),
3818
+ formatAriaValueText(secondary)
3819
+ )
3768
3820
  ]
3769
3821
  }
3770
3822
  ) }),