@tamagui/slider 1.88.1 → 1.88.2

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.
@@ -1,40 +1,41 @@
1
- import { composeRefs, useComposedRefs } from "@tamagui/compose-refs";
2
- import { isClient, isWeb } from "@tamagui/constants";
3
- import {
4
- createShallowSetState,
5
- getTokens,
6
- getVariableValue,
7
- styled
8
- } from "@tamagui/core";
9
- import { getSize } from "@tamagui/get-token";
10
- import { withStaticProperties } from "@tamagui/helpers";
11
- import { clamp, composeEventHandlers } from "@tamagui/helpers";
12
- import { ThemeableStack } from "@tamagui/stacks";
13
- import { useControllableState } from "@tamagui/use-controllable-state";
14
- import { useDirection } from "@tamagui/use-direction";
15
- import * as React from "react";
16
- import {
17
- ARROW_KEYS,
18
- BACK_KEYS,
19
- PAGE_KEYS,
20
- SLIDER_NAME,
21
- SliderOrientationProvider,
22
- SliderProvider,
23
- useSliderContext,
24
- useSliderOrientationContext
25
- } from "./constants";
26
- import {
27
- convertValueToPercentage,
28
- getClosestValueIndex,
29
- getDecimalCount,
30
- getLabel,
31
- getNextSortedValues,
32
- getThumbInBoundsOffset,
33
- hasMinStepsBetweenValues,
34
- linearScale,
35
- roundValue
36
- } from "./helpers";
37
- import { SliderFrame, SliderImpl } from "./SliderImpl";
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: !0 });
10
+ }, __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from == "object" || typeof from == "function")
12
+ for (let key of __getOwnPropNames(from))
13
+ !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ return to;
15
+ };
16
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
17
+ // If the importer is in node compatibility mode or this is not an ESM
18
+ // file that has been converted to a CommonJS file using a Babel-
19
+ // compatible transform (i.e. "__esModule" has not been set), then set
20
+ // "default" to the CommonJS "module.exports" for node compatibility.
21
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
22
+ mod
23
+ )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
24
+ var Slider_exports = {};
25
+ __export(Slider_exports, {
26
+ Range: () => Range,
27
+ Slider: () => Slider,
28
+ SliderThumb: () => SliderThumb,
29
+ SliderThumbFrame: () => SliderThumbFrame,
30
+ SliderTrack: () => SliderTrack,
31
+ SliderTrackActive: () => SliderTrackActive,
32
+ SliderTrackActiveFrame: () => SliderTrackActiveFrame,
33
+ SliderTrackFrame: () => SliderTrackFrame,
34
+ Thumb: () => Thumb,
35
+ Track: () => Track
36
+ });
37
+ module.exports = __toCommonJS(Slider_exports);
38
+ var import_compose_refs = require("@tamagui/compose-refs"), import_constants = require("@tamagui/constants"), import_core = require("@tamagui/core"), import_get_token = require("@tamagui/get-token"), import_helpers = require("@tamagui/helpers"), import_helpers2 = require("@tamagui/helpers"), import_stacks = require("@tamagui/stacks"), import_use_controllable_state = require("@tamagui/use-controllable-state"), import_use_direction = require("@tamagui/use-direction"), React = __toESM(require("react")), import_constants2 = require("./constants"), import_helpers3 = require("./helpers"), import_SliderImpl = require("./SliderImpl"), import_jsx_runtime = require("react/jsx-runtime");
38
39
  const SliderHorizontal = React.forwardRef(
39
40
  (props, forwardedRef) => {
40
41
  const {
@@ -46,10 +47,10 @@ const SliderHorizontal = React.forwardRef(
46
47
  onStepKeyDown,
47
48
  onSlideEnd,
48
49
  ...sliderProps
49
- } = props, direction = useDirection(dir), isDirectionLTR = direction === "ltr", sliderRef = React.useRef(null), [state, setState_] = React.useState(() => ({ size: 0, offset: 0 })), setState = createShallowSetState(setState_);
50
+ } = props, direction = (0, import_use_direction.useDirection)(dir), isDirectionLTR = direction === "ltr", sliderRef = React.useRef(null), [state, setState_] = React.useState(() => ({ size: 0, offset: 0 })), setState = (0, import_core.createShallowSetState)(setState_);
50
51
  function getValueFromPointer(pointerPosition) {
51
52
  const input = [0, state.size];
52
- return linearScale(input, isDirectionLTR ? [min, max] : [max, min])(pointerPosition);
53
+ return (0, import_helpers3.linearScale)(input, isDirectionLTR ? [min, max] : [max, min])(pointerPosition);
53
54
  }
54
55
  const measure = () => {
55
56
  var _a;
@@ -60,36 +61,43 @@ const SliderHorizontal = React.forwardRef(
60
61
  });
61
62
  });
62
63
  };
63
- return isClient && useOnDebouncedWindowResize(measure), <SliderOrientationProvider
64
- scope={props.__scopeSlider}
65
- startEdge={isDirectionLTR ? "left" : "right"}
66
- endEdge={isDirectionLTR ? "right" : "left"}
67
- direction={isDirectionLTR ? 1 : -1}
68
- sizeProp="width"
69
- size={state.size}
70
- ><SliderImpl
71
- ref={composeRefs(forwardedRef, sliderRef)}
72
- dir={direction}
73
- {...sliderProps}
74
- orientation="horizontal"
75
- onLayout={measure}
76
- onSlideStart={(event, target) => {
77
- const value = getValueFromPointer(event.nativeEvent.locationX);
78
- value && (onSlideStart == null || onSlideStart(value, target, event));
79
- }}
80
- onSlideMove={(event) => {
81
- const value = getValueFromPointer(event.nativeEvent.pageX - state.offset);
82
- value && (onSlideMove == null || onSlideMove(value, event));
83
- }}
84
- onSlideEnd={(event) => {
85
- const value = getValueFromPointer(event.nativeEvent.pageX - state.offset);
86
- value && (onSlideEnd == null || onSlideEnd(event, value));
87
- }}
88
- onStepKeyDown={(event) => {
89
- const isBackKey = BACK_KEYS[direction].includes(event.key);
90
- onStepKeyDown == null || onStepKeyDown({ event, direction: isBackKey ? -1 : 1 });
91
- }}
92
- /></SliderOrientationProvider>;
64
+ return import_constants.isClient && useOnDebouncedWindowResize(measure), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
+ import_constants2.SliderOrientationProvider,
66
+ {
67
+ scope: props.__scopeSlider,
68
+ startEdge: isDirectionLTR ? "left" : "right",
69
+ endEdge: isDirectionLTR ? "right" : "left",
70
+ direction: isDirectionLTR ? 1 : -1,
71
+ sizeProp: "width",
72
+ size: state.size,
73
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
74
+ import_SliderImpl.SliderImpl,
75
+ {
76
+ ref: (0, import_compose_refs.composeRefs)(forwardedRef, sliderRef),
77
+ dir: direction,
78
+ ...sliderProps,
79
+ orientation: "horizontal",
80
+ onLayout: measure,
81
+ onSlideStart: (event, target) => {
82
+ const value = getValueFromPointer(event.nativeEvent.locationX);
83
+ value && (onSlideStart == null || onSlideStart(value, target, event));
84
+ },
85
+ onSlideMove: (event) => {
86
+ const value = getValueFromPointer(event.nativeEvent.pageX - state.offset);
87
+ value && (onSlideMove == null || onSlideMove(value, event));
88
+ },
89
+ onSlideEnd: (event) => {
90
+ const value = getValueFromPointer(event.nativeEvent.pageX - state.offset);
91
+ value && (onSlideEnd == null || onSlideEnd(event, value));
92
+ },
93
+ onStepKeyDown: (event) => {
94
+ const isBackKey = import_constants2.BACK_KEYS[direction].includes(event.key);
95
+ onStepKeyDown == null || onStepKeyDown({ event, direction: isBackKey ? -1 : 1 });
96
+ }
97
+ }
98
+ )
99
+ }
100
+ );
93
101
  }
94
102
  );
95
103
  function useOnDebouncedWindowResize(callback, amt = 200) {
@@ -113,10 +121,10 @@ const SliderVertical = React.forwardRef(
113
121
  onStepKeyDown,
114
122
  onSlideEnd,
115
123
  ...sliderProps
116
- } = props, [state, setState_] = React.useState(() => ({ size: 0, offset: 0 })), setState = createShallowSetState(setState_), sliderRef = React.useRef(null);
124
+ } = props, [state, setState_] = React.useState(() => ({ size: 0, offset: 0 })), setState = (0, import_core.createShallowSetState)(setState_), sliderRef = React.useRef(null);
117
125
  function getValueFromPointer(pointerPosition) {
118
126
  const input = [0, state.size];
119
- return linearScale(input, [max, min])(pointerPosition);
127
+ return (0, import_helpers3.linearScale)(input, [max, min])(pointerPosition);
120
128
  }
121
129
  const measure = () => {
122
130
  var _a;
@@ -127,37 +135,44 @@ const SliderVertical = React.forwardRef(
127
135
  });
128
136
  });
129
137
  };
130
- return isClient && useOnDebouncedWindowResize(measure), <SliderOrientationProvider
131
- scope={props.__scopeSlider}
132
- startEdge="bottom"
133
- endEdge="top"
134
- sizeProp="height"
135
- size={state.size}
136
- direction={1}
137
- ><SliderImpl
138
- ref={composeRefs(forwardedRef, sliderRef)}
139
- {...sliderProps}
140
- orientation="vertical"
141
- onLayout={measure}
142
- onSlideStart={(event, target) => {
143
- const value = getValueFromPointer(event.nativeEvent.locationY);
144
- value && (onSlideStart == null || onSlideStart(value, target, event));
145
- }}
146
- onSlideMove={(event) => {
147
- const value = getValueFromPointer(event.nativeEvent.pageY - state.offset);
148
- value && (onSlideMove == null || onSlideMove(value, event));
149
- }}
150
- onSlideEnd={(event) => {
151
- const value = getValueFromPointer(event.nativeEvent.pageY - state.offset);
152
- onSlideEnd == null || onSlideEnd(event, value);
153
- }}
154
- onStepKeyDown={(event) => {
155
- const isBackKey = BACK_KEYS.ltr.includes(event.key);
156
- onStepKeyDown == null || onStepKeyDown({ event, direction: isBackKey ? -1 : 1 });
157
- }}
158
- /></SliderOrientationProvider>;
138
+ return import_constants.isClient && useOnDebouncedWindowResize(measure), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
139
+ import_constants2.SliderOrientationProvider,
140
+ {
141
+ scope: props.__scopeSlider,
142
+ startEdge: "bottom",
143
+ endEdge: "top",
144
+ sizeProp: "height",
145
+ size: state.size,
146
+ direction: 1,
147
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
148
+ import_SliderImpl.SliderImpl,
149
+ {
150
+ ref: (0, import_compose_refs.composeRefs)(forwardedRef, sliderRef),
151
+ ...sliderProps,
152
+ orientation: "vertical",
153
+ onLayout: measure,
154
+ onSlideStart: (event, target) => {
155
+ const value = getValueFromPointer(event.nativeEvent.locationY);
156
+ value && (onSlideStart == null || onSlideStart(value, target, event));
157
+ },
158
+ onSlideMove: (event) => {
159
+ const value = getValueFromPointer(event.nativeEvent.pageY - state.offset);
160
+ value && (onSlideMove == null || onSlideMove(value, event));
161
+ },
162
+ onSlideEnd: (event) => {
163
+ const value = getValueFromPointer(event.nativeEvent.pageY - state.offset);
164
+ onSlideEnd == null || onSlideEnd(event, value);
165
+ },
166
+ onStepKeyDown: (event) => {
167
+ const isBackKey = import_constants2.BACK_KEYS.ltr.includes(event.key);
168
+ onStepKeyDown == null || onStepKeyDown({ event, direction: isBackKey ? -1 : 1 });
169
+ }
170
+ }
171
+ )
172
+ }
173
+ );
159
174
  }
160
- ), TRACK_NAME = "SliderTrack", SliderTrackFrame = styled(SliderFrame, {
175
+ ), TRACK_NAME = "SliderTrack", SliderTrackFrame = (0, import_core.styled)(import_SliderImpl.SliderFrame, {
161
176
  name: "SliderTrack",
162
177
  variants: {
163
178
  unstyled: {
@@ -176,49 +191,55 @@ const SliderVertical = React.forwardRef(
176
191
  }
177
192
  }), SliderTrack = React.forwardRef(
178
193
  (props, forwardedRef) => {
179
- const { __scopeSlider, ...trackProps } = props, context = useSliderContext(TRACK_NAME, __scopeSlider);
180
- return <SliderTrackFrame
181
- data-disabled={context.disabled ? "" : void 0}
182
- data-orientation={context.orientation}
183
- orientation={context.orientation}
184
- size={context.size}
185
- {...trackProps}
186
- ref={forwardedRef}
187
- />;
194
+ const { __scopeSlider, ...trackProps } = props, context = (0, import_constants2.useSliderContext)(TRACK_NAME, __scopeSlider);
195
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
196
+ SliderTrackFrame,
197
+ {
198
+ "data-disabled": context.disabled ? "" : void 0,
199
+ "data-orientation": context.orientation,
200
+ orientation: context.orientation,
201
+ size: context.size,
202
+ ...trackProps,
203
+ ref: forwardedRef
204
+ }
205
+ );
188
206
  }
189
207
  );
190
208
  SliderTrack.displayName = TRACK_NAME;
191
- const RANGE_NAME = "SliderTrackActive", SliderTrackActiveFrame = styled(SliderFrame, {
209
+ const RANGE_NAME = "SliderTrackActive", SliderTrackActiveFrame = (0, import_core.styled)(import_SliderImpl.SliderFrame, {
192
210
  name: "SliderTrackActive",
193
211
  backgroundColor: "$background",
194
212
  position: "absolute"
195
213
  }), SliderTrackActive = React.forwardRef(
196
214
  (props, forwardedRef) => {
197
- const { __scopeSlider, ...rangeProps } = props, context = useSliderContext(RANGE_NAME, __scopeSlider), orientation = useSliderOrientationContext(RANGE_NAME, __scopeSlider), ref = React.useRef(null), composedRefs = useComposedRefs(forwardedRef, ref), valuesCount = context.values.length, percentages = context.values.map(
198
- (value) => convertValueToPercentage(value, context.min, context.max)
215
+ const { __scopeSlider, ...rangeProps } = props, context = (0, import_constants2.useSliderContext)(RANGE_NAME, __scopeSlider), orientation = (0, import_constants2.useSliderOrientationContext)(RANGE_NAME, __scopeSlider), ref = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(forwardedRef, ref), valuesCount = context.values.length, percentages = context.values.map(
216
+ (value) => (0, import_helpers3.convertValueToPercentage)(value, context.min, context.max)
199
217
  ), offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0, offsetEnd = 100 - Math.max(...percentages);
200
- return <SliderTrackActiveFrame
201
- orientation={context.orientation}
202
- data-orientation={context.orientation}
203
- data-disabled={context.disabled ? "" : void 0}
204
- size={context.size}
205
- animateOnly={["left", "top", "right", "bottom"]}
206
- {...rangeProps}
207
- ref={composedRefs}
208
- {...{ [orientation.startEdge]: `${offsetStart}%` }}
209
- {...{ [orientation.endEdge]: `${offsetEnd}%` }}
210
- {...orientation.sizeProp === "width" ? {
211
- height: "100%"
212
- } : {
213
- left: 0,
214
- right: 0
215
- }}
216
- />;
218
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
219
+ SliderTrackActiveFrame,
220
+ {
221
+ orientation: context.orientation,
222
+ "data-orientation": context.orientation,
223
+ "data-disabled": context.disabled ? "" : void 0,
224
+ size: context.size,
225
+ animateOnly: ["left", "top", "right", "bottom"],
226
+ ...rangeProps,
227
+ ref: composedRefs,
228
+ [orientation.startEdge]: `${offsetStart}%`,
229
+ [orientation.endEdge]: `${offsetEnd}%`,
230
+ ...orientation.sizeProp === "width" ? {
231
+ height: "100%"
232
+ } : {
233
+ left: 0,
234
+ right: 0
235
+ }
236
+ }
237
+ );
217
238
  }
218
239
  );
219
240
  SliderTrackActive.displayName = RANGE_NAME;
220
241
  const THUMB_NAME = "SliderThumb", getThumbSize = (val) => {
221
- const tokens = getTokens(), size = typeof val == "number" ? val : getSize(tokens.size[val], {
242
+ const tokens = (0, import_core.getTokens)(), size = typeof val == "number" ? val : (0, import_get_token.getSize)(tokens.size[val], {
222
243
  shift: -1
223
244
  });
224
245
  return {
@@ -227,7 +248,7 @@ const THUMB_NAME = "SliderThumb", getThumbSize = (val) => {
227
248
  minWidth: size,
228
249
  minHeight: size
229
250
  };
230
- }, SliderThumbFrame = styled(ThemeableStack, {
251
+ }, SliderThumbFrame = (0, import_core.styled)(import_stacks.ThemeableStack, {
231
252
  name: "SliderThumb",
232
253
  variants: {
233
254
  size: {
@@ -239,9 +260,9 @@ const THUMB_NAME = "SliderThumb", getThumbSize = (val) => {
239
260
  bordered: 2,
240
261
  borderWidth: 2,
241
262
  backgrounded: !0,
242
- pressTheme: isWeb,
243
- focusTheme: isWeb,
244
- hoverTheme: isWeb
263
+ pressTheme: import_constants.isWeb,
264
+ focusTheme: import_constants.isWeb,
265
+ hoverTheme: import_constants.isWeb
245
266
  }
246
267
  }
247
268
  },
@@ -250,10 +271,10 @@ const THUMB_NAME = "SliderThumb", getThumbSize = (val) => {
250
271
  }
251
272
  }), SliderThumb = React.memo(
252
273
  SliderThumbFrame.styleable(function(props, forwardedRef) {
253
- const { __scopeSlider, index, size: sizeProp, ...thumbProps } = props, context = useSliderContext(THUMB_NAME, __scopeSlider), orientation = useSliderOrientationContext(THUMB_NAME, __scopeSlider), [thumb, setThumb] = React.useState(null), composedRefs = useComposedRefs(
274
+ const { __scopeSlider, index, size: sizeProp, ...thumbProps } = props, context = (0, import_constants2.useSliderContext)(THUMB_NAME, __scopeSlider), orientation = (0, import_constants2.useSliderOrientationContext)(THUMB_NAME, __scopeSlider), [thumb, setThumb] = React.useState(null), composedRefs = (0, import_compose_refs.useComposedRefs)(
254
275
  forwardedRef,
255
276
  (node) => setThumb(node)
256
- ), value = context.values[index], percent = value === void 0 ? 0 : convertValueToPercentage(value, context.min, context.max), label = getLabel(index, context.values.length), sizeIn = sizeProp ?? context.size ?? "$true", [size, setSize] = React.useState(() => getVariableValue(getThumbSize(sizeIn).width)), thumbInBoundsOffset = size ? getThumbInBoundsOffset(size, percent, orientation.direction) : 0;
277
+ ), value = context.values[index], percent = value === void 0 ? 0 : (0, import_helpers3.convertValueToPercentage)(value, context.min, context.max), label = (0, import_helpers3.getLabel)(index, context.values.length), sizeIn = sizeProp ?? context.size ?? "$true", [size, setSize] = React.useState(() => (0, import_core.getVariableValue)(getThumbSize(sizeIn).width)), thumbInBoundsOffset = size ? (0, import_helpers3.getThumbInBoundsOffset)(size, percent, orientation.direction) : 0;
257
278
  React.useEffect(() => {
258
279
  if (thumb)
259
280
  return context.thumbs.set(thumb, index), () => {
@@ -277,29 +298,32 @@ const THUMB_NAME = "SliderThumb", getThumbSize = (val) => {
277
298
  right: "auto"
278
299
  }
279
300
  };
280
- return <SliderThumbFrame
281
- ref={composedRefs}
282
- role="slider"
283
- aria-label={props["aria-label"] || label}
284
- aria-valuemin={context.min}
285
- aria-valuenow={value}
286
- aria-valuemax={context.max}
287
- aria-orientation={context.orientation}
288
- data-orientation={context.orientation}
289
- data-disabled={context.disabled ? "" : void 0}
290
- tabIndex={context.disabled ? void 0 : 0}
291
- animateOnly={["transform", "left", "top", "right", "bottom"]}
292
- {...positionalStyles}
293
- {...{ [orientation.startEdge]: `${percent}%` }}
294
- size={sizeIn}
295
- {...thumbProps}
296
- onLayout={(e) => {
297
- setSize(e.nativeEvent.layout[orientation.sizeProp]);
298
- }}
299
- onFocus={composeEventHandlers(props.onFocus, () => {
300
- context.valueIndexToChangeRef.current = index;
301
- })}
302
- />;
301
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
302
+ SliderThumbFrame,
303
+ {
304
+ ref: composedRefs,
305
+ role: "slider",
306
+ "aria-label": props["aria-label"] || label,
307
+ "aria-valuemin": context.min,
308
+ "aria-valuenow": value,
309
+ "aria-valuemax": context.max,
310
+ "aria-orientation": context.orientation,
311
+ "data-orientation": context.orientation,
312
+ "data-disabled": context.disabled ? "" : void 0,
313
+ tabIndex: context.disabled ? void 0 : 0,
314
+ animateOnly: ["transform", "left", "top", "right", "bottom"],
315
+ ...positionalStyles,
316
+ [orientation.startEdge]: `${percent}%`,
317
+ size: sizeIn,
318
+ ...thumbProps,
319
+ onLayout: (e) => {
320
+ setSize(e.nativeEvent.layout[orientation.sizeProp]);
321
+ },
322
+ onFocus: (0, import_helpers2.composeEventHandlers)(props.onFocus, () => {
323
+ context.valueIndexToChangeRef.current = index;
324
+ })
325
+ }
326
+ );
303
327
  })
304
328
  ), SliderComponent = React.forwardRef(
305
329
  (props, forwardedRef) => {
@@ -320,7 +344,7 @@ const THUMB_NAME = "SliderThumb", getThumbSize = (val) => {
320
344
  onSlideMove,
321
345
  onSlideStart,
322
346
  ...sliderProps
323
- } = props, sliderRef = React.useRef(null), composedRefs = useComposedRefs(sliderRef, forwardedRef), thumbRefs = React.useRef(/* @__PURE__ */ new Map()), valueIndexToChangeRef = React.useRef(0), isHorizontal = orientation === "horizontal", [values = [], setValues] = useControllableState({
347
+ } = props, sliderRef = React.useRef(null), composedRefs = (0, import_compose_refs.useComposedRefs)(sliderRef, forwardedRef), thumbRefs = React.useRef(/* @__PURE__ */ new Map()), valueIndexToChangeRef = React.useRef(0), isHorizontal = orientation === "horizontal", [values = [], setValues] = (0, import_use_controllable_state.useControllableState)({
324
348
  prop: value,
325
349
  defaultProp: defaultValue,
326
350
  transition: !0,
@@ -328,7 +352,7 @@ const THUMB_NAME = "SliderThumb", getThumbSize = (val) => {
328
352
  updateThumbFocus(valueIndexToChangeRef.current), onValueChange(value2);
329
353
  }
330
354
  });
331
- isWeb && React.useEffect(() => {
355
+ import_constants.isWeb && React.useEffect(() => {
332
356
  const node = sliderRef.current;
333
357
  if (!node)
334
358
  return;
@@ -340,7 +364,7 @@ const THUMB_NAME = "SliderThumb", getThumbSize = (val) => {
340
364
  };
341
365
  }, []);
342
366
  function updateThumbFocus(focusIndex) {
343
- if (isWeb) {
367
+ if (import_constants.isWeb) {
344
368
  for (const [node, index] of thumbRefs.current.entries())
345
369
  if (index === focusIndex) {
346
370
  node.focus();
@@ -352,72 +376,68 @@ const THUMB_NAME = "SliderThumb", getThumbSize = (val) => {
352
376
  updateValues(value2, valueIndexToChangeRef.current), onSlideMove == null || onSlideMove(event, value2);
353
377
  }
354
378
  function updateValues(value2, atIndex) {
355
- const decimalCount = getDecimalCount(step), snapToStep = roundValue(
379
+ const decimalCount = (0, import_helpers3.getDecimalCount)(step), snapToStep = (0, import_helpers3.roundValue)(
356
380
  Math.round((value2 - min) / step) * step + min,
357
381
  decimalCount
358
- ), nextValue = clamp(snapToStep, [min, max]);
382
+ ), nextValue = (0, import_helpers2.clamp)(snapToStep, [min, max]);
359
383
  setValues((prevValues = []) => {
360
- const nextValues = getNextSortedValues(prevValues, nextValue, atIndex);
361
- return hasMinStepsBetweenValues(nextValues, minStepsBetweenThumbs * step) ? (valueIndexToChangeRef.current = nextValues.indexOf(nextValue), String(nextValues) === String(prevValues) ? prevValues : nextValues) : prevValues;
384
+ const nextValues = (0, import_helpers3.getNextSortedValues)(prevValues, nextValue, atIndex);
385
+ return (0, import_helpers3.hasMinStepsBetweenValues)(nextValues, minStepsBetweenThumbs * step) ? (valueIndexToChangeRef.current = nextValues.indexOf(nextValue), String(nextValues) === String(prevValues) ? prevValues : nextValues) : prevValues;
362
386
  });
363
387
  }
364
388
  const SliderOriented = isHorizontal ? SliderHorizontal : SliderVertical;
365
- return <SliderProvider
366
- scope={props.__scopeSlider}
367
- disabled={disabled}
368
- min={min}
369
- max={max}
370
- valueIndexToChangeRef={valueIndexToChangeRef}
371
- thumbs={thumbRefs.current}
372
- values={values}
373
- orientation={orientation}
374
- size={sizeProp}
375
- >
376
- <SliderOriented
377
- aria-disabled={disabled}
378
- data-disabled={disabled ? "" : void 0}
379
- {...sliderProps}
380
- ref={composedRefs}
381
- min={min}
382
- max={max}
383
- onSlideEnd={onSlideEnd}
384
- onSlideStart={disabled ? void 0 : (value2, target, event) => {
385
- if (target !== "thumb") {
386
- const closestIndex = getClosestValueIndex(values, value2);
387
- updateValues(value2, closestIndex);
388
- }
389
- onSlideStart == null || onSlideStart(event, value2, target);
390
- }}
391
- onSlideMove={disabled ? void 0 : handleSlideMove}
392
- onHomeKeyDown={() => !disabled && updateValues(min, 0)}
393
- onEndKeyDown={() => !disabled && updateValues(max, values.length - 1)}
394
- onStepKeyDown={({ event, direction: stepDirection }) => {
395
- if (!disabled) {
396
- const multiplier = PAGE_KEYS.includes(event.key) || event.shiftKey && ARROW_KEYS.includes(event.key) ? 10 : 1, atIndex = valueIndexToChangeRef.current, value2 = values[atIndex], stepInDirection = step * multiplier * stepDirection;
397
- updateValues(value2 + stepInDirection, atIndex);
398
- }
399
- }}
400
- />
389
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
390
+ import_constants2.SliderProvider,
401
391
  {
402
- /* {isFormControl &&
403
- values.map((value, index) => (
404
- <BubbleInput
405
- key={index}
406
- name={name ? name + (values.length > 1 ? '[]' : '') : undefined}
407
- value={value}
408
- />
409
- ))} */
392
+ scope: props.__scopeSlider,
393
+ disabled,
394
+ min,
395
+ max,
396
+ valueIndexToChangeRef,
397
+ thumbs: thumbRefs.current,
398
+ values,
399
+ orientation,
400
+ size: sizeProp,
401
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
402
+ SliderOriented,
403
+ {
404
+ "aria-disabled": disabled,
405
+ "data-disabled": disabled ? "" : void 0,
406
+ ...sliderProps,
407
+ ref: composedRefs,
408
+ min,
409
+ max,
410
+ onSlideEnd,
411
+ onSlideStart: disabled ? void 0 : (value2, target, event) => {
412
+ if (target !== "thumb") {
413
+ const closestIndex = (0, import_helpers3.getClosestValueIndex)(values, value2);
414
+ updateValues(value2, closestIndex);
415
+ }
416
+ onSlideStart == null || onSlideStart(event, value2, target);
417
+ },
418
+ onSlideMove: disabled ? void 0 : handleSlideMove,
419
+ onHomeKeyDown: () => !disabled && updateValues(min, 0),
420
+ onEndKeyDown: () => !disabled && updateValues(max, values.length - 1),
421
+ onStepKeyDown: ({ event, direction: stepDirection }) => {
422
+ if (!disabled) {
423
+ const multiplier = import_constants2.PAGE_KEYS.includes(event.key) || event.shiftKey && import_constants2.ARROW_KEYS.includes(event.key) ? 10 : 1, atIndex = valueIndexToChangeRef.current, value2 = values[atIndex], stepInDirection = step * multiplier * stepDirection;
424
+ updateValues(value2 + stepInDirection, atIndex);
425
+ }
426
+ }
427
+ }
428
+ )
410
429
  }
411
- </SliderProvider>;
430
+ );
412
431
  }
413
- ), Slider = withStaticProperties(SliderComponent, {
432
+ ), Slider = (0, import_helpers.withStaticProperties)(SliderComponent, {
414
433
  Track: SliderTrack,
415
434
  TrackActive: SliderTrackActive,
416
435
  Thumb: SliderThumb
417
436
  });
418
- Slider.displayName = SLIDER_NAME;
437
+ Slider.displayName = import_constants2.SLIDER_NAME;
419
438
  const Track = SliderTrack, Range = SliderTrackActive, Thumb = SliderThumb;
420
- export {
439
+ // Annotate the CommonJS export names for ESM import in node:
440
+ 0 && (module.exports = {
421
441
  Range,
422
442
  Slider,
423
443
  SliderThumb,
@@ -428,5 +448,5 @@ export {
428
448
  SliderTrackFrame,
429
449
  Thumb,
430
450
  Track
431
- };
451
+ });
432
452
  //# sourceMappingURL=Slider.js.map