@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.d.cts CHANGED
@@ -11,7 +11,7 @@ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
11
11
  import { ClassValue } from 'clsx';
12
12
 
13
13
  declare const buttonVariants: (props?: ({
14
- variant?: "primary" | "secondary" | "ghost" | "outline" | "destructive" | null | undefined;
14
+ variant?: "primary" | "secondary" | "ghost" | "outline" | "destructive" | "destructive-outline" | null | undefined;
15
15
  size?: "sm" | "md" | "lg" | "xl" | null | undefined;
16
16
  } & class_variance_authority_types.ClassProp) | undefined) => string;
17
17
  interface ButtonProps$1 extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
@@ -540,10 +540,13 @@ type SliderBaseProps = {
540
540
  tooltipPlacement?: SliderTooltipPlacement;
541
541
  /**
542
542
  * Custom formatter for tooltip / numeric / accessibility text.
543
- * Receives the current slider value and should return a display string.
543
+ * Receives the current slider value and should return display content.
544
544
  * If provided, it takes precedence over `showPercentage`.
545
+ *
546
+ * Accessibility note: when the formatter returns non-text content,
547
+ * `aria-valuetext` falls back to the default numeric/percentage string.
545
548
  */
546
- tooltipFormatter?: (value: number) => string;
549
+ tooltipFormatter?: (value: number) => React$1.ReactNode;
547
550
  /**
548
551
  * When true (default), values are rendered as percentages (e.g. "30%").
549
552
  * When false, raw numbers are shown instead.
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
11
11
  import { ClassValue } from 'clsx';
12
12
 
13
13
  declare const buttonVariants: (props?: ({
14
- variant?: "primary" | "secondary" | "ghost" | "outline" | "destructive" | null | undefined;
14
+ variant?: "primary" | "secondary" | "ghost" | "outline" | "destructive" | "destructive-outline" | null | undefined;
15
15
  size?: "sm" | "md" | "lg" | "xl" | null | undefined;
16
16
  } & class_variance_authority_types.ClassProp) | undefined) => string;
17
17
  interface ButtonProps$1 extends React$1.ButtonHTMLAttributes<HTMLButtonElement>, VariantProps<typeof buttonVariants> {
@@ -540,10 +540,13 @@ type SliderBaseProps = {
540
540
  tooltipPlacement?: SliderTooltipPlacement;
541
541
  /**
542
542
  * Custom formatter for tooltip / numeric / accessibility text.
543
- * Receives the current slider value and should return a display string.
543
+ * Receives the current slider value and should return display content.
544
544
  * If provided, it takes precedence over `showPercentage`.
545
+ *
546
+ * Accessibility note: when the formatter returns non-text content,
547
+ * `aria-valuetext` falls back to the default numeric/percentage string.
545
548
  */
546
- tooltipFormatter?: (value: number) => string;
549
+ tooltipFormatter?: (value: number) => React$1.ReactNode;
547
550
  /**
548
551
  * When true (default), values are rendered as percentages (e.g. "30%").
549
552
  * When false, raw numbers are shown instead.
package/dist/index.js CHANGED
@@ -66,6 +66,10 @@ var buttonVariants = cva(
66
66
  destructive: [
67
67
  "btn-destructive",
68
68
  "focus-ring-error"
69
+ ],
70
+ "destructive-outline": [
71
+ "btn-destructive-outline",
72
+ "focus-ring-error-outline"
69
73
  ]
70
74
  },
71
75
  size: {
@@ -1956,7 +1960,7 @@ import { cva as cva15 } from "class-variance-authority";
1956
1960
  import { ChevronDownIcon as ChevronDownIcon2 } from "@bubo-squared/icons";
1957
1961
  import { jsx as jsx26, jsxs as jsxs16 } from "react/jsx-runtime";
1958
1962
  var selectTriggerVariants = cva15(
1959
- "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",
1963
+ "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",
1960
1964
  {
1961
1965
  variants: {
1962
1966
  size: {
@@ -2796,7 +2800,7 @@ var countryOptionVariants = cva18(
2796
2800
  }
2797
2801
  );
2798
2802
  var PhoneInput = React31.forwardRef(
2799
- (props, ref) => {
2803
+ (props, forwardedRef) => {
2800
2804
  const {
2801
2805
  className,
2802
2806
  onChange,
@@ -2810,6 +2814,11 @@ var PhoneInput = React31.forwardRef(
2810
2814
  status = "default",
2811
2815
  ...rest
2812
2816
  } = props;
2817
+ const wrapperRef = React31.useRef(null);
2818
+ const focusNumberInput = React31.useCallback(() => {
2819
+ const el = wrapperRef.current?.querySelector("input");
2820
+ el?.focus();
2821
+ }, []);
2813
2822
  return /* @__PURE__ */ jsx33(
2814
2823
  Field,
2815
2824
  {
@@ -2819,16 +2828,29 @@ var PhoneInput = React31.forwardRef(
2819
2828
  status,
2820
2829
  disabled,
2821
2830
  className,
2822
- children: /* @__PURE__ */ jsx33("div", { className: cn("w-full", wrapperStatusClass[status]), children: /* @__PURE__ */ jsx33(
2831
+ children: /* @__PURE__ */ jsx33("div", { ref: wrapperRef, className: cn("w-full", wrapperStatusClass[status]), children: /* @__PURE__ */ jsx33(
2823
2832
  RPNInput.default,
2824
2833
  {
2825
- ref,
2834
+ ref: forwardedRef,
2826
2835
  className: cn(
2827
2836
  sizeBase({ size }),
2828
2837
  inputTextVariants2({ size, disabled })
2829
2838
  ),
2830
2839
  flagComponent: FlagComponent,
2831
- countrySelectComponent: (countrySelectProps) => /* @__PURE__ */ jsx33(CountrySelect, { ...countrySelectProps, size }),
2840
+ countrySelectComponent: (countrySelectProps) => /* @__PURE__ */ jsx33(
2841
+ CountrySelect,
2842
+ {
2843
+ ...countrySelectProps,
2844
+ size,
2845
+ onAfterSelect: () => {
2846
+ requestAnimationFrame(() => {
2847
+ requestAnimationFrame(() => {
2848
+ focusNumberInput();
2849
+ });
2850
+ });
2851
+ }
2852
+ }
2853
+ ),
2832
2854
  inputComponent: InputComponent,
2833
2855
  smartCaret: false,
2834
2856
  value: value || void 0,
@@ -2863,7 +2885,8 @@ var CountrySelect = ({
2863
2885
  value: selectedCountry,
2864
2886
  options: countryList,
2865
2887
  onChange,
2866
- size = "md"
2888
+ size = "md",
2889
+ onAfterSelect
2867
2890
  }) => {
2868
2891
  const scrollAreaRef = React31.useRef(null);
2869
2892
  const [searchValue, setSearchValue] = React31.useState("");
@@ -2947,7 +2970,10 @@ var CountrySelect = ({
2947
2970
  countryName: label,
2948
2971
  selectedCountry,
2949
2972
  onChange,
2950
- onSelectComplete: () => setIsOpen(false),
2973
+ onSelectComplete: () => {
2974
+ setIsOpen(false);
2975
+ onAfterSelect?.();
2976
+ },
2951
2977
  size
2952
2978
  },
2953
2979
  value
@@ -3549,15 +3575,27 @@ var Slider = React35.forwardRef((props, forwardedRef) => {
3549
3575
  }
3550
3576
  return rounded.toFixed(2);
3551
3577
  };
3552
- const formatDisplayValue = (val) => {
3578
+ const formatFallbackText = (val) => {
3553
3579
  const value2 = val ?? min;
3554
- if (tooltipFormatter) return tooltipFormatter(value2);
3555
3580
  if (showPercentage) {
3556
3581
  const percent = valueToPercent(value2);
3557
3582
  return `${formatNumber(percent)}%`;
3558
3583
  }
3559
3584
  return formatNumber(value2);
3560
3585
  };
3586
+ const formatDisplayNode = (val) => {
3587
+ const value2 = val ?? min;
3588
+ if (tooltipFormatter) return tooltipFormatter(value2);
3589
+ return formatFallbackText(value2);
3590
+ };
3591
+ const formatAriaValueText = (val) => {
3592
+ const fallback = formatFallbackText(val);
3593
+ if (!tooltipFormatter) return fallback;
3594
+ const node = tooltipFormatter(val ?? min);
3595
+ if (typeof node === "string") return node;
3596
+ if (typeof node === "number") return String(node);
3597
+ return fallback;
3598
+ };
3561
3599
  const formatNumericLabel = () => {
3562
3600
  if (isRange && secondary !== void 0) {
3563
3601
  if (!tooltipFormatter && showPercentage && display === "numeric") {
@@ -3565,14 +3603,18 @@ var Slider = React35.forwardRef((props, forwardedRef) => {
3565
3603
  const second = formatNumber(valueToPercent(secondary));
3566
3604
  return `${first} - ${second}`;
3567
3605
  }
3568
- return `${formatDisplayValue(primary)} - ${formatDisplayValue(secondary)}`;
3606
+ return /* @__PURE__ */ jsxs25(Fragment2, { children: [
3607
+ formatDisplayNode(primary),
3608
+ " - ",
3609
+ formatDisplayNode(secondary)
3610
+ ] });
3569
3611
  }
3570
- return formatDisplayValue(primary);
3612
+ return formatDisplayNode(primary);
3571
3613
  };
3572
3614
  const trackHeight = 32;
3573
3615
  const thumbWidth = 18;
3574
3616
  const thumbRadius = thumbWidth / 2;
3575
- const renderHandle = (index, percent, ariaValueText) => {
3617
+ const renderHandle = (index, percent, tooltipContent, ariaValueText) => {
3576
3618
  const val = index === 0 ? primary : secondary;
3577
3619
  const isDragging = draggingThumbIndex === index;
3578
3620
  const isTooltipVisible = showTooltip && (hoveredThumbIndex === index || draggingThumbIndex === index || focusedThumbIndex === index);
@@ -3625,7 +3667,7 @@ var Slider = React35.forwardRef((props, forwardedRef) => {
3625
3667
  return /* @__PURE__ */ jsx37(
3626
3668
  Tooltip,
3627
3669
  {
3628
- title: ariaValueText,
3670
+ title: tooltipContent,
3629
3671
  placement: tooltipPlacement === "top" ? "top" : "bottom",
3630
3672
  offset: 8,
3631
3673
  open: isTooltipVisible,
@@ -3687,8 +3729,18 @@ var Slider = React35.forwardRef((props, forwardedRef) => {
3687
3729
  }
3688
3730
  }
3689
3731
  ),
3690
- renderHandle(0, primaryPercent, formatDisplayValue(primary)),
3691
- isRange && secondary !== void 0 && renderHandle(1, secondaryPercent, formatDisplayValue(secondary))
3732
+ renderHandle(
3733
+ 0,
3734
+ primaryPercent,
3735
+ formatDisplayNode(primary),
3736
+ formatAriaValueText(primary)
3737
+ ),
3738
+ isRange && secondary !== void 0 && renderHandle(
3739
+ 1,
3740
+ secondaryPercent,
3741
+ formatDisplayNode(secondary),
3742
+ formatAriaValueText(secondary)
3743
+ )
3692
3744
  ]
3693
3745
  }
3694
3746
  ) }),