@ankhorage/zora 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +41 -0
- package/dist/components/navigation-item/NavigationItem.d.ts +4 -0
- package/dist/components/navigation-item/NavigationItem.d.ts.map +1 -0
- package/dist/components/navigation-item/NavigationItem.js +18 -0
- package/dist/components/navigation-item/NavigationItem.js.map +1 -0
- package/dist/components/navigation-item/index.d.ts +3 -0
- package/dist/components/navigation-item/index.d.ts.map +1 -0
- package/dist/components/navigation-item/index.js +2 -0
- package/dist/components/navigation-item/index.js.map +1 -0
- package/dist/components/navigation-item/types.d.ts +23 -0
- package/dist/components/navigation-item/types.d.ts.map +1 -0
- package/dist/components/navigation-item/types.js +2 -0
- package/dist/components/navigation-item/types.js.map +1 -0
- package/dist/components/navigation-list/NavigationList.d.ts +4 -0
- package/dist/components/navigation-list/NavigationList.d.ts.map +1 -0
- package/dist/components/navigation-list/NavigationList.js +26 -0
- package/dist/components/navigation-list/NavigationList.js.map +1 -0
- package/dist/components/navigation-list/index.d.ts +3 -0
- package/dist/components/navigation-list/index.d.ts.map +1 -0
- package/dist/components/navigation-list/index.js +2 -0
- package/dist/components/navigation-list/index.js.map +1 -0
- package/dist/components/navigation-list/types.d.ts +15 -0
- package/dist/components/navigation-list/types.d.ts.map +1 -0
- package/dist/components/navigation-list/types.js +2 -0
- package/dist/components/navigation-list/types.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/resolveZoraNavigationItems.d.ts +64 -0
- package/dist/internal/resolveZoraNavigationItems.d.ts.map +1 -0
- package/dist/internal/resolveZoraNavigationItems.js +55 -0
- package/dist/internal/resolveZoraNavigationItems.js.map +1 -0
- package/dist/patterns/zora-drawer-content/ZoraDrawerContent.d.ts +4 -0
- package/dist/patterns/zora-drawer-content/ZoraDrawerContent.d.ts.map +1 -0
- package/dist/patterns/zora-drawer-content/ZoraDrawerContent.js +26 -0
- package/dist/patterns/zora-drawer-content/ZoraDrawerContent.js.map +1 -0
- package/dist/patterns/zora-drawer-content/index.d.ts +3 -0
- package/dist/patterns/zora-drawer-content/index.d.ts.map +1 -0
- package/dist/patterns/zora-drawer-content/index.js +2 -0
- package/dist/patterns/zora-drawer-content/index.js.map +1 -0
- package/dist/patterns/zora-drawer-content/types.d.ts +15 -0
- package/dist/patterns/zora-drawer-content/types.d.ts.map +1 -0
- package/dist/patterns/zora-drawer-content/types.js +2 -0
- package/dist/patterns/zora-drawer-content/types.js.map +1 -0
- package/dist/patterns/zora-tab-bar/ZoraTabBar.d.ts +4 -0
- package/dist/patterns/zora-tab-bar/ZoraTabBar.d.ts.map +1 -0
- package/dist/patterns/zora-tab-bar/ZoraTabBar.js +33 -0
- package/dist/patterns/zora-tab-bar/ZoraTabBar.js.map +1 -0
- package/dist/patterns/zora-tab-bar/index.d.ts +3 -0
- package/dist/patterns/zora-tab-bar/index.d.ts.map +1 -0
- package/dist/patterns/zora-tab-bar/index.js +2 -0
- package/dist/patterns/zora-tab-bar/index.js.map +1 -0
- package/dist/patterns/zora-tab-bar/types.d.ts +19 -0
- package/dist/patterns/zora-tab-bar/types.d.ts.map +1 -0
- package/dist/patterns/zora-tab-bar/types.js +2 -0
- package/dist/patterns/zora-tab-bar/types.js.map +1 -0
- package/package.json +2 -2
- package/src/audit.test.ts +29 -0
- package/src/components/navigation-item/NavigationItem.tsx +36 -0
- package/src/components/navigation-item/index.ts +6 -0
- package/src/components/navigation-item/types.ts +26 -0
- package/src/components/navigation-list/NavigationList.tsx +62 -0
- package/src/components/navigation-list/index.ts +2 -0
- package/src/components/navigation-list/types.ts +17 -0
- package/src/index.ts +12 -0
- package/src/internal/resolveZoraNavigationItems.test.ts +163 -0
- package/src/internal/resolveZoraNavigationItems.ts +156 -0
- package/src/navigationExports.test.ts +15 -0
- package/src/patterns/zora-drawer-content/ZoraDrawerContent.tsx +53 -0
- package/src/patterns/zora-drawer-content/index.ts +2 -0
- package/src/patterns/zora-drawer-content/types.ts +20 -0
- package/src/patterns/zora-tab-bar/ZoraTabBar.tsx +55 -0
- package/src/patterns/zora-tab-bar/index.ts +2 -0
- package/src/patterns/zora-tab-bar/types.ts +18 -0
- package/src/showcaseCoverage.test.ts +4 -0
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
state,
|
|
15
|
+
navigation,
|
|
16
|
+
descriptors,
|
|
17
|
+
routeMap,
|
|
18
|
+
compact = false,
|
|
19
|
+
header,
|
|
20
|
+
footer,
|
|
21
|
+
testID,
|
|
22
|
+
}: ZoraDrawerContentProps) {
|
|
23
|
+
const resolved = resolveNavigationItems({
|
|
24
|
+
state,
|
|
25
|
+
descriptors,
|
|
26
|
+
routeMap,
|
|
27
|
+
kind: 'drawer',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const items = resolved.map((item) => ({
|
|
31
|
+
id: item.route.key,
|
|
32
|
+
label: item.label,
|
|
33
|
+
icon: item.metadata?.icon,
|
|
34
|
+
badge: item.metadata?.badge,
|
|
35
|
+
active: item.active,
|
|
36
|
+
disabled: item.disabled,
|
|
37
|
+
onPress: createDrawerItemPressHandler({ item, navigation }),
|
|
38
|
+
accessibilityLabel: item.metadata?.accessibilityLabel,
|
|
39
|
+
testID: item.metadata?.testID,
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<SurfaceDrawerNavigation
|
|
44
|
+
compact={compact}
|
|
45
|
+
footer={footer}
|
|
46
|
+
header={header}
|
|
47
|
+
items={items}
|
|
48
|
+
testID={testID}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const ZoraDrawerContent = withZoraThemeScope(ZoraDrawerContentInner);
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { TabBar as SurfaceTabBar } from '@ankhorage/surface';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { Surface } from '../../foundation';
|
|
5
|
+
import {
|
|
6
|
+
createTabBarItemPressHandler,
|
|
7
|
+
resolveNavigationItems,
|
|
8
|
+
} from '../../internal/resolveZoraNavigationItems';
|
|
9
|
+
import { withZoraThemeScope } from '../../theme/withZoraThemeScope';
|
|
10
|
+
import type { ZoraTabBarProps } from './types';
|
|
11
|
+
|
|
12
|
+
function ZoraTabBarInner({
|
|
13
|
+
themeId: _themeId,
|
|
14
|
+
mode: _mode,
|
|
15
|
+
state,
|
|
16
|
+
navigation,
|
|
17
|
+
descriptors,
|
|
18
|
+
routeMap,
|
|
19
|
+
compact = false,
|
|
20
|
+
chrome = 'raised',
|
|
21
|
+
testID,
|
|
22
|
+
}: ZoraTabBarProps) {
|
|
23
|
+
const resolved = resolveNavigationItems({
|
|
24
|
+
state,
|
|
25
|
+
descriptors,
|
|
26
|
+
routeMap,
|
|
27
|
+
kind: 'tab',
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const items = resolved.map((item) => ({
|
|
31
|
+
id: item.route.key,
|
|
32
|
+
label: item.label,
|
|
33
|
+
icon: item.metadata?.icon,
|
|
34
|
+
badge: item.metadata?.badge,
|
|
35
|
+
active: item.active,
|
|
36
|
+
disabled: item.disabled,
|
|
37
|
+
onPress: createTabBarItemPressHandler({ item, navigation }),
|
|
38
|
+
accessibilityLabel: item.metadata?.accessibilityLabel,
|
|
39
|
+
testID: item.metadata?.testID,
|
|
40
|
+
}));
|
|
41
|
+
|
|
42
|
+
const content = <SurfaceTabBar compact={compact} items={items} testID={testID} />;
|
|
43
|
+
|
|
44
|
+
if (chrome === 'none') {
|
|
45
|
+
return content;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<Surface variant="raised" testID={testID ? `${testID}-chrome` : undefined}>
|
|
50
|
+
{content}
|
|
51
|
+
</Surface>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export const ZoraTabBar = withZoraThemeScope(ZoraTabBarInner);
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -38,6 +38,8 @@ const REQUIRED_SHOWCASE_COVERAGE = {
|
|
|
38
38
|
'MediaCard',
|
|
39
39
|
'MetricCard',
|
|
40
40
|
'Modal',
|
|
41
|
+
'NavigationItem',
|
|
42
|
+
'NavigationList',
|
|
41
43
|
'Progress',
|
|
42
44
|
'Radio',
|
|
43
45
|
'RadioGroup',
|
|
@@ -98,6 +100,8 @@ const REQUIRED_SHOWCASE_COVERAGE = {
|
|
|
98
100
|
'TileGrid',
|
|
99
101
|
'TreeItem',
|
|
100
102
|
'TreeView',
|
|
103
|
+
'ZoraDrawerContent',
|
|
104
|
+
'ZoraTabBar',
|
|
101
105
|
],
|
|
102
106
|
} as const;
|
|
103
107
|
|