@react-aria/slider 3.0.4-nightly.3085 → 3.0.4-nightly.3100
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 +47 -47
- package/dist/module.js +46 -46
- package/package.json +11 -11
package/dist/main.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
var $
|
|
2
|
-
var $
|
|
3
|
-
var $
|
|
4
|
-
var $
|
|
5
|
-
var $
|
|
6
|
-
var $
|
|
1
|
+
var $433oN$reactariautils = require("@react-aria/utils");
|
|
2
|
+
var $433oN$react = require("react");
|
|
3
|
+
var $433oN$reactariainteractions = require("@react-aria/interactions");
|
|
4
|
+
var $433oN$reactarialabel = require("@react-aria/label");
|
|
5
|
+
var $433oN$reactariai18n = require("@react-aria/i18n");
|
|
6
|
+
var $433oN$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 $59b2df71a191ec9b$exports = {};
|
|
28
28
|
|
|
29
|
-
$parcel$export($
|
|
29
|
+
$parcel$export($59b2df71a191ec9b$exports, "useSlider", () => $59b2df71a191ec9b$export$56b2c08e277f365);
|
|
30
30
|
|
|
31
|
-
const $
|
|
32
|
-
function $
|
|
33
|
-
let id = $
|
|
31
|
+
const $a834cdc37005ff28$export$7a8d2b02c9371cbf = new WeakMap();
|
|
32
|
+
function $a834cdc37005ff28$export$68e648cbec363a18(state, index) {
|
|
33
|
+
let id = $a834cdc37005ff28$export$7a8d2b02c9371cbf.get(state);
|
|
34
34
|
if (!id) throw new Error('Unknown slider state');
|
|
35
35
|
return `${id}-${index}`;
|
|
36
36
|
}
|
|
@@ -40,23 +40,23 @@ function $8c52a6191bdb125d$export$68e648cbec363a18(state, index) {
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
function $
|
|
44
|
-
let { labelProps: labelProps , fieldProps: fieldProps } = $
|
|
43
|
+
function $59b2df71a191ec9b$export$56b2c08e277f365(props, state, trackRef) {
|
|
44
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = $433oN$reactarialabel.useLabel(props);
|
|
45
45
|
let isVertical = props.orientation === 'vertical';
|
|
46
46
|
// 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 } = $
|
|
47
|
+
$a834cdc37005ff28$export$7a8d2b02c9371cbf.set(state, labelProps.id ?? fieldProps.id);
|
|
48
|
+
let { direction: direction } = $433oN$reactariai18n.useLocale();
|
|
49
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $433oN$reactariautils.useGlobalListeners();
|
|
50
50
|
// When the user clicks or drags the track, we want the motion to set and drag the
|
|
51
51
|
// closest thumb. Hence we also need to install useMove() on the track element.
|
|
52
52
|
// Here, we keep track of which index is the "closest" to the drag start point.
|
|
53
53
|
// It is set onMouseDown/onTouchDown; see trackProps below.
|
|
54
|
-
const realTimeTrackDraggingIndex = $
|
|
55
|
-
const stateRef = $
|
|
54
|
+
const realTimeTrackDraggingIndex = $433oN$react.useRef(null);
|
|
55
|
+
const stateRef = $433oN$react.useRef(null);
|
|
56
56
|
stateRef.current = state;
|
|
57
57
|
const reverseX = direction === 'rtl';
|
|
58
|
-
const currentPosition = $
|
|
59
|
-
const { moveProps: moveProps } = $
|
|
58
|
+
const currentPosition = $433oN$react.useRef(null);
|
|
59
|
+
const { moveProps: moveProps } = $433oN$reactariainteractions.useMove({
|
|
60
60
|
onMoveStart () {
|
|
61
61
|
currentPosition.current = null;
|
|
62
62
|
},
|
|
@@ -67,7 +67,7 @@ function $c435846bb557c48e$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
67
67
|
if (isVertical || reverseX) delta = -delta;
|
|
68
68
|
currentPosition.current += delta;
|
|
69
69
|
if (realTimeTrackDraggingIndex.current != null && trackRef.current) {
|
|
70
|
-
const percent = $
|
|
70
|
+
const percent = $433oN$reactariautils.clamp(currentPosition.current / size, 0, 1);
|
|
71
71
|
stateRef.current.setThumbPercent(realTimeTrackDraggingIndex.current, percent);
|
|
72
72
|
}
|
|
73
73
|
},
|
|
@@ -78,7 +78,7 @@ function $c435846bb557c48e$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
});
|
|
81
|
-
let currentPointer = $
|
|
81
|
+
let currentPointer = $433oN$react.useRef(undefined);
|
|
82
82
|
let onDownTrack = (e, id, clientX, clientY)=>{
|
|
83
83
|
// We only trigger track-dragging if the user clicks on the track itself and nothing is currently being dragged.
|
|
84
84
|
if (trackRef.current && !props.isDisabled && state.values.every((_, i)=>!state.isThumbDragging(i)
|
|
@@ -140,8 +140,8 @@ function $c435846bb557c48e$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
140
140
|
labelProps.onClick = ()=>{
|
|
141
141
|
// Safari does not focus <input type="range"> elements when clicking on an associated <label>,
|
|
142
142
|
// so do it manually. In addition, make sure we show the focus ring.
|
|
143
|
-
document.getElementById($
|
|
144
|
-
$
|
|
143
|
+
document.getElementById($a834cdc37005ff28$export$68e648cbec363a18(state, 0))?.focus();
|
|
144
|
+
$433oN$reactariainteractions.setInteractionModality('keyboard');
|
|
145
145
|
};
|
|
146
146
|
}
|
|
147
147
|
return {
|
|
@@ -153,7 +153,7 @@ function $c435846bb557c48e$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
153
153
|
role: 'group',
|
|
154
154
|
...fieldProps
|
|
155
155
|
},
|
|
156
|
-
trackProps: $
|
|
156
|
+
trackProps: $433oN$reactariautils.mergeProps({
|
|
157
157
|
onMouseDown (e) {
|
|
158
158
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
159
159
|
onDownTrack(e, undefined, e.clientX, e.clientY);
|
|
@@ -167,7 +167,7 @@ function $c435846bb557c48e$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
167
167
|
}
|
|
168
168
|
}, moveProps),
|
|
169
169
|
outputProps: {
|
|
170
|
-
htmlFor: state.values.map((_, index)=>$
|
|
170
|
+
htmlFor: state.values.map((_, index)=>$a834cdc37005ff28$export$68e648cbec363a18(state, index)
|
|
171
171
|
).join(' '),
|
|
172
172
|
'aria-live': 'off'
|
|
173
173
|
}
|
|
@@ -175,9 +175,9 @@ function $c435846bb557c48e$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
|
|
178
|
-
var $
|
|
178
|
+
var $d1bbfa318457062f$exports = {};
|
|
179
179
|
|
|
180
|
-
$parcel$export($
|
|
180
|
+
$parcel$export($d1bbfa318457062f$exports, "useSliderThumb", () => $d1bbfa318457062f$export$8d15029008292ae);
|
|
181
181
|
|
|
182
182
|
|
|
183
183
|
|
|
@@ -185,35 +185,35 @@ $parcel$export($07aa5c3f60769fb0$exports, "useSliderThumb", () => $07aa5c3f60769
|
|
|
185
185
|
|
|
186
186
|
|
|
187
187
|
|
|
188
|
-
function $
|
|
188
|
+
function $d1bbfa318457062f$export$8d15029008292ae(opts, state) {
|
|
189
189
|
let { index: index , isRequired: isRequired , isDisabled: isDisabled , validationState: validationState , trackRef: trackRef , inputRef: inputRef } = opts;
|
|
190
190
|
let isVertical = opts.orientation === 'vertical';
|
|
191
|
-
let { direction: direction } = $
|
|
192
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $
|
|
193
|
-
let labelId = $
|
|
194
|
-
const { labelProps: labelProps , fieldProps: fieldProps } = $
|
|
191
|
+
let { direction: direction } = $433oN$reactariai18n.useLocale();
|
|
192
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $433oN$reactariautils.useGlobalListeners();
|
|
193
|
+
let labelId = $a834cdc37005ff28$export$7a8d2b02c9371cbf.get(state);
|
|
194
|
+
const { labelProps: labelProps , fieldProps: fieldProps } = $433oN$reactarialabel.useLabel({
|
|
195
195
|
...opts,
|
|
196
|
-
id: $
|
|
196
|
+
id: $a834cdc37005ff28$export$68e648cbec363a18(state, index),
|
|
197
197
|
'aria-labelledby': `${labelId} ${opts['aria-labelledby'] ?? ''}`.trim()
|
|
198
198
|
});
|
|
199
199
|
const value = state.values[index];
|
|
200
|
-
const focusInput = $
|
|
201
|
-
if (inputRef.current) $
|
|
200
|
+
const focusInput = $433oN$react.useCallback(()=>{
|
|
201
|
+
if (inputRef.current) $433oN$reactariautils.focusWithoutScrolling(inputRef.current);
|
|
202
202
|
}, [
|
|
203
203
|
inputRef
|
|
204
204
|
]);
|
|
205
205
|
const isFocused = state.focusedThumb === index;
|
|
206
|
-
$
|
|
206
|
+
$433oN$react.useEffect(()=>{
|
|
207
207
|
if (isFocused) focusInput();
|
|
208
208
|
}, [
|
|
209
209
|
isFocused,
|
|
210
210
|
focusInput
|
|
211
211
|
]);
|
|
212
|
-
const stateRef = $
|
|
212
|
+
const stateRef = $433oN$react.useRef(null);
|
|
213
213
|
stateRef.current = state;
|
|
214
214
|
let reverseX = direction === 'rtl';
|
|
215
|
-
let currentPosition = $
|
|
216
|
-
let { moveProps: moveProps } = $
|
|
215
|
+
let currentPosition = $433oN$react.useRef(null);
|
|
216
|
+
let { moveProps: moveProps } = $433oN$reactariainteractions.useMove({
|
|
217
217
|
onMoveStart () {
|
|
218
218
|
currentPosition.current = null;
|
|
219
219
|
state.setThumbDragging(index, true);
|
|
@@ -230,7 +230,7 @@ function $07aa5c3f60769fb0$export$8d15029008292ae(opts, state) {
|
|
|
230
230
|
let delta = isVertical ? deltaY : deltaX;
|
|
231
231
|
if (isVertical || reverseX) delta = -delta;
|
|
232
232
|
currentPosition.current += delta;
|
|
233
|
-
stateRef.current.setThumbPercent(index, $
|
|
233
|
+
stateRef.current.setThumbPercent(index, $433oN$reactariautils.clamp(currentPosition.current / size, 0, 1));
|
|
234
234
|
}
|
|
235
235
|
},
|
|
236
236
|
onMoveEnd () {
|
|
@@ -239,12 +239,12 @@ function $07aa5c3f60769fb0$export$8d15029008292ae(opts, state) {
|
|
|
239
239
|
});
|
|
240
240
|
// Immediately register editability with the state
|
|
241
241
|
state.setThumbEditable(index, !isDisabled);
|
|
242
|
-
const { focusableProps: focusableProps } = $
|
|
242
|
+
const { focusableProps: focusableProps } = $433oN$reactariafocus.useFocusable($433oN$reactariautils.mergeProps(opts, {
|
|
243
243
|
onFocus: ()=>state.setFocusedThumb(index)
|
|
244
244
|
,
|
|
245
245
|
onBlur: ()=>state.setFocusedThumb(undefined)
|
|
246
246
|
}), inputRef);
|
|
247
|
-
let currentPointer = $
|
|
247
|
+
let currentPointer = $433oN$react.useRef(undefined);
|
|
248
248
|
let onDown = (id)=>{
|
|
249
249
|
focusInput();
|
|
250
250
|
currentPointer.current = id;
|
|
@@ -268,7 +268,7 @@ function $07aa5c3f60769fb0$export$8d15029008292ae(opts, state) {
|
|
|
268
268
|
// we focus the range input, and let the browser handle the keyboard
|
|
269
269
|
// interactions; we then listen to input's onChange to update state.
|
|
270
270
|
return {
|
|
271
|
-
inputProps: $
|
|
271
|
+
inputProps: $433oN$reactariautils.mergeProps(focusableProps, fieldProps, {
|
|
272
272
|
type: 'range',
|
|
273
273
|
tabIndex: !isDisabled ? 0 : undefined,
|
|
274
274
|
min: state.getThumbMinValue(index),
|
|
@@ -285,7 +285,7 @@ function $07aa5c3f60769fb0$export$8d15029008292ae(opts, state) {
|
|
|
285
285
|
state.setThumbValue(index, parseFloat(e.target.value));
|
|
286
286
|
}
|
|
287
287
|
}),
|
|
288
|
-
thumbProps: !isDisabled ? $
|
|
288
|
+
thumbProps: !isDisabled ? $433oN$reactariautils.mergeProps(moveProps, {
|
|
289
289
|
onMouseDown: (e)=>{
|
|
290
290
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
291
291
|
onDown();
|
|
@@ -304,8 +304,8 @@ function $07aa5c3f60769fb0$export$8d15029008292ae(opts, state) {
|
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
|
|
307
|
-
$parcel$exportWildcard(module.exports, $
|
|
308
|
-
$parcel$exportWildcard(module.exports, $
|
|
307
|
+
$parcel$exportWildcard(module.exports, $59b2df71a191ec9b$exports);
|
|
308
|
+
$parcel$exportWildcard(module.exports, $d1bbfa318457062f$exports);
|
|
309
309
|
|
|
310
310
|
|
|
311
311
|
//# sourceMappingURL=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 $hU63G$useGlobalListeners, clamp as $hU63G$clamp, mergeProps as $hU63G$mergeProps, focusWithoutScrolling as $hU63G$focusWithoutScrolling} from "@react-aria/utils";
|
|
2
|
+
import {useRef as $hU63G$useRef, useCallback as $hU63G$useCallback, useEffect as $hU63G$useEffect} from "react";
|
|
3
|
+
import {useMove as $hU63G$useMove, setInteractionModality as $hU63G$setInteractionModality} from "@react-aria/interactions";
|
|
4
|
+
import {useLabel as $hU63G$useLabel} from "@react-aria/label";
|
|
5
|
+
import {useLocale as $hU63G$useLocale} from "@react-aria/i18n";
|
|
6
|
+
import {useFocusable as $hU63G$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 $9006468ca971c07d$exports = {};
|
|
12
12
|
|
|
13
|
-
$parcel$export($
|
|
13
|
+
$parcel$export($9006468ca971c07d$exports, "useSlider", () => $9006468ca971c07d$export$56b2c08e277f365);
|
|
14
14
|
|
|
15
|
-
const $
|
|
16
|
-
function $
|
|
17
|
-
let id = $
|
|
15
|
+
const $21858bef1d0ccf3b$export$7a8d2b02c9371cbf = new WeakMap();
|
|
16
|
+
function $21858bef1d0ccf3b$export$68e648cbec363a18(state, index) {
|
|
17
|
+
let id = $21858bef1d0ccf3b$export$7a8d2b02c9371cbf.get(state);
|
|
18
18
|
if (!id) throw new Error('Unknown slider state');
|
|
19
19
|
return `${id}-${index}`;
|
|
20
20
|
}
|
|
@@ -24,23 +24,23 @@ function $7a671d3c5e67938a$export$68e648cbec363a18(state, index) {
|
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
27
|
-
function $
|
|
28
|
-
let { labelProps: labelProps , fieldProps: fieldProps } = $
|
|
27
|
+
function $9006468ca971c07d$export$56b2c08e277f365(props, state, trackRef) {
|
|
28
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = $hU63G$useLabel(props);
|
|
29
29
|
let isVertical = props.orientation === 'vertical';
|
|
30
30
|
// 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 } = $
|
|
31
|
+
$21858bef1d0ccf3b$export$7a8d2b02c9371cbf.set(state, labelProps.id ?? fieldProps.id);
|
|
32
|
+
let { direction: direction } = $hU63G$useLocale();
|
|
33
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $hU63G$useGlobalListeners();
|
|
34
34
|
// When the user clicks or drags the track, we want the motion to set and drag the
|
|
35
35
|
// closest thumb. Hence we also need to install useMove() on the track element.
|
|
36
36
|
// Here, we keep track of which index is the "closest" to the drag start point.
|
|
37
37
|
// It is set onMouseDown/onTouchDown; see trackProps below.
|
|
38
|
-
const realTimeTrackDraggingIndex = $
|
|
39
|
-
const stateRef = $
|
|
38
|
+
const realTimeTrackDraggingIndex = $hU63G$useRef(null);
|
|
39
|
+
const stateRef = $hU63G$useRef(null);
|
|
40
40
|
stateRef.current = state;
|
|
41
41
|
const reverseX = direction === 'rtl';
|
|
42
|
-
const currentPosition = $
|
|
43
|
-
const { moveProps: moveProps } = $
|
|
42
|
+
const currentPosition = $hU63G$useRef(null);
|
|
43
|
+
const { moveProps: moveProps } = $hU63G$useMove({
|
|
44
44
|
onMoveStart () {
|
|
45
45
|
currentPosition.current = null;
|
|
46
46
|
},
|
|
@@ -51,7 +51,7 @@ function $394ba6dee0c1502a$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
51
51
|
if (isVertical || reverseX) delta = -delta;
|
|
52
52
|
currentPosition.current += delta;
|
|
53
53
|
if (realTimeTrackDraggingIndex.current != null && trackRef.current) {
|
|
54
|
-
const percent = $
|
|
54
|
+
const percent = $hU63G$clamp(currentPosition.current / size, 0, 1);
|
|
55
55
|
stateRef.current.setThumbPercent(realTimeTrackDraggingIndex.current, percent);
|
|
56
56
|
}
|
|
57
57
|
},
|
|
@@ -62,7 +62,7 @@ function $394ba6dee0c1502a$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
|
-
let currentPointer = $
|
|
65
|
+
let currentPointer = $hU63G$useRef(undefined);
|
|
66
66
|
let onDownTrack = (e, id, clientX, clientY)=>{
|
|
67
67
|
// We only trigger track-dragging if the user clicks on the track itself and nothing is currently being dragged.
|
|
68
68
|
if (trackRef.current && !props.isDisabled && state.values.every((_, i)=>!state.isThumbDragging(i)
|
|
@@ -124,8 +124,8 @@ function $394ba6dee0c1502a$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
124
124
|
labelProps.onClick = ()=>{
|
|
125
125
|
// Safari does not focus <input type="range"> elements when clicking on an associated <label>,
|
|
126
126
|
// so do it manually. In addition, make sure we show the focus ring.
|
|
127
|
-
document.getElementById($
|
|
128
|
-
$
|
|
127
|
+
document.getElementById($21858bef1d0ccf3b$export$68e648cbec363a18(state, 0))?.focus();
|
|
128
|
+
$hU63G$setInteractionModality('keyboard');
|
|
129
129
|
};
|
|
130
130
|
}
|
|
131
131
|
return {
|
|
@@ -137,7 +137,7 @@ function $394ba6dee0c1502a$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
137
137
|
role: 'group',
|
|
138
138
|
...fieldProps
|
|
139
139
|
},
|
|
140
|
-
trackProps: $
|
|
140
|
+
trackProps: $hU63G$mergeProps({
|
|
141
141
|
onMouseDown (e) {
|
|
142
142
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
143
143
|
onDownTrack(e, undefined, e.clientX, e.clientY);
|
|
@@ -151,7 +151,7 @@ function $394ba6dee0c1502a$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
151
151
|
}
|
|
152
152
|
}, moveProps),
|
|
153
153
|
outputProps: {
|
|
154
|
-
htmlFor: state.values.map((_, index)=>$
|
|
154
|
+
htmlFor: state.values.map((_, index)=>$21858bef1d0ccf3b$export$68e648cbec363a18(state, index)
|
|
155
155
|
).join(' '),
|
|
156
156
|
'aria-live': 'off'
|
|
157
157
|
}
|
|
@@ -159,9 +159,9 @@ function $394ba6dee0c1502a$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
|
|
162
|
-
var $
|
|
162
|
+
var $fa28a9d9b8b61e27$exports = {};
|
|
163
163
|
|
|
164
|
-
$parcel$export($
|
|
164
|
+
$parcel$export($fa28a9d9b8b61e27$exports, "useSliderThumb", () => $fa28a9d9b8b61e27$export$8d15029008292ae);
|
|
165
165
|
|
|
166
166
|
|
|
167
167
|
|
|
@@ -169,35 +169,35 @@ $parcel$export($b6a2c1cf13588c87$exports, "useSliderThumb", () => $b6a2c1cf13588
|
|
|
169
169
|
|
|
170
170
|
|
|
171
171
|
|
|
172
|
-
function $
|
|
172
|
+
function $fa28a9d9b8b61e27$export$8d15029008292ae(opts, state) {
|
|
173
173
|
let { index: index , isRequired: isRequired , isDisabled: isDisabled , validationState: validationState , trackRef: trackRef , inputRef: inputRef } = opts;
|
|
174
174
|
let isVertical = opts.orientation === 'vertical';
|
|
175
|
-
let { direction: direction } = $
|
|
176
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $
|
|
177
|
-
let labelId = $
|
|
178
|
-
const { labelProps: labelProps , fieldProps: fieldProps } = $
|
|
175
|
+
let { direction: direction } = $hU63G$useLocale();
|
|
176
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $hU63G$useGlobalListeners();
|
|
177
|
+
let labelId = $21858bef1d0ccf3b$export$7a8d2b02c9371cbf.get(state);
|
|
178
|
+
const { labelProps: labelProps , fieldProps: fieldProps } = $hU63G$useLabel({
|
|
179
179
|
...opts,
|
|
180
|
-
id: $
|
|
180
|
+
id: $21858bef1d0ccf3b$export$68e648cbec363a18(state, index),
|
|
181
181
|
'aria-labelledby': `${labelId} ${opts['aria-labelledby'] ?? ''}`.trim()
|
|
182
182
|
});
|
|
183
183
|
const value = state.values[index];
|
|
184
|
-
const focusInput = $
|
|
185
|
-
if (inputRef.current) $
|
|
184
|
+
const focusInput = $hU63G$useCallback(()=>{
|
|
185
|
+
if (inputRef.current) $hU63G$focusWithoutScrolling(inputRef.current);
|
|
186
186
|
}, [
|
|
187
187
|
inputRef
|
|
188
188
|
]);
|
|
189
189
|
const isFocused = state.focusedThumb === index;
|
|
190
|
-
$
|
|
190
|
+
$hU63G$useEffect(()=>{
|
|
191
191
|
if (isFocused) focusInput();
|
|
192
192
|
}, [
|
|
193
193
|
isFocused,
|
|
194
194
|
focusInput
|
|
195
195
|
]);
|
|
196
|
-
const stateRef = $
|
|
196
|
+
const stateRef = $hU63G$useRef(null);
|
|
197
197
|
stateRef.current = state;
|
|
198
198
|
let reverseX = direction === 'rtl';
|
|
199
|
-
let currentPosition = $
|
|
200
|
-
let { moveProps: moveProps } = $
|
|
199
|
+
let currentPosition = $hU63G$useRef(null);
|
|
200
|
+
let { moveProps: moveProps } = $hU63G$useMove({
|
|
201
201
|
onMoveStart () {
|
|
202
202
|
currentPosition.current = null;
|
|
203
203
|
state.setThumbDragging(index, true);
|
|
@@ -214,7 +214,7 @@ function $b6a2c1cf13588c87$export$8d15029008292ae(opts, state) {
|
|
|
214
214
|
let delta = isVertical ? deltaY : deltaX;
|
|
215
215
|
if (isVertical || reverseX) delta = -delta;
|
|
216
216
|
currentPosition.current += delta;
|
|
217
|
-
stateRef.current.setThumbPercent(index, $
|
|
217
|
+
stateRef.current.setThumbPercent(index, $hU63G$clamp(currentPosition.current / size, 0, 1));
|
|
218
218
|
}
|
|
219
219
|
},
|
|
220
220
|
onMoveEnd () {
|
|
@@ -223,12 +223,12 @@ function $b6a2c1cf13588c87$export$8d15029008292ae(opts, state) {
|
|
|
223
223
|
});
|
|
224
224
|
// Immediately register editability with the state
|
|
225
225
|
state.setThumbEditable(index, !isDisabled);
|
|
226
|
-
const { focusableProps: focusableProps } = $
|
|
226
|
+
const { focusableProps: focusableProps } = $hU63G$useFocusable($hU63G$mergeProps(opts, {
|
|
227
227
|
onFocus: ()=>state.setFocusedThumb(index)
|
|
228
228
|
,
|
|
229
229
|
onBlur: ()=>state.setFocusedThumb(undefined)
|
|
230
230
|
}), inputRef);
|
|
231
|
-
let currentPointer = $
|
|
231
|
+
let currentPointer = $hU63G$useRef(undefined);
|
|
232
232
|
let onDown = (id)=>{
|
|
233
233
|
focusInput();
|
|
234
234
|
currentPointer.current = id;
|
|
@@ -252,7 +252,7 @@ function $b6a2c1cf13588c87$export$8d15029008292ae(opts, state) {
|
|
|
252
252
|
// we focus the range input, and let the browser handle the keyboard
|
|
253
253
|
// interactions; we then listen to input's onChange to update state.
|
|
254
254
|
return {
|
|
255
|
-
inputProps: $
|
|
255
|
+
inputProps: $hU63G$mergeProps(focusableProps, fieldProps, {
|
|
256
256
|
type: 'range',
|
|
257
257
|
tabIndex: !isDisabled ? 0 : undefined,
|
|
258
258
|
min: state.getThumbMinValue(index),
|
|
@@ -269,7 +269,7 @@ function $b6a2c1cf13588c87$export$8d15029008292ae(opts, state) {
|
|
|
269
269
|
state.setThumbValue(index, parseFloat(e.target.value));
|
|
270
270
|
}
|
|
271
271
|
}),
|
|
272
|
-
thumbProps: !isDisabled ? $
|
|
272
|
+
thumbProps: !isDisabled ? $hU63G$mergeProps(moveProps, {
|
|
273
273
|
onMouseDown: (e)=>{
|
|
274
274
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
275
275
|
onDown();
|
|
@@ -290,5 +290,5 @@ function $b6a2c1cf13588c87$export$8d15029008292ae(opts, state) {
|
|
|
290
290
|
|
|
291
291
|
|
|
292
292
|
|
|
293
|
-
export {$
|
|
293
|
+
export {$9006468ca971c07d$export$56b2c08e277f365 as useSlider, $fa28a9d9b8b61e27$export$8d15029008292ae as useSliderThumb};
|
|
294
294
|
//# sourceMappingURL=module.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/slider",
|
|
3
|
-
"version": "3.0.4-nightly.
|
|
3
|
+
"version": "3.0.4-nightly.3100+da2aa7467",
|
|
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": "3.0.0-nightly.
|
|
22
|
-
"@react-aria/i18n": "3.0.0-nightly.
|
|
23
|
-
"@react-aria/interactions": "3.0.0-nightly.
|
|
24
|
-
"@react-aria/label": "3.0.0-nightly.
|
|
25
|
-
"@react-aria/utils": "3.0.0-nightly.
|
|
26
|
-
"@react-stately/radio": "3.0.0-nightly.
|
|
27
|
-
"@react-stately/slider": "3.0.4-nightly.
|
|
28
|
-
"@react-types/radio": "3.0.0-nightly.
|
|
29
|
-
"@react-types/slider": "3.0.3-nightly.
|
|
21
|
+
"@react-aria/focus": "3.0.0-nightly.1409+da2aa7467",
|
|
22
|
+
"@react-aria/i18n": "3.0.0-nightly.1409+da2aa7467",
|
|
23
|
+
"@react-aria/interactions": "3.0.0-nightly.1409+da2aa7467",
|
|
24
|
+
"@react-aria/label": "3.0.0-nightly.1409+da2aa7467",
|
|
25
|
+
"@react-aria/utils": "3.0.0-nightly.1409+da2aa7467",
|
|
26
|
+
"@react-stately/radio": "3.0.0-nightly.1409+da2aa7467",
|
|
27
|
+
"@react-stately/slider": "3.0.4-nightly.3100+da2aa7467",
|
|
28
|
+
"@react-types/radio": "3.0.0-nightly.1409+da2aa7467",
|
|
29
|
+
"@react-types/slider": "3.0.3-nightly.3100+da2aa7467"
|
|
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": "da2aa74670fbd93335ff01401ca53826b3602777"
|
|
38
38
|
}
|