@react-aria/slider 3.0.0-alpha.3 → 3.0.0-nightly-4980928d3-240906
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/import.mjs +19 -0
- package/dist/main.js +16 -348
- package/dist/main.js.map +1 -1
- package/dist/module.js +14 -320
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +32 -18
- package/dist/types.d.ts.map +1 -1
- package/dist/useSlider.main.js +174 -0
- package/dist/useSlider.main.js.map +1 -0
- package/dist/useSlider.mjs +169 -0
- package/dist/useSlider.module.js +169 -0
- package/dist/useSlider.module.js.map +1 -0
- package/dist/useSliderThumb.main.js +196 -0
- package/dist/useSliderThumb.main.js.map +1 -0
- package/dist/useSliderThumb.mjs +191 -0
- package/dist/useSliderThumb.module.js +191 -0
- package/dist/useSliderThumb.module.js.map +1 -0
- package/dist/utils.main.js +16 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +10 -0
- package/dist/utils.module.js +10 -0
- package/dist/utils.module.js.map +1 -0
- package/package.json +18 -14
- package/src/index.ts +7 -3
- package/src/useSlider.ts +89 -33
- package/src/useSliderThumb.ts +141 -44
- package/src/utils.ts +16 -1
- package/LICENSE +0 -201
package/dist/import.mjs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {useSlider as $bcca50147b47f54d$export$56b2c08e277f365} from "./useSlider.mjs";
|
|
2
|
+
import {useSliderThumb as $47b897dc8cdb026b$export$8d15029008292ae} from "./useSliderThumb.mjs";
|
|
3
|
+
|
|
4
|
+
/*
|
|
5
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
6
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
8
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
11
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
12
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
13
|
+
* governing permissions and limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
export {$bcca50147b47f54d$export$56b2c08e277f365 as useSlider, $47b897dc8cdb026b$export$8d15029008292ae as useSliderThumb};
|
|
19
|
+
//# sourceMappingURL=module.js.map
|
package/dist/main.js
CHANGED
|
@@ -1,357 +1,25 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
} = require("@react-aria/focus");
|
|
1
|
+
var $481f97d830e3ede6$exports = require("./useSlider.main.js");
|
|
2
|
+
var $5eb806b626475377$exports = require("./useSliderThumb.main.js");
|
|
4
3
|
|
|
5
|
-
var {
|
|
6
|
-
useMove
|
|
7
|
-
} = require("@react-aria/interactions");
|
|
8
4
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} = require("@react-aria/i18n");
|
|
12
|
-
|
|
13
|
-
var {
|
|
14
|
-
useLabel
|
|
15
|
-
} = require("@react-aria/label");
|
|
16
|
-
|
|
17
|
-
var {
|
|
18
|
-
useRef,
|
|
19
|
-
useCallback,
|
|
20
|
-
useEffect
|
|
21
|
-
} = require("react");
|
|
22
|
-
|
|
23
|
-
var {
|
|
24
|
-
clamp,
|
|
25
|
-
mergeProps,
|
|
26
|
-
useGlobalListeners,
|
|
27
|
-
focusWithoutScrolling
|
|
28
|
-
} = require("@react-aria/utils");
|
|
29
|
-
|
|
30
|
-
var _babelRuntimeHelpersExtends = $parcel$interopDefault(require("@babel/runtime/helpers/extends"));
|
|
31
|
-
|
|
32
|
-
function $parcel$interopDefault(a) {
|
|
33
|
-
return a && a.__esModule ? a.default : a;
|
|
5
|
+
function $parcel$export(e, n, v, s) {
|
|
6
|
+
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
34
7
|
}
|
|
35
8
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
*
|
|
9
|
+
$parcel$export(module.exports, "useSlider", () => $481f97d830e3ede6$exports.useSlider);
|
|
10
|
+
$parcel$export(module.exports, "useSliderThumb", () => $5eb806b626475377$exports.useSliderThumb);
|
|
11
|
+
/*
|
|
12
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
40
16
|
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
|
|
46
|
-
* the track.
|
|
47
|
-
*/
|
|
48
|
-
function useSlider(props, state, trackRef) {
|
|
49
|
-
var _labelProps$id;
|
|
50
|
-
|
|
51
|
-
let {
|
|
52
|
-
labelProps,
|
|
53
|
-
fieldProps
|
|
54
|
-
} = useLabel(props);
|
|
55
|
-
let isVertical = props.orientation === 'vertical'; // Attach id of the label to the state so it can be accessed by useSliderThumb.
|
|
56
|
-
|
|
57
|
-
$dec1906781d9c7cb69245fc4d5344b$export$sliderIds.set(state, (_labelProps$id = labelProps.id) != null ? _labelProps$id : fieldProps.id);
|
|
58
|
-
let {
|
|
59
|
-
direction
|
|
60
|
-
} = useLocale();
|
|
61
|
-
let {
|
|
62
|
-
addGlobalListener,
|
|
63
|
-
removeGlobalListener
|
|
64
|
-
} = useGlobalListeners(); // When the user clicks or drags the track, we want the motion to set and drag the
|
|
65
|
-
// closest thumb. Hence we also need to install useMove() on the track element.
|
|
66
|
-
// Here, we keep track of which index is the "closest" to the drag start point.
|
|
67
|
-
// It is set onMouseDown/onTouchDown; see trackProps below.
|
|
68
|
-
|
|
69
|
-
const realTimeTrackDraggingIndex = useRef(null);
|
|
70
|
-
const stateRef = useRef(null);
|
|
71
|
-
stateRef.current = state;
|
|
72
|
-
const reverseX = direction === 'rtl';
|
|
73
|
-
const currentPosition = useRef(null);
|
|
74
|
-
const {
|
|
75
|
-
moveProps
|
|
76
|
-
} = useMove({
|
|
77
|
-
onMoveStart() {
|
|
78
|
-
currentPosition.current = null;
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
onMove(_ref) {
|
|
82
|
-
let {
|
|
83
|
-
deltaX,
|
|
84
|
-
deltaY
|
|
85
|
-
} = _ref;
|
|
86
|
-
let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth;
|
|
87
|
-
|
|
88
|
-
if (currentPosition.current == null) {
|
|
89
|
-
currentPosition.current = stateRef.current.getThumbPercent(realTimeTrackDraggingIndex.current) * size;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
let delta = isVertical ? deltaY : deltaX;
|
|
93
|
-
|
|
94
|
-
if (isVertical || reverseX) {
|
|
95
|
-
delta = -delta;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
currentPosition.current += delta;
|
|
99
|
-
|
|
100
|
-
if (realTimeTrackDraggingIndex.current != null && trackRef.current) {
|
|
101
|
-
const percent = clamp(currentPosition.current / size, 0, 1);
|
|
102
|
-
stateRef.current.setThumbPercent(realTimeTrackDraggingIndex.current, percent);
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
onMoveEnd() {
|
|
107
|
-
if (realTimeTrackDraggingIndex.current != null) {
|
|
108
|
-
stateRef.current.setThumbDragging(realTimeTrackDraggingIndex.current, false);
|
|
109
|
-
realTimeTrackDraggingIndex.current = null;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
});
|
|
114
|
-
let currentPointer = useRef(undefined);
|
|
115
|
-
|
|
116
|
-
let onDownTrack = (e, id, clientX, clientY) => {
|
|
117
|
-
// We only trigger track-dragging if the user clicks on the track itself and nothing is currently being dragged.
|
|
118
|
-
if (trackRef.current && !props.isDisabled && state.values.every((_, i) => !state.isThumbDragging(i))) {
|
|
119
|
-
let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth; // Find the closest thumb
|
|
120
|
-
|
|
121
|
-
const trackPosition = trackRef.current.getBoundingClientRect()[isVertical ? 'top' : 'left'];
|
|
122
|
-
const clickPosition = isVertical ? clientY : clientX;
|
|
123
|
-
const offset = clickPosition - trackPosition;
|
|
124
|
-
let percent = offset / size;
|
|
125
|
-
|
|
126
|
-
if (direction === 'rtl' || isVertical) {
|
|
127
|
-
percent = 1 - percent;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
let value = state.getPercentValue(percent); // Only compute the diff for thumbs that are editable, as only they can be dragged
|
|
131
|
-
|
|
132
|
-
const minDiff = Math.min(...state.values.map((v, index) => state.isThumbEditable(index) ? Math.abs(v - value) : Number.POSITIVE_INFINITY));
|
|
133
|
-
const index = state.values.findIndex(v => Math.abs(v - value) === minDiff);
|
|
134
|
-
|
|
135
|
-
if (minDiff !== Number.POSITIVE_INFINITY && index >= 0) {
|
|
136
|
-
// Don't unfocus anything
|
|
137
|
-
e.preventDefault();
|
|
138
|
-
realTimeTrackDraggingIndex.current = index;
|
|
139
|
-
state.setFocusedThumb(index);
|
|
140
|
-
currentPointer.current = id;
|
|
141
|
-
state.setThumbDragging(realTimeTrackDraggingIndex.current, true);
|
|
142
|
-
state.setThumbValue(index, value);
|
|
143
|
-
addGlobalListener(window, 'mouseup', onUpTrack, false);
|
|
144
|
-
addGlobalListener(window, 'touchend', onUpTrack, false);
|
|
145
|
-
addGlobalListener(window, 'pointerup', onUpTrack, false);
|
|
146
|
-
} else {
|
|
147
|
-
realTimeTrackDraggingIndex.current = null;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
let onUpTrack = e => {
|
|
153
|
-
var _e$pointerId, _e$changedTouches;
|
|
154
|
-
|
|
155
|
-
let id = (_e$pointerId = e.pointerId) != null ? _e$pointerId : (_e$changedTouches = e.changedTouches) == null ? void 0 : _e$changedTouches[0].identifier;
|
|
17
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
+
* governing permissions and limitations under the License.
|
|
21
|
+
*/
|
|
156
22
|
|
|
157
|
-
if (id === currentPointer.current) {
|
|
158
|
-
if (realTimeTrackDraggingIndex.current != null) {
|
|
159
|
-
state.setThumbDragging(realTimeTrackDraggingIndex.current, false);
|
|
160
|
-
realTimeTrackDraggingIndex.current = null;
|
|
161
|
-
}
|
|
162
23
|
|
|
163
|
-
removeGlobalListener(window, 'mouseup', onUpTrack, false);
|
|
164
|
-
removeGlobalListener(window, 'touchend', onUpTrack, false);
|
|
165
|
-
removeGlobalListener(window, 'pointerup', onUpTrack, false);
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
labelProps,
|
|
171
|
-
// The root element of the Slider will have role="group" to group together
|
|
172
|
-
// all the thumb inputs in the Slider. The label of the Slider will
|
|
173
|
-
// be used to label the group.
|
|
174
|
-
containerProps: _babelRuntimeHelpersExtends({
|
|
175
|
-
role: 'group'
|
|
176
|
-
}, fieldProps),
|
|
177
|
-
trackProps: mergeProps({
|
|
178
|
-
onMouseDown(e) {
|
|
179
|
-
onDownTrack(e, undefined, e.clientX, e.clientY);
|
|
180
|
-
},
|
|
181
|
-
|
|
182
|
-
onPointerDown(e) {
|
|
183
|
-
onDownTrack(e, e.pointerId, e.clientX, e.clientY);
|
|
184
|
-
},
|
|
185
|
-
|
|
186
|
-
onTouchStart(e) {
|
|
187
|
-
onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
}, moveProps)
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
exports.useSlider = useSlider;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Provides behavior and accessibility for a thumb of a slider component.
|
|
198
|
-
*
|
|
199
|
-
* @param opts Options for this Slider thumb.
|
|
200
|
-
* @param state Slider state, created via `useSliderState`.
|
|
201
|
-
*/
|
|
202
|
-
function useSliderThumb(opts, state) {
|
|
203
|
-
var _opts$ariaLabelledby;
|
|
204
|
-
|
|
205
|
-
let {
|
|
206
|
-
index,
|
|
207
|
-
isRequired,
|
|
208
|
-
isDisabled,
|
|
209
|
-
validationState,
|
|
210
|
-
trackRef,
|
|
211
|
-
inputRef
|
|
212
|
-
} = opts;
|
|
213
|
-
let isVertical = opts.orientation === 'vertical';
|
|
214
|
-
let {
|
|
215
|
-
direction
|
|
216
|
-
} = useLocale();
|
|
217
|
-
let {
|
|
218
|
-
addGlobalListener,
|
|
219
|
-
removeGlobalListener
|
|
220
|
-
} = useGlobalListeners();
|
|
221
|
-
let labelId = $dec1906781d9c7cb69245fc4d5344b$export$sliderIds.get(state);
|
|
222
|
-
const {
|
|
223
|
-
labelProps,
|
|
224
|
-
fieldProps
|
|
225
|
-
} = useLabel(_babelRuntimeHelpersExtends({}, opts, {
|
|
226
|
-
'aria-labelledby': (labelId + " " + ((_opts$ariaLabelledby = opts['aria-labelledby']) != null ? _opts$ariaLabelledby : '')).trim()
|
|
227
|
-
}));
|
|
228
|
-
const value = state.values[index];
|
|
229
|
-
const focusInput = useCallback(() => {
|
|
230
|
-
if (inputRef.current) {
|
|
231
|
-
focusWithoutScrolling(inputRef.current);
|
|
232
|
-
}
|
|
233
|
-
}, [inputRef]);
|
|
234
|
-
const isFocused = state.focusedThumb === index;
|
|
235
|
-
useEffect(() => {
|
|
236
|
-
if (isFocused) {
|
|
237
|
-
focusInput();
|
|
238
|
-
}
|
|
239
|
-
}, [isFocused, focusInput]);
|
|
240
|
-
const stateRef = useRef(null);
|
|
241
|
-
stateRef.current = state;
|
|
242
|
-
let reverseX = direction === 'rtl';
|
|
243
|
-
let currentPosition = useRef(null);
|
|
244
|
-
let {
|
|
245
|
-
moveProps
|
|
246
|
-
} = useMove({
|
|
247
|
-
onMoveStart() {
|
|
248
|
-
currentPosition.current = null;
|
|
249
|
-
state.setThumbDragging(index, true);
|
|
250
|
-
},
|
|
251
|
-
|
|
252
|
-
onMove(_ref) {
|
|
253
|
-
let {
|
|
254
|
-
deltaX,
|
|
255
|
-
deltaY,
|
|
256
|
-
pointerType
|
|
257
|
-
} = _ref;
|
|
258
|
-
let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth;
|
|
259
|
-
|
|
260
|
-
if (currentPosition.current == null) {
|
|
261
|
-
currentPosition.current = stateRef.current.getThumbPercent(index) * size;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
if (pointerType === 'keyboard') {
|
|
265
|
-
// (invert left/right according to language direction) + (according to vertical)
|
|
266
|
-
let delta = ((reverseX ? -deltaX : deltaX) + (isVertical ? -deltaY : -deltaY)) * stateRef.current.step;
|
|
267
|
-
currentPosition.current += delta * size;
|
|
268
|
-
stateRef.current.setThumbValue(index, stateRef.current.getThumbValue(index) + delta);
|
|
269
|
-
} else {
|
|
270
|
-
let delta = isVertical ? deltaY : deltaX;
|
|
271
|
-
|
|
272
|
-
if (isVertical || reverseX) {
|
|
273
|
-
delta = -delta;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
currentPosition.current += delta;
|
|
277
|
-
stateRef.current.setThumbPercent(index, clamp(currentPosition.current / size, 0, 1));
|
|
278
|
-
}
|
|
279
|
-
},
|
|
280
|
-
|
|
281
|
-
onMoveEnd() {
|
|
282
|
-
state.setThumbDragging(index, false);
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
}); // Immediately register editability with the state
|
|
286
|
-
|
|
287
|
-
state.setThumbEditable(index, !isDisabled);
|
|
288
|
-
const {
|
|
289
|
-
focusableProps
|
|
290
|
-
} = useFocusable(mergeProps(opts, {
|
|
291
|
-
onFocus: () => state.setFocusedThumb(index),
|
|
292
|
-
onBlur: () => state.setFocusedThumb(undefined)
|
|
293
|
-
}), inputRef);
|
|
294
|
-
let currentPointer = useRef(undefined);
|
|
295
|
-
|
|
296
|
-
let onDown = id => {
|
|
297
|
-
focusInput();
|
|
298
|
-
currentPointer.current = id;
|
|
299
|
-
state.setThumbDragging(index, true);
|
|
300
|
-
addGlobalListener(window, 'mouseup', onUp, false);
|
|
301
|
-
addGlobalListener(window, 'touchend', onUp, false);
|
|
302
|
-
addGlobalListener(window, 'pointerup', onUp, false);
|
|
303
|
-
};
|
|
304
|
-
|
|
305
|
-
let onUp = e => {
|
|
306
|
-
var _e$pointerId, _e$changedTouches;
|
|
307
|
-
|
|
308
|
-
let id = (_e$pointerId = e.pointerId) != null ? _e$pointerId : (_e$changedTouches = e.changedTouches) == null ? void 0 : _e$changedTouches[0].identifier;
|
|
309
|
-
|
|
310
|
-
if (id === currentPointer.current) {
|
|
311
|
-
focusInput();
|
|
312
|
-
state.setThumbDragging(index, false);
|
|
313
|
-
removeGlobalListener(window, 'mouseup', onUp, false);
|
|
314
|
-
removeGlobalListener(window, 'touchend', onUp, false);
|
|
315
|
-
removeGlobalListener(window, 'pointerup', onUp, false);
|
|
316
|
-
}
|
|
317
|
-
}; // We install mouse handlers for the drag motion on the thumb div, but
|
|
318
|
-
// not the key handler for moving the thumb with the slider. Instead,
|
|
319
|
-
// we focus the range input, and let the browser handle the keyboard
|
|
320
|
-
// interactions; we then listen to input's onChange to update state.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
return {
|
|
324
|
-
inputProps: mergeProps(focusableProps, fieldProps, {
|
|
325
|
-
type: 'range',
|
|
326
|
-
tabIndex: !isDisabled ? 0 : undefined,
|
|
327
|
-
min: state.getThumbMinValue(index),
|
|
328
|
-
max: state.getThumbMaxValue(index),
|
|
329
|
-
step: state.step,
|
|
330
|
-
value: value,
|
|
331
|
-
disabled: isDisabled,
|
|
332
|
-
'aria-orientation': opts.orientation,
|
|
333
|
-
'aria-valuetext': state.getThumbValueLabel(index),
|
|
334
|
-
'aria-required': isRequired || undefined,
|
|
335
|
-
'aria-invalid': validationState === 'invalid' || undefined,
|
|
336
|
-
'aria-errormessage': opts['aria-errormessage'],
|
|
337
|
-
onChange: e => {
|
|
338
|
-
state.setThumbValue(index, parseFloat(e.target.value));
|
|
339
|
-
}
|
|
340
|
-
}),
|
|
341
|
-
thumbProps: !isDisabled ? mergeProps(moveProps, {
|
|
342
|
-
onMouseDown: () => {
|
|
343
|
-
onDown(null);
|
|
344
|
-
},
|
|
345
|
-
onPointerDown: e => {
|
|
346
|
-
onDown(e.pointerId);
|
|
347
|
-
},
|
|
348
|
-
onTouchStart: e => {
|
|
349
|
-
onDown(e.changedTouches[0].identifier);
|
|
350
|
-
}
|
|
351
|
-
}) : {},
|
|
352
|
-
labelProps
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
24
|
|
|
356
|
-
exports.useSliderThumb = useSliderThumb;
|
|
357
25
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAASA,sBAAT,CAAgCC,CAAhC,EAAmC;AACjC,SAAOA,CAAC,IAAIA,CAAC,CAACC,UAAP,GAAoBD,CAAC,CAACE,OAAtB,GAAgCF,CAAvC;AACD;;ACAM,MAAMG,gDAAS,GAAG,IAAIC,OAAJ,EAAlB;;AC8BP;;;;;;;;;;AAUO,SAASC,SAAT,CACLC,KADK,EAELC,KAFK,EAGLC,QAHK,EAIO;AAAA;;AACZ,MAAI;AAACC,IAAAA,UAAD;AAAaC,IAAAA;AAAb,MAA2BC,QAAQ,CAACL,KAAD,CAAvC;AAEA,MAAIM,UAAU,GAAGN,KAAK,CAACO,WAAN,KAAsB,UAAvC,CAHY,CAKZ;;AACA,mDAAUC,GAAV,CAAcP,KAAd,oBAAqBE,UAAU,CAACM,EAAhC,6BAAsCL,UAAU,CAACK,EAAjD;AAEA,MAAI;AAACC,IAAAA;AA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A4BD","sources":["./node_modules/@parcel/scope-hoisting/lib/helpers.js","./packages/@react-aria/slider/src/utils.ts","./packages/@react-aria/slider/src/useSlider.ts","./packages/@react-aria/slider/src/useSliderThumb.ts"],"sourcesContent":["function $parcel$interopDefault(a) {\n return a && a.__esModule ? a.default : a;\n}\n\nfunction $parcel$defineInteropFlag(a) {\n Object.defineProperty(a, '__esModule', {value: true});\n}\n\nfunction $parcel$exportWildcard(dest, source) {\n Object.keys(source).forEach(function(key) {\n if (key === 'default' || key === '__esModule') {\n return;\n }\n\n Object.defineProperty(dest, key, {\n enumerable: true,\n get: function get() {\n return source[key];\n },\n });\n });\n\n return dest;\n}\n\nfunction $parcel$missingModule(name) {\n var err = new Error(\"Cannot find module '\" + name + \"'\");\n err.code = 'MODULE_NOT_FOUND';\n throw err;\n}\n\nvar $parcel$global =\n typeof globalThis !== 'undefined'\n ? globalThis\n : typeof self !== 'undefined'\n ? self\n : typeof window !== 'undefined'\n ? window\n : typeof global !== 'undefined'\n ? global\n : {};\n","import {SliderState} from '@react-stately/slider';\n\nexport const sliderIds = new WeakMap<SliderState, string>();\n","/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {clamp, mergeProps, useGlobalListeners} from '@react-aria/utils';\nimport React, {HTMLAttributes, useRef} from 'react';\nimport {sliderIds} from './utils';\nimport {SliderProps} from '@react-types/slider';\nimport {SliderState} from '@react-stately/slider';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\nimport {useMove} from '@react-aria/interactions';\n\ninterface SliderAria {\n /** Props for the label element. */\n labelProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the root element of the slider component; groups slider inputs. */\n containerProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the track element. */\n trackProps: HTMLAttributes<HTMLElement>\n}\n\n/**\n * Provides behavior and accessibility for a slider component.\n *\n * @param props Props for the slider.\n * @param state State for the slider, as returned by `useSliderState`.\n * @param trackRef Ref for the \"track\" element. The width of this element provides the \"length\"\n * of the track -- the span of one dimensional space that the slider thumb can be. It also\n * accepts click and drag motions, so that the closest thumb will follow clicks and drags on\n * the track.\n */\nexport function useSlider(\n props: SliderProps,\n state: SliderState,\n trackRef: React.RefObject<HTMLElement>\n): SliderAria {\n let {labelProps, fieldProps} = useLabel(props);\n\n let isVertical = props.orientation === 'vertical';\n\n // Attach id of the label to the state so it can be accessed by useSliderThumb.\n sliderIds.set(state, labelProps.id ?? fieldProps.id);\n\n let {direction} = useLocale();\n\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n // When the user clicks or drags the track, we want the motion to set and drag the\n // closest thumb. Hence we also need to install useMove() on the track element.\n // Here, we keep track of which index is the \"closest\" to the drag start point.\n // It is set onMouseDown/onTouchDown; see trackProps below.\n const realTimeTrackDraggingIndex = useRef<number | null>(null);\n\n const stateRef = useRef<SliderState>(null);\n stateRef.current = state;\n const reverseX = direction === 'rtl';\n const currentPosition = useRef<number>(null);\n const {moveProps} = useMove({\n onMoveStart() {\n currentPosition.current = null;\n },\n onMove({deltaX, deltaY}) {\n let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth;\n\n if (currentPosition.current == null) {\n currentPosition.current = stateRef.current.getThumbPercent(realTimeTrackDraggingIndex.current) * size;\n }\n\n let delta = isVertical ? deltaY : deltaX;\n if (isVertical || reverseX) {\n delta = -delta;\n }\n\n currentPosition.current += delta;\n\n if (realTimeTrackDraggingIndex.current != null && trackRef.current) {\n const percent = clamp(currentPosition.current / size, 0, 1);\n stateRef.current.setThumbPercent(realTimeTrackDraggingIndex.current, percent);\n }\n },\n onMoveEnd() {\n if (realTimeTrackDraggingIndex.current != null) {\n stateRef.current.setThumbDragging(realTimeTrackDraggingIndex.current, false);\n realTimeTrackDraggingIndex.current = null;\n }\n }\n });\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let onDownTrack = (e: React.UIEvent, id: number, clientX: number, clientY: number) => {\n // We only trigger track-dragging if the user clicks on the track itself and nothing is currently being dragged.\n if (trackRef.current && !props.isDisabled && state.values.every((_, i) => !state.isThumbDragging(i))) {\n let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth;\n // Find the closest thumb\n const trackPosition = trackRef.current.getBoundingClientRect()[isVertical ? 'top' : 'left'];\n const clickPosition = isVertical ? clientY : clientX;\n const offset = clickPosition - trackPosition;\n let percent = offset / size;\n if (direction === 'rtl' || isVertical) {\n percent = 1 - percent;\n }\n let value = state.getPercentValue(percent);\n\n // Only compute the diff for thumbs that are editable, as only they can be dragged\n const minDiff = Math.min(...state.values.map((v, index) => state.isThumbEditable(index) ? Math.abs(v - value) : Number.POSITIVE_INFINITY));\n const index = state.values.findIndex(v => Math.abs(v - value) === minDiff);\n if (minDiff !== Number.POSITIVE_INFINITY && index >= 0) {\n // Don't unfocus anything\n e.preventDefault();\n\n realTimeTrackDraggingIndex.current = index;\n state.setFocusedThumb(index);\n currentPointer.current = id;\n\n state.setThumbDragging(realTimeTrackDraggingIndex.current, true);\n state.setThumbValue(index, value);\n\n addGlobalListener(window, 'mouseup', onUpTrack, false);\n addGlobalListener(window, 'touchend', onUpTrack, false);\n addGlobalListener(window, 'pointerup', onUpTrack, false);\n } else {\n realTimeTrackDraggingIndex.current = null;\n }\n }\n };\n\n let onUpTrack = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n if (realTimeTrackDraggingIndex.current != null) {\n state.setThumbDragging(realTimeTrackDraggingIndex.current, false);\n realTimeTrackDraggingIndex.current = null;\n }\n\n removeGlobalListener(window, 'mouseup', onUpTrack, false);\n removeGlobalListener(window, 'touchend', onUpTrack, false);\n removeGlobalListener(window, 'pointerup', onUpTrack, false);\n }\n };\n\n return {\n labelProps,\n // The root element of the Slider will have role=\"group\" to group together\n // all the thumb inputs in the Slider. The label of the Slider will\n // be used to label the group.\n containerProps: {\n role: 'group',\n ...fieldProps\n },\n trackProps: mergeProps({\n onMouseDown(e: React.MouseEvent<HTMLElement>) { onDownTrack(e, undefined, e.clientX, e.clientY); },\n onPointerDown(e: React.PointerEvent<HTMLElement>) { onDownTrack(e, e.pointerId, e.clientX, e.clientY); },\n onTouchStart(e: React.TouchEvent<HTMLElement>) { onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY); }\n }, moveProps)\n };\n}\n","import {clamp, focusWithoutScrolling, mergeProps, useGlobalListeners} from '@react-aria/utils';\nimport React, {ChangeEvent, HTMLAttributes, useCallback, useEffect, useRef} from 'react';\nimport {sliderIds} from './utils';\nimport {SliderState} from '@react-stately/slider';\nimport {SliderThumbProps} from '@react-types/slider';\nimport {useFocusable} from '@react-aria/focus';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\nimport {useMove} from '@react-aria/interactions';\n\ninterface SliderThumbAria {\n /** Props for the range input. */\n inputProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the root thumb element; handles the dragging motion. */\n thumbProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the label element for this thumb. */\n labelProps: HTMLAttributes<HTMLElement>\n}\n\nexport interface SliderThumbOptions extends SliderThumbProps {\n trackRef: React.RefObject<HTMLElement>,\n inputRef: React.RefObject<HTMLInputElement>\n}\n\n/**\n * Provides behavior and accessibility for a thumb of a slider component.\n *\n * @param opts Options for this Slider thumb.\n * @param state Slider state, created via `useSliderState`.\n */\nexport function useSliderThumb(\n opts: SliderThumbOptions,\n state: SliderState\n): SliderThumbAria {\n let {\n index,\n isRequired,\n isDisabled,\n validationState,\n trackRef,\n inputRef\n } = opts;\n\n let isVertical = opts.orientation === 'vertical';\n\n let {direction} = useLocale();\n let {addGlobalListener, removeGlobalListener} = useGlobalListeners();\n\n let labelId = sliderIds.get(state);\n const {labelProps, fieldProps} = useLabel({\n ...opts,\n 'aria-labelledby': `${labelId} ${opts['aria-labelledby'] ?? ''}`.trim()\n });\n\n const value = state.values[index];\n\n const focusInput = useCallback(() => {\n if (inputRef.current) {\n focusWithoutScrolling(inputRef.current);\n }\n }, [inputRef]);\n\n const isFocused = state.focusedThumb === index;\n\n useEffect(() => {\n if (isFocused) {\n focusInput();\n }\n }, [isFocused, focusInput]);\n\n const stateRef = useRef<SliderState>(null);\n stateRef.current = state;\n let reverseX = direction === 'rtl';\n let currentPosition = useRef<number>(null);\n let {moveProps} = useMove({\n onMoveStart() {\n currentPosition.current = null;\n state.setThumbDragging(index, true);\n },\n onMove({deltaX, deltaY, pointerType}) {\n let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth;\n\n if (currentPosition.current == null) {\n currentPosition.current = stateRef.current.getThumbPercent(index) * size;\n }\n if (pointerType === 'keyboard') {\n // (invert left/right according to language direction) + (according to vertical)\n let delta = ((reverseX ? -deltaX : deltaX) + (isVertical ? -deltaY : -deltaY)) * stateRef.current.step;\n currentPosition.current += delta * size;\n stateRef.current.setThumbValue(index, stateRef.current.getThumbValue(index) + delta);\n } else {\n let delta = isVertical ? deltaY : deltaX;\n if (isVertical || reverseX) {\n delta = -delta;\n }\n\n currentPosition.current += delta;\n stateRef.current.setThumbPercent(index, clamp(currentPosition.current / size, 0, 1));\n }\n },\n onMoveEnd() {\n state.setThumbDragging(index, false);\n }\n });\n\n // Immediately register editability with the state\n state.setThumbEditable(index, !isDisabled);\n\n const {focusableProps} = useFocusable(\n mergeProps(opts, {\n onFocus: () => state.setFocusedThumb(index),\n onBlur: () => state.setFocusedThumb(undefined)\n }),\n inputRef\n );\n\n let currentPointer = useRef<number | null | undefined>(undefined);\n let onDown = (id: number | null) => {\n focusInput();\n currentPointer.current = id;\n state.setThumbDragging(index, true);\n\n addGlobalListener(window, 'mouseup', onUp, false);\n addGlobalListener(window, 'touchend', onUp, false);\n addGlobalListener(window, 'pointerup', onUp, false);\n\n };\n\n let onUp = (e) => {\n let id = e.pointerId ?? e.changedTouches?.[0].identifier;\n if (id === currentPointer.current) {\n focusInput();\n state.setThumbDragging(index, false);\n removeGlobalListener(window, 'mouseup', onUp, false);\n removeGlobalListener(window, 'touchend', onUp, false);\n removeGlobalListener(window, 'pointerup', onUp, false);\n }\n };\n\n // We install mouse handlers for the drag motion on the thumb div, but\n // not the key handler for moving the thumb with the slider. Instead,\n // we focus the range input, and let the browser handle the keyboard\n // interactions; we then listen to input's onChange to update state.\n return {\n inputProps: mergeProps(focusableProps, fieldProps, {\n type: 'range',\n tabIndex: !isDisabled ? 0 : undefined,\n min: state.getThumbMinValue(index),\n max: state.getThumbMaxValue(index),\n step: state.step,\n value: value,\n disabled: isDisabled,\n 'aria-orientation': opts.orientation,\n 'aria-valuetext': state.getThumbValueLabel(index),\n 'aria-required': isRequired || undefined,\n 'aria-invalid': validationState === 'invalid' || undefined,\n 'aria-errormessage': opts['aria-errormessage'],\n onChange: (e: ChangeEvent<HTMLInputElement>) => {\n state.setThumbValue(index, parseFloat(e.target.value));\n }\n }),\n thumbProps: !isDisabled ? mergeProps(\n moveProps,\n {\n onMouseDown: () => {onDown(null);},\n onPointerDown: (e: React.PointerEvent) => {onDown(e.pointerId);},\n onTouchStart: (e: React.TouchEvent) => {onDown(e.changedTouches[0].identifier);}\n }\n ) : {},\n labelProps\n };\n}\n"],"names":["$parcel$interopDefault","a","__esModule","default","sliderIds","WeakMap","useSlider","props","state","trackRef","labelProps","fieldProps","useLabel","isVertical","orientation","set","id","direction","useLocale","addGlobalListener","removeGlobalListener","useGlobalListeners","realTimeTrackDraggingIndex","useRef","stateRef","current","reverseX","currentPosition","moveProps","useMove","onMoveStart","onMove","deltaX","deltaY","size","offsetHeight","offsetWidth","getThumbPercent","delta","percent","clamp","setThumbPercent","onMoveEnd","setThumbDragging","currentPointer","undefined","onDownTrack","e","clientX","clientY","isDisabled","values","every","_","i","isThumbDragging","trackPosition","getBoundingClientRect","clickPosition","offset","value","getPercentValue","minDiff","Math","min","map","v","index","isThumbEditable","abs","Number","POSITIVE_INFINITY","findIndex","preventDefault","setFocusedThumb","setThumbValue","window","onUpTrack","pointerId","changedTouches","identifier","containerProps","role","trackProps","mergeProps","onMouseDown","onPointerDown","onTouchStart","useSliderThumb","opts","isRequired","validationState","inputRef","labelId","get","trim","focusInput","useCallback","focusWithoutScrolling","isFocused","focusedThumb","useEffect","pointerType","step","getThumbValue","setThumbEditable","focusableProps","useFocusable","onFocus","onBlur","onDown","onUp","inputProps","type","tabIndex","getThumbMinValue","max","getThumbMaxValue","disabled","getThumbValueLabel","onChange","parseFloat","target","thumbProps"],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC","sources":["packages/@react-aria/slider/src/index.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport {useSlider} from './useSlider';\nexport {useSliderThumb} from './useSliderThumb';\nexport type {AriaSliderProps} from '@react-types/slider';\nexport type {SliderAria} from './useSlider';\nexport type {AriaSliderThumbOptions, SliderThumbAria} from './useSliderThumb';\nexport type {AriaSliderThumbProps} from '@react-types/slider';\nexport type {Orientation} from '@react-types/shared';\n"],"names":[],"version":3,"file":"main.js.map"}
|