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