@react-aria/slider 3.0.4 → 3.0.6-nightly.3120
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/main.js +95 -60
- package/dist/main.js.map +1 -1
- package/dist/module.js +94 -59
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +11 -11
- package/src/useSliderThumb.ts +60 -11
package/dist/main.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $
|
|
5
|
-
var $
|
|
6
|
-
var $
|
|
1
|
+
var $coMqq$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $coMqq$react = require("react");
|
|
3
|
+
var $coMqq$reactariainteractions = require("@react-aria/interactions");
|
|
4
|
+
var $coMqq$reactarialabel = require("@react-aria/label");
|
|
5
|
+
var $coMqq$reactariai18n = require("@react-aria/i18n");
|
|
6
|
+
var $coMqq$reactariafocus = require("@react-aria/focus");
|
|
7
7
|
|
|
8
8
|
function $parcel$exportWildcard(dest, source) {
|
|
9
9
|
Object.keys(source).forEach(function(key) {
|
|
@@ -24,13 +24,13 @@ function $parcel$exportWildcard(dest, source) {
|
|
|
24
24
|
function $parcel$export(e, n, v, s) {
|
|
25
25
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
26
26
|
}
|
|
27
|
-
var $
|
|
27
|
+
var $481f97d830e3ede6$exports = {};
|
|
28
28
|
|
|
29
|
-
$parcel$export($
|
|
29
|
+
$parcel$export($481f97d830e3ede6$exports, "useSlider", () => $481f97d830e3ede6$export$56b2c08e277f365);
|
|
30
30
|
|
|
31
|
-
const $
|
|
32
|
-
function $
|
|
33
|
-
let id = $
|
|
31
|
+
const $28db8d634be2fa58$export$7a8d2b02c9371cbf = new WeakMap();
|
|
32
|
+
function $28db8d634be2fa58$export$68e648cbec363a18(state, index) {
|
|
33
|
+
let id = $28db8d634be2fa58$export$7a8d2b02c9371cbf.get(state);
|
|
34
34
|
if (!id) throw new Error('Unknown slider state');
|
|
35
35
|
return `${id}-${index}`;
|
|
36
36
|
}
|
|
@@ -40,23 +40,24 @@ function $a834cdc37005ff28$export$68e648cbec363a18(state, index) {
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
function $
|
|
44
|
-
let { labelProps: labelProps , fieldProps: fieldProps } = $
|
|
43
|
+
function $481f97d830e3ede6$export$56b2c08e277f365(props, state, trackRef) {
|
|
44
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = $coMqq$reactarialabel.useLabel(props);
|
|
45
45
|
let isVertical = props.orientation === 'vertical';
|
|
46
|
+
var _id;
|
|
46
47
|
// Attach id of the label to the state so it can be accessed by useSliderThumb.
|
|
47
|
-
$
|
|
48
|
-
let { direction: direction } = $
|
|
49
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $
|
|
48
|
+
$28db8d634be2fa58$export$7a8d2b02c9371cbf.set(state, (_id = labelProps.id) !== null && _id !== void 0 ? _id : fieldProps.id);
|
|
49
|
+
let { direction: direction } = $coMqq$reactariai18n.useLocale();
|
|
50
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $coMqq$reactariautils.useGlobalListeners();
|
|
50
51
|
// When the user clicks or drags the track, we want the motion to set and drag the
|
|
51
52
|
// closest thumb. Hence we also need to install useMove() on the track element.
|
|
52
53
|
// Here, we keep track of which index is the "closest" to the drag start point.
|
|
53
54
|
// It is set onMouseDown/onTouchDown; see trackProps below.
|
|
54
|
-
const realTimeTrackDraggingIndex = $
|
|
55
|
-
const stateRef = $
|
|
55
|
+
const realTimeTrackDraggingIndex = $coMqq$react.useRef(null);
|
|
56
|
+
const stateRef = $coMqq$react.useRef(null);
|
|
56
57
|
stateRef.current = state;
|
|
57
58
|
const reverseX = direction === 'rtl';
|
|
58
|
-
const currentPosition = $
|
|
59
|
-
const { moveProps: moveProps } = $
|
|
59
|
+
const currentPosition = $coMqq$react.useRef(null);
|
|
60
|
+
const { moveProps: moveProps } = $coMqq$reactariainteractions.useMove({
|
|
60
61
|
onMoveStart () {
|
|
61
62
|
currentPosition.current = null;
|
|
62
63
|
},
|
|
@@ -67,7 +68,7 @@ function $59b2df71a191ec9b$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
67
68
|
if (isVertical || reverseX) delta = -delta;
|
|
68
69
|
currentPosition.current += delta;
|
|
69
70
|
if (realTimeTrackDraggingIndex.current != null && trackRef.current) {
|
|
70
|
-
const percent = $
|
|
71
|
+
const percent = $coMqq$reactariautils.clamp(currentPosition.current / size, 0, 1);
|
|
71
72
|
stateRef.current.setThumbPercent(realTimeTrackDraggingIndex.current, percent);
|
|
72
73
|
}
|
|
73
74
|
},
|
|
@@ -78,7 +79,7 @@ function $59b2df71a191ec9b$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
});
|
|
81
|
-
let currentPointer = $
|
|
82
|
+
let currentPointer = $coMqq$react.useRef(undefined);
|
|
82
83
|
let onDownTrack = (e, id, clientX, clientY)=>{
|
|
83
84
|
// We only trigger track-dragging if the user clicks on the track itself and nothing is currently being dragged.
|
|
84
85
|
if (trackRef.current && !props.isDisabled && state.values.every((_, i)=>!state.isThumbDragging(i)
|
|
@@ -120,7 +121,9 @@ function $59b2df71a191ec9b$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
120
121
|
}
|
|
121
122
|
};
|
|
122
123
|
let onUpTrack = (e)=>{
|
|
123
|
-
|
|
124
|
+
var ref;
|
|
125
|
+
var _pointerId;
|
|
126
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
124
127
|
if (id === currentPointer.current) {
|
|
125
128
|
if (realTimeTrackDraggingIndex.current != null) {
|
|
126
129
|
state.setThumbDragging(realTimeTrackDraggingIndex.current, false);
|
|
@@ -138,10 +141,11 @@ function $59b2df71a191ec9b$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
138
141
|
// See https://bugs.webkit.org/show_bug.cgi?id=172464.
|
|
139
142
|
delete labelProps.htmlFor;
|
|
140
143
|
labelProps.onClick = ()=>{
|
|
141
|
-
// Safari does not focus <input type="range"> elements when clicking on an associated <label>,
|
|
144
|
+
var // Safari does not focus <input type="range"> elements when clicking on an associated <label>,
|
|
142
145
|
// so do it manually. In addition, make sure we show the focus ring.
|
|
143
|
-
|
|
144
|
-
$
|
|
146
|
+
ref;
|
|
147
|
+
(ref = document.getElementById($28db8d634be2fa58$export$68e648cbec363a18(state, 0))) === null || ref === void 0 ? void 0 : ref.focus();
|
|
148
|
+
$coMqq$reactariainteractions.setInteractionModality('keyboard');
|
|
145
149
|
};
|
|
146
150
|
}
|
|
147
151
|
return {
|
|
@@ -153,7 +157,7 @@ function $59b2df71a191ec9b$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
153
157
|
role: 'group',
|
|
154
158
|
...fieldProps
|
|
155
159
|
},
|
|
156
|
-
trackProps: $
|
|
160
|
+
trackProps: $coMqq$reactariautils.mergeProps({
|
|
157
161
|
onMouseDown (e) {
|
|
158
162
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
159
163
|
onDownTrack(e, undefined, e.clientX, e.clientY);
|
|
@@ -167,7 +171,7 @@ function $59b2df71a191ec9b$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
167
171
|
}
|
|
168
172
|
}, moveProps),
|
|
169
173
|
outputProps: {
|
|
170
|
-
htmlFor: state.values.map((_, index)=>$
|
|
174
|
+
htmlFor: state.values.map((_, index)=>$28db8d634be2fa58$export$68e648cbec363a18(state, index)
|
|
171
175
|
).join(' '),
|
|
172
176
|
'aria-live': 'off'
|
|
173
177
|
}
|
|
@@ -175,9 +179,9 @@ function $59b2df71a191ec9b$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
175
179
|
}
|
|
176
180
|
|
|
177
181
|
|
|
178
|
-
var $
|
|
182
|
+
var $5eb806b626475377$exports = {};
|
|
179
183
|
|
|
180
|
-
$parcel$export($
|
|
184
|
+
$parcel$export($5eb806b626475377$exports, "useSliderThumb", () => $5eb806b626475377$export$8d15029008292ae);
|
|
181
185
|
|
|
182
186
|
|
|
183
187
|
|
|
@@ -185,66 +189,95 @@ $parcel$export($d1bbfa318457062f$exports, "useSliderThumb", () => $d1bbfa3184570
|
|
|
185
189
|
|
|
186
190
|
|
|
187
191
|
|
|
188
|
-
function $
|
|
192
|
+
function $5eb806b626475377$export$8d15029008292ae(opts, state) {
|
|
189
193
|
let { index: index , isRequired: isRequired , isDisabled: isDisabled , validationState: validationState , trackRef: trackRef , inputRef: inputRef } = opts;
|
|
190
194
|
let isVertical = opts.orientation === 'vertical';
|
|
191
|
-
let { direction: direction } = $
|
|
192
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $
|
|
193
|
-
let labelId = $
|
|
194
|
-
|
|
195
|
+
let { direction: direction } = $coMqq$reactariai18n.useLocale();
|
|
196
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $coMqq$reactariautils.useGlobalListeners();
|
|
197
|
+
let labelId = $28db8d634be2fa58$export$7a8d2b02c9371cbf.get(state);
|
|
198
|
+
var ref1;
|
|
199
|
+
const { labelProps: labelProps , fieldProps: fieldProps } = $coMqq$reactarialabel.useLabel({
|
|
195
200
|
...opts,
|
|
196
|
-
id: $
|
|
197
|
-
'aria-labelledby': `${labelId} ${opts['aria-labelledby']
|
|
201
|
+
id: $28db8d634be2fa58$export$68e648cbec363a18(state, index),
|
|
202
|
+
'aria-labelledby': `${labelId} ${(ref1 = opts['aria-labelledby']) !== null && ref1 !== void 0 ? ref1 : ''}`.trim()
|
|
198
203
|
});
|
|
199
204
|
const value = state.values[index];
|
|
200
|
-
const focusInput = $
|
|
201
|
-
if (inputRef.current) $
|
|
205
|
+
const focusInput = $coMqq$react.useCallback(()=>{
|
|
206
|
+
if (inputRef.current) $coMqq$reactariautils.focusWithoutScrolling(inputRef.current);
|
|
202
207
|
}, [
|
|
203
208
|
inputRef
|
|
204
209
|
]);
|
|
205
210
|
const isFocused = state.focusedThumb === index;
|
|
206
|
-
$
|
|
211
|
+
$coMqq$react.useEffect(()=>{
|
|
207
212
|
if (isFocused) focusInput();
|
|
208
213
|
}, [
|
|
209
214
|
isFocused,
|
|
210
215
|
focusInput
|
|
211
216
|
]);
|
|
212
|
-
const stateRef = $
|
|
217
|
+
const stateRef = $coMqq$react.useRef(null);
|
|
213
218
|
stateRef.current = state;
|
|
214
219
|
let reverseX = direction === 'rtl';
|
|
215
|
-
let currentPosition = $
|
|
216
|
-
let {
|
|
220
|
+
let currentPosition = $coMqq$react.useRef(null);
|
|
221
|
+
let { keyboardProps: keyboardProps } = $coMqq$reactariainteractions.useKeyboard({
|
|
222
|
+
onKeyDown (e) {
|
|
223
|
+
let { getThumbMaxValue: getThumbMaxValue , getThumbMinValue: getThumbMinValue , decrementThumb: decrementThumb , incrementThumb: incrementThumb , setThumbValue: setThumbValue , setThumbDragging: setThumbDragging , pageSize: pageSize } = stateRef.current;
|
|
224
|
+
// these are the cases that useMove or useSlider don't handle
|
|
225
|
+
if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
|
|
226
|
+
e.continuePropagation();
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
// same handling as useMove, stopPropagation to prevent useSlider from handling the event as well.
|
|
230
|
+
e.preventDefault();
|
|
231
|
+
// remember to set this so that onChangeEnd is fired
|
|
232
|
+
setThumbDragging(index, true);
|
|
233
|
+
switch(e.key){
|
|
234
|
+
case 'PageUp':
|
|
235
|
+
incrementThumb(index, pageSize);
|
|
236
|
+
break;
|
|
237
|
+
case 'PageDown':
|
|
238
|
+
decrementThumb(index, pageSize);
|
|
239
|
+
break;
|
|
240
|
+
case 'Home':
|
|
241
|
+
setThumbValue(index, getThumbMinValue(index));
|
|
242
|
+
break;
|
|
243
|
+
case 'End':
|
|
244
|
+
setThumbValue(index, getThumbMaxValue(index));
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
setThumbDragging(index, false);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
let { moveProps: moveProps } = $coMqq$reactariainteractions.useMove({
|
|
217
251
|
onMoveStart () {
|
|
218
252
|
currentPosition.current = null;
|
|
219
|
-
|
|
253
|
+
stateRef.current.setThumbDragging(index, true);
|
|
220
254
|
},
|
|
221
|
-
onMove ({ deltaX: deltaX , deltaY: deltaY , pointerType: pointerType }) {
|
|
255
|
+
onMove ({ deltaX: deltaX , deltaY: deltaY , pointerType: pointerType , shiftKey: shiftKey }) {
|
|
256
|
+
const { getThumbPercent: getThumbPercent , setThumbPercent: setThumbPercent , decrementThumb: decrementThumb , incrementThumb: incrementThumb , step: step , pageSize: pageSize } = stateRef.current;
|
|
222
257
|
let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth;
|
|
223
|
-
if (currentPosition.current == null) currentPosition.current =
|
|
258
|
+
if (currentPosition.current == null) currentPosition.current = getThumbPercent(index) * size;
|
|
224
259
|
if (pointerType === 'keyboard') {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
currentPosition.current += delta * size;
|
|
228
|
-
stateRef.current.setThumbValue(index, stateRef.current.getThumbValue(index) + delta);
|
|
260
|
+
if (deltaX > 0 && reverseX || deltaX < 0 && !reverseX || deltaY > 0) decrementThumb(index, shiftKey ? pageSize : step);
|
|
261
|
+
else incrementThumb(index, shiftKey ? pageSize : step);
|
|
229
262
|
} else {
|
|
230
263
|
let delta = isVertical ? deltaY : deltaX;
|
|
231
264
|
if (isVertical || reverseX) delta = -delta;
|
|
232
265
|
currentPosition.current += delta;
|
|
233
|
-
|
|
266
|
+
setThumbPercent(index, $coMqq$reactariautils.clamp(currentPosition.current / size, 0, 1));
|
|
234
267
|
}
|
|
235
268
|
},
|
|
236
269
|
onMoveEnd () {
|
|
237
|
-
|
|
270
|
+
stateRef.current.setThumbDragging(index, false);
|
|
238
271
|
}
|
|
239
272
|
});
|
|
240
273
|
// Immediately register editability with the state
|
|
241
274
|
state.setThumbEditable(index, !isDisabled);
|
|
242
|
-
const { focusableProps: focusableProps } = $
|
|
275
|
+
const { focusableProps: focusableProps } = $coMqq$reactariafocus.useFocusable($coMqq$reactariautils.mergeProps(opts, {
|
|
243
276
|
onFocus: ()=>state.setFocusedThumb(index)
|
|
244
277
|
,
|
|
245
278
|
onBlur: ()=>state.setFocusedThumb(undefined)
|
|
246
279
|
}), inputRef);
|
|
247
|
-
let currentPointer = $
|
|
280
|
+
let currentPointer = $coMqq$react.useRef(undefined);
|
|
248
281
|
let onDown = (id)=>{
|
|
249
282
|
focusInput();
|
|
250
283
|
currentPointer.current = id;
|
|
@@ -254,7 +287,9 @@ function $d1bbfa318457062f$export$8d15029008292ae(opts, state) {
|
|
|
254
287
|
addGlobalListener(window, 'pointerup', onUp, false);
|
|
255
288
|
};
|
|
256
289
|
let onUp = (e)=>{
|
|
257
|
-
|
|
290
|
+
var ref;
|
|
291
|
+
var _pointerId;
|
|
292
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
258
293
|
if (id === currentPointer.current) {
|
|
259
294
|
focusInput();
|
|
260
295
|
state.setThumbDragging(index, false);
|
|
@@ -268,7 +303,7 @@ function $d1bbfa318457062f$export$8d15029008292ae(opts, state) {
|
|
|
268
303
|
// we focus the range input, and let the browser handle the keyboard
|
|
269
304
|
// interactions; we then listen to input's onChange to update state.
|
|
270
305
|
return {
|
|
271
|
-
inputProps: $
|
|
306
|
+
inputProps: $coMqq$reactariautils.mergeProps(focusableProps, fieldProps, {
|
|
272
307
|
type: 'range',
|
|
273
308
|
tabIndex: !isDisabled ? 0 : undefined,
|
|
274
309
|
min: state.getThumbMinValue(index),
|
|
@@ -282,10 +317,10 @@ function $d1bbfa318457062f$export$8d15029008292ae(opts, state) {
|
|
|
282
317
|
'aria-invalid': validationState === 'invalid' || undefined,
|
|
283
318
|
'aria-errormessage': opts['aria-errormessage'],
|
|
284
319
|
onChange: (e)=>{
|
|
285
|
-
|
|
320
|
+
stateRef.current.setThumbValue(index, parseFloat(e.target.value));
|
|
286
321
|
}
|
|
287
322
|
}),
|
|
288
|
-
thumbProps: !isDisabled ? $
|
|
323
|
+
thumbProps: !isDisabled ? $coMqq$reactariautils.mergeProps(keyboardProps, moveProps, {
|
|
289
324
|
onMouseDown: (e)=>{
|
|
290
325
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
291
326
|
onDown();
|
|
@@ -304,8 +339,8 @@ function $d1bbfa318457062f$export$8d15029008292ae(opts, state) {
|
|
|
304
339
|
}
|
|
305
340
|
|
|
306
341
|
|
|
307
|
-
$parcel$exportWildcard(module.exports, $
|
|
308
|
-
$parcel$exportWildcard(module.exports, $
|
|
342
|
+
$parcel$exportWildcard(module.exports, $481f97d830e3ede6$exports);
|
|
343
|
+
$parcel$exportWildcard(module.exports, $5eb806b626475377$exports);
|
|
309
344
|
|
|
310
345
|
|
|
311
346
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEEO,KAAK,CAAC,yCAAS,GAAG,GAAG,CAAC,OAAO;SAEpB,yCAAgB,CAAC,KAAkB,EAAE,KAAa,EAAE,CAAC;IACnE,GAAG,CAAC,EAAE,GAAG,yCAAS,CAAC,GAAG,CAAC,KAAK;IAC5B,EAAE,GAAG,EAAE,EACL,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAsB;IAGxC,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK;AACvB,CAAC;;;;;;;SDkCe,wCAAS,CACvB,KAAsB,EACtB,KAAkB,EAClB,QAAgC,EACpB,CAAC;I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,UAAU,GAAG,UAAU,GAAG,gCAAU,CAClC,SAAS,EACT,CAAC;YACC,WAAW,GAAG,CAAgC,GAAK,CAAC;gBAClD,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EACtD,MAAM;gBAER,MAAM;YACR,CAAC;YACD,aAAa,GAAG,CAAkC,GAAK,CAAC;gBACtD,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EACtD,MAAM;gBAER,MAAM,CAAC,CAAC,CAAC,SAAS;YACpB,CAAC;YACD,YAAY,GAAG,CAAgC,GAAK,CAAC;gBAAA,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,UAAU;YAAE,CAAC;QAC/F,CAAC,IACC,CAAC;QAAA,CAAC;oBACN,UAAU;IACZ,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/slider/src/index.ts","packages/@react-aria/slider/src/useSlider.ts","packages/@react-aria/slider/src/utils.ts","packages/@react-aria/slider/src/useSliderThumb.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 */\n\nexport * from './useSlider';\nexport * from './useSliderThumb';\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 {AriaSliderProps} from '@react-types/slider';\nimport {clamp, mergeProps, useGlobalListeners} from '@react-aria/utils';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {HTMLAttributes, LabelHTMLAttributes, OutputHTMLAttributes, RefObject, useRef} from 'react';\nimport {setInteractionModality, useMove} from '@react-aria/interactions';\nimport {SliderState} from '@react-stately/slider';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface SliderAria {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n\n /** Props for the root element of the slider component; groups slider inputs. */\n groupProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the track element. */\n trackProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the output element, displaying the value of the slider thumbs. */\n outputProps: OutputHTMLAttributes<HTMLOutputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a slider component representing one or more values.\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: AriaSliderProps,\n state: SliderState,\n trackRef: 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 // to find the closet thumb we split the array based on the first thumb position to the \"right/end\" of the click.\n let closestThumb;\n let split = state.values.findIndex(v => value - v < 0);\n if (split === 0) { // If the index is zero then the closetThumb is the first one\n closestThumb = split;\n } else if (split === -1) { // If no index is found they've clicked past all the thumbs\n closestThumb = state.values.length - 1;\n } else {\n let lastLeft = state.values[split - 1];\n let firstRight = state.values[split];\n // Pick the last left/start thumb, unless they are stacked on top of each other, then pick the right/end one\n if (Math.abs(lastLeft - value) < Math.abs(firstRight - value)) {\n closestThumb = split - 1;\n } else {\n closestThumb = split;\n }\n }\n\n // Confirm that the found closest thumb is editable, not disabled, and move it\n if (closestThumb >= 0 && state.isThumbEditable(closestThumb)) {\n // Don't unfocus anything\n e.preventDefault();\n\n realTimeTrackDraggingIndex.current = closestThumb;\n state.setFocusedThumb(closestThumb);\n currentPointer.current = id;\n\n state.setThumbDragging(realTimeTrackDraggingIndex.current, true);\n state.setThumbValue(closestThumb, 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 if (labelProps.htmlFor) {\n // Ideally the `for` attribute should point to the first thumb, but VoiceOver on iOS\n // causes this to override the `aria-labelledby` on the thumb. This causes the first\n // thumb to only be announced as the slider label rather than its individual name as well.\n // See https://bugs.webkit.org/show_bug.cgi?id=172464.\n delete labelProps.htmlFor;\n labelProps.onClick = () => {\n // Safari does not focus <input type=\"range\"> elements when clicking on an associated <label>,\n // so do it manually. In addition, make sure we show the focus ring.\n document.getElementById(getSliderThumbId(state, 0))?.focus();\n setInteractionModality('keyboard');\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 groupProps: {\n role: 'group',\n ...fieldProps\n },\n trackProps: mergeProps({\n onMouseDown(e: React.MouseEvent<HTMLElement>) {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDownTrack(e, undefined, e.clientX, e.clientY);\n },\n onPointerDown(e: React.PointerEvent<HTMLElement>) {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onDownTrack(e, e.pointerId, e.clientX, e.clientY);\n },\n onTouchStart(e: React.TouchEvent<HTMLElement>) { onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY); }\n }, moveProps),\n outputProps: {\n htmlFor: state.values.map((_, index) => getSliderThumbId(state, index)).join(' '),\n 'aria-live': 'off'\n }\n };\n}\n","import {SliderState} from '@react-stately/slider';\n\nexport const sliderIds = new WeakMap<SliderState, string>();\n\nexport function getSliderThumbId(state: SliderState, index: number) {\n let id = sliderIds.get(state);\n if (!id) {\n throw new Error('Unknown slider state');\n }\n\n return `${id}-${index}`;\n}\n","import {AriaSliderThumbProps} from '@react-types/slider';\nimport {clamp, focusWithoutScrolling, mergeProps, useGlobalListeners} from '@react-aria/utils';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {ChangeEvent, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, RefObject, useCallback, useEffect, useRef} from 'react';\nimport {SliderState} from '@react-stately/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 root thumb element; handles the dragging motion. */\n thumbProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n\n /** Props for the label element for this thumb (optional). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>\n}\n\ninterface SliderThumbOptions extends AriaSliderThumbProps {\n /** A ref to the track element. */\n trackRef: RefObject<HTMLElement>,\n /** A ref to the thumb input element. */\n inputRef: 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 id: getSliderThumbId(state, index),\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 | undefined>(undefined);\n let onDown = (id?: number) => {\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: (e: React.MouseEvent<HTMLElement>) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown();\n },\n onPointerDown: (e: React.PointerEvent<HTMLElement>) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent<HTMLElement>) => {onDown(e.changedTouches[0].identifier);}\n }\n ) : {},\n labelProps\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AEEO,KAAK,CAAC,yCAAS,GAAG,GAAG,CAAC,OAAO;SAEpB,yCAAgB,CAAC,KAAkB,EAAE,KAAa,EAAE,CAAC;IACnE,GAAG,CAAC,EAAE,GAAG,yCAAS,CAAC,GAAG,CAAC,KAAK;IAC5B,EAAE,GAAG,EAAE,EACL,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAsB;IAGxC,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK;AACvB,CAAC;;;;;;;SDkCe,wCAAS,CACvB,KAAsB,EACtB,KAAkB,EAClB,QAAgC,EACpB,CAAC;IACb,GAAG,CAAC,CAAC,aAAA,UAAU,eAAE,UAAU,EAAA,CAAC,GAAG,8BAAQ,CAAC,KAAK;IAE7C,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,WAAW,KAAK,CAAU;QAG5B,GAAa;IADlC,EAA+E,AAA/E,6EAA+E;IAC/E,yCAAS,CAAC,GAAG,CAAC,KAAK,GAAE,GAAa,GAAb,UAAU,CAAC,EAAE,cAAb,GAAa,cAAb,GAAa,GAAI,UAAU,CAAC,EAAE;IAEnD,GAAG,CAAC,CAAC,YAAA,SAAS,EAAA,CAAC,GAAG,8BAAS;IAE3B,GAAG,CAAC,CAAC,oBAAA,iBAAiB,yBAAE,oBAAoB,EAAA,CAAC,GAAG,wCAAkB;IAElE,EAAkF,AAAlF,gFAAkF;IAClF,EAAgF,AAAhF,8E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,OAAO,EACtD,MAAM;gBAER,MAAM;YACR,CAAC;YACD,aAAa,GAAG,CAAkC,GAAK,CAAC;gBACtD,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EACtD,MAAM;gBAER,MAAM,CAAC,CAAC,CAAC,SAAS;YACpB,CAAC;YACD,YAAY,GAAG,CAAgC,GAAK,CAAC;gBAAA,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,UAAU;YAAE,CAAC;QAC/F,CAAC,IACC,CAAC;QAAA,CAAC;oBACN,UAAU;IACZ,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/slider/src/index.ts","packages/@react-aria/slider/src/useSlider.ts","packages/@react-aria/slider/src/utils.ts","packages/@react-aria/slider/src/useSliderThumb.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 */\n\nexport * from './useSlider';\nexport * from './useSliderThumb';\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 {AriaSliderProps} from '@react-types/slider';\nimport {clamp, mergeProps, useGlobalListeners} from '@react-aria/utils';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {HTMLAttributes, LabelHTMLAttributes, OutputHTMLAttributes, RefObject, useRef} from 'react';\nimport {setInteractionModality, useMove} from '@react-aria/interactions';\nimport {SliderState} from '@react-stately/slider';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface SliderAria {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n\n /** Props for the root element of the slider component; groups slider inputs. */\n groupProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the track element. */\n trackProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the output element, displaying the value of the slider thumbs. */\n outputProps: OutputHTMLAttributes<HTMLOutputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a slider component representing one or more values.\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: AriaSliderProps,\n state: SliderState,\n trackRef: 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 // to find the closet thumb we split the array based on the first thumb position to the \"right/end\" of the click.\n let closestThumb;\n let split = state.values.findIndex(v => value - v < 0);\n if (split === 0) { // If the index is zero then the closetThumb is the first one\n closestThumb = split;\n } else if (split === -1) { // If no index is found they've clicked past all the thumbs\n closestThumb = state.values.length - 1;\n } else {\n let lastLeft = state.values[split - 1];\n let firstRight = state.values[split];\n // Pick the last left/start thumb, unless they are stacked on top of each other, then pick the right/end one\n if (Math.abs(lastLeft - value) < Math.abs(firstRight - value)) {\n closestThumb = split - 1;\n } else {\n closestThumb = split;\n }\n }\n\n // Confirm that the found closest thumb is editable, not disabled, and move it\n if (closestThumb >= 0 && state.isThumbEditable(closestThumb)) {\n // Don't unfocus anything\n e.preventDefault();\n\n realTimeTrackDraggingIndex.current = closestThumb;\n state.setFocusedThumb(closestThumb);\n currentPointer.current = id;\n\n state.setThumbDragging(realTimeTrackDraggingIndex.current, true);\n state.setThumbValue(closestThumb, 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 if (labelProps.htmlFor) {\n // Ideally the `for` attribute should point to the first thumb, but VoiceOver on iOS\n // causes this to override the `aria-labelledby` on the thumb. This causes the first\n // thumb to only be announced as the slider label rather than its individual name as well.\n // See https://bugs.webkit.org/show_bug.cgi?id=172464.\n delete labelProps.htmlFor;\n labelProps.onClick = () => {\n // Safari does not focus <input type=\"range\"> elements when clicking on an associated <label>,\n // so do it manually. In addition, make sure we show the focus ring.\n document.getElementById(getSliderThumbId(state, 0))?.focus();\n setInteractionModality('keyboard');\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 groupProps: {\n role: 'group',\n ...fieldProps\n },\n trackProps: mergeProps({\n onMouseDown(e: React.MouseEvent<HTMLElement>) {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDownTrack(e, undefined, e.clientX, e.clientY);\n },\n onPointerDown(e: React.PointerEvent<HTMLElement>) {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onDownTrack(e, e.pointerId, e.clientX, e.clientY);\n },\n onTouchStart(e: React.TouchEvent<HTMLElement>) { onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY); }\n }, moveProps),\n outputProps: {\n htmlFor: state.values.map((_, index) => getSliderThumbId(state, index)).join(' '),\n 'aria-live': 'off'\n }\n };\n}\n","import {SliderState} from '@react-stately/slider';\n\nexport const sliderIds = new WeakMap<SliderState, string>();\n\nexport function getSliderThumbId(state: SliderState, index: number) {\n let id = sliderIds.get(state);\n if (!id) {\n throw new Error('Unknown slider state');\n }\n\n return `${id}-${index}`;\n}\n","import {AriaSliderThumbProps} from '@react-types/slider';\nimport {clamp, focusWithoutScrolling, mergeProps, useGlobalListeners} from '@react-aria/utils';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {ChangeEvent, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, RefObject, useCallback, useEffect, useRef} from 'react';\nimport {SliderState} from '@react-stately/slider';\nimport {useFocusable} from '@react-aria/focus';\nimport {useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface SliderThumbAria {\n /** Props for the root thumb element; handles the dragging motion. */\n thumbProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n\n /** Props for the label element for this thumb (optional). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>\n}\n\ninterface SliderThumbOptions extends AriaSliderThumbProps {\n /** A ref to the track element. */\n trackRef: RefObject<HTMLElement>,\n /** A ref to the thumb input element. */\n inputRef: 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 id: getSliderThumbId(state, index),\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\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n let {\n getThumbMaxValue,\n getThumbMinValue,\n decrementThumb,\n incrementThumb,\n setThumbValue,\n setThumbDragging,\n pageSize\n } = stateRef.current;\n // these are the cases that useMove or useSlider don't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, stopPropagation to prevent useSlider from handling the event as well.\n e.preventDefault();\n // remember to set this so that onChangeEnd is fired\n setThumbDragging(index, true);\n switch (e.key) {\n case 'PageUp':\n incrementThumb(index, pageSize);\n break;\n case 'PageDown':\n decrementThumb(index, pageSize);\n break;\n case 'Home':\n setThumbValue(index, getThumbMinValue(index));\n break;\n case 'End':\n setThumbValue(index, getThumbMaxValue(index));\n break;\n }\n setThumbDragging(index, false);\n }\n });\n\n let {moveProps} = useMove({\n onMoveStart() {\n currentPosition.current = null;\n stateRef.current.setThumbDragging(index, true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n const {\n getThumbPercent,\n setThumbPercent,\n decrementThumb,\n incrementThumb,\n step,\n pageSize\n } = stateRef.current;\n let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth;\n\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPercent(index) * size;\n }\n if (pointerType === 'keyboard') {\n if ((deltaX > 0 && reverseX) || (deltaX < 0 && !reverseX) || deltaY > 0) {\n decrementThumb(index, shiftKey ? pageSize : step);\n } else {\n incrementThumb(index, shiftKey ? pageSize : step);\n }\n } else {\n let delta = isVertical ? deltaY : deltaX;\n if (isVertical || reverseX) {\n delta = -delta;\n }\n\n currentPosition.current += delta;\n setThumbPercent(index, clamp(currentPosition.current / size, 0, 1));\n }\n },\n onMoveEnd() {\n stateRef.current.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 | undefined>(undefined);\n let onDown = (id?: number) => {\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 stateRef.current.setThumbValue(index, parseFloat(e.target.value));\n }\n }),\n thumbProps: !isDisabled ? mergeProps(\n keyboardProps,\n moveProps,\n {\n onMouseDown: (e: React.MouseEvent<HTMLElement>) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown();\n },\n onPointerDown: (e: React.PointerEvent<HTMLElement>) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent<HTMLElement>) => {onDown(e.changedTouches[0].identifier);}\n }\n ) : {},\n labelProps\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {useGlobalListeners as $
|
|
2
|
-
import {useRef as $
|
|
3
|
-
import {useMove as $
|
|
4
|
-
import {useLabel as $
|
|
5
|
-
import {useLocale as $
|
|
6
|
-
import {useFocusable as $
|
|
1
|
+
import {useGlobalListeners as $fA3fN$useGlobalListeners, clamp as $fA3fN$clamp, mergeProps as $fA3fN$mergeProps, focusWithoutScrolling as $fA3fN$focusWithoutScrolling} from "@react-aria/utils";
|
|
2
|
+
import {useRef as $fA3fN$useRef, useCallback as $fA3fN$useCallback, useEffect as $fA3fN$useEffect} from "react";
|
|
3
|
+
import {useMove as $fA3fN$useMove, setInteractionModality as $fA3fN$setInteractionModality, useKeyboard as $fA3fN$useKeyboard} from "@react-aria/interactions";
|
|
4
|
+
import {useLabel as $fA3fN$useLabel} from "@react-aria/label";
|
|
5
|
+
import {useLocale as $fA3fN$useLocale} from "@react-aria/i18n";
|
|
6
|
+
import {useFocusable as $fA3fN$useFocusable} from "@react-aria/focus";
|
|
7
7
|
|
|
8
8
|
function $parcel$export(e, n, v, s) {
|
|
9
9
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
10
10
|
}
|
|
11
|
-
var $
|
|
11
|
+
var $bcca50147b47f54d$exports = {};
|
|
12
12
|
|
|
13
|
-
$parcel$export($
|
|
13
|
+
$parcel$export($bcca50147b47f54d$exports, "useSlider", () => $bcca50147b47f54d$export$56b2c08e277f365);
|
|
14
14
|
|
|
15
|
-
const $
|
|
16
|
-
function $
|
|
17
|
-
let id = $
|
|
15
|
+
const $aa519ee6cf463259$export$7a8d2b02c9371cbf = new WeakMap();
|
|
16
|
+
function $aa519ee6cf463259$export$68e648cbec363a18(state, index) {
|
|
17
|
+
let id = $aa519ee6cf463259$export$7a8d2b02c9371cbf.get(state);
|
|
18
18
|
if (!id) throw new Error('Unknown slider state');
|
|
19
19
|
return `${id}-${index}`;
|
|
20
20
|
}
|
|
@@ -24,23 +24,24 @@ function $21858bef1d0ccf3b$export$68e648cbec363a18(state, index) {
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
function $
|
|
28
|
-
let { labelProps: labelProps , fieldProps: fieldProps } = $
|
|
27
|
+
function $bcca50147b47f54d$export$56b2c08e277f365(props, state, trackRef) {
|
|
28
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = $fA3fN$useLabel(props);
|
|
29
29
|
let isVertical = props.orientation === 'vertical';
|
|
30
|
+
var _id;
|
|
30
31
|
// Attach id of the label to the state so it can be accessed by useSliderThumb.
|
|
31
|
-
$
|
|
32
|
-
let { direction: direction } = $
|
|
33
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $
|
|
32
|
+
$aa519ee6cf463259$export$7a8d2b02c9371cbf.set(state, (_id = labelProps.id) !== null && _id !== void 0 ? _id : fieldProps.id);
|
|
33
|
+
let { direction: direction } = $fA3fN$useLocale();
|
|
34
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $fA3fN$useGlobalListeners();
|
|
34
35
|
// When the user clicks or drags the track, we want the motion to set and drag the
|
|
35
36
|
// closest thumb. Hence we also need to install useMove() on the track element.
|
|
36
37
|
// Here, we keep track of which index is the "closest" to the drag start point.
|
|
37
38
|
// It is set onMouseDown/onTouchDown; see trackProps below.
|
|
38
|
-
const realTimeTrackDraggingIndex = $
|
|
39
|
-
const stateRef = $
|
|
39
|
+
const realTimeTrackDraggingIndex = $fA3fN$useRef(null);
|
|
40
|
+
const stateRef = $fA3fN$useRef(null);
|
|
40
41
|
stateRef.current = state;
|
|
41
42
|
const reverseX = direction === 'rtl';
|
|
42
|
-
const currentPosition = $
|
|
43
|
-
const { moveProps: moveProps } = $
|
|
43
|
+
const currentPosition = $fA3fN$useRef(null);
|
|
44
|
+
const { moveProps: moveProps } = $fA3fN$useMove({
|
|
44
45
|
onMoveStart () {
|
|
45
46
|
currentPosition.current = null;
|
|
46
47
|
},
|
|
@@ -51,7 +52,7 @@ function $9006468ca971c07d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
51
52
|
if (isVertical || reverseX) delta = -delta;
|
|
52
53
|
currentPosition.current += delta;
|
|
53
54
|
if (realTimeTrackDraggingIndex.current != null && trackRef.current) {
|
|
54
|
-
const percent = $
|
|
55
|
+
const percent = $fA3fN$clamp(currentPosition.current / size, 0, 1);
|
|
55
56
|
stateRef.current.setThumbPercent(realTimeTrackDraggingIndex.current, percent);
|
|
56
57
|
}
|
|
57
58
|
},
|
|
@@ -62,7 +63,7 @@ function $9006468ca971c07d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
});
|
|
65
|
-
let currentPointer = $
|
|
66
|
+
let currentPointer = $fA3fN$useRef(undefined);
|
|
66
67
|
let onDownTrack = (e, id, clientX, clientY)=>{
|
|
67
68
|
// We only trigger track-dragging if the user clicks on the track itself and nothing is currently being dragged.
|
|
68
69
|
if (trackRef.current && !props.isDisabled && state.values.every((_, i)=>!state.isThumbDragging(i)
|
|
@@ -104,7 +105,9 @@ function $9006468ca971c07d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
104
105
|
}
|
|
105
106
|
};
|
|
106
107
|
let onUpTrack = (e)=>{
|
|
107
|
-
|
|
108
|
+
var ref;
|
|
109
|
+
var _pointerId;
|
|
110
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
108
111
|
if (id === currentPointer.current) {
|
|
109
112
|
if (realTimeTrackDraggingIndex.current != null) {
|
|
110
113
|
state.setThumbDragging(realTimeTrackDraggingIndex.current, false);
|
|
@@ -122,10 +125,11 @@ function $9006468ca971c07d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
122
125
|
// See https://bugs.webkit.org/show_bug.cgi?id=172464.
|
|
123
126
|
delete labelProps.htmlFor;
|
|
124
127
|
labelProps.onClick = ()=>{
|
|
125
|
-
// Safari does not focus <input type="range"> elements when clicking on an associated <label>,
|
|
128
|
+
var // Safari does not focus <input type="range"> elements when clicking on an associated <label>,
|
|
126
129
|
// so do it manually. In addition, make sure we show the focus ring.
|
|
127
|
-
|
|
128
|
-
$
|
|
130
|
+
ref;
|
|
131
|
+
(ref = document.getElementById($aa519ee6cf463259$export$68e648cbec363a18(state, 0))) === null || ref === void 0 ? void 0 : ref.focus();
|
|
132
|
+
$fA3fN$setInteractionModality('keyboard');
|
|
129
133
|
};
|
|
130
134
|
}
|
|
131
135
|
return {
|
|
@@ -137,7 +141,7 @@ function $9006468ca971c07d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
137
141
|
role: 'group',
|
|
138
142
|
...fieldProps
|
|
139
143
|
},
|
|
140
|
-
trackProps: $
|
|
144
|
+
trackProps: $fA3fN$mergeProps({
|
|
141
145
|
onMouseDown (e) {
|
|
142
146
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
143
147
|
onDownTrack(e, undefined, e.clientX, e.clientY);
|
|
@@ -151,7 +155,7 @@ function $9006468ca971c07d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
151
155
|
}
|
|
152
156
|
}, moveProps),
|
|
153
157
|
outputProps: {
|
|
154
|
-
htmlFor: state.values.map((_, index)=>$
|
|
158
|
+
htmlFor: state.values.map((_, index)=>$aa519ee6cf463259$export$68e648cbec363a18(state, index)
|
|
155
159
|
).join(' '),
|
|
156
160
|
'aria-live': 'off'
|
|
157
161
|
}
|
|
@@ -159,9 +163,9 @@ function $9006468ca971c07d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
159
163
|
}
|
|
160
164
|
|
|
161
165
|
|
|
162
|
-
var $
|
|
166
|
+
var $47b897dc8cdb026b$exports = {};
|
|
163
167
|
|
|
164
|
-
$parcel$export($
|
|
168
|
+
$parcel$export($47b897dc8cdb026b$exports, "useSliderThumb", () => $47b897dc8cdb026b$export$8d15029008292ae);
|
|
165
169
|
|
|
166
170
|
|
|
167
171
|
|
|
@@ -169,66 +173,95 @@ $parcel$export($fa28a9d9b8b61e27$exports, "useSliderThumb", () => $fa28a9d9b8b61
|
|
|
169
173
|
|
|
170
174
|
|
|
171
175
|
|
|
172
|
-
function $
|
|
176
|
+
function $47b897dc8cdb026b$export$8d15029008292ae(opts, state) {
|
|
173
177
|
let { index: index , isRequired: isRequired , isDisabled: isDisabled , validationState: validationState , trackRef: trackRef , inputRef: inputRef } = opts;
|
|
174
178
|
let isVertical = opts.orientation === 'vertical';
|
|
175
|
-
let { direction: direction } = $
|
|
176
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $
|
|
177
|
-
let labelId = $
|
|
178
|
-
|
|
179
|
+
let { direction: direction } = $fA3fN$useLocale();
|
|
180
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $fA3fN$useGlobalListeners();
|
|
181
|
+
let labelId = $aa519ee6cf463259$export$7a8d2b02c9371cbf.get(state);
|
|
182
|
+
var ref1;
|
|
183
|
+
const { labelProps: labelProps , fieldProps: fieldProps } = $fA3fN$useLabel({
|
|
179
184
|
...opts,
|
|
180
|
-
id: $
|
|
181
|
-
'aria-labelledby': `${labelId} ${opts['aria-labelledby']
|
|
185
|
+
id: $aa519ee6cf463259$export$68e648cbec363a18(state, index),
|
|
186
|
+
'aria-labelledby': `${labelId} ${(ref1 = opts['aria-labelledby']) !== null && ref1 !== void 0 ? ref1 : ''}`.trim()
|
|
182
187
|
});
|
|
183
188
|
const value = state.values[index];
|
|
184
|
-
const focusInput = $
|
|
185
|
-
if (inputRef.current) $
|
|
189
|
+
const focusInput = $fA3fN$useCallback(()=>{
|
|
190
|
+
if (inputRef.current) $fA3fN$focusWithoutScrolling(inputRef.current);
|
|
186
191
|
}, [
|
|
187
192
|
inputRef
|
|
188
193
|
]);
|
|
189
194
|
const isFocused = state.focusedThumb === index;
|
|
190
|
-
$
|
|
195
|
+
$fA3fN$useEffect(()=>{
|
|
191
196
|
if (isFocused) focusInput();
|
|
192
197
|
}, [
|
|
193
198
|
isFocused,
|
|
194
199
|
focusInput
|
|
195
200
|
]);
|
|
196
|
-
const stateRef = $
|
|
201
|
+
const stateRef = $fA3fN$useRef(null);
|
|
197
202
|
stateRef.current = state;
|
|
198
203
|
let reverseX = direction === 'rtl';
|
|
199
|
-
let currentPosition = $
|
|
200
|
-
let {
|
|
204
|
+
let currentPosition = $fA3fN$useRef(null);
|
|
205
|
+
let { keyboardProps: keyboardProps } = $fA3fN$useKeyboard({
|
|
206
|
+
onKeyDown (e) {
|
|
207
|
+
let { getThumbMaxValue: getThumbMaxValue , getThumbMinValue: getThumbMinValue , decrementThumb: decrementThumb , incrementThumb: incrementThumb , setThumbValue: setThumbValue , setThumbDragging: setThumbDragging , pageSize: pageSize } = stateRef.current;
|
|
208
|
+
// these are the cases that useMove or useSlider don't handle
|
|
209
|
+
if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
|
|
210
|
+
e.continuePropagation();
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
// same handling as useMove, stopPropagation to prevent useSlider from handling the event as well.
|
|
214
|
+
e.preventDefault();
|
|
215
|
+
// remember to set this so that onChangeEnd is fired
|
|
216
|
+
setThumbDragging(index, true);
|
|
217
|
+
switch(e.key){
|
|
218
|
+
case 'PageUp':
|
|
219
|
+
incrementThumb(index, pageSize);
|
|
220
|
+
break;
|
|
221
|
+
case 'PageDown':
|
|
222
|
+
decrementThumb(index, pageSize);
|
|
223
|
+
break;
|
|
224
|
+
case 'Home':
|
|
225
|
+
setThumbValue(index, getThumbMinValue(index));
|
|
226
|
+
break;
|
|
227
|
+
case 'End':
|
|
228
|
+
setThumbValue(index, getThumbMaxValue(index));
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
setThumbDragging(index, false);
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
let { moveProps: moveProps } = $fA3fN$useMove({
|
|
201
235
|
onMoveStart () {
|
|
202
236
|
currentPosition.current = null;
|
|
203
|
-
|
|
237
|
+
stateRef.current.setThumbDragging(index, true);
|
|
204
238
|
},
|
|
205
|
-
onMove ({ deltaX: deltaX , deltaY: deltaY , pointerType: pointerType }) {
|
|
239
|
+
onMove ({ deltaX: deltaX , deltaY: deltaY , pointerType: pointerType , shiftKey: shiftKey }) {
|
|
240
|
+
const { getThumbPercent: getThumbPercent , setThumbPercent: setThumbPercent , decrementThumb: decrementThumb , incrementThumb: incrementThumb , step: step , pageSize: pageSize } = stateRef.current;
|
|
206
241
|
let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth;
|
|
207
|
-
if (currentPosition.current == null) currentPosition.current =
|
|
242
|
+
if (currentPosition.current == null) currentPosition.current = getThumbPercent(index) * size;
|
|
208
243
|
if (pointerType === 'keyboard') {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
currentPosition.current += delta * size;
|
|
212
|
-
stateRef.current.setThumbValue(index, stateRef.current.getThumbValue(index) + delta);
|
|
244
|
+
if (deltaX > 0 && reverseX || deltaX < 0 && !reverseX || deltaY > 0) decrementThumb(index, shiftKey ? pageSize : step);
|
|
245
|
+
else incrementThumb(index, shiftKey ? pageSize : step);
|
|
213
246
|
} else {
|
|
214
247
|
let delta = isVertical ? deltaY : deltaX;
|
|
215
248
|
if (isVertical || reverseX) delta = -delta;
|
|
216
249
|
currentPosition.current += delta;
|
|
217
|
-
|
|
250
|
+
setThumbPercent(index, $fA3fN$clamp(currentPosition.current / size, 0, 1));
|
|
218
251
|
}
|
|
219
252
|
},
|
|
220
253
|
onMoveEnd () {
|
|
221
|
-
|
|
254
|
+
stateRef.current.setThumbDragging(index, false);
|
|
222
255
|
}
|
|
223
256
|
});
|
|
224
257
|
// Immediately register editability with the state
|
|
225
258
|
state.setThumbEditable(index, !isDisabled);
|
|
226
|
-
const { focusableProps: focusableProps } = $
|
|
259
|
+
const { focusableProps: focusableProps } = $fA3fN$useFocusable($fA3fN$mergeProps(opts, {
|
|
227
260
|
onFocus: ()=>state.setFocusedThumb(index)
|
|
228
261
|
,
|
|
229
262
|
onBlur: ()=>state.setFocusedThumb(undefined)
|
|
230
263
|
}), inputRef);
|
|
231
|
-
let currentPointer = $
|
|
264
|
+
let currentPointer = $fA3fN$useRef(undefined);
|
|
232
265
|
let onDown = (id)=>{
|
|
233
266
|
focusInput();
|
|
234
267
|
currentPointer.current = id;
|
|
@@ -238,7 +271,9 @@ function $fa28a9d9b8b61e27$export$8d15029008292ae(opts, state) {
|
|
|
238
271
|
addGlobalListener(window, 'pointerup', onUp, false);
|
|
239
272
|
};
|
|
240
273
|
let onUp = (e)=>{
|
|
241
|
-
|
|
274
|
+
var ref;
|
|
275
|
+
var _pointerId;
|
|
276
|
+
let id = (_pointerId = e.pointerId) !== null && _pointerId !== void 0 ? _pointerId : (ref = e.changedTouches) === null || ref === void 0 ? void 0 : ref[0].identifier;
|
|
242
277
|
if (id === currentPointer.current) {
|
|
243
278
|
focusInput();
|
|
244
279
|
state.setThumbDragging(index, false);
|
|
@@ -252,7 +287,7 @@ function $fa28a9d9b8b61e27$export$8d15029008292ae(opts, state) {
|
|
|
252
287
|
// we focus the range input, and let the browser handle the keyboard
|
|
253
288
|
// interactions; we then listen to input's onChange to update state.
|
|
254
289
|
return {
|
|
255
|
-
inputProps: $
|
|
290
|
+
inputProps: $fA3fN$mergeProps(focusableProps, fieldProps, {
|
|
256
291
|
type: 'range',
|
|
257
292
|
tabIndex: !isDisabled ? 0 : undefined,
|
|
258
293
|
min: state.getThumbMinValue(index),
|
|
@@ -266,10 +301,10 @@ function $fa28a9d9b8b61e27$export$8d15029008292ae(opts, state) {
|
|
|
266
301
|
'aria-invalid': validationState === 'invalid' || undefined,
|
|
267
302
|
'aria-errormessage': opts['aria-errormessage'],
|
|
268
303
|
onChange: (e)=>{
|
|
269
|
-
|
|
304
|
+
stateRef.current.setThumbValue(index, parseFloat(e.target.value));
|
|
270
305
|
}
|
|
271
306
|
}),
|
|
272
|
-
thumbProps: !isDisabled ? $
|
|
307
|
+
thumbProps: !isDisabled ? $fA3fN$mergeProps(keyboardProps, moveProps, {
|
|
273
308
|
onMouseDown: (e)=>{
|
|
274
309
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
275
310
|
onDown();
|
|
@@ -290,5 +325,5 @@ function $fa28a9d9b8b61e27$export$8d15029008292ae(opts, state) {
|
|
|
290
325
|
|
|
291
326
|
|
|
292
327
|
|
|
293
|
-
export {$
|
|
328
|
+
export {$bcca50147b47f54d$export$56b2c08e277f365 as useSlider, $47b897dc8cdb026b$export$8d15029008292ae as useSliderThumb};
|
|
294
329
|
//# sourceMappingURL=module.js.map
|
package/dist/module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;AEEO,KAAK,CAAC,yCAAS,GAAG,GAA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gB,iBAAE,KAAK,CAAC,kBAAkB,CAAC,KAAK;YAChD,CAAe,gBAAE,UAAU,IAAI,SAAS;YACxC,CAAc,eAAE,eAAe,KAAK,CAAS,YAAI,SAAS;YAC1D,CAAmB,oBAAE,IAAI,CAAC,CAAmB;YAC7C,QAAQ,GAAG,CAAgC,GAAK,CAAC;gBAC/C,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK;YACtD,CAAC;QACH,CAAC;QACD,UAAU,GAAG,UAAU,GAAG,iBAAU,CAClC,SAAS,EACT,CAAC;YACC,WAAW,GAAG,CAAgC,GAAK,CAAC;gBAClD,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EACtD,MAAM;gBAER,MAAM;YACR,CAAC;YACD,aAAa,GAAG,CAAkC,GAAK,CAAC;gBACtD,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EACtD,MAAM;gBAER,MAAM,CAAC,CAAC,CAAC,SAAS;YACpB,CAAC;YACD,YAAY,GAAG,CAAgC,GAAK,CAAC;gBAAA,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,UAAU;YAAE,CAAC;QAC/F,CAAC,IACC,CAAC;QAAA,CAAC;oBACN,UAAU;IACZ,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/slider/src/index.ts","packages/@react-aria/slider/src/useSlider.ts","packages/@react-aria/slider/src/utils.ts","packages/@react-aria/slider/src/useSliderThumb.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 */\n\nexport * from './useSlider';\nexport * from './useSliderThumb';\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 {AriaSliderProps} from '@react-types/slider';\nimport {clamp, mergeProps, useGlobalListeners} from '@react-aria/utils';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {HTMLAttributes, LabelHTMLAttributes, OutputHTMLAttributes, RefObject, useRef} from 'react';\nimport {setInteractionModality, useMove} from '@react-aria/interactions';\nimport {SliderState} from '@react-stately/slider';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface SliderAria {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n\n /** Props for the root element of the slider component; groups slider inputs. */\n groupProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the track element. */\n trackProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the output element, displaying the value of the slider thumbs. */\n outputProps: OutputHTMLAttributes<HTMLOutputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a slider component representing one or more values.\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: AriaSliderProps,\n state: SliderState,\n trackRef: 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 // to find the closet thumb we split the array based on the first thumb position to the \"right/end\" of the click.\n let closestThumb;\n let split = state.values.findIndex(v => value - v < 0);\n if (split === 0) { // If the index is zero then the closetThumb is the first one\n closestThumb = split;\n } else if (split === -1) { // If no index is found they've clicked past all the thumbs\n closestThumb = state.values.length - 1;\n } else {\n let lastLeft = state.values[split - 1];\n let firstRight = state.values[split];\n // Pick the last left/start thumb, unless they are stacked on top of each other, then pick the right/end one\n if (Math.abs(lastLeft - value) < Math.abs(firstRight - value)) {\n closestThumb = split - 1;\n } else {\n closestThumb = split;\n }\n }\n\n // Confirm that the found closest thumb is editable, not disabled, and move it\n if (closestThumb >= 0 && state.isThumbEditable(closestThumb)) {\n // Don't unfocus anything\n e.preventDefault();\n\n realTimeTrackDraggingIndex.current = closestThumb;\n state.setFocusedThumb(closestThumb);\n currentPointer.current = id;\n\n state.setThumbDragging(realTimeTrackDraggingIndex.current, true);\n state.setThumbValue(closestThumb, 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 if (labelProps.htmlFor) {\n // Ideally the `for` attribute should point to the first thumb, but VoiceOver on iOS\n // causes this to override the `aria-labelledby` on the thumb. This causes the first\n // thumb to only be announced as the slider label rather than its individual name as well.\n // See https://bugs.webkit.org/show_bug.cgi?id=172464.\n delete labelProps.htmlFor;\n labelProps.onClick = () => {\n // Safari does not focus <input type=\"range\"> elements when clicking on an associated <label>,\n // so do it manually. In addition, make sure we show the focus ring.\n document.getElementById(getSliderThumbId(state, 0))?.focus();\n setInteractionModality('keyboard');\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 groupProps: {\n role: 'group',\n ...fieldProps\n },\n trackProps: mergeProps({\n onMouseDown(e: React.MouseEvent<HTMLElement>) {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDownTrack(e, undefined, e.clientX, e.clientY);\n },\n onPointerDown(e: React.PointerEvent<HTMLElement>) {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onDownTrack(e, e.pointerId, e.clientX, e.clientY);\n },\n onTouchStart(e: React.TouchEvent<HTMLElement>) { onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY); }\n }, moveProps),\n outputProps: {\n htmlFor: state.values.map((_, index) => getSliderThumbId(state, index)).join(' '),\n 'aria-live': 'off'\n }\n };\n}\n","import {SliderState} from '@react-stately/slider';\n\nexport const sliderIds = new WeakMap<SliderState, string>();\n\nexport function getSliderThumbId(state: SliderState, index: number) {\n let id = sliderIds.get(state);\n if (!id) {\n throw new Error('Unknown slider state');\n }\n\n return `${id}-${index}`;\n}\n","import {AriaSliderThumbProps} from '@react-types/slider';\nimport {clamp, focusWithoutScrolling, mergeProps, useGlobalListeners} from '@react-aria/utils';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {ChangeEvent, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, RefObject, useCallback, useEffect, useRef} from 'react';\nimport {SliderState} from '@react-stately/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 root thumb element; handles the dragging motion. */\n thumbProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n\n /** Props for the label element for this thumb (optional). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>\n}\n\ninterface SliderThumbOptions extends AriaSliderThumbProps {\n /** A ref to the track element. */\n trackRef: RefObject<HTMLElement>,\n /** A ref to the thumb input element. */\n inputRef: 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 id: getSliderThumbId(state, index),\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 | undefined>(undefined);\n let onDown = (id?: number) => {\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: (e: React.MouseEvent<HTMLElement>) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown();\n },\n onPointerDown: (e: React.PointerEvent<HTMLElement>) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent<HTMLElement>) => {onDown(e.changedTouches[0].identifier);}\n }\n ) : {},\n labelProps\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;;AEEO,KAAK,CAAC,yCAAS,GAAG,GAAG,CAAC,OAAO;SAEpB,yCAAgB,CAAC,KAAkB,EAAE,KAAa,EAAE,CAAC;IACnE,GAAG,CAAC,EAAE,GAAG,yCAAS,CAAC,GAAG,CAAC,KAAK;IAC5B,EAAE,GAAG,EAAE,EACL,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAsB;IAGxC,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,KAAK;AACvB,CAAC;;;;;;;SDkCe,wCAAS,CACvB,KAAsB,EACtB,KAAkB,EAClB,QAAgC,EACpB,CAAC;IACb,GAAG,CAAC,CAAC,aAAA,UAAU,eAAE,UAAU,EAAA,CAAC,GAAG,eAAQ,CAAC,KAAK;IAE7C,GAAG,CAAC,UAAU,GAAG,KAAK,CAAC,WAAW,KAAK,CAAU;QAG5B,GAAa;IADlC,EAA+E,AAA/E,6EAA+E;IAC/E,yCAAS,CAA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E,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK;YACjE,CAAC;QACH,CAAC;QACD,UAAU,GAAG,UAAU,GAAG,iBAAU,CAClC,aAAa,EACb,SAAS,EACT,CAAC;YACC,WAAW,GAAG,CAAgC,GAAK,CAAC;gBAClD,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EACtD,MAAM;gBAER,MAAM;YACR,CAAC;YACD,aAAa,GAAG,CAAkC,GAAK,CAAC;gBACtD,EAAE,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,EACtD,MAAM;gBAER,MAAM,CAAC,CAAC,CAAC,SAAS;YACpB,CAAC;YACD,YAAY,GAAG,CAAgC,GAAK,CAAC;gBAAA,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,EAAE,UAAU;YAAE,CAAC;QAC/F,CAAC,IACC,CAAC;QAAA,CAAC;oBACN,UAAU;IACZ,CAAC;AACH,CAAC;;","sources":["packages/@react-aria/slider/src/index.ts","packages/@react-aria/slider/src/useSlider.ts","packages/@react-aria/slider/src/utils.ts","packages/@react-aria/slider/src/useSliderThumb.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 */\n\nexport * from './useSlider';\nexport * from './useSliderThumb';\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 {AriaSliderProps} from '@react-types/slider';\nimport {clamp, mergeProps, useGlobalListeners} from '@react-aria/utils';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {HTMLAttributes, LabelHTMLAttributes, OutputHTMLAttributes, RefObject, useRef} from 'react';\nimport {setInteractionModality, useMove} from '@react-aria/interactions';\nimport {SliderState} from '@react-stately/slider';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface SliderAria {\n /** Props for the label element. */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>,\n\n /** Props for the root element of the slider component; groups slider inputs. */\n groupProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the track element. */\n trackProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the output element, displaying the value of the slider thumbs. */\n outputProps: OutputHTMLAttributes<HTMLOutputElement>\n}\n\n/**\n * Provides the behavior and accessibility implementation for a slider component representing one or more values.\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: AriaSliderProps,\n state: SliderState,\n trackRef: 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 // to find the closet thumb we split the array based on the first thumb position to the \"right/end\" of the click.\n let closestThumb;\n let split = state.values.findIndex(v => value - v < 0);\n if (split === 0) { // If the index is zero then the closetThumb is the first one\n closestThumb = split;\n } else if (split === -1) { // If no index is found they've clicked past all the thumbs\n closestThumb = state.values.length - 1;\n } else {\n let lastLeft = state.values[split - 1];\n let firstRight = state.values[split];\n // Pick the last left/start thumb, unless they are stacked on top of each other, then pick the right/end one\n if (Math.abs(lastLeft - value) < Math.abs(firstRight - value)) {\n closestThumb = split - 1;\n } else {\n closestThumb = split;\n }\n }\n\n // Confirm that the found closest thumb is editable, not disabled, and move it\n if (closestThumb >= 0 && state.isThumbEditable(closestThumb)) {\n // Don't unfocus anything\n e.preventDefault();\n\n realTimeTrackDraggingIndex.current = closestThumb;\n state.setFocusedThumb(closestThumb);\n currentPointer.current = id;\n\n state.setThumbDragging(realTimeTrackDraggingIndex.current, true);\n state.setThumbValue(closestThumb, 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 if (labelProps.htmlFor) {\n // Ideally the `for` attribute should point to the first thumb, but VoiceOver on iOS\n // causes this to override the `aria-labelledby` on the thumb. This causes the first\n // thumb to only be announced as the slider label rather than its individual name as well.\n // See https://bugs.webkit.org/show_bug.cgi?id=172464.\n delete labelProps.htmlFor;\n labelProps.onClick = () => {\n // Safari does not focus <input type=\"range\"> elements when clicking on an associated <label>,\n // so do it manually. In addition, make sure we show the focus ring.\n document.getElementById(getSliderThumbId(state, 0))?.focus();\n setInteractionModality('keyboard');\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 groupProps: {\n role: 'group',\n ...fieldProps\n },\n trackProps: mergeProps({\n onMouseDown(e: React.MouseEvent<HTMLElement>) {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDownTrack(e, undefined, e.clientX, e.clientY);\n },\n onPointerDown(e: React.PointerEvent<HTMLElement>) {\n if (e.pointerType === 'mouse' && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) {\n return;\n }\n onDownTrack(e, e.pointerId, e.clientX, e.clientY);\n },\n onTouchStart(e: React.TouchEvent<HTMLElement>) { onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY); }\n }, moveProps),\n outputProps: {\n htmlFor: state.values.map((_, index) => getSliderThumbId(state, index)).join(' '),\n 'aria-live': 'off'\n }\n };\n}\n","import {SliderState} from '@react-stately/slider';\n\nexport const sliderIds = new WeakMap<SliderState, string>();\n\nexport function getSliderThumbId(state: SliderState, index: number) {\n let id = sliderIds.get(state);\n if (!id) {\n throw new Error('Unknown slider state');\n }\n\n return `${id}-${index}`;\n}\n","import {AriaSliderThumbProps} from '@react-types/slider';\nimport {clamp, focusWithoutScrolling, mergeProps, useGlobalListeners} from '@react-aria/utils';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {ChangeEvent, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, RefObject, useCallback, useEffect, useRef} from 'react';\nimport {SliderState} from '@react-stately/slider';\nimport {useFocusable} from '@react-aria/focus';\nimport {useKeyboard, useMove} from '@react-aria/interactions';\nimport {useLabel} from '@react-aria/label';\nimport {useLocale} from '@react-aria/i18n';\n\ninterface SliderThumbAria {\n /** Props for the root thumb element; handles the dragging motion. */\n thumbProps: HTMLAttributes<HTMLElement>,\n\n /** Props for the visually hidden range input element. */\n inputProps: InputHTMLAttributes<HTMLInputElement>,\n\n /** Props for the label element for this thumb (optional). */\n labelProps: LabelHTMLAttributes<HTMLLabelElement>\n}\n\ninterface SliderThumbOptions extends AriaSliderThumbProps {\n /** A ref to the track element. */\n trackRef: RefObject<HTMLElement>,\n /** A ref to the thumb input element. */\n inputRef: 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 id: getSliderThumbId(state, index),\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\n let {keyboardProps} = useKeyboard({\n onKeyDown(e) {\n let {\n getThumbMaxValue,\n getThumbMinValue,\n decrementThumb,\n incrementThumb,\n setThumbValue,\n setThumbDragging,\n pageSize\n } = stateRef.current;\n // these are the cases that useMove or useSlider don't handle\n if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {\n e.continuePropagation();\n return;\n }\n // same handling as useMove, stopPropagation to prevent useSlider from handling the event as well.\n e.preventDefault();\n // remember to set this so that onChangeEnd is fired\n setThumbDragging(index, true);\n switch (e.key) {\n case 'PageUp':\n incrementThumb(index, pageSize);\n break;\n case 'PageDown':\n decrementThumb(index, pageSize);\n break;\n case 'Home':\n setThumbValue(index, getThumbMinValue(index));\n break;\n case 'End':\n setThumbValue(index, getThumbMaxValue(index));\n break;\n }\n setThumbDragging(index, false);\n }\n });\n\n let {moveProps} = useMove({\n onMoveStart() {\n currentPosition.current = null;\n stateRef.current.setThumbDragging(index, true);\n },\n onMove({deltaX, deltaY, pointerType, shiftKey}) {\n const {\n getThumbPercent,\n setThumbPercent,\n decrementThumb,\n incrementThumb,\n step,\n pageSize\n } = stateRef.current;\n let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth;\n\n if (currentPosition.current == null) {\n currentPosition.current = getThumbPercent(index) * size;\n }\n if (pointerType === 'keyboard') {\n if ((deltaX > 0 && reverseX) || (deltaX < 0 && !reverseX) || deltaY > 0) {\n decrementThumb(index, shiftKey ? pageSize : step);\n } else {\n incrementThumb(index, shiftKey ? pageSize : step);\n }\n } else {\n let delta = isVertical ? deltaY : deltaX;\n if (isVertical || reverseX) {\n delta = -delta;\n }\n\n currentPosition.current += delta;\n setThumbPercent(index, clamp(currentPosition.current / size, 0, 1));\n }\n },\n onMoveEnd() {\n stateRef.current.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 | undefined>(undefined);\n let onDown = (id?: number) => {\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 stateRef.current.setThumbValue(index, parseFloat(e.target.value));\n }\n }),\n thumbProps: !isDisabled ? mergeProps(\n keyboardProps,\n moveProps,\n {\n onMouseDown: (e: React.MouseEvent<HTMLElement>) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown();\n },\n onPointerDown: (e: React.PointerEvent<HTMLElement>) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent<HTMLElement>) => {onDown(e.changedTouches[0].identifier);}\n }\n ) : {},\n labelProps\n };\n}\n"],"names":[],"version":3,"file":"module.js.map"}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;ACqBA;IACE,mCAAmC;IACnC,UAAU,EAAE,oBAAoB,gBAAgB,CAAC,CAAC;IAElD,gFAAgF;IAChF,UAAU,EAAE,eAAe,WAAW,CAAC,CAAC;IAExC,mCAAmC;IACnC,UAAU,EAAE,eAAe,WAAW,CAAC,CAAC;IAExC,+EAA+E;IAC/E,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IACvD,kCAAkC;IAClC,QAAQ,EAAE,UAAU,WAAW,CAAC,CAAC;IACjC,wCAAwC;IACxC,QAAQ,EAAE,UAAU,gBAAgB,CAAC,CAAA;CACtC;AAED;;;;;GAKG;AACH,+BACE,IAAI,EAAE,kBAAkB,EACxB,KAAK,EAAE,WAAW,GACjB,eAAe,CAsMjB","sources":["packages/@react-aria/slider/src/packages/@react-aria/slider/src/utils.ts","packages/@react-aria/slider/src/packages/@react-aria/slider/src/useSlider.ts","packages/@react-aria/slider/src/packages/@react-aria/slider/src/useSliderThumb.ts","packages/@react-aria/slider/src/packages/@react-aria/slider/src/index.ts","packages/@react-aria/slider/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\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\nexport * from './useSlider';\nexport * from './useSliderThumb';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/slider",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6-nightly.3120+1aa66e6e7",
|
|
4
4
|
"description": "Slider",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -18,15 +18,15 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@babel/runtime": "^7.6.2",
|
|
21
|
-
"@react-aria/focus": "
|
|
22
|
-
"@react-aria/i18n": "
|
|
23
|
-
"@react-aria/interactions": "
|
|
24
|
-
"@react-aria/label": "
|
|
25
|
-
"@react-aria/utils": "
|
|
26
|
-
"@react-stately/radio": "
|
|
27
|
-
"@react-stately/slider": "
|
|
28
|
-
"@react-types/radio": "
|
|
29
|
-
"@react-types/slider": "
|
|
21
|
+
"@react-aria/focus": "3.0.0-nightly.1424+1aa66e6e7",
|
|
22
|
+
"@react-aria/i18n": "3.0.0-nightly.1424+1aa66e6e7",
|
|
23
|
+
"@react-aria/interactions": "3.0.0-nightly.1424+1aa66e6e7",
|
|
24
|
+
"@react-aria/label": "3.0.0-nightly.1424+1aa66e6e7",
|
|
25
|
+
"@react-aria/utils": "3.0.0-nightly.1424+1aa66e6e7",
|
|
26
|
+
"@react-stately/radio": "3.0.0-nightly.1424+1aa66e6e7",
|
|
27
|
+
"@react-stately/slider": "3.0.6-nightly.3120+1aa66e6e7",
|
|
28
|
+
"@react-types/radio": "3.0.0-nightly.1424+1aa66e6e7",
|
|
29
|
+
"@react-types/slider": "3.0.5-nightly.3120+1aa66e6e7"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": "^16.8.0 || ^17.0.0-rc.1"
|
|
@@ -34,5 +34,5 @@
|
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "1aa66e6e75e2da014f44177686c3332cd625fb9f"
|
|
38
38
|
}
|
package/src/useSliderThumb.ts
CHANGED
|
@@ -4,9 +4,9 @@ import {getSliderThumbId, sliderIds} from './utils';
|
|
|
4
4
|
import React, {ChangeEvent, HTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, RefObject, useCallback, useEffect, useRef} from 'react';
|
|
5
5
|
import {SliderState} from '@react-stately/slider';
|
|
6
6
|
import {useFocusable} from '@react-aria/focus';
|
|
7
|
+
import {useKeyboard, useMove} from '@react-aria/interactions';
|
|
7
8
|
import {useLabel} from '@react-aria/label';
|
|
8
9
|
import {useLocale} from '@react-aria/i18n';
|
|
9
|
-
import {useMove} from '@react-aria/interactions';
|
|
10
10
|
|
|
11
11
|
interface SliderThumbAria {
|
|
12
12
|
/** Props for the root thumb element; handles the dragging motion. */
|
|
@@ -77,22 +77,70 @@ export function useSliderThumb(
|
|
|
77
77
|
stateRef.current = state;
|
|
78
78
|
let reverseX = direction === 'rtl';
|
|
79
79
|
let currentPosition = useRef<number>(null);
|
|
80
|
+
|
|
81
|
+
let {keyboardProps} = useKeyboard({
|
|
82
|
+
onKeyDown(e) {
|
|
83
|
+
let {
|
|
84
|
+
getThumbMaxValue,
|
|
85
|
+
getThumbMinValue,
|
|
86
|
+
decrementThumb,
|
|
87
|
+
incrementThumb,
|
|
88
|
+
setThumbValue,
|
|
89
|
+
setThumbDragging,
|
|
90
|
+
pageSize
|
|
91
|
+
} = stateRef.current;
|
|
92
|
+
// these are the cases that useMove or useSlider don't handle
|
|
93
|
+
if (!/^(PageUp|PageDown|Home|End)$/.test(e.key)) {
|
|
94
|
+
e.continuePropagation();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
// same handling as useMove, stopPropagation to prevent useSlider from handling the event as well.
|
|
98
|
+
e.preventDefault();
|
|
99
|
+
// remember to set this so that onChangeEnd is fired
|
|
100
|
+
setThumbDragging(index, true);
|
|
101
|
+
switch (e.key) {
|
|
102
|
+
case 'PageUp':
|
|
103
|
+
incrementThumb(index, pageSize);
|
|
104
|
+
break;
|
|
105
|
+
case 'PageDown':
|
|
106
|
+
decrementThumb(index, pageSize);
|
|
107
|
+
break;
|
|
108
|
+
case 'Home':
|
|
109
|
+
setThumbValue(index, getThumbMinValue(index));
|
|
110
|
+
break;
|
|
111
|
+
case 'End':
|
|
112
|
+
setThumbValue(index, getThumbMaxValue(index));
|
|
113
|
+
break;
|
|
114
|
+
}
|
|
115
|
+
setThumbDragging(index, false);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
80
119
|
let {moveProps} = useMove({
|
|
81
120
|
onMoveStart() {
|
|
82
121
|
currentPosition.current = null;
|
|
83
|
-
|
|
122
|
+
stateRef.current.setThumbDragging(index, true);
|
|
84
123
|
},
|
|
85
|
-
onMove({deltaX, deltaY, pointerType}) {
|
|
124
|
+
onMove({deltaX, deltaY, pointerType, shiftKey}) {
|
|
125
|
+
const {
|
|
126
|
+
getThumbPercent,
|
|
127
|
+
setThumbPercent,
|
|
128
|
+
decrementThumb,
|
|
129
|
+
incrementThumb,
|
|
130
|
+
step,
|
|
131
|
+
pageSize
|
|
132
|
+
} = stateRef.current;
|
|
86
133
|
let size = isVertical ? trackRef.current.offsetHeight : trackRef.current.offsetWidth;
|
|
87
134
|
|
|
88
135
|
if (currentPosition.current == null) {
|
|
89
|
-
currentPosition.current =
|
|
136
|
+
currentPosition.current = getThumbPercent(index) * size;
|
|
90
137
|
}
|
|
91
138
|
if (pointerType === 'keyboard') {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
139
|
+
if ((deltaX > 0 && reverseX) || (deltaX < 0 && !reverseX) || deltaY > 0) {
|
|
140
|
+
decrementThumb(index, shiftKey ? pageSize : step);
|
|
141
|
+
} else {
|
|
142
|
+
incrementThumb(index, shiftKey ? pageSize : step);
|
|
143
|
+
}
|
|
96
144
|
} else {
|
|
97
145
|
let delta = isVertical ? deltaY : deltaX;
|
|
98
146
|
if (isVertical || reverseX) {
|
|
@@ -100,11 +148,11 @@ export function useSliderThumb(
|
|
|
100
148
|
}
|
|
101
149
|
|
|
102
150
|
currentPosition.current += delta;
|
|
103
|
-
|
|
151
|
+
setThumbPercent(index, clamp(currentPosition.current / size, 0, 1));
|
|
104
152
|
}
|
|
105
153
|
},
|
|
106
154
|
onMoveEnd() {
|
|
107
|
-
|
|
155
|
+
stateRef.current.setThumbDragging(index, false);
|
|
108
156
|
}
|
|
109
157
|
});
|
|
110
158
|
|
|
@@ -161,10 +209,11 @@ export function useSliderThumb(
|
|
|
161
209
|
'aria-invalid': validationState === 'invalid' || undefined,
|
|
162
210
|
'aria-errormessage': opts['aria-errormessage'],
|
|
163
211
|
onChange: (e: ChangeEvent<HTMLInputElement>) => {
|
|
164
|
-
|
|
212
|
+
stateRef.current.setThumbValue(index, parseFloat(e.target.value));
|
|
165
213
|
}
|
|
166
214
|
}),
|
|
167
215
|
thumbProps: !isDisabled ? mergeProps(
|
|
216
|
+
keyboardProps,
|
|
168
217
|
moveProps,
|
|
169
218
|
{
|
|
170
219
|
onMouseDown: (e: React.MouseEvent<HTMLElement>) => {
|