panelui-native 0.63.0 → 0.65.0
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/README.md +5 -0
- package/lib/module/components/badge/index.js +1 -1
- package/lib/module/components/badge/index.js.map +1 -1
- package/lib/module/components/bar-chart/index.js +39 -2
- package/lib/module/components/bar-chart/index.js.map +1 -1
- package/lib/module/components/bottom-sheet/index.js +2 -2
- package/lib/module/components/bottom-sheet/index.js.map +1 -1
- package/lib/module/components/button/index.js +19 -9
- package/lib/module/components/button/index.js.map +1 -1
- package/lib/module/components/carousel/index.js +28 -14
- package/lib/module/components/carousel/index.js.map +1 -1
- package/lib/module/components/checkbox/index.js +2 -3
- package/lib/module/components/checkbox/index.js.map +1 -1
- package/lib/module/components/dialog/index.js +2 -2
- package/lib/module/components/dialog/index.js.map +1 -1
- package/lib/module/components/drawer/index.js +2 -2
- package/lib/module/components/drawer/index.js.map +1 -1
- package/lib/module/components/fab/index.js +4 -3
- package/lib/module/components/fab/index.js.map +1 -1
- package/lib/module/components/field/index.js +41 -6
- package/lib/module/components/field/index.js.map +1 -1
- package/lib/module/components/flow/flow-accessibility.js +84 -0
- package/lib/module/components/flow/flow-accessibility.js.map +1 -0
- package/lib/module/components/flow/index.js +100 -39
- package/lib/module/components/flow/index.js.map +1 -1
- package/lib/module/components/form/use-form.js +93 -66
- package/lib/module/components/form/use-form.js.map +1 -1
- package/lib/module/components/heatmap-chart/index.js +2 -2
- package/lib/module/components/heatmap-chart/index.js.map +1 -1
- package/lib/module/components/hex-chart/index.js +2 -2
- package/lib/module/components/hex-chart/index.js.map +1 -1
- package/lib/module/components/kpi/index.js +3 -1
- package/lib/module/components/kpi/index.js.map +1 -1
- package/lib/module/components/line-chart/index.js +3 -3
- package/lib/module/components/line-chart/index.js.map +1 -1
- package/lib/module/components/map/index.js +71 -8
- package/lib/module/components/map/index.js.map +1 -1
- package/lib/module/components/map/map-accessibility.js +20 -0
- package/lib/module/components/map/map-accessibility.js.map +1 -0
- package/lib/module/components/map/maplibre.js.map +1 -1
- package/lib/module/components/menu/index.js +4 -1
- package/lib/module/components/menu/index.js.map +1 -1
- package/lib/module/components/number-input/index.js +1 -23
- package/lib/module/components/number-input/index.js.map +1 -1
- package/lib/module/components/number-input/number-input-math.js +44 -0
- package/lib/module/components/number-input/number-input-math.js.map +1 -0
- package/lib/module/components/plot/index.js +2 -2
- package/lib/module/components/plot/index.js.map +1 -1
- package/lib/module/components/radio-group/index.js +1 -2
- package/lib/module/components/radio-group/index.js.map +1 -1
- package/lib/module/components/sortable/index.js +5 -55
- package/lib/module/components/sortable/index.js.map +1 -1
- package/lib/module/components/sortable/reorder.js +63 -0
- package/lib/module/components/sortable/reorder.js.map +1 -0
- package/lib/module/components/swipe/index.js +4 -4
- package/lib/module/components/swipe/index.js.map +1 -1
- package/lib/module/components/switch/index.js +36 -3
- package/lib/module/components/switch/index.js.map +1 -1
- package/lib/module/components/time-picker/accessibility.js +21 -0
- package/lib/module/components/time-picker/accessibility.js.map +1 -0
- package/lib/module/components/time-picker/index.js +34 -8
- package/lib/module/components/time-picker/index.js.map +1 -1
- package/lib/module/components/waterfall-chart/index.js +1325 -0
- package/lib/module/components/waterfall-chart/index.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/primitives/modal-isolation-store.js +29 -0
- package/lib/module/primitives/modal-isolation-store.js.map +1 -0
- package/lib/module/primitives/portal.js +36 -4
- package/lib/module/primitives/portal.js.map +1 -1
- package/lib/module/providers/panel-ui-provider.js +27 -6
- package/lib/module/providers/panel-ui-provider.js.map +1 -1
- package/lib/typescript/src/components/badge/index.d.ts.map +1 -1
- package/lib/typescript/src/components/bar-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/button/index.d.ts.map +1 -1
- package/lib/typescript/src/components/carousel/index.d.ts +1 -1
- package/lib/typescript/src/components/carousel/index.d.ts.map +1 -1
- package/lib/typescript/src/components/checkbox/index.d.ts.map +1 -1
- package/lib/typescript/src/components/fab/index.d.ts.map +1 -1
- package/lib/typescript/src/components/field/index.d.ts +8 -1
- package/lib/typescript/src/components/field/index.d.ts.map +1 -1
- package/lib/typescript/src/components/flow/flow-accessibility.d.ts +49 -0
- package/lib/typescript/src/components/flow/flow-accessibility.d.ts.map +1 -0
- package/lib/typescript/src/components/flow/index.d.ts +14 -2
- package/lib/typescript/src/components/flow/index.d.ts.map +1 -1
- package/lib/typescript/src/components/form/use-form.d.ts.map +1 -1
- package/lib/typescript/src/components/heatmap-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/hex-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/kpi/index.d.ts.map +1 -1
- package/lib/typescript/src/components/line-chart/index.d.ts.map +1 -1
- package/lib/typescript/src/components/map/index.d.ts +13 -5
- package/lib/typescript/src/components/map/index.d.ts.map +1 -1
- package/lib/typescript/src/components/map/map-accessibility.d.ts +19 -0
- package/lib/typescript/src/components/map/map-accessibility.d.ts.map +1 -0
- package/lib/typescript/src/components/map/maplibre.d.ts +2 -0
- package/lib/typescript/src/components/map/maplibre.d.ts.map +1 -1
- package/lib/typescript/src/components/menu/index.d.ts.map +1 -1
- package/lib/typescript/src/components/number-input/index.d.ts.map +1 -1
- package/lib/typescript/src/components/number-input/number-input-math.d.ts +9 -0
- package/lib/typescript/src/components/number-input/number-input-math.d.ts.map +1 -0
- package/lib/typescript/src/components/plot/index.d.ts.map +1 -1
- package/lib/typescript/src/components/radio-group/index.d.ts.map +1 -1
- package/lib/typescript/src/components/sortable/index.d.ts.map +1 -1
- package/lib/typescript/src/components/sortable/reorder.d.ts +14 -0
- package/lib/typescript/src/components/sortable/reorder.d.ts.map +1 -0
- package/lib/typescript/src/components/swipe/index.d.ts.map +1 -1
- package/lib/typescript/src/components/switch/index.d.ts +3 -3
- package/lib/typescript/src/components/switch/index.d.ts.map +1 -1
- package/lib/typescript/src/components/time-picker/accessibility.d.ts +10 -0
- package/lib/typescript/src/components/time-picker/accessibility.d.ts.map +1 -0
- package/lib/typescript/src/components/time-picker/index.d.ts.map +1 -1
- package/lib/typescript/src/components/waterfall-chart/index.d.ts +379 -0
- package/lib/typescript/src/components/waterfall-chart/index.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/primitives/modal-isolation-store.d.ts +10 -0
- package/lib/typescript/src/primitives/modal-isolation-store.d.ts.map +1 -0
- package/lib/typescript/src/primitives/portal.d.ts +6 -0
- package/lib/typescript/src/primitives/portal.d.ts.map +1 -1
- package/lib/typescript/src/providers/panel-ui-provider.d.ts.map +1 -1
- package/package.json +5 -2
- package/src/components/badge/index.tsx +4 -1
- package/src/components/bar-chart/index.tsx +40 -3
- package/src/components/bottom-sheet/index.tsx +3 -3
- package/src/components/button/index.tsx +15 -21
- package/src/components/carousel/index.tsx +42 -20
- package/src/components/checkbox/index.tsx +1 -2
- package/src/components/dialog/index.tsx +3 -3
- package/src/components/drawer/index.tsx +3 -3
- package/src/components/fab/index.tsx +8 -12
- package/src/components/field/index.tsx +52 -10
- package/src/components/flow/flow-accessibility.ts +109 -0
- package/src/components/flow/index.tsx +162 -50
- package/src/components/form/use-form.ts +101 -65
- package/src/components/heatmap-chart/index.tsx +2 -3
- package/src/components/hex-chart/index.tsx +2 -3
- package/src/components/kpi/index.tsx +3 -1
- package/src/components/line-chart/index.tsx +3 -2
- package/src/components/map/index.tsx +110 -7
- package/src/components/map/map-accessibility.ts +41 -0
- package/src/components/map/maplibre.ts +2 -0
- package/src/components/menu/index.tsx +4 -1
- package/src/components/number-input/index.tsx +1 -26
- package/src/components/number-input/number-input-math.ts +50 -0
- package/src/components/plot/index.tsx +2 -1
- package/src/components/radio-group/index.tsx +1 -2
- package/src/components/sortable/index.tsx +12 -64
- package/src/components/sortable/reorder.ts +88 -0
- package/src/components/swipe/index.tsx +7 -4
- package/src/components/switch/index.tsx +42 -6
- package/src/components/time-picker/accessibility.ts +24 -0
- package/src/components/time-picker/index.tsx +48 -2
- package/src/components/waterfall-chart/index.tsx +1589 -0
- package/src/index.ts +23 -0
- package/src/primitives/modal-isolation-store.ts +31 -0
- package/src/primitives/portal.tsx +34 -4
- package/src/providers/panel-ui-provider.tsx +41 -9
- package/theme.css +30 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
type PinnedItems = Readonly<Record<string, boolean>>;
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Move one item, then restore pinned items to the slots in `laid`.
|
|
5
|
+
*
|
|
6
|
+
* Restoring after the move lets an item cross a pin instead of turning that
|
|
7
|
+
* slot into a wall. The laid-out order is the source of truth because it is
|
|
8
|
+
* the last arrangement the caller rendered and therefore the one whose pins
|
|
9
|
+
* are known to be in their promised positions.
|
|
10
|
+
*/
|
|
11
|
+
export function moveWithPinned(
|
|
12
|
+
list: readonly string[],
|
|
13
|
+
laid: readonly string[],
|
|
14
|
+
pinned: PinnedItems,
|
|
15
|
+
id: string,
|
|
16
|
+
from: number,
|
|
17
|
+
to: number
|
|
18
|
+
): string[] {
|
|
19
|
+
'worklet';
|
|
20
|
+
if (
|
|
21
|
+
from === to ||
|
|
22
|
+
from < 0 ||
|
|
23
|
+
from >= list.length ||
|
|
24
|
+
to < 0 ||
|
|
25
|
+
to >= list.length ||
|
|
26
|
+
list[from] !== id ||
|
|
27
|
+
pinned[id]
|
|
28
|
+
) {
|
|
29
|
+
return [...list];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const moved = [...list];
|
|
33
|
+
moved.splice(from, 1);
|
|
34
|
+
moved.splice(to, 0, id);
|
|
35
|
+
|
|
36
|
+
const next: (string | undefined)[] = [];
|
|
37
|
+
let anyPinned = false;
|
|
38
|
+
for (let i = 0; i < moved.length; i += 1) next.push(undefined);
|
|
39
|
+
for (let i = 0; i < laid.length && i < next.length; i += 1) {
|
|
40
|
+
const at = laid[i];
|
|
41
|
+
if (at !== undefined && pinned[at]) {
|
|
42
|
+
next[i] = at;
|
|
43
|
+
anyPinned = true;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (!anyPinned) return moved;
|
|
47
|
+
|
|
48
|
+
const free: string[] = [];
|
|
49
|
+
for (let i = 0; i < moved.length; i += 1) {
|
|
50
|
+
const at = moved[i];
|
|
51
|
+
if (at !== undefined && !pinned[at]) free.push(at);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const result: string[] = [];
|
|
55
|
+
let freeIndex = 0;
|
|
56
|
+
for (let i = 0; i < next.length; i += 1) {
|
|
57
|
+
const held = next[i];
|
|
58
|
+
if (held !== undefined) {
|
|
59
|
+
result.push(held);
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const take = free[freeIndex];
|
|
63
|
+
freeIndex += 1;
|
|
64
|
+
if (take !== undefined) result.push(take);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Move by one available slot, stepping past pinned slots that would be a no-op. */
|
|
70
|
+
export function stepWithPinned(
|
|
71
|
+
list: readonly string[],
|
|
72
|
+
laid: readonly string[],
|
|
73
|
+
pinned: PinnedItems,
|
|
74
|
+
id: string,
|
|
75
|
+
from: number,
|
|
76
|
+
delta: number
|
|
77
|
+
): string[] {
|
|
78
|
+
'worklet';
|
|
79
|
+
const direction = Math.sign(delta);
|
|
80
|
+
if (direction === 0) return [...list];
|
|
81
|
+
|
|
82
|
+
for (let to = from + direction; to >= 0 && to < list.length; to += direction) {
|
|
83
|
+
const next = moveWithPinned(list, laid, pinned, id, from, to);
|
|
84
|
+
if (next.indexOf(id) !== from) return next;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return [...list];
|
|
88
|
+
}
|
|
@@ -258,10 +258,13 @@ const actionVariants = tv({
|
|
|
258
258
|
color: {
|
|
259
259
|
default: { root: 'bg-muted-foreground', label: 'text-background' },
|
|
260
260
|
primary: { root: 'bg-primary', label: 'text-primary-foreground' },
|
|
261
|
-
success: { root: 'bg-success', label: 'text-
|
|
262
|
-
warning: { root: 'bg-warning', label: 'text-
|
|
263
|
-
info: { root: 'bg-info', label: 'text-
|
|
264
|
-
destructive: {
|
|
261
|
+
success: { root: 'bg-success', label: 'text-success-solid-foreground' },
|
|
262
|
+
warning: { root: 'bg-warning', label: 'text-warning-solid-foreground' },
|
|
263
|
+
info: { root: 'bg-info', label: 'text-info-solid-foreground' },
|
|
264
|
+
destructive: {
|
|
265
|
+
root: 'bg-destructive',
|
|
266
|
+
label: 'text-destructive-solid-foreground',
|
|
267
|
+
},
|
|
265
268
|
},
|
|
266
269
|
},
|
|
267
270
|
defaultVariants: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { forwardRef, useEffect } from 'react';
|
|
2
|
-
import { Pressable, View } from 'react-native';
|
|
2
|
+
import { Pressable, View, type PressableProps } from 'react-native';
|
|
3
3
|
import Animated, {
|
|
4
4
|
interpolate,
|
|
5
5
|
useAnimatedStyle,
|
|
@@ -10,6 +10,7 @@ import { tv, type VariantProps } from 'tailwind-variants';
|
|
|
10
10
|
import { useDirectionSign } from '../../hooks/use-direction';
|
|
11
11
|
import { getNativeUI } from '../../native';
|
|
12
12
|
import { selectionTick } from '../../utils/haptics';
|
|
13
|
+
import { useFieldLabelledBy } from '../field';
|
|
13
14
|
|
|
14
15
|
const SPRING = { damping: 18, stiffness: 250, mass: 0.5 } as const;
|
|
15
16
|
|
|
@@ -35,7 +36,22 @@ const switchVariants = tv({
|
|
|
35
36
|
|
|
36
37
|
const TRAVEL: Record<'sm' | 'md', number> = { sm: 16, md: 20 };
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Room around each track so the target reaches 48dp on both axes.
|
|
41
|
+
*
|
|
42
|
+
* Slop rather than a bigger box, because a box is layout: a switch sized to
|
|
43
|
+
* its target would stand 48dp tall in every row it has ever been placed in,
|
|
44
|
+
* and the tracks are only 24 and 28 tall. The `md` track is already 48 wide,
|
|
45
|
+
* which is why the horizontal figures differ between the two sizes.
|
|
46
|
+
*/
|
|
47
|
+
const SWITCH_HIT_SLOP: Record<'sm' | 'md', { top: number; bottom: number; left: number; right: number }> = {
|
|
48
|
+
sm: { top: 12, bottom: 12, left: 4, right: 4 },
|
|
49
|
+
md: { top: 10, bottom: 10, left: 0, right: 0 },
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export interface SwitchProps
|
|
53
|
+
extends VariantProps<typeof switchVariants>,
|
|
54
|
+
Pick<PressableProps, 'accessibilityLabel' | 'accessibilityHint' | 'accessibilityLabelledBy'> {
|
|
39
55
|
className?: string;
|
|
40
56
|
value: boolean;
|
|
41
57
|
onValueChange?: (value: boolean) => void;
|
|
@@ -48,7 +64,7 @@ export interface SwitchProps extends VariantProps<typeof switchVariants> {
|
|
|
48
64
|
* `className` and `size` are ignored.
|
|
49
65
|
*/
|
|
50
66
|
native?: boolean;
|
|
51
|
-
/**
|
|
67
|
+
/** Names the control to assistive technology; native mode also draws it. */
|
|
52
68
|
label?: string;
|
|
53
69
|
/**
|
|
54
70
|
* Tick the haptic engine each time the switch is flipped — a toggle you feel
|
|
@@ -65,7 +81,19 @@ export interface SwitchProps extends VariantProps<typeof switchVariants> {
|
|
|
65
81
|
*/
|
|
66
82
|
export const Switch = forwardRef<View, SwitchProps>(
|
|
67
83
|
(
|
|
68
|
-
{
|
|
84
|
+
{
|
|
85
|
+
className,
|
|
86
|
+
value,
|
|
87
|
+
onValueChange,
|
|
88
|
+
disabled,
|
|
89
|
+
size = 'md',
|
|
90
|
+
native,
|
|
91
|
+
label,
|
|
92
|
+
haptics,
|
|
93
|
+
accessibilityLabel,
|
|
94
|
+
accessibilityHint,
|
|
95
|
+
accessibilityLabelledBy,
|
|
96
|
+
},
|
|
69
97
|
ref
|
|
70
98
|
) => {
|
|
71
99
|
const progress = useSharedValue(value ? 1 : 0);
|
|
@@ -75,6 +103,9 @@ export const Switch = forwardRef<View, SwitchProps>(
|
|
|
75
103
|
const sign = useDirectionSign();
|
|
76
104
|
const nativeUI = native ? getNativeUI() : null;
|
|
77
105
|
const slots = switchVariants({ size, disabled: !!disabled });
|
|
106
|
+
// React Native's labelled-by relationship is Android-only. `label` or an
|
|
107
|
+
// explicit accessibilityLabel remains the portable name on iOS.
|
|
108
|
+
const fieldLabelledBy = useFieldLabelledBy();
|
|
78
109
|
|
|
79
110
|
useEffect(() => {
|
|
80
111
|
progress.value = withSpring(value ? 1 : 0, SPRING);
|
|
@@ -101,7 +132,7 @@ export const Switch = forwardRef<View, SwitchProps>(
|
|
|
101
132
|
<NativeSwitch
|
|
102
133
|
value={value}
|
|
103
134
|
onValueChange={(next: boolean) => onValueChange?.(next)}
|
|
104
|
-
label={label}
|
|
135
|
+
label={label ?? accessibilityLabel}
|
|
105
136
|
disabled={disabled}
|
|
106
137
|
/>
|
|
107
138
|
</Host>
|
|
@@ -113,12 +144,17 @@ export const Switch = forwardRef<View, SwitchProps>(
|
|
|
113
144
|
ref={ref}
|
|
114
145
|
accessibilityRole="switch"
|
|
115
146
|
accessibilityState={{ checked: value, disabled: !!disabled }}
|
|
147
|
+
accessibilityLabel={accessibilityLabel ?? label}
|
|
148
|
+
accessibilityHint={accessibilityHint}
|
|
149
|
+
accessibilityLabelledBy={
|
|
150
|
+
accessibilityLabelledBy ?? (accessibilityLabel || label ? undefined : fieldLabelledBy)
|
|
151
|
+
}
|
|
116
152
|
disabled={disabled}
|
|
117
153
|
onPress={() => {
|
|
118
154
|
if (haptics) selectionTick();
|
|
119
155
|
onValueChange?.(!value);
|
|
120
156
|
}}
|
|
121
|
-
hitSlop={
|
|
157
|
+
hitSlop={SWITCH_HIT_SLOP[size]}
|
|
122
158
|
>
|
|
123
159
|
<View className={slots.track({ className })}>
|
|
124
160
|
<Animated.View style={activeTrackStyle} className={slots.activeTrack()} />
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** Resolve a standard adjustable action without wrapping past either bound. */
|
|
2
|
+
export function indexForAccessibilityAction(
|
|
3
|
+
index: number,
|
|
4
|
+
length: number,
|
|
5
|
+
actionName: string,
|
|
6
|
+
disabled = false
|
|
7
|
+
): number | undefined {
|
|
8
|
+
const direction = actionName === 'increment' ? 1 : actionName === 'decrement' ? -1 : 0;
|
|
9
|
+
if (disabled || direction === 0 || length <= 0) return undefined;
|
|
10
|
+
|
|
11
|
+
const next = Math.min(Math.max(index + direction, 0), length - 1);
|
|
12
|
+
return next === index ? undefined : next;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Keep the numeric adjustable range aligned with the values the face offers. */
|
|
16
|
+
export function accessibilityValueForIndex(index: number, length: number, text: string) {
|
|
17
|
+
const max = Math.max(0, length - 1);
|
|
18
|
+
return {
|
|
19
|
+
min: 0,
|
|
20
|
+
max,
|
|
21
|
+
now: Math.min(Math.max(index, 0), max),
|
|
22
|
+
text,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -55,6 +55,7 @@ import {
|
|
|
55
55
|
import {
|
|
56
56
|
ScrollView,
|
|
57
57
|
View,
|
|
58
|
+
type AccessibilityActionEvent,
|
|
58
59
|
type NativeScrollEvent,
|
|
59
60
|
type NativeSyntheticEvent,
|
|
60
61
|
} from 'react-native';
|
|
@@ -74,6 +75,10 @@ import { ClockIcon } from '../../icons';
|
|
|
74
75
|
import { Text } from '../../primitives/text';
|
|
75
76
|
import { cn } from '../../utils/cn';
|
|
76
77
|
import { selectionTick } from '../../utils/haptics';
|
|
78
|
+
import {
|
|
79
|
+
accessibilityValueForIndex,
|
|
80
|
+
indexForAccessibilityAction,
|
|
81
|
+
} from './accessibility';
|
|
77
82
|
import {
|
|
78
83
|
clampTime,
|
|
79
84
|
displayHour,
|
|
@@ -398,6 +403,20 @@ function Column<T>({
|
|
|
398
403
|
|
|
399
404
|
const selectedItem = items[index];
|
|
400
405
|
|
|
406
|
+
const onAccessibilityAction = useCallback(
|
|
407
|
+
(event: AccessibilityActionEvent) => {
|
|
408
|
+
const next = indexForAccessibilityAction(
|
|
409
|
+
index,
|
|
410
|
+
items.length,
|
|
411
|
+
event.nativeEvent.actionName,
|
|
412
|
+
disabled
|
|
413
|
+
);
|
|
414
|
+
if (next === undefined) return;
|
|
415
|
+
onIndexChange(next);
|
|
416
|
+
},
|
|
417
|
+
[disabled, index, items.length, onIndexChange]
|
|
418
|
+
);
|
|
419
|
+
|
|
401
420
|
return (
|
|
402
421
|
<Animated.ScrollView
|
|
403
422
|
ref={ref}
|
|
@@ -426,7 +445,12 @@ function Column<T>({
|
|
|
426
445
|
removeClippedSubviews={false}
|
|
427
446
|
accessibilityRole="adjustable"
|
|
428
447
|
accessibilityLabel={accessibilityLabel}
|
|
429
|
-
|
|
448
|
+
accessibilityState={{ disabled }}
|
|
449
|
+
accessibilityValue={
|
|
450
|
+
selectedItem ? accessibilityValueForIndex(index, items.length, label(selectedItem)) : undefined
|
|
451
|
+
}
|
|
452
|
+
accessibilityActions={[{ name: 'increment' }, { name: 'decrement' }]}
|
|
453
|
+
onAccessibilityAction={onAccessibilityAction}
|
|
430
454
|
>
|
|
431
455
|
{items.map((item, i) => (
|
|
432
456
|
<ColumnRow key={i} offset={offset} index={i} selected={i === index}>
|
|
@@ -930,6 +954,21 @@ function RulerFace({
|
|
|
930
954
|
[width]
|
|
931
955
|
);
|
|
932
956
|
|
|
957
|
+
const onAccessibilityAction = useCallback(
|
|
958
|
+
(event: AccessibilityActionEvent) => {
|
|
959
|
+
const next = indexForAccessibilityAction(
|
|
960
|
+
index,
|
|
961
|
+
times.length,
|
|
962
|
+
event.nativeEvent.actionName,
|
|
963
|
+
disabled
|
|
964
|
+
);
|
|
965
|
+
if (next === undefined) return;
|
|
966
|
+
const time = times[next];
|
|
967
|
+
if (time) onValueChange(time);
|
|
968
|
+
},
|
|
969
|
+
[disabled, index, onValueChange, times]
|
|
970
|
+
);
|
|
971
|
+
|
|
933
972
|
return (
|
|
934
973
|
<View className={readout === 'none' ? undefined : 'gap-4'}>
|
|
935
974
|
{readout === 'none' ? null : (
|
|
@@ -955,7 +994,14 @@ function RulerFace({
|
|
|
955
994
|
onMomentumScrollEnd={onMomentumEnd}
|
|
956
995
|
accessibilityRole="adjustable"
|
|
957
996
|
accessibilityLabel="Time"
|
|
958
|
-
|
|
997
|
+
accessibilityState={{ disabled }}
|
|
998
|
+
accessibilityValue={accessibilityValueForIndex(
|
|
999
|
+
index,
|
|
1000
|
+
times.length,
|
|
1001
|
+
formatTime(value, { hourCycle, locale })
|
|
1002
|
+
)}
|
|
1003
|
+
accessibilityActions={[{ name: 'increment' }, { name: 'decrement' }]}
|
|
1004
|
+
onAccessibilityAction={onAccessibilityAction}
|
|
959
1005
|
>
|
|
960
1006
|
{/*
|
|
961
1007
|
No numbers under the ticks. The readout above already says the
|