@cdx-ui/primitives 0.0.1-beta.170 → 0.0.1-beta.171
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/lib/commonjs/slider/SliderRail.js +35 -9
- package/lib/commonjs/slider/SliderRail.js.map +1 -1
- package/lib/commonjs/slider/SliderRoot.js +155 -97
- package/lib/commonjs/slider/SliderRoot.js.map +1 -1
- package/lib/commonjs/slider/SliderThumb.js +182 -68
- package/lib/commonjs/slider/SliderThumb.js.map +1 -1
- package/lib/commonjs/slider/context.js +4 -1
- package/lib/commonjs/slider/context.js.map +1 -1
- package/lib/commonjs/slider/index.js +36 -0
- package/lib/commonjs/slider/index.js.map +1 -1
- package/lib/commonjs/slider/useSliderPointer.js +1 -1
- package/lib/commonjs/slider/useSliderPointer.js.map +1 -1
- package/lib/commonjs/slider/utils.js +68 -0
- package/lib/commonjs/slider/utils.js.map +1 -1
- package/lib/module/slider/SliderRail.js +35 -9
- package/lib/module/slider/SliderRail.js.map +1 -1
- package/lib/module/slider/SliderRoot.js +157 -99
- package/lib/module/slider/SliderRoot.js.map +1 -1
- package/lib/module/slider/SliderThumb.js +185 -71
- package/lib/module/slider/SliderThumb.js.map +1 -1
- package/lib/module/slider/context.js +1 -0
- package/lib/module/slider/context.js.map +1 -1
- package/lib/module/slider/index.js +2 -2
- package/lib/module/slider/index.js.map +1 -1
- package/lib/module/slider/useSliderPointer.js +1 -1
- package/lib/module/slider/useSliderPointer.js.map +1 -1
- package/lib/module/slider/utils.js +63 -0
- package/lib/module/slider/utils.js.map +1 -1
- package/lib/typescript/slider/SliderRail.d.ts.map +1 -1
- package/lib/typescript/slider/SliderRoot.d.ts +2 -2
- package/lib/typescript/slider/SliderRoot.d.ts.map +1 -1
- package/lib/typescript/slider/SliderThumb.d.ts.map +1 -1
- package/lib/typescript/slider/context.d.ts +53 -9
- package/lib/typescript/slider/context.d.ts.map +1 -1
- package/lib/typescript/slider/index.d.ts +4 -4
- package/lib/typescript/slider/index.d.ts.map +1 -1
- package/lib/typescript/slider/types.d.ts +44 -8
- package/lib/typescript/slider/types.d.ts.map +1 -1
- package/lib/typescript/slider/utils.d.ts +8 -0
- package/lib/typescript/slider/utils.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/slider/SliderRail.tsx +56 -8
- package/src/slider/SliderRoot.tsx +255 -136
- package/src/slider/SliderThumb.tsx +240 -88
- package/src/slider/context.tsx +53 -9
- package/src/slider/index.ts +9 -2
- package/src/slider/types.ts +49 -8
- package/src/slider/useSliderPointer.ts +1 -1
- package/src/slider/utils.ts +76 -0
|
@@ -1,25 +1,32 @@
|
|
|
1
|
-
import { forwardRef, useCallback, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
Platform,
|
|
4
|
-
View,
|
|
5
|
-
type NativeSyntheticEvent,
|
|
6
|
-
type TargetedEvent,
|
|
7
|
-
type ViewProps,
|
|
8
|
-
} from 'react-native';
|
|
1
|
+
import { forwardRef, useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Platform, View, type ViewProps } from 'react-native';
|
|
9
3
|
import { composeEventHandlers, useControllableState } from '@cdx-ui/utils';
|
|
10
|
-
import { useFocus } from '@react-native-aria/focus';
|
|
11
4
|
import { Slot } from '../slot';
|
|
12
5
|
import { dataAttributes } from '../utils/dataAttributes';
|
|
13
6
|
import { SliderProvider, type SliderTrackLayout } from './context';
|
|
14
|
-
import type {
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
import type { SliderRootImplementationProps } from './types';
|
|
8
|
+
import {
|
|
9
|
+
arraysEqual,
|
|
10
|
+
clamp,
|
|
11
|
+
denormalizeSliderValue,
|
|
12
|
+
formatSliderValue,
|
|
13
|
+
getClosestValueIndex,
|
|
14
|
+
normalizeSliderValue,
|
|
15
|
+
snapToStep,
|
|
16
|
+
valueToPercent,
|
|
17
|
+
} from './utils';
|
|
18
18
|
|
|
19
|
-
export interface SliderRootProps extends
|
|
19
|
+
export interface SliderRootProps extends SliderRootImplementationProps {
|
|
20
20
|
readonly asChild?: boolean;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
function isArrayShape(
|
|
24
|
+
value: number | readonly number[] | undefined,
|
|
25
|
+
defaultValue: number | readonly number[] | undefined,
|
|
26
|
+
): boolean {
|
|
27
|
+
return Array.isArray(value) || Array.isArray(defaultValue);
|
|
28
|
+
}
|
|
29
|
+
|
|
23
30
|
export const SliderRoot = forwardRef<View, SliderRootProps>(
|
|
24
31
|
(
|
|
25
32
|
{
|
|
@@ -35,8 +42,6 @@ export const SliderRoot = forwardRef<View, SliderRootProps>(
|
|
|
35
42
|
orientation = 'horizontal',
|
|
36
43
|
accessibilityLabel,
|
|
37
44
|
accessibilityValue: accessibilityValueProp,
|
|
38
|
-
accessibilityRole = 'adjustable',
|
|
39
|
-
role = 'slider',
|
|
40
45
|
children,
|
|
41
46
|
onLayout,
|
|
42
47
|
...props
|
|
@@ -45,42 +50,173 @@ export const SliderRoot = forwardRef<View, SliderRootProps>(
|
|
|
45
50
|
) => {
|
|
46
51
|
const [trackLayout, setTrackLayoutState] = useState<SliderTrackLayout | null>(null);
|
|
47
52
|
const [thumbSize, setThumbSizeState] = useState(20);
|
|
48
|
-
const [
|
|
49
|
-
const [
|
|
50
|
-
const [
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
53
|
+
const [draggingIndex, setDraggingIndex] = useState<number | null>(null);
|
|
54
|
+
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
|
|
55
|
+
const [focusedIndex, setFocusedIndex] = useState<number | null>(null);
|
|
56
|
+
const [registeredThumbCounts, setRegisteredThumbCounts] = useState<Map<number, number>>(
|
|
57
|
+
() => new Map(),
|
|
58
|
+
);
|
|
59
|
+
const deprecatedThumbRef = useRef<View>(null);
|
|
60
|
+
|
|
61
|
+
const isRangeShapeRef = useRef(isArrayShape(valueProp, defaultValue));
|
|
62
|
+
isRangeShapeRef.current = isArrayShape(valueProp, defaultValue);
|
|
63
|
+
|
|
64
|
+
const resolvedDefaultScalar = typeof defaultValue === 'number' ? defaultValue : min;
|
|
65
|
+
const resolvedDefaultArray = Array.isArray(defaultValue)
|
|
66
|
+
? [...defaultValue]
|
|
67
|
+
: [resolvedDefaultScalar];
|
|
68
|
+
|
|
69
|
+
const [values, setValuesState] = useControllableState<readonly number[]>({
|
|
70
|
+
prop:
|
|
71
|
+
valueProp == null ? undefined : normalizeSliderValue(valueProp, min, resolvedDefaultScalar),
|
|
72
|
+
defaultProp: resolvedDefaultArray,
|
|
73
|
+
onChange: onChange
|
|
74
|
+
? (next) => {
|
|
75
|
+
const denormalized = denormalizeSliderValue(next, isRangeShapeRef.current);
|
|
76
|
+
if (isRangeShapeRef.current) {
|
|
77
|
+
(onChange as (value: number[]) => void)(denormalized as number[]);
|
|
78
|
+
} else {
|
|
79
|
+
(onChange as (value: number) => void)(denormalized as number);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
: undefined,
|
|
59
83
|
});
|
|
60
84
|
|
|
61
|
-
const
|
|
62
|
-
|
|
85
|
+
const currentValues = useMemo(() => {
|
|
86
|
+
const source = values ?? resolvedDefaultArray;
|
|
87
|
+
return source.map((value) => snapToStep(value, min, max, step));
|
|
88
|
+
}, [max, min, resolvedDefaultArray, step, values]);
|
|
63
89
|
|
|
64
|
-
const
|
|
65
|
-
(
|
|
90
|
+
const registeredThumbCount = [...registeredThumbCounts.values()].reduce(
|
|
91
|
+
(total, count) => total + count,
|
|
92
|
+
0,
|
|
93
|
+
);
|
|
94
|
+
const hasDuplicateThumbIndices = [...registeredThumbCounts.values()].some((count) => count > 1);
|
|
95
|
+
const thumbCount = Math.max(currentValues.length, registeredThumbCount);
|
|
96
|
+
|
|
97
|
+
const registerThumb = useCallback((index: number) => {
|
|
98
|
+
setRegisteredThumbCounts((prev) => {
|
|
99
|
+
const next = new Map(prev);
|
|
100
|
+
next.set(index, (next.get(index) ?? 0) + 1);
|
|
101
|
+
return next;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
return () => {
|
|
105
|
+
setRegisteredThumbCounts((prev) => {
|
|
106
|
+
const count = prev.get(index);
|
|
107
|
+
if (count == null) {
|
|
108
|
+
return prev;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const next = new Map(prev);
|
|
112
|
+
if (count === 1) {
|
|
113
|
+
next.delete(index);
|
|
114
|
+
} else {
|
|
115
|
+
next.set(index, count - 1);
|
|
116
|
+
}
|
|
117
|
+
return next;
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
}, []);
|
|
121
|
+
|
|
122
|
+
useEffect(() => {
|
|
123
|
+
if (!__DEV__) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
const renderedCount = registeredThumbCount;
|
|
128
|
+
if (renderedCount > 0 && renderedCount !== currentValues.length) {
|
|
129
|
+
console.warn(
|
|
130
|
+
`[Slider] Thumb count (${String(renderedCount)}) does not match value count (${String(currentValues.length)}).`,
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
if (hasDuplicateThumbIndices) {
|
|
135
|
+
console.warn('[Slider] Multiple thumbs share the same `index` prop.');
|
|
136
|
+
}
|
|
137
|
+
}, [currentValues.length, hasDuplicateThumbIndices, registeredThumbCount]);
|
|
138
|
+
|
|
139
|
+
const getThumbMinValue = useCallback(
|
|
140
|
+
(index: number) => {
|
|
141
|
+
if (index <= 0) {
|
|
142
|
+
return min;
|
|
143
|
+
}
|
|
144
|
+
return currentValues[index - 1] ?? min;
|
|
145
|
+
},
|
|
146
|
+
[currentValues, min],
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
const getThumbMaxValue = useCallback(
|
|
150
|
+
(index: number) => {
|
|
151
|
+
if (index >= currentValues.length - 1) {
|
|
152
|
+
return max;
|
|
153
|
+
}
|
|
154
|
+
return currentValues[index + 1] ?? max;
|
|
155
|
+
},
|
|
156
|
+
[currentValues, max],
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
const getThumbPercent = useCallback(
|
|
160
|
+
(index: number) => valueToPercent(currentValues[index] ?? min, min, max),
|
|
161
|
+
[currentValues, max, min],
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const commitValues = useCallback(
|
|
165
|
+
(nextValues: number[], complete = false) => {
|
|
66
166
|
if (isDisabled) {
|
|
67
167
|
return;
|
|
68
168
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
169
|
+
|
|
170
|
+
const unchanged = arraysEqual(nextValues, currentValues);
|
|
171
|
+
|
|
172
|
+
if (!unchanged) {
|
|
173
|
+
setValuesState(nextValues);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (complete && onChangeComplete) {
|
|
177
|
+
const denormalized = denormalizeSliderValue(
|
|
178
|
+
unchanged ? currentValues : nextValues,
|
|
179
|
+
isRangeShapeRef.current,
|
|
180
|
+
);
|
|
181
|
+
if (isRangeShapeRef.current) {
|
|
182
|
+
(onChangeComplete as (value: number[]) => void)(denormalized as number[]);
|
|
183
|
+
} else {
|
|
184
|
+
(onChangeComplete as (value: number) => void)(denormalized as number);
|
|
185
|
+
}
|
|
73
186
|
}
|
|
74
187
|
},
|
|
75
|
-
[
|
|
188
|
+
[currentValues, isDisabled, onChangeComplete, setValuesState],
|
|
76
189
|
);
|
|
77
190
|
|
|
78
|
-
const
|
|
79
|
-
(
|
|
191
|
+
const setThumbValue = useCallback(
|
|
192
|
+
(index: number, next: number, complete = false) => {
|
|
193
|
+
if (isDisabled || index < 0 || index >= currentValues.length) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const snapped = snapToStep(next, getThumbMinValue(index), getThumbMaxValue(index), step);
|
|
198
|
+
const nextValues = [...currentValues];
|
|
199
|
+
nextValues[index] = snapped;
|
|
200
|
+
commitValues(nextValues, complete);
|
|
201
|
+
},
|
|
202
|
+
[commitValues, currentValues, getThumbMaxValue, getThumbMinValue, isDisabled, step],
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
const setThumbValueFromRatio = useCallback(
|
|
206
|
+
(index: number, ratio: number, complete = false) => {
|
|
80
207
|
const next = min + clamp(ratio, 0, 1) * (max - min);
|
|
81
|
-
|
|
208
|
+
setThumbValue(index, next, complete);
|
|
209
|
+
},
|
|
210
|
+
[max, min, setThumbValue],
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
const setNearestThumbValueFromRatio = useCallback(
|
|
214
|
+
(ratio: number, complete = false) => {
|
|
215
|
+
const target = min + clamp(ratio, 0, 1) * (max - min);
|
|
216
|
+
const index = getClosestValueIndex(currentValues, target);
|
|
217
|
+
setThumbValue(index, target, complete);
|
|
82
218
|
},
|
|
83
|
-
[max, min,
|
|
219
|
+
[currentValues, max, min, setThumbValue],
|
|
84
220
|
);
|
|
85
221
|
|
|
86
222
|
const setTrackLayout = useCallback((layout: SliderTrackLayout) => {
|
|
@@ -102,96 +238,112 @@ export const SliderRoot = forwardRef<View, SliderRootProps>(
|
|
|
102
238
|
setThumbSizeState((prev) => (prev === size ? prev : size));
|
|
103
239
|
}, []);
|
|
104
240
|
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
now: currentValue,
|
|
110
|
-
text: formatSliderValue(currentValue),
|
|
111
|
-
};
|
|
241
|
+
const getThumbValueLabel = useCallback(
|
|
242
|
+
(index: number) => formatSliderValue(currentValues[index] ?? min),
|
|
243
|
+
[currentValues, min],
|
|
244
|
+
);
|
|
112
245
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
246
|
+
const isThumbDragging = useCallback(
|
|
247
|
+
(index: number) => draggingIndex === index,
|
|
248
|
+
[draggingIndex],
|
|
249
|
+
);
|
|
116
250
|
|
|
117
|
-
|
|
118
|
-
|
|
251
|
+
const setValue = useCallback(
|
|
252
|
+
(next: number, complete = false) => setThumbValue(0, next, complete),
|
|
253
|
+
[setThumbValue],
|
|
254
|
+
);
|
|
119
255
|
|
|
120
|
-
const
|
|
256
|
+
const setValueFromRatio = useCallback(
|
|
257
|
+
(ratio: number, complete = false) => setNearestThumbValueFromRatio(ratio, complete),
|
|
258
|
+
[setNearestThumbValueFromRatio],
|
|
259
|
+
);
|
|
121
260
|
|
|
122
|
-
const
|
|
123
|
-
(
|
|
124
|
-
|
|
125
|
-
return;
|
|
126
|
-
}
|
|
127
|
-
const key = event.nativeEvent.key;
|
|
128
|
-
if (!key || !STEP_KEYS.has(key)) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
if (Platform.OS === 'web') {
|
|
132
|
-
(event as unknown as { preventDefault: () => void }).preventDefault();
|
|
133
|
-
}
|
|
261
|
+
const setIsDragging = useCallback((dragging: boolean) => {
|
|
262
|
+
setDraggingIndex(dragging ? 0 : null);
|
|
263
|
+
}, []);
|
|
134
264
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
} else if (key === 'ArrowDown' || key === 'ArrowLeft') {
|
|
139
|
-
next = currentValue - step;
|
|
140
|
-
} else if (key === 'Home') {
|
|
141
|
-
next = min;
|
|
142
|
-
} else if (key === 'End') {
|
|
143
|
-
next = max;
|
|
144
|
-
}
|
|
265
|
+
const setIsHovered = useCallback((hovered: boolean) => {
|
|
266
|
+
setHoveredIndex(hovered ? 0 : null);
|
|
267
|
+
}, []);
|
|
145
268
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
);
|
|
269
|
+
const setIsFocused = useCallback((focused: boolean) => {
|
|
270
|
+
setFocusedIndex(focused ? 0 : null);
|
|
271
|
+
}, []);
|
|
150
272
|
|
|
151
273
|
const contextValue = useMemo(
|
|
152
274
|
() => ({
|
|
153
|
-
|
|
275
|
+
values: currentValues,
|
|
154
276
|
min,
|
|
155
277
|
max,
|
|
156
278
|
step,
|
|
157
|
-
percent,
|
|
158
279
|
orientation,
|
|
159
280
|
isDisabled,
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
281
|
+
draggingIndex,
|
|
282
|
+
hoveredIndex,
|
|
283
|
+
focusedIndex,
|
|
163
284
|
trackLayout,
|
|
164
285
|
thumbSize,
|
|
165
|
-
|
|
166
|
-
|
|
286
|
+
thumbCount,
|
|
287
|
+
groupAccessibilityLabel: accessibilityLabel,
|
|
288
|
+
accessibilityValueProp,
|
|
289
|
+
getThumbPercent,
|
|
290
|
+
getThumbMinValue,
|
|
291
|
+
getThumbMaxValue,
|
|
292
|
+
setThumbValue,
|
|
293
|
+
setThumbValueFromRatio,
|
|
294
|
+
setNearestThumbValueFromRatio,
|
|
167
295
|
setTrackLayout,
|
|
168
296
|
setThumbSize,
|
|
297
|
+
setDraggingIndex,
|
|
298
|
+
setHoveredIndex,
|
|
299
|
+
setFocusedIndex,
|
|
300
|
+
getThumbValueLabel,
|
|
301
|
+
registerThumb,
|
|
302
|
+
isThumbDragging,
|
|
303
|
+
value: currentValues[0] ?? min,
|
|
304
|
+
percent: getThumbPercent(0),
|
|
305
|
+
isDragging: draggingIndex !== null,
|
|
306
|
+
isHovered: hoveredIndex !== null,
|
|
307
|
+
isFocused: focusedIndex !== null,
|
|
308
|
+
getValueLabel: () => getThumbValueLabel(0),
|
|
309
|
+
setValue,
|
|
310
|
+
setValueFromRatio,
|
|
311
|
+
thumbRef: deprecatedThumbRef,
|
|
169
312
|
setIsDragging,
|
|
170
313
|
setIsHovered,
|
|
171
|
-
setIsFocused
|
|
172
|
-
getValueLabel,
|
|
173
|
-
thumbRef,
|
|
314
|
+
setIsFocused,
|
|
174
315
|
}),
|
|
175
316
|
[
|
|
176
|
-
|
|
177
|
-
|
|
317
|
+
accessibilityLabel,
|
|
318
|
+
accessibilityValueProp,
|
|
319
|
+
currentValues,
|
|
320
|
+
draggingIndex,
|
|
321
|
+
focusedIndex,
|
|
322
|
+
getThumbMaxValue,
|
|
323
|
+
getThumbMinValue,
|
|
324
|
+
getThumbPercent,
|
|
325
|
+
getThumbValueLabel,
|
|
326
|
+
hoveredIndex,
|
|
178
327
|
isDisabled,
|
|
179
|
-
|
|
180
|
-
isFocused,
|
|
181
|
-
isFocusedState,
|
|
182
|
-
isHovered,
|
|
328
|
+
isThumbDragging,
|
|
183
329
|
max,
|
|
184
330
|
min,
|
|
185
331
|
orientation,
|
|
186
|
-
|
|
187
|
-
|
|
332
|
+
registerThumb,
|
|
333
|
+
setIsDragging,
|
|
334
|
+
setIsFocused,
|
|
335
|
+
setIsHovered,
|
|
336
|
+
setNearestThumbValueFromRatio,
|
|
188
337
|
setThumbSize,
|
|
338
|
+
setThumbValue,
|
|
339
|
+
setThumbValueFromRatio,
|
|
340
|
+
setTrackLayout,
|
|
189
341
|
setValue,
|
|
190
342
|
setValueFromRatio,
|
|
191
343
|
step,
|
|
344
|
+
thumbCount,
|
|
192
345
|
thumbSize,
|
|
193
346
|
trackLayout,
|
|
194
|
-
thumbRef,
|
|
195
347
|
],
|
|
196
348
|
);
|
|
197
349
|
|
|
@@ -199,10 +351,10 @@ export const SliderRoot = forwardRef<View, SliderRootProps>(
|
|
|
199
351
|
slot: 'slider',
|
|
200
352
|
orientation,
|
|
201
353
|
disabled: isDisabled,
|
|
202
|
-
dragging:
|
|
203
|
-
hover:
|
|
204
|
-
focus:
|
|
205
|
-
|
|
354
|
+
dragging: draggingIndex !== null,
|
|
355
|
+
hover: hoveredIndex !== null,
|
|
356
|
+
focus: focusedIndex !== null,
|
|
357
|
+
values: currentValues.join(','),
|
|
206
358
|
min: String(min),
|
|
207
359
|
max: String(max),
|
|
208
360
|
});
|
|
@@ -211,49 +363,16 @@ export const SliderRoot = forwardRef<View, SliderRootProps>(
|
|
|
211
363
|
|
|
212
364
|
const handleLayout = composeEventHandlers(onLayout, () => undefined);
|
|
213
365
|
|
|
214
|
-
const webKeyProps =
|
|
215
|
-
Platform.OS === 'web'
|
|
216
|
-
? {
|
|
217
|
-
tabIndex: isDisabled ? -1 : 0,
|
|
218
|
-
onKeyDown: composeEventHandlers(
|
|
219
|
-
(props as ViewProps & { onKeyDown?: (event: unknown) => void }).onKeyDown,
|
|
220
|
-
handleKeyDown as never,
|
|
221
|
-
),
|
|
222
|
-
}
|
|
223
|
-
: {};
|
|
224
|
-
|
|
225
366
|
return (
|
|
226
367
|
<SliderProvider value={contextValue}>
|
|
227
368
|
<Comp
|
|
228
369
|
ref={ref}
|
|
229
370
|
{...(props as ViewProps)}
|
|
230
|
-
{...focusProps}
|
|
231
|
-
{...webKeyProps}
|
|
232
371
|
onLayout={handleLayout}
|
|
233
|
-
onFocus={composeEventHandlers(
|
|
234
|
-
composeEventHandlers(
|
|
235
|
-
props.onFocus as (...args: unknown[]) => unknown,
|
|
236
|
-
focusProps.onFocus,
|
|
237
|
-
),
|
|
238
|
-
() => setIsFocusedState(true),
|
|
239
|
-
)}
|
|
240
|
-
onBlur={composeEventHandlers(
|
|
241
|
-
composeEventHandlers(
|
|
242
|
-
props.onBlur as (...args: unknown[]) => unknown,
|
|
243
|
-
focusProps.onBlur,
|
|
244
|
-
),
|
|
245
|
-
() => setIsFocusedState(false),
|
|
246
|
-
)}
|
|
247
|
-
accessibilityRole={accessibilityRole}
|
|
248
372
|
accessibilityLabel={accessibilityLabel}
|
|
249
|
-
accessibilityValue={accessibilityValue}
|
|
250
373
|
accessibilityState={{ disabled: isDisabled }}
|
|
251
|
-
aria-valuemin={min}
|
|
252
|
-
aria-valuemax={max}
|
|
253
|
-
aria-valuenow={currentValue}
|
|
254
|
-
aria-orientation={orientation}
|
|
255
374
|
aria-disabled={isDisabled}
|
|
256
|
-
role={
|
|
375
|
+
role={Platform.OS === 'web' ? 'group' : undefined}
|
|
257
376
|
{...dataAttrs}
|
|
258
377
|
>
|
|
259
378
|
{children}
|