@octanejs/base-ui 0.1.31 → 0.1.32

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.
Files changed (201) hide show
  1. package/dist/cjs/accordion.cjs +497 -0
  2. package/dist/cjs/alert-dialog.cjs +65 -0
  3. package/dist/cjs/avatar.cjs +234 -0
  4. package/dist/cjs/button.cjs +54 -0
  5. package/dist/cjs/checkbox-group.cjs +165 -0
  6. package/dist/cjs/checkbox.cjs +475 -0
  7. package/dist/cjs/collapsible.cjs +700 -0
  8. package/dist/cjs/context-menu.cjs +257 -0
  9. package/dist/cjs/csp-provider.cjs +40 -0
  10. package/dist/cjs/dialog.cjs +741 -0
  11. package/dist/cjs/direction-provider.cjs +35 -0
  12. package/dist/cjs/field.cjs +559 -0
  13. package/dist/cjs/fieldset.cjs +101 -0
  14. package/dist/cjs/form.cjs +177 -0
  15. package/dist/cjs/index.cjs +133 -0
  16. package/dist/cjs/input.cjs +32 -0
  17. package/dist/cjs/internal.cjs +51 -0
  18. package/dist/cjs/menu.cjs +2420 -0
  19. package/dist/cjs/menubar.cjs +132 -0
  20. package/dist/cjs/merge-props.cjs +34 -0
  21. package/dist/cjs/meter.cjs +169 -0
  22. package/dist/cjs/number-field.cjs +812 -0
  23. package/dist/cjs/popover.cjs +966 -0
  24. package/dist/cjs/preview-card.cjs +632 -0
  25. package/dist/cjs/progress.cjs +206 -0
  26. package/dist/cjs/radio-group.cjs +264 -0
  27. package/dist/cjs/radio.cjs +327 -0
  28. package/dist/cjs/separator.cjs +44 -0
  29. package/dist/cjs/slider.cjs +1384 -0
  30. package/dist/cjs/switch.cjs +306 -0
  31. package/dist/cjs/tabs.cjs +727 -0
  32. package/dist/cjs/toast.cjs +1766 -0
  33. package/dist/cjs/toggle-group.cjs +118 -0
  34. package/dist/cjs/toggle.cjs +121 -0
  35. package/dist/cjs/tooltip.cjs +835 -0
  36. package/dist/cjs/unstable-use-media-query.cjs +79 -0
  37. package/dist/cjs/use-render.cjs +40 -0
  38. package/dist/cjs/utils/CSPContext.cjs +38 -0
  39. package/dist/cjs/utils/CheckboxGroupContext.cjs +40 -0
  40. package/dist/cjs/utils/CompositeRootContext.cjs +40 -0
  41. package/dist/cjs/utils/ContextMenuRootContext.cjs +42 -0
  42. package/dist/cjs/utils/DirectionContext.cjs +34 -0
  43. package/dist/cjs/utils/FloatingPortalLite.cjs +47 -0
  44. package/dist/cjs/utils/InternalBackdrop.cjs +49 -0
  45. package/dist/cjs/utils/MenubarContext.cjs +40 -0
  46. package/dist/cjs/utils/RadioGroupContext.cjs +34 -0
  47. package/dist/cjs/utils/RequestQueue.cjs +111 -0
  48. package/dist/cjs/utils/TimeoutManager.cjs +50 -0
  49. package/dist/cjs/utils/ToggleGroupContext.cjs +40 -0
  50. package/dist/cjs/utils/adaptiveOriginMiddleware.cjs +94 -0
  51. package/dist/cjs/utils/addEventListener.cjs +33 -0
  52. package/dist/cjs/utils/areArraysEqual.cjs +30 -0
  53. package/dist/cjs/utils/clamp.cjs +30 -0
  54. package/dist/cjs/utils/closePart.cjs +70 -0
  55. package/dist/cjs/utils/collapsibleOpenStateMapping.cjs +42 -0
  56. package/dist/cjs/utils/composeRefs.cjs +68 -0
  57. package/dist/cjs/utils/composite/CompositeItem.cjs +59 -0
  58. package/dist/cjs/utils/composite/CompositeList.cjs +177 -0
  59. package/dist/cjs/utils/composite/CompositeListContext.cjs +43 -0
  60. package/dist/cjs/utils/composite/CompositeRoot.cjs +118 -0
  61. package/dist/cjs/utils/composite/grid-utils.cjs +343 -0
  62. package/dist/cjs/utils/composite/gridNavigation.cjs +92 -0
  63. package/dist/cjs/utils/composite/keys.cjs +174 -0
  64. package/dist/cjs/utils/composite/list-utils.cjs +90 -0
  65. package/dist/cjs/utils/composite/useCompositeItem.cjs +63 -0
  66. package/dist/cjs/utils/composite/useCompositeListItem.cjs +104 -0
  67. package/dist/cjs/utils/composite/useCompositeRoot.cjs +263 -0
  68. package/dist/cjs/utils/constants.cjs +56 -0
  69. package/dist/cjs/utils/contains.cjs +46 -0
  70. package/dist/cjs/utils/createChangeEventDetails.cjs +92 -0
  71. package/dist/cjs/utils/dom.cjs +35 -0
  72. package/dist/cjs/utils/empty.cjs +34 -0
  73. package/dist/cjs/utils/field/FieldItemContext.cjs +34 -0
  74. package/dist/cjs/utils/field/FieldRootContext.cjs +80 -0
  75. package/dist/cjs/utils/field/FormContext.cjs +41 -0
  76. package/dist/cjs/utils/field/LabelableContext.cjs +43 -0
  77. package/dist/cjs/utils/field/LabelableProvider.cjs +115 -0
  78. package/dist/cjs/utils/field/constants.cjs +68 -0
  79. package/dist/cjs/utils/field/getCombinedFieldValidityData.cjs +36 -0
  80. package/dist/cjs/utils/field/useAriaLabelledBy.cjs +87 -0
  81. package/dist/cjs/utils/field/useFieldControlRegistration.cjs +165 -0
  82. package/dist/cjs/utils/field/useFieldValidation.cjs +285 -0
  83. package/dist/cjs/utils/field/useLabel.cjs +99 -0
  84. package/dist/cjs/utils/field/useLabelableId.cjs +105 -0
  85. package/dist/cjs/utils/field/useRegisterFieldControl.cjs +60 -0
  86. package/dist/cjs/utils/findRootOwnerId.cjs +37 -0
  87. package/dist/cjs/utils/floating/FloatingDelayGroup.cjs +219 -0
  88. package/dist/cjs/utils/floating/FloatingFocusManager.cjs +685 -0
  89. package/dist/cjs/utils/floating/FloatingPortal.cjs +230 -0
  90. package/dist/cjs/utils/floating/FloatingRootStore.cjs +87 -0
  91. package/dist/cjs/utils/floating/FloatingTree.cjs +86 -0
  92. package/dist/cjs/utils/floating/FloatingTreeStore.cjs +41 -0
  93. package/dist/cjs/utils/floating/FocusGuard.cjs +54 -0
  94. package/dist/cjs/utils/floating/composite.cjs +42 -0
  95. package/dist/cjs/utils/floating/constants.cjs +34 -0
  96. package/dist/cjs/utils/floating/createAttribute.cjs +30 -0
  97. package/dist/cjs/utils/floating/createEventEmitter.cjs +44 -0
  98. package/dist/cjs/utils/floating/element.cjs +103 -0
  99. package/dist/cjs/utils/floating/enqueueFocus.cjs +51 -0
  100. package/dist/cjs/utils/floating/event.cjs +65 -0
  101. package/dist/cjs/utils/floating/getEmptyRootContext.cjs +42 -0
  102. package/dist/cjs/utils/floating/gridNavigation.cjs +45 -0
  103. package/dist/cjs/utils/floating/markOthers.cjs +181 -0
  104. package/dist/cjs/utils/floating/nodes.cjs +48 -0
  105. package/dist/cjs/utils/floating/safePolygon.cjs +301 -0
  106. package/dist/cjs/utils/floating/tabbable.cjs +242 -0
  107. package/dist/cjs/utils/floating/types.cjs +16 -0
  108. package/dist/cjs/utils/floating/useClick.cjs +153 -0
  109. package/dist/cjs/utils/floating/useClientPoint.cjs +225 -0
  110. package/dist/cjs/utils/floating/useDismiss.cjs +506 -0
  111. package/dist/cjs/utils/floating/useFloating.cjs +186 -0
  112. package/dist/cjs/utils/floating/useFloatingRootContext.cjs +75 -0
  113. package/dist/cjs/utils/floating/useFocus.cjs +184 -0
  114. package/dist/cjs/utils/floating/useHoverFloatingInteraction.cjs +231 -0
  115. package/dist/cjs/utils/floating/useHoverInteractionSharedState.cjs +113 -0
  116. package/dist/cjs/utils/floating/useHoverReferenceInteraction.cjs +380 -0
  117. package/dist/cjs/utils/floating/useHoverShared.cjs +65 -0
  118. package/dist/cjs/utils/floating/useListNavigation.cjs +665 -0
  119. package/dist/cjs/utils/floating/useSyncedFloatingRootContext.cjs +91 -0
  120. package/dist/cjs/utils/floating/useTypeahead.cjs +187 -0
  121. package/dist/cjs/utils/formatNumber.cjs +60 -0
  122. package/dist/cjs/utils/generateId.cjs +32 -0
  123. package/dist/cjs/utils/getCssDimensions.cjs +42 -0
  124. package/dist/cjs/utils/getDefaultFormSubmitter.cjs +42 -0
  125. package/dist/cjs/utils/getDisabledMountTransitionStyles.cjs +32 -0
  126. package/dist/cjs/utils/getElementRef.cjs +35 -0
  127. package/dist/cjs/utils/getPseudoElementBounds.cjs +56 -0
  128. package/dist/cjs/utils/getStateAttributesProps.cjs +46 -0
  129. package/dist/cjs/utils/hideMiddleware.cjs +42 -0
  130. package/dist/cjs/utils/inertValue.cjs +30 -0
  131. package/dist/cjs/utils/matchesFocusVisible.cjs +38 -0
  132. package/dist/cjs/utils/mergeCleanups.cjs +37 -0
  133. package/dist/cjs/utils/mergeObjects.cjs +39 -0
  134. package/dist/cjs/utils/mergeProps.cjs +182 -0
  135. package/dist/cjs/utils/noop.cjs +29 -0
  136. package/dist/cjs/utils/number/constants.cjs +34 -0
  137. package/dist/cjs/utils/number/parse.cjs +258 -0
  138. package/dist/cjs/utils/number/types.cjs +16 -0
  139. package/dist/cjs/utils/number/validate.cjs +104 -0
  140. package/dist/cjs/utils/owner.cjs +35 -0
  141. package/dist/cjs/utils/platform.cjs +83 -0
  142. package/dist/cjs/utils/popupStateMapping.cjs +74 -0
  143. package/dist/cjs/utils/popups/index.cjs +39 -0
  144. package/dist/cjs/utils/popups/inlineRect.cjs +218 -0
  145. package/dist/cjs/utils/popups/popupStoreUtils.cjs +379 -0
  146. package/dist/cjs/utils/popups/popupTriggerMap.cjs +76 -0
  147. package/dist/cjs/utils/popups/store.cjs +118 -0
  148. package/dist/cjs/utils/popups/useTriggerFocusGuards.cjs +72 -0
  149. package/dist/cjs/utils/resolveAriaLabelledBy.cjs +35 -0
  150. package/dist/cjs/utils/resolveClassName.cjs +30 -0
  151. package/dist/cjs/utils/resolveRef.cjs +33 -0
  152. package/dist/cjs/utils/resolveStyle.cjs +30 -0
  153. package/dist/cjs/utils/serializeValue.cjs +40 -0
  154. package/dist/cjs/utils/slider/asc.cjs +30 -0
  155. package/dist/cjs/utils/slider/getMidpoint.cjs +34 -0
  156. package/dist/cjs/utils/slider/getPushedThumbValues.cjs +73 -0
  157. package/dist/cjs/utils/slider/getSliderValue.cjs +42 -0
  158. package/dist/cjs/utils/slider/replaceArrayItemAtIndex.cjs +33 -0
  159. package/dist/cjs/utils/slider/resolveThumbCollision.cjs +155 -0
  160. package/dist/cjs/utils/slider/roundValueToStep.cjs +45 -0
  161. package/dist/cjs/utils/slider/validateMinimumDistance.cjs +40 -0
  162. package/dist/cjs/utils/slider/valueArrayToPercentages.cjs +36 -0
  163. package/dist/cjs/utils/store/ReactStore.cjs +135 -0
  164. package/dist/cjs/utils/store/Store.cjs +83 -0
  165. package/dist/cjs/utils/store/createSelector.cjs +74 -0
  166. package/dist/cjs/utils/store/useStore.cjs +51 -0
  167. package/dist/cjs/utils/stringifyLocale.cjs +36 -0
  168. package/dist/cjs/utils/useAnchorPositioning.cjs +421 -0
  169. package/dist/cjs/utils/useAnchoredPopupScrollLock.cjs +59 -0
  170. package/dist/cjs/utils/useAnimationFrame.cjs +93 -0
  171. package/dist/cjs/utils/useAnimationsFinished.cjs +98 -0
  172. package/dist/cjs/utils/useBaseUiId.cjs +36 -0
  173. package/dist/cjs/utils/useButton.cjs +177 -0
  174. package/dist/cjs/utils/useCheckboxGroupParent.cjs +114 -0
  175. package/dist/cjs/utils/useControlled.cjs +47 -0
  176. package/dist/cjs/utils/useEnhancedClickHandler.cjs +60 -0
  177. package/dist/cjs/utils/useFocusableWhenDisabled.cjs +77 -0
  178. package/dist/cjs/utils/useForcedRerendering.cjs +35 -0
  179. package/dist/cjs/utils/useIsHydrating.cjs +44 -0
  180. package/dist/cjs/utils/useMixedToggleClickHandler.cjs +66 -0
  181. package/dist/cjs/utils/useOnFirstRender.cjs +35 -0
  182. package/dist/cjs/utils/useOnMount.cjs +36 -0
  183. package/dist/cjs/utils/useOpenChangeComplete.cjs +57 -0
  184. package/dist/cjs/utils/useOpenInteractionType.cjs +69 -0
  185. package/dist/cjs/utils/usePopupAutoResize.cjs +191 -0
  186. package/dist/cjs/utils/usePopupViewport.cjs +283 -0
  187. package/dist/cjs/utils/usePositioner.cjs +53 -0
  188. package/dist/cjs/utils/usePressAndHold.cjs +51 -0
  189. package/dist/cjs/utils/usePreviousValue.cjs +47 -0
  190. package/dist/cjs/utils/useRefWithInit.cjs +41 -0
  191. package/dist/cjs/utils/useRegisteredLabelId.cjs +48 -0
  192. package/dist/cjs/utils/useRenderElement.cjs +106 -0
  193. package/dist/cjs/utils/useScrollLock.cjs +232 -0
  194. package/dist/cjs/utils/useStableCallback.cjs +41 -0
  195. package/dist/cjs/utils/useTimeout.cjs +66 -0
  196. package/dist/cjs/utils/useTransitionStatus.cjs +116 -0
  197. package/dist/cjs/utils/useValueAsRef.cjs +43 -0
  198. package/dist/cjs/utils/useValueChanged.cjs +55 -0
  199. package/dist/cjs/utils/valueToPercent.cjs +30 -0
  200. package/dist/cjs/utils/visuallyHidden.cjs +49 -0
  201. package/package.json +20 -8
@@ -0,0 +1,1384 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var slider_exports = {};
20
+ __export(slider_exports, {
21
+ Slider: () => Slider
22
+ });
23
+ module.exports = __toCommonJS(slider_exports);
24
+ var import_octane = require("octane");
25
+ var import_internal = require("./internal.cjs");
26
+ var import_useRenderElement = require("./utils/useRenderElement.cjs");
27
+ var import_mergeProps = require("./utils/mergeProps.cjs");
28
+ var import_composeRefs = require("./utils/composeRefs.cjs");
29
+ var import_useControlled = require("./utils/useControlled.cjs");
30
+ var import_useStableCallback = require("./utils/useStableCallback.cjs");
31
+ var import_useValueAsRef = require("./utils/useValueAsRef.cjs");
32
+ var import_useValueChanged = require("./utils/useValueChanged.cjs");
33
+ var import_useBaseUiId = require("./utils/useBaseUiId.cjs");
34
+ var import_useAnimationFrame = require("./utils/useAnimationFrame.cjs");
35
+ var import_clamp = require("./utils/clamp.cjs");
36
+ var import_areArraysEqual = require("./utils/areArraysEqual.cjs");
37
+ var import_contains = require("./utils/contains.cjs");
38
+ var import_addEventListener = require("./utils/addEventListener.cjs");
39
+ var import_owner = require("./utils/owner.cjs");
40
+ var import_visuallyHidden = require("./utils/visuallyHidden.cjs");
41
+ var import_valueToPercent = require("./utils/valueToPercent.cjs");
42
+ var import_formatNumber = require("./utils/formatNumber.cjs");
43
+ var import_matchesFocusVisible = require("./utils/matchesFocusVisible.cjs");
44
+ var import_useIsHydrating = require("./utils/useIsHydrating.cjs");
45
+ var import_list_utils = require("./utils/composite/list-utils.cjs");
46
+ var import_CompositeList = require("./utils/composite/CompositeList.cjs");
47
+ var import_useCompositeListItem = require("./utils/composite/useCompositeListItem.cjs");
48
+ var import_keys = require("./utils/composite/keys.cjs");
49
+ var import_DirectionContext = require("./utils/DirectionContext.cjs");
50
+ var import_constants = require("./utils/field/constants.cjs");
51
+ var import_FieldRootContext = require("./utils/field/FieldRootContext.cjs");
52
+ var import_FormContext = require("./utils/field/FormContext.cjs");
53
+ var import_LabelableContext = require("./utils/field/LabelableContext.cjs");
54
+ var import_useLabelableId = require("./utils/field/useLabelableId.cjs");
55
+ var import_useLabel = require("./utils/field/useLabel.cjs");
56
+ var import_useRegisterFieldControl = require("./utils/field/useRegisterFieldControl.cjs");
57
+ var import_createChangeEventDetails = require("./utils/createChangeEventDetails.cjs");
58
+ var import_asc = require("./utils/slider/asc.cjs");
59
+ var import_getSliderValue = require("./utils/slider/getSliderValue.cjs");
60
+ var import_getMidpoint = require("./utils/slider/getMidpoint.cjs");
61
+ var import_roundValueToStep = require("./utils/slider/roundValueToStep.cjs");
62
+ var import_validateMinimumDistance = require("./utils/slider/validateMinimumDistance.cjs");
63
+ var import_resolveThumbCollision = require("./utils/slider/resolveThumbCollision.cjs");
64
+ var import_resolveAriaLabelledBy = require("./utils/resolveAriaLabelledBy.cjs");
65
+ const ALL_KEYS = /* @__PURE__ */ new Set([...import_keys.COMPOSITE_KEYS, import_keys.PAGE_UP, import_keys.PAGE_DOWN]);
66
+ const INTENTIONAL_DRAG_COUNT_THRESHOLD = 2;
67
+ function isElementNode(target) {
68
+ return target != null && target instanceof Element;
69
+ }
70
+ function isHTMLElementNode(target) {
71
+ return target != null && target instanceof HTMLElement;
72
+ }
73
+ const sliderStateAttributesMapping = {
74
+ activeThumbIndex: () => null,
75
+ max: () => null,
76
+ min: () => null,
77
+ minStepsBetweenValues: () => null,
78
+ step: () => null,
79
+ values: () => null,
80
+ ...import_constants.fieldValidityMapping
81
+ };
82
+ const SliderRootContext = (0, import_octane.createContext)(void 0);
83
+ function useSliderRootContext() {
84
+ const context = (0, import_octane.useContext)(SliderRootContext);
85
+ if (context === void 0) {
86
+ throw new Error(
87
+ "Base UI: SliderRootContext is missing. Slider parts must be placed within <Slider.Root>."
88
+ );
89
+ }
90
+ return context;
91
+ }
92
+ function getSliderChangeEventReason(event) {
93
+ return "key" in event ? import_createChangeEventDetails.REASONS.keyboard : import_createChangeEventDetails.REASONS.inputChange;
94
+ }
95
+ function areValuesEqual(newValue, oldValue) {
96
+ if (typeof newValue === "number" && typeof oldValue === "number") {
97
+ return newValue === oldValue;
98
+ }
99
+ if (Array.isArray(newValue) && Array.isArray(oldValue)) {
100
+ return (0, import_areArraysEqual.areArraysEqual)(newValue, oldValue);
101
+ }
102
+ return false;
103
+ }
104
+ function SliderRoot(componentProps) {
105
+ const slot = (0, import_internal.S)("SliderRoot");
106
+ const {
107
+ "aria-labelledby": ariaLabelledByProp,
108
+ className,
109
+ defaultValue,
110
+ disabled: disabledProp = false,
111
+ id: idProp,
112
+ format,
113
+ largeStep = 10,
114
+ locale,
115
+ render,
116
+ max = 100,
117
+ min = 0,
118
+ minStepsBetweenValues = 0,
119
+ form,
120
+ name: nameProp,
121
+ onValueChange: onValueChangeProp,
122
+ onValueCommitted: onValueCommittedProp,
123
+ orientation = "horizontal",
124
+ step = 1,
125
+ thumbCollisionBehavior = "push",
126
+ thumbAlignment = "center",
127
+ value: valueProp,
128
+ style,
129
+ ref,
130
+ ...elementProps
131
+ } = componentProps;
132
+ const id = (0, import_useBaseUiId.useBaseUiId)(idProp, (0, import_internal.subSlot)(slot, "id"));
133
+ const defaultLabelId = (0, import_resolveAriaLabelledBy.getDefaultLabelId)(id);
134
+ const onValueChange = (0, import_useStableCallback.useStableCallback)(onValueChangeProp, (0, import_internal.subSlot)(slot, "onChange"));
135
+ const onValueCommitted = (0, import_useStableCallback.useStableCallback)(onValueCommittedProp, (0, import_internal.subSlot)(slot, "onCommit"));
136
+ const { clearErrors } = (0, import_FormContext.useFormContext)();
137
+ const {
138
+ state: fieldState,
139
+ disabled: fieldDisabled,
140
+ name: fieldName,
141
+ setTouched,
142
+ setDirty,
143
+ validityData,
144
+ validation
145
+ } = (0, import_FieldRootContext.useFieldRootContext)();
146
+ const { labelId: fieldLabelId } = (0, import_LabelableContext.useLabelableContext)();
147
+ const [labelId, setLabelId] = (0, import_octane.useState)(void 0, (0, import_internal.subSlot)(slot, "labelId"));
148
+ const ariaLabelledby = ariaLabelledByProp ?? (0, import_resolveAriaLabelledBy.resolveAriaLabelledBy)(fieldLabelId, labelId);
149
+ const disabled = fieldDisabled || disabledProp;
150
+ const name = fieldName ?? nameProp;
151
+ const [valueUnwrapped, setValueUnwrapped] = (0, import_useControlled.useControlled)(
152
+ { controlled: valueProp, default: defaultValue ?? min, name: "Slider" },
153
+ (0, import_internal.subSlot)(slot, "value")
154
+ );
155
+ const sliderRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "sliderRef"));
156
+ const controlRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "controlRef"));
157
+ const thumbRefs = (0, import_octane.useRef)([], (0, import_internal.subSlot)(slot, "thumbRefs"));
158
+ const pressedInputRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "pressedInput"));
159
+ const pressedThumbCenterOffsetRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "pressedOffset"));
160
+ const pressedThumbIndexRef = (0, import_octane.useRef)(-1, (0, import_internal.subSlot)(slot, "pressedIndex"));
161
+ const pressedValuesRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "pressedValues"));
162
+ const lastChangeReasonRef = (0, import_octane.useRef)("none", (0, import_internal.subSlot)(slot, "lastReason"));
163
+ const formatOptionsRef = (0, import_useValueAsRef.useValueAsRef)(
164
+ format,
165
+ (0, import_internal.subSlot)(slot, "fmtRef")
166
+ );
167
+ const [active, setActiveState] = (0, import_octane.useState)(-1, (0, import_internal.subSlot)(slot, "active"));
168
+ const [lastUsedThumbIndex, setLastUsedThumbIndex] = (0, import_octane.useState)(-1, (0, import_internal.subSlot)(slot, "lastUsed"));
169
+ const [dragging, setDragging] = (0, import_octane.useState)(false, (0, import_internal.subSlot)(slot, "dragging"));
170
+ const [thumbMap, setThumbMap] = (0, import_octane.useState)(() => /* @__PURE__ */ new Map(), (0, import_internal.subSlot)(slot, "thumbMap"));
171
+ const [indicatorPosition, setIndicatorPosition] = (0, import_octane.useState)(
172
+ [void 0, void 0],
173
+ (0, import_internal.subSlot)(slot, "indicatorPos")
174
+ );
175
+ const setActive = (0, import_useStableCallback.useStableCallback)(
176
+ (value) => {
177
+ setActiveState(value);
178
+ if (value !== -1) {
179
+ setLastUsedThumbIndex(value);
180
+ }
181
+ },
182
+ (0, import_internal.subSlot)(slot, "setActive")
183
+ );
184
+ (0, import_useRegisterFieldControl.useRegisterFieldControl)(
185
+ validation.inputRef,
186
+ id,
187
+ valueUnwrapped,
188
+ void 0,
189
+ !disabled,
190
+ nameProp,
191
+ (0, import_internal.subSlot)(slot, "register")
192
+ );
193
+ (0, import_useValueChanged.useValueChanged)(
194
+ valueUnwrapped,
195
+ () => {
196
+ clearErrors(name);
197
+ validation.change(valueUnwrapped);
198
+ const initialValue = validityData.initialValue;
199
+ let isDirty;
200
+ if (Array.isArray(valueUnwrapped) && Array.isArray(initialValue)) {
201
+ isDirty = !(0, import_areArraysEqual.areArraysEqual)(valueUnwrapped, initialValue);
202
+ } else {
203
+ isDirty = valueUnwrapped !== initialValue;
204
+ }
205
+ setDirty(isDirty);
206
+ },
207
+ (0, import_internal.subSlot)(slot, "valueChanged")
208
+ );
209
+ const registerFieldControlRef = (0, import_useStableCallback.useStableCallback)(
210
+ (element2) => {
211
+ if (element2) {
212
+ controlRef.current = element2;
213
+ }
214
+ },
215
+ (0, import_internal.subSlot)(slot, "regRef")
216
+ );
217
+ const range = Array.isArray(valueUnwrapped);
218
+ const values = (0, import_octane.useMemo)(
219
+ () => {
220
+ if (!range) {
221
+ return [(0, import_clamp.clamp)(valueUnwrapped, min, max)];
222
+ }
223
+ return valueUnwrapped.slice().sort(import_asc.asc);
224
+ },
225
+ [max, min, range, valueUnwrapped],
226
+ (0, import_internal.subSlot)(slot, "values")
227
+ );
228
+ const setValue = (0, import_useStableCallback.useStableCallback)(
229
+ (newValue, details) => {
230
+ if (Number.isNaN(newValue) || areValuesEqual(newValue, valueUnwrapped)) {
231
+ return false;
232
+ }
233
+ const changeDetails = details ?? (0, import_createChangeEventDetails.createChangeEventDetails)(import_createChangeEventDetails.REASONS.none, void 0, void 0, { activeThumbIndex: -1 });
234
+ const nativeEvent = changeDetails.event;
235
+ const EventConstructor = nativeEvent.constructor ?? Event;
236
+ let clonedEvent;
237
+ try {
238
+ clonedEvent = new EventConstructor(nativeEvent.type, nativeEvent);
239
+ } catch {
240
+ clonedEvent = new Event(nativeEvent.type);
241
+ }
242
+ Object.defineProperty(clonedEvent, "target", {
243
+ writable: true,
244
+ value: { value: newValue, name }
245
+ });
246
+ changeDetails.event = clonedEvent;
247
+ onValueChange(newValue, changeDetails);
248
+ if (changeDetails.isCanceled) {
249
+ return false;
250
+ }
251
+ lastChangeReasonRef.current = changeDetails.reason;
252
+ setValueUnwrapped(newValue);
253
+ return true;
254
+ },
255
+ (0, import_internal.subSlot)(slot, "setValue")
256
+ );
257
+ const handleInputChange = (0, import_useStableCallback.useStableCallback)(
258
+ (valueInput, index, event) => {
259
+ const newValue = (0, import_getSliderValue.getSliderValue)(valueInput, index, min, max, range, values);
260
+ if ((0, import_validateMinimumDistance.validateMinimumDistance)(newValue, step, minStepsBetweenValues)) {
261
+ const reason = getSliderChangeEventReason(event);
262
+ const applied = setValue(
263
+ newValue,
264
+ (0, import_createChangeEventDetails.createChangeEventDetails)(reason, event, void 0, { activeThumbIndex: index })
265
+ );
266
+ setTouched(true);
267
+ if (applied) {
268
+ onValueCommitted(newValue, (0, import_createChangeEventDetails.createGenericEventDetails)(reason, event));
269
+ }
270
+ }
271
+ },
272
+ (0, import_internal.subSlot)(slot, "handleInput")
273
+ );
274
+ (0, import_octane.useLayoutEffect)(
275
+ () => {
276
+ const activeEl = (0, import_owner.ownerDocument)(sliderRef.current).activeElement;
277
+ if (disabled && (0, import_contains.contains)(sliderRef.current, activeEl)) {
278
+ activeEl.blur();
279
+ }
280
+ },
281
+ [disabled],
282
+ (0, import_internal.subSlot)(slot, "e:disabledBlur")
283
+ );
284
+ if (disabled && active !== -1) {
285
+ setActive(-1);
286
+ }
287
+ const state = (0, import_octane.useMemo)(
288
+ () => ({
289
+ ...fieldState,
290
+ activeThumbIndex: active,
291
+ disabled,
292
+ dragging,
293
+ orientation,
294
+ max,
295
+ min,
296
+ minStepsBetweenValues,
297
+ step,
298
+ values
299
+ }),
300
+ [
301
+ fieldState,
302
+ active,
303
+ disabled,
304
+ dragging,
305
+ max,
306
+ min,
307
+ minStepsBetweenValues,
308
+ orientation,
309
+ step,
310
+ values
311
+ ],
312
+ (0, import_internal.subSlot)(slot, "state")
313
+ );
314
+ const contextValue = (0, import_octane.useMemo)(
315
+ () => ({
316
+ active,
317
+ controlRef,
318
+ disabled,
319
+ dragging,
320
+ validation,
321
+ formatOptionsRef,
322
+ handleInputChange,
323
+ indicatorPosition,
324
+ inset: thumbAlignment !== "center",
325
+ labelId: ariaLabelledby,
326
+ rootLabelId: defaultLabelId,
327
+ largeStep,
328
+ lastUsedThumbIndex,
329
+ lastChangeReasonRef,
330
+ form,
331
+ locale,
332
+ max,
333
+ min,
334
+ minStepsBetweenValues,
335
+ name,
336
+ onValueCommitted,
337
+ orientation,
338
+ pressedInputRef,
339
+ pressedThumbCenterOffsetRef,
340
+ pressedThumbIndexRef,
341
+ pressedValuesRef,
342
+ registerFieldControlRef,
343
+ renderBeforeHydration: thumbAlignment === "edge",
344
+ setActive,
345
+ setDragging,
346
+ setIndicatorPosition,
347
+ setLabelId,
348
+ setValue,
349
+ state,
350
+ step,
351
+ thumbCollisionBehavior,
352
+ thumbMap,
353
+ thumbRefs,
354
+ values
355
+ }),
356
+ [
357
+ active,
358
+ ariaLabelledby,
359
+ defaultLabelId,
360
+ disabled,
361
+ dragging,
362
+ validation,
363
+ formatOptionsRef,
364
+ handleInputChange,
365
+ indicatorPosition,
366
+ largeStep,
367
+ lastUsedThumbIndex,
368
+ form,
369
+ locale,
370
+ max,
371
+ min,
372
+ minStepsBetweenValues,
373
+ name,
374
+ onValueCommitted,
375
+ orientation,
376
+ registerFieldControlRef,
377
+ setActive,
378
+ setValue,
379
+ state,
380
+ step,
381
+ thumbCollisionBehavior,
382
+ thumbAlignment,
383
+ thumbMap,
384
+ values
385
+ ],
386
+ (0, import_internal.subSlot)(slot, "ctx")
387
+ );
388
+ const element = (0, import_useRenderElement.useRenderElement)(
389
+ "div",
390
+ { render, className, style },
391
+ {
392
+ state,
393
+ ref: [ref, sliderRef],
394
+ props: [
395
+ { "aria-labelledby": ariaLabelledby, id, role: "group" },
396
+ elementProps,
397
+ (props) => validation.getValidationProps(disabled, props)
398
+ ],
399
+ stateAttributesMapping: sliderStateAttributesMapping
400
+ },
401
+ (0, import_internal.subSlot)(slot, "re")
402
+ );
403
+ return (0, import_octane.createElement)(SliderRootContext.Provider, {
404
+ value: contextValue,
405
+ children: (0, import_octane.createElement)(import_CompositeList.CompositeList, {
406
+ elementsRef: thumbRefs,
407
+ onMapChange: setThumbMap,
408
+ children: element
409
+ })
410
+ });
411
+ }
412
+ function getControlOffset(styles, vertical) {
413
+ if (!styles) {
414
+ return { start: 0, end: 0 };
415
+ }
416
+ function parseSize(value) {
417
+ const parsed = value != null ? parseFloat(value) : 0;
418
+ return Number.isNaN(parsed) ? 0 : parsed;
419
+ }
420
+ const start = !vertical ? "InlineStart" : "Top";
421
+ const end = !vertical ? "InlineEnd" : "Bottom";
422
+ return {
423
+ start: parseSize(styles[`border${start}Width`]) + parseSize(styles[`padding${start}`]),
424
+ end: parseSize(styles[`border${end}Width`]) + parseSize(styles[`padding${end}`])
425
+ };
426
+ }
427
+ function getFingerCoords(event, touchIdRef) {
428
+ if (touchIdRef.current != null && event.changedTouches) {
429
+ for (let i = 0; i < event.changedTouches.length; i += 1) {
430
+ const touch = event.changedTouches[i];
431
+ if (touch.identifier === touchIdRef.current) {
432
+ return { x: touch.clientX, y: touch.clientY };
433
+ }
434
+ }
435
+ return null;
436
+ }
437
+ return { x: event.clientX, y: event.clientY };
438
+ }
439
+ function SliderControl(componentProps) {
440
+ const slot = (0, import_internal.S)("SliderControl");
441
+ const { render, className, style, ref, ...elementProps } = componentProps;
442
+ const {
443
+ disabled,
444
+ dragging,
445
+ inset,
446
+ lastChangeReasonRef,
447
+ max,
448
+ min,
449
+ minStepsBetweenValues,
450
+ onValueCommitted,
451
+ orientation,
452
+ pressedInputRef,
453
+ pressedThumbCenterOffsetRef,
454
+ pressedThumbIndexRef,
455
+ pressedValuesRef,
456
+ registerFieldControlRef,
457
+ renderBeforeHydration,
458
+ setActive,
459
+ setDragging,
460
+ setValue,
461
+ state,
462
+ step,
463
+ thumbCollisionBehavior,
464
+ thumbRefs,
465
+ values
466
+ } = useSliderRootContext();
467
+ const direction = (0, import_DirectionContext.useDirection)();
468
+ const range = values.length > 1;
469
+ const vertical = orientation === "vertical";
470
+ const controlRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "controlRef"));
471
+ const stylesRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "stylesRef"));
472
+ const setStylesRef = (0, import_useStableCallback.useStableCallback)(
473
+ (element) => {
474
+ if (element && stylesRef.current == null) {
475
+ stylesRef.current = (0, import_owner.ownerWindow)(element).getComputedStyle(element);
476
+ }
477
+ },
478
+ (0, import_internal.subSlot)(slot, "setStyles")
479
+ );
480
+ const touchIdRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "touchId"));
481
+ const moveCountRef = (0, import_octane.useRef)(0, (0, import_internal.subSlot)(slot, "moveCount"));
482
+ const insetThumbOffsetRef = (0, import_octane.useRef)(0, (0, import_internal.subSlot)(slot, "insetOffset"));
483
+ const currentInteractionValueRef = (0, import_octane.useRef)(
484
+ null,
485
+ (0, import_internal.subSlot)(slot, "currentVal")
486
+ );
487
+ const latestValuesRef = (0, import_useValueAsRef.useValueAsRef)(values, (0, import_internal.subSlot)(slot, "latestValues"));
488
+ function updatePressedThumb(nextIndex) {
489
+ if (pressedThumbIndexRef.current !== nextIndex) {
490
+ pressedThumbIndexRef.current = nextIndex;
491
+ }
492
+ const thumbElement = thumbRefs.current[nextIndex];
493
+ if (!thumbElement) {
494
+ pressedThumbCenterOffsetRef.current = null;
495
+ pressedInputRef.current = null;
496
+ return;
497
+ }
498
+ pressedInputRef.current = thumbElement.querySelector('input[type="range"]');
499
+ }
500
+ function resetPressedThumb() {
501
+ pressedThumbIndexRef.current = -1;
502
+ pressedThumbCenterOffsetRef.current = null;
503
+ pressedInputRef.current = null;
504
+ }
505
+ function isTargetDisabledThumb(target) {
506
+ if (!isElementNode(target)) {
507
+ return false;
508
+ }
509
+ return thumbRefs.current.some((thumbEl) => {
510
+ if (!isElementNode(thumbEl) || !(0, import_contains.contains)(thumbEl, target)) {
511
+ return false;
512
+ }
513
+ return thumbEl.querySelector('input[type="range"]')?.disabled === true;
514
+ });
515
+ }
516
+ function getFingerState(fingerCoords) {
517
+ const control = controlRef.current;
518
+ const thumbIndex = pressedThumbIndexRef.current;
519
+ if (!control || !range && (thumbIndex < 0 || thumbIndex >= values.length)) {
520
+ return null;
521
+ }
522
+ const { width, height, bottom, left, right } = control.getBoundingClientRect();
523
+ const controlOffset = getControlOffset(stylesRef.current, vertical);
524
+ const insetThumbOffset = insetThumbOffsetRef.current;
525
+ const controlSize = (vertical ? height : width) - controlOffset.start - controlOffset.end - insetThumbOffset * 2;
526
+ const thumbCenterOffset = pressedThumbCenterOffsetRef.current ?? 0;
527
+ const fingerX = fingerCoords.x - thumbCenterOffset;
528
+ const fingerY = fingerCoords.y - thumbCenterOffset;
529
+ const valueSize = vertical ? bottom - fingerY - controlOffset.end : (direction === "rtl" ? right - fingerX : fingerX - left) - controlOffset.start;
530
+ const valueRescaled = (0, import_clamp.clamp)((valueSize - insetThumbOffset) / controlSize, 0, 1);
531
+ let newValue = (max - min) * valueRescaled + min;
532
+ newValue = (0, import_roundValueToStep.roundValueToStep)(newValue, step, min);
533
+ newValue = (0, import_clamp.clamp)(newValue, min, max);
534
+ if (!range) {
535
+ return { value: newValue, thumbIndex, didSwap: false };
536
+ }
537
+ if (thumbIndex < 0) {
538
+ return null;
539
+ }
540
+ return (0, import_resolveThumbCollision.resolveThumbCollision)({
541
+ behavior: thumbCollisionBehavior,
542
+ values,
543
+ currentValues: latestValuesRef.current ?? values,
544
+ initialValues: pressedValuesRef.current,
545
+ pressedIndex: thumbIndex,
546
+ nextValue: newValue,
547
+ min,
548
+ max,
549
+ step,
550
+ minStepsBetweenValues
551
+ });
552
+ }
553
+ function startPressing(fingerCoords) {
554
+ pressedValuesRef.current = range ? values.slice() : null;
555
+ currentInteractionValueRef.current = null;
556
+ latestValuesRef.current = values;
557
+ const pressedThumbIndex = pressedThumbIndexRef.current;
558
+ let closestThumbIndex = pressedThumbIndex;
559
+ if (pressedThumbIndex > -1 && pressedThumbIndex < values.length) {
560
+ if (values[pressedThumbIndex] === max) {
561
+ let candidateIndex = pressedThumbIndex;
562
+ while (candidateIndex > 0 && values[candidateIndex - 1] === max) {
563
+ candidateIndex -= 1;
564
+ }
565
+ closestThumbIndex = candidateIndex;
566
+ }
567
+ } else {
568
+ const axis = !vertical ? "x" : "y";
569
+ let minDistance;
570
+ closestThumbIndex = -1;
571
+ for (let i = 0; i < thumbRefs.current.length; i += 1) {
572
+ const thumbEl = thumbRefs.current[i];
573
+ if (isElementNode(thumbEl) && !thumbEl.querySelector('input[type="range"]')?.disabled) {
574
+ const midpoint = (0, import_getMidpoint.getMidpoint)(thumbEl);
575
+ const distance = Math.abs(fingerCoords[axis] - midpoint[axis]);
576
+ if (minDistance === void 0 || distance <= minDistance) {
577
+ closestThumbIndex = i;
578
+ minDistance = distance;
579
+ }
580
+ }
581
+ }
582
+ }
583
+ if (closestThumbIndex > -1 && closestThumbIndex !== pressedThumbIndex) {
584
+ updatePressedThumb(closestThumbIndex);
585
+ }
586
+ if (inset) {
587
+ const thumbEl = thumbRefs.current[closestThumbIndex];
588
+ if (isElementNode(thumbEl)) {
589
+ const thumbRect = thumbEl.getBoundingClientRect();
590
+ const side = !vertical ? "width" : "height";
591
+ insetThumbOffsetRef.current = thumbRect[side] / 2;
592
+ }
593
+ }
594
+ }
595
+ function focusThumb(thumbIndex) {
596
+ const input = thumbRefs.current?.[thumbIndex]?.querySelector('input[type="range"]');
597
+ if (!input) {
598
+ return;
599
+ }
600
+ input.focus({ preventScroll: true, focusVisible: false });
601
+ }
602
+ function setValueFromPointer(finger, reason, nativeEvent) {
603
+ const applied = setValue(
604
+ finger.value,
605
+ (0, import_createChangeEventDetails.createChangeEventDetails)(reason, nativeEvent, void 0, {
606
+ activeThumbIndex: finger.thumbIndex
607
+ })
608
+ );
609
+ if (applied) {
610
+ currentInteractionValueRef.current = finger.value;
611
+ latestValuesRef.current = Array.isArray(finger.value) ? finger.value : [finger.value];
612
+ if (finger.didSwap) {
613
+ updatePressedThumb(finger.thumbIndex);
614
+ }
615
+ }
616
+ return applied;
617
+ }
618
+ const handleTouchMove = (0, import_useStableCallback.useStableCallback)(
619
+ (nativeEvent) => {
620
+ const fingerCoords = getFingerCoords(nativeEvent, touchIdRef);
621
+ if (fingerCoords == null) {
622
+ return;
623
+ }
624
+ moveCountRef.current += 1;
625
+ if (nativeEvent.type === "pointermove" && nativeEvent.buttons === 0) {
626
+ handleTouchEnd(nativeEvent);
627
+ return;
628
+ }
629
+ const finger = getFingerState(fingerCoords);
630
+ if (finger == null) {
631
+ return;
632
+ }
633
+ if ((0, import_validateMinimumDistance.validateMinimumDistance)(finger.value, step, minStepsBetweenValues)) {
634
+ if (!dragging && moveCountRef.current > INTENTIONAL_DRAG_COUNT_THRESHOLD) {
635
+ setDragging(true);
636
+ }
637
+ const applied = setValueFromPointer(finger, import_createChangeEventDetails.REASONS.drag, nativeEvent);
638
+ if (applied && finger.didSwap) {
639
+ focusThumb(finger.thumbIndex);
640
+ }
641
+ }
642
+ },
643
+ (0, import_internal.subSlot)(slot, "touchMove")
644
+ );
645
+ const handleTouchEnd = (0, import_useStableCallback.useStableCallback)(
646
+ (nativeEvent) => {
647
+ setActive(-1);
648
+ setDragging(false);
649
+ pressedInputRef.current = null;
650
+ pressedThumbCenterOffsetRef.current = null;
651
+ if (currentInteractionValueRef.current != null) {
652
+ const commitReason = lastChangeReasonRef.current;
653
+ onValueCommitted(
654
+ currentInteractionValueRef.current,
655
+ (0, import_createChangeEventDetails.createGenericEventDetails)(commitReason, nativeEvent)
656
+ );
657
+ }
658
+ if ("pointerType" in nativeEvent && controlRef.current?.hasPointerCapture(nativeEvent.pointerId)) {
659
+ controlRef.current?.releasePointerCapture(nativeEvent.pointerId);
660
+ }
661
+ pressedThumbIndexRef.current = -1;
662
+ touchIdRef.current = null;
663
+ pressedValuesRef.current = null;
664
+ currentInteractionValueRef.current = null;
665
+ stopListening();
666
+ },
667
+ (0, import_internal.subSlot)(slot, "touchEnd")
668
+ );
669
+ const handleTouchStart = (0, import_useStableCallback.useStableCallback)(
670
+ (nativeEvent) => {
671
+ if (disabled) {
672
+ return;
673
+ }
674
+ if (isTargetDisabledThumb((0, import_list_utils.getTarget)(nativeEvent))) {
675
+ resetPressedThumb();
676
+ return;
677
+ }
678
+ const touch = nativeEvent.changedTouches[0];
679
+ if (touch != null) {
680
+ touchIdRef.current = touch.identifier;
681
+ }
682
+ const fingerCoords = getFingerCoords(nativeEvent, touchIdRef);
683
+ if (fingerCoords != null) {
684
+ startPressing(fingerCoords);
685
+ const finger = getFingerState(fingerCoords);
686
+ if (finger == null) {
687
+ return;
688
+ }
689
+ focusThumb(finger.thumbIndex);
690
+ const applied = setValueFromPointer(finger, import_createChangeEventDetails.REASONS.trackPress, nativeEvent);
691
+ if (applied && finger.didSwap) {
692
+ focusThumb(finger.thumbIndex);
693
+ }
694
+ }
695
+ moveCountRef.current = 0;
696
+ const doc = (0, import_owner.ownerDocument)(controlRef.current);
697
+ doc.addEventListener("touchmove", handleTouchMove, { passive: true });
698
+ doc.addEventListener("touchend", handleTouchEnd, { passive: true });
699
+ },
700
+ (0, import_internal.subSlot)(slot, "touchStart")
701
+ );
702
+ const stopListening = (0, import_useStableCallback.useStableCallback)(
703
+ () => {
704
+ const doc = (0, import_owner.ownerDocument)(controlRef.current);
705
+ doc.removeEventListener("pointermove", handleTouchMove);
706
+ doc.removeEventListener("pointerup", handleTouchEnd);
707
+ doc.removeEventListener("touchmove", handleTouchMove);
708
+ doc.removeEventListener("touchend", handleTouchEnd);
709
+ pressedValuesRef.current = null;
710
+ currentInteractionValueRef.current = null;
711
+ },
712
+ (0, import_internal.subSlot)(slot, "stop")
713
+ );
714
+ const focusFrame = (0, import_useAnimationFrame.useAnimationFrame)((0, import_internal.subSlot)(slot, "focusFrame"));
715
+ (0, import_octane.useEffect)(
716
+ () => {
717
+ const control = controlRef.current;
718
+ if (!control) {
719
+ return () => stopListening();
720
+ }
721
+ const unsubscribeTouchStart = (0, import_addEventListener.addEventListener)(control, "touchstart", handleTouchStart, {
722
+ passive: true
723
+ });
724
+ return () => {
725
+ unsubscribeTouchStart();
726
+ focusFrame.cancel();
727
+ stopListening();
728
+ };
729
+ },
730
+ [stopListening, handleTouchStart, focusFrame],
731
+ (0, import_internal.subSlot)(slot, "e:touchstart")
732
+ );
733
+ (0, import_octane.useEffect)(
734
+ () => {
735
+ if (disabled) {
736
+ stopListening();
737
+ }
738
+ },
739
+ [disabled, stopListening],
740
+ (0, import_internal.subSlot)(slot, "e:disabled")
741
+ );
742
+ return (0, import_useRenderElement.useRenderElement)(
743
+ "div",
744
+ { render, className, style },
745
+ {
746
+ state,
747
+ ref: [ref, registerFieldControlRef, controlRef, setStylesRef],
748
+ props: [
749
+ {
750
+ ["data-base-ui-slider-control"]: renderBeforeHydration ? "" : void 0,
751
+ onPointerDown(event) {
752
+ const control = controlRef.current;
753
+ const target = (0, import_list_utils.getTarget)(event);
754
+ if (!control || disabled || event.defaultPrevented || !isElementNode(target) || event.button !== 0) {
755
+ return;
756
+ }
757
+ if (isTargetDisabledThumb(target)) {
758
+ resetPressedThumb();
759
+ return;
760
+ }
761
+ const fingerCoords = getFingerCoords(event, touchIdRef);
762
+ if (fingerCoords != null) {
763
+ startPressing(fingerCoords);
764
+ const finger = getFingerState(fingerCoords);
765
+ if (finger == null) {
766
+ return;
767
+ }
768
+ const pressedOnFocusedThumb = (0, import_contains.contains)(
769
+ thumbRefs.current[finger.thumbIndex],
770
+ (0, import_owner.ownerDocument)(control).activeElement
771
+ );
772
+ if (pressedOnFocusedThumb) {
773
+ event.preventDefault();
774
+ } else {
775
+ focusFrame.request(() => {
776
+ focusThumb(finger.thumbIndex);
777
+ });
778
+ }
779
+ setDragging(true);
780
+ const pressedOnAnyThumb = pressedThumbCenterOffsetRef.current != null;
781
+ if (!pressedOnAnyThumb) {
782
+ const applied = setValueFromPointer(finger, import_createChangeEventDetails.REASONS.trackPress, event);
783
+ if (applied && finger.didSwap) {
784
+ focusThumb(finger.thumbIndex);
785
+ }
786
+ }
787
+ }
788
+ if (event.pointerId) {
789
+ control.setPointerCapture(event.pointerId);
790
+ }
791
+ moveCountRef.current = 0;
792
+ const doc = (0, import_owner.ownerDocument)(controlRef.current);
793
+ doc.addEventListener("pointermove", handleTouchMove, { passive: true });
794
+ doc.addEventListener("pointerup", handleTouchEnd, { once: true });
795
+ }
796
+ },
797
+ elementProps
798
+ ],
799
+ stateAttributesMapping: sliderStateAttributesMapping
800
+ },
801
+ (0, import_internal.subSlot)(slot, "re")
802
+ );
803
+ }
804
+ function SliderTrack(componentProps) {
805
+ const slot = (0, import_internal.S)("SliderTrack");
806
+ const { render, className, style, ref, ...elementProps } = componentProps;
807
+ const { state } = useSliderRootContext();
808
+ return (0, import_useRenderElement.useRenderElement)(
809
+ "div",
810
+ { render, className, style },
811
+ {
812
+ state,
813
+ ref,
814
+ props: [{ style: { position: "relative" } }, elementProps],
815
+ stateAttributesMapping: sliderStateAttributesMapping
816
+ },
817
+ (0, import_internal.subSlot)(slot, "re")
818
+ );
819
+ }
820
+ function getInsetStyles(vertical, range, start, end, renderBeforeHydration, hydrating) {
821
+ const visibility = start === void 0 || range && end === void 0 ? "hidden" : void 0;
822
+ const startEdge = vertical ? "bottom" : "insetInlineStart";
823
+ const mainSide = vertical ? "height" : "width";
824
+ const crossSide = vertical ? "width" : "height";
825
+ const styles = {
826
+ visibility: renderBeforeHydration && hydrating ? "hidden" : visibility,
827
+ position: vertical ? "absolute" : "relative",
828
+ [crossSide]: "inherit"
829
+ };
830
+ styles["--start-position"] = `${start ?? 0}%`;
831
+ if (!range) {
832
+ styles[startEdge] = 0;
833
+ styles[mainSide] = "var(--start-position)";
834
+ return styles;
835
+ }
836
+ styles["--relative-size"] = `${(end ?? 0) - (start ?? 0)}%`;
837
+ styles[startEdge] = "var(--start-position)";
838
+ styles[mainSide] = "var(--relative-size)";
839
+ return styles;
840
+ }
841
+ function getCenteredStyles(vertical, range, start, end) {
842
+ const startEdge = vertical ? "bottom" : "insetInlineStart";
843
+ const mainSide = vertical ? "height" : "width";
844
+ const crossSide = vertical ? "width" : "height";
845
+ const styles = {
846
+ position: vertical ? "absolute" : "relative",
847
+ [crossSide]: "inherit"
848
+ };
849
+ if (!range) {
850
+ styles[startEdge] = 0;
851
+ styles[mainSide] = `${start}%`;
852
+ return styles;
853
+ }
854
+ const size = end - start;
855
+ styles[startEdge] = `${start}%`;
856
+ styles[mainSide] = `${size}%`;
857
+ return styles;
858
+ }
859
+ function SliderIndicator(componentProps) {
860
+ const slot = (0, import_internal.S)("SliderIndicator");
861
+ const { render, className, style: styleProp, ref, ...elementProps } = componentProps;
862
+ const { indicatorPosition, inset, max, min, orientation, renderBeforeHydration, state, values } = useSliderRootContext();
863
+ const isHydrating = (0, import_useIsHydrating.useIsHydrating)((0, import_internal.subSlot)(slot, "hydrating"));
864
+ const vertical = orientation === "vertical";
865
+ const range = values.length > 1;
866
+ const style = inset ? getInsetStyles(
867
+ vertical,
868
+ range,
869
+ indicatorPosition[0],
870
+ indicatorPosition[1],
871
+ renderBeforeHydration,
872
+ isHydrating
873
+ ) : getCenteredStyles(
874
+ vertical,
875
+ range,
876
+ (0, import_valueToPercent.valueToPercent)(values[0], min, max),
877
+ (0, import_valueToPercent.valueToPercent)(values[values.length - 1], min, max)
878
+ );
879
+ return (0, import_useRenderElement.useRenderElement)(
880
+ "div",
881
+ { render, className, style: styleProp },
882
+ {
883
+ state,
884
+ ref,
885
+ props: [
886
+ { ["data-base-ui-slider-indicator"]: renderBeforeHydration ? "" : void 0, style },
887
+ elementProps
888
+ ],
889
+ stateAttributesMapping: sliderStateAttributesMapping
890
+ },
891
+ (0, import_internal.subSlot)(slot, "re")
892
+ );
893
+ }
894
+ function getDefaultAriaValueText(values, index, format, locale) {
895
+ if (index < 0) {
896
+ return void 0;
897
+ }
898
+ if (values.length === 2) {
899
+ if (index === 0) {
900
+ return `${(0, import_formatNumber.formatNumber)(values[index], locale, format)} start range`;
901
+ }
902
+ return `${(0, import_formatNumber.formatNumber)(values[index], locale, format)} end range`;
903
+ }
904
+ return format ? (0, import_formatNumber.formatNumber)(values[index], locale, format) : void 0;
905
+ }
906
+ function getNewValue(thumbValue, increment, direction, min, max) {
907
+ const value = direction === 1 ? thumbValue + increment : thumbValue - increment;
908
+ const roundedValue = Number(
909
+ value.toFixed(
910
+ Math.max(
911
+ (0, import_roundValueToStep.getDecimalPrecision)(thumbValue),
912
+ (0, import_roundValueToStep.getDecimalPrecision)(increment),
913
+ (0, import_roundValueToStep.getDecimalPrecision)(min)
914
+ )
915
+ )
916
+ );
917
+ return (0, import_clamp.clamp)(roundedValue, min, max);
918
+ }
919
+ function SliderThumb(componentProps) {
920
+ const slot = (0, import_internal.S)("SliderThumb");
921
+ const {
922
+ render,
923
+ children: childrenProp,
924
+ className,
925
+ "aria-describedby": ariaDescribedByProp,
926
+ "aria-label": ariaLabelProp,
927
+ "aria-labelledby": ariaLabelledByProp,
928
+ "aria-valuetext": ariaValueTextProp,
929
+ disabled: disabledProp = false,
930
+ getAriaLabel: getAriaLabelProp,
931
+ getAriaValueText: getAriaValueTextProp,
932
+ id: idProp,
933
+ index: indexProp,
934
+ inputRef: inputRefProp,
935
+ onBlur: onBlurProp,
936
+ onFocus: onFocusProp,
937
+ onKeyDown: onKeyDownProp,
938
+ tabIndex: tabIndexProp,
939
+ style,
940
+ ref,
941
+ ...elementProps
942
+ } = componentProps;
943
+ const id = (0, import_useBaseUiId.useBaseUiId)(idProp, (0, import_internal.subSlot)(slot, "id"));
944
+ const {
945
+ active: activeIndex,
946
+ lastUsedThumbIndex,
947
+ controlRef,
948
+ disabled: contextDisabled,
949
+ validation,
950
+ formatOptionsRef,
951
+ handleInputChange,
952
+ inset,
953
+ labelId,
954
+ largeStep,
955
+ locale,
956
+ max,
957
+ min,
958
+ minStepsBetweenValues,
959
+ form,
960
+ name,
961
+ orientation,
962
+ pressedInputRef,
963
+ pressedThumbCenterOffsetRef,
964
+ pressedThumbIndexRef,
965
+ renderBeforeHydration,
966
+ setActive,
967
+ setIndicatorPosition,
968
+ state,
969
+ step,
970
+ values: sliderValues
971
+ } = useSliderRootContext();
972
+ const direction = (0, import_DirectionContext.useDirection)();
973
+ const disabled = disabledProp || contextDisabled;
974
+ const range = sliderValues.length > 1;
975
+ const vertical = orientation === "vertical";
976
+ const rtl = direction === "rtl";
977
+ const { setTouched, setFocused, validationMode } = (0, import_FieldRootContext.useFieldRootContext)();
978
+ const thumbRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "thumbRef"));
979
+ const inputRef = (0, import_octane.useRef)(null, (0, import_internal.subSlot)(slot, "inputRef"));
980
+ const restoringFocusVisibleRef = (0, import_octane.useRef)(false, (0, import_internal.subSlot)(slot, "restoring"));
981
+ const defaultInputId = (0, import_useBaseUiId.useBaseUiId)(void 0, (0, import_internal.subSlot)(slot, "defInputId"));
982
+ const labelableId = (0, import_useLabelableId.useLabelableId)(void 0, (0, import_internal.subSlot)(slot, "labelableId"));
983
+ const inputId = range ? defaultInputId : labelableId;
984
+ const thumbMetadata = (0, import_octane.useMemo)(() => ({ inputId }), [inputId], (0, import_internal.subSlot)(slot, "meta"));
985
+ const { ref: listItemRef, index: compositeIndex } = (0, import_useCompositeListItem.useCompositeListItem)(
986
+ { metadata: thumbMetadata },
987
+ (0, import_internal.subSlot)(slot, "listItem")
988
+ );
989
+ const index = !range ? 0 : indexProp ?? compositeIndex;
990
+ const last = index === sliderValues.length - 1;
991
+ const thumbValue = sliderValues[index];
992
+ const thumbValuePercent = (0, import_valueToPercent.valueToPercent)(thumbValue, min, max);
993
+ const [positionPercent, setPositionPercent] = (0, import_octane.useState)(
994
+ void 0,
995
+ (0, import_internal.subSlot)(slot, "posPct")
996
+ );
997
+ const isHydrating = (0, import_useIsHydrating.useIsHydrating)((0, import_internal.subSlot)(slot, "hydrating"));
998
+ const safeLastUsedThumbIndex = lastUsedThumbIndex >= 0 && lastUsedThumbIndex < sliderValues.length ? lastUsedThumbIndex : -1;
999
+ const getInsetPosition = (0, import_useStableCallback.useStableCallback)(
1000
+ () => {
1001
+ const control = controlRef.current;
1002
+ const thumb = thumbRef.current;
1003
+ if (!control || !thumb) {
1004
+ return;
1005
+ }
1006
+ const thumbRect = thumb.getBoundingClientRect();
1007
+ const controlRect = control.getBoundingClientRect();
1008
+ const side = vertical ? "height" : "width";
1009
+ const controlSize = controlRect[side] - thumbRect[side];
1010
+ const thumbOffsetFromControlEdge = thumbRect[side] / 2 + controlSize * thumbValuePercent / 100;
1011
+ const nextPositionPercent = thumbOffsetFromControlEdge / controlRect[side] * 100;
1012
+ const nextInsetPosition = Number.isFinite(nextPositionPercent) ? nextPositionPercent : void 0;
1013
+ setPositionPercent(nextInsetPosition);
1014
+ if (index === 0) {
1015
+ setIndicatorPosition((prevPosition) => [nextInsetPosition, prevPosition[1]]);
1016
+ } else if (last) {
1017
+ setIndicatorPosition((prevPosition) => [prevPosition[0], nextInsetPosition]);
1018
+ }
1019
+ },
1020
+ (0, import_internal.subSlot)(slot, "insetPos")
1021
+ );
1022
+ (0, import_octane.useLayoutEffect)(
1023
+ () => {
1024
+ if (inset) {
1025
+ queueMicrotask(getInsetPosition);
1026
+ }
1027
+ },
1028
+ [getInsetPosition, inset],
1029
+ (0, import_internal.subSlot)(slot, "e:inset1")
1030
+ );
1031
+ (0, import_octane.useLayoutEffect)(
1032
+ () => {
1033
+ if (inset) {
1034
+ getInsetPosition();
1035
+ }
1036
+ },
1037
+ [getInsetPosition, inset, thumbValuePercent],
1038
+ (0, import_internal.subSlot)(slot, "e:inset2")
1039
+ );
1040
+ (0, import_octane.useLayoutEffect)(
1041
+ () => {
1042
+ if (!inset) {
1043
+ return void 0;
1044
+ }
1045
+ const control = controlRef.current;
1046
+ const thumb = thumbRef.current;
1047
+ if (!control || !thumb) {
1048
+ return void 0;
1049
+ }
1050
+ const ResizeObserverCtor = (0, import_owner.ownerWindow)(control).ResizeObserver;
1051
+ if (typeof ResizeObserverCtor !== "function") {
1052
+ return void 0;
1053
+ }
1054
+ const resizeObserver = new ResizeObserverCtor(getInsetPosition);
1055
+ resizeObserver.observe(control);
1056
+ resizeObserver.observe(thumb);
1057
+ return () => {
1058
+ resizeObserver.disconnect();
1059
+ };
1060
+ },
1061
+ [getInsetPosition, inset],
1062
+ (0, import_internal.subSlot)(slot, "e:inset3")
1063
+ );
1064
+ const startEdge = vertical ? "bottom" : "insetInlineStart";
1065
+ const crossOffsetProperty = vertical ? "left" : "top";
1066
+ let zIndex;
1067
+ if (range) {
1068
+ if (activeIndex === index) {
1069
+ zIndex = 2;
1070
+ } else if (safeLastUsedThumbIndex === index) {
1071
+ zIndex = 1;
1072
+ }
1073
+ } else if (activeIndex === index) {
1074
+ zIndex = 1;
1075
+ }
1076
+ let thumbStyle;
1077
+ if (inset) {
1078
+ thumbStyle = {
1079
+ ["--position"]: `${positionPercent ?? 0}%`,
1080
+ visibility: renderBeforeHydration && isHydrating || positionPercent === void 0 ? "hidden" : void 0,
1081
+ position: "absolute",
1082
+ [startEdge]: "var(--position)",
1083
+ [crossOffsetProperty]: "50%",
1084
+ translate: `${(vertical || !rtl ? -1 : 1) * 50}% ${(vertical ? 1 : -1) * 50}%`,
1085
+ zIndex
1086
+ };
1087
+ } else {
1088
+ thumbStyle = !Number.isFinite(thumbValuePercent) ? import_visuallyHidden.visuallyHidden : {
1089
+ position: "absolute",
1090
+ [startEdge]: `${thumbValuePercent}%`,
1091
+ [crossOffsetProperty]: "50%",
1092
+ translate: `${(vertical || !rtl ? -1 : 1) * 50}% ${(vertical ? 1 : -1) * 50}%`,
1093
+ zIndex
1094
+ };
1095
+ }
1096
+ let cssWritingMode;
1097
+ if (orientation === "vertical") {
1098
+ cssWritingMode = rtl ? "vertical-rl" : "vertical-lr";
1099
+ }
1100
+ const ariaLabel = typeof getAriaLabelProp === "function" ? getAriaLabelProp(index) : ariaLabelProp;
1101
+ const inputProps = (0, import_mergeProps.mergeProps)(
1102
+ {
1103
+ "aria-label": ariaLabel,
1104
+ "aria-labelledby": ariaLabelledByProp ?? (ariaLabel == null ? labelId : void 0),
1105
+ "aria-describedby": ariaDescribedByProp,
1106
+ "aria-orientation": orientation,
1107
+ "aria-valuenow": thumbValue,
1108
+ "aria-valuetext": typeof getAriaValueTextProp === "function" ? getAriaValueTextProp(
1109
+ (0, import_formatNumber.formatNumber)(thumbValue, locale, formatOptionsRef.current ?? void 0),
1110
+ thumbValue,
1111
+ index
1112
+ ) : ariaValueTextProp ?? getDefaultAriaValueText(
1113
+ sliderValues,
1114
+ index,
1115
+ formatOptionsRef.current ?? void 0,
1116
+ locale
1117
+ ),
1118
+ disabled,
1119
+ form,
1120
+ id: inputId,
1121
+ max,
1122
+ min,
1123
+ name,
1124
+ onChange(event) {
1125
+ handleInputChange(event.currentTarget.valueAsNumber, index, event);
1126
+ },
1127
+ onFocus(event) {
1128
+ const isRestoringFocusVisible = restoringFocusVisibleRef.current;
1129
+ restoringFocusVisibleRef.current = false;
1130
+ setActive(index);
1131
+ setFocused(true);
1132
+ if (isRestoringFocusVisible) {
1133
+ event.stopPropagation();
1134
+ }
1135
+ },
1136
+ onBlur(event) {
1137
+ if (restoringFocusVisibleRef.current) {
1138
+ event.stopPropagation();
1139
+ return;
1140
+ }
1141
+ if (!thumbRef.current) {
1142
+ return;
1143
+ }
1144
+ setActive(-1);
1145
+ setTouched(true);
1146
+ setFocused(false);
1147
+ if (validationMode === "onBlur") {
1148
+ validation.commit((0, import_getSliderValue.getSliderValue)(thumbValue, index, min, max, range, sliderValues));
1149
+ }
1150
+ },
1151
+ onKeyDown(event) {
1152
+ if (event.defaultPrevented) {
1153
+ return;
1154
+ }
1155
+ if (!ALL_KEYS.has(event.key)) {
1156
+ return;
1157
+ }
1158
+ if (import_keys.COMPOSITE_KEYS.has(event.key)) {
1159
+ event.stopPropagation();
1160
+ }
1161
+ let newValue = null;
1162
+ const roundedValue = (0, import_roundValueToStep.roundValueToStep)(thumbValue, step, min);
1163
+ switch (event.key) {
1164
+ case import_keys.ARROW_UP:
1165
+ newValue = getNewValue(roundedValue, event.shiftKey ? largeStep : step, 1, min, max);
1166
+ break;
1167
+ case import_keys.ARROW_RIGHT:
1168
+ newValue = getNewValue(
1169
+ roundedValue,
1170
+ event.shiftKey ? largeStep : step,
1171
+ rtl ? -1 : 1,
1172
+ min,
1173
+ max
1174
+ );
1175
+ break;
1176
+ case import_keys.ARROW_DOWN:
1177
+ newValue = getNewValue(roundedValue, event.shiftKey ? largeStep : step, -1, min, max);
1178
+ break;
1179
+ case import_keys.ARROW_LEFT:
1180
+ newValue = getNewValue(
1181
+ roundedValue,
1182
+ event.shiftKey ? largeStep : step,
1183
+ rtl ? 1 : -1,
1184
+ min,
1185
+ max
1186
+ );
1187
+ break;
1188
+ case import_keys.PAGE_UP:
1189
+ newValue = getNewValue(roundedValue, largeStep, 1, min, max);
1190
+ break;
1191
+ case import_keys.PAGE_DOWN:
1192
+ newValue = getNewValue(roundedValue, largeStep, -1, min, max);
1193
+ break;
1194
+ case import_keys.END:
1195
+ newValue = max;
1196
+ if (range) {
1197
+ newValue = Number.isFinite(sliderValues[index + 1]) ? sliderValues[index + 1] - step * minStepsBetweenValues : max;
1198
+ }
1199
+ break;
1200
+ case import_keys.HOME:
1201
+ newValue = min;
1202
+ if (range) {
1203
+ newValue = Number.isFinite(sliderValues[index - 1]) ? sliderValues[index - 1] + step * minStepsBetweenValues : min;
1204
+ }
1205
+ break;
1206
+ default:
1207
+ break;
1208
+ }
1209
+ if (newValue !== null) {
1210
+ const input = event.currentTarget;
1211
+ if (!(0, import_matchesFocusVisible.matchesFocusVisible)(input)) {
1212
+ restoringFocusVisibleRef.current = true;
1213
+ input.blur();
1214
+ input.focus({ preventScroll: true, focusVisible: true });
1215
+ }
1216
+ handleInputChange(newValue, index, event);
1217
+ event.preventDefault();
1218
+ }
1219
+ },
1220
+ step,
1221
+ style: {
1222
+ ...import_visuallyHidden.visuallyHidden,
1223
+ width: "100%",
1224
+ height: "100%",
1225
+ writingMode: cssWritingMode
1226
+ },
1227
+ tabIndex: tabIndexProp ?? void 0,
1228
+ type: "range",
1229
+ // octane: `value` is live CONTROLLED (React parity) — the runtime drives the
1230
+ // `.value` property, mirrors it to the attribute, and reasserts after commits and
1231
+ // discrete events. Base UI prevents native range interaction (keydown →
1232
+ // preventDefault), so `thumbValue` stays the single source of truth, as on React.
1233
+ value: thumbValue ?? ""
1234
+ },
1235
+ (props) => validation.getValidationProps(disabled, props),
1236
+ { onKeyDown: onKeyDownProp }
1237
+ );
1238
+ const mergedInputRef = (0, import_composeRefs.useComposedRefs)(
1239
+ inputRef,
1240
+ validation.inputRef,
1241
+ inputRefProp,
1242
+ (0, import_internal.subSlot)(slot, "inputRefs")
1243
+ );
1244
+ const inputElement = (0, import_octane.createElement)("input", { key: "input", ...inputProps, ref: mergedInputRef });
1245
+ return (0, import_useRenderElement.useRenderElement)(
1246
+ "div",
1247
+ { render, className, style },
1248
+ {
1249
+ state,
1250
+ ref: [ref, listItemRef, thumbRef],
1251
+ props: [
1252
+ {
1253
+ ["data-index"]: index,
1254
+ // Keyed for the same reason as dialog and progress: octane reconciles an array
1255
+ // child as a keyed list, and the consumer's children cannot be keyed in place.
1256
+ children: [
1257
+ (0, import_octane.createElement)(import_octane.Fragment, { key: "children", children: childrenProp }),
1258
+ inputElement
1259
+ ],
1260
+ id,
1261
+ onBlur: onBlurProp,
1262
+ onFocus: onFocusProp,
1263
+ onPointerDown(event) {
1264
+ if (disabled) {
1265
+ return;
1266
+ }
1267
+ pressedThumbIndexRef.current = index;
1268
+ if (thumbRef.current != null) {
1269
+ const axis = orientation === "horizontal" ? "x" : "y";
1270
+ const midpoint = (0, import_getMidpoint.getMidpoint)(thumbRef.current);
1271
+ const offset = (orientation === "horizontal" ? event.clientX : event.clientY) - midpoint[axis];
1272
+ pressedThumbCenterOffsetRef.current = offset;
1273
+ }
1274
+ if (inputRef.current != null && pressedInputRef.current !== inputRef.current) {
1275
+ pressedInputRef.current = inputRef.current;
1276
+ }
1277
+ },
1278
+ style: thumbStyle
1279
+ },
1280
+ elementProps
1281
+ ],
1282
+ stateAttributesMapping: sliderStateAttributesMapping
1283
+ },
1284
+ (0, import_internal.subSlot)(slot, "re")
1285
+ );
1286
+ }
1287
+ function SliderValue(componentProps) {
1288
+ const slot = (0, import_internal.S)("SliderValue");
1289
+ const {
1290
+ "aria-live": ariaLive = "off",
1291
+ render,
1292
+ className,
1293
+ children,
1294
+ style,
1295
+ ref,
1296
+ ...elementProps
1297
+ } = componentProps;
1298
+ const { thumbMap, state, values, formatOptionsRef, locale } = useSliderRootContext();
1299
+ let htmlFor = "";
1300
+ for (const thumbMetadata of thumbMap.values()) {
1301
+ if (thumbMetadata?.inputId) {
1302
+ htmlFor += `${thumbMetadata.inputId} `;
1303
+ }
1304
+ }
1305
+ const outputFor = htmlFor.trim() === "" ? void 0 : htmlFor.trim();
1306
+ const formattedValues = (0, import_octane.useMemo)(
1307
+ () => {
1308
+ const arr = [];
1309
+ for (let i = 0; i < values.length; i += 1) {
1310
+ arr.push((0, import_formatNumber.formatNumber)(values[i], locale, formatOptionsRef.current ?? void 0));
1311
+ }
1312
+ return arr;
1313
+ },
1314
+ [formatOptionsRef, locale, values],
1315
+ (0, import_internal.subSlot)(slot, "fmt")
1316
+ );
1317
+ const defaultDisplayValue = values.map((v, i) => formattedValues[i] || v).join(" \u2013 ");
1318
+ return (0, import_useRenderElement.useRenderElement)(
1319
+ "output",
1320
+ { render, className, style },
1321
+ {
1322
+ state,
1323
+ ref,
1324
+ props: [
1325
+ {
1326
+ "aria-live": ariaLive,
1327
+ children: typeof children === "function" ? children(formattedValues, values) : defaultDisplayValue,
1328
+ htmlFor: outputFor
1329
+ },
1330
+ elementProps
1331
+ ],
1332
+ stateAttributesMapping: sliderStateAttributesMapping
1333
+ },
1334
+ (0, import_internal.subSlot)(slot, "re")
1335
+ );
1336
+ }
1337
+ function SliderLabel(componentProps) {
1338
+ const slot = (0, import_internal.S)("SliderLabel");
1339
+ const { render, className, style, ref, ...elementProps } = componentProps;
1340
+ delete elementProps.id;
1341
+ const { state, setLabelId, controlRef, rootLabelId } = useSliderRootContext();
1342
+ function focusControl(event, controlId) {
1343
+ if (controlId) {
1344
+ const controlElement = (0, import_owner.ownerDocument)(event.currentTarget).getElementById(controlId);
1345
+ if (isHTMLElementNode(controlElement)) {
1346
+ (0, import_useLabel.focusElementWithVisible)(controlElement);
1347
+ return;
1348
+ }
1349
+ }
1350
+ const fallbackInputs = controlRef.current?.querySelectorAll('input[type="range"]');
1351
+ const fallbackInput = fallbackInputs?.length === 1 ? fallbackInputs[0] : null;
1352
+ if (isHTMLElementNode(fallbackInput)) {
1353
+ (0, import_useLabel.focusElementWithVisible)(fallbackInput);
1354
+ }
1355
+ }
1356
+ const labelProps = (0, import_useLabel.useLabel)(
1357
+ { id: rootLabelId, setLabelId, focusControl },
1358
+ (0, import_internal.subSlot)(slot, "label")
1359
+ );
1360
+ return (0, import_useRenderElement.useRenderElement)(
1361
+ "div",
1362
+ { render, className, style },
1363
+ {
1364
+ state,
1365
+ ref,
1366
+ props: [labelProps, elementProps],
1367
+ stateAttributesMapping: sliderStateAttributesMapping
1368
+ },
1369
+ (0, import_internal.subSlot)(slot, "re")
1370
+ );
1371
+ }
1372
+ const Slider = {
1373
+ Root: SliderRoot,
1374
+ Value: SliderValue,
1375
+ Control: SliderControl,
1376
+ Track: SliderTrack,
1377
+ Indicator: SliderIndicator,
1378
+ Thumb: SliderThumb,
1379
+ Label: SliderLabel
1380
+ };
1381
+ // Annotate the CommonJS export names for ESM import in node:
1382
+ 0 && (module.exports = {
1383
+ Slider
1384
+ });