@ankhorage/zora 4.5.0 → 5.0.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 (147) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +1 -1
  3. package/dist/index.d.ts +0 -12
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +0 -6
  6. package/dist/index.js.map +1 -1
  7. package/dist/metadata/componentMeta.d.ts.map +1 -1
  8. package/dist/metadata/componentMeta.js +0 -12
  9. package/dist/metadata/componentMeta.js.map +1 -1
  10. package/dist/registry.d.ts.map +1 -1
  11. package/dist/registry.js +0 -12
  12. package/dist/registry.js.map +1 -1
  13. package/package.json +1 -1
  14. package/src/audit.test.ts +0 -29
  15. package/src/index.ts +0 -23
  16. package/src/interactionPolicy.test.ts +0 -17
  17. package/src/metadata/componentMeta.ts +0 -12
  18. package/src/registry.ts +0 -12
  19. package/src/showcaseCoverage.test.ts +0 -6
  20. package/src/theme/themeScopeStructure.test.ts +0 -4
  21. package/dist/components/drawer/Drawer.d.ts +0 -7
  22. package/dist/components/drawer/Drawer.d.ts.map +0 -1
  23. package/dist/components/drawer/Drawer.js +0 -36
  24. package/dist/components/drawer/Drawer.js.map +0 -1
  25. package/dist/components/drawer/index.d.ts +0 -3
  26. package/dist/components/drawer/index.d.ts.map +0 -1
  27. package/dist/components/drawer/index.js +0 -2
  28. package/dist/components/drawer/index.js.map +0 -1
  29. package/dist/components/drawer/meta.d.ts +0 -9
  30. package/dist/components/drawer/meta.d.ts.map +0 -1
  31. package/dist/components/drawer/meta.js +0 -9
  32. package/dist/components/drawer/meta.js.map +0 -1
  33. package/dist/components/drawer/types.d.ts +0 -10
  34. package/dist/components/drawer/types.d.ts.map +0 -1
  35. package/dist/components/drawer/types.js +0 -2
  36. package/dist/components/drawer/types.js.map +0 -1
  37. package/dist/components/navigation-item/NavigationItem.d.ts +0 -7
  38. package/dist/components/navigation-item/NavigationItem.d.ts.map +0 -1
  39. package/dist/components/navigation-item/NavigationItem.js +0 -21
  40. package/dist/components/navigation-item/NavigationItem.js.map +0 -1
  41. package/dist/components/navigation-item/index.d.ts +0 -3
  42. package/dist/components/navigation-item/index.d.ts.map +0 -1
  43. package/dist/components/navigation-item/index.js +0 -2
  44. package/dist/components/navigation-item/index.js.map +0 -1
  45. package/dist/components/navigation-item/meta.d.ts +0 -9
  46. package/dist/components/navigation-item/meta.d.ts.map +0 -1
  47. package/dist/components/navigation-item/meta.js +0 -9
  48. package/dist/components/navigation-item/meta.js.map +0 -1
  49. package/dist/components/navigation-item/types.d.ts +0 -23
  50. package/dist/components/navigation-item/types.d.ts.map +0 -1
  51. package/dist/components/navigation-item/types.js +0 -2
  52. package/dist/components/navigation-item/types.js.map +0 -1
  53. package/dist/components/navigation-list/NavigationList.d.ts +0 -7
  54. package/dist/components/navigation-list/NavigationList.d.ts.map +0 -1
  55. package/dist/components/navigation-list/NavigationList.js +0 -29
  56. package/dist/components/navigation-list/NavigationList.js.map +0 -1
  57. package/dist/components/navigation-list/index.d.ts +0 -3
  58. package/dist/components/navigation-list/index.d.ts.map +0 -1
  59. package/dist/components/navigation-list/index.js +0 -2
  60. package/dist/components/navigation-list/index.js.map +0 -1
  61. package/dist/components/navigation-list/meta.d.ts +0 -9
  62. package/dist/components/navigation-list/meta.d.ts.map +0 -1
  63. package/dist/components/navigation-list/meta.js +0 -9
  64. package/dist/components/navigation-list/meta.js.map +0 -1
  65. package/dist/components/navigation-list/types.d.ts +0 -15
  66. package/dist/components/navigation-list/types.d.ts.map +0 -1
  67. package/dist/components/navigation-list/types.js +0 -2
  68. package/dist/components/navigation-list/types.js.map +0 -1
  69. package/dist/internal/resolveZoraNavigationItems.d.ts +0 -65
  70. package/dist/internal/resolveZoraNavigationItems.d.ts.map +0 -1
  71. package/dist/internal/resolveZoraNavigationItems.js +0 -56
  72. package/dist/internal/resolveZoraNavigationItems.js.map +0 -1
  73. package/dist/patterns/responsive-panel/ResponsivePanel.d.ts +0 -16
  74. package/dist/patterns/responsive-panel/ResponsivePanel.d.ts.map +0 -1
  75. package/dist/patterns/responsive-panel/ResponsivePanel.js +0 -101
  76. package/dist/patterns/responsive-panel/ResponsivePanel.js.map +0 -1
  77. package/dist/patterns/responsive-panel/index.d.ts +0 -3
  78. package/dist/patterns/responsive-panel/index.d.ts.map +0 -1
  79. package/dist/patterns/responsive-panel/index.js +0 -3
  80. package/dist/patterns/responsive-panel/index.js.map +0 -1
  81. package/dist/patterns/responsive-panel/meta.d.ts +0 -9
  82. package/dist/patterns/responsive-panel/meta.d.ts.map +0 -1
  83. package/dist/patterns/responsive-panel/meta.js +0 -9
  84. package/dist/patterns/responsive-panel/meta.js.map +0 -1
  85. package/dist/patterns/responsive-panel/types.d.ts +0 -23
  86. package/dist/patterns/responsive-panel/types.d.ts.map +0 -1
  87. package/dist/patterns/responsive-panel/types.js +0 -2
  88. package/dist/patterns/responsive-panel/types.js.map +0 -1
  89. package/dist/patterns/zora-drawer-content/ZoraDrawerContent.d.ts +0 -9
  90. package/dist/patterns/zora-drawer-content/ZoraDrawerContent.d.ts.map +0 -1
  91. package/dist/patterns/zora-drawer-content/ZoraDrawerContent.js +0 -31
  92. package/dist/patterns/zora-drawer-content/ZoraDrawerContent.js.map +0 -1
  93. package/dist/patterns/zora-drawer-content/index.d.ts +0 -3
  94. package/dist/patterns/zora-drawer-content/index.d.ts.map +0 -1
  95. package/dist/patterns/zora-drawer-content/index.js +0 -2
  96. package/dist/patterns/zora-drawer-content/index.js.map +0 -1
  97. package/dist/patterns/zora-drawer-content/meta.d.ts +0 -9
  98. package/dist/patterns/zora-drawer-content/meta.d.ts.map +0 -1
  99. package/dist/patterns/zora-drawer-content/meta.js +0 -9
  100. package/dist/patterns/zora-drawer-content/meta.js.map +0 -1
  101. package/dist/patterns/zora-drawer-content/types.d.ts +0 -15
  102. package/dist/patterns/zora-drawer-content/types.d.ts.map +0 -1
  103. package/dist/patterns/zora-drawer-content/types.js +0 -2
  104. package/dist/patterns/zora-drawer-content/types.js.map +0 -1
  105. package/dist/patterns/zora-tab-bar/ZoraTabBar.d.ts +0 -9
  106. package/dist/patterns/zora-tab-bar/ZoraTabBar.d.ts.map +0 -1
  107. package/dist/patterns/zora-tab-bar/ZoraTabBar.js +0 -89
  108. package/dist/patterns/zora-tab-bar/ZoraTabBar.js.map +0 -1
  109. package/dist/patterns/zora-tab-bar/index.d.ts +0 -3
  110. package/dist/patterns/zora-tab-bar/index.d.ts.map +0 -1
  111. package/dist/patterns/zora-tab-bar/index.js +0 -2
  112. package/dist/patterns/zora-tab-bar/index.js.map +0 -1
  113. package/dist/patterns/zora-tab-bar/meta.d.ts +0 -9
  114. package/dist/patterns/zora-tab-bar/meta.d.ts.map +0 -1
  115. package/dist/patterns/zora-tab-bar/meta.js +0 -9
  116. package/dist/patterns/zora-tab-bar/meta.js.map +0 -1
  117. package/dist/patterns/zora-tab-bar/types.d.ts +0 -19
  118. package/dist/patterns/zora-tab-bar/types.d.ts.map +0 -1
  119. package/dist/patterns/zora-tab-bar/types.js +0 -2
  120. package/dist/patterns/zora-tab-bar/types.js.map +0 -1
  121. package/src/components/drawer/Drawer.tsx +0 -59
  122. package/src/components/drawer/index.ts +0 -2
  123. package/src/components/drawer/meta.ts +0 -10
  124. package/src/components/drawer/types.ts +0 -17
  125. package/src/components/navigation-item/NavigationItem.tsx +0 -41
  126. package/src/components/navigation-item/index.ts +0 -6
  127. package/src/components/navigation-item/meta.ts +0 -10
  128. package/src/components/navigation-item/types.ts +0 -26
  129. package/src/components/navigation-list/NavigationList.tsx +0 -68
  130. package/src/components/navigation-list/index.ts +0 -2
  131. package/src/components/navigation-list/meta.ts +0 -10
  132. package/src/components/navigation-list/types.ts +0 -17
  133. package/src/internal/resolveZoraNavigationItems.test.ts +0 -174
  134. package/src/internal/resolveZoraNavigationItems.ts +0 -157
  135. package/src/navigationExports.test.ts +0 -15
  136. package/src/patterns/responsive-panel/ResponsivePanel.tsx +0 -172
  137. package/src/patterns/responsive-panel/index.ts +0 -2
  138. package/src/patterns/responsive-panel/meta.ts +0 -10
  139. package/src/patterns/responsive-panel/types.ts +0 -25
  140. package/src/patterns/zora-drawer-content/ZoraDrawerContent.tsx +0 -60
  141. package/src/patterns/zora-drawer-content/index.ts +0 -2
  142. package/src/patterns/zora-drawer-content/meta.ts +0 -10
  143. package/src/patterns/zora-drawer-content/types.ts +0 -20
  144. package/src/patterns/zora-tab-bar/ZoraTabBar.tsx +0 -157
  145. package/src/patterns/zora-tab-bar/index.ts +0 -2
  146. package/src/patterns/zora-tab-bar/meta.ts +0 -10
  147. package/src/patterns/zora-tab-bar/types.ts +0 -18
@@ -1,157 +0,0 @@
1
- import type React from 'react';
2
-
3
- import type {
4
- ZoraNavigationRouteMetadata,
5
- ZoraNavigationRouteState,
6
- } from '../components/navigation-item';
7
- import type { ZoraNavigationRouteMap } from '../components/navigation-list';
8
-
9
- interface ZoraNavigationDescriptorOptions {
10
- title?: string;
11
- tabBarLabel?: unknown;
12
- drawerLabel?: unknown;
13
- }
14
-
15
- export interface ZoraNavigationDescriptor {
16
- options?: ZoraNavigationDescriptorOptions;
17
- }
18
-
19
- export type ZoraNavigationDescriptors = Readonly<
20
- Record<string, ZoraNavigationDescriptor | undefined>
21
- >;
22
-
23
- export interface ZoraNavigationState {
24
- index: number;
25
- routes: readonly ZoraNavigationRouteState[];
26
- }
27
-
28
- interface ZoraTabPressEvent {
29
- type: 'tabPress';
30
- target: string;
31
- canPreventDefault: true;
32
- }
33
-
34
- interface ZoraTabPressEventResult {
35
- defaultPrevented: boolean;
36
- }
37
-
38
- export interface ZoraTabBarNavigation {
39
- emit?: (event: ZoraTabPressEvent) => ZoraTabPressEventResult;
40
- navigate: (name: string) => void;
41
- }
42
-
43
- export interface ZoraDrawerNavigation {
44
- navigate: (name: string) => void;
45
- closeDrawer?: () => void;
46
- }
47
-
48
- export interface ZoraResolvedNavigationItem {
49
- route: ZoraNavigationRouteState;
50
- metadata?: ZoraNavigationRouteMetadata;
51
- label: React.ReactNode;
52
- active: boolean;
53
- disabled: boolean;
54
- }
55
-
56
- export type ZoraRouteLabelSource = 'routeMap' | 'descriptor' | 'name';
57
-
58
- export function resolveRouteLabel({
59
- route,
60
- metadata,
61
- descriptor,
62
- kind,
63
- }: {
64
- route: ZoraNavigationRouteState;
65
- metadata: ZoraNavigationRouteMetadata | undefined;
66
- descriptor: ZoraNavigationDescriptor | undefined;
67
- kind: 'tab' | 'drawer';
68
- }): { label: React.ReactNode; source: ZoraRouteLabelSource } {
69
- if (metadata?.label !== undefined) {
70
- return { label: metadata.label, source: 'routeMap' };
71
- }
72
-
73
- const options = descriptor?.options;
74
- const configuredLabel = kind === 'tab' ? options?.tabBarLabel : options?.drawerLabel;
75
- const fallback =
76
- configuredLabel === undefined || typeof configuredLabel === 'function'
77
- ? options?.title
78
- : configuredLabel;
79
-
80
- if (fallback !== undefined) {
81
- return { label: fallback as React.ReactNode, source: 'descriptor' };
82
- }
83
-
84
- return { label: route.name, source: 'name' };
85
- }
86
-
87
- export function resolveNavigationItems({
88
- state,
89
- descriptors,
90
- routeMap,
91
- kind,
92
- }: {
93
- state: ZoraNavigationState;
94
- descriptors?: ZoraNavigationDescriptors | undefined;
95
- routeMap?: ZoraNavigationRouteMap | undefined;
96
- kind: 'tab' | 'drawer';
97
- }): readonly ZoraResolvedNavigationItem[] {
98
- const activeRoute = state.routes[state.index];
99
-
100
- return state.routes.map((route) => {
101
- const metadata = routeMap?.[route.name];
102
- const descriptor = descriptors?.[route.key];
103
- const { label } = resolveRouteLabel({ route, metadata, descriptor, kind });
104
- const disabled = Boolean(metadata?.disabled);
105
-
106
- return {
107
- route,
108
- metadata,
109
- label,
110
- active: activeRoute ? activeRoute.key === route.key : false,
111
- disabled,
112
- };
113
- });
114
- }
115
-
116
- export function createTabBarItemPressHandler({
117
- item,
118
- navigation,
119
- }: {
120
- item: ZoraResolvedNavigationItem;
121
- navigation: ZoraTabBarNavigation;
122
- }): (() => void) | undefined {
123
- if (item.disabled || item.active) {
124
- return undefined;
125
- }
126
-
127
- return () => {
128
- const result = navigation.emit?.({
129
- type: 'tabPress',
130
- target: item.route.key,
131
- canPreventDefault: true,
132
- });
133
-
134
- if (result?.defaultPrevented) {
135
- return;
136
- }
137
-
138
- navigation.navigate(item.route.name);
139
- };
140
- }
141
-
142
- export function createDrawerItemPressHandler({
143
- item,
144
- navigation,
145
- }: {
146
- item: ZoraResolvedNavigationItem;
147
- navigation: ZoraDrawerNavigation;
148
- }): (() => void) | undefined {
149
- if (item.disabled) {
150
- return undefined;
151
- }
152
-
153
- return () => {
154
- navigation.navigate(item.route.name);
155
- navigation.closeDrawer?.();
156
- };
157
- }
@@ -1,15 +0,0 @@
1
- import { readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
-
4
- import { describe, expect, test } from 'bun:test';
5
-
6
- describe('navigation exports', () => {
7
- test('exports navigation chrome from src/index.ts', () => {
8
- const source = readFileSync(join(process.cwd(), 'src', 'index.ts'), 'utf8');
9
-
10
- expect(source).toContain('export { NavigationItem }');
11
- expect(source).toContain('export { NavigationList }');
12
- expect(source).toContain('export { ZoraTabBar }');
13
- expect(source).toContain('export { ZoraDrawerContent }');
14
- });
15
- });
@@ -1,172 +0,0 @@
1
- import React from 'react';
2
- import { ScrollView, StyleSheet, View } from 'react-native';
3
-
4
- import { Drawer } from '../../components/drawer';
5
- import { Modal } from '../../components/modal';
6
- import type { ZoraContentWidth } from '../../internal/recipes';
7
- import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
8
- import { Panel } from '../panel';
9
- import type { ResponsivePanelProps, ResponsivePanelScroll, ResponsivePanelSize } from './types';
10
-
11
- function resolvePanelWidth(size: ResponsivePanelSize): number {
12
- switch (size) {
13
- case 'compact':
14
- return 300;
15
- case 'wide':
16
- return 420;
17
- case 'extraWide':
18
- return 560;
19
- case 'default':
20
- default:
21
- return 360;
22
- }
23
- }
24
-
25
- function resolveModalWidth(size: ResponsivePanelSize | undefined): ZoraContentWidth | undefined {
26
- switch (size) {
27
- case 'compact':
28
- return 'narrow';
29
- case 'wide':
30
- case 'extraWide':
31
- return 'wide';
32
- case 'default':
33
- return 'default';
34
- default:
35
- return undefined;
36
- }
37
- }
38
-
39
- function renderPanelBody(children: React.ReactNode, scroll: ResponsivePanelScroll) {
40
- if (children == null) return null;
41
-
42
- if (scroll === 'content') {
43
- return (
44
- <ScrollView
45
- contentContainerStyle={styles.scrollContent}
46
- keyboardShouldPersistTaps="handled"
47
- showsVerticalScrollIndicator
48
- style={styles.scrollBody}
49
- >
50
- {children}
51
- </ScrollView>
52
- );
53
- }
54
-
55
- return children;
56
- }
57
-
58
- function ResponsivePanelInner({
59
- themeId: _themeId,
60
- mode: _mode,
61
- title,
62
- description,
63
- actions,
64
- footer,
65
- children,
66
- open,
67
- onOpenChange,
68
- side = 'right',
69
- desktopMode = 'inline',
70
- mobileMode = 'drawer',
71
- compact = true,
72
- size,
73
- scroll = 'none',
74
- testID,
75
- interactionPolicy,
76
- }: ResponsivePanelProps) {
77
- if (!open) return null;
78
-
79
- const passive = interactionPolicy === 'passive';
80
- const body = renderPanelBody(children, scroll);
81
-
82
- // For now, we assume desktopMode determines the rendering.
83
- // In a real app, this would react to window size.
84
- if (desktopMode === 'floating') {
85
- if (mobileMode === 'modal') {
86
- const modalWidth = resolveModalWidth(size);
87
-
88
- return (
89
- <Modal
90
- description={description}
91
- footer={footer}
92
- interactionPolicy={interactionPolicy}
93
- onDismiss={() => {
94
- if (passive) return;
95
-
96
- onOpenChange(false);
97
- }}
98
- testID={testID}
99
- title={title}
100
- visible={open}
101
- width={modalWidth}
102
- >
103
- {body}
104
- </Modal>
105
- );
106
- }
107
-
108
- return (
109
- <Drawer
110
- description={description}
111
- footer={footer}
112
- interactionPolicy={interactionPolicy}
113
- onDismiss={() => {
114
- if (passive) return;
115
-
116
- onOpenChange(false);
117
- }}
118
- position={side}
119
- testID={testID}
120
- title={title}
121
- visible={open}
122
- >
123
- {body}
124
- </Drawer>
125
- );
126
- }
127
-
128
- const panel = (
129
- <Panel
130
- actions={actions}
131
- compact={compact}
132
- description={description}
133
- footer={footer}
134
- interactionPolicy={interactionPolicy}
135
- testID={testID}
136
- title={title}
137
- >
138
- {body}
139
- </Panel>
140
- );
141
-
142
- if (size === undefined) return panel;
143
-
144
- return <View style={[styles.inlineSizedPanel, { width: resolvePanelWidth(size) }]}>{panel}</View>;
145
- }
146
-
147
- const styles = StyleSheet.create({
148
- inlineSizedPanel: {
149
- maxWidth: '100%',
150
- },
151
- scrollBody: {
152
- flexGrow: 0,
153
- maxHeight: '100%',
154
- },
155
- scrollContent: {
156
- flexGrow: 1,
157
- },
158
- });
159
-
160
- /***
161
- * Adaptive secondary surface that can render as an inline panel, drawer, or modal.
162
- *
163
- * Use `ResponsivePanel` for tool panes and admin/detail flows that need the same
164
- * content to work across compact mobile screens and wider desktop layouts.
165
- *
166
-
167
- * @example Scrollable wide panel
168
- * ```tsx
169
- * <ResponsivePanel open title="APIs" size="wide" scroll="content">...</ResponsivePanel>
170
- * ```
171
- */
172
- export const ResponsivePanel = withZoraThemeScope(ResponsivePanelInner);
@@ -1,2 +0,0 @@
1
- export * from './ResponsivePanel';
2
- export * from './types';
@@ -1,10 +0,0 @@
1
- import type { ZoraComponentMeta } from '../../metadata';
2
-
3
- export const responsivePanelMeta = {
4
- name: 'ResponsivePanel',
5
- category: 'pattern',
6
- directManifestNode: false,
7
- allowedChildren: [],
8
- note: 'Responsive panel pattern; not represented as a manifest node in v1.',
9
- props: {},
10
- } as const satisfies ZoraComponentMeta;
@@ -1,25 +0,0 @@
1
- import type React from 'react';
2
-
3
- import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
4
-
5
- export type ResponsivePanelSide = 'left' | 'right';
6
- export type ResponsivePanelDesktopMode = 'inline' | 'floating';
7
- export type ResponsivePanelMobileMode = 'drawer' | 'modal';
8
- export type ResponsivePanelSize = 'compact' | 'default' | 'wide' | 'extraWide';
9
- export type ResponsivePanelScroll = 'none' | 'content';
10
-
11
- export interface ResponsivePanelProps extends ZoraBaseProps {
12
- title?: React.ReactNode;
13
- description?: React.ReactNode;
14
- actions?: React.ReactNode;
15
- footer?: React.ReactNode;
16
- children?: React.ReactNode;
17
- open: boolean;
18
- onOpenChange: (open: boolean) => void;
19
- side?: ResponsivePanelSide;
20
- desktopMode?: ResponsivePanelDesktopMode;
21
- mobileMode?: ResponsivePanelMobileMode;
22
- compact?: boolean;
23
- size?: ResponsivePanelSize;
24
- scroll?: ResponsivePanelScroll;
25
- }
@@ -1,60 +0,0 @@
1
- import { DrawerNavigation as SurfaceDrawerNavigation } from '@ankhorage/surface';
2
- import React from 'react';
3
-
4
- import {
5
- createDrawerItemPressHandler,
6
- resolveNavigationItems,
7
- } from '../../internal/resolveZoraNavigationItems';
8
- import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
9
- import type { ZoraDrawerContentProps } from './types';
10
-
11
- function ZoraDrawerContentInner({
12
- themeId: _themeId,
13
- mode: _mode,
14
- interactionPolicy,
15
- state,
16
- navigation,
17
- descriptors,
18
- routeMap,
19
- compact = false,
20
- header,
21
- footer,
22
- testID,
23
- }: ZoraDrawerContentProps) {
24
- const resolved = resolveNavigationItems({
25
- state,
26
- descriptors,
27
- routeMap,
28
- kind: 'drawer',
29
- });
30
-
31
- const items = resolved.map((item) => ({
32
- id: item.route.key,
33
- label: item.label,
34
- icon: item.metadata?.icon,
35
- badge: item.metadata?.badge,
36
- active: item.active,
37
- disabled: item.disabled,
38
- onPress: createDrawerItemPressHandler({ item, navigation }),
39
- accessibilityLabel: item.metadata?.accessibilityLabel,
40
- testID: item.metadata?.testID,
41
- }));
42
-
43
- return (
44
- <SurfaceDrawerNavigation
45
- compact={compact}
46
- footer={footer}
47
- header={header}
48
- interactionPolicy={interactionPolicy}
49
- items={items}
50
- testID={testID}
51
- />
52
- );
53
- }
54
-
55
- /***
56
- * Standard drawer content pattern for ZORA navigation lists.
57
- *
58
-
59
- */
60
- export const ZoraDrawerContent = withZoraThemeScope(ZoraDrawerContentInner);
@@ -1,2 +0,0 @@
1
- export type { ZoraDrawerContentProps } from './types';
2
- export { ZoraDrawerContent } from './ZoraDrawerContent';
@@ -1,10 +0,0 @@
1
- import type { ZoraComponentMeta } from '../../metadata';
2
-
3
- export const zoraDrawerContentMeta = {
4
- name: 'ZoraDrawerContent',
5
- category: 'pattern',
6
- directManifestNode: false,
7
- allowedChildren: [],
8
- note: 'Navigation chrome pattern; not represented as a manifest node in v1.',
9
- props: {},
10
- } as const satisfies ZoraComponentMeta;
@@ -1,20 +0,0 @@
1
- import type React from 'react';
2
-
3
- import type { ZoraNavigationRouteMap } from '../../components/navigation-list';
4
- import type {
5
- ZoraDrawerNavigation,
6
- ZoraNavigationDescriptors,
7
- ZoraNavigationState,
8
- } from '../../internal/resolveZoraNavigationItems';
9
- import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
10
-
11
- export interface ZoraDrawerContentProps extends ZoraBaseProps {
12
- state: ZoraNavigationState;
13
- navigation: ZoraDrawerNavigation;
14
- descriptors?: ZoraNavigationDescriptors | undefined;
15
- routeMap?: ZoraNavigationRouteMap | undefined;
16
- compact?: boolean;
17
- header?: React.ReactNode;
18
- footer?: React.ReactNode;
19
- testID?: string;
20
- }
@@ -1,157 +0,0 @@
1
- import React from 'react';
2
- import { Pressable, Text as ReactNativeText } from 'react-native';
3
-
4
- import { Icon } from '../../components/icon';
5
- import { Box, Surface } from '../../foundation';
6
- import {
7
- createTabBarItemPressHandler,
8
- resolveNavigationItems,
9
- } from '../../internal/resolveZoraNavigationItems';
10
- import { useZoraTheme } from '../../theme/useZoraTheme';
11
- import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
12
- import type { ZoraTabBarProps } from './types';
13
-
14
- function resolveAccessibilityLabel(
15
- label: React.ReactNode,
16
- explicitLabel?: string,
17
- ): string | undefined {
18
- if (explicitLabel !== undefined) {
19
- return explicitLabel;
20
- }
21
-
22
- if (typeof label === 'string') {
23
- return label;
24
- }
25
-
26
- if (typeof label === 'number') {
27
- return String(label);
28
- }
29
-
30
- return undefined;
31
- }
32
-
33
- function ZoraTabBarInner({
34
- themeId: _themeId,
35
- mode: _mode,
36
- interactionPolicy,
37
- state,
38
- navigation,
39
- descriptors,
40
- insets,
41
- routeMap,
42
- compact = false,
43
- chrome = 'raised',
44
- testID,
45
- }: ZoraTabBarProps) {
46
- const { theme } = useZoraTheme();
47
- const resolved = resolveNavigationItems({
48
- state,
49
- descriptors,
50
- routeMap,
51
- kind: 'tab',
52
- });
53
-
54
- const bottomInset = insets?.bottom ?? 0;
55
- const minHeight = compact ? 56 : 64;
56
- const labelSize = compact ? theme.typography.sizes.xs : theme.typography.sizes.s;
57
- const labelWeight = theme.typography.weights.medium;
58
- const content = (
59
- <Box
60
- bg="surface"
61
- style={{
62
- borderTopColor: theme.semantics.border.default,
63
- borderTopWidth: 1,
64
- flexDirection: 'row',
65
- minHeight: minHeight + bottomInset,
66
- paddingBottom: bottomInset,
67
- }}
68
- testID={testID}
69
- >
70
- {resolved.map((item) => {
71
- const { active } = item;
72
- const { disabled } = item;
73
- const contentColor = disabled
74
- ? theme.semantics.content.subtle
75
- : active
76
- ? theme.semantics.action.primary.base
77
- : theme.semantics.content.muted;
78
- const backgroundColor = active
79
- ? theme.semantics.action.primary.softBg
80
- : theme.semantics.surface.default;
81
-
82
- return (
83
- <Pressable
84
- accessibilityLabel={resolveAccessibilityLabel(
85
- item.label,
86
- item.metadata?.accessibilityLabel,
87
- )}
88
- accessibilityRole="tab"
89
- accessibilityState={{ selected: active, disabled }}
90
- disabled={disabled}
91
- key={item.route.key}
92
- onPress={
93
- interactionPolicy === 'passive'
94
- ? undefined
95
- : createTabBarItemPressHandler({ item, navigation })
96
- }
97
- style={{
98
- alignItems: 'center',
99
- backgroundColor,
100
- flex: 1,
101
- justifyContent: 'center',
102
- minHeight,
103
- opacity: disabled ? 0.48 : 1,
104
- paddingHorizontal: theme.spacing.s,
105
- paddingVertical: compact ? theme.spacing.xs : theme.spacing.s,
106
- }}
107
- testID={
108
- item.metadata?.testID ?? (testID ? `${testID}-item-${item.route.key}` : undefined)
109
- }
110
- >
111
- {item.metadata?.icon ? (
112
- <Icon
113
- {...item.metadata.icon}
114
- color={contentColor}
115
- size={compact ? theme.spacing.m : theme.spacing.l}
116
- />
117
- ) : null}
118
- <ReactNativeText
119
- numberOfLines={1}
120
- style={{
121
- color: contentColor,
122
- fontSize: labelSize,
123
- fontWeight: labelWeight,
124
- lineHeight: compact ? 16 : 20,
125
- marginTop: item.metadata?.icon ? theme.spacing.xs : 0,
126
- textAlign: 'center',
127
- }}
128
- >
129
- {item.label}
130
- </ReactNativeText>
131
- </Pressable>
132
- );
133
- })}
134
- </Box>
135
- );
136
-
137
- if (chrome === 'none') {
138
- return content;
139
- }
140
-
141
- return (
142
- <Surface
143
- interactionPolicy={interactionPolicy}
144
- testID={testID ? `${testID}-chrome` : undefined}
145
- variant="raised"
146
- >
147
- {content}
148
- </Surface>
149
- );
150
- }
151
-
152
- /***
153
- * Bottom tab bar pattern with badge support and active state styling.
154
- *
155
-
156
- */
157
- export const ZoraTabBar = withZoraThemeScope(ZoraTabBarInner);
@@ -1,2 +0,0 @@
1
- export type { ZoraTabBarProps } from './types';
2
- export { ZoraTabBar } from './ZoraTabBar';
@@ -1,10 +0,0 @@
1
- import type { ZoraComponentMeta } from '../../metadata';
2
-
3
- export const zoraTabBarMeta = {
4
- name: 'ZoraTabBar',
5
- category: 'pattern',
6
- directManifestNode: false,
7
- allowedChildren: [],
8
- note: 'Navigation chrome pattern; not represented as a manifest node in v1.',
9
- props: {},
10
- } as const satisfies ZoraComponentMeta;
@@ -1,18 +0,0 @@
1
- import type { ZoraNavigationRouteMap } from '../../components/navigation-list';
2
- import type {
3
- ZoraNavigationDescriptors,
4
- ZoraNavigationState,
5
- ZoraTabBarNavigation,
6
- } from '../../internal/resolveZoraNavigationItems';
7
- import type { ZoraBaseProps } from '../../theme/ZoraBaseProps';
8
-
9
- export interface ZoraTabBarProps extends ZoraBaseProps {
10
- state: ZoraNavigationState;
11
- navigation: ZoraTabBarNavigation;
12
- descriptors?: ZoraNavigationDescriptors | undefined;
13
- insets?: { top?: number; bottom?: number; left?: number; right?: number } | undefined;
14
- routeMap?: ZoraNavigationRouteMap | undefined;
15
- compact?: boolean;
16
- chrome?: 'none' | 'raised';
17
- testID?: string;
18
- }