@baukit/navigation 0.18.3 → 0.19.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.
Files changed (70) hide show
  1. package/dist/index.d.ts.map +1 -1
  2. package/dist/index.js +19 -14
  3. package/dist/index.js.map +1 -1
  4. package/dist/native-menu.d.ts +22 -0
  5. package/dist/native-menu.d.ts.map +1 -0
  6. package/dist/native-menu.js +226 -0
  7. package/dist/native-menu.js.map +1 -0
  8. package/dist/native-primitives.d.ts +51 -0
  9. package/dist/native-primitives.d.ts.map +1 -0
  10. package/dist/native-primitives.js +125 -0
  11. package/dist/native-primitives.js.map +1 -0
  12. package/dist/native-profile.d.ts +34 -0
  13. package/dist/native-profile.d.ts.map +1 -0
  14. package/dist/native-profile.js +67 -0
  15. package/dist/native-profile.js.map +1 -0
  16. package/dist/native-section-picker.d.ts +14 -0
  17. package/dist/native-section-picker.d.ts.map +1 -0
  18. package/dist/native-section-picker.js +46 -0
  19. package/dist/native-section-picker.js.map +1 -0
  20. package/dist/native-styles.d.ts +106 -0
  21. package/dist/native-styles.d.ts.map +1 -0
  22. package/dist/native-styles.js +50 -0
  23. package/dist/native-styles.js.map +1 -0
  24. package/dist/native-theme.d.ts +49 -0
  25. package/dist/native-theme.d.ts.map +1 -0
  26. package/dist/native-theme.js +56 -0
  27. package/dist/native-theme.js.map +1 -0
  28. package/dist/native.d.ts +9 -52
  29. package/dist/native.d.ts.map +1 -1
  30. package/dist/native.js +148 -536
  31. package/dist/native.js.map +1 -1
  32. package/dist/use-navigation-state.d.ts +9 -8
  33. package/dist/use-navigation-state.d.ts.map +1 -1
  34. package/dist/use-navigation-state.js +3 -2
  35. package/dist/use-navigation-state.js.map +1 -1
  36. package/dist/web-link.d.ts +20 -0
  37. package/dist/web-link.d.ts.map +1 -0
  38. package/dist/web-link.js +23 -0
  39. package/dist/web-link.js.map +1 -0
  40. package/dist/web-menu.d.ts +19 -0
  41. package/dist/web-menu.d.ts.map +1 -0
  42. package/dist/web-menu.js +96 -0
  43. package/dist/web-menu.js.map +1 -0
  44. package/dist/web-profile.d.ts +16 -0
  45. package/dist/web-profile.d.ts.map +1 -0
  46. package/dist/web-profile.js +58 -0
  47. package/dist/web-profile.js.map +1 -0
  48. package/dist/web-section-picker.d.ts +13 -0
  49. package/dist/web-section-picker.d.ts.map +1 -0
  50. package/dist/web-section-picker.js +71 -0
  51. package/dist/web-section-picker.js.map +1 -0
  52. package/dist/web.d.ts +7 -25
  53. package/dist/web.d.ts.map +1 -1
  54. package/dist/web.js +113 -257
  55. package/dist/web.js.map +1 -1
  56. package/package.json +7 -7
  57. package/src/index.ts +22 -16
  58. package/src/native-menu.tsx +436 -0
  59. package/src/native-primitives.tsx +308 -0
  60. package/src/native-profile.tsx +153 -0
  61. package/src/native-section-picker.tsx +102 -0
  62. package/src/native-styles.ts +50 -0
  63. package/src/native-theme.ts +108 -0
  64. package/src/native.tsx +355 -1086
  65. package/src/use-navigation-state.ts +20 -5
  66. package/src/web-link.tsx +51 -0
  67. package/src/web-menu.tsx +220 -0
  68. package/src/web-profile.tsx +201 -0
  69. package/src/web-section-picker.tsx +128 -0
  70. package/src/web.tsx +256 -598
@@ -0,0 +1,308 @@
1
+ import { useState, type ComponentPropsWithRef, type ReactNode, type RefObject } from 'react';
2
+ import {
3
+ Image,
4
+ Platform,
5
+ Pressable,
6
+ Text,
7
+ View,
8
+ type GestureResponderEvent,
9
+ type NativeSyntheticEvent,
10
+ type StyleProp,
11
+ type ViewStyle,
12
+ } from 'react-native';
13
+ import type { useRovingMenu } from '@baukit/a11y-core';
14
+ import {
15
+ getNavigationBarVisualHeight,
16
+ NAVIGATION_BAR_DIMENSIONS,
17
+ NAVIGATION_DIMENSIONS,
18
+ type NavigationProfile,
19
+ } from './index.js';
20
+ import { styles } from './native-styles.js';
21
+ import {
22
+ subtitleTextStyle,
23
+ textStyle,
24
+ type Navigate,
25
+ type NavigationTheme,
26
+ } from './native-theme.js';
27
+
28
+ export type RovingItemProps = ReturnType<ReturnType<typeof useRovingMenu>['itemProps']>;
29
+
30
+ type FocusablePressableProps = Omit<ComponentPropsWithRef<typeof Pressable>, 'style'> & {
31
+ readonly theme: NavigationTheme;
32
+ readonly selected?: boolean;
33
+ readonly unfocusedBorderColor?: string;
34
+ readonly style?: StyleProp<ViewStyle>;
35
+ };
36
+ function showsFocusRing(event: NativeSyntheticEvent<unknown>): boolean {
37
+ if (Platform.OS !== 'web') return true;
38
+ const target: unknown = (event.nativeEvent as { target?: unknown } | undefined)?.target;
39
+ return !(target instanceof Element) || target.matches(':focus-visible');
40
+ }
41
+ function focusBorderColor(
42
+ theme: NavigationTheme,
43
+ focused: boolean,
44
+ selected: boolean,
45
+ unfocused: string | undefined,
46
+ ): string {
47
+ if (!focused) return unfocused ?? 'transparent';
48
+ return selected ? theme.activeText : theme.focus;
49
+ }
50
+ function targetSize(): number {
51
+ return Platform.OS === 'android'
52
+ ? NAVIGATION_DIMENSIONS.androidTarget
53
+ : NAVIGATION_DIMENSIONS.target;
54
+ }
55
+
56
+ export function FocusablePressable({
57
+ theme,
58
+ selected = false,
59
+ unfocusedBorderColor,
60
+ style,
61
+ onFocus,
62
+ onBlur,
63
+ ...props
64
+ }: FocusablePressableProps): ReactNode {
65
+ const [focused, setFocused] = useState(false);
66
+ const size = targetSize();
67
+ return (
68
+ <Pressable
69
+ {...props}
70
+ onFocus={(event) => {
71
+ setFocused(showsFocusRing(event));
72
+ onFocus?.(event);
73
+ }}
74
+ onBlur={(event) => {
75
+ setFocused(false);
76
+ onBlur?.(event);
77
+ }}
78
+ style={[
79
+ style,
80
+ {
81
+ minHeight: size,
82
+ minWidth: size,
83
+ borderWidth: NAVIGATION_BAR_DIMENSIONS.targetBorder,
84
+ borderColor: focusBorderColor(theme, focused, selected, unfocusedBorderColor),
85
+ },
86
+ ]}
87
+ />
88
+ );
89
+ }
90
+
91
+ export function isModifiedPress(event: GestureResponderEvent): boolean {
92
+ const native: unknown = event.nativeEvent;
93
+ if (typeof native !== 'object' || native === null) return false;
94
+ return (
95
+ ('button' in native && native.button !== undefined && native.button !== 0) ||
96
+ ('metaKey' in native && native.metaKey === true) ||
97
+ ('ctrlKey' in native && native.ctrlKey === true) ||
98
+ ('shiftKey' in native && native.shiftKey === true) ||
99
+ ('altKey' in native && native.altKey === true)
100
+ );
101
+ }
102
+ export function webLink(
103
+ href: string,
104
+ active: boolean,
105
+ ): { href?: string; 'aria-current'?: 'page' | undefined } {
106
+ return Platform.OS === 'web'
107
+ ? { href, 'aria-current': active ? ('page' as const) : undefined }
108
+ : {};
109
+ }
110
+ export function follow(href: string, event: GestureResponderEvent, onNavigate: Navigate): void {
111
+ if (isModifiedPress(event)) return;
112
+ event.preventDefault();
113
+ onNavigate(href);
114
+ }
115
+
116
+ interface TargetProps {
117
+ readonly label: string;
118
+ readonly subtitle?: string | undefined;
119
+ readonly selected?: boolean;
120
+ readonly ancestor?: boolean;
121
+ readonly expanded?: boolean;
122
+ readonly controls?: string;
123
+ readonly menu?: boolean;
124
+ readonly href?: string;
125
+ readonly onPress: (event: GestureResponderEvent) => void;
126
+ readonly theme: NavigationTheme;
127
+ readonly bar?: boolean;
128
+ readonly collapsed?: boolean;
129
+ readonly children: ReactNode;
130
+ readonly roving?: RovingItemProps;
131
+ readonly triggerRef?: RefObject<View | null>;
132
+ readonly testID?: string;
133
+ }
134
+
135
+ function activeMarker(selected: boolean, ancestor: boolean): 'ancestor' | 'page' | 'false' {
136
+ if (!selected) return 'false';
137
+ return ancestor ? 'ancestor' : 'page';
138
+ }
139
+
140
+ function webTargetProps(
141
+ label: string,
142
+ {
143
+ collapsed = false,
144
+ controls,
145
+ menu = false,
146
+ }: Pick<TargetProps, 'collapsed' | 'controls' | 'menu'>,
147
+ ): Record<string, string | undefined> {
148
+ if (Platform.OS !== 'web') return {};
149
+ return {
150
+ title: collapsed ? label : undefined,
151
+ 'aria-controls': controls,
152
+ 'aria-haspopup': menu ? 'menu' : undefined,
153
+ };
154
+ }
155
+
156
+ function labelColor(theme: NavigationTheme, selected: boolean, ancestor: boolean): string {
157
+ if (ancestor) return theme.ancestorText;
158
+ return selected ? theme.activeText : theme.text;
159
+ }
160
+
161
+ interface TargetLabelProps {
162
+ readonly label: string;
163
+ readonly subtitle: string | undefined;
164
+ readonly selected: boolean;
165
+ readonly ancestor: boolean;
166
+ readonly bar: boolean;
167
+ readonly theme: NavigationTheme;
168
+ }
169
+ function TargetLabel({
170
+ label,
171
+ subtitle,
172
+ selected,
173
+ ancestor,
174
+ bar,
175
+ theme,
176
+ }: TargetLabelProps): ReactNode {
177
+ return (
178
+ <View style={styles.labelGroup}>
179
+ <Text
180
+ numberOfLines={1}
181
+ style={{
182
+ ...textStyle(theme, selected && !ancestor, bar),
183
+ color: labelColor(theme, selected, ancestor),
184
+ }}
185
+ >
186
+ {label}
187
+ </Text>
188
+ {!bar && subtitle !== undefined ? (
189
+ <Text numberOfLines={1} style={subtitleTextStyle(theme)}>
190
+ {subtitle}
191
+ </Text>
192
+ ) : null}
193
+ </View>
194
+ );
195
+ }
196
+
197
+ export function Target(props: TargetProps): ReactNode {
198
+ const { label, subtitle, href, theme, roving, triggerRef, children } = props;
199
+ const selected = props.selected ?? false;
200
+ const ancestor = props.ancestor ?? false;
201
+ const bar = props.bar ?? false;
202
+ const collapsed = props.collapsed ?? false;
203
+ const expanded = props.expanded;
204
+ return (
205
+ <FocusablePressable
206
+ theme={theme}
207
+ selected={selected && !ancestor}
208
+ {...{ dataSet: { active: activeMarker(selected, ancestor) } }}
209
+ {...roving}
210
+ {...(href === undefined ? {} : webLink(href, selected))}
211
+ {...webTargetProps(label, props)}
212
+ accessibilityLabel={subtitle === undefined ? label : `${label}, ${subtitle}`}
213
+ accessibilityRole={href === undefined ? 'button' : 'link'}
214
+ accessibilityState={{ selected, ...(expanded === undefined ? {} : { expanded }) }}
215
+ ref={(node) => {
216
+ roving?.ref(node);
217
+ if (triggerRef !== undefined) triggerRef.current = node;
218
+ }}
219
+ onPress={props.onPress}
220
+ testID={props.testID}
221
+ style={[
222
+ styles.target,
223
+ bar ? styles.barTarget : styles.railTarget,
224
+ collapsed && styles.collapsedTarget,
225
+ {
226
+ borderRadius: theme.radius,
227
+ gap: theme.spacing,
228
+ backgroundColor: selected && !ancestor ? theme.activeBackground : theme.background,
229
+ },
230
+ ]}
231
+ >
232
+ {children}
233
+ {!collapsed ? (
234
+ <TargetLabel
235
+ label={label}
236
+ subtitle={subtitle}
237
+ selected={selected}
238
+ ancestor={ancestor}
239
+ bar={bar}
240
+ theme={theme}
241
+ />
242
+ ) : null}
243
+ </FocusablePressable>
244
+ );
245
+ }
246
+ export function Decorative({
247
+ children,
248
+ style,
249
+ }: {
250
+ readonly children: ReactNode;
251
+ readonly style?: StyleProp<ViewStyle>;
252
+ }): ReactNode {
253
+ return (
254
+ <View
255
+ style={style}
256
+ accessible={false}
257
+ accessibilityElementsHidden
258
+ importantForAccessibility="no-hide-descendants"
259
+ aria-hidden
260
+ >
261
+ {children}
262
+ </View>
263
+ );
264
+ }
265
+
266
+ export function compactVisualStyle(fontScale: number): ViewStyle {
267
+ return { height: getNavigationBarVisualHeight(fontScale), justifyContent: 'center' };
268
+ }
269
+
270
+ export function Avatar({
271
+ profile,
272
+ active,
273
+ theme,
274
+ style,
275
+ }: {
276
+ readonly profile: NavigationProfile;
277
+ readonly active: boolean;
278
+ readonly theme: NavigationTheme;
279
+ readonly style?: StyleProp<ViewStyle>;
280
+ }): ReactNode {
281
+ const [failedUrl, setFailedUrl] = useState<string>();
282
+ if (profile.renderAvatar !== undefined) {
283
+ return (
284
+ <Decorative style={style}>
285
+ {profile.renderAvatar({ active, size: NAVIGATION_DIMENSIONS.avatar })}
286
+ </Decorative>
287
+ );
288
+ }
289
+ return (
290
+ <Decorative style={style}>
291
+ {profile.imageUrl !== undefined && failedUrl !== profile.imageUrl ? (
292
+ <Image
293
+ source={{ uri: profile.imageUrl }}
294
+ onError={() => {
295
+ setFailedUrl(profile.imageUrl);
296
+ }}
297
+ style={styles.avatar}
298
+ />
299
+ ) : (
300
+ <View style={[styles.avatar, { backgroundColor: theme.activeBackground }]}>
301
+ <Text allowFontScaling={false} style={{ ...textStyle(theme), color: theme.activeText }}>
302
+ {profile.initials}
303
+ </Text>
304
+ </View>
305
+ )}
306
+ </Decorative>
307
+ );
308
+ }
@@ -0,0 +1,153 @@
1
+ import { useCallback, useEffect, useRef, type ReactNode, type RefObject } from 'react';
2
+ import {
3
+ ScrollView,
4
+ View,
5
+ useWindowDimensions,
6
+ type LayoutChangeEvent,
7
+ type NativeScrollEvent,
8
+ type NativeSyntheticEvent,
9
+ } from 'react-native';
10
+ import {
11
+ getNavigationBarHeight,
12
+ navigationMatches,
13
+ resolveActiveMenuEntry,
14
+ type NavigationProfile,
15
+ } from './index.js';
16
+ import {
17
+ Avatar,
18
+ compactVisualStyle,
19
+ follow,
20
+ Target,
21
+ type RovingItemProps,
22
+ } from './native-primitives.js';
23
+ import { styles } from './native-styles.js';
24
+ import { barMetrics, type Navigate, type NavigationTheme } from './native-theme.js';
25
+
26
+ export interface CompactBarScroll {
27
+ readonly scrollProps: {
28
+ readonly ref: RefObject<ScrollView | null>;
29
+ readonly onLayout: (event: LayoutChangeEvent) => void;
30
+ readonly onContentSizeChange: (width: number) => void;
31
+ readonly onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => void;
32
+ };
33
+ readonly itemLayout: (index: number) => (event: LayoutChangeEvent) => void;
34
+ }
35
+
36
+ interface ProfileProps {
37
+ readonly open: boolean;
38
+ readonly onOpen: () => void;
39
+ readonly triggerRef: RefObject<View | null>;
40
+ readonly id: string;
41
+ readonly profile: NavigationProfile;
42
+ readonly theme: NavigationTheme;
43
+ readonly bar: boolean;
44
+ readonly collapsed: boolean;
45
+ readonly pathname: string;
46
+ readonly onNavigate: Navigate;
47
+ readonly roving: RovingItemProps;
48
+ readonly onLayout?: (event: LayoutChangeEvent) => void;
49
+ }
50
+ export function profileIsActive(profile: NavigationProfile, pathname: string): boolean {
51
+ return profile.href !== undefined
52
+ ? navigationMatches({ id: 'profile', label: profile.label, href: profile.href }, pathname)
53
+ : resolveActiveMenuEntry(profile.menu, pathname) !== null;
54
+ }
55
+ export function Profile({
56
+ profile,
57
+ open,
58
+ onOpen,
59
+ triggerRef,
60
+ id,
61
+ theme,
62
+ bar,
63
+ collapsed,
64
+ pathname,
65
+ onNavigate,
66
+ roving,
67
+ onLayout,
68
+ }: ProfileProps): ReactNode {
69
+ const { fontScale } = useWindowDimensions();
70
+ const active = profileIsActive(profile, pathname);
71
+ return (
72
+ <View
73
+ style={bar ? styles.barSection : styles.profile}
74
+ testID="navigation-profile"
75
+ onLayout={onLayout}
76
+ >
77
+ <Target
78
+ label={profile.label}
79
+ subtitle={profile.subtitle}
80
+ selected={active}
81
+ theme={theme}
82
+ bar={bar}
83
+ collapsed={collapsed}
84
+ roving={roving}
85
+ triggerRef={triggerRef}
86
+ {...(profile.href === undefined
87
+ ? { expanded: open, controls: id, menu: true }
88
+ : { href: profile.href })}
89
+ onPress={(event) => {
90
+ if (profile.href !== undefined) follow(profile.href, event, onNavigate);
91
+ else onOpen();
92
+ }}
93
+ >
94
+ <Avatar
95
+ profile={profile}
96
+ active={active}
97
+ theme={theme}
98
+ style={bar ? compactVisualStyle(fontScale) : undefined}
99
+ />
100
+ </Target>
101
+ </View>
102
+ );
103
+ }
104
+
105
+ export function useNavigationBarHeight(
106
+ bottomInset = 0,
107
+ theme?: NavigationTheme,
108
+ slotHeight = 0,
109
+ ): number {
110
+ const { fontScale } = useWindowDimensions();
111
+ return getNavigationBarHeight(fontScale, bottomInset, { ...barMetrics(theme), slotHeight });
112
+ }
113
+
114
+ export function useCompactBarScroll(selectedIndex: number): CompactBarScroll {
115
+ const ref = useRef<ScrollView>(null);
116
+ const viewport = useRef(0);
117
+ const content = useRef(0);
118
+ const offset = useRef(0);
119
+ const frames = useRef(new Map<number, { x: number; width: number }>());
120
+ const revealSelected = useCallback(() => {
121
+ const frame = frames.current.get(selectedIndex);
122
+ if (frame === undefined || viewport.current === 0 || content.current === 0) return;
123
+ if (frame.x >= offset.current && frame.x + frame.width <= offset.current + viewport.current)
124
+ return;
125
+ const x = Math.max(
126
+ 0,
127
+ Math.min(frame.x + (frame.width - viewport.current) / 2, content.current - viewport.current),
128
+ );
129
+ ref.current?.scrollTo({ x, animated: false });
130
+ offset.current = x;
131
+ }, [selectedIndex]);
132
+ useEffect(revealSelected, [revealSelected]);
133
+ return {
134
+ scrollProps: {
135
+ ref,
136
+ onLayout: (event: LayoutChangeEvent) => {
137
+ viewport.current = event.nativeEvent.layout.width;
138
+ revealSelected();
139
+ },
140
+ onContentSizeChange: (width: number) => {
141
+ content.current = width;
142
+ revealSelected();
143
+ },
144
+ onScroll: (event: NativeSyntheticEvent<NativeScrollEvent>) => {
145
+ offset.current = event.nativeEvent.contentOffset.x;
146
+ },
147
+ },
148
+ itemLayout: (index: number) => (event: LayoutChangeEvent) => {
149
+ frames.current.set(index, event.nativeEvent.layout);
150
+ revealSelected();
151
+ },
152
+ };
153
+ }
@@ -0,0 +1,102 @@
1
+ import { useId, useRef, useState, type ReactNode } from 'react';
2
+ import { Platform, Text, View } from 'react-native';
3
+ import { announce, type OverlayBackgroundProps } from '@baukit/a11y-core';
4
+ import { resolveActiveNavigation, type NavigationItem } from './index.js';
5
+ import { Menu } from './native-menu.js';
6
+ import { Decorative, FocusablePressable } from './native-primitives.js';
7
+ import { styles } from './native-styles.js';
8
+ import {
9
+ textStyle,
10
+ type Navigate,
11
+ type NavigationIcon,
12
+ type NavigationInsets,
13
+ type NavigationTheme,
14
+ } from './native-theme.js';
15
+
16
+ export interface SectionPickerProps {
17
+ readonly replace?: boolean;
18
+ readonly closeLabel: string;
19
+ readonly item: NavigationItem<NavigationIcon>;
20
+ readonly pathname: string;
21
+ readonly onNavigate: Navigate;
22
+ readonly theme: NavigationTheme;
23
+ readonly insets?: NavigationInsets;
24
+ }
25
+ export function SectionPicker({
26
+ replace = false,
27
+ item,
28
+ pathname,
29
+ onNavigate,
30
+ theme,
31
+ closeLabel,
32
+ insets,
33
+ }: SectionPickerProps): ReactNode {
34
+ const [open, setOpen] = useState(false);
35
+ const [openedAt, setOpenedAt] = useState(pathname);
36
+ if (openedAt !== pathname) {
37
+ setOpenedAt(pathname);
38
+ setOpen(false);
39
+ }
40
+ const triggerRef = useRef<View>(null);
41
+ const id = useId();
42
+ const active = resolveActiveNavigation([item], pathname).subItem ?? item.children?.[0];
43
+ const entries = item.children ?? [];
44
+ if (entries.length === 0) return null;
45
+ const renderBackground = (backgroundProps: OverlayBackgroundProps) => (
46
+ <View {...backgroundProps} role="navigation" accessibilityLabel={item.label}>
47
+ <FocusablePressable
48
+ theme={theme}
49
+ unfocusedBorderColor={theme.border}
50
+ ref={triggerRef}
51
+ {...(Platform.OS === 'web'
52
+ ? { 'aria-controls': id, 'aria-haspopup': 'menu' as const }
53
+ : {})}
54
+ accessibilityRole="button"
55
+ accessibilityLabel={`${item.label}, ${active?.label ?? ''}`}
56
+ accessibilityState={{ expanded: open }}
57
+ onPress={() => {
58
+ setOpen(true);
59
+ }}
60
+ style={[
61
+ styles.picker,
62
+ {
63
+ backgroundColor: theme.background,
64
+ borderColor: theme.border,
65
+ borderRadius: theme.radius,
66
+ padding: theme.spacing,
67
+ },
68
+ ]}
69
+ >
70
+ <View>
71
+ <Text style={{ ...textStyle(theme), color: theme.muted }}>{item.label}</Text>
72
+ <Text style={{ ...textStyle(theme), color: theme.text }}>{active?.label}</Text>
73
+ </View>
74
+ <Decorative>
75
+ <Text style={{ ...textStyle(theme), color: theme.text }}>⌄</Text>
76
+ </Decorative>
77
+ </FocusablePressable>
78
+ </View>
79
+ );
80
+ return (
81
+ <Menu
82
+ renderBackground={renderBackground}
83
+ entries={entries}
84
+ closeLabel={closeLabel}
85
+ pathname={pathname}
86
+ label={item.label}
87
+ visible={open}
88
+ id={id}
89
+ triggerRef={triggerRef}
90
+ theme={theme}
91
+ insets={insets}
92
+ onClose={() => {
93
+ setOpen(false);
94
+ }}
95
+ onNavigate={(href) => {
96
+ announce(entries.find((entry) => entry.href === href)?.label ?? item.label);
97
+ if (replace) onNavigate(href, { replace: true });
98
+ else onNavigate(href);
99
+ }}
100
+ />
101
+ );
102
+ }
@@ -0,0 +1,50 @@
1
+ import { StyleSheet } from 'react-native';
2
+ import { NAVIGATION_BAR_DIMENSIONS, NAVIGATION_DIMENSIONS } from './index.js';
3
+
4
+ export const styles = StyleSheet.create({
5
+ labelGroup: { minWidth: 0, flexShrink: 1 },
6
+ menuProfile: { padding: 8 },
7
+ target: {
8
+ padding: NAVIGATION_BAR_DIMENSIONS.targetPadding,
9
+ },
10
+ railTarget: { flexDirection: 'row', alignItems: 'center' },
11
+ collapsedTarget: { justifyContent: 'center' },
12
+ barTarget: { flexDirection: 'column', alignItems: 'center', justifyContent: 'center', flex: 1 },
13
+ bar: {
14
+ flexDirection: 'column',
15
+ minHeight: NAVIGATION_DIMENSIONS.nativeBar,
16
+ borderTopWidth: NAVIGATION_BAR_DIMENSIONS.border,
17
+ width: '100%',
18
+ },
19
+ rail: { borderRightWidth: 1, height: '100%' },
20
+ slots: { flexShrink: 0 },
21
+ barSlots: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
22
+ slot: { minWidth: 0, flexShrink: 1 },
23
+ barBrand: { flexShrink: 0 },
24
+ railItems: { flex: 1 },
25
+ barItems: { width: '100%', flexGrow: 0, flexShrink: 0 },
26
+ barContent: { flexDirection: 'row', flexGrow: 1, minWidth: '100%' },
27
+ barSection: { flex: 1, minWidth: NAVIGATION_DIMENSIONS.target },
28
+ children: { marginLeft: 20, paddingLeft: 8, borderLeftWidth: 1 },
29
+ profile: { position: 'relative', marginTop: 'auto', paddingTop: 8, borderTopWidth: 1 },
30
+ avatar: {
31
+ width: NAVIGATION_DIMENSIONS.avatar,
32
+ height: NAVIGATION_DIMENSIONS.avatar,
33
+ borderRadius: NAVIGATION_DIMENSIONS.avatar / 2,
34
+ alignItems: 'center',
35
+ justifyContent: 'center',
36
+ },
37
+ modal: { flex: 1, justifyContent: 'flex-end' },
38
+ menu: { borderWidth: 1, padding: 8, maxHeight: '80%' },
39
+ menuItem: {
40
+ justifyContent: 'center',
41
+ padding: 8,
42
+ },
43
+ picker: {
44
+ flexDirection: 'row',
45
+ alignItems: 'center',
46
+ justifyContent: 'space-between',
47
+ borderWidth: 1,
48
+ width: '100%',
49
+ },
50
+ });