@tinybigui/react 0.18.0 → 0.19.0

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.js CHANGED
@@ -10409,9 +10409,12 @@ function SliderThumbInternal({
10409
10409
  state,
10410
10410
  trackRef,
10411
10411
  isDisabled,
10412
+ orientation,
10412
10413
  formatValue: formatValue2,
10413
10414
  className,
10414
10415
  "data-direction": dataDirection,
10416
+ renderContent,
10417
+ onDraggingChange,
10415
10418
  ...ariaProps
10416
10419
  }) {
10417
10420
  const inputRef = useRef(null);
@@ -10426,33 +10429,70 @@ function SliderThumbInternal({
10426
10429
  state
10427
10430
  );
10428
10431
  const { isFocusVisible, focusProps } = useFocusRing();
10432
+ const { isHovered, hoverProps } = useHover({ isDisabled });
10433
+ useEffect(() => {
10434
+ onDraggingChange?.(isDragging);
10435
+ }, [isDragging, onDraggingChange]);
10429
10436
  const currentValue = state.getThumbValue(index);
10430
10437
  const ariaValueText = formatValue2 ? formatValue2(currentValue) : void 0;
10431
- return /* @__PURE__ */ jsx(
10438
+ const thumbPercent = state.getThumbPercent(index);
10439
+ const positionStyle = orientation === "horizontal" ? {
10440
+ position: "absolute",
10441
+ left: `${thumbPercent * 100}%`,
10442
+ top: "50%",
10443
+ transform: "translate(-50%, -50%)",
10444
+ zIndex: 10
10445
+ } : {
10446
+ position: "absolute",
10447
+ bottom: `${thumbPercent * 100}%`,
10448
+ left: "50%",
10449
+ transform: "translate(-50%, 50%)",
10450
+ zIndex: 10
10451
+ };
10452
+ const renderState = {
10453
+ index,
10454
+ value: currentValue,
10455
+ isDragging,
10456
+ isFocusVisible,
10457
+ isHovered,
10458
+ isDisabled
10459
+ };
10460
+ return /* @__PURE__ */ jsxs(
10432
10461
  "div",
10433
10462
  {
10434
- ...thumbProps,
10463
+ ...mergeProps$1(thumbProps, hoverProps, { style: positionStyle }),
10464
+ "data-slot": "slider-thumb",
10435
10465
  "data-dragging": isDragging || void 0,
10436
10466
  "data-focused": isFocused || void 0,
10437
- "data-focus-visible": isFocusVisible || void 0,
10438
- "data-disabled": isDisabled || void 0,
10439
10467
  ...dataDirection !== void 0 ? { "data-direction": dataDirection } : {},
10468
+ ...getInteractionDataAttributes({
10469
+ isHovered,
10470
+ isFocusVisible,
10471
+ isPressed: isDragging,
10472
+ isDisabled
10473
+ }),
10440
10474
  className: cn(
10475
+ // Group scope: interaction selectors on children target this element
10476
+ "group/slider-thumb",
10477
+ // Accessibility: remove default outline (custom focus ring via data-[focus-visible])
10441
10478
  "outline-none",
10442
- // Focus ring visible only on keyboard focus — matches project pattern (md3-design.mdc §Accessibility)
10479
+ // Focus ring visible only on keyboard focus — matches project pattern
10443
10480
  "data-[focus-visible]:ring-3",
10444
10481
  "data-[focus-visible]:ring-secondary",
10445
10482
  "data-[focus-visible]:ring-offset-2",
10446
10483
  className
10447
10484
  ),
10448
- children: /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(
10449
- "input",
10450
- {
10451
- ref: inputRef,
10452
- ...mergeProps$1(inputProps, focusProps),
10453
- ...ariaValueText !== void 0 ? { "aria-valuetext": ariaValueText } : {}
10454
- }
10455
- ) })
10485
+ children: [
10486
+ /* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx(
10487
+ "input",
10488
+ {
10489
+ ref: inputRef,
10490
+ ...mergeProps$1(inputProps, focusProps),
10491
+ ...ariaValueText !== void 0 ? { "aria-valuetext": ariaValueText } : {}
10492
+ }
10493
+ ) }),
10494
+ renderContent?.(renderState)
10495
+ ]
10456
10496
  }
10457
10497
  );
10458
10498
  }
@@ -10475,6 +10515,9 @@ var SliderHeadless = forwardRef(
10475
10515
  className,
10476
10516
  style,
10477
10517
  children,
10518
+ trackClassName,
10519
+ renderThumbContent,
10520
+ onThumbDraggingChange,
10478
10521
  ...ariaProps
10479
10522
  } = props;
10480
10523
  const trackRef = useRef(null);
@@ -10536,7 +10579,18 @@ var SliderHeadless = forwardRef(
10536
10579
  "data-variant": variant,
10537
10580
  ...zeroPercent !== void 0 ? { "data-zero-percent": zeroPercent } : {},
10538
10581
  children: [
10539
- label && /* @__PURE__ */ jsx("label", { ...labelProps, children: label }),
10582
+ label && /* @__PURE__ */ jsx("label", { ...labelProps, className: cn(orientation === "vertical" && "sr-only"), children: label }),
10583
+ /* @__PURE__ */ jsx(
10584
+ "output",
10585
+ {
10586
+ ...outputProps,
10587
+ className: cn(
10588
+ orientation === "horizontal" && "justify-self-end",
10589
+ orientation === "vertical" && "sr-only"
10590
+ ),
10591
+ children: isRange ? formatValue2 ? `${formatValue2(state.getThumbValue(0))} \u2013 ${formatValue2(state.getThumbValue(1))}` : `${state.getThumbValueLabel(0)} \u2013 ${state.getThumbValueLabel(1)}` : formatValue2 ? formatValue2(state.getThumbValue(0)) : state.getThumbValueLabel(0)
10592
+ }
10593
+ ),
10540
10594
  /* @__PURE__ */ jsxs(
10541
10595
  "div",
10542
10596
  {
@@ -10545,6 +10599,10 @@ var SliderHeadless = forwardRef(
10545
10599
  "data-orientation": orientation,
10546
10600
  "data-track": true,
10547
10601
  ...zeroPercent !== void 0 ? { "data-zero-percent": zeroPercent } : {},
10602
+ className: cn(
10603
+ trackClassName ?? "relative w-full",
10604
+ orientation === "vertical" && !trackClassName && "h-full"
10605
+ ),
10548
10606
  children: [
10549
10607
  children,
10550
10608
  /* @__PURE__ */ jsx(
@@ -10554,9 +10612,12 @@ var SliderHeadless = forwardRef(
10554
10612
  state,
10555
10613
  trackRef,
10556
10614
  isDisabled,
10615
+ orientation,
10557
10616
  ...formatValue2 !== void 0 ? { formatValue: formatValue2 } : {},
10558
10617
  ...thumb0Label !== void 0 ? { "aria-label": thumb0Label } : {},
10559
- ...direction !== void 0 ? { "data-direction": direction } : {}
10618
+ ...direction !== void 0 ? { "data-direction": direction } : {},
10619
+ ...renderThumbContent !== void 0 ? { renderContent: renderThumbContent } : {},
10620
+ ...onThumbDraggingChange !== void 0 ? { onDraggingChange: (d) => onThumbDraggingChange(0, d) } : {}
10560
10621
  }
10561
10622
  ),
10562
10623
  isRange && /* @__PURE__ */ jsx(
@@ -10566,144 +10627,174 @@ var SliderHeadless = forwardRef(
10566
10627
  state,
10567
10628
  trackRef,
10568
10629
  isDisabled,
10630
+ orientation,
10569
10631
  ...formatValue2 !== void 0 ? { formatValue: formatValue2 } : {},
10570
- "aria-label": thumbLabels?.[1] ?? "Maximum"
10632
+ "aria-label": thumbLabels?.[1] ?? "Maximum",
10633
+ ...renderThumbContent !== void 0 ? { renderContent: renderThumbContent } : {},
10634
+ ...onThumbDraggingChange !== void 0 ? { onDraggingChange: (d) => onThumbDraggingChange(1, d) } : {}
10571
10635
  }
10572
10636
  )
10573
10637
  ]
10574
10638
  }
10575
- ),
10576
- /* @__PURE__ */ jsx("output", { ...outputProps, children: isRange ? formatValue2 ? `${formatValue2(state.getThumbValue(0))} \u2013 ${formatValue2(state.getThumbValue(1))}` : `${state.getThumbValueLabel(0)} \u2013 ${state.getThumbValueLabel(1)}` : formatValue2 ? formatValue2(state.getThumbValue(0)) : state.getThumbValueLabel(0) })
10639
+ )
10577
10640
  ]
10578
10641
  }
10579
10642
  );
10580
10643
  }
10581
10644
  );
10582
10645
  SliderHeadless.displayName = "SliderHeadless";
10583
- var sliderContainerVariants = cva(
10584
- [
10585
- "relative",
10586
- "flex",
10587
- "items-center",
10588
- "w-full",
10589
- "touch-none",
10590
- // NOTE: measurement-derived value from MD3 spec; permitted exception — prevents browser scroll on drag
10591
- "select-none"
10592
- ],
10593
- {
10594
- variants: {
10595
- size: {
10596
- // NOTE: measurement-derived values from MD3 spec §4.2; permitted exception
10597
- xsmall: "h-[44px]",
10598
- small: "h-[44px]",
10599
- medium: "h-[52px]",
10600
- large: "h-[68px]",
10601
- xlarge: "h-[108px]"
10602
- },
10603
- orientation: {
10604
- // Horizontal: w-full already in base; flex-row is default flex direction
10605
- horizontal: "",
10606
- // Vertical: transposed — container height fills parent, width = handle height (per size)
10607
- // flex-col stacks label → track → output vertically
10608
- // NOTE: h-full requires a parent with defined height; w-[...] set via compound variants
10609
- vertical: "h-full flex-col"
10610
- },
10611
- disabled: {
10612
- true: "cursor-not-allowed pointer-events-none",
10613
- false: "cursor-pointer"
10614
- }
10615
- },
10616
- compoundVariants: [
10617
- // Vertical: container WIDTH = handle height (MD3 §10.9 — dimensions transposed)
10618
- // Overrides w-full from base via tailwind-merge in cn()
10646
+ var sliderContainerVariants = cva(["group/slider", "relative", "select-none"], {
10647
+ variants: {
10648
+ orientation: {
10649
+ // Grid: 1fr for label, auto for output value; gap-x for label↔output spacing
10650
+ horizontal: "grid grid-cols-[1fr_auto] items-center gap-x-2 w-full",
10651
+ // Flex column: label → track → output stacked; width = handle height (per size)
10652
+ vertical: "flex flex-col items-center h-full"
10653
+ },
10654
+ size: {
10655
+ // Vertical orientation: container width = handle height (dimensions transposed)
10656
+ // Applied only for vertical via compoundVariants below
10619
10657
  // NOTE: measurement-derived values from MD3 spec §4.2; permitted exception
10620
- { orientation: "vertical", size: "xsmall", className: "w-[44px]" },
10621
- { orientation: "vertical", size: "small", className: "w-[44px]" },
10622
- { orientation: "vertical", size: "medium", className: "w-[52px]" },
10623
- { orientation: "vertical", size: "large", className: "w-[68px]" },
10624
- { orientation: "vertical", size: "xlarge", className: "w-[108px]" }
10625
- ],
10626
- defaultVariants: {
10627
- size: "xsmall",
10628
- orientation: "horizontal",
10629
- disabled: false
10658
+ xsmall: "",
10659
+ small: "",
10660
+ medium: "",
10661
+ large: "",
10662
+ xlarge: ""
10630
10663
  }
10664
+ },
10665
+ compoundVariants: [
10666
+ // Vertical: container WIDTH = handle height (MD3 §10.9 — dimensions transposed)
10667
+ // NOTE: measurement-derived values from MD3 spec §4.2; permitted exception
10668
+ { orientation: "vertical", size: "xsmall", class: "w-[44px]" },
10669
+ { orientation: "vertical", size: "small", class: "w-[44px]" },
10670
+ { orientation: "vertical", size: "medium", class: "w-[52px]" },
10671
+ { orientation: "vertical", size: "large", class: "w-[68px]" },
10672
+ { orientation: "vertical", size: "xlarge", class: "w-[108px]" }
10673
+ ],
10674
+ defaultVariants: {
10675
+ orientation: "horizontal",
10676
+ size: "xsmall"
10631
10677
  }
10632
- );
10678
+ });
10679
+ var sliderTrackRegionVariants = cva(["relative", "touch-none"], {
10680
+ variants: {
10681
+ orientation: {
10682
+ horizontal: "col-span-2 w-full",
10683
+ // flex-1 fills the vertical container reliably; h-full collapses when the
10684
+ // container itself is a flex item without an explicit pixel height (CSS spec).
10685
+ // min-h-0 allows the flex child to shrink below its natural size if needed.
10686
+ vertical: "flex-1 min-h-0"
10687
+ },
10688
+ size: {
10689
+ // Horizontal: size controls track region HEIGHT (= handle height)
10690
+ // Vertical: size controls track region WIDTH (= handle height, dimensions transposed)
10691
+ // Applied as compound variants below to avoid cross-orientation conflicts
10692
+ xsmall: "",
10693
+ small: "",
10694
+ medium: "",
10695
+ large: "",
10696
+ xlarge: ""
10697
+ }
10698
+ },
10699
+ compoundVariants: [
10700
+ // Horizontal: height = handle height per MD3 §4.2
10701
+ { orientation: "horizontal", size: "xsmall", class: "h-[44px]" },
10702
+ { orientation: "horizontal", size: "small", class: "h-[44px]" },
10703
+ { orientation: "horizontal", size: "medium", class: "h-[52px]" },
10704
+ { orientation: "horizontal", size: "large", class: "h-[68px]" },
10705
+ { orientation: "horizontal", size: "xlarge", class: "h-[108px]" },
10706
+ // Vertical: width = handle height (transposed per MD3 §10.9)
10707
+ { orientation: "vertical", size: "xsmall", class: "w-[44px]" },
10708
+ { orientation: "vertical", size: "small", class: "w-[44px]" },
10709
+ { orientation: "vertical", size: "medium", class: "w-[52px]" },
10710
+ { orientation: "vertical", size: "large", class: "w-[68px]" },
10711
+ { orientation: "vertical", size: "xlarge", class: "w-[108px]" }
10712
+ ],
10713
+ defaultVariants: {
10714
+ orientation: "horizontal",
10715
+ size: "xsmall"
10716
+ }
10717
+ });
10718
+ var sliderTrackLayoutVariants = cva(["absolute", "inset-0", "pointer-events-none"]);
10633
10719
  var sliderActiveTrackVariants = cva(
10634
- ["bg-primary", "flex-shrink-0", "overflow-hidden", "relative"],
10720
+ [
10721
+ // Color
10722
+ "bg-primary",
10723
+ // Disabled — driven by root group/slider data-disabled attr
10724
+ "group-data-[disabled]/slider:bg-on-surface",
10725
+ "group-data-[disabled]/slider:opacity-38",
10726
+ // Layout — absolute fill within the track region
10727
+ "absolute",
10728
+ "overflow-hidden"
10729
+ ],
10635
10730
  {
10636
10731
  variants: {
10637
10732
  size: {
10638
- // NOTE: measurement-derived values from MD3 spec §4.2, §6 Corner tokens; permitted exception
10639
- // Corner classes are in compound variants to avoid conflicts with vertical orientation corners
10733
+ // Horizontal: left (start) = outer corner, right (near handle) = 2dp inner
10734
+ // NOTE: measurement-derived values from MD3 spec §4.2, §6; permitted exception
10640
10735
  xsmall: "h-[16px] rounded-l-[16px] rounded-r-[2px]",
10641
- // corner.large outer (16dp), 2dp inner
10642
10736
  small: "h-[16px] rounded-l-[16px] rounded-r-[2px]",
10643
10737
  medium: "h-[40px] rounded-l-[12px] rounded-r-[2px]",
10644
- // corner.medium outer (12dp), 2dp inner
10645
10738
  large: "h-[56px] rounded-l-[16px] rounded-r-[2px]",
10646
- // corner.large outer (16dp), 2dp inner
10647
10739
  xlarge: "h-[96px] rounded-l-[28px] rounded-r-[2px]"
10648
- // corner.extra-large outer (28dp), 2dp inner
10649
10740
  },
10650
10741
  orientation: {
10651
- horizontal: "",
10652
- // Vertical: track thickness is now width; flex-basis (inline style) controls height.
10653
- // h-[...] from size variant is overridden by flex-basis in a flex-col container.
10654
- // Individual corner classes (rounded-tl/tr/bl/br) override the horizontal rounded-l/r
10655
- // via tailwind-merge conflict resolution in cn().
10656
- vertical: ""
10657
- },
10658
- disabled: {
10659
- true: "bg-on-surface opacity-38",
10660
- false: ""
10742
+ // Horizontal: center vertically within track region
10743
+ horizontal: "top-1/2 -translate-y-1/2",
10744
+ // Vertical: center horizontally; length controlled by inline top/height styles
10745
+ vertical: "left-1/2 -translate-x-1/2"
10661
10746
  }
10662
10747
  },
10663
10748
  compoundVariants: [
10664
- // Vertical: width = track thickness, corners transposed (bottom = outer, top = inner near handle)
10665
- // Using individual corner utilities so tailwind-merge correctly resolves conflicts with
10666
- // the horizontal rounded-l/rounded-r classes from size variants.
10667
- // NOTE: measurement-derived values from MD3 spec §4.2, §6 Corner tokens; permitted exception
10749
+ // Vertical: width = track thickness; bottom = outer corner, top = 2dp inner (near handle)
10750
+ // NOTE: measurement-derived values from MD3 spec §4.2, §6; permitted exception
10668
10751
  {
10669
10752
  orientation: "vertical",
10670
10753
  size: "xsmall",
10671
- className: "w-[16px] rounded-tl-[2px] rounded-tr-[2px] rounded-bl-[16px] rounded-br-[16px]"
10754
+ class: "w-[16px] rounded-tl-[2px] rounded-tr-[2px] rounded-bl-[16px] rounded-br-[16px]"
10672
10755
  },
10673
10756
  {
10674
10757
  orientation: "vertical",
10675
10758
  size: "small",
10676
- className: "w-[16px] rounded-tl-[2px] rounded-tr-[2px] rounded-bl-[16px] rounded-br-[16px]"
10759
+ class: "w-[16px] rounded-tl-[2px] rounded-tr-[2px] rounded-bl-[16px] rounded-br-[16px]"
10677
10760
  },
10678
10761
  {
10679
10762
  orientation: "vertical",
10680
10763
  size: "medium",
10681
- className: "w-[40px] rounded-tl-[2px] rounded-tr-[2px] rounded-bl-[12px] rounded-br-[12px]"
10764
+ class: "w-[40px] rounded-tl-[2px] rounded-tr-[2px] rounded-bl-[12px] rounded-br-[12px]"
10682
10765
  },
10683
10766
  {
10684
10767
  orientation: "vertical",
10685
10768
  size: "large",
10686
- className: "w-[56px] rounded-tl-[2px] rounded-tr-[2px] rounded-bl-[16px] rounded-br-[16px]"
10769
+ class: "w-[56px] rounded-tl-[2px] rounded-tr-[2px] rounded-bl-[16px] rounded-br-[16px]"
10687
10770
  },
10688
10771
  {
10689
10772
  orientation: "vertical",
10690
10773
  size: "xlarge",
10691
- className: "w-[96px] rounded-tl-[2px] rounded-tr-[2px] rounded-bl-[28px] rounded-br-[28px]"
10774
+ class: "w-[96px] rounded-tl-[2px] rounded-tr-[2px] rounded-bl-[28px] rounded-br-[28px]"
10692
10775
  }
10693
10776
  ],
10694
10777
  defaultVariants: {
10695
10778
  size: "xsmall",
10696
- orientation: "horizontal",
10697
- disabled: false
10779
+ orientation: "horizontal"
10698
10780
  }
10699
10781
  }
10700
10782
  );
10701
10783
  var sliderInactiveTrackVariants = cva(
10702
- ["bg-secondary-container", "flex-1", "overflow-hidden", "relative"],
10784
+ [
10785
+ // Color
10786
+ "bg-secondary-container",
10787
+ // Disabled — driven by root group/slider data-disabled attr
10788
+ "group-data-[disabled]/slider:bg-on-surface/10",
10789
+ // Layout — absolute fill within the track region
10790
+ "absolute",
10791
+ "overflow-hidden"
10792
+ ],
10703
10793
  {
10704
10794
  variants: {
10705
10795
  size: {
10706
- // NOTE: measurement-derived values from MD3 spec §4.2, §6 Corner tokens; permitted exception
10796
+ // Horizontal: left (near handle) = 2dp inner, right (end) = outer corner
10797
+ // NOTE: measurement-derived values from MD3 spec §4.2, §6; permitted exception
10707
10798
  xsmall: "h-[16px] rounded-l-[2px] rounded-r-[16px]",
10708
10799
  small: "h-[16px] rounded-l-[2px] rounded-r-[16px]",
10709
10800
  medium: "h-[40px] rounded-l-[2px] rounded-r-[12px]",
@@ -10711,68 +10802,65 @@ var sliderInactiveTrackVariants = cva(
10711
10802
  xlarge: "h-[96px] rounded-l-[2px] rounded-r-[28px]"
10712
10803
  },
10713
10804
  orientation: {
10714
- horizontal: "",
10715
- // Vertical: track thickness is width; flex-1 controls height growth.
10716
- // Individual corner classes override horizontal rounded-l/r via tailwind-merge.
10717
- vertical: ""
10718
- },
10719
- disabled: {
10720
- true: "bg-on-surface/10",
10721
- // MD3 §8.2: 10% opacity via background alpha
10722
- false: ""
10805
+ // Horizontal: center vertically within track region
10806
+ horizontal: "top-1/2 -translate-y-1/2",
10807
+ // Vertical: center horizontally; length controlled by inline top/height styles
10808
+ vertical: "left-1/2 -translate-x-1/2"
10723
10809
  }
10724
10810
  },
10725
10811
  compoundVariants: [
10726
- // Vertical: width = track thickness, corners transposed (top = outer, bottom = inner near handle)
10727
- // NOTE: measurement-derived values from MD3 spec §4.2, §6 Corner tokens; permitted exception
10812
+ // Vertical: width = track thickness; top = outer corner, bottom = 2dp inner (near handle)
10813
+ // NOTE: measurement-derived values from MD3 spec §4.2, §6; permitted exception
10728
10814
  {
10729
10815
  orientation: "vertical",
10730
10816
  size: "xsmall",
10731
- className: "w-[16px] rounded-tl-[16px] rounded-tr-[16px] rounded-bl-[2px] rounded-br-[2px]"
10817
+ class: "w-[16px] rounded-tl-[16px] rounded-tr-[16px] rounded-bl-[2px] rounded-br-[2px]"
10732
10818
  },
10733
10819
  {
10734
10820
  orientation: "vertical",
10735
10821
  size: "small",
10736
- className: "w-[16px] rounded-tl-[16px] rounded-tr-[16px] rounded-bl-[2px] rounded-br-[2px]"
10822
+ class: "w-[16px] rounded-tl-[16px] rounded-tr-[16px] rounded-bl-[2px] rounded-br-[2px]"
10737
10823
  },
10738
10824
  {
10739
10825
  orientation: "vertical",
10740
10826
  size: "medium",
10741
- className: "w-[40px] rounded-tl-[12px] rounded-tr-[12px] rounded-bl-[2px] rounded-br-[2px]"
10827
+ class: "w-[40px] rounded-tl-[12px] rounded-tr-[12px] rounded-bl-[2px] rounded-br-[2px]"
10742
10828
  },
10743
10829
  {
10744
10830
  orientation: "vertical",
10745
10831
  size: "large",
10746
- className: "w-[56px] rounded-tl-[16px] rounded-tr-[16px] rounded-bl-[2px] rounded-br-[2px]"
10832
+ class: "w-[56px] rounded-tl-[16px] rounded-tr-[16px] rounded-bl-[2px] rounded-br-[2px]"
10747
10833
  },
10748
10834
  {
10749
10835
  orientation: "vertical",
10750
10836
  size: "xlarge",
10751
- className: "w-[96px] rounded-tl-[28px] rounded-tr-[28px] rounded-bl-[2px] rounded-br-[2px]"
10837
+ class: "w-[96px] rounded-tl-[28px] rounded-tr-[28px] rounded-bl-[2px] rounded-br-[2px]"
10752
10838
  }
10753
10839
  ],
10754
10840
  defaultVariants: {
10755
10841
  size: "xsmall",
10756
- orientation: "horizontal",
10757
- disabled: false
10842
+ orientation: "horizontal"
10758
10843
  }
10759
10844
  }
10760
10845
  );
10761
10846
  var sliderHandleVariants = cva(
10762
10847
  [
10848
+ // Color
10763
10849
  "bg-primary",
10850
+ // Disabled — driven by thumb group/slider-thumb data-disabled attr
10851
+ "group-data-[disabled]/slider-thumb:bg-on-surface",
10852
+ "group-data-[disabled]/slider-thumb:opacity-38",
10853
+ // Pressed width (MD3: 4dp → 2dp on press, spatial spring)
10854
+ "group-data-[pressed]/slider-thumb:w-[2px]",
10855
+ // Shape
10764
10856
  "rounded-[2px]",
10765
- // NOTE: measurement-derived value from MD3 spec §10.3 (2dp handle border-radius); permitted exception
10857
+ // Layout
10766
10858
  "flex-shrink-0",
10767
- "relative",
10768
- "z-10",
10769
- "outline-none"
10770
- // Motion classes applied conditionally in Slider.tsx via useReducedMotion guard
10859
+ "pointer-events-none"
10771
10860
  ],
10772
10861
  {
10773
10862
  variants: {
10774
10863
  size: {
10775
- // NOTE: measurement-derived values from MD3 spec §4.2, §10.3; permitted exception
10776
10864
  xsmall: "w-[4px] h-[44px]",
10777
10865
  small: "w-[4px] h-[44px]",
10778
10866
  medium: "w-[4px] h-[52px]",
@@ -10781,79 +10869,99 @@ var sliderHandleVariants = cva(
10781
10869
  },
10782
10870
  orientation: {
10783
10871
  horizontal: "",
10784
- // Vertical: dimensions transposed. h-[4px] overrides size-variant h-[...] via tailwind-merge;
10785
- // w-full overrides size-variant w-[4px] via tailwind-merge (both in cn() call at styled layer).
10786
- // NOTE: measurement-derived value from MD3 spec §10.3 (4dp handle width); permitted exception
10787
- vertical: "h-[4px] w-full"
10788
- },
10789
- pressed: {
10790
- true: "w-[2px]",
10791
- // NOTE: measurement-derived value from MD3 spec §10.3 (2dp pressed width); permitted exception
10792
- false: ""
10793
- },
10794
- disabled: {
10795
- true: "bg-on-surface opacity-38",
10796
- false: ""
10872
+ // Vertical: handle is a thin horizontal bar. h-[4px] overrides the base
10873
+ // h-[44px..108px]. Width is explicitly set per size below so the RA thumb
10874
+ // (which is shrink-to-fit) assumes the correct measured width this also
10875
+ // fixes the hit-area (w-full) and state-layer (inset-0) widths.
10876
+ vertical: "h-[4px]"
10797
10877
  }
10798
10878
  },
10879
+ compoundVariants: [
10880
+ // Vertical: override to height-based narrowing on press
10881
+ {
10882
+ orientation: "vertical",
10883
+ class: "group-data-[pressed]/slider-thumb:h-[2px]"
10884
+ },
10885
+ // Vertical per-size widths (transposed handle length = track region width per MD3 §10.9)
10886
+ // NOTE: measurement-derived values from MD3 spec §4.2; permitted exception
10887
+ { orientation: "vertical", size: "xsmall", class: "w-[44px]" },
10888
+ { orientation: "vertical", size: "small", class: "w-[44px]" },
10889
+ { orientation: "vertical", size: "medium", class: "w-[52px]" },
10890
+ { orientation: "vertical", size: "large", class: "w-[68px]" },
10891
+ { orientation: "vertical", size: "xlarge", class: "w-[108px]" }
10892
+ ],
10799
10893
  defaultVariants: {
10800
10894
  size: "xsmall",
10801
- orientation: "horizontal",
10802
- pressed: false,
10803
- disabled: false
10804
- }
10805
- }
10806
- );
10807
- var sliderHandleStateLayerVariants = cva(
10808
- [
10809
- "absolute",
10810
- "inset-0",
10811
- "rounded-[4px]",
10812
- // NOTE: measurement-derived value from MD3 spec §10.3 (4dp state layer border-radius); permitted exception
10813
- "bg-on-primary",
10814
- "pointer-events-none"
10815
- // Motion classes applied conditionally in Slider.tsx via useReducedMotion guard
10816
- ],
10817
- {
10818
- variants: {
10819
- state: {
10820
- enabled: "opacity-0",
10821
- hovered: "opacity-8",
10822
- // MD3 §8.3: 8% hover
10823
- pressed: "opacity-10",
10824
- // MD3 §8.3: 10% pressed
10825
- focused: "opacity-10",
10826
- // MD3 §8.3: 10% focus
10827
- disabled: "opacity-0"
10828
- }
10829
- },
10830
- defaultVariants: {
10831
- state: "enabled"
10895
+ orientation: "horizontal"
10832
10896
  }
10833
10897
  }
10834
10898
  );
10835
- var sliderTrackLayoutVariants = cva(
10836
- [
10837
- "relative",
10838
- "flex",
10839
- "items-center",
10840
- "gap-[6px]"
10841
- // NOTE: measurement-derived value from MD3 spec §2, §6 (thumbTrackGapSize: 6dp); permitted exception
10842
- ],
10843
- {
10844
- variants: {
10845
- orientation: {
10846
- // Horizontal: full width, left-to-right fill
10847
- horizontal: "flex-row w-full",
10848
- // Vertical: full height, bottom-to-top fill (flex-col-reverse places active track at bottom)
10849
- vertical: "flex-col-reverse h-full"
10850
- }
10899
+ var sliderHandleStateLayerVariants = cva([
10900
+ // Color
10901
+ "bg-primary",
10902
+ // Positioning — covers the handle
10903
+ "absolute",
10904
+ "inset-0",
10905
+ "rounded-[2px]",
10906
+ // Interaction: hidden by default
10907
+ "opacity-0",
10908
+ "pointer-events-none",
10909
+ // State opacities — driven by group/slider-thumb data attrs
10910
+ "group-data-[hovered]/slider-thumb:opacity-8",
10911
+ "group-data-[focus-visible]/slider-thumb:opacity-10",
10912
+ "group-data-[pressed]/slider-thumb:opacity-10",
10913
+ // Disabled: hide state layer (no interaction feedback)
10914
+ "group-data-[disabled]/slider-thumb:hidden",
10915
+ // Motion: effects spring (opacity transition only)
10916
+ "transition-opacity",
10917
+ "duration-spring-standard-fast-effects",
10918
+ "ease-spring-standard-fast-effects"
10919
+ ]);
10920
+ var sliderValueIndicatorVariants = cva([
10921
+ // Positioning: float above handle center
10922
+ "absolute",
10923
+ "left-1/2",
10924
+ "-translate-x-1/2",
10925
+ "bottom-[calc(100%+4px)]",
10926
+ // Shape & color
10927
+ "bg-inverse-surface",
10928
+ "rounded-full",
10929
+ "px-[12px]",
10930
+ "py-[6px]",
10931
+ "min-w-[48px]",
10932
+ "text-center",
10933
+ // Hidden by default; revealed when thumb group has data-pressed
10934
+ "opacity-0",
10935
+ "scale-0",
10936
+ "group-data-[pressed]/slider-thumb:opacity-100",
10937
+ "group-data-[pressed]/slider-thumb:scale-100",
10938
+ // Prevent interaction (value display only)
10939
+ "pointer-events-none",
10940
+ // Z-index above track overlays
10941
+ "z-10",
10942
+ // In Tailwind v4, scale-* maps to the CSS `scale` property (not `transform`),
10943
+ // so we must list `scale` here — not `transform` — to animate the reveal.
10944
+ "will-change-[scale,opacity]"
10945
+ ]);
10946
+ var sliderStopDotVariants = cva(["rounded-full", "flex-shrink-0", "pointer-events-none"], {
10947
+ variants: {
10948
+ region: {
10949
+ active: "bg-on-primary",
10950
+ inactive: "bg-on-secondary-container"
10851
10951
  },
10852
- defaultVariants: {
10853
- orientation: "horizontal"
10952
+ size: {
10953
+ xsmall: "w-[4px] h-[4px]",
10954
+ small: "w-[4px] h-[4px]",
10955
+ medium: "w-[6px] h-[6px]",
10956
+ large: "w-[6px] h-[6px]",
10957
+ xlarge: "w-[8px] h-[8px]"
10854
10958
  }
10959
+ },
10960
+ defaultVariants: {
10961
+ region: "inactive",
10962
+ size: "xsmall"
10855
10963
  }
10856
- );
10964
+ });
10857
10965
  var sliderStopsContainerVariants = cva([
10858
10966
  "absolute",
10859
10967
  "inset-0",
@@ -10861,58 +10969,22 @@ var sliderStopsContainerVariants = cva([
10861
10969
  "items-center",
10862
10970
  "justify-between",
10863
10971
  "px-[4px]",
10864
- // NOTE: measurement-derived value from MD3 spec §10.5 (stopPadding: 4dp); permitted exception
10865
10972
  "pointer-events-none",
10866
- "z-0"
10973
+ "z-10"
10867
10974
  ]);
10868
- var sliderStopDotVariants = cva(
10869
- [
10870
- "rounded-full",
10871
- "flex-shrink-0",
10872
- "w-[4px]",
10873
- // NOTE: measurement-derived value from MD3 spec §10.5 (stopIndicatorSize: 4dp); permitted exception
10874
- "h-[4px]"
10875
- ],
10876
- {
10877
- variants: {
10878
- /**
10879
- * Whether this dot is positioned on the active track portion.
10880
- * Determines the dot color per MD3 spec §5.2.
10881
- */
10882
- onActiveTrack: {
10883
- true: "bg-on-primary",
10884
- // Light dots on primary background
10885
- false: "bg-on-secondary-container"
10886
- // Dark dots on secondary-container background
10887
- },
10888
- disabled: {
10889
- true: "opacity-38",
10890
- false: ""
10891
- }
10892
- },
10893
- defaultVariants: {
10894
- onActiveTrack: false,
10895
- disabled: false
10896
- }
10897
- }
10898
- );
10899
10975
  var sliderTrackStopVariants = cva(
10900
10976
  [
10901
10977
  "absolute",
10902
- "top-1/2",
10903
- "-translate-y-1/2",
10904
- "w-[4px]",
10905
- // NOTE: measurement-derived value from MD3 spec §10.6 (trackStopDiameter: 4dp); permitted exception
10906
- "h-[4px]",
10907
10978
  "rounded-full",
10908
10979
  "bg-on-secondary-container",
10909
- "pointer-events-none"
10980
+ "pointer-events-none",
10981
+ "w-[4px]",
10982
+ "h-[4px]"
10910
10983
  ],
10911
10984
  {
10912
10985
  variants: {
10913
10986
  position: {
10914
10987
  start: "left-[4px]",
10915
- // NOTE: measurement-derived (trackStopOffset: 4dp); permitted exception
10916
10988
  end: "right-[4px]"
10917
10989
  }
10918
10990
  },
@@ -10921,64 +10993,23 @@ var sliderTrackStopVariants = cva(
10921
10993
  }
10922
10994
  }
10923
10995
  );
10924
- var sliderValueIndicatorVariants = cva(
10925
- [
10926
- "absolute",
10927
- "left-1/2",
10928
- "-translate-x-1/2",
10929
- "bottom-[calc(100%+4px)]",
10930
- // NOTE: measurement-derived (4dp gap above handle); permitted exception
10931
- "bg-inverse-surface",
10932
- "rounded-full",
10933
- // pill shape (1000dp radius)
10934
- "px-[16px]",
10935
- // NOTE: measurement-derived (valueIndicatorPaddingH: 16dp); permitted exception
10936
- "py-[12px]",
10937
- // NOTE: measurement-derived (valueIndicatorPaddingV: 12dp); permitted exception
10938
- "min-w-[48px]",
10939
- // NOTE: measurement-derived (valueIndicatorWidth: 48dp); permitted exception
10940
- "flex",
10941
- "items-center",
10942
- "justify-center",
10943
- "pointer-events-none",
10944
- "z-20"
10945
- // Motion classes (transition-[transform,opacity] with directional easing) applied
10946
- // conditionally in SliderValueIndicator.tsx via useReducedMotion guard.
10947
- ],
10948
- {
10949
- variants: {
10950
- visible: {
10951
- true: "opacity-100 scale-100",
10952
- false: "opacity-0 scale-0"
10953
- }
10954
- },
10955
- defaultVariants: {
10956
- visible: false
10957
- }
10958
- }
10959
- );
10960
10996
  var sliderValueIndicatorTextVariants = cva([
10961
10997
  "text-inverse-on-surface",
10962
10998
  "text-label-large",
10963
- // MD3 Label Large typescale token
10964
- "whitespace-nowrap",
10965
- "text-center"
10999
+ "select-none",
11000
+ "whitespace-nowrap"
10966
11001
  ]);
10967
11002
  var sliderInsetIconVariants = cva(
10968
11003
  ["absolute", "text-on-primary", "pointer-events-none", "flex", "items-center", "justify-center"],
10969
11004
  {
10970
11005
  variants: {
10971
11006
  size: {
10972
- // NOTE: measurement-derived values from MD3 spec §10.7 (icon sizes); permitted exception
10973
11007
  medium: "w-[24px] h-[24px]",
10974
11008
  large: "w-[24px] h-[24px]",
10975
11009
  xlarge: "w-[32px] h-[32px]"
10976
11010
  },
10977
11011
  orientation: {
10978
- // Horizontal: 8dp from active track left edge, vertically centered
10979
- // NOTE: measurement-derived value from MD3 spec §10.7 (iconOffset: 8dp); permitted exception
10980
11012
  horizontal: "left-[8px] top-1/2 -translate-y-1/2",
10981
- // Vertical: 8dp from active track bottom edge (outer end), horizontally centered
10982
11013
  vertical: "bottom-[8px] left-1/2 -translate-x-1/2"
10983
11014
  }
10984
11015
  },
@@ -11009,7 +11040,7 @@ function SliderStops({
11009
11040
  step,
11010
11041
  values,
11011
11042
  variant,
11012
- isDisabled,
11043
+ size = "xsmall",
11013
11044
  className
11014
11045
  }) {
11015
11046
  const stopCount = Math.floor((maxValue - minValue) / step) + 1;
@@ -11027,7 +11058,10 @@ function SliderStops({
11027
11058
  {
11028
11059
  "data-slot": "stop-dot",
11029
11060
  className: cn(
11030
- sliderStopDotVariants({ onActiveTrack: isOnActive, disabled: isDisabled })
11061
+ sliderStopDotVariants({
11062
+ region: isOnActive ? "active" : "inactive",
11063
+ size
11064
+ })
11031
11065
  )
11032
11066
  },
11033
11067
  i
@@ -11038,27 +11072,19 @@ function SliderStops({
11038
11072
  }
11039
11073
  function SliderValueIndicator({
11040
11074
  value,
11041
- isVisible,
11042
11075
  formatValue: formatValue2,
11043
11076
  className
11044
11077
  }) {
11045
11078
  const displayValue = formatValue2 ? formatValue2(value) : `${Math.round(value)}`;
11046
11079
  const reducedMotion = useReducedMotion();
11047
- const transitionClasses = reducedMotion ? "" : cn(
11048
- "transition-[transform,opacity]",
11049
- isVisible ? "duration-short3 ease-standard-decelerate" : "duration-short2 ease-standard-accelerate"
11050
- );
11080
+ const transitionClasses = reducedMotion ? "" : "transition-[scale,opacity] duration-spring-standard-fast-spatial ease-spring-standard-fast-spatial";
11051
11081
  return /* @__PURE__ */ jsx(
11052
11082
  "div",
11053
11083
  {
11054
11084
  "data-slot": "value-indicator",
11055
- className: cn(
11056
- sliderValueIndicatorVariants({ visible: isVisible }),
11057
- transitionClasses,
11058
- className
11059
- ),
11085
+ className: cn(sliderValueIndicatorVariants(), transitionClasses, className),
11060
11086
  role: "tooltip",
11061
- "aria-hidden": !isVisible,
11087
+ "aria-hidden": "true",
11062
11088
  children: /* @__PURE__ */ jsx("span", { className: sliderValueIndicatorTextVariants(), children: displayValue })
11063
11089
  }
11064
11090
  );
@@ -11071,6 +11097,16 @@ function resolveDefaultValue(variant, minValue) {
11071
11097
  if (variant === "centered") return [0];
11072
11098
  return [minValue];
11073
11099
  }
11100
+ var GAP_PX = 3;
11101
+ function segmentStyle(orientation, opts) {
11102
+ const { start, end, startGap = 0, endGap = 0 } = opts;
11103
+ const startVal = start !== null ? `calc(${start}% + ${startGap}px)` : `${startGap}px`;
11104
+ const endVal = end !== null ? `calc(${100 - end}% + ${endGap}px)` : `${endGap}px`;
11105
+ if (orientation === "horizontal") {
11106
+ return { left: startVal, right: endVal };
11107
+ }
11108
+ return { bottom: startVal, top: endVal };
11109
+ }
11074
11110
  var Slider = forwardRef(
11075
11111
  ({
11076
11112
  size = "xsmall",
@@ -11104,103 +11140,75 @@ var Slider = forwardRef(
11104
11140
  },
11105
11141
  [value, onChange]
11106
11142
  );
11107
- const thumbCount = variant === "range" ? 2 : 1;
11108
- const [thumbStates, setThumbStates] = useState(
11109
- () => Array(thumbCount).fill("enabled")
11110
- );
11111
- const isDragging = thumbStates.some((s) => s === "pressed");
11112
- const trackTransition = reducedMotion || isDragging ? "" : "transition-[flex-basis] duration-spring-standard-fast-spatial ease-spring-standard-fast-spatial";
11113
- const handleMotion = reducedMotion ? "" : "transition-[width] duration-short2 ease-standard";
11114
- const stateLayerMotion = reducedMotion ? "" : "transition-opacity duration-short1 ease-standard";
11143
+ const [anyThumbDragging, setAnyThumbDragging] = useState(false);
11144
+ const handleThumbDraggingChange = useCallback((_index, isDragging) => {
11145
+ setAnyThumbDragging(isDragging);
11146
+ }, []);
11147
+ const springTokens = "duration-spring-standard-fast-spatial ease-spring-standard-fast-spatial";
11148
+ const trackTransition = reducedMotion || anyThumbDragging ? "" : orientation === "vertical" ? `transition-[top,bottom,height] ${springTokens}` : `transition-[left,width,right] ${springTokens}`;
11149
+ const handleMotion = reducedMotion ? "" : "transition-[width] duration-spring-standard-fast-spatial ease-spring-standard-fast-spatial";
11115
11150
  const isRange = variant === "range";
11116
11151
  const isCentered = variant === "centered";
11117
11152
  const showIcon = icon !== void 0 && variant === "standard" && (size === "medium" || size === "large" || size === "xlarge");
11153
+ const renderThumbContent = useCallback(
11154
+ ({ value: thumbValue }) => /* @__PURE__ */ jsxs(Fragment, { children: [
11155
+ /* @__PURE__ */ jsx(
11156
+ "div",
11157
+ {
11158
+ "aria-hidden": "true",
11159
+ className: cn(
11160
+ "absolute",
11161
+ "left-1/2",
11162
+ "top-1/2",
11163
+ "-translate-x-1/2",
11164
+ "-translate-y-1/2",
11165
+ orientation === "vertical" ? "h-[20px] w-full" : "h-full w-[20px]"
11166
+ )
11167
+ }
11168
+ ),
11169
+ /* @__PURE__ */ jsx(
11170
+ "div",
11171
+ {
11172
+ "data-slot": "handle",
11173
+ className: cn(sliderHandleVariants({ size, orientation }), handleMotion)
11174
+ }
11175
+ ),
11176
+ /* @__PURE__ */ jsx("div", { "data-slot": "state-layer", className: cn(sliderHandleStateLayerVariants()) }),
11177
+ showValueIndicator && /* @__PURE__ */ jsx(
11178
+ SliderValueIndicator,
11179
+ {
11180
+ value: thumbValue,
11181
+ ...formatValue2 !== void 0 ? { formatValue: formatValue2 } : {}
11182
+ }
11183
+ )
11184
+ ] }),
11185
+ [size, orientation, showValueIndicator, formatValue2, handleMotion]
11186
+ );
11118
11187
  const renderStandardTrack = () => {
11119
11188
  const pct = clampPercent(currentValues[0] ?? minValue, minValue, maxValue);
11120
- const thumb0State = isDisabled ? "disabled" : thumbStates[0] ?? "enabled";
11121
11189
  return /* @__PURE__ */ jsxs(Fragment, { children: [
11122
11190
  /* @__PURE__ */ jsx(
11123
11191
  "div",
11124
11192
  {
11125
11193
  "data-slot": "active-track",
11126
- className: cn(
11127
- sliderActiveTrackVariants({ size, disabled: isDisabled, orientation }),
11128
- trackTransition
11129
- ),
11130
- style: { flexBasis: `${pct}%` },
11194
+ className: cn(sliderActiveTrackVariants({ size, orientation }), trackTransition),
11195
+ style: segmentStyle(orientation, { start: null, end: pct, endGap: GAP_PX }),
11131
11196
  children: showIcon && /* @__PURE__ */ jsx(
11132
11197
  "span",
11133
11198
  {
11134
11199
  "data-slot": "inset-icon",
11135
- className: cn(
11136
- sliderInsetIconVariants({
11137
- size,
11138
- orientation
11139
- })
11140
- ),
11200
+ className: cn(sliderInsetIconVariants({ size, orientation })),
11141
11201
  children: icon
11142
11202
  }
11143
11203
  )
11144
11204
  }
11145
11205
  ),
11146
- /* @__PURE__ */ jsxs(
11147
- "div",
11148
- {
11149
- "data-slot": "handle",
11150
- className: cn(
11151
- sliderHandleVariants({
11152
- size,
11153
- disabled: isDisabled,
11154
- pressed: thumb0State === "pressed",
11155
- orientation
11156
- }),
11157
- handleMotion
11158
- ),
11159
- onPointerEnter: () => {
11160
- if (!isDisabled) setThumbStates(["hovered"]);
11161
- },
11162
- onPointerLeave: () => {
11163
- if (!isDisabled) setThumbStates(["enabled"]);
11164
- },
11165
- onPointerDown: (e) => {
11166
- e.stopPropagation();
11167
- if (!isDisabled) setThumbStates(["pressed"]);
11168
- },
11169
- onPointerUp: (e) => {
11170
- e.stopPropagation();
11171
- if (!isDisabled) setThumbStates(["enabled"]);
11172
- },
11173
- children: [
11174
- /* @__PURE__ */ jsx(
11175
- "div",
11176
- {
11177
- "data-slot": "state-layer",
11178
- className: cn(
11179
- sliderHandleStateLayerVariants({ state: thumb0State }),
11180
- stateLayerMotion
11181
- )
11182
- }
11183
- ),
11184
- showValueIndicator && /* @__PURE__ */ jsx(
11185
- SliderValueIndicator,
11186
- {
11187
- value: currentValues[0] ?? minValue,
11188
- isVisible: thumb0State === "pressed",
11189
- ...formatValue2 !== void 0 ? { formatValue: formatValue2 } : {}
11190
- }
11191
- )
11192
- ]
11193
- }
11194
- ),
11195
11206
  /* @__PURE__ */ jsx(
11196
11207
  "div",
11197
11208
  {
11198
11209
  "data-slot": "inactive-track",
11199
- className: cn(
11200
- sliderInactiveTrackVariants({ size, disabled: isDisabled, orientation }),
11201
- trackTransition
11202
- ),
11203
- style: { flexBasis: `${100 - pct}%` },
11210
+ className: cn(sliderInactiveTrackVariants({ size, orientation }), trackTransition),
11211
+ style: segmentStyle(orientation, { start: pct, startGap: GAP_PX, end: null }),
11204
11212
  children: showStops && /* @__PURE__ */ jsx(
11205
11213
  "span",
11206
11214
  {
@@ -11215,20 +11223,13 @@ var Slider = forwardRef(
11215
11223
  const renderRangeTrack = () => {
11216
11224
  const leftPct = clampPercent(currentValues[0] ?? minValue, minValue, maxValue);
11217
11225
  const rightPct = clampPercent(currentValues[1] ?? maxValue, minValue, maxValue);
11218
- const thumb0State = isDisabled ? "disabled" : thumbStates[0] ?? "enabled";
11219
- const thumb1State = isDisabled ? "disabled" : thumbStates[1] ?? "enabled";
11220
- const setThumb0 = (next) => setThumbStates((s) => [next, s[1] ?? "enabled"]);
11221
- const setThumb1 = (next) => setThumbStates((s) => [s[0] ?? "enabled", next]);
11222
11226
  return /* @__PURE__ */ jsxs(Fragment, { children: [
11223
11227
  /* @__PURE__ */ jsx(
11224
11228
  "div",
11225
11229
  {
11226
11230
  "data-slot": "inactive-track-left",
11227
- className: cn(
11228
- sliderInactiveTrackVariants({ size, disabled: isDisabled, orientation }),
11229
- trackTransition
11230
- ),
11231
- style: { flexBasis: `${leftPct}%` },
11231
+ className: cn(sliderInactiveTrackVariants({ size, orientation }), trackTransition),
11232
+ style: segmentStyle(orientation, { start: null, end: leftPct, endGap: GAP_PX }),
11232
11233
  children: showStops && /* @__PURE__ */ jsx(
11233
11234
  "span",
11234
11235
  {
@@ -11238,128 +11239,30 @@ var Slider = forwardRef(
11238
11239
  )
11239
11240
  }
11240
11241
  ),
11241
- /* @__PURE__ */ jsxs(
11242
- "div",
11243
- {
11244
- "data-slot": "handle",
11245
- "data-index": "0",
11246
- className: cn(
11247
- sliderHandleVariants({
11248
- size,
11249
- disabled: isDisabled,
11250
- pressed: thumb0State === "pressed",
11251
- orientation
11252
- }),
11253
- handleMotion
11254
- ),
11255
- onPointerEnter: () => {
11256
- if (!isDisabled) setThumb0("hovered");
11257
- },
11258
- onPointerLeave: () => {
11259
- if (!isDisabled) setThumb0("enabled");
11260
- },
11261
- onPointerDown: (e) => {
11262
- e.stopPropagation();
11263
- if (!isDisabled) setThumb0("pressed");
11264
- },
11265
- onPointerUp: (e) => {
11266
- e.stopPropagation();
11267
- if (!isDisabled) setThumb0("enabled");
11268
- },
11269
- children: [
11270
- /* @__PURE__ */ jsx(
11271
- "div",
11272
- {
11273
- "data-slot": "state-layer",
11274
- className: cn(
11275
- sliderHandleStateLayerVariants({ state: thumb0State }),
11276
- stateLayerMotion
11277
- )
11278
- }
11279
- ),
11280
- showValueIndicator && /* @__PURE__ */ jsx(
11281
- SliderValueIndicator,
11282
- {
11283
- value: currentValues[0] ?? minValue,
11284
- isVisible: thumb0State === "pressed",
11285
- ...formatValue2 !== void 0 ? { formatValue: formatValue2 } : {}
11286
- }
11287
- )
11288
- ]
11289
- }
11290
- ),
11291
11242
  /* @__PURE__ */ jsx(
11292
11243
  "div",
11293
11244
  {
11294
11245
  "data-slot": "active-track",
11295
11246
  className: cn(
11296
- sliderActiveTrackVariants({ size, disabled: isDisabled, orientation }),
11247
+ sliderActiveTrackVariants({ size, orientation }),
11297
11248
  "rounded-[2px]",
11298
- // Both ends near handles: 2dp (MD3 §10.2)
11249
+ // Both ends near handles: 2dp inner (MD3 §10.2)
11299
11250
  trackTransition
11300
11251
  ),
11301
- style: { flexBasis: `${rightPct - leftPct}%` }
11302
- }
11303
- ),
11304
- /* @__PURE__ */ jsxs(
11305
- "div",
11306
- {
11307
- "data-slot": "handle",
11308
- "data-index": "1",
11309
- className: cn(
11310
- sliderHandleVariants({
11311
- size,
11312
- disabled: isDisabled,
11313
- pressed: thumb1State === "pressed",
11314
- orientation
11315
- }),
11316
- handleMotion
11317
- ),
11318
- onPointerEnter: () => {
11319
- if (!isDisabled) setThumb1("hovered");
11320
- },
11321
- onPointerLeave: () => {
11322
- if (!isDisabled) setThumb1("enabled");
11323
- },
11324
- onPointerDown: (e) => {
11325
- e.stopPropagation();
11326
- if (!isDisabled) setThumb1("pressed");
11327
- },
11328
- onPointerUp: (e) => {
11329
- e.stopPropagation();
11330
- if (!isDisabled) setThumb1("enabled");
11331
- },
11332
- children: [
11333
- /* @__PURE__ */ jsx(
11334
- "div",
11335
- {
11336
- "data-slot": "state-layer",
11337
- className: cn(
11338
- sliderHandleStateLayerVariants({ state: thumb1State }),
11339
- stateLayerMotion
11340
- )
11341
- }
11342
- ),
11343
- showValueIndicator && /* @__PURE__ */ jsx(
11344
- SliderValueIndicator,
11345
- {
11346
- value: currentValues[1] ?? maxValue,
11347
- isVisible: thumb1State === "pressed",
11348
- ...formatValue2 !== void 0 ? { formatValue: formatValue2 } : {}
11349
- }
11350
- )
11351
- ]
11252
+ style: segmentStyle(orientation, {
11253
+ start: leftPct,
11254
+ startGap: GAP_PX,
11255
+ end: rightPct,
11256
+ endGap: GAP_PX
11257
+ })
11352
11258
  }
11353
11259
  ),
11354
11260
  /* @__PURE__ */ jsx(
11355
11261
  "div",
11356
11262
  {
11357
11263
  "data-slot": "inactive-track-right",
11358
- className: cn(
11359
- sliderInactiveTrackVariants({ size, disabled: isDisabled, orientation }),
11360
- trackTransition
11361
- ),
11362
- style: { flexBasis: `${100 - rightPct}%` },
11264
+ className: cn(sliderInactiveTrackVariants({ size, orientation }), trackTransition),
11265
+ style: segmentStyle(orientation, { start: rightPct, startGap: GAP_PX, end: null }),
11363
11266
  children: showStops && /* @__PURE__ */ jsx(
11364
11267
  "span",
11365
11268
  {
@@ -11374,126 +11277,65 @@ var Slider = forwardRef(
11374
11277
  const renderCenteredTrack = () => {
11375
11278
  const thumbPct = clampPercent(currentValues[0] ?? minValue, minValue, maxValue);
11376
11279
  const zeroPct = minValue >= 0 ? 0 : maxValue <= 0 ? 100 : (0 - minValue) / (maxValue - minValue) * 100;
11377
- const thumb0State = isDisabled ? "disabled" : thumbStates[0] ?? "enabled";
11378
- const handleEl = /* @__PURE__ */ jsxs(
11379
- "div",
11380
- {
11381
- "data-slot": "handle",
11382
- className: cn(
11383
- sliderHandleVariants({
11384
- size,
11385
- disabled: isDisabled,
11386
- pressed: thumb0State === "pressed",
11387
- orientation
11388
- }),
11389
- handleMotion
11390
- ),
11391
- onPointerEnter: () => {
11392
- if (!isDisabled) setThumbStates(["hovered"]);
11393
- },
11394
- onPointerLeave: () => {
11395
- if (!isDisabled) setThumbStates(["enabled"]);
11396
- },
11397
- onPointerDown: (e) => {
11398
- e.stopPropagation();
11399
- if (!isDisabled) setThumbStates(["pressed"]);
11400
- },
11401
- onPointerUp: (e) => {
11402
- e.stopPropagation();
11403
- if (!isDisabled) setThumbStates(["enabled"]);
11404
- },
11405
- children: [
11406
- /* @__PURE__ */ jsx(
11407
- "div",
11408
- {
11409
- "data-slot": "state-layer",
11410
- className: cn(sliderHandleStateLayerVariants({ state: thumb0State }), stateLayerMotion)
11411
- }
11412
- ),
11413
- showValueIndicator && /* @__PURE__ */ jsx(
11414
- SliderValueIndicator,
11415
- {
11416
- value: currentValues[0] ?? minValue,
11417
- isVisible: thumb0State === "pressed",
11418
- ...formatValue2 !== void 0 ? { formatValue: formatValue2 } : {}
11419
- }
11420
- )
11421
- ]
11422
- }
11423
- );
11424
11280
  if (thumbPct >= zeroPct) {
11425
- const activePct = thumbPct - zeroPct;
11426
11281
  return /* @__PURE__ */ jsxs(Fragment, { children: [
11427
11282
  /* @__PURE__ */ jsx(
11428
11283
  "div",
11429
11284
  {
11430
11285
  "data-slot": "inactive-track-left",
11431
- className: cn(
11432
- sliderInactiveTrackVariants({ size, disabled: isDisabled, orientation }),
11433
- trackTransition
11434
- ),
11435
- style: { flexBasis: `${zeroPct}%` }
11286
+ className: cn(sliderInactiveTrackVariants({ size, orientation }), trackTransition),
11287
+ style: segmentStyle(orientation, { start: null, end: zeroPct })
11436
11288
  }
11437
11289
  ),
11438
- handleEl,
11439
11290
  /* @__PURE__ */ jsx(
11440
11291
  "div",
11441
11292
  {
11442
11293
  "data-slot": "active-track",
11443
- className: cn(
11444
- sliderActiveTrackVariants({ size, disabled: isDisabled, orientation }),
11445
- trackTransition
11446
- ),
11447
- style: { flexBasis: `${activePct}%` }
11294
+ className: cn(sliderActiveTrackVariants({ size, orientation }), trackTransition),
11295
+ style: segmentStyle(orientation, {
11296
+ start: zeroPct,
11297
+ end: thumbPct,
11298
+ endGap: GAP_PX
11299
+ })
11448
11300
  }
11449
11301
  ),
11450
11302
  /* @__PURE__ */ jsx(
11451
11303
  "div",
11452
11304
  {
11453
11305
  "data-slot": "inactive-track-right",
11454
- className: cn(
11455
- sliderInactiveTrackVariants({ size, disabled: isDisabled, orientation }),
11456
- trackTransition
11457
- ),
11458
- style: { flexBasis: `${100 - zeroPct - activePct}%` }
11306
+ className: cn(sliderInactiveTrackVariants({ size, orientation }), trackTransition),
11307
+ style: segmentStyle(orientation, { start: thumbPct, startGap: GAP_PX, end: null })
11459
11308
  }
11460
11309
  )
11461
11310
  ] });
11462
11311
  } else {
11463
- const activePct = zeroPct - thumbPct;
11464
11312
  return /* @__PURE__ */ jsxs(Fragment, { children: [
11465
11313
  /* @__PURE__ */ jsx(
11466
11314
  "div",
11467
11315
  {
11468
11316
  "data-slot": "inactive-track-left",
11469
- className: cn(
11470
- sliderInactiveTrackVariants({ size, disabled: isDisabled, orientation }),
11471
- trackTransition
11472
- ),
11473
- style: { flexBasis: `${thumbPct}%` }
11317
+ className: cn(sliderInactiveTrackVariants({ size, orientation }), trackTransition),
11318
+ style: segmentStyle(orientation, { start: null, end: thumbPct, endGap: GAP_PX })
11474
11319
  }
11475
11320
  ),
11476
11321
  /* @__PURE__ */ jsx(
11477
11322
  "div",
11478
11323
  {
11479
11324
  "data-slot": "active-track",
11480
- className: cn(
11481
- sliderActiveTrackVariants({ size, disabled: isDisabled, orientation }),
11482
- trackTransition
11483
- ),
11484
- style: { flexBasis: `${activePct}%` }
11325
+ className: cn(sliderActiveTrackVariants({ size, orientation }), trackTransition),
11326
+ style: segmentStyle(orientation, {
11327
+ start: thumbPct,
11328
+ startGap: GAP_PX,
11329
+ end: zeroPct
11330
+ })
11485
11331
  }
11486
11332
  ),
11487
- handleEl,
11488
11333
  /* @__PURE__ */ jsx(
11489
11334
  "div",
11490
11335
  {
11491
11336
  "data-slot": "inactive-track-right",
11492
- className: cn(
11493
- sliderInactiveTrackVariants({ size, disabled: isDisabled, orientation }),
11494
- trackTransition
11495
- ),
11496
- style: { flexBasis: `${100 - zeroPct}%` }
11337
+ className: cn(sliderInactiveTrackVariants({ size, orientation }), trackTransition),
11338
+ style: segmentStyle(orientation, { start: zeroPct, end: null })
11497
11339
  }
11498
11340
  )
11499
11341
  ] });
@@ -11516,11 +11358,11 @@ var Slider = forwardRef(
11516
11358
  ...value !== void 0 ? { value } : {},
11517
11359
  ...defaultValue !== void 0 ? { defaultValue } : {},
11518
11360
  ...onChangeEnd !== void 0 ? { onChangeEnd } : {},
11519
- className: cn(
11520
- sliderContainerVariants({ size, disabled: isDisabled, orientation }),
11521
- className
11522
- ),
11523
- children: /* @__PURE__ */ jsxs("div", { "data-slot": "track-layout", className: cn(sliderTrackLayoutVariants({ orientation })), children: [
11361
+ renderThumbContent,
11362
+ onThumbDraggingChange: handleThumbDraggingChange,
11363
+ className: cn(sliderContainerVariants({ size, orientation }), className),
11364
+ trackClassName: sliderTrackRegionVariants({ size, orientation }),
11365
+ children: /* @__PURE__ */ jsxs("div", { "data-slot": "track-layout", className: cn(sliderTrackLayoutVariants()), children: [
11524
11366
  isRange ? renderRangeTrack() : isCentered ? renderCenteredTrack() : renderStandardTrack(),
11525
11367
  canShowStops && /* @__PURE__ */ jsx(
11526
11368
  SliderStops,
@@ -11530,7 +11372,7 @@ var Slider = forwardRef(
11530
11372
  step,
11531
11373
  values: currentValues,
11532
11374
  variant,
11533
- isDisabled
11375
+ size
11534
11376
  }
11535
11377
  )
11536
11378
  ] })