@ankhorage/surface 3.4.6 → 4.1.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 (121) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +1 -6
  3. package/dist/examples/DocsExamples.d.ts.map +1 -1
  4. package/dist/examples/DocsExamples.js +0 -6
  5. package/dist/examples/DocsExamples.js.map +1 -1
  6. package/dist/features/bottom-sheet/BottomSheetContext.d.ts +4 -0
  7. package/dist/features/bottom-sheet/BottomSheetContext.d.ts.map +1 -0
  8. package/dist/features/bottom-sheet/BottomSheetContext.js +3 -0
  9. package/dist/features/bottom-sheet/BottomSheetContext.js.map +1 -0
  10. package/dist/features/bottom-sheet/BottomSheetProvider.d.ts +6 -0
  11. package/dist/features/bottom-sheet/BottomSheetProvider.d.ts.map +1 -0
  12. package/dist/features/bottom-sheet/BottomSheetProvider.js +61 -0
  13. package/dist/features/bottom-sheet/BottomSheetProvider.js.map +1 -0
  14. package/dist/features/bottom-sheet/public.d.ts +4 -0
  15. package/dist/features/bottom-sheet/public.d.ts.map +1 -0
  16. package/dist/features/bottom-sheet/public.js +3 -0
  17. package/dist/features/bottom-sheet/public.js.map +1 -0
  18. package/dist/features/bottom-sheet/useBottomSheet.d.ts +4 -0
  19. package/dist/features/bottom-sheet/useBottomSheet.d.ts.map +1 -0
  20. package/dist/features/bottom-sheet/useBottomSheet.js +11 -0
  21. package/dist/features/bottom-sheet/useBottomSheet.js.map +1 -0
  22. package/dist/index.d.ts +0 -6
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +0 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/types/bottomSheet.d.ts +18 -0
  27. package/dist/types/bottomSheet.d.ts.map +1 -0
  28. package/dist/types/bottomSheet.js +2 -0
  29. package/dist/types/bottomSheet.js.map +1 -0
  30. package/package.json +17 -3
  31. package/src/examples/DocsExamples.tsx +0 -6
  32. package/src/features/bottom-sheet/BottomSheetContext.ts +5 -0
  33. package/src/features/bottom-sheet/BottomSheetProvider.tsx +129 -0
  34. package/src/features/bottom-sheet/public.ts +3 -0
  35. package/src/features/bottom-sheet/useBottomSheet.test.tsx +18 -0
  36. package/src/features/bottom-sheet/useBottomSheet.ts +15 -0
  37. package/src/index.test.ts +40 -12
  38. package/src/index.ts +0 -22
  39. package/src/types/bottomSheet.ts +19 -0
  40. package/dist/components/action-sheet/ActionSheet.d.ts +0 -4
  41. package/dist/components/action-sheet/ActionSheet.d.ts.map +0 -1
  42. package/dist/components/action-sheet/ActionSheet.js +0 -77
  43. package/dist/components/action-sheet/ActionSheet.js.map +0 -1
  44. package/dist/components/action-sheet/ActionSheetItem.d.ts +0 -4
  45. package/dist/components/action-sheet/ActionSheetItem.d.ts.map +0 -1
  46. package/dist/components/action-sheet/ActionSheetItem.js +0 -27
  47. package/dist/components/action-sheet/ActionSheetItem.js.map +0 -1
  48. package/dist/components/action-sheet/index.d.ts +0 -4
  49. package/dist/components/action-sheet/index.d.ts.map +0 -1
  50. package/dist/components/action-sheet/index.js +0 -3
  51. package/dist/components/action-sheet/index.js.map +0 -1
  52. package/dist/components/action-sheet/types.d.ts +0 -27
  53. package/dist/components/action-sheet/types.d.ts.map +0 -1
  54. package/dist/components/action-sheet/types.js +0 -2
  55. package/dist/components/action-sheet/types.js.map +0 -1
  56. package/dist/components/drawer/Drawer.d.ts +0 -4
  57. package/dist/components/drawer/Drawer.d.ts.map +0 -1
  58. package/dist/components/drawer/Drawer.js +0 -62
  59. package/dist/components/drawer/Drawer.js.map +0 -1
  60. package/dist/components/drawer/index.d.ts +0 -3
  61. package/dist/components/drawer/index.d.ts.map +0 -1
  62. package/dist/components/drawer/index.js +0 -2
  63. package/dist/components/drawer/index.js.map +0 -1
  64. package/dist/components/drawer/types.d.ts +0 -12
  65. package/dist/components/drawer/types.d.ts.map +0 -1
  66. package/dist/components/drawer/types.js +0 -2
  67. package/dist/components/drawer/types.js.map +0 -1
  68. package/dist/components/navigation/DrawerNavigation.d.ts +0 -4
  69. package/dist/components/navigation/DrawerNavigation.d.ts.map +0 -1
  70. package/dist/components/navigation/DrawerNavigation.js +0 -13
  71. package/dist/components/navigation/DrawerNavigation.js.map +0 -1
  72. package/dist/components/navigation/DrawerNavigationItem.d.ts +0 -4
  73. package/dist/components/navigation/DrawerNavigationItem.d.ts.map +0 -1
  74. package/dist/components/navigation/DrawerNavigationItem.js +0 -9
  75. package/dist/components/navigation/DrawerNavigationItem.js.map +0 -1
  76. package/dist/components/navigation/NavigationItem.d.ts +0 -4
  77. package/dist/components/navigation/NavigationItem.d.ts.map +0 -1
  78. package/dist/components/navigation/NavigationItem.js +0 -41
  79. package/dist/components/navigation/NavigationItem.js.map +0 -1
  80. package/dist/components/navigation/NavigationList.d.ts +0 -4
  81. package/dist/components/navigation/NavigationList.d.ts.map +0 -1
  82. package/dist/components/navigation/NavigationList.js +0 -9
  83. package/dist/components/navigation/NavigationList.js.map +0 -1
  84. package/dist/components/navigation/TabBar.d.ts +0 -4
  85. package/dist/components/navigation/TabBar.d.ts.map +0 -1
  86. package/dist/components/navigation/TabBar.js +0 -15
  87. package/dist/components/navigation/TabBar.js.map +0 -1
  88. package/dist/components/navigation/TabBarItem.d.ts +0 -4
  89. package/dist/components/navigation/TabBarItem.d.ts.map +0 -1
  90. package/dist/components/navigation/TabBarItem.js +0 -44
  91. package/dist/components/navigation/TabBarItem.js.map +0 -1
  92. package/dist/components/navigation/helpers.d.ts +0 -15
  93. package/dist/components/navigation/helpers.d.ts.map +0 -1
  94. package/dist/components/navigation/helpers.js +0 -48
  95. package/dist/components/navigation/helpers.js.map +0 -1
  96. package/dist/components/navigation/index.d.ts +0 -8
  97. package/dist/components/navigation/index.d.ts.map +0 -1
  98. package/dist/components/navigation/index.js +0 -7
  99. package/dist/components/navigation/index.js.map +0 -1
  100. package/dist/components/navigation/types.d.ts +0 -58
  101. package/dist/components/navigation/types.d.ts.map +0 -1
  102. package/dist/components/navigation/types.js +0 -2
  103. package/dist/components/navigation/types.js.map +0 -1
  104. package/src/components/action-sheet/ActionSheet.tsx +0 -130
  105. package/src/components/action-sheet/ActionSheetItem.tsx +0 -59
  106. package/src/components/action-sheet/index.ts +0 -3
  107. package/src/components/action-sheet/types.ts +0 -29
  108. package/src/components/drawer/Drawer.tsx +0 -100
  109. package/src/components/drawer/index.ts +0 -2
  110. package/src/components/drawer/types.ts +0 -13
  111. package/src/components/navigation/DrawerNavigation.tsx +0 -32
  112. package/src/components/navigation/DrawerNavigationItem.tsx +0 -23
  113. package/src/components/navigation/NavigationItem.tsx +0 -79
  114. package/src/components/navigation/NavigationList.tsx +0 -31
  115. package/src/components/navigation/TabBar.tsx +0 -31
  116. package/src/components/navigation/TabBarItem.tsx +0 -79
  117. package/src/components/navigation/helpers.test.ts +0 -74
  118. package/src/components/navigation/helpers.ts +0 -81
  119. package/src/components/navigation/index.ts +0 -16
  120. package/src/components/navigation/policy.test.ts +0 -140
  121. package/src/components/navigation/types.ts +0 -66
@@ -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
- }