@ankhorage/surface 4.4.1 → 5.0.1

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 (235) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +2 -2
  3. package/dist/features/bottom-sheet/BottomSheetProvider.js +8 -6
  4. package/dist/features/bottom-sheet/BottomSheetProvider.js.map +1 -1
  5. package/dist/features/bottom-sheet/public.d.ts +2 -1
  6. package/dist/features/bottom-sheet/public.d.ts.map +1 -1
  7. package/dist/features/bottom-sheet/public.js +1 -0
  8. package/dist/features/bottom-sheet/public.js.map +1 -1
  9. package/dist/{components/modal → features/modal/adapters/inbound}/Modal.d.ts +2 -1
  10. package/dist/features/modal/adapters/inbound/Modal.d.ts.map +1 -0
  11. package/dist/features/modal/adapters/inbound/Modal.js +51 -0
  12. package/dist/features/modal/adapters/inbound/Modal.js.map +1 -0
  13. package/dist/features/modal/public.d.ts +3 -0
  14. package/dist/features/modal/public.d.ts.map +1 -0
  15. package/dist/features/modal/public.js +2 -0
  16. package/dist/features/modal/public.js.map +1 -0
  17. package/dist/features/popover-menu/adapters/inbound/PopoverMenu.d.ts +5 -0
  18. package/dist/features/popover-menu/adapters/inbound/PopoverMenu.d.ts.map +1 -0
  19. package/dist/features/popover-menu/adapters/inbound/PopoverMenu.js +85 -0
  20. package/dist/features/popover-menu/adapters/inbound/PopoverMenu.js.map +1 -0
  21. package/dist/features/popover-menu/composition/usePopoverMenuController.d.ts +19 -0
  22. package/dist/features/popover-menu/composition/usePopoverMenuController.d.ts.map +1 -0
  23. package/dist/features/popover-menu/composition/usePopoverMenuController.js +35 -0
  24. package/dist/features/popover-menu/composition/usePopoverMenuController.js.map +1 -0
  25. package/dist/features/popover-menu/public.d.ts +3 -0
  26. package/dist/features/popover-menu/public.d.ts.map +1 -0
  27. package/dist/features/popover-menu/public.js +2 -0
  28. package/dist/features/popover-menu/public.js.map +1 -0
  29. package/dist/features/popover-menu/utils/resolveNextMenuIndex.d.ts +5 -0
  30. package/dist/features/popover-menu/utils/resolveNextMenuIndex.d.ts.map +1 -0
  31. package/dist/features/popover-menu/utils/resolveNextMenuIndex.js +18 -0
  32. package/dist/features/popover-menu/utils/resolveNextMenuIndex.js.map +1 -0
  33. package/dist/features/tabs/adapters/inbound/Tab.d.ts +5 -0
  34. package/dist/features/tabs/adapters/inbound/Tab.d.ts.map +1 -0
  35. package/dist/features/tabs/adapters/inbound/Tab.js +33 -0
  36. package/dist/features/tabs/adapters/inbound/Tab.js.map +1 -0
  37. package/dist/features/tabs/adapters/inbound/TabList.d.ts +5 -0
  38. package/dist/features/tabs/adapters/inbound/TabList.d.ts.map +1 -0
  39. package/dist/features/tabs/adapters/inbound/TabList.js +42 -0
  40. package/dist/features/tabs/adapters/inbound/TabList.js.map +1 -0
  41. package/dist/features/tabs/adapters/inbound/TabPanel.d.ts +5 -0
  42. package/dist/features/tabs/adapters/inbound/TabPanel.d.ts.map +1 -0
  43. package/dist/features/tabs/adapters/inbound/TabPanel.js +14 -0
  44. package/dist/features/tabs/adapters/inbound/TabPanel.js.map +1 -0
  45. package/dist/features/tabs/adapters/inbound/Tabs.d.ts +5 -0
  46. package/dist/features/tabs/adapters/inbound/Tabs.d.ts.map +1 -0
  47. package/dist/features/tabs/adapters/inbound/Tabs.js +12 -0
  48. package/dist/features/tabs/adapters/inbound/Tabs.js.map +1 -0
  49. package/dist/features/tabs/composition/TabsContext.d.ts +4 -0
  50. package/dist/features/tabs/composition/TabsContext.d.ts.map +1 -0
  51. package/dist/features/tabs/composition/TabsContext.js +3 -0
  52. package/dist/features/tabs/composition/TabsContext.js.map +1 -0
  53. package/dist/features/tabs/composition/useTabRegistration.d.ts +7 -0
  54. package/dist/features/tabs/composition/useTabRegistration.d.ts.map +1 -0
  55. package/dist/features/tabs/composition/useTabRegistration.js +20 -0
  56. package/dist/features/tabs/composition/useTabRegistration.js.map +1 -0
  57. package/dist/features/tabs/composition/useTabsContext.d.ts +4 -0
  58. package/dist/features/tabs/composition/useTabsContext.d.ts.map +1 -0
  59. package/dist/{components/tabs/context.js → features/tabs/composition/useTabsContext.js} +4 -4
  60. package/dist/features/tabs/composition/useTabsContext.js.map +1 -0
  61. package/dist/features/tabs/composition/useTabsController.d.ts +4 -0
  62. package/dist/features/tabs/composition/useTabsController.d.ts.map +1 -0
  63. package/dist/features/tabs/composition/useTabsController.js +43 -0
  64. package/dist/features/tabs/composition/useTabsController.js.map +1 -0
  65. package/dist/features/tabs/public.d.ts +6 -0
  66. package/dist/features/tabs/public.d.ts.map +1 -0
  67. package/dist/features/tabs/public.js +5 -0
  68. package/dist/features/tabs/public.js.map +1 -0
  69. package/dist/features/tabs/utils/resolveNextTabValue.d.ts +4 -0
  70. package/dist/features/tabs/utils/resolveNextTabValue.d.ts.map +1 -0
  71. package/dist/{components/tabs/navigation.js → features/tabs/utils/resolveNextTabValue.js} +10 -13
  72. package/dist/features/tabs/utils/resolveNextTabValue.js.map +1 -0
  73. package/dist/features/tabs/utils/resolveTabElementId.d.ts +3 -0
  74. package/dist/features/tabs/utils/resolveTabElementId.d.ts.map +1 -0
  75. package/dist/features/tabs/utils/resolveTabElementId.js +10 -0
  76. package/dist/features/tabs/utils/resolveTabElementId.js.map +1 -0
  77. package/dist/features/tooltip/adapters/inbound/Tooltip.d.ts +5 -0
  78. package/dist/features/tooltip/adapters/inbound/Tooltip.d.ts.map +1 -0
  79. package/dist/features/tooltip/adapters/inbound/Tooltip.js +25 -0
  80. package/dist/features/tooltip/adapters/inbound/Tooltip.js.map +1 -0
  81. package/dist/features/tooltip/composition/useTooltipVisibility.d.ts +9 -0
  82. package/dist/features/tooltip/composition/useTooltipVisibility.d.ts.map +1 -0
  83. package/dist/features/tooltip/composition/useTooltipVisibility.js +25 -0
  84. package/dist/features/tooltip/composition/useTooltipVisibility.js.map +1 -0
  85. package/dist/features/tooltip/public.d.ts +3 -0
  86. package/dist/features/tooltip/public.d.ts.map +1 -0
  87. package/dist/features/tooltip/public.js +2 -0
  88. package/dist/features/tooltip/public.js.map +1 -0
  89. package/dist/index.d.ts +8 -8
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +4 -4
  92. package/dist/index.js.map +1 -1
  93. package/dist/types/bottomSheet.d.ts +3 -0
  94. package/dist/types/bottomSheet.d.ts.map +1 -1
  95. package/dist/types/bottomSheet.js.map +1 -1
  96. package/dist/{components/modal/types.d.ts → types/modal.d.ts} +2 -2
  97. package/dist/types/modal.d.ts.map +1 -0
  98. package/dist/types/modal.js +2 -0
  99. package/dist/types/modal.js.map +1 -0
  100. package/dist/types/popoverMenu.d.ts +24 -0
  101. package/dist/types/popoverMenu.d.ts.map +1 -0
  102. package/dist/types/popoverMenu.js +2 -0
  103. package/dist/types/popoverMenu.js.map +1 -0
  104. package/dist/types/tabs.d.ts +43 -0
  105. package/dist/types/tabs.d.ts.map +1 -0
  106. package/dist/types/tabs.js +2 -0
  107. package/dist/types/tabs.js.map +1 -0
  108. package/dist/{components/tooltip/types.d.ts → types/tooltip.d.ts} +2 -2
  109. package/dist/types/tooltip.d.ts.map +1 -0
  110. package/dist/types/tooltip.js +2 -0
  111. package/dist/types/tooltip.js.map +1 -0
  112. package/package.json +1 -1
  113. package/src/features/bottom-sheet/BottomSheetProvider.tsx +13 -8
  114. package/src/features/bottom-sheet/public.test.ts +23 -0
  115. package/src/features/bottom-sheet/public.ts +12 -1
  116. package/src/features/modal/adapters/inbound/Modal.tsx +74 -0
  117. package/src/features/modal/public.ts +2 -0
  118. package/src/features/popover-menu/adapters/inbound/PopoverMenu.tsx +201 -0
  119. package/src/features/popover-menu/composition/usePopoverMenuController.ts +55 -0
  120. package/src/features/popover-menu/public.test.ts +13 -0
  121. package/src/features/popover-menu/public.ts +6 -0
  122. package/src/{components/menu/navigation.test.ts → features/popover-menu/utils/resolveNextMenuIndex.test.ts} +4 -4
  123. package/src/features/popover-menu/utils/resolveNextMenuIndex.ts +21 -0
  124. package/src/features/tabs/adapters/inbound/Tab.tsx +67 -0
  125. package/src/features/tabs/adapters/inbound/TabList.tsx +50 -0
  126. package/src/{components/tabs → features/tabs/adapters/inbound}/TabPanel.tsx +6 -10
  127. package/src/features/tabs/adapters/inbound/Tabs.tsx +17 -0
  128. package/src/features/tabs/composition/TabsContext.tsx +5 -0
  129. package/src/features/tabs/composition/useTabRegistration.ts +27 -0
  130. package/src/features/tabs/composition/useTabsContext.ts +13 -0
  131. package/src/features/tabs/composition/useTabsController.ts +55 -0
  132. package/src/features/tabs/public.ts +5 -0
  133. package/src/{components/tabs/navigation.test.ts → features/tabs/utils/resolveNextTabValue.test.ts} +2 -2
  134. package/src/features/tabs/utils/resolveNextTabValue.ts +24 -0
  135. package/src/features/tabs/utils/resolveTabElementId.test.ts +19 -0
  136. package/src/features/tabs/utils/resolveTabElementId.ts +14 -0
  137. package/src/features/tooltip/adapters/inbound/Tooltip.tsx +56 -0
  138. package/src/features/tooltip/composition/useTooltipVisibility.ts +29 -0
  139. package/src/features/tooltip/public.test.ts +11 -0
  140. package/src/features/tooltip/public.ts +2 -0
  141. package/src/index.test.ts +12 -5
  142. package/src/index.ts +12 -8
  143. package/src/types/bottomSheet.ts +4 -0
  144. package/src/{components/modal/types.ts → types/modal.ts} +1 -1
  145. package/src/types/popoverMenu.ts +27 -0
  146. package/src/types/tabs.ts +51 -0
  147. package/src/{components/tooltip/types.ts → types/tooltip.ts} +1 -1
  148. package/dist/components/menu/Menu.d.ts +0 -4
  149. package/dist/components/menu/Menu.d.ts.map +0 -1
  150. package/dist/components/menu/Menu.js +0 -152
  151. package/dist/components/menu/Menu.js.map +0 -1
  152. package/dist/components/menu/index.d.ts +0 -3
  153. package/dist/components/menu/index.d.ts.map +0 -1
  154. package/dist/components/menu/index.js +0 -2
  155. package/dist/components/menu/index.js.map +0 -1
  156. package/dist/components/menu/navigation.d.ts +0 -4
  157. package/dist/components/menu/navigation.d.ts.map +0 -1
  158. package/dist/components/menu/navigation.js +0 -25
  159. package/dist/components/menu/navigation.js.map +0 -1
  160. package/dist/components/menu/types.d.ts +0 -23
  161. package/dist/components/menu/types.d.ts.map +0 -1
  162. package/dist/components/menu/types.js +0 -2
  163. package/dist/components/menu/types.js.map +0 -1
  164. package/dist/components/modal/Modal.d.ts.map +0 -1
  165. package/dist/components/modal/Modal.js +0 -59
  166. package/dist/components/modal/Modal.js.map +0 -1
  167. package/dist/components/modal/index.d.ts +0 -3
  168. package/dist/components/modal/index.d.ts.map +0 -1
  169. package/dist/components/modal/index.js +0 -2
  170. package/dist/components/modal/index.js.map +0 -1
  171. package/dist/components/modal/types.d.ts.map +0 -1
  172. package/dist/components/modal/types.js +0 -2
  173. package/dist/components/modal/types.js.map +0 -1
  174. package/dist/components/tabs/Tab.d.ts +0 -4
  175. package/dist/components/tabs/Tab.d.ts.map +0 -1
  176. package/dist/components/tabs/Tab.js +0 -48
  177. package/dist/components/tabs/Tab.js.map +0 -1
  178. package/dist/components/tabs/TabList.d.ts +0 -4
  179. package/dist/components/tabs/TabList.d.ts.map +0 -1
  180. package/dist/components/tabs/TabList.js +0 -37
  181. package/dist/components/tabs/TabList.js.map +0 -1
  182. package/dist/components/tabs/TabPanel.d.ts +0 -4
  183. package/dist/components/tabs/TabPanel.d.ts.map +0 -1
  184. package/dist/components/tabs/TabPanel.js +0 -16
  185. package/dist/components/tabs/TabPanel.js.map +0 -1
  186. package/dist/components/tabs/Tabs.d.ts +0 -4
  187. package/dist/components/tabs/Tabs.d.ts.map +0 -1
  188. package/dist/components/tabs/Tabs.js +0 -54
  189. package/dist/components/tabs/Tabs.js.map +0 -1
  190. package/dist/components/tabs/a11y.d.ts +0 -3
  191. package/dist/components/tabs/a11y.d.ts.map +0 -1
  192. package/dist/components/tabs/a11y.js +0 -13
  193. package/dist/components/tabs/a11y.js.map +0 -1
  194. package/dist/components/tabs/context.d.ts +0 -20
  195. package/dist/components/tabs/context.d.ts.map +0 -1
  196. package/dist/components/tabs/context.js.map +0 -1
  197. package/dist/components/tabs/index.d.ts +0 -6
  198. package/dist/components/tabs/index.d.ts.map +0 -1
  199. package/dist/components/tabs/index.js +0 -5
  200. package/dist/components/tabs/index.js.map +0 -1
  201. package/dist/components/tabs/navigation.d.ts +0 -3
  202. package/dist/components/tabs/navigation.d.ts.map +0 -1
  203. package/dist/components/tabs/navigation.js.map +0 -1
  204. package/dist/components/tabs/types.d.ts +0 -26
  205. package/dist/components/tabs/types.d.ts.map +0 -1
  206. package/dist/components/tabs/types.js +0 -2
  207. package/dist/components/tabs/types.js.map +0 -1
  208. package/dist/components/tooltip/Tooltip.d.ts +0 -4
  209. package/dist/components/tooltip/Tooltip.d.ts.map +0 -1
  210. package/dist/components/tooltip/Tooltip.js +0 -75
  211. package/dist/components/tooltip/Tooltip.js.map +0 -1
  212. package/dist/components/tooltip/index.d.ts +0 -3
  213. package/dist/components/tooltip/index.d.ts.map +0 -1
  214. package/dist/components/tooltip/index.js +0 -2
  215. package/dist/components/tooltip/index.js.map +0 -1
  216. package/dist/components/tooltip/types.d.ts.map +0 -1
  217. package/dist/components/tooltip/types.js +0 -2
  218. package/dist/components/tooltip/types.js.map +0 -1
  219. package/src/components/menu/Menu.tsx +0 -228
  220. package/src/components/menu/index.ts +0 -2
  221. package/src/components/menu/navigation.ts +0 -34
  222. package/src/components/menu/types.ts +0 -26
  223. package/src/components/modal/Modal.tsx +0 -96
  224. package/src/components/modal/index.ts +0 -2
  225. package/src/components/tabs/Tab.tsx +0 -89
  226. package/src/components/tabs/TabList.tsx +0 -51
  227. package/src/components/tabs/Tabs.tsx +0 -67
  228. package/src/components/tabs/a11y.test.ts +0 -15
  229. package/src/components/tabs/a11y.ts +0 -15
  230. package/src/components/tabs/context.tsx +0 -31
  231. package/src/components/tabs/index.ts +0 -5
  232. package/src/components/tabs/navigation.ts +0 -32
  233. package/src/components/tabs/types.ts +0 -30
  234. package/src/components/tooltip/Tooltip.tsx +0 -117
  235. package/src/components/tooltip/index.ts +0 -2
@@ -0,0 +1,51 @@
1
+ import type React from 'react';
2
+
3
+ import type { InteractionPolicy } from '../interactionPolicy';
4
+
5
+ export interface TabsProps {
6
+ children?: React.ReactNode;
7
+ value?: string;
8
+ defaultValue?: string;
9
+ onValueChange?: ((value: string) => void) | undefined;
10
+ testID?: string;
11
+ }
12
+
13
+ export interface TabListProps {
14
+ children?: React.ReactNode;
15
+ testID?: string;
16
+ }
17
+
18
+ export interface TabProps {
19
+ value: string;
20
+ children?: React.ReactNode;
21
+ disabled?: boolean;
22
+ interactionPolicy?: InteractionPolicy;
23
+ testID?: string;
24
+ }
25
+
26
+ export interface TabPanelProps {
27
+ value: string;
28
+ children?: React.ReactNode;
29
+ testID?: string;
30
+ }
31
+
32
+ export interface TabRegistration {
33
+ disabled: boolean;
34
+ focus: () => void;
35
+ value: string;
36
+ }
37
+
38
+ export interface TabsContextValue {
39
+ activeValue: string | undefined;
40
+ focusedValue: string | undefined;
41
+ getPanelId: (value: string) => string;
42
+ getTabId: (value: string) => string;
43
+ registerTab: (tab: TabRegistration) => void;
44
+ setActiveValue: (value: string) => void;
45
+ setFocusedValue: (value: string | undefined) => void;
46
+ tabs: readonly TabRegistration[];
47
+ unregisterTab: (value: string) => void;
48
+ }
49
+
50
+ export type TabNavigationKey =
51
+ 'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'ArrowDown' | 'Home' | 'End';
@@ -1,6 +1,6 @@
1
1
  import type React from 'react';
2
2
 
3
- import type { InteractionPolicy } from '../../interactionPolicy';
3
+ import type { InteractionPolicy } from '../interactionPolicy';
4
4
 
5
5
  export interface TooltipProps {
6
6
  children?: React.ReactNode;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { MenuProps } from './types';
3
- export declare function Menu({ trigger, actions, dismiss, closeOnSelect, interactionPolicy, testID, }: MenuProps): React.JSX.Element;
4
- //# sourceMappingURL=Menu.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Menu.d.ts","sourceRoot":"","sources":["../../../src/components/menu/Menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAe1B,OAAO,KAAK,EAAc,SAAS,EAAE,MAAM,SAAS,CAAC;AA6CrD,wBAAgB,IAAI,CAAC,EACnB,OAAO,EACP,OAAO,EACP,OAAO,EACP,aAAoB,EACpB,iBAA6B,EAC7B,MAAM,GACP,EAAE,SAAS,qBAgKX"}
@@ -1,152 +0,0 @@
1
- import React from 'react';
2
- import { Pressable, View } from 'react-native';
3
- import { Box, Stack } from '../../features/layout/public';
4
- import { Surface } from '../../features/surface/public';
5
- import { Text } from '../../features/typography/public';
6
- import { FocusScope } from '../../internal/focus/FocusScope';
7
- import { useFocusManager } from '../../internal/focus/useFocusManager';
8
- import { Portal } from '../../internal/overlay/Portal';
9
- import { resolvePointerEvents } from '../../internal/resolvePointerEvents';
10
- import { resolveOverlayAnimation } from '../../internal/resolvers';
11
- import { Inline } from '../../layout';
12
- import { ButtonBase } from '../../primitives/button-base';
13
- import { useTheme } from '../../theme/ThemeContext';
14
- import { resolveNextMenuIndex } from './navigation';
15
- const boxNonePointerEvents = resolvePointerEvents('box-none');
16
- function measureNode(node, callback) {
17
- const measurableNode = node;
18
- measurableNode?.measureInWindow?.((x, y, width, height) => {
19
- callback({ height, width, x, y });
20
- });
21
- }
22
- function renderActionContent(action, active) {
23
- const titleColor = action.intent === 'danger' ? 'danger' : active || action.selected ? 'neutral' : undefined;
24
- return (<Inline align="center" gap="s" justify="space-between" wrap="nowrap">
25
- {action.leading ? <Box>{action.leading}</Box> : null}
26
- <Box flex={1}>
27
- <Stack gap="xxs">
28
- <Text color={titleColor} variant="bodySmall" weight={action.selected ? 'semiBold' : 'medium'}>
29
- {action.title}
30
- </Text>
31
- {action.description ? (<Text emphasis="muted" variant="caption">
32
- {action.description}
33
- </Text>) : null}
34
- </Stack>
35
- </Box>
36
- {action.trailing ? <Box>{action.trailing}</Box> : null}
37
- </Inline>);
38
- }
39
- export function Menu({ trigger, actions, dismiss, closeOnSelect = true, interactionPolicy = 'enabled', testID, }) {
40
- const { theme } = useTheme();
41
- const { bindKeydown } = useFocusManager();
42
- const animation = resolveOverlayAnimation('menu');
43
- const anchorRef = React.useRef(null);
44
- const [open, setOpen] = React.useState(false);
45
- const [layout, setLayout] = React.useState(null);
46
- const [activeIndex, setActiveIndex] = React.useState(0);
47
- const passive = interactionPolicy === 'passive';
48
- const closeMenu = React.useCallback(() => {
49
- setOpen(false);
50
- if (dismiss) {
51
- dismiss();
52
- }
53
- }, [dismiss]);
54
- const activateAction = React.useCallback((action) => {
55
- if (action.disabled) {
56
- return;
57
- }
58
- if (action.activate) {
59
- action.activate();
60
- }
61
- if (closeOnSelect) {
62
- closeMenu();
63
- }
64
- }, [closeMenu, closeOnSelect]);
65
- const openMenu = React.useCallback(() => {
66
- measureNode(anchorRef.current, setLayout);
67
- const firstEnabledIndex = actions.findIndex((action) => !action.disabled);
68
- setActiveIndex(firstEnabledIndex === -1 ? 0 : firstEnabledIndex);
69
- setOpen(true);
70
- }, [actions]);
71
- React.useEffect(() => {
72
- if (!open) {
73
- return undefined;
74
- }
75
- return bindKeydown((event) => {
76
- if (passive) {
77
- return;
78
- }
79
- const { key } = event;
80
- if (key === 'ArrowDown' || key === 'ArrowUp' || key === 'Home' || key === 'End') {
81
- event.preventDefault();
82
- setActiveIndex((current) => resolveNextMenuIndex(actions, current, key));
83
- }
84
- if (event.key === 'Enter') {
85
- event.preventDefault();
86
- const activeAction = actions[activeIndex];
87
- if (activeAction) {
88
- activateAction(activeAction);
89
- }
90
- }
91
- if (event.key === 'Escape') {
92
- event.preventDefault();
93
- closeMenu();
94
- }
95
- });
96
- }, [activateAction, actions, activeIndex, bindKeydown, closeMenu, open, passive]);
97
- return (<View collapsable={false} ref={anchorRef}>
98
- <ButtonBase onPress={passive ? undefined : open ? closeMenu : openMenu} testID={testID ? `${testID}-trigger` : undefined}>
99
- {trigger}
100
- </ButtonBase>
101
- <Portal layer="menu" visible={open && Boolean(layout)}>
102
- <View {...boxNonePointerEvents.props} style={[
103
- boxNonePointerEvents.style,
104
- {
105
- bottom: 0,
106
- left: 0,
107
- position: 'absolute',
108
- right: 0,
109
- top: 0,
110
- },
111
- ]}>
112
- <Pressable onPress={passive ? undefined : closeMenu} style={{
113
- bottom: 0,
114
- left: 0,
115
- position: 'absolute',
116
- right: 0,
117
- top: 0,
118
- }}/>
119
- <FocusScope active={open} onEscape={passive ? undefined : closeMenu}>
120
- <View style={{
121
- left: layout?.x ?? 0,
122
- position: 'absolute',
123
- top: (layout?.y ?? 0) + (layout?.height ?? 0) + animation.offset,
124
- }}>
125
- <Surface accessibilityRole="menu" p="xs" style={{
126
- minWidth: Math.max(layout?.width ?? 0, 220),
127
- shadowOpacity: 0.12,
128
- shadowRadius: 12,
129
- shadowOffset: { width: 0, height: 6 },
130
- }} testID={testID} variant="raised">
131
- {actions.map((action, index) => {
132
- const active = index === activeIndex;
133
- const selected = action.selected ?? active;
134
- return (<Pressable accessibilityRole="menuitem" accessibilityState={{ disabled: action.disabled, selected }} disabled={action.disabled} key={action.id} onPress={passive ? undefined : () => activateAction(action)}>
135
- <Box px="m" py="s" radius="s" style={{
136
- backgroundColor: selected
137
- ? theme.semantics.action.neutral.softBg
138
- : 'transparent',
139
- opacity: action.disabled ? 0.56 : 1,
140
- }} testID={testID ? `${testID}-item-${action.id}` : undefined}>
141
- {renderActionContent(action, active)}
142
- </Box>
143
- </Pressable>);
144
- })}
145
- </Surface>
146
- </View>
147
- </FocusScope>
148
- </View>
149
- </Portal>
150
- </View>);
151
- }
152
- //# sourceMappingURL=Menu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Menu.js","sourceRoot":"","sources":["../../../src/components/menu/Menu.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAwB,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAErE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,C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AAC,GAAG,CACV,KAAK,CAAC,CAAC;oBACL,eAAe,EAAE,QAAQ;wBACvB,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM;wBACvC,CAAC,CAAC,aAAa;oBACjB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;iBACpC,CAAC,CACF,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,SAAS,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAE3D;wBAAA,CAAC,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC,CACtC;sBAAA,EAAE,GAAG,CACP;oBAAA,EAAE,SAAS,CAAC,CACb,CAAC;QACJ,CAAC,CAAC,CACJ;cAAA,EAAE,OAAO,CACX;YAAA,EAAE,IAAI,CACR;UAAA,EAAE,UAAU,CACd;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,MAAM,CACV;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { type LayoutRectangle, Pressable, View } from 'react-native';\n\nimport { Box, Stack } from '../../features/layout/public';\nimport { Surface } from '../../features/surface/public';\nimport { Text } from '../../features/typography/public';\nimport { FocusScope } from '../../internal/focus/FocusScope';\nimport { useFocusManager } from '../../internal/focus/useFocusManager';\nimport { Portal } from '../../internal/overlay/Portal';\nimport { resolvePointerEvents } from '../../internal/resolvePointerEvents';\nimport { resolveOverlayAnimation } from '../../internal/resolvers';\nimport { Inline } from '../../layout';\nimport { ButtonBase } from '../../primitives/button-base';\nimport { useTheme } from '../../theme/ThemeContext';\nimport { resolveNextMenuIndex } from './navigation';\nimport type { MenuAction, MenuProps } from './types';\n\nconst boxNonePointerEvents = resolvePointerEvents('box-none');\n\ninterface MeasurableNode {\n measureInWindow?: (\n callback: (x: number, y: number, width: number, height: number) => void,\n ) => void;\n}\n\nfunction measureNode(node: unknown, callback: (layout: LayoutRectangle) => void) {\n const measurableNode = node as MeasurableNode | null;\n measurableNode?.measureInWindow?.((x, y, width, height) => {\n callback({ height, width, x, y });\n });\n}\n\nfunction renderActionContent(action: MenuAction, active: boolean) {\n const titleColor =\n action.intent === 'danger' ? 'danger' : active || action.selected ? 'neutral' : undefined;\n\n return (\n <Inline align=\"center\" gap=\"s\" justify=\"space-between\" wrap=\"nowrap\">\n {action.leading ? <Box>{action.leading}</Box> : null}\n <Box flex={1}>\n <Stack gap=\"xxs\">\n <Text\n color={titleColor}\n variant=\"bodySmall\"\n weight={action.selected ? 'semiBold' : 'medium'}\n >\n {action.title}\n </Text>\n {action.description ? (\n <Text emphasis=\"muted\" variant=\"caption\">\n {action.description}\n </Text>\n ) : null}\n </Stack>\n </Box>\n {action.trailing ? <Box>{action.trailing}</Box> : null}\n </Inline>\n );\n}\n\nexport function Menu({\n trigger,\n actions,\n dismiss,\n closeOnSelect = true,\n interactionPolicy = 'enabled',\n testID,\n}: MenuProps) {\n const { theme } = useTheme();\n const { bindKeydown } = useFocusManager();\n const animation = resolveOverlayAnimation('menu');\n const anchorRef = React.useRef<View | null>(null);\n const [open, setOpen] = React.useState(false);\n const [layout, setLayout] = React.useState<LayoutRectangle | null>(null);\n const [activeIndex, setActiveIndex] = React.useState(0);\n const passive = interactionPolicy === 'passive';\n\n const closeMenu = React.useCallback(() => {\n setOpen(false);\n if (dismiss) {\n dismiss();\n }\n }, [dismiss]);\n\n const activateAction = React.useCallback(\n (action: MenuAction) => {\n if (action.disabled) {\n return;\n }\n\n if (action.activate) {\n action.activate();\n }\n\n if (closeOnSelect) {\n closeMenu();\n }\n },\n [closeMenu, closeOnSelect],\n );\n\n const openMenu = React.useCallback(() => {\n measureNode(anchorRef.current, setLayout);\n const firstEnabledIndex = actions.findIndex((action) => !action.disabled);\n setActiveIndex(firstEnabledIndex === -1 ? 0 : firstEnabledIndex);\n setOpen(true);\n }, [actions]);\n\n React.useEffect(() => {\n if (!open) {\n return undefined;\n }\n\n return bindKeydown((event) => {\n if (passive) {\n return;\n }\n\n const { key } = event;\n if (key === 'ArrowDown' || key === 'ArrowUp' || key === 'Home' || key === 'End') {\n event.preventDefault();\n setActiveIndex((current) => resolveNextMenuIndex(actions, current, key));\n }\n\n if (event.key === 'Enter') {\n event.preventDefault();\n const activeAction = actions[activeIndex];\n if (activeAction) {\n activateAction(activeAction);\n }\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n closeMenu();\n }\n });\n }, [activateAction, actions, activeIndex, bindKeydown, closeMenu, open, passive]);\n\n return (\n <View collapsable={false} ref={anchorRef}>\n <ButtonBase\n onPress={passive ? undefined : open ? closeMenu : openMenu}\n testID={testID ? `${testID}-trigger` : undefined}\n >\n {trigger}\n </ButtonBase>\n <Portal layer=\"menu\" visible={open && Boolean(layout)}>\n <View\n {...boxNonePointerEvents.props}\n style={[\n boxNonePointerEvents.style,\n {\n bottom: 0,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n },\n ]}\n >\n <Pressable\n onPress={passive ? undefined : closeMenu}\n style={{\n bottom: 0,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n }}\n />\n <FocusScope active={open} onEscape={passive ? undefined : closeMenu}>\n <View\n style={{\n left: layout?.x ?? 0,\n position: 'absolute',\n top: (layout?.y ?? 0) + (layout?.height ?? 0) + animation.offset,\n }}\n >\n <Surface\n accessibilityRole=\"menu\"\n p=\"xs\"\n style={{\n minWidth: Math.max(layout?.width ?? 0, 220),\n shadowOpacity: 0.12,\n shadowRadius: 12,\n shadowOffset: { width: 0, height: 6 },\n }}\n testID={testID}\n variant=\"raised\"\n >\n {actions.map((action, index) => {\n const active = index === activeIndex;\n const selected = action.selected ?? active;\n\n return (\n <Pressable\n accessibilityRole=\"menuitem\"\n accessibilityState={{ disabled: action.disabled, selected }}\n disabled={action.disabled}\n key={action.id}\n onPress={passive ? undefined : () => activateAction(action)}\n >\n <Box\n px=\"m\"\n py=\"s\"\n radius=\"s\"\n style={{\n backgroundColor: selected\n ? theme.semantics.action.neutral.softBg\n : 'transparent',\n opacity: action.disabled ? 0.56 : 1,\n }}\n testID={testID ? `${testID}-item-${action.id}` : undefined}\n >\n {renderActionContent(action, active)}\n </Box>\n </Pressable>\n );\n })}\n </Surface>\n </View>\n </FocusScope>\n </View>\n </Portal>\n </View>\n );\n}\n"]}
@@ -1,3 +0,0 @@
1
- export { Menu } from './Menu';
2
- export type { MenuAction, MenuActionIntent, MenuAction as MenuItem, MenuProps } from './types';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/menu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,UAAU,IAAI,QAAQ,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
@@ -1,2 +0,0 @@
1
- export { Menu } from './Menu';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/menu/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC","sourcesContent":["export { Menu } from './Menu';\nexport type { MenuAction, MenuActionIntent, MenuAction as MenuItem, MenuProps } from './types';\n"]}
@@ -1,4 +0,0 @@
1
- export declare function resolveNextMenuIndex(items: readonly {
2
- disabled?: boolean;
3
- }[], currentIndex: number, key: 'ArrowDown' | 'ArrowUp' | 'Home' | 'End'): number;
4
- //# sourceMappingURL=navigation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"navigation.d.ts","sourceRoot":"","sources":["../../../src/components/menu/navigation.ts"],"names":[],"mappings":"AAAA,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,EACxC,YAAY,EAAE,MAAM,EACpB,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,KAAK,GAC5C,MAAM,CA6BR"}
@@ -1,25 +0,0 @@
1
- export function resolveNextMenuIndex(items, currentIndex, key) {
2
- const enabledIndexes = items.reduce((indexes, item, index) => {
3
- if (!item.disabled) {
4
- indexes.push(index);
5
- }
6
- return indexes;
7
- }, []);
8
- if (enabledIndexes.length === 0) {
9
- return -1;
10
- }
11
- if (key === 'Home') {
12
- return enabledIndexes[0] ?? -1;
13
- }
14
- if (key === 'End') {
15
- return enabledIndexes[enabledIndexes.length - 1] ?? -1;
16
- }
17
- const activeEnabledIndex = enabledIndexes.indexOf(currentIndex);
18
- const nextEnabledIndex = activeEnabledIndex === -1
19
- ? 0
20
- : key === 'ArrowUp'
21
- ? (activeEnabledIndex - 1 + enabledIndexes.length) % enabledIndexes.length
22
- : (activeEnabledIndex + 1) % enabledIndexes.length;
23
- return enabledIndexes[nextEnabledIndex] ?? -1;
24
- }
25
- //# sourceMappingURL=navigation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"navigation.js","sourceRoot":"","sources":["../../../src/components/menu/navigation.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,oBAAoB,CAClC,KAAwC,EACxC,YAAoB,EACpB,GAA6C;IAE7C,MAAM,cAAc,GAAG,KAAK,CAAC,MAAM,CAAW,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;QACrE,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACtB,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,IAAI,cAAc,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAChC,OAAO,CAAC,CAAC,CAAC;IACZ,CAAC;IAED,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QACnB,OAAO,cAAc,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,GAAG,KAAK,KAAK,EAAE,CAAC;QAClB,OAAO,cAAc,CAAC,cAAc,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,MAAM,kBAAkB,GAAG,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAChE,MAAM,gBAAgB,GACpB,kBAAkB,KAAK,CAAC,CAAC;QACvB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,GAAG,KAAK,SAAS;YACjB,CAAC,CAAC,CAAC,kBAAkB,GAAG,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,cAAc,CAAC,MAAM;YAC1E,CAAC,CAAC,CAAC,kBAAkB,GAAG,CAAC,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC;IAEzD,OAAO,cAAc,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC;AAChD,CAAC","sourcesContent":["export function resolveNextMenuIndex(\n items: readonly { disabled?: boolean }[],\n currentIndex: number,\n key: 'ArrowDown' | 'ArrowUp' | 'Home' | 'End',\n): number {\n const enabledIndexes = items.reduce<number[]>((indexes, item, index) => {\n if (!item.disabled) {\n indexes.push(index);\n }\n return indexes;\n }, []);\n\n if (enabledIndexes.length === 0) {\n return -1;\n }\n\n if (key === 'Home') {\n return enabledIndexes[0] ?? -1;\n }\n\n if (key === 'End') {\n return enabledIndexes[enabledIndexes.length - 1] ?? -1;\n }\n\n const activeEnabledIndex = enabledIndexes.indexOf(currentIndex);\n const nextEnabledIndex =\n activeEnabledIndex === -1\n ? 0\n : key === 'ArrowUp'\n ? (activeEnabledIndex - 1 + enabledIndexes.length) % enabledIndexes.length\n : (activeEnabledIndex + 1) % enabledIndexes.length;\n\n return enabledIndexes[nextEnabledIndex] ?? -1;\n}\n"]}
@@ -1,23 +0,0 @@
1
- import type React from 'react';
2
- import type { InteractionPolicy } from '../../interactionPolicy';
3
- export type MenuActionIntent = 'default' | 'danger';
4
- export interface MenuAction {
5
- id: string;
6
- title: React.ReactNode;
7
- description?: React.ReactNode;
8
- leading?: React.ReactNode;
9
- trailing?: React.ReactNode;
10
- intent?: MenuActionIntent;
11
- disabled?: boolean;
12
- selected?: boolean;
13
- activate?: () => void;
14
- }
15
- export interface MenuProps {
16
- trigger?: React.ReactNode;
17
- actions: readonly MenuAction[];
18
- dismiss?: () => void;
19
- closeOnSelect?: boolean;
20
- interactionPolicy?: InteractionPolicy;
21
- testID?: string;
22
- }
23
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/menu/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,MAAM,gBAAgB,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEpD,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC;IACvB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,SAAS,UAAU,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/menu/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { InteractionPolicy } from '../../interactionPolicy';\n\nexport type MenuActionIntent = 'default' | 'danger';\n\nexport interface MenuAction {\n id: string;\n title: React.ReactNode;\n description?: React.ReactNode;\n leading?: React.ReactNode;\n trailing?: React.ReactNode;\n intent?: MenuActionIntent;\n disabled?: boolean;\n selected?: boolean;\n activate?: () => void;\n}\n\nexport interface MenuProps {\n trigger?: React.ReactNode;\n actions: readonly MenuAction[];\n dismiss?: () => void;\n closeOnSelect?: boolean;\n interactionPolicy?: InteractionPolicy;\n testID?: string;\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAI1C,wBAAgB,KAAK,CAAC,EACpB,OAAO,EACP,SAAS,EACT,QAAQ,EACR,eAAsB,EACtB,iBAA6B,EAC7B,MAAM,GACP,EAAE,UAAU,4BA0EZ"}
@@ -1,59 +0,0 @@
1
- import React from 'react';
2
- import { Pressable, View } from 'react-native';
3
- import { Surface } from '../../features/surface/public';
4
- import { FocusScope } from '../../internal/focus/FocusScope';
5
- import { Portal } from '../../internal/overlay/Portal';
6
- import { resolvePointerEvents } from '../../internal/resolvePointerEvents';
7
- import { resolveOverlayAnimation } from '../../internal/resolvers';
8
- import { Center } from '../../layout';
9
- import { useTheme } from '../../theme/ThemeContext';
10
- const boxNonePointerEvents = resolvePointerEvents('box-none');
11
- export function Modal({ visible, onDismiss, children, closeOnBackdrop = true, interactionPolicy = 'enabled', testID, }) {
12
- const { theme } = useTheme();
13
- const animation = resolveOverlayAnimation('modal');
14
- const passive = interactionPolicy === 'passive';
15
- if (!visible) {
16
- return null;
17
- }
18
- return (<Portal layer="modal" visible={visible}>
19
- <View {...boxNonePointerEvents.props} style={[
20
- boxNonePointerEvents.style,
21
- {
22
- bottom: 0,
23
- left: 0,
24
- position: 'absolute',
25
- right: 0,
26
- top: 0,
27
- },
28
- ]}>
29
- <Pressable onPress={passive ? undefined : closeOnBackdrop ? onDismiss : undefined} style={{
30
- backgroundColor: theme.semantics.neutral.text,
31
- bottom: 0,
32
- left: 0,
33
- opacity: animation.backdropOpacity,
34
- position: 'absolute',
35
- right: 0,
36
- top: 0,
37
- }} testID={testID ? `${testID}-backdrop` : undefined}/>
38
- <FocusScope active={visible} onEscape={passive ? undefined : onDismiss} testID={testID ? `${testID}-focus` : undefined}>
39
- <Center p="l" style={{
40
- flex: 1,
41
- }}>
42
- <View accessible accessibilityViewIsModal style={{
43
- maxWidth: 560,
44
- width: '100%',
45
- }}>
46
- <Surface p="l" style={{
47
- shadowOpacity: 0.14,
48
- shadowRadius: 18,
49
- shadowOffset: { width: 0, height: 8 },
50
- }} testID={testID} variant="raised">
51
- {children}
52
- </Surface>
53
- </View>
54
- </Center>
55
- </FocusScope>
56
- </View>
57
- </Portal>);
58
- }
59
- //# sourceMappingURL=Modal.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../../src/components/modal/Modal.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OA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C;YACT,IAAI,EAAE,CAAC;YACP,OAAO,EAAE,SAAS,CAAC,eAAe;YAClC,QAAQ,EAAE,UAAU;YACpB,KAAK,EAAE,CAAC;YACR,GAAG,EAAE,CAAC;SACP,CAAC,CACF,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,EAEpD;QAAA,CAAC,UAAU,CACT,MAAM,CAAC,CAAC,OAAO,CAAC,CAChB,QAAQ,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAC1C,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAE/C;UAAA,CAAC,MAAM,CACL,CAAC,CAAC,GAAG,CACL,KAAK,CAAC,CAAC;YACL,IAAI,EAAE,CAAC;SACR,CAAC,CAEF;YAAA,CAAC,IAAI,CACH,UAAU,CACV,wBAAwB,CACxB,KAAK,CAAC,CAAC;YACL,QAAQ,EAAE,GAAG;YACb,KAAK,EAAE,MAAM;SACd,CAAC,CAEF;cAAA,CAAC,OAAO,CACN,CAAC,CAAC,GAAG,CACL,KAAK,CAAC,CAAC;YACL,aAAa,EAAE,IAAI;YACnB,YAAY,EAAE,EAAE;YAChB,YAAY,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;SACtC,CAAC,CACF,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,OAAO,CAAC,QAAQ,CAEhB;gBAAA,CAAC,QAAQ,CACX;cAAA,EAAE,OAAO,CACX;YAAA,EAAE,IAAI,CACR;UAAA,EAAE,MAAM,CACV;QAAA,EAAE,UAAU,CACd;MAAA,EAAE,IAAI,CACR;IAAA,EAAE,MAAM,CAAC,CACV,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Pressable, View } from 'react-native';\n\nimport { Surface } from '../../features/surface/public';\nimport { FocusScope } from '../../internal/focus/FocusScope';\nimport { Portal } from '../../internal/overlay/Portal';\nimport { resolvePointerEvents } from '../../internal/resolvePointerEvents';\nimport { resolveOverlayAnimation } from '../../internal/resolvers';\nimport { Center } from '../../layout';\nimport { useTheme } from '../../theme/ThemeContext';\nimport type { ModalProps } from './types';\n\nconst boxNonePointerEvents = resolvePointerEvents('box-none');\n\nexport function Modal({\n visible,\n onDismiss,\n children,\n closeOnBackdrop = true,\n interactionPolicy = 'enabled',\n testID,\n}: ModalProps) {\n const { theme } = useTheme();\n const animation = resolveOverlayAnimation('modal');\n const passive = interactionPolicy === 'passive';\n\n if (!visible) {\n return null;\n }\n\n return (\n <Portal layer=\"modal\" visible={visible}>\n <View\n {...boxNonePointerEvents.props}\n style={[\n boxNonePointerEvents.style,\n {\n bottom: 0,\n left: 0,\n position: 'absolute',\n right: 0,\n top: 0,\n },\n ]}\n >\n <Pressable\n onPress={passive ? undefined : closeOnBackdrop ? onDismiss : undefined}\n style={{\n backgroundColor: theme.semantics.neutral.text,\n bottom: 0,\n left: 0,\n opacity: animation.backdropOpacity,\n position: 'absolute',\n right: 0,\n top: 0,\n }}\n testID={testID ? `${testID}-backdrop` : undefined}\n />\n <FocusScope\n active={visible}\n onEscape={passive ? undefined : onDismiss}\n testID={testID ? `${testID}-focus` : undefined}\n >\n <Center\n p=\"l\"\n style={{\n flex: 1,\n }}\n >\n <View\n accessible\n accessibilityViewIsModal\n style={{\n maxWidth: 560,\n width: '100%',\n }}\n >\n <Surface\n p=\"l\"\n style={{\n shadowOpacity: 0.14,\n shadowRadius: 18,\n shadowOffset: { width: 0, height: 8 },\n }}\n testID={testID}\n variant=\"raised\"\n >\n {children}\n </Surface>\n </View>\n </Center>\n </FocusScope>\n </View>\n </Portal>\n );\n}\n"]}
@@ -1,3 +0,0 @@
1
- export { Modal } from './Modal';
2
- export type { ModalProps } from './types';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/modal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC"}
@@ -1,2 +0,0 @@
1
- export { Modal } from './Modal';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/modal/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC","sourcesContent":["export { Modal } from './Modal';\nexport type { ModalProps } from './types';\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/modal/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACrC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/modal/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { InteractionPolicy } from '../../interactionPolicy';\n\nexport interface ModalProps {\n visible: boolean;\n onDismiss?: (() => void) | undefined;\n children?: React.ReactNode;\n closeOnBackdrop?: boolean;\n interactionPolicy?: InteractionPolicy;\n testID?: string;\n}\n"]}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { TabProps } from './types';
3
- export declare function Tab({ value, children, disabled, interactionPolicy, testID, }: TabProps): React.JSX.Element;
4
- //# sourceMappingURL=Tab.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tab.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/Tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAO1B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC,wBAAgB,GAAG,CAAC,EAClB,KAAK,EACL,QAAQ,EACR,QAAgB,EAChB,iBAA6B,EAC7B,MAAM,GACP,EAAE,QAAQ,qBAyEV"}
@@ -1,48 +0,0 @@
1
- import React from 'react';
2
- import { Pressable } from 'react-native';
3
- import { Box } from '../../features/layout/public';
4
- import { Text } from '../../features/typography/public';
5
- import { useTheme } from '../../theme/ThemeContext';
6
- import { useTabsContext } from './context';
7
- export function Tab({ value, children, disabled = false, interactionPolicy = 'enabled', testID, }) {
8
- const { theme } = useTheme();
9
- const { activeValue, getPanelId, getTabId, registerTab, setActiveValue, setFocusedValue, unregisterTab, } = useTabsContext();
10
- const pressableRef = React.useRef(null);
11
- const selected = activeValue === value;
12
- const tabId = getTabId(value);
13
- const panelId = getPanelId(value);
14
- const passive = interactionPolicy === 'passive';
15
- React.useEffect(() => {
16
- registerTab({
17
- disabled,
18
- focus: () => {
19
- const focusable = pressableRef.current;
20
- focusable?.focus?.();
21
- },
22
- value,
23
- });
24
- return () => {
25
- unregisterTab(value);
26
- };
27
- }, [disabled, registerTab, unregisterTab, value]);
28
- return (<Pressable accessibilityLabel={undefined} accessibilityRole="tab" accessibilityState={{ disabled, selected }} nativeID={tabId} aria-controls={panelId} disabled={disabled} onFocus={() => setFocusedValue(value)} onBlur={() => setFocusedValue(undefined)} onPress={passive
29
- ? undefined
30
- : () => {
31
- if (!disabled) {
32
- setActiveValue(value);
33
- }
34
- }} ref={pressableRef} testID={testID}>
35
- <Box px="m" py="s" style={{
36
- borderBottomColor: selected
37
- ? theme.semantics.action.primary.base
38
- : theme.semantics.border.default,
39
- borderBottomWidth: 2,
40
- opacity: disabled ? 0.64 : 1,
41
- }}>
42
- <Text color={selected ? 'primary' : undefined} variant="label" weight="medium">
43
- {children}
44
- </Text>
45
- </Box>
46
- </Pressable>);
47
- }
48
- //# sourceMappingURL=Tab.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Tab.js","sourceRoot":"","sources":["../../../src/components/tabs/Tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,UAAU,GAAG,CAAC,EAClB,KAAK,EACL,QAAQ,EACR,QAAQ,GAAG,KAAK,EAChB,iBAAiB,GAAG,SAAS,EAC7B,MAAM,GACG;IACT,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,EAAE,CAAC;IAC7B,MAAM,EACJ,WAAW,EACX,UAAU,EACV,QAAQ,EACR,WAAW,EACX,cAAc,EACd,eAAe,EACf,aAAa,GACd,GAAG,cAAc,EAAE,CAAC;IACrB,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CAA4C,IAAI,CAAC,CAAC;IACnF,MAAM,QAAQ,GAAG,WAAW,KAAK,KAAK,CAAC;IACvC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,OAAO,GAAG,iBAAiB,KAAK,SAAS,CAAC;IAEhD,KAAK,CAAC,SAAS,CAAC,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C,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO;YAClC,iBAAiB,EAAE,CAAC;YACpB,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;SAC7B,CAAC,CAEF;QAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAC5E;UAAA,CAAC,QAAQ,CACX;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,GAAG,CACP;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Pressable } from 'react-native';\n\nimport { Box } from '../../features/layout/public';\nimport { Text } from '../../features/typography/public';\nimport { useTheme } from '../../theme/ThemeContext';\nimport { useTabsContext } from './context';\nimport type { TabProps } from './types';\n\nexport function Tab({\n value,\n children,\n disabled = false,\n interactionPolicy = 'enabled',\n testID,\n}: TabProps) {\n const { theme } = useTheme();\n const {\n activeValue,\n getPanelId,\n getTabId,\n registerTab,\n setActiveValue,\n setFocusedValue,\n unregisterTab,\n } = useTabsContext();\n const pressableRef = React.useRef<React.ElementRef<typeof Pressable> | null>(null);\n const selected = activeValue === value;\n const tabId = getTabId(value);\n const panelId = getPanelId(value);\n const passive = interactionPolicy === 'passive';\n\n React.useEffect(() => {\n registerTab({\n disabled,\n focus: () => {\n const focusable = pressableRef.current as unknown as {\n focus?: (() => void) | undefined;\n } | null;\n focusable?.focus?.();\n },\n value,\n });\n\n return () => {\n unregisterTab(value);\n };\n }, [disabled, registerTab, unregisterTab, value]);\n\n return (\n <Pressable\n accessibilityLabel={undefined}\n accessibilityRole=\"tab\"\n accessibilityState={{ disabled, selected }}\n nativeID={tabId}\n aria-controls={panelId}\n disabled={disabled}\n onFocus={() => setFocusedValue(value)}\n onBlur={() => setFocusedValue(undefined)}\n onPress={\n passive\n ? undefined\n : () => {\n if (!disabled) {\n setActiveValue(value);\n }\n }\n }\n ref={pressableRef}\n testID={testID}\n >\n <Box\n px=\"m\"\n py=\"s\"\n style={{\n borderBottomColor: selected\n ? theme.semantics.action.primary.base\n : theme.semantics.border.default,\n borderBottomWidth: 2,\n opacity: disabled ? 0.64 : 1,\n }}\n >\n <Text color={selected ? 'primary' : undefined} variant=\"label\" weight=\"medium\">\n {children}\n </Text>\n </Box>\n </Pressable>\n );\n}\n"]}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { TabListProps } from './types';
3
- export declare function TabList({ children, testID }: TabListProps): React.JSX.Element;
4
- //# sourceMappingURL=TabList.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabList.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/TabList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C,wBAAgB,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,YAAY,qBA0CzD"}
@@ -1,37 +0,0 @@
1
- import React from 'react';
2
- import { Box } from '../../features/layout/public';
3
- import { useFocusManager } from '../../internal/focus/useFocusManager';
4
- import { useTabsContext } from './context';
5
- import { resolveNextTabValue } from './navigation';
6
- export function TabList({ children, testID }) {
7
- const { bindKeydown } = useFocusManager();
8
- const { focusedValue, setActiveValue, tabs } = useTabsContext();
9
- React.useEffect(() => {
10
- if (!focusedValue) {
11
- return undefined;
12
- }
13
- return bindKeydown((event) => {
14
- const nextValue = event.key === 'ArrowLeft' ||
15
- event.key === 'ArrowRight' ||
16
- event.key === 'ArrowUp' ||
17
- event.key === 'ArrowDown' ||
18
- event.key === 'Home' ||
19
- event.key === 'End'
20
- ? resolveNextTabValue(tabs, focusedValue, event.key)
21
- : undefined;
22
- if (!nextValue) {
23
- return;
24
- }
25
- event.preventDefault();
26
- const nextTab = tabs.find((tab) => tab.value === nextValue);
27
- nextTab?.focus();
28
- setActiveValue(nextValue);
29
- });
30
- }, [bindKeydown, focusedValue, setActiveValue, tabs]);
31
- return (<Box accessibilityRole="tablist" style={{
32
- flexDirection: 'row',
33
- }} testID={testID}>
34
- {children}
35
- </Box>);
36
- }
37
- //# sourceMappingURL=TabList.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabList.js","sourceRoot":"","sources":["../../../src/components/tabs/TabList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,GAAG,EAAE,MAAM,8BAA8B,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGnD,MAAM,UAAU,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAgB;IACxD,MAAM,EAAE,WAAW,EAAE,GAAG,eAAe,EAAE,CAAC;IAC1C,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE,CAAC;IAEhE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE;YAC3B,MAAM,SAAS,GACb,KAAK,CAAC,GAAG,KAAK,WAAW;gBACzB,KAAK,CAAC,GAAG,KAAK,YAAY;gBAC1B,KAAK,CAAC,GAAG,KAAK,SAAS;gBACvB,KAAK,CAAC,GAAG,KAAK,WAAW;gBACzB,KAAK,CAAC,GAAG,KAAK,MAAM;gBACpB,KAAK,CAAC,GAAG,KAAK,KAAK;gBACjB,CAAC,CAAC,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,CAAC,GAAG,CAAC;gBACpD,CAAC,CAAC,SAAS,CAAC;YAEhB,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,OAAO;YACT,CAAC;YAED,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC;YAC5D,OAAO,EAAE,KAAK,EAAE,CAAC;YACjB,cAAc,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC;IAEtD,OAAO,CACL,CAAC,GAAG,CACF,iBAAiB,CAAC,SAAS,CAC3B,KAAK,CAAC,CAAC;YACL,aAAa,EAAE,KAAK;SACrB,CAAC,CACF,MAAM,CAAC,CAAC,MAAM,CAAC,CAEf;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,GAAG,CAAC,CACP,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\n\nimport { Box } from '../../features/layout/public';\nimport { useFocusManager } from '../../internal/focus/useFocusManager';\nimport { useTabsContext } from './context';\nimport { resolveNextTabValue } from './navigation';\nimport type { TabListProps } from './types';\n\nexport function TabList({ children, testID }: TabListProps) {\n const { bindKeydown } = useFocusManager();\n const { focusedValue, setActiveValue, tabs } = useTabsContext();\n\n React.useEffect(() => {\n if (!focusedValue) {\n return undefined;\n }\n\n return bindKeydown((event) => {\n const nextValue =\n event.key === 'ArrowLeft' ||\n event.key === 'ArrowRight' ||\n event.key === 'ArrowUp' ||\n event.key === 'ArrowDown' ||\n event.key === 'Home' ||\n event.key === 'End'\n ? resolveNextTabValue(tabs, focusedValue, event.key)\n : undefined;\n\n if (!nextValue) {\n return;\n }\n\n event.preventDefault();\n const nextTab = tabs.find((tab) => tab.value === nextValue);\n nextTab?.focus();\n setActiveValue(nextValue);\n });\n }, [bindKeydown, focusedValue, setActiveValue, tabs]);\n\n return (\n <Box\n accessibilityRole=\"tablist\"\n style={{\n flexDirection: 'row',\n }}\n testID={testID}\n >\n {children}\n </Box>\n );\n}\n"]}
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- import type { TabPanelProps } from './types';
3
- export declare function TabPanel({ value, children, testID }: TabPanelProps): React.JSX.Element | null;
4
- //# sourceMappingURL=TabPanel.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabPanel.d.ts","sourceRoot":"","sources":["../../../src/components/tabs/TabPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAI7C,wBAAgB,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,aAAa,4BAoBlE"}
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import { View } from 'react-native';
3
- import { useTabsContext } from './context';
4
- const TAB_PANEL_ROLE = 'tabpanel';
5
- export function TabPanel({ value, children, testID }) {
6
- const { activeValue, getPanelId, getTabId } = useTabsContext();
7
- if (activeValue !== value) {
8
- return null;
9
- }
10
- const tabId = getTabId(value);
11
- const panelId = getPanelId(value);
12
- return (<View accessibilityLabelledBy={tabId} accessibilityRole={TAB_PANEL_ROLE} nativeID={panelId} testID={testID}>
13
- {children}
14
- </View>);
15
- }
16
- //# sourceMappingURL=TabPanel.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TabPanel.js","sourceRoot":"","sources":["../../../src/components/tabs/TabPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAG3C,MAAM,cAAc,GAAG,UAAoE,CAAC;AAE5F,MAAM,UAAU,QAAQ,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAiB;IACjE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAE,CAAC;IAE/D,IAAI,WAAW,KAAK,KAAK,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAC9B,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IAElC,OAAO,CACL,CAAC,IAAI,CACH,uBAAuB,CAAC,CAAC,KAAK,CAAC,CAC/B,iBAAiB,CAAC,CAAC,cAAc,CAAC,CAClC,QAAQ,CAAC,CAAC,OAAO,CAAC,CAClB,MAAM,CAAC,CAAC,MAAM,CAAC,CAEf;MAAA,CAAC,QAAQ,CACX;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { View } from 'react-native';\n\nimport { useTabsContext } from './context';\nimport type { TabPanelProps } from './types';\n\nconst TAB_PANEL_ROLE = 'tabpanel' as React.ComponentProps<typeof View>['accessibilityRole'];\n\nexport function TabPanel({ value, children, testID }: TabPanelProps) {\n const { activeValue, getPanelId, getTabId } = useTabsContext();\n\n if (activeValue !== value) {\n return null;\n }\n\n const tabId = getTabId(value);\n const panelId = getPanelId(value);\n\n return (\n <View\n accessibilityLabelledBy={tabId}\n accessibilityRole={TAB_PANEL_ROLE}\n nativeID={panelId}\n testID={testID}\n >\n {children}\n </View>\n );\n}\n"]}