@react-aria/slider 3.2.4-nightly.3598 → 3.2.4-nightly.3600
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 +98 -83
- package/dist/main.js.map +1 -1
- package/dist/module.mjs +98 -83
- package/dist/module.mjs.map +1 -1
- package/package.json +13 -13
package/dist/main.js
CHANGED
|
@@ -11,11 +11,31 @@ function $parcel$export(e, n, v, s) {
|
|
|
11
11
|
|
|
12
12
|
$parcel$export(module.exports, "useSlider", () => $481f97d830e3ede6$export$56b2c08e277f365);
|
|
13
13
|
$parcel$export(module.exports, "useSliderThumb", () => $5eb806b626475377$export$8d15029008292ae);
|
|
14
|
-
|
|
14
|
+
/*
|
|
15
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
16
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
18
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
19
|
+
*
|
|
20
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
21
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
22
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
23
|
+
* governing permissions and limitations under the License.
|
|
24
|
+
*/ /*
|
|
25
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
26
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
27
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
28
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
29
|
+
*
|
|
30
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
31
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
32
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
33
|
+
* governing permissions and limitations under the License.
|
|
34
|
+
*/
|
|
15
35
|
const $28db8d634be2fa58$export$7a8d2b02c9371cbf = new WeakMap();
|
|
16
36
|
function $28db8d634be2fa58$export$68e648cbec363a18(state, index) {
|
|
17
37
|
let id = $28db8d634be2fa58$export$7a8d2b02c9371cbf.get(state);
|
|
18
|
-
if (!id) throw new Error(
|
|
38
|
+
if (!id) throw new Error("Unknown slider state");
|
|
19
39
|
return `${id}-${index}`;
|
|
20
40
|
}
|
|
21
41
|
|
|
@@ -25,23 +45,23 @@ function $28db8d634be2fa58$export$68e648cbec363a18(state, index) {
|
|
|
25
45
|
|
|
26
46
|
|
|
27
47
|
function $481f97d830e3ede6$export$56b2c08e277f365(props, state, trackRef) {
|
|
28
|
-
let { labelProps: labelProps , fieldProps: fieldProps } = $coMqq$reactarialabel.useLabel(props);
|
|
29
|
-
let isVertical = props.orientation ===
|
|
48
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = (0, $coMqq$reactarialabel.useLabel)(props);
|
|
49
|
+
let isVertical = props.orientation === "vertical";
|
|
30
50
|
var _id;
|
|
31
51
|
// Attach id of the label to the state so it can be accessed by useSliderThumb.
|
|
32
|
-
$28db8d634be2fa58$export$7a8d2b02c9371cbf.set(state, (_id = labelProps.id) !== null && _id !== void 0 ? _id : fieldProps.id);
|
|
33
|
-
let { direction: direction } = $coMqq$reactariai18n.useLocale();
|
|
34
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $coMqq$reactariautils.useGlobalListeners();
|
|
52
|
+
(0, $28db8d634be2fa58$export$7a8d2b02c9371cbf).set(state, (_id = labelProps.id) !== null && _id !== void 0 ? _id : fieldProps.id);
|
|
53
|
+
let { direction: direction } = (0, $coMqq$reactariai18n.useLocale)();
|
|
54
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $coMqq$reactariautils.useGlobalListeners)();
|
|
35
55
|
// When the user clicks or drags the track, we want the motion to set and drag the
|
|
36
56
|
// closest thumb. Hence we also need to install useMove() on the track element.
|
|
37
57
|
// Here, we keep track of which index is the "closest" to the drag start point.
|
|
38
58
|
// It is set onMouseDown/onTouchDown; see trackProps below.
|
|
39
|
-
const realTimeTrackDraggingIndex = $coMqq$react.useRef(null);
|
|
40
|
-
const stateRef = $coMqq$react.useRef(null);
|
|
59
|
+
const realTimeTrackDraggingIndex = (0, $coMqq$react.useRef)(null);
|
|
60
|
+
const stateRef = (0, $coMqq$react.useRef)(null);
|
|
41
61
|
stateRef.current = state;
|
|
42
|
-
const reverseX = direction ===
|
|
43
|
-
const currentPosition = $coMqq$react.useRef(null);
|
|
44
|
-
const { moveProps: moveProps } = $coMqq$reactariainteractions.useMove({
|
|
62
|
+
const reverseX = direction === "rtl";
|
|
63
|
+
const currentPosition = (0, $coMqq$react.useRef)(null);
|
|
64
|
+
const { moveProps: moveProps } = (0, $coMqq$reactariainteractions.useMove)({
|
|
45
65
|
onMoveStart () {
|
|
46
66
|
currentPosition.current = null;
|
|
47
67
|
},
|
|
@@ -53,7 +73,7 @@ function $481f97d830e3ede6$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
53
73
|
if (isVertical || reverseX) delta = -delta;
|
|
54
74
|
currentPosition.current += delta;
|
|
55
75
|
if (realTimeTrackDraggingIndex.current != null && trackRef.current) {
|
|
56
|
-
const percent = $coMqq$reactariautils.clamp(currentPosition.current / size, 0, 1);
|
|
76
|
+
const percent = (0, $coMqq$reactariautils.clamp)(currentPosition.current / size, 0, 1);
|
|
57
77
|
stateRef.current.setThumbPercent(realTimeTrackDraggingIndex.current, percent);
|
|
58
78
|
}
|
|
59
79
|
},
|
|
@@ -64,11 +84,10 @@ function $481f97d830e3ede6$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
64
84
|
}
|
|
65
85
|
}
|
|
66
86
|
});
|
|
67
|
-
let currentPointer = $coMqq$react.useRef(undefined);
|
|
87
|
+
let currentPointer = (0, $coMqq$react.useRef)(undefined);
|
|
68
88
|
let onDownTrack = (e, id, clientX, clientY)=>{
|
|
69
89
|
// We only trigger track-dragging if the user clicks on the track itself and nothing is currently being dragged.
|
|
70
|
-
if (trackRef.current && !props.isDisabled && state.values.every((_, i)=>!state.isThumbDragging(i)
|
|
71
|
-
)) {
|
|
90
|
+
if (trackRef.current && !props.isDisabled && state.values.every((_, i)=>!state.isThumbDragging(i))) {
|
|
72
91
|
let { height: height , width: width , top: top , left: left } = trackRef.current.getBoundingClientRect();
|
|
73
92
|
let size = isVertical ? height : width;
|
|
74
93
|
// Find the closest thumb
|
|
@@ -76,12 +95,11 @@ function $481f97d830e3ede6$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
76
95
|
const clickPosition = isVertical ? clientY : clientX;
|
|
77
96
|
const offset = clickPosition - trackPosition;
|
|
78
97
|
let percent = offset / size;
|
|
79
|
-
if (direction ===
|
|
98
|
+
if (direction === "rtl" || isVertical) percent = 1 - percent;
|
|
80
99
|
let value = state.getPercentValue(percent);
|
|
81
100
|
// to find the closet thumb we split the array based on the first thumb position to the "right/end" of the click.
|
|
82
101
|
let closestThumb;
|
|
83
|
-
let split = state.values.findIndex((v)=>value - v < 0
|
|
84
|
-
);
|
|
102
|
+
let split = state.values.findIndex((v)=>value - v < 0);
|
|
85
103
|
if (split === 0) closestThumb = split;
|
|
86
104
|
else if (split === -1) closestThumb = state.values.length - 1;
|
|
87
105
|
else {
|
|
@@ -100,9 +118,9 @@ function $481f97d830e3ede6$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
100
118
|
currentPointer.current = id;
|
|
101
119
|
state.setThumbDragging(realTimeTrackDraggingIndex.current, true);
|
|
102
120
|
state.setThumbValue(closestThumb, value);
|
|
103
|
-
addGlobalListener(window,
|
|
104
|
-
addGlobalListener(window,
|
|
105
|
-
addGlobalListener(window,
|
|
121
|
+
addGlobalListener(window, "mouseup", onUpTrack, false);
|
|
122
|
+
addGlobalListener(window, "touchend", onUpTrack, false);
|
|
123
|
+
addGlobalListener(window, "pointerup", onUpTrack, false);
|
|
106
124
|
} else realTimeTrackDraggingIndex.current = null;
|
|
107
125
|
}
|
|
108
126
|
};
|
|
@@ -115,12 +133,12 @@ function $481f97d830e3ede6$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
115
133
|
state.setThumbDragging(realTimeTrackDraggingIndex.current, false);
|
|
116
134
|
realTimeTrackDraggingIndex.current = null;
|
|
117
135
|
}
|
|
118
|
-
removeGlobalListener(window,
|
|
119
|
-
removeGlobalListener(window,
|
|
120
|
-
removeGlobalListener(window,
|
|
136
|
+
removeGlobalListener(window, "mouseup", onUpTrack, false);
|
|
137
|
+
removeGlobalListener(window, "touchend", onUpTrack, false);
|
|
138
|
+
removeGlobalListener(window, "pointerup", onUpTrack, false);
|
|
121
139
|
}
|
|
122
140
|
};
|
|
123
|
-
if (
|
|
141
|
+
if ("htmlFor" in labelProps && labelProps.htmlFor) {
|
|
124
142
|
// Ideally the `for` attribute should point to the first thumb, but VoiceOver on iOS
|
|
125
143
|
// causes this to override the `aria-labelledby` on the thumb. This causes the first
|
|
126
144
|
// thumb to only be announced as the slider label rather than its individual name as well.
|
|
@@ -130,8 +148,8 @@ function $481f97d830e3ede6$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
130
148
|
var // Safari does not focus <input type="range"> elements when clicking on an associated <label>,
|
|
131
149
|
// so do it manually. In addition, make sure we show the focus ring.
|
|
132
150
|
ref;
|
|
133
|
-
(ref = document.getElementById($28db8d634be2fa58$export$68e648cbec363a18(state, 0))) === null || ref === void 0 ? void 0 : ref.focus();
|
|
134
|
-
$coMqq$reactariainteractions.setInteractionModality(
|
|
151
|
+
(ref = document.getElementById((0, $28db8d634be2fa58$export$68e648cbec363a18)(state, 0))) === null || ref === void 0 ? void 0 : ref.focus();
|
|
152
|
+
(0, $coMqq$reactariainteractions.setInteractionModality)("keyboard");
|
|
135
153
|
};
|
|
136
154
|
}
|
|
137
155
|
return {
|
|
@@ -140,30 +158,29 @@ function $481f97d830e3ede6$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
140
158
|
// all the thumb inputs in the Slider. The label of the Slider will
|
|
141
159
|
// be used to label the group.
|
|
142
160
|
groupProps: {
|
|
143
|
-
role:
|
|
161
|
+
role: "group",
|
|
144
162
|
...fieldProps
|
|
145
163
|
},
|
|
146
|
-
trackProps: $coMqq$reactariautils.mergeProps({
|
|
164
|
+
trackProps: (0, $coMqq$reactariautils.mergeProps)({
|
|
147
165
|
onMouseDown (e) {
|
|
148
166
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
149
167
|
onDownTrack(e, undefined, e.clientX, e.clientY);
|
|
150
168
|
},
|
|
151
169
|
onPointerDown (e) {
|
|
152
|
-
if (e.pointerType ===
|
|
170
|
+
if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
153
171
|
onDownTrack(e, e.pointerId, e.clientX, e.clientY);
|
|
154
172
|
},
|
|
155
173
|
onTouchStart (e) {
|
|
156
174
|
onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
157
175
|
},
|
|
158
176
|
style: {
|
|
159
|
-
position:
|
|
160
|
-
touchAction:
|
|
177
|
+
position: "relative",
|
|
178
|
+
touchAction: "none"
|
|
161
179
|
}
|
|
162
180
|
}, moveProps),
|
|
163
181
|
outputProps: {
|
|
164
|
-
htmlFor: state.values.map((_, index)
|
|
165
|
-
|
|
166
|
-
'aria-live': 'off'
|
|
182
|
+
htmlFor: state.values.map((_, index)=>(0, $28db8d634be2fa58$export$68e648cbec363a18)(state, index)).join(" "),
|
|
183
|
+
"aria-live": "off"
|
|
167
184
|
}
|
|
168
185
|
};
|
|
169
186
|
}
|
|
@@ -179,34 +196,34 @@ function $481f97d830e3ede6$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
179
196
|
function $5eb806b626475377$export$8d15029008292ae(opts, state) {
|
|
180
197
|
let { index: index , isRequired: isRequired , validationState: validationState , trackRef: trackRef , inputRef: inputRef , orientation: orientation = state.orientation } = opts;
|
|
181
198
|
let isDisabled = opts.isDisabled || state.isDisabled;
|
|
182
|
-
let isVertical = orientation ===
|
|
183
|
-
let { direction: direction } = $coMqq$reactariai18n.useLocale();
|
|
184
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $coMqq$reactariautils.useGlobalListeners();
|
|
185
|
-
let labelId = $28db8d634be2fa58$export$7a8d2b02c9371cbf.get(state);
|
|
186
|
-
var
|
|
187
|
-
const { labelProps: labelProps , fieldProps: fieldProps } = $coMqq$reactarialabel.useLabel({
|
|
199
|
+
let isVertical = orientation === "vertical";
|
|
200
|
+
let { direction: direction } = (0, $coMqq$reactariai18n.useLocale)();
|
|
201
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $coMqq$reactariautils.useGlobalListeners)();
|
|
202
|
+
let labelId = (0, $28db8d634be2fa58$export$7a8d2b02c9371cbf).get(state);
|
|
203
|
+
var ref;
|
|
204
|
+
const { labelProps: labelProps , fieldProps: fieldProps } = (0, $coMqq$reactarialabel.useLabel)({
|
|
188
205
|
...opts,
|
|
189
|
-
id: $28db8d634be2fa58$export$68e648cbec363a18(state, index),
|
|
190
|
-
|
|
206
|
+
id: (0, $28db8d634be2fa58$export$68e648cbec363a18)(state, index),
|
|
207
|
+
"aria-labelledby": `${labelId} ${(ref = opts["aria-labelledby"]) !== null && ref !== void 0 ? ref : ""}`.trim()
|
|
191
208
|
});
|
|
192
209
|
const value = state.values[index];
|
|
193
|
-
const focusInput = $coMqq$react.useCallback(()=>{
|
|
194
|
-
if (inputRef.current) $coMqq$reactariautils.focusWithoutScrolling(inputRef.current);
|
|
210
|
+
const focusInput = (0, $coMqq$react.useCallback)(()=>{
|
|
211
|
+
if (inputRef.current) (0, $coMqq$reactariautils.focusWithoutScrolling)(inputRef.current);
|
|
195
212
|
}, [
|
|
196
213
|
inputRef
|
|
197
214
|
]);
|
|
198
215
|
const isFocused = state.focusedThumb === index;
|
|
199
|
-
$coMqq$react.useEffect(()=>{
|
|
216
|
+
(0, $coMqq$react.useEffect)(()=>{
|
|
200
217
|
if (isFocused) focusInput();
|
|
201
218
|
}, [
|
|
202
219
|
isFocused,
|
|
203
220
|
focusInput
|
|
204
221
|
]);
|
|
205
|
-
const stateRef = $coMqq$react.useRef(null);
|
|
222
|
+
const stateRef = (0, $coMqq$react.useRef)(null);
|
|
206
223
|
stateRef.current = state;
|
|
207
|
-
let reverseX = direction ===
|
|
208
|
-
let currentPosition = $coMqq$react.useRef(null);
|
|
209
|
-
let { keyboardProps: keyboardProps } = $coMqq$reactariainteractions.useKeyboard({
|
|
224
|
+
let reverseX = direction === "rtl";
|
|
225
|
+
let currentPosition = (0, $coMqq$react.useRef)(null);
|
|
226
|
+
let { keyboardProps: keyboardProps } = (0, $coMqq$reactariainteractions.useKeyboard)({
|
|
210
227
|
onKeyDown (e) {
|
|
211
228
|
let { getThumbMaxValue: getThumbMaxValue , getThumbMinValue: getThumbMinValue , decrementThumb: decrementThumb , incrementThumb: incrementThumb , setThumbValue: setThumbValue , setThumbDragging: setThumbDragging , pageSize: pageSize } = stateRef.current;
|
|
212
229
|
// these are the cases that useMove or useSlider don't handle
|
|
@@ -219,23 +236,23 @@ function $5eb806b626475377$export$8d15029008292ae(opts, state) {
|
|
|
219
236
|
// remember to set this so that onChangeEnd is fired
|
|
220
237
|
setThumbDragging(index, true);
|
|
221
238
|
switch(e.key){
|
|
222
|
-
case
|
|
239
|
+
case "PageUp":
|
|
223
240
|
incrementThumb(index, pageSize);
|
|
224
241
|
break;
|
|
225
|
-
case
|
|
242
|
+
case "PageDown":
|
|
226
243
|
decrementThumb(index, pageSize);
|
|
227
244
|
break;
|
|
228
|
-
case
|
|
245
|
+
case "Home":
|
|
229
246
|
setThumbValue(index, getThumbMinValue(index));
|
|
230
247
|
break;
|
|
231
|
-
case
|
|
248
|
+
case "End":
|
|
232
249
|
setThumbValue(index, getThumbMaxValue(index));
|
|
233
250
|
break;
|
|
234
251
|
}
|
|
235
252
|
setThumbDragging(index, false);
|
|
236
253
|
}
|
|
237
254
|
});
|
|
238
|
-
let { moveProps: moveProps } = $coMqq$reactariainteractions.useMove({
|
|
255
|
+
let { moveProps: moveProps } = (0, $coMqq$reactariainteractions.useMove)({
|
|
239
256
|
onMoveStart () {
|
|
240
257
|
currentPosition.current = null;
|
|
241
258
|
stateRef.current.setThumbDragging(index, true);
|
|
@@ -245,14 +262,14 @@ function $5eb806b626475377$export$8d15029008292ae(opts, state) {
|
|
|
245
262
|
let { width: width , height: height } = trackRef.current.getBoundingClientRect();
|
|
246
263
|
let size = isVertical ? height : width;
|
|
247
264
|
if (currentPosition.current == null) currentPosition.current = getThumbPercent(index) * size;
|
|
248
|
-
if (pointerType ===
|
|
265
|
+
if (pointerType === "keyboard") {
|
|
249
266
|
if (deltaX > 0 && reverseX || deltaX < 0 && !reverseX || deltaY > 0) decrementThumb(index, shiftKey ? pageSize : step);
|
|
250
267
|
else incrementThumb(index, shiftKey ? pageSize : step);
|
|
251
268
|
} else {
|
|
252
269
|
let delta = isVertical ? deltaY : deltaX;
|
|
253
270
|
if (isVertical || reverseX) delta = -delta;
|
|
254
271
|
currentPosition.current += delta;
|
|
255
|
-
setThumbPercent(index, $coMqq$reactariautils.clamp(currentPosition.current / size, 0, 1));
|
|
272
|
+
setThumbPercent(index, (0, $coMqq$reactariautils.clamp)(currentPosition.current / size, 0, 1));
|
|
256
273
|
}
|
|
257
274
|
},
|
|
258
275
|
onMoveEnd () {
|
|
@@ -261,19 +278,18 @@ function $5eb806b626475377$export$8d15029008292ae(opts, state) {
|
|
|
261
278
|
});
|
|
262
279
|
// Immediately register editability with the state
|
|
263
280
|
state.setThumbEditable(index, !isDisabled);
|
|
264
|
-
const { focusableProps: focusableProps } = $coMqq$reactariafocus.useFocusable($coMqq$reactariautils.mergeProps(opts, {
|
|
265
|
-
onFocus: ()=>state.setFocusedThumb(index)
|
|
266
|
-
,
|
|
281
|
+
const { focusableProps: focusableProps } = (0, $coMqq$reactariafocus.useFocusable)((0, $coMqq$reactariautils.mergeProps)(opts, {
|
|
282
|
+
onFocus: ()=>state.setFocusedThumb(index),
|
|
267
283
|
onBlur: ()=>state.setFocusedThumb(undefined)
|
|
268
284
|
}), inputRef);
|
|
269
|
-
let currentPointer = $coMqq$react.useRef(undefined);
|
|
285
|
+
let currentPointer = (0, $coMqq$react.useRef)(undefined);
|
|
270
286
|
let onDown = (id)=>{
|
|
271
287
|
focusInput();
|
|
272
288
|
currentPointer.current = id;
|
|
273
289
|
state.setThumbDragging(index, true);
|
|
274
|
-
addGlobalListener(window,
|
|
275
|
-
addGlobalListener(window,
|
|
276
|
-
addGlobalListener(window,
|
|
290
|
+
addGlobalListener(window, "mouseup", onUp, false);
|
|
291
|
+
addGlobalListener(window, "touchend", onUp, false);
|
|
292
|
+
addGlobalListener(window, "pointerup", onUp, false);
|
|
277
293
|
};
|
|
278
294
|
let onUp = (e)=>{
|
|
279
295
|
var ref;
|
|
@@ -282,14 +298,14 @@ function $5eb806b626475377$export$8d15029008292ae(opts, state) {
|
|
|
282
298
|
if (id === currentPointer.current) {
|
|
283
299
|
focusInput();
|
|
284
300
|
state.setThumbDragging(index, false);
|
|
285
|
-
removeGlobalListener(window,
|
|
286
|
-
removeGlobalListener(window,
|
|
287
|
-
removeGlobalListener(window,
|
|
301
|
+
removeGlobalListener(window, "mouseup", onUp, false);
|
|
302
|
+
removeGlobalListener(window, "touchend", onUp, false);
|
|
303
|
+
removeGlobalListener(window, "pointerup", onUp, false);
|
|
288
304
|
}
|
|
289
305
|
};
|
|
290
306
|
let thumbPosition = state.getThumbPercent(index);
|
|
291
|
-
if (isVertical || direction ===
|
|
292
|
-
let interactions = !isDisabled ? $coMqq$reactariautils.mergeProps(keyboardProps, moveProps, {
|
|
307
|
+
if (isVertical || direction === "rtl") thumbPosition = 1 - thumbPosition;
|
|
308
|
+
let interactions = !isDisabled ? (0, $coMqq$reactariautils.mergeProps)(keyboardProps, moveProps, {
|
|
293
309
|
onMouseDown: (e)=>{
|
|
294
310
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
295
311
|
onDown();
|
|
@@ -301,26 +317,25 @@ function $5eb806b626475377$export$8d15029008292ae(opts, state) {
|
|
|
301
317
|
onTouchStart: (e)=>{
|
|
302
318
|
onDown(e.changedTouches[0].identifier);
|
|
303
319
|
}
|
|
304
|
-
}) : {
|
|
305
|
-
};
|
|
320
|
+
}) : {};
|
|
306
321
|
// We install mouse handlers for the drag motion on the thumb div, but
|
|
307
322
|
// not the key handler for moving the thumb with the slider. Instead,
|
|
308
323
|
// we focus the range input, and let the browser handle the keyboard
|
|
309
324
|
// interactions; we then listen to input's onChange to update state.
|
|
310
325
|
return {
|
|
311
|
-
inputProps: $coMqq$reactariautils.mergeProps(focusableProps, fieldProps, {
|
|
312
|
-
type:
|
|
326
|
+
inputProps: (0, $coMqq$reactariautils.mergeProps)(focusableProps, fieldProps, {
|
|
327
|
+
type: "range",
|
|
313
328
|
tabIndex: !isDisabled ? 0 : undefined,
|
|
314
329
|
min: state.getThumbMinValue(index),
|
|
315
330
|
max: state.getThumbMaxValue(index),
|
|
316
331
|
step: state.step,
|
|
317
332
|
value: value,
|
|
318
333
|
disabled: isDisabled,
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
334
|
+
"aria-orientation": orientation,
|
|
335
|
+
"aria-valuetext": state.getThumbValueLabel(index),
|
|
336
|
+
"aria-required": isRequired || undefined,
|
|
337
|
+
"aria-invalid": validationState === "invalid" || undefined,
|
|
338
|
+
"aria-errormessage": opts["aria-errormessage"],
|
|
324
339
|
onChange: (e)=>{
|
|
325
340
|
stateRef.current.setThumbValue(index, parseFloat(e.target.value));
|
|
326
341
|
}
|
|
@@ -328,10 +343,10 @@ function $5eb806b626475377$export$8d15029008292ae(opts, state) {
|
|
|
328
343
|
thumbProps: {
|
|
329
344
|
...interactions,
|
|
330
345
|
style: {
|
|
331
|
-
position:
|
|
332
|
-
[isVertical ?
|
|
333
|
-
transform:
|
|
334
|
-
touchAction:
|
|
346
|
+
position: "absolute",
|
|
347
|
+
[isVertical ? "top" : "left"]: `${thumbPosition * 100}%`,
|
|
348
|
+
transform: "translate(-50%, -50%)",
|
|
349
|
+
touchAction: "none"
|
|
335
350
|
}
|
|
336
351
|
},
|
|
337
352
|
labelProps: labelProps,
|
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;;;;;;;SDmCe,wCAAS,CACvB,KAAyB,EACzB,KAAkB,EAClB,QAA4B,EAChB,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,8EAAgF;IAChF,EAA+E,AAA/E,6EAA+E;IAC/E,EAA2D,AAA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,EAAsE,AAAtE,oEAAsE;IACtE,EAAsE,AAAtE,oEAAsE;IACtE,EAAoE,AAApE,kEAAoE;IACpE,EAAoE,AAApE,kEAAoE;IACpE,MAAM,CAAC,CAAC;QACN,UAAU,EAAE,gCAAU,CAAC,cAAc,EAAE,UAAU,EAAE,CAAC;YAClD,IAAI,EAAE,CAAO;YACb,QAAQ,GAAG,UAAU,GAAG,CAAC,GAAG,SAAS;YACrC,GAAG,EAAE,KAAK,CAAC,gBAAgB,CAAC,KAAK;YACjC,GAAG,EAAE,KAAK,CAAC,gBAAgB,CAAC,KAAK;YACjC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK;YACZ,QAAQ,EAAE,UAAU;YACpB,CAAkB,mBAAE,WAAW;YAC/B,CAAgB,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,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK;YACjE,CAAC;QACH,CAAC;QACD,UAAU,EAAE,CAAC;eACR,YAAY;YACf,KAAK,EAAE,CAAC;gBACN,QAAQ,EAAE,CAAU;iBACnB,UAAU,GAAG,CAAK,OAAG,CAAM,WAAM,aAAa,GAAG,GAAG,CAAC,CAAC;gBACvD,SAAS,EAAE,CAAuB;gBAClC,WAAW,EAAE,CAAM;YACrB,CAAC;QACH,CAAC;oBACD,UAAU;QACV,UAAU,EAAE,KAAK,CAAC,eAAe,CAAC,KAAK;oBACvC,UAAU;mBACV,SAAS;IACX,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 */\nexport {useSlider} from './useSlider';\nexport {useSliderThumb} from './useSliderThumb';\nexport type {AriaSliderProps} from '@react-types/slider';\nexport type {SliderAria} from './useSlider';\nexport type {AriaSliderThumbOptions, SliderThumbAria} from './useSliderThumb';\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 {DOMAttributes} from '@react-types/shared';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {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\nexport interface 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: DOMAttributes,\n\n /** Props for the track element. */\n trackProps: DOMAttributes,\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<T extends number | number[]>(\n props: AriaSliderProps<T>,\n state: SliderState,\n trackRef: RefObject<Element>\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 {height, width} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\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 {height, width, top, left} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\n // Find the closest thumb\n const trackPosition = 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 ('htmlFor' in labelProps && 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) {\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) {\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) { onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY); },\n style: {\n position: 'relative',\n touchAction: 'none'\n }\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 {DOMAttributes} from '@react-types/shared';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {ChangeEvent, 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\nexport interface SliderThumbAria {\n /** Props for the root thumb element; handles the dragging motion. */\n thumbProps: DOMAttributes,\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 /** Whether this thumb is currently being dragged. */\n isDragging: boolean,\n /** Whether the thumb is currently focused. */\n isFocused: boolean,\n /** Whether the thumb is disabled. */\n isDisabled: boolean\n}\n\nexport interface AriaSliderThumbOptions extends AriaSliderThumbProps {\n /** A ref to the track element. */\n trackRef: RefObject<Element>,\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: AriaSliderThumbOptions,\n state: SliderState\n): SliderThumbAria {\n let {\n index,\n isRequired,\n validationState,\n trackRef,\n inputRef,\n orientation = state.orientation\n } = opts;\n\n let isDisabled = opts.isDisabled || state.isDisabled;\n let isVertical = 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 {width, height} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\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 let thumbPosition = state.getThumbPercent(index);\n if (isVertical || direction === 'rtl') {\n thumbPosition = 1 - thumbPosition;\n }\n\n let interactions = !isDisabled ? mergeProps(\n keyboardProps,\n moveProps,\n {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown();\n },\n onPointerDown: (e: React.PointerEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent) => {onDown(e.changedTouches[0].identifier);}\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': 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: {\n ...interactions,\n style: {\n position: 'absolute',\n [isVertical ? 'top' : 'left']: `${thumbPosition * 100}%`,\n transform: 'translate(-50%, -50%)',\n touchAction: 'none'\n }\n },\n labelProps,\n isDragging: state.isThumbDragging(index),\n isDisabled,\n isFocused\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;ACVO,MAAM,4CAAY,IAAI;AAEtB,SAAS,0CAAiB,KAAkB,EAAE,KAAa,EAAE;IAClE,IAAI,KAAK,0CAAU,GAAG,CAAC;IACvB,IAAI,CAAC,IACH,MAAM,IAAI,MAAM,wBAAwB;IAG1C,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC;AACzB;;;;;;;ADmCO,SAAS,yCACd,KAAyB,EACzB,KAAkB,EAClB,QAA4B,EAChB;IACZ,IAAI,cAAC,WAAU,cAAE,WAAU,EAAC,GAAG,CAAA,GAAA,8BAAQ,AAAD,EAAE;IAExC,IAAI,aAAa,MAAM,WAAW,KAAK;QAGlB;IADrB,+EAA+E;IAC/E,CAAA,GAAA,yCAAQ,EAAE,GAAG,CAAC,OAAO,CAAA,MAAA,WAAW,EAAE,cAAb,i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OAAO,EACtD;YAEF;QACF;QACA,eAAe,CAAC,IAA0B;YACxC,IAAI,EAAE,MAAM,KAAK,KAAK,EAAE,MAAM,IAAI,EAAE,OAAO,IAAI,EAAE,OAAO,EACtD;YAEF,OAAO,EAAE,SAAS;QACpB;QACA,cAAc,CAAC,IAAwB;YAAC,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC,UAAU;QAAE;IACjF,KACE,CAAC,CAAC;IAEN,sEAAsE;IACtE,sEAAsE;IACtE,oEAAoE;IACpE,oEAAoE;IACpE,OAAO;QACL,YAAY,CAAA,GAAA,gCAAU,AAAD,EAAE,gBAAgB,YAAY;YACjD,MAAM;YACN,UAAU,CAAC,aAAa,IAAI,SAAS;YACrC,KAAK,MAAM,gBAAgB,CAAC;YAC5B,KAAK,MAAM,gBAAgB,CAAC;YAC5B,MAAM,MAAM,IAAI;YAChB,OAAO;YACP,UAAU;YACV,oBAAoB;YACpB,kBAAkB,MAAM,kBAAkB,CAAC;YAC3C,iBAAiB,cAAc;YAC/B,gBAAgB,oBAAoB,aAAa;YACjD,qBAAqB,IAAI,CAAC,oBAAoB;YAC9C,UAAU,CAAC,IAAqC;gBAC9C,SAAS,OAAO,CAAC,aAAa,CAAC,OAAO,WAAW,EAAE,MAAM,CAAC,KAAK;YACjE;QACF;QACA,YAAY;YACV,GAAG,YAAY;YACf,OAAO;gBACL,UAAU;gBACV,CAAC,aAAa,QAAQ,MAAM,CAAC,EAAE,CAAC,EAAE,gBAAgB,IAAI,CAAC,CAAC;gBACxD,WAAW;gBACX,aAAa;YACf;QACF;oBACA;QACA,YAAY,MAAM,eAAe,CAAC;oBAClC;mBACA;IACF;AACF;","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 */\nexport {useSlider} from './useSlider';\nexport {useSliderThumb} from './useSliderThumb';\nexport type {AriaSliderProps} from '@react-types/slider';\nexport type {SliderAria} from './useSlider';\nexport type {AriaSliderThumbOptions, SliderThumbAria} from './useSliderThumb';\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 {DOMAttributes} from '@react-types/shared';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {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\nexport interface 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: DOMAttributes,\n\n /** Props for the track element. */\n trackProps: DOMAttributes,\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<T extends number | number[]>(\n props: AriaSliderProps<T>,\n state: SliderState,\n trackRef: RefObject<Element>\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 {height, width} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\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 {height, width, top, left} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\n // Find the closest thumb\n const trackPosition = 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 ('htmlFor' in labelProps && 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) {\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) {\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) { onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY); },\n style: {\n position: 'relative',\n touchAction: 'none'\n }\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 {DOMAttributes} from '@react-types/shared';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {ChangeEvent, 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\nexport interface SliderThumbAria {\n /** Props for the root thumb element; handles the dragging motion. */\n thumbProps: DOMAttributes,\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 /** Whether this thumb is currently being dragged. */\n isDragging: boolean,\n /** Whether the thumb is currently focused. */\n isFocused: boolean,\n /** Whether the thumb is disabled. */\n isDisabled: boolean\n}\n\nexport interface AriaSliderThumbOptions extends AriaSliderThumbProps {\n /** A ref to the track element. */\n trackRef: RefObject<Element>,\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: AriaSliderThumbOptions,\n state: SliderState\n): SliderThumbAria {\n let {\n index,\n isRequired,\n validationState,\n trackRef,\n inputRef,\n orientation = state.orientation\n } = opts;\n\n let isDisabled = opts.isDisabled || state.isDisabled;\n let isVertical = 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 {width, height} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\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 let thumbPosition = state.getThumbPercent(index);\n if (isVertical || direction === 'rtl') {\n thumbPosition = 1 - thumbPosition;\n }\n\n let interactions = !isDisabled ? mergeProps(\n keyboardProps,\n moveProps,\n {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown();\n },\n onPointerDown: (e: React.PointerEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent) => {onDown(e.changedTouches[0].identifier);}\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': 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: {\n ...interactions,\n style: {\n position: 'absolute',\n [isVertical ? 'top' : 'left']: `${thumbPosition * 100}%`,\n transform: 'translate(-50%, -50%)',\n touchAction: 'none'\n }\n },\n labelProps,\n isDragging: state.isThumbDragging(index),\n isDisabled,\n isFocused\n };\n}\n"],"names":[],"version":3,"file":"main.js.map"}
|
package/dist/module.mjs
CHANGED
|
@@ -5,11 +5,31 @@ import {useLabel as $fA3fN$useLabel} from "@react-aria/label";
|
|
|
5
5
|
import {useLocale as $fA3fN$useLocale} from "@react-aria/i18n";
|
|
6
6
|
import {useFocusable as $fA3fN$useFocusable} from "@react-aria/focus";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
/*
|
|
9
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
10
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
11
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
12
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
15
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
16
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
17
|
+
* governing permissions and limitations under the License.
|
|
18
|
+
*/ /*
|
|
19
|
+
* Copyright 2020 Adobe. All rights reserved.
|
|
20
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
22
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
23
|
+
*
|
|
24
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
25
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
26
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
27
|
+
* governing permissions and limitations under the License.
|
|
28
|
+
*/
|
|
9
29
|
const $aa519ee6cf463259$export$7a8d2b02c9371cbf = new WeakMap();
|
|
10
30
|
function $aa519ee6cf463259$export$68e648cbec363a18(state, index) {
|
|
11
31
|
let id = $aa519ee6cf463259$export$7a8d2b02c9371cbf.get(state);
|
|
12
|
-
if (!id) throw new Error(
|
|
32
|
+
if (!id) throw new Error("Unknown slider state");
|
|
13
33
|
return `${id}-${index}`;
|
|
14
34
|
}
|
|
15
35
|
|
|
@@ -19,23 +39,23 @@ function $aa519ee6cf463259$export$68e648cbec363a18(state, index) {
|
|
|
19
39
|
|
|
20
40
|
|
|
21
41
|
function $bcca50147b47f54d$export$56b2c08e277f365(props, state, trackRef) {
|
|
22
|
-
let { labelProps: labelProps , fieldProps: fieldProps } = $fA3fN$useLabel(props);
|
|
23
|
-
let isVertical = props.orientation ===
|
|
42
|
+
let { labelProps: labelProps , fieldProps: fieldProps } = (0, $fA3fN$useLabel)(props);
|
|
43
|
+
let isVertical = props.orientation === "vertical";
|
|
24
44
|
var _id;
|
|
25
45
|
// Attach id of the label to the state so it can be accessed by useSliderThumb.
|
|
26
|
-
$aa519ee6cf463259$export$7a8d2b02c9371cbf.set(state, (_id = labelProps.id) !== null && _id !== void 0 ? _id : fieldProps.id);
|
|
27
|
-
let { direction: direction } = $fA3fN$useLocale();
|
|
28
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $fA3fN$useGlobalListeners();
|
|
46
|
+
(0, $aa519ee6cf463259$export$7a8d2b02c9371cbf).set(state, (_id = labelProps.id) !== null && _id !== void 0 ? _id : fieldProps.id);
|
|
47
|
+
let { direction: direction } = (0, $fA3fN$useLocale)();
|
|
48
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $fA3fN$useGlobalListeners)();
|
|
29
49
|
// When the user clicks or drags the track, we want the motion to set and drag the
|
|
30
50
|
// closest thumb. Hence we also need to install useMove() on the track element.
|
|
31
51
|
// Here, we keep track of which index is the "closest" to the drag start point.
|
|
32
52
|
// It is set onMouseDown/onTouchDown; see trackProps below.
|
|
33
|
-
const realTimeTrackDraggingIndex = $fA3fN$useRef(null);
|
|
34
|
-
const stateRef = $fA3fN$useRef(null);
|
|
53
|
+
const realTimeTrackDraggingIndex = (0, $fA3fN$useRef)(null);
|
|
54
|
+
const stateRef = (0, $fA3fN$useRef)(null);
|
|
35
55
|
stateRef.current = state;
|
|
36
|
-
const reverseX = direction ===
|
|
37
|
-
const currentPosition = $fA3fN$useRef(null);
|
|
38
|
-
const { moveProps: moveProps } = $fA3fN$useMove({
|
|
56
|
+
const reverseX = direction === "rtl";
|
|
57
|
+
const currentPosition = (0, $fA3fN$useRef)(null);
|
|
58
|
+
const { moveProps: moveProps } = (0, $fA3fN$useMove)({
|
|
39
59
|
onMoveStart () {
|
|
40
60
|
currentPosition.current = null;
|
|
41
61
|
},
|
|
@@ -47,7 +67,7 @@ function $bcca50147b47f54d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
47
67
|
if (isVertical || reverseX) delta = -delta;
|
|
48
68
|
currentPosition.current += delta;
|
|
49
69
|
if (realTimeTrackDraggingIndex.current != null && trackRef.current) {
|
|
50
|
-
const percent = $fA3fN$clamp(currentPosition.current / size, 0, 1);
|
|
70
|
+
const percent = (0, $fA3fN$clamp)(currentPosition.current / size, 0, 1);
|
|
51
71
|
stateRef.current.setThumbPercent(realTimeTrackDraggingIndex.current, percent);
|
|
52
72
|
}
|
|
53
73
|
},
|
|
@@ -58,11 +78,10 @@ function $bcca50147b47f54d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
58
78
|
}
|
|
59
79
|
}
|
|
60
80
|
});
|
|
61
|
-
let currentPointer = $fA3fN$useRef(undefined);
|
|
81
|
+
let currentPointer = (0, $fA3fN$useRef)(undefined);
|
|
62
82
|
let onDownTrack = (e, id, clientX, clientY)=>{
|
|
63
83
|
// We only trigger track-dragging if the user clicks on the track itself and nothing is currently being dragged.
|
|
64
|
-
if (trackRef.current && !props.isDisabled && state.values.every((_, i)=>!state.isThumbDragging(i)
|
|
65
|
-
)) {
|
|
84
|
+
if (trackRef.current && !props.isDisabled && state.values.every((_, i)=>!state.isThumbDragging(i))) {
|
|
66
85
|
let { height: height , width: width , top: top , left: left } = trackRef.current.getBoundingClientRect();
|
|
67
86
|
let size = isVertical ? height : width;
|
|
68
87
|
// Find the closest thumb
|
|
@@ -70,12 +89,11 @@ function $bcca50147b47f54d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
70
89
|
const clickPosition = isVertical ? clientY : clientX;
|
|
71
90
|
const offset = clickPosition - trackPosition;
|
|
72
91
|
let percent = offset / size;
|
|
73
|
-
if (direction ===
|
|
92
|
+
if (direction === "rtl" || isVertical) percent = 1 - percent;
|
|
74
93
|
let value = state.getPercentValue(percent);
|
|
75
94
|
// to find the closet thumb we split the array based on the first thumb position to the "right/end" of the click.
|
|
76
95
|
let closestThumb;
|
|
77
|
-
let split = state.values.findIndex((v)=>value - v < 0
|
|
78
|
-
);
|
|
96
|
+
let split = state.values.findIndex((v)=>value - v < 0);
|
|
79
97
|
if (split === 0) closestThumb = split;
|
|
80
98
|
else if (split === -1) closestThumb = state.values.length - 1;
|
|
81
99
|
else {
|
|
@@ -94,9 +112,9 @@ function $bcca50147b47f54d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
94
112
|
currentPointer.current = id;
|
|
95
113
|
state.setThumbDragging(realTimeTrackDraggingIndex.current, true);
|
|
96
114
|
state.setThumbValue(closestThumb, value);
|
|
97
|
-
addGlobalListener(window,
|
|
98
|
-
addGlobalListener(window,
|
|
99
|
-
addGlobalListener(window,
|
|
115
|
+
addGlobalListener(window, "mouseup", onUpTrack, false);
|
|
116
|
+
addGlobalListener(window, "touchend", onUpTrack, false);
|
|
117
|
+
addGlobalListener(window, "pointerup", onUpTrack, false);
|
|
100
118
|
} else realTimeTrackDraggingIndex.current = null;
|
|
101
119
|
}
|
|
102
120
|
};
|
|
@@ -109,12 +127,12 @@ function $bcca50147b47f54d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
109
127
|
state.setThumbDragging(realTimeTrackDraggingIndex.current, false);
|
|
110
128
|
realTimeTrackDraggingIndex.current = null;
|
|
111
129
|
}
|
|
112
|
-
removeGlobalListener(window,
|
|
113
|
-
removeGlobalListener(window,
|
|
114
|
-
removeGlobalListener(window,
|
|
130
|
+
removeGlobalListener(window, "mouseup", onUpTrack, false);
|
|
131
|
+
removeGlobalListener(window, "touchend", onUpTrack, false);
|
|
132
|
+
removeGlobalListener(window, "pointerup", onUpTrack, false);
|
|
115
133
|
}
|
|
116
134
|
};
|
|
117
|
-
if (
|
|
135
|
+
if ("htmlFor" in labelProps && labelProps.htmlFor) {
|
|
118
136
|
// Ideally the `for` attribute should point to the first thumb, but VoiceOver on iOS
|
|
119
137
|
// causes this to override the `aria-labelledby` on the thumb. This causes the first
|
|
120
138
|
// thumb to only be announced as the slider label rather than its individual name as well.
|
|
@@ -124,8 +142,8 @@ function $bcca50147b47f54d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
124
142
|
var // Safari does not focus <input type="range"> elements when clicking on an associated <label>,
|
|
125
143
|
// so do it manually. In addition, make sure we show the focus ring.
|
|
126
144
|
ref;
|
|
127
|
-
(ref = document.getElementById($aa519ee6cf463259$export$68e648cbec363a18(state, 0))) === null || ref === void 0 ? void 0 : ref.focus();
|
|
128
|
-
$fA3fN$setInteractionModality(
|
|
145
|
+
(ref = document.getElementById((0, $aa519ee6cf463259$export$68e648cbec363a18)(state, 0))) === null || ref === void 0 ? void 0 : ref.focus();
|
|
146
|
+
(0, $fA3fN$setInteractionModality)("keyboard");
|
|
129
147
|
};
|
|
130
148
|
}
|
|
131
149
|
return {
|
|
@@ -134,30 +152,29 @@ function $bcca50147b47f54d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
134
152
|
// all the thumb inputs in the Slider. The label of the Slider will
|
|
135
153
|
// be used to label the group.
|
|
136
154
|
groupProps: {
|
|
137
|
-
role:
|
|
155
|
+
role: "group",
|
|
138
156
|
...fieldProps
|
|
139
157
|
},
|
|
140
|
-
trackProps: $fA3fN$mergeProps({
|
|
158
|
+
trackProps: (0, $fA3fN$mergeProps)({
|
|
141
159
|
onMouseDown (e) {
|
|
142
160
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
143
161
|
onDownTrack(e, undefined, e.clientX, e.clientY);
|
|
144
162
|
},
|
|
145
163
|
onPointerDown (e) {
|
|
146
|
-
if (e.pointerType ===
|
|
164
|
+
if (e.pointerType === "mouse" && (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey)) return;
|
|
147
165
|
onDownTrack(e, e.pointerId, e.clientX, e.clientY);
|
|
148
166
|
},
|
|
149
167
|
onTouchStart (e) {
|
|
150
168
|
onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY);
|
|
151
169
|
},
|
|
152
170
|
style: {
|
|
153
|
-
position:
|
|
154
|
-
touchAction:
|
|
171
|
+
position: "relative",
|
|
172
|
+
touchAction: "none"
|
|
155
173
|
}
|
|
156
174
|
}, moveProps),
|
|
157
175
|
outputProps: {
|
|
158
|
-
htmlFor: state.values.map((_, index)
|
|
159
|
-
|
|
160
|
-
'aria-live': 'off'
|
|
176
|
+
htmlFor: state.values.map((_, index)=>(0, $aa519ee6cf463259$export$68e648cbec363a18)(state, index)).join(" "),
|
|
177
|
+
"aria-live": "off"
|
|
161
178
|
}
|
|
162
179
|
};
|
|
163
180
|
}
|
|
@@ -173,34 +190,34 @@ function $bcca50147b47f54d$export$56b2c08e277f365(props, state, trackRef) {
|
|
|
173
190
|
function $47b897dc8cdb026b$export$8d15029008292ae(opts, state) {
|
|
174
191
|
let { index: index , isRequired: isRequired , validationState: validationState , trackRef: trackRef , inputRef: inputRef , orientation: orientation = state.orientation } = opts;
|
|
175
192
|
let isDisabled = opts.isDisabled || state.isDisabled;
|
|
176
|
-
let isVertical = orientation ===
|
|
177
|
-
let { direction: direction } = $fA3fN$useLocale();
|
|
178
|
-
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = $fA3fN$useGlobalListeners();
|
|
179
|
-
let labelId = $aa519ee6cf463259$export$7a8d2b02c9371cbf.get(state);
|
|
180
|
-
var
|
|
181
|
-
const { labelProps: labelProps , fieldProps: fieldProps } = $fA3fN$useLabel({
|
|
193
|
+
let isVertical = orientation === "vertical";
|
|
194
|
+
let { direction: direction } = (0, $fA3fN$useLocale)();
|
|
195
|
+
let { addGlobalListener: addGlobalListener , removeGlobalListener: removeGlobalListener } = (0, $fA3fN$useGlobalListeners)();
|
|
196
|
+
let labelId = (0, $aa519ee6cf463259$export$7a8d2b02c9371cbf).get(state);
|
|
197
|
+
var ref;
|
|
198
|
+
const { labelProps: labelProps , fieldProps: fieldProps } = (0, $fA3fN$useLabel)({
|
|
182
199
|
...opts,
|
|
183
|
-
id: $aa519ee6cf463259$export$68e648cbec363a18(state, index),
|
|
184
|
-
|
|
200
|
+
id: (0, $aa519ee6cf463259$export$68e648cbec363a18)(state, index),
|
|
201
|
+
"aria-labelledby": `${labelId} ${(ref = opts["aria-labelledby"]) !== null && ref !== void 0 ? ref : ""}`.trim()
|
|
185
202
|
});
|
|
186
203
|
const value = state.values[index];
|
|
187
|
-
const focusInput = $fA3fN$useCallback(()=>{
|
|
188
|
-
if (inputRef.current) $fA3fN$focusWithoutScrolling(inputRef.current);
|
|
204
|
+
const focusInput = (0, $fA3fN$useCallback)(()=>{
|
|
205
|
+
if (inputRef.current) (0, $fA3fN$focusWithoutScrolling)(inputRef.current);
|
|
189
206
|
}, [
|
|
190
207
|
inputRef
|
|
191
208
|
]);
|
|
192
209
|
const isFocused = state.focusedThumb === index;
|
|
193
|
-
$fA3fN$useEffect(()=>{
|
|
210
|
+
(0, $fA3fN$useEffect)(()=>{
|
|
194
211
|
if (isFocused) focusInput();
|
|
195
212
|
}, [
|
|
196
213
|
isFocused,
|
|
197
214
|
focusInput
|
|
198
215
|
]);
|
|
199
|
-
const stateRef = $fA3fN$useRef(null);
|
|
216
|
+
const stateRef = (0, $fA3fN$useRef)(null);
|
|
200
217
|
stateRef.current = state;
|
|
201
|
-
let reverseX = direction ===
|
|
202
|
-
let currentPosition = $fA3fN$useRef(null);
|
|
203
|
-
let { keyboardProps: keyboardProps } = $fA3fN$useKeyboard({
|
|
218
|
+
let reverseX = direction === "rtl";
|
|
219
|
+
let currentPosition = (0, $fA3fN$useRef)(null);
|
|
220
|
+
let { keyboardProps: keyboardProps } = (0, $fA3fN$useKeyboard)({
|
|
204
221
|
onKeyDown (e) {
|
|
205
222
|
let { getThumbMaxValue: getThumbMaxValue , getThumbMinValue: getThumbMinValue , decrementThumb: decrementThumb , incrementThumb: incrementThumb , setThumbValue: setThumbValue , setThumbDragging: setThumbDragging , pageSize: pageSize } = stateRef.current;
|
|
206
223
|
// these are the cases that useMove or useSlider don't handle
|
|
@@ -213,23 +230,23 @@ function $47b897dc8cdb026b$export$8d15029008292ae(opts, state) {
|
|
|
213
230
|
// remember to set this so that onChangeEnd is fired
|
|
214
231
|
setThumbDragging(index, true);
|
|
215
232
|
switch(e.key){
|
|
216
|
-
case
|
|
233
|
+
case "PageUp":
|
|
217
234
|
incrementThumb(index, pageSize);
|
|
218
235
|
break;
|
|
219
|
-
case
|
|
236
|
+
case "PageDown":
|
|
220
237
|
decrementThumb(index, pageSize);
|
|
221
238
|
break;
|
|
222
|
-
case
|
|
239
|
+
case "Home":
|
|
223
240
|
setThumbValue(index, getThumbMinValue(index));
|
|
224
241
|
break;
|
|
225
|
-
case
|
|
242
|
+
case "End":
|
|
226
243
|
setThumbValue(index, getThumbMaxValue(index));
|
|
227
244
|
break;
|
|
228
245
|
}
|
|
229
246
|
setThumbDragging(index, false);
|
|
230
247
|
}
|
|
231
248
|
});
|
|
232
|
-
let { moveProps: moveProps } = $fA3fN$useMove({
|
|
249
|
+
let { moveProps: moveProps } = (0, $fA3fN$useMove)({
|
|
233
250
|
onMoveStart () {
|
|
234
251
|
currentPosition.current = null;
|
|
235
252
|
stateRef.current.setThumbDragging(index, true);
|
|
@@ -239,14 +256,14 @@ function $47b897dc8cdb026b$export$8d15029008292ae(opts, state) {
|
|
|
239
256
|
let { width: width , height: height } = trackRef.current.getBoundingClientRect();
|
|
240
257
|
let size = isVertical ? height : width;
|
|
241
258
|
if (currentPosition.current == null) currentPosition.current = getThumbPercent(index) * size;
|
|
242
|
-
if (pointerType ===
|
|
259
|
+
if (pointerType === "keyboard") {
|
|
243
260
|
if (deltaX > 0 && reverseX || deltaX < 0 && !reverseX || deltaY > 0) decrementThumb(index, shiftKey ? pageSize : step);
|
|
244
261
|
else incrementThumb(index, shiftKey ? pageSize : step);
|
|
245
262
|
} else {
|
|
246
263
|
let delta = isVertical ? deltaY : deltaX;
|
|
247
264
|
if (isVertical || reverseX) delta = -delta;
|
|
248
265
|
currentPosition.current += delta;
|
|
249
|
-
setThumbPercent(index, $fA3fN$clamp(currentPosition.current / size, 0, 1));
|
|
266
|
+
setThumbPercent(index, (0, $fA3fN$clamp)(currentPosition.current / size, 0, 1));
|
|
250
267
|
}
|
|
251
268
|
},
|
|
252
269
|
onMoveEnd () {
|
|
@@ -255,19 +272,18 @@ function $47b897dc8cdb026b$export$8d15029008292ae(opts, state) {
|
|
|
255
272
|
});
|
|
256
273
|
// Immediately register editability with the state
|
|
257
274
|
state.setThumbEditable(index, !isDisabled);
|
|
258
|
-
const { focusableProps: focusableProps } = $fA3fN$useFocusable($fA3fN$mergeProps(opts, {
|
|
259
|
-
onFocus: ()=>state.setFocusedThumb(index)
|
|
260
|
-
,
|
|
275
|
+
const { focusableProps: focusableProps } = (0, $fA3fN$useFocusable)((0, $fA3fN$mergeProps)(opts, {
|
|
276
|
+
onFocus: ()=>state.setFocusedThumb(index),
|
|
261
277
|
onBlur: ()=>state.setFocusedThumb(undefined)
|
|
262
278
|
}), inputRef);
|
|
263
|
-
let currentPointer = $fA3fN$useRef(undefined);
|
|
279
|
+
let currentPointer = (0, $fA3fN$useRef)(undefined);
|
|
264
280
|
let onDown = (id)=>{
|
|
265
281
|
focusInput();
|
|
266
282
|
currentPointer.current = id;
|
|
267
283
|
state.setThumbDragging(index, true);
|
|
268
|
-
addGlobalListener(window,
|
|
269
|
-
addGlobalListener(window,
|
|
270
|
-
addGlobalListener(window,
|
|
284
|
+
addGlobalListener(window, "mouseup", onUp, false);
|
|
285
|
+
addGlobalListener(window, "touchend", onUp, false);
|
|
286
|
+
addGlobalListener(window, "pointerup", onUp, false);
|
|
271
287
|
};
|
|
272
288
|
let onUp = (e)=>{
|
|
273
289
|
var ref;
|
|
@@ -276,14 +292,14 @@ function $47b897dc8cdb026b$export$8d15029008292ae(opts, state) {
|
|
|
276
292
|
if (id === currentPointer.current) {
|
|
277
293
|
focusInput();
|
|
278
294
|
state.setThumbDragging(index, false);
|
|
279
|
-
removeGlobalListener(window,
|
|
280
|
-
removeGlobalListener(window,
|
|
281
|
-
removeGlobalListener(window,
|
|
295
|
+
removeGlobalListener(window, "mouseup", onUp, false);
|
|
296
|
+
removeGlobalListener(window, "touchend", onUp, false);
|
|
297
|
+
removeGlobalListener(window, "pointerup", onUp, false);
|
|
282
298
|
}
|
|
283
299
|
};
|
|
284
300
|
let thumbPosition = state.getThumbPercent(index);
|
|
285
|
-
if (isVertical || direction ===
|
|
286
|
-
let interactions = !isDisabled ? $fA3fN$mergeProps(keyboardProps, moveProps, {
|
|
301
|
+
if (isVertical || direction === "rtl") thumbPosition = 1 - thumbPosition;
|
|
302
|
+
let interactions = !isDisabled ? (0, $fA3fN$mergeProps)(keyboardProps, moveProps, {
|
|
287
303
|
onMouseDown: (e)=>{
|
|
288
304
|
if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) return;
|
|
289
305
|
onDown();
|
|
@@ -295,26 +311,25 @@ function $47b897dc8cdb026b$export$8d15029008292ae(opts, state) {
|
|
|
295
311
|
onTouchStart: (e)=>{
|
|
296
312
|
onDown(e.changedTouches[0].identifier);
|
|
297
313
|
}
|
|
298
|
-
}) : {
|
|
299
|
-
};
|
|
314
|
+
}) : {};
|
|
300
315
|
// We install mouse handlers for the drag motion on the thumb div, but
|
|
301
316
|
// not the key handler for moving the thumb with the slider. Instead,
|
|
302
317
|
// we focus the range input, and let the browser handle the keyboard
|
|
303
318
|
// interactions; we then listen to input's onChange to update state.
|
|
304
319
|
return {
|
|
305
|
-
inputProps: $fA3fN$mergeProps(focusableProps, fieldProps, {
|
|
306
|
-
type:
|
|
320
|
+
inputProps: (0, $fA3fN$mergeProps)(focusableProps, fieldProps, {
|
|
321
|
+
type: "range",
|
|
307
322
|
tabIndex: !isDisabled ? 0 : undefined,
|
|
308
323
|
min: state.getThumbMinValue(index),
|
|
309
324
|
max: state.getThumbMaxValue(index),
|
|
310
325
|
step: state.step,
|
|
311
326
|
value: value,
|
|
312
327
|
disabled: isDisabled,
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
328
|
+
"aria-orientation": orientation,
|
|
329
|
+
"aria-valuetext": state.getThumbValueLabel(index),
|
|
330
|
+
"aria-required": isRequired || undefined,
|
|
331
|
+
"aria-invalid": validationState === "invalid" || undefined,
|
|
332
|
+
"aria-errormessage": opts["aria-errormessage"],
|
|
318
333
|
onChange: (e)=>{
|
|
319
334
|
stateRef.current.setThumbValue(index, parseFloat(e.target.value));
|
|
320
335
|
}
|
|
@@ -322,10 +337,10 @@ function $47b897dc8cdb026b$export$8d15029008292ae(opts, state) {
|
|
|
322
337
|
thumbProps: {
|
|
323
338
|
...interactions,
|
|
324
339
|
style: {
|
|
325
|
-
position:
|
|
326
|
-
[isVertical ?
|
|
327
|
-
transform:
|
|
328
|
-
touchAction:
|
|
340
|
+
position: "absolute",
|
|
341
|
+
[isVertical ? "top" : "left"]: `${thumbPosition * 100}%`,
|
|
342
|
+
transform: "translate(-50%, -50%)",
|
|
343
|
+
touchAction: "none"
|
|
329
344
|
}
|
|
330
345
|
},
|
|
331
346
|
labelProps: labelProps,
|
package/dist/module.mjs.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;;;;;;;SDmCe,wCAAS,CACvB,KAAyB,EACzB,KAAkB,EAClB,QAA4B,EAChB,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,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,gBAAS;IAE3B,GAAG,CAAC,CAAC,oBAAA,iBAAiB,yBAAE,oBAAoB,EAAA,CAAC,GAAG,yBAAkB;IAElE,EAAkF,AAAlF,gFAAkF;IAClF,EAAgF,AAAhF,8EAAgF;IAChF,EAA+E,AAA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@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 */\nexport {useSlider} from './useSlider';\nexport {useSliderThumb} from './useSliderThumb';\nexport type {AriaSliderProps} from '@react-types/slider';\nexport type {SliderAria} from './useSlider';\nexport type {AriaSliderThumbOptions, SliderThumbAria} from './useSliderThumb';\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 {DOMAttributes} from '@react-types/shared';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {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\nexport interface 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: DOMAttributes,\n\n /** Props for the track element. */\n trackProps: DOMAttributes,\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<T extends number | number[]>(\n props: AriaSliderProps<T>,\n state: SliderState,\n trackRef: RefObject<Element>\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 {height, width} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\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 {height, width, top, left} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\n // Find the closest thumb\n const trackPosition = 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 ('htmlFor' in labelProps && 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) {\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) {\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) { onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY); },\n style: {\n position: 'relative',\n touchAction: 'none'\n }\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 {DOMAttributes} from '@react-types/shared';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {ChangeEvent, 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\nexport interface SliderThumbAria {\n /** Props for the root thumb element; handles the dragging motion. */\n thumbProps: DOMAttributes,\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 /** Whether this thumb is currently being dragged. */\n isDragging: boolean,\n /** Whether the thumb is currently focused. */\n isFocused: boolean,\n /** Whether the thumb is disabled. */\n isDisabled: boolean\n}\n\nexport interface AriaSliderThumbOptions extends AriaSliderThumbProps {\n /** A ref to the track element. */\n trackRef: RefObject<Element>,\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: AriaSliderThumbOptions,\n state: SliderState\n): SliderThumbAria {\n let {\n index,\n isRequired,\n validationState,\n trackRef,\n inputRef,\n orientation = state.orientation\n } = opts;\n\n let isDisabled = opts.isDisabled || state.isDisabled;\n let isVertical = 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 {width, height} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\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 let thumbPosition = state.getThumbPercent(index);\n if (isVertical || direction === 'rtl') {\n thumbPosition = 1 - thumbPosition;\n }\n\n let interactions = !isDisabled ? mergeProps(\n keyboardProps,\n moveProps,\n {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown();\n },\n onPointerDown: (e: React.PointerEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent) => {onDown(e.changedTouches[0].identifier);}\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': 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: {\n ...interactions,\n style: {\n position: 'absolute',\n [isVertical ? 'top' : 'left']: `${thumbPosition * 100}%`,\n transform: 'translate(-50%, -50%)',\n touchAction: 'none'\n }\n },\n labelProps,\n isDragging: state.isThumbDragging(index),\n isDisabled,\n isFocused\n };\n}\n"],"names":[],"version":3,"file":"module.mjs.map"}
|
|
1
|
+
{"mappings":";;;;;;;AAAA;;;;;;;;;;ACAA;;;;;;;;;;CAUC,GAED;ACVO,MAAM,4CAAY,IAAI;AAEtB,SAAS,0CAAiB,KAAkB,EAAE,KAAa,EAAE;IAClE,IAAI,KAAK,0CAAU,GAAG,CAAC;IACvB,IAAI,CAAC,IACH,MAAM,IAAI,MAAM,wBAAwB;IAG1C,OAAO,CAAC,EAAE,GAAG,CAAC,EAAE,MAAM,CAAC;AACzB;;;;;;;ADmCO,SAAS,yCACd,KAAyB,EACzB,KAAkB,EAClB,QAA4B,EAChB;IACZ,IAAI,cAAC,WAAU,cAAE,WAAU,EAAC,GAAG,CAAA,GAAA,eAAQ,AAAD,EAAE;IAExC,IAAI,aAAa,MAAM,WAAW,KAAK;QAGlB;IADrB,+EAA+E;IAC/E,CAAA,GAAA,yCAAQ,EAAE,GAAG,CAAC,OAAO,CAAA,MAAA,WAAW,EAA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,EACtD;YAEF;QACF;QACA,eAAe,CAAC,IAA0B;YACxC,IAAI,EAAE,MAAM,KAAK,KAAK,EAAE,MAAM,IAAI,EAAE,OAAO,IAAI,EAAE,OAAO,EACtD;YAEF,OAAO,EAAE,SAAS;QACpB;QACA,cAAc,CAAC,IAAwB;YAAC,OAAO,EAAE,cAAc,CAAC,EAAE,CAAC,UAAU;QAAE;IACjF,KACE,CAAC,CAAC;IAEN,sEAAsE;IACtE,sEAAsE;IACtE,oEAAoE;IACpE,oEAAoE;IACpE,OAAO;QACL,YAAY,CAAA,GAAA,iBAAU,AAAD,EAAE,gBAAgB,YAAY;YACjD,MAAM;YACN,UAAU,CAAC,aAAa,IAAI,SAAS;YACrC,KAAK,MAAM,gBAAgB,CAAC;YAC5B,KAAK,MAAM,gBAAgB,CAAC;YAC5B,MAAM,MAAM,IAAI;YAChB,OAAO;YACP,UAAU;YACV,oBAAoB;YACpB,kBAAkB,MAAM,kBAAkB,CAAC;YAC3C,iBAAiB,cAAc;YAC/B,gBAAgB,oBAAoB,aAAa;YACjD,qBAAqB,IAAI,CAAC,oBAAoB;YAC9C,UAAU,CAAC,IAAqC;gBAC9C,SAAS,OAAO,CAAC,aAAa,CAAC,OAAO,WAAW,EAAE,MAAM,CAAC,KAAK;YACjE;QACF;QACA,YAAY;YACV,GAAG,YAAY;YACf,OAAO;gBACL,UAAU;gBACV,CAAC,aAAa,QAAQ,MAAM,CAAC,EAAE,CAAC,EAAE,gBAAgB,IAAI,CAAC,CAAC;gBACxD,WAAW;gBACX,aAAa;YACf;QACF;oBACA;QACA,YAAY,MAAM,eAAe,CAAC;oBAClC;mBACA;IACF;AACF;","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 */\nexport {useSlider} from './useSlider';\nexport {useSliderThumb} from './useSliderThumb';\nexport type {AriaSliderProps} from '@react-types/slider';\nexport type {SliderAria} from './useSlider';\nexport type {AriaSliderThumbOptions, SliderThumbAria} from './useSliderThumb';\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 {DOMAttributes} from '@react-types/shared';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {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\nexport interface 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: DOMAttributes,\n\n /** Props for the track element. */\n trackProps: DOMAttributes,\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<T extends number | number[]>(\n props: AriaSliderProps<T>,\n state: SliderState,\n trackRef: RefObject<Element>\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 {height, width} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\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 {height, width, top, left} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\n // Find the closest thumb\n const trackPosition = 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 ('htmlFor' in labelProps && 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) {\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) {\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) { onDownTrack(e, e.changedTouches[0].identifier, e.changedTouches[0].clientX, e.changedTouches[0].clientY); },\n style: {\n position: 'relative',\n touchAction: 'none'\n }\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 {DOMAttributes} from '@react-types/shared';\nimport {getSliderThumbId, sliderIds} from './utils';\nimport React, {ChangeEvent, 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\nexport interface SliderThumbAria {\n /** Props for the root thumb element; handles the dragging motion. */\n thumbProps: DOMAttributes,\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 /** Whether this thumb is currently being dragged. */\n isDragging: boolean,\n /** Whether the thumb is currently focused. */\n isFocused: boolean,\n /** Whether the thumb is disabled. */\n isDisabled: boolean\n}\n\nexport interface AriaSliderThumbOptions extends AriaSliderThumbProps {\n /** A ref to the track element. */\n trackRef: RefObject<Element>,\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: AriaSliderThumbOptions,\n state: SliderState\n): SliderThumbAria {\n let {\n index,\n isRequired,\n validationState,\n trackRef,\n inputRef,\n orientation = state.orientation\n } = opts;\n\n let isDisabled = opts.isDisabled || state.isDisabled;\n let isVertical = 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 {width, height} = trackRef.current.getBoundingClientRect();\n let size = isVertical ? height : width;\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 let thumbPosition = state.getThumbPercent(index);\n if (isVertical || direction === 'rtl') {\n thumbPosition = 1 - thumbPosition;\n }\n\n let interactions = !isDisabled ? mergeProps(\n keyboardProps,\n moveProps,\n {\n onMouseDown: (e: React.MouseEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown();\n },\n onPointerDown: (e: React.PointerEvent) => {\n if (e.button !== 0 || e.altKey || e.ctrlKey || e.metaKey) {\n return;\n }\n onDown(e.pointerId);\n },\n onTouchStart: (e: React.TouchEvent) => {onDown(e.changedTouches[0].identifier);}\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': 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: {\n ...interactions,\n style: {\n position: 'absolute',\n [isVertical ? 'top' : 'left']: `${thumbPosition * 100}%`,\n transform: 'translate(-50%, -50%)',\n touchAction: 'none'\n }\n },\n labelProps,\n isDragging: state.isThumbDragging(index),\n isDisabled,\n isFocused\n };\n}\n"],"names":[],"version":3,"file":"module.mjs.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-aria/slider",
|
|
3
|
-
"version": "3.2.4-nightly.
|
|
3
|
+
"version": "3.2.4-nightly.3600+bfce84fee",
|
|
4
4
|
"description": "Slider",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@
|
|
26
|
-
"@react-aria/
|
|
27
|
-
"@react-aria/
|
|
28
|
-
"@react-aria/
|
|
29
|
-
"@react-aria/
|
|
30
|
-
"@react-
|
|
31
|
-
"@react-stately/
|
|
32
|
-
"@react-
|
|
33
|
-
"@react-types/
|
|
34
|
-
"@react-types/
|
|
35
|
-
"@
|
|
25
|
+
"@react-aria/focus": "3.0.0-nightly.1900+bfce84fee",
|
|
26
|
+
"@react-aria/i18n": "3.0.0-nightly.1900+bfce84fee",
|
|
27
|
+
"@react-aria/interactions": "3.0.0-nightly.1900+bfce84fee",
|
|
28
|
+
"@react-aria/label": "3.0.0-nightly.1900+bfce84fee",
|
|
29
|
+
"@react-aria/utils": "3.0.0-nightly.1900+bfce84fee",
|
|
30
|
+
"@react-stately/radio": "3.0.0-nightly.1900+bfce84fee",
|
|
31
|
+
"@react-stately/slider": "3.2.4-nightly.3600+bfce84fee",
|
|
32
|
+
"@react-types/radio": "3.0.0-nightly.1900+bfce84fee",
|
|
33
|
+
"@react-types/shared": "3.0.0-nightly.1900+bfce84fee",
|
|
34
|
+
"@react-types/slider": "3.3.2-nightly.3600+bfce84fee",
|
|
35
|
+
"@swc/helpers": "^0.4.14"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "bfce84fee12a027d9cbc38b43e1747e3e4b4b169"
|
|
44
44
|
}
|