@expressive-ui/native 0.0.0-stage → 0.1.1

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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +40 -2
  3. package/dist/Button.d.ts +48 -0
  4. package/dist/Button.d.ts.map +1 -0
  5. package/dist/Button.js +122 -0
  6. package/dist/Button.js.map +1 -0
  7. package/dist/Carousel.d.ts +13 -0
  8. package/dist/Carousel.d.ts.map +1 -0
  9. package/dist/Carousel.js +52 -0
  10. package/dist/Carousel.js.map +1 -0
  11. package/dist/Chips.d.ts +35 -0
  12. package/dist/Chips.d.ts.map +1 -0
  13. package/dist/Chips.js +138 -0
  14. package/dist/Chips.js.map +1 -0
  15. package/dist/Dialogs.d.ts +42 -0
  16. package/dist/Dialogs.d.ts.map +1 -0
  17. package/dist/Dialogs.js +115 -0
  18. package/dist/Dialogs.js.map +1 -0
  19. package/dist/ExpressiveCard.d.ts +20 -0
  20. package/dist/ExpressiveCard.d.ts.map +1 -0
  21. package/dist/ExpressiveCard.js +71 -0
  22. package/dist/ExpressiveCard.js.map +1 -0
  23. package/dist/Fab.d.ts +16 -0
  24. package/dist/Fab.d.ts.map +1 -0
  25. package/dist/Fab.js +104 -0
  26. package/dist/Fab.js.map +1 -0
  27. package/dist/Fields.d.ts +90 -0
  28. package/dist/Fields.d.ts.map +1 -0
  29. package/dist/Fields.js +211 -0
  30. package/dist/Fields.js.map +1 -0
  31. package/dist/Grid.d.ts +8 -0
  32. package/dist/Grid.d.ts.map +1 -0
  33. package/dist/Grid.js +16 -0
  34. package/dist/Grid.js.map +1 -0
  35. package/dist/Inputs.d.ts +33 -0
  36. package/dist/Inputs.d.ts.map +1 -0
  37. package/dist/Inputs.js +172 -0
  38. package/dist/Inputs.js.map +1 -0
  39. package/dist/List.d.ts +20 -0
  40. package/dist/List.d.ts.map +1 -0
  41. package/dist/List.js +222 -0
  42. package/dist/List.js.map +1 -0
  43. package/dist/Menu.d.ts +26 -0
  44. package/dist/Menu.d.ts.map +1 -0
  45. package/dist/Menu.js +117 -0
  46. package/dist/Menu.js.map +1 -0
  47. package/dist/Navigation.d.ts +34 -0
  48. package/dist/Navigation.d.ts.map +1 -0
  49. package/dist/Navigation.js +80 -0
  50. package/dist/Navigation.js.map +1 -0
  51. package/dist/Pickers.d.ts +16 -0
  52. package/dist/Pickers.d.ts.map +1 -0
  53. package/dist/Pickers.js +100 -0
  54. package/dist/Pickers.js.map +1 -0
  55. package/dist/Progress.d.ts +20 -0
  56. package/dist/Progress.d.ts.map +1 -0
  57. package/dist/Progress.js +93 -0
  58. package/dist/Progress.js.map +1 -0
  59. package/dist/Search.d.ts +50 -0
  60. package/dist/Search.d.ts.map +1 -0
  61. package/dist/Search.js +121 -0
  62. package/dist/Search.js.map +1 -0
  63. package/dist/Sheets.d.ts +44 -0
  64. package/dist/Sheets.d.ts.map +1 -0
  65. package/dist/Sheets.js +128 -0
  66. package/dist/Sheets.js.map +1 -0
  67. package/dist/Toolbar.d.ts +13 -0
  68. package/dist/Toolbar.d.ts.map +1 -0
  69. package/dist/Toolbar.js +38 -0
  70. package/dist/Toolbar.js.map +1 -0
  71. package/dist/Transition.d.ts +34 -0
  72. package/dist/Transition.d.ts.map +1 -0
  73. package/dist/Transition.js +93 -0
  74. package/dist/Transition.js.map +1 -0
  75. package/dist/index.d.ts +21 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +21 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/primitives.d.ts +41 -0
  80. package/dist/primitives.d.ts.map +1 -0
  81. package/dist/primitives.js +55 -0
  82. package/dist/primitives.js.map +1 -0
  83. package/dist/theme.d.ts +57 -0
  84. package/dist/theme.d.ts.map +1 -0
  85. package/dist/theme.js +89 -0
  86. package/dist/theme.js.map +1 -0
  87. package/package.json +53 -4
  88. package/src/Button.tsx +347 -0
  89. package/src/Carousel.tsx +108 -0
  90. package/src/Chips.tsx +292 -0
  91. package/src/Dialogs.tsx +252 -0
  92. package/src/ExpressiveCard.tsx +205 -0
  93. package/src/Fab.tsx +187 -0
  94. package/src/Fields.tsx +556 -0
  95. package/src/Grid.tsx +29 -0
  96. package/src/Inputs.tsx +290 -0
  97. package/src/List.tsx +295 -0
  98. package/src/Menu.tsx +238 -0
  99. package/src/Navigation.tsx +198 -0
  100. package/src/Pickers.tsx +151 -0
  101. package/src/Progress.tsx +192 -0
  102. package/src/Search.tsx +351 -0
  103. package/src/Sheets.tsx +273 -0
  104. package/src/Toolbar.tsx +88 -0
  105. package/src/Transition.tsx +155 -0
  106. package/src/index.ts +20 -0
  107. package/src/primitives.tsx +110 -0
  108. package/src/theme.tsx +125 -0
package/src/Menu.tsx ADDED
@@ -0,0 +1,238 @@
1
+ import { Fragment, useEffect, useRef, useState, type ReactNode } from 'react';
2
+ import { Animated, Modal, Pressable, ScrollView, StyleSheet, useWindowDimensions, View, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { isMenuSlot, placeMenu, resolveMenu, type MenuColor, type MenuEntry, type MenuGroup, type MenuItem, type MenuPlacement, type MenuSeparator } from '@expressive-ui/core';
4
+ import { tokens } from '@expressive-ui/tokens';
5
+ import { Icon, T, withAlpha } from './primitives.js';
6
+ import { useExpressiveTheme, usePresence } from './theme.js';
7
+
8
+ export type { MenuEntry, MenuGroup, MenuItem };
9
+
10
+ export type MenuTriggerProps = { open: boolean; toggle: () => void };
11
+
12
+ export type MenuProps = {
13
+ trigger: (props: MenuTriggerProps) => ReactNode;
14
+ groups?: readonly MenuGroup[];
15
+ items?: readonly MenuEntry[];
16
+ open?: boolean;
17
+ onOpenChange?: (open: boolean) => void;
18
+ onSelect?: (key: string, item: MenuItem) => void;
19
+ color?: MenuColor;
20
+ separator?: MenuSeparator;
21
+ maxHeight?: number;
22
+ placement?: Partial<MenuPlacement>;
23
+ matchTriggerWidth?: boolean;
24
+ closeOnSelect?: boolean;
25
+ style?: StyleProp<ViewStyle>;
26
+ };
27
+
28
+ type Frame = { x: number; y: number; width: number; height: number };
29
+
30
+ /** Menu ancorado ao gatilho; submenus trocam o nível (com voltar), o padrão em telas de toque. */
31
+ export function Menu({
32
+ trigger,
33
+ groups,
34
+ items,
35
+ open: controlled,
36
+ onOpenChange,
37
+ onSelect,
38
+ color = 'standard',
39
+ separator = 'gap',
40
+ maxHeight,
41
+ placement: forced,
42
+ matchTriggerWidth = false,
43
+ closeOnSelect = true,
44
+ style,
45
+ }: MenuProps) {
46
+ const { labels } = useExpressiveTheme();
47
+ const { colors, mode } = useExpressiveTheme();
48
+ const window = useWindowDimensions();
49
+ const spec = resolveMenu(color);
50
+ const [inner, setInner] = useState(false);
51
+ const open = controlled ?? inner;
52
+ const setOpen = (next: boolean) => {
53
+ if (controlled === undefined) setInner(next);
54
+ onOpenChange?.(next);
55
+ };
56
+ const anchor = useRef<View>(null);
57
+ const [frame, setFrame] = useState<Frame | null>(null);
58
+ const [size, setSize] = useState<{ width: number; height: number } | null>(null);
59
+ // Pilha de níveis: [raiz, submenu, sub-submenu…].
60
+ const [stack, setStack] = useState<{ title?: string; groups: readonly MenuGroup[] }[]>([]);
61
+ const { progress: reveal, opacity, mounted } = usePresence(open && !!size);
62
+ const root = groups ?? [{ items: items ?? [] }];
63
+
64
+ useEffect(() => {
65
+ if (!open) return;
66
+ setStack([{ groups: root }]);
67
+ anchor.current?.measureInWindow((x, y, width, height) => setFrame({ x, y, width, height }));
68
+ }, [open]);
69
+ useEffect(() => {
70
+ if (!open && !mounted) {
71
+ setFrame(null);
72
+ setSize(null);
73
+ }
74
+ }, [open, mounted]);
75
+
76
+ const level = stack[stack.length - 1];
77
+ const choose = (item: MenuItem) => {
78
+ if (item.submenu?.length) return setStack([...stack, { title: item.label, groups: item.submenu }]);
79
+ item.onSelect?.();
80
+ onSelect?.(item.key, item);
81
+ if (closeOnSelect) setOpen(false);
82
+ };
83
+
84
+ let position: ViewStyle = { opacity: 0, left: 0, top: 0 };
85
+ let vertical: MenuPlacement['vertical'] = 'bottom';
86
+ if (frame && size) {
87
+ const auto = placeMenu(frame, size, window);
88
+ vertical = forced?.vertical ?? auto.vertical;
89
+ const horizontal = forced?.horizontal ?? auto.horizontal;
90
+ position = {
91
+ top: vertical === 'bottom' ? frame.y + frame.height + 4 : frame.y - size.height - 4,
92
+ left: Math.max(8, Math.min(window.width - size.width - 8, horizontal === 'start' ? frame.x : frame.x + frame.width - size.width)),
93
+ };
94
+ }
95
+
96
+ const surface = { backgroundColor: colors[spec.container], boxShadow: tokens.elevation[mode][spec.elevation] };
97
+ const panel = level ? (
98
+ <Animated.View
99
+ onLayout={(e) => !size && setSize({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height })}
100
+ style={[
101
+ styles.panel,
102
+ { minWidth: Math.max(spec.minWidth, matchTriggerWidth && frame ? frame.width : 0), maxWidth: spec.maxWidth },
103
+ position,
104
+ size && {
105
+ opacity,
106
+ transform: [{ scaleY: reveal.interpolate({ inputRange: [0, 1], outputRange: [0.8, 1] }) }],
107
+ transformOrigin: vertical === 'bottom' ? 'top' : 'bottom',
108
+ },
109
+ separator === 'gap' ? { gap: spec.groupGap } : [surface, { borderRadius: spec.radius.outer, padding: spec.padding }],
110
+ style,
111
+ ]}
112
+ >
113
+ <ScrollView style={maxHeight ? { maxHeight } : undefined} scrollEnabled={Boolean(maxHeight)} contentContainerStyle={separator === 'gap' ? { gap: spec.groupGap } : undefined}>
114
+ {stack.length > 1 ? (
115
+ <View style={[separator === 'gap' && [surface, { borderRadius: spec.radius.outer, padding: spec.padding }]]}>
116
+ <Row spec={spec} item={{ key: '__back', label: level.title ?? '', icon: 'arrow_back' }} onPress={() => setStack(stack.slice(0, -1))} header />
117
+ </View>
118
+ ) : null}
119
+ {level.groups.map((group, g) => {
120
+ const first = g === 0 && stack.length === 1;
121
+ const last = g === level.groups.length - 1;
122
+ return (
123
+ <Fragment key={group.key ?? g}>
124
+ {separator === 'divider' && g > 0 ? <View style={[styles.divider, { backgroundColor: colors[spec.divider] }]} /> : null}
125
+ <View
126
+ accessibilityRole="menu"
127
+ style={
128
+ separator === 'gap'
129
+ ? [
130
+ surface,
131
+ {
132
+ padding: spec.padding,
133
+ borderTopLeftRadius: first ? spec.radius.outer : spec.radius.inner,
134
+ borderTopRightRadius: first ? spec.radius.outer : spec.radius.inner,
135
+ borderBottomLeftRadius: last ? spec.radius.outer : spec.radius.inner,
136
+ borderBottomRightRadius: last ? spec.radius.outer : spec.radius.inner,
137
+ },
138
+ ]
139
+ : undefined
140
+ }
141
+ >
142
+ {group.label ? (
143
+ <T variant="labelMedium" emphasized color={spec.supporting} style={styles.label}>
144
+ {group.label}
145
+ </T>
146
+ ) : null}
147
+ {group.items.map((entry) =>
148
+ isMenuSlot(entry) ? (
149
+ <View key={entry.key} style={styles.slot}>
150
+ {entry.slot}
151
+ </View>
152
+ ) : (
153
+ <Row key={entry.key} spec={spec} item={entry} onPress={() => choose(entry)} />
154
+ ),
155
+ )}
156
+ </View>
157
+ </Fragment>
158
+ );
159
+ })}
160
+ </ScrollView>
161
+ </Animated.View>
162
+ ) : null;
163
+
164
+ return (
165
+ <View ref={anchor} collapsable={false} style={styles.anchor}>
166
+ {trigger({ open, toggle: () => setOpen(!open) })}
167
+ {open || mounted ? (
168
+ <Modal visible transparent animationType="none" onRequestClose={() => (stack.length > 1 ? setStack(stack.slice(0, -1)) : setOpen(false))}>
169
+ <Pressable accessibilityRole="button" accessibilityLabel={labels.closeMenu} style={StyleSheet.absoluteFill} onPress={() => setOpen(false)} />
170
+ {panel}
171
+ </Modal>
172
+ ) : null}
173
+ </View>
174
+ );
175
+ }
176
+
177
+ function Row({ spec, item, onPress, header = false }: { spec: ReturnType<typeof resolveMenu>; item: MenuItem; onPress: () => void; header?: boolean }) {
178
+ const { colors } = useExpressiveTheme();
179
+ const selected = item.selected === true;
180
+ const fg = item.destructive ? 'error' : selected ? spec.selected.content : spec.content;
181
+ const muted = selected ? spec.selected.content : spec.supporting;
182
+ const hasSub = Boolean(item.submenu?.length);
183
+ return (
184
+ <Pressable
185
+ accessibilityRole="menuitem"
186
+ accessibilityLabel={header ? `Voltar: ${item.label}` : item.label}
187
+ accessibilityState={{ disabled: item.disabled, checked: item.selected, expanded: hasSub ? false : undefined }}
188
+ disabled={item.disabled}
189
+ onPress={onPress}
190
+ style={({ pressed }) => [
191
+ styles.item,
192
+ {
193
+ minHeight: item.supporting ? spec.itemHeightWithSupporting : spec.itemHeight,
194
+ borderRadius: pressed ? tokens.shape.large : spec.radius.item,
195
+ backgroundColor: selected ? colors[spec.selected.container] : pressed ? withAlpha(colors[spec.content], tokens.state.pressed) : 'transparent',
196
+ opacity: item.disabled ? tokens.state.disabledContent : 1,
197
+ },
198
+ ]}
199
+ >
200
+ {selected ? <Icon name="check" size={20} color={fg} /> : item.icon ? <Icon name={item.icon} size={20} color={item.destructive ? 'error' : selected ? fg : spec.icon} /> : null}
201
+ <View style={styles.text}>
202
+ <T variant="labelLarge" emphasized={header} color={fg} numberOfLines={1}>
203
+ {item.label}
204
+ </T>
205
+ {item.supporting ? (
206
+ <T variant="bodySmall" color={muted}>
207
+ {item.supporting}
208
+ </T>
209
+ ) : null}
210
+ </View>
211
+ {item.badge ? (
212
+ <View style={[styles.badge, { backgroundColor: colors[spec.badge.container] }]}>
213
+ <T variant="labelSmall" emphasized color={spec.badge.content}>
214
+ {item.badge}
215
+ </T>
216
+ </View>
217
+ ) : null}
218
+ {item.trailingText ? (
219
+ <T variant="labelLarge" color={muted} style={styles.trailingText}>
220
+ {item.trailingText}
221
+ </T>
222
+ ) : null}
223
+ {hasSub ? <Icon name="arrow_right" size={20} color={spec.icon} /> : item.trailingIcon ? <Icon name={item.trailingIcon} size={20} color={selected ? fg : spec.icon} /> : null}
224
+ </Pressable>
225
+ );
226
+ }
227
+
228
+ const styles = StyleSheet.create({
229
+ anchor: { alignSelf: 'flex-start' },
230
+ panel: { position: 'absolute' },
231
+ divider: { height: 1, marginVertical: 4, marginHorizontal: 12 },
232
+ label: { paddingHorizontal: 12, paddingTop: 12, paddingBottom: 4 },
233
+ slot: { paddingVertical: 4 },
234
+ item: { flexDirection: 'row', alignItems: 'center', gap: 12, paddingHorizontal: 12 },
235
+ text: { flex: 1, minWidth: 0 },
236
+ badge: { paddingHorizontal: 8, paddingVertical: 2, borderRadius: 8 },
237
+ trailingText: { marginLeft: 12, fontVariant: ['tabular-nums'] },
238
+ });
@@ -0,0 +1,198 @@
1
+ import type { ReactNode } from 'react';
2
+ import { Animated, Pressable, StyleSheet, View, type StyleProp, type ViewStyle } from 'react-native';
3
+ import { NAV_BAR, NAV_RAIL, resolveNavItem, useInteraction, type NavItem } from '@expressive-ui/core';
4
+ import { tokens } from '@expressive-ui/tokens';
5
+ import { Fab } from './Fab.js';
6
+ import { Icon, T, withAlpha } from './primitives.js';
7
+ import { useExpressiveTheme, useSpringValue } from './theme.js';
8
+
9
+ type NavProps<K extends string> = {
10
+ items: readonly NavItem<K>[];
11
+ /** Chave do destino ativo (a rota atual). */
12
+ value: K;
13
+ onChange?: (key: K) => void;
14
+ style?: StyleProp<ViewStyle>;
15
+ };
16
+
17
+ // stacked: barra; rail: rail recolhido (mesmo visual, sem flex: 1 na coluna); horizontal/expanded: rótulo na pílula.
18
+ type Layout = 'stacked' | 'rail' | 'horizontal' | 'expanded';
19
+
20
+ // No rail expandido o badge continua preso ao ícone (anatomia do M3); só a barra horizontal o põe em linha.
21
+ function Badge({ badge, layout }: { badge: ReturnType<typeof resolveNavItem>['badge']; layout: Layout }) {
22
+ const { colors } = useExpressiveTheme();
23
+ if (!badge) return null;
24
+ const position = layout === 'horizontal' ? null : [badge.dot ? styles.dotFloating : styles.badgeFloating, layout === 'expanded' && { marginTop: 12 }];
25
+ return (
26
+ <View style={[badge.dot ? styles.dot : styles.badge, { backgroundColor: colors.error }, position]}>
27
+ {badge.text ? (
28
+ <T variant="labelSmall" emphasized color="onError">
29
+ {badge.text}
30
+ </T>
31
+ ) : null}
32
+ </View>
33
+ );
34
+ }
35
+
36
+ // Um destino. A pílula cresce do centro (metade → inteira) com a mola spatial, como no mobile-app-rhosse.
37
+ function NavDestination<K extends string>({ item, active, layout, onChange }: { item: NavItem<K>; active: boolean; layout: Layout; onChange?: (key: K) => void }) {
38
+ const { colors } = useExpressiveTheme();
39
+ const spec = resolveNavItem(item, active);
40
+ const { state, handlers } = useInteraction(item.disabled);
41
+ const grow = useSpringValue(active ? 1 : 0.5, 'spatialDefault');
42
+ const shown = useSpringValue(active ? 1 : 0, 'effectsFast');
43
+ const layer = useSpringValue(state.pressed ? tokens.state.pressed : state.hovered ? tokens.state.hover : 0, 'effectsDefault');
44
+ const inline = layout === 'horizontal' || layout === 'expanded';
45
+ const height = layout === 'expanded' ? NAV_RAIL.indicator.expandedHeight : layout === 'horizontal' ? NAV_BAR.indicator.horizontalHeight : NAV_BAR.indicator.height;
46
+ const content = colors[spec.icon];
47
+
48
+ return (
49
+ <Pressable
50
+ accessibilityRole="tab"
51
+ accessibilityLabel={spec.accessibilityLabel}
52
+ accessibilityState={{ selected: active, disabled: item.disabled }}
53
+ disabled={item.disabled}
54
+ onPress={() => onChange?.(item.key)}
55
+ style={[styles.item, layout === 'stacked' && styles.itemStacked, layout === 'rail' && styles.itemRail, item.disabled && { opacity: tokens.state.disabledContent }]}
56
+ {...handlers}
57
+ >
58
+ <View
59
+ style={[
60
+ styles.indicator,
61
+ { height, borderRadius: height / 2 },
62
+ inline ? { paddingLeft: 16, paddingRight: 16, gap: layout === 'expanded' ? 8 : 4 } : { width: NAV_BAR.indicator.width },
63
+ ]}
64
+ >
65
+ <Animated.View pointerEvents="none" style={[StyleSheet.absoluteFill, { borderRadius: height / 2, backgroundColor: colors[spec.indicator], opacity: shown, transform: [{ scaleX: grow }] }]} />
66
+ <Animated.View pointerEvents="none" style={[StyleSheet.absoluteFill, { borderRadius: height / 2, backgroundColor: content, opacity: layer }]} />
67
+ <Icon name={item.icon} size={NAV_BAR.iconSize} tint={content} filled={spec.iconFilled} />
68
+ {inline ? (
69
+ <T variant={layout === 'expanded' ? NAV_RAIL.labelType : NAV_BAR.labelType} emphasized={spec.labelEmphasized} color={spec.icon} numberOfLines={1}>
70
+ {item.label}
71
+ </T>
72
+ ) : null}
73
+ <Badge badge={spec.badge} layout={layout} />
74
+ </View>
75
+ {inline ? null : (
76
+ <T variant={NAV_BAR.labelType} color={spec.label} numberOfLines={1} style={{ fontWeight: spec.labelEmphasized ? '700' : '500' }}>
77
+ {item.shortLabel ?? item.label}
78
+ </T>
79
+ )}
80
+ </Pressable>
81
+ );
82
+ }
83
+
84
+ export type NavigationBarProps<K extends string> = NavProps<K> & {
85
+ layout?: 'stacked' | 'horizontal';
86
+ /** Área segura inferior (ex.: useSafeAreaInsets().bottom); a biblioteca não depende de safe-area-context. */
87
+ bottomInset?: number;
88
+ };
89
+
90
+ /** Barra inferior do M3, portada do mobile-app-rhosse e do Elo mobile. Use de 3 a 5 destinos. */
91
+ export function NavigationBar<K extends string>({ items, value, onChange, layout = 'stacked', bottomInset = 0, style }: NavigationBarProps<K>) {
92
+ const { colors } = useExpressiveTheme();
93
+ return (
94
+ <View
95
+ accessibilityRole="tablist"
96
+ style={[
97
+ styles.bar,
98
+ { backgroundColor: colors[NAV_BAR.container], paddingTop: NAV_BAR.paddingTop, paddingBottom: Math.max(16, bottomInset + 4) },
99
+ layout === 'horizontal' && styles.barHorizontal,
100
+ style,
101
+ ]}
102
+ >
103
+ {items.map((item) => (
104
+ <NavDestination key={item.key} item={item} active={item.key === value} layout={layout} onChange={onChange} />
105
+ ))}
106
+ </View>
107
+ );
108
+ }
109
+
110
+ export type NavigationRailProps<K extends string> = NavProps<K> & {
111
+ expanded?: boolean;
112
+ onToggle?: () => void;
113
+ header?: ReactNode;
114
+ fab?: { icon: string; label: string; onPress?: () => void };
115
+ footer?: ReactNode | ((expanded: boolean) => ReactNode);
116
+ /** Expandido por cima do conteúdo, com scrim; o espaço recolhido continua reservado. */
117
+ modal?: boolean;
118
+ };
119
+
120
+ /** Navigation rail para tablets, com a mesma anatomia do rail dos admins. */
121
+ export function NavigationRail<K extends string>({ items, value, onChange, expanded = false, onToggle, header, fab, footer, modal = false, style }: NavigationRailProps<K>) {
122
+ const { labels } = useExpressiveTheme();
123
+ const { colors, mode } = useExpressiveTheme();
124
+ const width = useSpringValue(expanded ? NAV_RAIL.expandedWidth : NAV_RAIL.collapsedWidth, 'spatialDefault');
125
+ const scrim = useSpringValue(modal && expanded ? 1 : 0, 'effectsDefault');
126
+ const rail = (
127
+ <Animated.View
128
+ style={[
129
+ styles.rail,
130
+ { width, backgroundColor: colors[NAV_RAIL.container], paddingHorizontal: expanded ? 20 : 0, alignItems: expanded ? 'stretch' : 'center' },
131
+ modal && styles.railModal,
132
+ modal && expanded && { borderTopRightRadius: 28, borderBottomRightRadius: 28, boxShadow: tokens.elevation[mode][3] },
133
+ ]}
134
+ >
135
+ {onToggle || header ? (
136
+ <View style={styles.header}>
137
+ {onToggle ? (
138
+ <Pressable
139
+ accessibilityRole="button"
140
+ accessibilityLabel={expanded ? labels.collapseMenu : labels.expandMenu}
141
+ accessibilityState={{ expanded }}
142
+ onPress={onToggle}
143
+ style={({ pressed }) => [styles.toggle, pressed && { backgroundColor: withAlpha(colors.onSurfaceVariant, tokens.state.pressed) }]}
144
+ >
145
+ <Icon name={expanded ? 'menu_open' : 'menu'} color="onSurfaceVariant" />
146
+ </Pressable>
147
+ ) : null}
148
+ {header && expanded ? <View style={styles.brand}>{header}</View> : null}
149
+ </View>
150
+ ) : null}
151
+ {fab ? (
152
+ <View style={[styles.fab, { alignSelf: expanded ? 'flex-start' : 'center' }]}>
153
+ <Fab action={{ id: 'rail.fab', label: fab.label }} icon={fab.icon} extended expanded={expanded} onPress={fab.onPress} />
154
+ </View>
155
+ ) : null}
156
+ <View accessibilityRole="tablist" style={styles.nav}>
157
+ {items.map((item) => (
158
+ <NavDestination key={item.key} item={item} active={item.key === value} layout={expanded ? 'expanded' : 'rail'} onChange={onChange} />
159
+ ))}
160
+ </View>
161
+ {footer ? <View style={styles.footer}>{typeof footer === 'function' ? footer(expanded) : footer}</View> : null}
162
+ </Animated.View>
163
+ );
164
+
165
+ if (!modal) return <View style={[{ height: '100%' }, style]}>{rail}</View>;
166
+ return (
167
+ <View style={[{ width: NAV_RAIL.collapsedWidth, height: '100%', zIndex: 20 }, style]}>
168
+ {expanded ? (
169
+ <Animated.View style={[styles.scrim, { backgroundColor: withAlpha(colors.scrim, 0.32), opacity: scrim }]}>
170
+ <Pressable accessibilityRole="button" accessibilityLabel={labels.collapseMenu} style={StyleSheet.absoluteFill} onPress={onToggle} />
171
+ </Animated.View>
172
+ ) : null}
173
+ {rail}
174
+ </View>
175
+ );
176
+ }
177
+
178
+ const styles = StyleSheet.create({
179
+ bar: { flexDirection: 'row', alignItems: 'flex-start' },
180
+ barHorizontal: { justifyContent: 'center', alignItems: 'center', gap: 8 },
181
+ item: { alignItems: 'center', gap: 4 },
182
+ itemStacked: { flex: 1 },
183
+ itemRail: { paddingTop: 4, paddingBottom: 6 },
184
+ indicator: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center' },
185
+ badge: { minWidth: 16, height: 16, paddingHorizontal: 4, borderRadius: 8, alignItems: 'center', justifyContent: 'center' },
186
+ dot: { width: 6, height: 6, borderRadius: 3 },
187
+ badgeFloating: { position: 'absolute', top: -2, left: 32 },
188
+ dotFloating: { position: 'absolute', top: 2, left: 36 },
189
+ rail: { height: '100%', paddingVertical: 16, gap: NAV_RAIL.gap, overflow: 'hidden' },
190
+ railModal: { position: 'absolute', top: 0, bottom: 0, left: 0 },
191
+ header: { flexDirection: 'row', alignItems: 'center', gap: 8, minHeight: 56 },
192
+ toggle: { width: 56, height: 56, borderRadius: 28, alignItems: 'center', justifyContent: 'center' },
193
+ brand: { flex: 1, minWidth: 0 },
194
+ fab: { marginTop: 4, marginBottom: 16 },
195
+ nav: { gap: 2, alignSelf: 'stretch' },
196
+ footer: { marginTop: 'auto', alignSelf: 'stretch' },
197
+ scrim: { position: 'absolute', top: 0, bottom: 0, left: 0, width: 4000 },
198
+ });
@@ -0,0 +1,151 @@
1
+ import { Fragment, useEffect, useRef, type ReactNode } from 'react';
2
+ import { Keyboard, Pressable, ScrollView, StyleSheet, TextInput, useWindowDimensions, View, type StyleProp, type ViewStyle } from 'react-native';
3
+ import Svg, { Circle, Line, Path, Rect } from 'react-native-svg';
4
+ import {
5
+ resolveTimePickerLayout, calendarDays, dateInputPattern, dateKey, dialValueAt, padTime, parseDate, pickerLabels, pickerYears,
6
+ useDatePickerState, useDateRangePickerState, useTimePickerState, type DatePickerOptions, type DateRangePickerOptions, type TimePickerOptions,
7
+ } from '@expressive-ui/core';
8
+ import { Dialog } from './Dialogs.js';
9
+ import { Button } from './Button.js';
10
+ import { TextField } from './Fields.js';
11
+ import { Icon, T } from './primitives.js';
12
+ import { useExpressiveTheme } from './theme.js';
13
+
14
+ function PickerIcon({ name, label, onPress, disabled }: { name: string; label: string; onPress: () => void; disabled?: boolean }) {
15
+ const { colors } = useExpressiveTheme();
16
+ return <Pressable accessibilityRole="button" accessibilityLabel={label} accessibilityState={{ disabled }} disabled={disabled} onPress={onPress} style={({ pressed }) => [styles.icon, { opacity: disabled ? .38 : 1, backgroundColor: pressed ? colors.surfaceContainerHighest : undefined }]}><Icon name={name} color="onSurfaceVariant" /></Pressable>;
17
+ }
18
+ function PickerActions({ cancel, confirm, onClose, onConfirm, valid, toggle }: { cancel: string; confirm: string; onClose: () => void; onConfirm: () => void; valid: boolean; toggle?: ReactNode }) {
19
+ return <View style={styles.actions}>{toggle}<View style={{ flex: 1 }} /><Button variant="text" action={{ id: 'cancel', label: cancel }} onPress={onClose} /><Button variant="text" action={{ id: 'confirm', label: confirm }} disabled={!valid} onPress={onConfirm} /></View>;
20
+ }
21
+
22
+ function TimeModeToggle({ input, label, onPress }: { input: boolean; label: string; onPress: () => void }) {
23
+ const { colors } = useExpressiveTheme();
24
+ return <Pressable accessibilityRole="button" accessibilityLabel={label} accessibilityState={{ selected: input }} onPress={() => { if (input) Keyboard.dismiss(); onPress(); }} style={({ pressed }) => ({ width: 48, height: 48, borderRadius: 24, alignItems: 'center', justifyContent: 'center', backgroundColor: pressed ? colors.surfaceContainerHighest : undefined })}>
25
+ <Svg width={24} height={24} viewBox="0 0 24 24" fill="none" stroke={colors.onSurfaceVariant} strokeWidth={1.8} strokeLinecap="round" strokeLinejoin="round" accessible={false}>
26
+ {input ? <><Circle cx={12} cy={12} r={9} /><Path d="M12 7v5l3 2" /></> : <><Rect x={2} y={5} width={20} height={14} rx={2} /><Path d="M5 9h1m3 0h1m3 0h1m3 0h1M5 12h1m3 0h1m3 0h1m3 0h1M7 15h10" /></>}
27
+ </Svg>
28
+ </Pressable>;
29
+ }
30
+
31
+ export type DatePickerProps = DatePickerOptions & { style?: StyleProp<ViewStyle> };
32
+ export type DateRangePickerProps = DateRangePickerOptions & { style?: StyleProp<ViewStyle> };
33
+ export type { DateRange } from '@expressive-ui/core';
34
+ export function DatePicker(props: DatePickerProps) {
35
+ const { locale: themeLocale } = useExpressiveTheme();
36
+ const locale = props.locale ?? themeLocale;
37
+ const state = useDatePickerState({ ...props, locale });
38
+ return <DatePickerSurface {...props} locale={locale} state={state} />;
39
+ }
40
+ export function DateRangePicker(props: DateRangePickerProps) {
41
+ const { locale: themeLocale } = useExpressiveTheme();
42
+ const locale = props.locale ?? themeLocale;
43
+ const range = useDateRangePickerState({ ...props, locale });
44
+ return <DatePickerSurface {...props} locale={locale} state={range} range={range} />;
45
+ }
46
+ type DatePickerSurfaceProps = Omit<DatePickerProps, 'value' | 'onConfirm'> & {
47
+ locale: string;
48
+ state: ReturnType<typeof useDatePickerState>;
49
+ range?: ReturnType<typeof useDateRangePickerState>;
50
+ startLabel?: string;
51
+ endLabel?: string;
52
+ };
53
+ function DatePickerSurface(props: DatePickerSurfaceProps) {
54
+ const { colors } = useExpressiveTheme();
55
+ const { open, onClose, title, fieldLabel, cancelLabel, confirmLabel, min, max, style, locale, state, range, startLabel, endLabel } = props;
56
+ const labels = pickerLabels(locale);
57
+ const rangeEnd = range?.range.end ?? '';
58
+ const shortDate = (date: string) => parseDate(date)?.toLocaleDateString(locale, { month: 'short', day: 'numeric' });
59
+ const list = useRef<ScrollView>(null);
60
+ const years = pickerYears(state.month, min, max);
61
+ useEffect(() => {
62
+ const index = state.view === 'months' ? state.month.getMonth() : years.indexOf(state.month.getFullYear());
63
+ if (state.view !== 'days') list.current?.scrollTo({ y: Math.max(0, index * 48 - 96), animated: false });
64
+ }, [state.view]);
65
+ const monthName = (m: number, long = false) => new Date(2024, m, 1).toLocaleDateString(locale, { month: long ? 'long' : 'short' });
66
+ const menu = (view: 'months' | 'years', label: string, text: string) => <Pressable accessibilityRole="button" accessibilityLabel={label} accessibilityState={{ expanded: state.view === view, disabled: state.view !== 'days' && state.view !== view }} disabled={state.view !== 'days' && state.view !== view} onPress={() => state.setView(state.view === view ? 'days' : view)} style={[styles.menuTrigger, { opacity: state.view !== 'days' && state.view !== view ? .38 : 1 }]}><T variant="labelLarge" color={state.view === view ? 'primary' : 'onSurfaceVariant'}>{text}</T><Icon name="arrow_drop_down" size={18} /></Pressable>;
67
+ return <Dialog open={open} onClose={onClose} style={[{ maxWidth: 360, borderRadius: 28 }, style]}>
68
+ <View style={{ gap: 16 }}>
69
+ <T variant="labelLarge" color="onSurfaceVariant">{title ?? (range ? labels.range : labels.date)}</T>
70
+ <View style={[styles.headline, { borderBottomColor: colors.outlineVariant, borderBottomWidth: 1, paddingBottom: 12 }]}><T variant={range ? "headlineSmall" : "headlineLarge"} style={{ flex: 1 }}>{range ? `${shortDate(range.range.start) ?? labels.start} – ${shortDate(range.range.end) ?? labels.end}` : parseDate(state.draft)?.toLocaleDateString(locale, { weekday: 'short', month: 'short', day: 'numeric' }) ?? '—'}</T><PickerIcon name={state.mode === 'calendar' ? 'edit' : 'calendar_today'} label={state.mode === 'calendar' ? labels.input : labels.calendar} onPress={() => { state.setMode(state.mode === 'calendar' ? 'input' : 'calendar'); state.setView('days'); }} /></View>
71
+ {state.mode === 'input' ? range ? <View style={{ gap: 16 }}>{(['start', 'end'] as const).map(part => <TextField key={part} variant="outlined" label={part === 'start' ? startLabel ?? labels.start : endLabel ?? labels.end} value={part === 'start' ? range.startText : range.endText} onChange={text => range.editPart(text, part)} keyboardType="numbers-and-punctuation" placeholder={dateInputPattern(locale)} supportingText={dateInputPattern(locale)} error={(part === 'start' ? range.startText : range.endText) && (!range.available(range.range[part]) || !!(range.range.start && range.range.end && !range.valid)) ? labels.rangeInvalid : undefined} />)}</View> : <TextField variant="outlined" label={fieldLabel ?? labels.dateField} value={state.text} onChange={state.edit} keyboardType="numbers-and-punctuation" placeholder={dateInputPattern(locale)} supportingText={dateInputPattern(locale)} error={state.text && !state.valid ? labels.invalid : undefined} /> : <View>
72
+ <View style={styles.navigation}>
73
+ <View style={styles.navGroup}><PickerIcon name="chevron_left" label={labels.previous} disabled={state.view === 'years' || !state.canNavigate(-1)} onPress={() => state.navigate(-1)} />{menu('months', labels.month, monthName(state.month.getMonth()))}<PickerIcon name="chevron_right" label={labels.next} disabled={state.view === 'years' || !state.canNavigate(1)} onPress={() => state.navigate(1)} /></View>
74
+ <View style={styles.navGroup}><PickerIcon name="chevron_left" label={labels.previousYear} disabled={state.view === 'months' || !state.canNavigate(-12)} onPress={() => state.navigate(-12)} />{menu('years', labels.year, String(state.month.getFullYear()))}<PickerIcon name="chevron_right" label={labels.nextYear} disabled={state.view === 'months' || !state.canNavigate(12)} onPress={() => state.navigate(12)} /></View>
75
+ </View>
76
+ {state.view === 'days' ? <View style={styles.calendar}>
77
+ {Array.from({ length: 7 }, (_, i) => <View key={i} style={styles.day}><T variant="labelSmall" color="onSurfaceVariant">{new Date(2024, 0, 7 + i).toLocaleDateString(locale, { weekday: 'narrow' })}</T></View>)}
78
+ {calendarDays(state.month).map(date => {
79
+ const start = !!range && date === range.range.start, end = !!range && date === range.range.end;
80
+ const selected = range ? start || end : state.draft === date, today = dateKey(new Date()) === date, enabled = state.available(date);
81
+ const inRange = !!(range?.range.start && rangeEnd && date >= range.range.start && date <= rangeEnd);
82
+ return <Pressable key={date} accessibilityRole="button" accessibilityLabel={`${parseDate(date)!.toLocaleDateString(locale, { dateStyle: 'full' })}${start ? `, ${startLabel ?? labels.start}` : ''}${end ? `, ${endLabel ?? labels.end}` : ''}`}
83
+ accessibilityHint={range ? labels.rangeHelp : undefined} accessibilityState={{ selected, disabled: !enabled }} disabled={!enabled} onPress={() => state.select(date)} style={[styles.day, { opacity: !enabled ? .38 : selected || inRange ? 1 : parseDate(date)!.getMonth() !== state.month.getMonth() ? .38 : 1 }]}>{inRange && !(start && end) ? <View pointerEvents="none" style={{ position: 'absolute', top: 5, bottom: 5, left: start ? '50%' : 0, right: end ? '50%' : 0, backgroundColor: colors.secondaryContainer }} /> : null}<View style={{ width: 34, height: 34, borderRadius: 17, alignItems: 'center', justifyContent: 'center', backgroundColor: selected ? colors.primary : undefined, borderWidth: today ? 1 : 0, borderColor: colors.primary }}><T color={selected ? 'onPrimary' : today ? 'primary' : inRange ? 'onSecondaryContainer' : 'onSurface'}>{parseDate(date)!.getDate()}</T></View></Pressable>;
84
+ })}
85
+ </View> : <ScrollView ref={list} style={{ height: 308, borderTopWidth: 1, borderColor: colors.outlineVariant }} nestedScrollEnabled>
86
+ {(state.view === 'months' ? Array.from({ length: 12 }, (_, i) => i) : years).map(n => {
87
+ const selected = n === (state.view === 'months' ? state.month.getMonth() : state.month.getFullYear());
88
+ const start = new Date(state.month); start.setDate(1); state.view === 'months' ? start.setMonth(n) : start.setFullYear(n, 0, 1);
89
+ const end = new Date(start); state.view === 'months' ? end.setMonth(end.getMonth() + 1, 0) : end.setFullYear(n + 1, 0, 0);
90
+ const disabled = !!((min && dateKey(end) < min) || (max && dateKey(start) > max));
91
+ return <Pressable key={n} accessibilityRole="button" accessibilityState={{ selected, disabled }} disabled={disabled} onPress={() => state.view === 'months' ? state.chooseMonth(n) : state.chooseYear(n)} style={{ minHeight: 48, paddingHorizontal: 16, flexDirection: 'row', alignItems: 'center', gap: 16, opacity: disabled ? .38 : 1, backgroundColor: selected ? colors.secondaryContainer : undefined }}><View style={{ width: 20 }}>{selected ? <Icon name="check" size={20} color="onSecondaryContainer" /> : null}</View><T color={selected ? 'onSecondaryContainer' : 'onSurface'}>{state.view === 'months' ? monthName(n, true) : n}</T></Pressable>;
92
+ })}
93
+ </ScrollView>}
94
+ </View>}
95
+ {range ? <T variant="bodySmall" color="onSurfaceVariant" accessibilityLiveRegion="polite">{range.range.start && !range.range.end ? labels.end : range.range.end && !range.valid ? labels.rangeInvalid : labels.rangeHelp}</T> : null}
96
+ <PickerActions cancel={cancelLabel ?? labels.cancel} confirm={confirmLabel ?? labels.confirm} onClose={onClose} onConfirm={state.confirm} valid={state.valid} />
97
+ </View>
98
+ </Dialog>;
99
+ }
100
+
101
+ export type TimePickerProps = TimePickerOptions & { style?: StyleProp<ViewStyle> };
102
+ export function TimePicker(props: TimePickerProps) {
103
+ const { locale, colors } = useExpressiveTheme();
104
+ const { open, onClose, title, cancelLabel, confirmLabel, format = '24h', layout = 'auto', style } = props;
105
+ const labels = pickerLabels(props.locale ?? locale), state = useTimePickerState(props);
106
+ const hourInput = useRef<TextInput>(null), minuteInput = useRef<TextInput>(null);
107
+ const { width, height } = useWindowDimensions();
108
+ const inputMode = state.mode === 'input';
109
+ const horizontal = resolveTimePickerLayout(layout, width, height, state.mode) === 'horizontal';
110
+ const size = horizontal ? Math.min(256, (Math.min(560, width - 48) - 72) * 1.1 / 2.1) : Math.min(256, width - 96), scale = size / 256, center = size / 2;
111
+ useEffect(() => { if (open && inputMode) (state.part === 'hour' ? hourInput : minuteInput).current?.focus(); }, [inputMode, open]);
112
+ const angle = (state.part === 'minute' ? state.minute / 60 : state.h24 % 12 / 12) * Math.PI * 2;
113
+ const radius = (state.h24 >= 12 && format === '24h' && state.part === 'hour' ? 65 : 100) * scale;
114
+ const selected = state.part === 'hour' ? state.hour : state.minute;
115
+ const periodSelector = format === '12h' ? <View style={{ borderWidth: 1, borderColor: colors.outline, borderRadius: 8, overflow: 'hidden', flexDirection: horizontal ? 'row' : 'column', width: horizontal ? '100%' : 52 }}>{['AM', 'PM'].map((period, i) => <Pressable key={period} accessibilityRole="button" accessibilityState={{ selected: state.period === i }} onPress={() => state.setPeriod(i)} style={{ minWidth: 46, flex: horizontal ? 1 : undefined, height: 39, alignItems: 'center', justifyContent: 'center', borderTopWidth: horizontal ? 0 : i, borderLeftWidth: horizontal ? i : 0, borderColor: colors.outline, backgroundColor: state.period === i ? colors.tertiaryContainer : undefined }}><T color={state.period === i ? 'onTertiaryContainer' : 'onSurfaceVariant'}>{period}</T></Pressable>)}</View> : null;
116
+ return <Dialog open={open} onClose={onClose} style={[{ maxWidth: horizontal ? 560 : 360, borderRadius: 28 }, style]}>
117
+ <View style={{ gap: 24 }}>
118
+ <T variant="labelLarge" color="onSurfaceVariant">{title ?? (inputMode ? labels.enterTime : labels.time)}</T>
119
+ <View style={{ flexDirection: horizontal ? 'row' : 'column', gap: 24, alignItems: 'center' }}><View style={{ flex: horizontal ? 1 : undefined, width: horizontal ? undefined : '100%' }}><View style={{ gap: 16, width: '100%', maxWidth: format === '12h' && !horizontal ? 284 : 256, alignSelf: 'center' }}><View style={[styles.time, { gap: format === '12h' ? 8 : 4 }]}>
120
+ {(['hour', 'minute'] as const).map((part, i) => <Fragment key={part}>{i ? <T accessible={false} style={{ width: 16, height: 80, fontSize: 56, lineHeight: 80, textAlign: 'center' }}>:</T> : null}<View style={{ gap: 7, flex: 1, minWidth: 0 }}>
121
+ {inputMode ? <TextInput ref={part === 'hour' ? hourInput : minuteInput} accessibilityLabel={labels[part]} keyboardType="number-pad" selectTextOnFocus maxLength={2} value={part === 'hour' ? state.hourText : state.minuteText} onFocus={() => state.setPart(part)} onBlur={() => state.normalize(part)} onChangeText={text => state.edit(text, part)} onSubmitEditing={() => part === 'hour' ? minuteInput.current?.focus() : state.confirm()} style={{ width: '100%', height: 80, fontSize: 56, textAlign: 'center', borderRadius: 8, borderWidth: 2, borderColor: !(part === 'hour' ? state.hourValid : state.minuteValid) ? colors.error : state.part === part ? colors.primary : 'transparent', color: state.part === part ? colors.onPrimaryContainer : colors.onSurface, backgroundColor: state.part === part ? colors.primaryContainer : colors.surfaceContainerHighest }} /> : <Pressable accessibilityRole="button" accessibilityLabel={labels[part]} accessibilityState={{ selected: state.part === part }} onPress={() => state.setPart(part)} onLongPress={() => { state.setPart(part); state.setMode('input'); }} style={{ width: '100%', height: 80, justifyContent: 'center', alignItems: 'center', borderRadius: 8, backgroundColor: state.part === part ? colors.primaryContainer : colors.surfaceContainerHighest }}><T style={{ fontSize: 56, lineHeight: 68 }} color={state.part === part ? 'onPrimaryContainer' : 'onSurface'}>{padTime(part === 'hour' ? state.hour : state.minute)}</T></Pressable>}
122
+ {inputMode ? <T variant="labelSmall" color="onSurfaceVariant">{labels[part]}</T> : null}
123
+ </View></Fragment>)}
124
+ {!horizontal ? periodSelector : null}
125
+ </View>{horizontal ? periodSelector : null}</View>
126
+ {inputMode && !state.valid ? <T color="error" accessibilityRole="alert">{labels.invalid}</T> : null}</View>
127
+ {!inputMode ? <View accessibilityLabel={labels[state.part]} style={{ width: size, height: size, alignSelf: 'center', borderRadius: center, backgroundColor: colors.surfaceContainerHighest }}>
128
+ <View style={StyleSheet.absoluteFill} onStartShouldSetResponder={() => true} onMoveShouldSetResponder={() => true} onResponderGrant={event => state.select(dialValueAt(event.nativeEvent.locationX, event.nativeEvent.locationY, size, state.part, format))} onResponderMove={event => state.select(dialValueAt(event.nativeEvent.locationX, event.nativeEvent.locationY, size, state.part, format))} onResponderRelease={() => { if (state.part === 'hour') state.setPart('minute'); }} />
129
+ <Svg width={size} height={size} style={StyleSheet.absoluteFill} pointerEvents="none"><Line x1={center} y1={center} x2={center + Math.sin(angle) * radius} y2={center - Math.cos(angle) * radius} stroke={colors.primary} strokeWidth={2} /><Circle cx={center} cy={center} r={4} fill={colors.primary} /><Circle cx={center + Math.sin(angle) * radius} cy={center - Math.cos(angle) * radius} r={20 * scale} fill={colors.primary} /></Svg>
130
+ {Array.from({ length: state.part === 'hour' && format === '24h' ? 24 : 12 }, (_, i) => {
131
+ const n = state.part === 'minute' ? i * 5 : format === '12h' ? i || 12 : i;
132
+ const a = i % 12 / 12 * Math.PI * 2, r = (i >= 12 ? 65 : 100) * scale;
133
+ return <Pressable key={n} accessibilityRole="button" accessibilityLabel={`${labels[state.part]} ${n}`} accessibilityState={{ selected: selected === n }} onPress={() => { state.select(n); if (state.part === 'hour') state.setPart('minute'); }} style={{ position: 'absolute', left: center - 20 * scale + Math.sin(a) * r, top: center - 20 * scale - Math.cos(a) * r, width: 40 * scale, height: 40 * scale, borderRadius: 20, alignItems: 'center', justifyContent: 'center' }}><T variant={i >= 12 ? 'labelSmall' : 'bodyLarge'} color={selected === n ? 'onPrimary' : 'onSurface'}>{state.part === 'minute' || format === '24h' && n === 0 ? padTime(n) : n}</T></Pressable>;
134
+ })}
135
+ </View> : null}
136
+ </View>
137
+ <PickerActions cancel={cancelLabel ?? labels.cancel} confirm={confirmLabel ?? labels.confirm} onClose={onClose} onConfirm={state.confirm} valid={state.valid} toggle={<TimeModeToggle input={inputMode} label={inputMode ? labels.dial : labels.input} onPress={state.toggle} />} />
138
+ </View>
139
+ </Dialog>;
140
+ }
141
+ const styles = StyleSheet.create({
142
+ icon: { width: 28, minHeight: 48, borderRadius: 24, alignItems: 'center', justifyContent: 'center' },
143
+ actions: { flexDirection: 'row', alignItems: 'center', gap: 8 },
144
+ headline: { flexDirection: 'row', alignItems: 'center', gap: 8 },
145
+ navigation: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', minHeight: 48 },
146
+ navGroup: { flexDirection: 'row', alignItems: 'center', flexShrink: 1 },
147
+ menuTrigger: { flexDirection: 'row', alignItems: 'center', gap: 2, minHeight: 48 },
148
+ calendar: { flexDirection: 'row', flexWrap: 'wrap' },
149
+ day: { width: '14.285714%', height: 44, alignItems: 'center', justifyContent: 'center' },
150
+ time: { flexDirection: 'row', gap: 8, justifyContent: 'center', alignItems: 'flex-start' },
151
+ });