@ankhorage/surface 3.4.5 → 4.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.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -6
- package/dist/components/radio/Radio.d.ts +3 -0
- package/dist/components/radio/Radio.d.ts.map +1 -1
- package/dist/components/radio/Radio.js +8 -2
- package/dist/components/radio/Radio.js.map +1 -1
- package/dist/components/radio/isRadioTextContent.d.ts +6 -0
- package/dist/components/radio/isRadioTextContent.d.ts.map +1 -0
- package/dist/components/radio/isRadioTextContent.js +7 -0
- package/dist/components/radio/isRadioTextContent.js.map +1 -0
- package/dist/examples/DocsExamples.d.ts.map +1 -1
- package/dist/examples/DocsExamples.js +0 -6
- package/dist/examples/DocsExamples.js.map +1 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -3
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/components/radio/Radio.test.ts +20 -0
- package/src/components/radio/Radio.tsx +9 -3
- package/src/components/radio/isRadioTextContent.ts +8 -0
- package/src/examples/DocsExamples.tsx +0 -6
- package/src/index.test.ts +24 -13
- package/src/index.ts +0 -22
- package/dist/components/action-sheet/ActionSheet.d.ts +0 -4
- package/dist/components/action-sheet/ActionSheet.d.ts.map +0 -1
- package/dist/components/action-sheet/ActionSheet.js +0 -77
- package/dist/components/action-sheet/ActionSheet.js.map +0 -1
- package/dist/components/action-sheet/ActionSheetItem.d.ts +0 -4
- package/dist/components/action-sheet/ActionSheetItem.d.ts.map +0 -1
- package/dist/components/action-sheet/ActionSheetItem.js +0 -27
- package/dist/components/action-sheet/ActionSheetItem.js.map +0 -1
- package/dist/components/action-sheet/index.d.ts +0 -4
- package/dist/components/action-sheet/index.d.ts.map +0 -1
- package/dist/components/action-sheet/index.js +0 -3
- package/dist/components/action-sheet/index.js.map +0 -1
- package/dist/components/action-sheet/types.d.ts +0 -27
- package/dist/components/action-sheet/types.d.ts.map +0 -1
- package/dist/components/action-sheet/types.js +0 -2
- package/dist/components/action-sheet/types.js.map +0 -1
- package/dist/components/drawer/Drawer.d.ts +0 -4
- package/dist/components/drawer/Drawer.d.ts.map +0 -1
- package/dist/components/drawer/Drawer.js +0 -62
- package/dist/components/drawer/Drawer.js.map +0 -1
- package/dist/components/drawer/index.d.ts +0 -3
- package/dist/components/drawer/index.d.ts.map +0 -1
- package/dist/components/drawer/index.js +0 -2
- package/dist/components/drawer/index.js.map +0 -1
- package/dist/components/drawer/types.d.ts +0 -12
- package/dist/components/drawer/types.d.ts.map +0 -1
- package/dist/components/drawer/types.js +0 -2
- package/dist/components/drawer/types.js.map +0 -1
- package/dist/components/navigation/DrawerNavigation.d.ts +0 -4
- package/dist/components/navigation/DrawerNavigation.d.ts.map +0 -1
- package/dist/components/navigation/DrawerNavigation.js +0 -13
- package/dist/components/navigation/DrawerNavigation.js.map +0 -1
- package/dist/components/navigation/DrawerNavigationItem.d.ts +0 -4
- package/dist/components/navigation/DrawerNavigationItem.d.ts.map +0 -1
- package/dist/components/navigation/DrawerNavigationItem.js +0 -9
- package/dist/components/navigation/DrawerNavigationItem.js.map +0 -1
- package/dist/components/navigation/NavigationItem.d.ts +0 -4
- package/dist/components/navigation/NavigationItem.d.ts.map +0 -1
- package/dist/components/navigation/NavigationItem.js +0 -41
- package/dist/components/navigation/NavigationItem.js.map +0 -1
- package/dist/components/navigation/NavigationList.d.ts +0 -4
- package/dist/components/navigation/NavigationList.d.ts.map +0 -1
- package/dist/components/navigation/NavigationList.js +0 -9
- package/dist/components/navigation/NavigationList.js.map +0 -1
- package/dist/components/navigation/TabBar.d.ts +0 -4
- package/dist/components/navigation/TabBar.d.ts.map +0 -1
- package/dist/components/navigation/TabBar.js +0 -15
- package/dist/components/navigation/TabBar.js.map +0 -1
- package/dist/components/navigation/TabBarItem.d.ts +0 -4
- package/dist/components/navigation/TabBarItem.d.ts.map +0 -1
- package/dist/components/navigation/TabBarItem.js +0 -44
- package/dist/components/navigation/TabBarItem.js.map +0 -1
- package/dist/components/navigation/helpers.d.ts +0 -15
- package/dist/components/navigation/helpers.d.ts.map +0 -1
- package/dist/components/navigation/helpers.js +0 -48
- package/dist/components/navigation/helpers.js.map +0 -1
- package/dist/components/navigation/index.d.ts +0 -8
- package/dist/components/navigation/index.d.ts.map +0 -1
- package/dist/components/navigation/index.js +0 -7
- package/dist/components/navigation/index.js.map +0 -1
- package/dist/components/navigation/types.d.ts +0 -58
- package/dist/components/navigation/types.d.ts.map +0 -1
- package/dist/components/navigation/types.js +0 -2
- package/dist/components/navigation/types.js.map +0 -1
- package/src/components/action-sheet/ActionSheet.tsx +0 -130
- package/src/components/action-sheet/ActionSheetItem.tsx +0 -59
- package/src/components/action-sheet/index.ts +0 -3
- package/src/components/action-sheet/types.ts +0 -29
- package/src/components/drawer/Drawer.tsx +0 -100
- package/src/components/drawer/index.ts +0 -2
- package/src/components/drawer/types.ts +0 -13
- package/src/components/navigation/DrawerNavigation.tsx +0 -32
- package/src/components/navigation/DrawerNavigationItem.tsx +0 -23
- package/src/components/navigation/NavigationItem.tsx +0 -79
- package/src/components/navigation/NavigationList.tsx +0 -31
- package/src/components/navigation/TabBar.tsx +0 -31
- package/src/components/navigation/TabBarItem.tsx +0 -79
- package/src/components/navigation/helpers.test.ts +0 -74
- package/src/components/navigation/helpers.ts +0 -81
- package/src/components/navigation/index.ts +0 -16
- package/src/components/navigation/policy.test.ts +0 -140
- package/src/components/navigation/types.ts +0 -66
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Stack } from '../../layout';
|
|
4
|
-
import { NavigationItem } from './NavigationItem';
|
|
5
|
-
import type { NavigationListProps } from './types';
|
|
6
|
-
|
|
7
|
-
export function NavigationList({
|
|
8
|
-
items,
|
|
9
|
-
orientation = 'vertical',
|
|
10
|
-
compact = false,
|
|
11
|
-
testID,
|
|
12
|
-
interactionPolicy,
|
|
13
|
-
}: NavigationListProps) {
|
|
14
|
-
return (
|
|
15
|
-
<Stack
|
|
16
|
-
direction={orientation === 'horizontal' ? 'row' : 'column'}
|
|
17
|
-
gap={compact ? 'xs' : 's'}
|
|
18
|
-
testID={testID}
|
|
19
|
-
>
|
|
20
|
-
{items.map((item) => (
|
|
21
|
-
<NavigationItem
|
|
22
|
-
compact={compact}
|
|
23
|
-
interactionPolicy={interactionPolicy}
|
|
24
|
-
item={item}
|
|
25
|
-
key={item.id}
|
|
26
|
-
testID={testID}
|
|
27
|
-
/>
|
|
28
|
-
))}
|
|
29
|
-
</Stack>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Box } from '../../layout';
|
|
4
|
-
import { useTheme } from '../../theme/ThemeContext';
|
|
5
|
-
import { TabBarItem } from './TabBarItem';
|
|
6
|
-
import type { TabBarProps } from './types';
|
|
7
|
-
|
|
8
|
-
export function TabBar({ items, compact = false, testID, interactionPolicy }: TabBarProps) {
|
|
9
|
-
const { theme } = useTheme();
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<Box
|
|
13
|
-
style={{
|
|
14
|
-
flexDirection: 'row',
|
|
15
|
-
borderTopColor: theme.semantics.border.default,
|
|
16
|
-
borderTopWidth: 1,
|
|
17
|
-
}}
|
|
18
|
-
testID={testID}
|
|
19
|
-
>
|
|
20
|
-
{items.map((item) => (
|
|
21
|
-
<TabBarItem
|
|
22
|
-
compact={compact}
|
|
23
|
-
interactionPolicy={interactionPolicy}
|
|
24
|
-
item={item}
|
|
25
|
-
key={item.id}
|
|
26
|
-
testID={testID}
|
|
27
|
-
/>
|
|
28
|
-
))}
|
|
29
|
-
</Box>
|
|
30
|
-
);
|
|
31
|
-
}
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import { Box } from '../../layout';
|
|
5
|
-
import { ButtonBase } from '../../primitives/button-base';
|
|
6
|
-
import { Icon } from '../../primitives/icon';
|
|
7
|
-
import { Text } from '../../primitives/text';
|
|
8
|
-
import { useTheme } from '../../theme/ThemeContext';
|
|
9
|
-
import { resolveNavigationAccessibilityState, resolveNavigationItemPresentation } from './helpers';
|
|
10
|
-
import type { TabBarItemProps } from './types';
|
|
11
|
-
|
|
12
|
-
export function TabBarItem({ item, compact = false, testID, interactionPolicy }: TabBarItemProps) {
|
|
13
|
-
const { theme } = useTheme();
|
|
14
|
-
const active = Boolean(item.active);
|
|
15
|
-
const disabled = Boolean(item.disabled);
|
|
16
|
-
const resolvedTestID = item.testID ?? (testID ? `${testID}-item-${item.id}` : undefined);
|
|
17
|
-
const resolvedAccessibilityState = resolveNavigationAccessibilityState(
|
|
18
|
-
active,
|
|
19
|
-
disabled,
|
|
20
|
-
item.accessibilityState,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
return (
|
|
24
|
-
<ButtonBase
|
|
25
|
-
accessibilityLabel={item.accessibilityLabel}
|
|
26
|
-
accessibilityRole={item.accessibilityRole ?? 'tab'}
|
|
27
|
-
accessibilityState={resolvedAccessibilityState}
|
|
28
|
-
disabled={disabled}
|
|
29
|
-
interactionPolicy={interactionPolicy}
|
|
30
|
-
onPress={item.onPress}
|
|
31
|
-
style={{ flex: 1 }}
|
|
32
|
-
testID={resolvedTestID}
|
|
33
|
-
>
|
|
34
|
-
{(state) => {
|
|
35
|
-
const presentation = resolveNavigationItemPresentation(theme, {
|
|
36
|
-
active,
|
|
37
|
-
disabled,
|
|
38
|
-
state,
|
|
39
|
-
});
|
|
40
|
-
const contentColor = disabled
|
|
41
|
-
? theme.semantics.content.muted
|
|
42
|
-
: active
|
|
43
|
-
? theme.semantics.action.primary.base
|
|
44
|
-
: theme.semantics.content.muted;
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<Box
|
|
48
|
-
px="m"
|
|
49
|
-
py={compact ? 's' : 'm'}
|
|
50
|
-
style={{
|
|
51
|
-
flex: 1,
|
|
52
|
-
alignItems: 'center',
|
|
53
|
-
justifyContent: 'center',
|
|
54
|
-
backgroundColor: presentation.backgroundColor,
|
|
55
|
-
opacity: presentation.opacity,
|
|
56
|
-
}}
|
|
57
|
-
>
|
|
58
|
-
{item.icon ? (
|
|
59
|
-
<View style={{ marginBottom: item.label ? theme.spacing.xs : 0 }}>
|
|
60
|
-
<Icon {...item.icon} color={contentColor} size={compact ? 's' : 'm'} />
|
|
61
|
-
</View>
|
|
62
|
-
) : null}
|
|
63
|
-
{item.label ? (
|
|
64
|
-
<Text
|
|
65
|
-
color={active && !disabled ? 'primary' : undefined}
|
|
66
|
-
emphasis={active && !disabled ? 'default' : 'muted'}
|
|
67
|
-
numberOfLines={1}
|
|
68
|
-
variant={compact ? 'bodySmall' : 'label'}
|
|
69
|
-
weight="medium"
|
|
70
|
-
>
|
|
71
|
-
{item.label}
|
|
72
|
-
</Text>
|
|
73
|
-
) : null}
|
|
74
|
-
</Box>
|
|
75
|
-
);
|
|
76
|
-
}}
|
|
77
|
-
</ButtonBase>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
|
|
3
|
-
import { createTheme } from '../../theme/createTheme';
|
|
4
|
-
import { resolveNavigationAccessibilityState, resolveNavigationItemPresentation } from './helpers';
|
|
5
|
-
|
|
6
|
-
describe('navigation helpers', () => {
|
|
7
|
-
it('forces selected and disabled when active/disabled are true', () => {
|
|
8
|
-
expect(
|
|
9
|
-
resolveNavigationAccessibilityState(true, true, {
|
|
10
|
-
selected: false,
|
|
11
|
-
disabled: false,
|
|
12
|
-
}),
|
|
13
|
-
).toEqual({
|
|
14
|
-
selected: true,
|
|
15
|
-
disabled: true,
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('preserves user-provided state when not active/disabled', () => {
|
|
20
|
-
expect(
|
|
21
|
-
resolveNavigationAccessibilityState(false, false, {
|
|
22
|
-
disabled: false,
|
|
23
|
-
selected: false,
|
|
24
|
-
expanded: true,
|
|
25
|
-
}),
|
|
26
|
-
).toEqual({
|
|
27
|
-
disabled: false,
|
|
28
|
-
selected: false,
|
|
29
|
-
expanded: true,
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('resolves active presentation via primary soft semantics', () => {
|
|
34
|
-
const theme = createTheme();
|
|
35
|
-
const state = { pressed: false, hovered: true, focused: false, disabled: false };
|
|
36
|
-
const resolved = resolveNavigationItemPresentation(theme, {
|
|
37
|
-
active: true,
|
|
38
|
-
disabled: false,
|
|
39
|
-
state,
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
expect(resolved.backgroundColor).toBe(theme.semantics.action.primary.softHover);
|
|
43
|
-
expect(resolved.contentColor).toBe(theme.semantics.action.primary.onSoftHoverText);
|
|
44
|
-
expect(resolved.opacity).toBe(1);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('resolves inactive presentation via neutral hover/active semantics', () => {
|
|
48
|
-
const theme = createTheme();
|
|
49
|
-
const state = { pressed: true, hovered: true, focused: false, disabled: false };
|
|
50
|
-
const resolved = resolveNavigationItemPresentation(theme, {
|
|
51
|
-
active: false,
|
|
52
|
-
disabled: false,
|
|
53
|
-
state,
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
expect(resolved.backgroundColor).toBe(theme.semantics.neutral.surfaceActive);
|
|
57
|
-
expect(resolved.contentColor).toBe(theme.semantics.content.default);
|
|
58
|
-
expect(resolved.opacity).toBe(1);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('ignores hover/pressed presentation when disabled', () => {
|
|
62
|
-
const theme = createTheme();
|
|
63
|
-
const state = { pressed: true, hovered: true, focused: false, disabled: true };
|
|
64
|
-
const resolved = resolveNavigationItemPresentation(theme, {
|
|
65
|
-
active: true,
|
|
66
|
-
disabled: true,
|
|
67
|
-
state,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
expect(resolved.backgroundColor).toBe(theme.semantics.surface.disabled);
|
|
71
|
-
expect(resolved.contentColor).toBe(theme.semantics.content.disabled);
|
|
72
|
-
expect(resolved.opacity).toBe(1);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { AccessibilityState } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import type { InteractionState } from '../../internal/resolvers/resolveInteractiveState';
|
|
4
|
-
import type { SurfaceTheme } from '../../theme/types';
|
|
5
|
-
|
|
6
|
-
export function resolveNavigationAccessibilityState(
|
|
7
|
-
active: boolean,
|
|
8
|
-
disabled: boolean,
|
|
9
|
-
accessibilityState?: AccessibilityState,
|
|
10
|
-
): AccessibilityState {
|
|
11
|
-
const resolved: AccessibilityState = { ...(accessibilityState ?? {}) };
|
|
12
|
-
|
|
13
|
-
if (active) {
|
|
14
|
-
resolved.selected = true;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (disabled) {
|
|
18
|
-
resolved.disabled = true;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return resolved;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface ResolvedNavigationItemPresentation {
|
|
25
|
-
backgroundColor: string;
|
|
26
|
-
contentColor: string;
|
|
27
|
-
opacity: number;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function resolveNavigationItemPresentation(
|
|
31
|
-
theme: SurfaceTheme,
|
|
32
|
-
{
|
|
33
|
-
active,
|
|
34
|
-
disabled,
|
|
35
|
-
state,
|
|
36
|
-
}: {
|
|
37
|
-
active: boolean;
|
|
38
|
-
disabled: boolean;
|
|
39
|
-
state: InteractionState;
|
|
40
|
-
},
|
|
41
|
-
): ResolvedNavigationItemPresentation {
|
|
42
|
-
const interactionState = disabled ? { ...state, hovered: false, pressed: false } : state;
|
|
43
|
-
|
|
44
|
-
if (disabled) {
|
|
45
|
-
return {
|
|
46
|
-
backgroundColor: theme.semantics.surface.disabled,
|
|
47
|
-
contentColor: theme.semantics.content.disabled,
|
|
48
|
-
opacity: 1,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const contentColor = active
|
|
53
|
-
? interactionState.pressed
|
|
54
|
-
? theme.semantics.action.primary.onSoftActiveText
|
|
55
|
-
: interactionState.hovered
|
|
56
|
-
? theme.semantics.action.primary.onSoftHoverText
|
|
57
|
-
: theme.semantics.action.primary.onSoftText
|
|
58
|
-
: theme.semantics.content.default;
|
|
59
|
-
|
|
60
|
-
if (active) {
|
|
61
|
-
return {
|
|
62
|
-
backgroundColor: interactionState.pressed
|
|
63
|
-
? theme.semantics.action.primary.softActive
|
|
64
|
-
: interactionState.hovered
|
|
65
|
-
? theme.semantics.action.primary.softHover
|
|
66
|
-
: theme.semantics.action.primary.softBg,
|
|
67
|
-
contentColor,
|
|
68
|
-
opacity: 1,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
return {
|
|
73
|
-
backgroundColor: interactionState.pressed
|
|
74
|
-
? theme.semantics.neutral.surfaceActive
|
|
75
|
-
: interactionState.hovered
|
|
76
|
-
? theme.semantics.neutral.surfaceHover
|
|
77
|
-
: 'transparent',
|
|
78
|
-
contentColor,
|
|
79
|
-
opacity: 1,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { DrawerNavigation } from './DrawerNavigation';
|
|
2
|
-
export { DrawerNavigationItem } from './DrawerNavigationItem';
|
|
3
|
-
export { NavigationItem } from './NavigationItem';
|
|
4
|
-
export { NavigationList } from './NavigationList';
|
|
5
|
-
export { TabBar } from './TabBar';
|
|
6
|
-
export { TabBarItem } from './TabBarItem';
|
|
7
|
-
export type {
|
|
8
|
-
DrawerNavigationItemProps,
|
|
9
|
-
DrawerNavigationProps,
|
|
10
|
-
NavigationItemIcon,
|
|
11
|
-
NavigationItemProps,
|
|
12
|
-
NavigationItemSpec,
|
|
13
|
-
NavigationListProps,
|
|
14
|
-
TabBarItemProps,
|
|
15
|
-
TabBarProps,
|
|
16
|
-
} from './types';
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
2
|
-
import { extname, join } from 'node:path';
|
|
3
|
-
import { fileURLToPath } from 'node:url';
|
|
4
|
-
|
|
5
|
-
import { describe, expect, it } from 'bun:test';
|
|
6
|
-
|
|
7
|
-
const navigationDir = fileURLToPath(new URL('.', import.meta.url));
|
|
8
|
-
|
|
9
|
-
const forbiddenPatterns = [
|
|
10
|
-
'expo-router',
|
|
11
|
-
'@react-navigation',
|
|
12
|
-
'AppManifest',
|
|
13
|
-
'NavigatorSpec',
|
|
14
|
-
'generated app',
|
|
15
|
-
'templates',
|
|
16
|
-
] as const;
|
|
17
|
-
|
|
18
|
-
function listNavigationSources() {
|
|
19
|
-
return readdirSync(navigationDir)
|
|
20
|
-
.filter((entry) => {
|
|
21
|
-
const extension = extname(entry);
|
|
22
|
-
if (!(extension === '.ts' || extension === '.tsx')) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return !entry.includes('.test.');
|
|
27
|
-
})
|
|
28
|
-
.map((entry) => join(navigationDir, entry));
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
describe('navigation module boundaries', () => {
|
|
32
|
-
it('does not import routers, manifests, or generated app code', () => {
|
|
33
|
-
const sources = listNavigationSources().map((path) => ({
|
|
34
|
-
path,
|
|
35
|
-
content: readFileSync(path, 'utf8'),
|
|
36
|
-
}));
|
|
37
|
-
|
|
38
|
-
sources.forEach(({ content, path }) => {
|
|
39
|
-
forbiddenPatterns.forEach((pattern) => {
|
|
40
|
-
expect(content, path).not.toContain(pattern);
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
describe('navigation interaction policy', () => {
|
|
47
|
-
it('host component prop types include interactionPolicy', () => {
|
|
48
|
-
const sources = listNavigationSources().map((path) => ({
|
|
49
|
-
path,
|
|
50
|
-
content: readFileSync(path, 'utf8'),
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
const hostComponents = [{ path: 'types.ts', prop: 'interactionPolicy?: InteractionPolicy' }];
|
|
54
|
-
|
|
55
|
-
sources.forEach(({ content, path }) => {
|
|
56
|
-
const component = hostComponents.find((host) => path.endsWith(host.path));
|
|
57
|
-
if (component) {
|
|
58
|
-
expect(content, path).toContain(component.prop);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it('navigation components accept interactionPolicy prop', () => {
|
|
64
|
-
const sources = listNavigationSources().map((path) => ({
|
|
65
|
-
path,
|
|
66
|
-
content: readFileSync(path, 'utf8'),
|
|
67
|
-
}));
|
|
68
|
-
|
|
69
|
-
const components = [
|
|
70
|
-
'NavigationItem.tsx',
|
|
71
|
-
'NavigationList.tsx',
|
|
72
|
-
'TabBar.tsx',
|
|
73
|
-
'TabBarItem.tsx',
|
|
74
|
-
'DrawerNavigation.tsx',
|
|
75
|
-
'DrawerNavigationItem.tsx',
|
|
76
|
-
];
|
|
77
|
-
|
|
78
|
-
sources.forEach(({ content, path }) => {
|
|
79
|
-
const component = components.find((c) => path.endsWith(c));
|
|
80
|
-
if (component) {
|
|
81
|
-
expect(content, path).toContain('interactionPolicy');
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('direct ButtonBase owners forward interactionPolicy unchanged', () => {
|
|
87
|
-
const sources = listNavigationSources().map((path) => ({
|
|
88
|
-
path,
|
|
89
|
-
content: readFileSync(path, 'utf8'),
|
|
90
|
-
}));
|
|
91
|
-
|
|
92
|
-
const directButtonBaseOwners = ['NavigationItem.tsx', 'TabBarItem.tsx'];
|
|
93
|
-
|
|
94
|
-
sources.forEach(({ content, path }) => {
|
|
95
|
-
const component = directButtonBaseOwners.find((owner) => path.endsWith(owner));
|
|
96
|
-
if (component) {
|
|
97
|
-
expect(content, path).toContain('interactionPolicy={interactionPolicy}');
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('container components forward interactionPolicy to children', () => {
|
|
103
|
-
const sources = listNavigationSources().map((path) => ({
|
|
104
|
-
path,
|
|
105
|
-
content: readFileSync(path, 'utf8'),
|
|
106
|
-
}));
|
|
107
|
-
|
|
108
|
-
const forwardingMap: Record<string, string> = {
|
|
109
|
-
'NavigationList.tsx': 'NavigationItem',
|
|
110
|
-
'TabBar.tsx': 'TabBarItem',
|
|
111
|
-
'DrawerNavigation.tsx': 'DrawerNavigationItem',
|
|
112
|
-
'DrawerNavigationItem.tsx': 'NavigationItem',
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
sources.forEach(({ content, path }) => {
|
|
116
|
-
const filename = path.split('/').pop();
|
|
117
|
-
if (filename && forwardingMap[filename]) {
|
|
118
|
-
expect(content, path).toContain(`interactionPolicy={interactionPolicy}`);
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('does not map passive interactionPolicy to disabled in navigation components', () => {
|
|
124
|
-
const sources = listNavigationSources().map((path) => ({
|
|
125
|
-
path,
|
|
126
|
-
content: readFileSync(path, 'utf8'),
|
|
127
|
-
}));
|
|
128
|
-
|
|
129
|
-
const passiveToDisabledPatterns = [
|
|
130
|
-
/disabled=\{interactionPolicy === 'passive'\}/,
|
|
131
|
-
/disabled=\{passive/,
|
|
132
|
-
];
|
|
133
|
-
|
|
134
|
-
sources.forEach(({ content, path }) => {
|
|
135
|
-
passiveToDisabledPatterns.forEach((pattern) => {
|
|
136
|
-
expect(content, path).not.toMatch(pattern);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import type React from 'react';
|
|
2
|
-
import type { AccessibilityRole, AccessibilityState } from 'react-native';
|
|
3
|
-
|
|
4
|
-
import type { InteractionPolicy } from '../../interactionPolicy';
|
|
5
|
-
import type { IconSource } from '../../primitives/icon';
|
|
6
|
-
|
|
7
|
-
export type NavigationItemIcon = IconSource;
|
|
8
|
-
|
|
9
|
-
export interface NavigationItemSpec {
|
|
10
|
-
id: string;
|
|
11
|
-
label: React.ReactNode;
|
|
12
|
-
icon?: NavigationItemIcon;
|
|
13
|
-
badge?: React.ReactNode;
|
|
14
|
-
active?: boolean;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
onPress?: (() => void) | undefined;
|
|
17
|
-
accessibilityLabel?: string;
|
|
18
|
-
accessibilityRole?: AccessibilityRole;
|
|
19
|
-
accessibilityState?: AccessibilityState;
|
|
20
|
-
testID?: string;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export interface NavigationItemProps {
|
|
24
|
-
item: NavigationItemSpec;
|
|
25
|
-
compact?: boolean;
|
|
26
|
-
testID?: string;
|
|
27
|
-
interactionPolicy?: InteractionPolicy;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface NavigationListProps {
|
|
31
|
-
items: readonly NavigationItemSpec[];
|
|
32
|
-
orientation?: 'vertical' | 'horizontal';
|
|
33
|
-
compact?: boolean;
|
|
34
|
-
testID?: string;
|
|
35
|
-
interactionPolicy?: InteractionPolicy;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface TabBarProps {
|
|
39
|
-
items: readonly NavigationItemSpec[];
|
|
40
|
-
compact?: boolean;
|
|
41
|
-
testID?: string;
|
|
42
|
-
interactionPolicy?: InteractionPolicy;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export interface TabBarItemProps {
|
|
46
|
-
item: NavigationItemSpec;
|
|
47
|
-
compact?: boolean;
|
|
48
|
-
testID?: string;
|
|
49
|
-
interactionPolicy?: InteractionPolicy;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export interface DrawerNavigationProps {
|
|
53
|
-
items: readonly NavigationItemSpec[];
|
|
54
|
-
header?: React.ReactNode;
|
|
55
|
-
footer?: React.ReactNode;
|
|
56
|
-
compact?: boolean;
|
|
57
|
-
testID?: string;
|
|
58
|
-
interactionPolicy?: InteractionPolicy;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export interface DrawerNavigationItemProps {
|
|
62
|
-
item: NavigationItemSpec;
|
|
63
|
-
compact?: boolean;
|
|
64
|
-
testID?: string;
|
|
65
|
-
interactionPolicy?: InteractionPolicy;
|
|
66
|
-
}
|