@ankhorage/surface 2.0.3 → 2.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 (134) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/components/action-sheet/ActionSheet.d.ts +1 -1
  3. package/dist/components/action-sheet/ActionSheet.d.ts.map +1 -1
  4. package/dist/components/action-sheet/ActionSheet.js +5 -4
  5. package/dist/components/action-sheet/ActionSheet.js.map +1 -1
  6. package/dist/components/action-sheet/ActionSheetItem.d.ts +1 -1
  7. package/dist/components/action-sheet/ActionSheetItem.d.ts.map +1 -1
  8. package/dist/components/action-sheet/ActionSheetItem.js +2 -2
  9. package/dist/components/action-sheet/ActionSheetItem.js.map +1 -1
  10. package/dist/components/action-sheet/types.d.ts +3 -0
  11. package/dist/components/action-sheet/types.d.ts.map +1 -1
  12. package/dist/components/action-sheet/types.js.map +1 -1
  13. package/dist/components/drawer/Drawer.d.ts +1 -1
  14. package/dist/components/drawer/Drawer.d.ts.map +1 -1
  15. package/dist/components/drawer/Drawer.js +4 -3
  16. package/dist/components/drawer/Drawer.js.map +1 -1
  17. package/dist/components/drawer/types.d.ts +2 -0
  18. package/dist/components/drawer/types.d.ts.map +1 -1
  19. package/dist/components/drawer/types.js.map +1 -1
  20. package/dist/components/menu/Menu.d.ts +1 -1
  21. package/dist/components/menu/Menu.d.ts.map +1 -1
  22. package/dist/components/menu/Menu.js +10 -6
  23. package/dist/components/menu/Menu.js.map +1 -1
  24. package/dist/components/menu/types.d.ts +2 -0
  25. package/dist/components/menu/types.d.ts.map +1 -1
  26. package/dist/components/menu/types.js.map +1 -1
  27. package/dist/components/modal/Modal.d.ts +1 -1
  28. package/dist/components/modal/Modal.d.ts.map +1 -1
  29. package/dist/components/modal/Modal.js +4 -3
  30. package/dist/components/modal/Modal.js.map +1 -1
  31. package/dist/components/modal/types.d.ts +2 -0
  32. package/dist/components/modal/types.d.ts.map +1 -1
  33. package/dist/components/modal/types.js.map +1 -1
  34. package/dist/components/navigation/DrawerNavigation.d.ts +1 -1
  35. package/dist/components/navigation/DrawerNavigation.d.ts.map +1 -1
  36. package/dist/components/navigation/DrawerNavigation.js +2 -2
  37. package/dist/components/navigation/DrawerNavigation.js.map +1 -1
  38. package/dist/components/navigation/DrawerNavigationItem.d.ts +1 -1
  39. package/dist/components/navigation/DrawerNavigationItem.d.ts.map +1 -1
  40. package/dist/components/navigation/DrawerNavigationItem.js +2 -2
  41. package/dist/components/navigation/DrawerNavigationItem.js.map +1 -1
  42. package/dist/components/navigation/NavigationItem.d.ts +1 -1
  43. package/dist/components/navigation/NavigationItem.d.ts.map +1 -1
  44. package/dist/components/navigation/NavigationItem.js +2 -2
  45. package/dist/components/navigation/NavigationItem.js.map +1 -1
  46. package/dist/components/navigation/NavigationList.d.ts +1 -1
  47. package/dist/components/navigation/NavigationList.d.ts.map +1 -1
  48. package/dist/components/navigation/NavigationList.js +2 -2
  49. package/dist/components/navigation/NavigationList.js.map +1 -1
  50. package/dist/components/navigation/TabBar.d.ts +1 -1
  51. package/dist/components/navigation/TabBar.d.ts.map +1 -1
  52. package/dist/components/navigation/TabBar.js +2 -2
  53. package/dist/components/navigation/TabBar.js.map +1 -1
  54. package/dist/components/navigation/TabBarItem.d.ts +1 -1
  55. package/dist/components/navigation/TabBarItem.d.ts.map +1 -1
  56. package/dist/components/navigation/TabBarItem.js +2 -2
  57. package/dist/components/navigation/TabBarItem.js.map +1 -1
  58. package/dist/components/navigation/types.d.ts +7 -0
  59. package/dist/components/navigation/types.d.ts.map +1 -1
  60. package/dist/components/navigation/types.js.map +1 -1
  61. package/dist/components/tabs/Tab.d.ts +1 -1
  62. package/dist/components/tabs/Tab.d.ts.map +1 -1
  63. package/dist/components/tabs/Tab.js +9 -6
  64. package/dist/components/tabs/Tab.js.map +1 -1
  65. package/dist/components/tabs/types.d.ts +2 -0
  66. package/dist/components/tabs/types.d.ts.map +1 -1
  67. package/dist/components/tabs/types.js.map +1 -1
  68. package/dist/components/text-input/TextInput.d.ts +1 -1
  69. package/dist/components/text-input/TextInput.d.ts.map +1 -1
  70. package/dist/components/text-input/TextInput.js +8 -2
  71. package/dist/components/text-input/TextInput.js.map +1 -1
  72. package/dist/components/text-input/types.d.ts +2 -0
  73. package/dist/components/text-input/types.d.ts.map +1 -1
  74. package/dist/components/text-input/types.js.map +1 -1
  75. package/dist/components/toast/Toast.d.ts +1 -1
  76. package/dist/components/toast/Toast.d.ts.map +1 -1
  77. package/dist/components/toast/Toast.js +3 -2
  78. package/dist/components/toast/Toast.js.map +1 -1
  79. package/dist/components/toast/types.d.ts +2 -0
  80. package/dist/components/toast/types.d.ts.map +1 -1
  81. package/dist/components/toast/types.js.map +1 -1
  82. package/dist/components/tooltip/Tooltip.d.ts +1 -1
  83. package/dist/components/tooltip/Tooltip.d.ts.map +1 -1
  84. package/dist/components/tooltip/Tooltip.js +3 -2
  85. package/dist/components/tooltip/Tooltip.js.map +1 -1
  86. package/dist/components/tooltip/types.d.ts +2 -0
  87. package/dist/components/tooltip/types.d.ts.map +1 -1
  88. package/dist/components/tooltip/types.js.map +1 -1
  89. package/dist/index.d.ts +1 -0
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js.map +1 -1
  92. package/dist/interactionPolicy.d.ts +5 -0
  93. package/dist/interactionPolicy.d.ts.map +1 -0
  94. package/dist/interactionPolicy.js +2 -0
  95. package/dist/interactionPolicy.js.map +1 -0
  96. package/dist/primitives/button-base/ButtonBase.d.ts +1 -1
  97. package/dist/primitives/button-base/ButtonBase.d.ts.map +1 -1
  98. package/dist/primitives/button-base/ButtonBase.js +3 -2
  99. package/dist/primitives/button-base/ButtonBase.js.map +1 -1
  100. package/dist/primitives/button-base/types.d.ts +2 -1
  101. package/dist/primitives/button-base/types.d.ts.map +1 -1
  102. package/dist/primitives/button-base/types.js.map +1 -1
  103. package/package.json +1 -1
  104. package/src/components/action-sheet/ActionSheet.tsx +5 -2
  105. package/src/components/action-sheet/ActionSheetItem.tsx +2 -0
  106. package/src/components/action-sheet/types.ts +3 -0
  107. package/src/components/drawer/Drawer.tsx +4 -2
  108. package/src/components/drawer/types.ts +3 -0
  109. package/src/components/menu/Menu.tsx +18 -6
  110. package/src/components/menu/types.ts +3 -0
  111. package/src/components/modal/Modal.tsx +4 -2
  112. package/src/components/modal/types.ts +3 -0
  113. package/src/components/navigation/DrawerNavigation.tsx +8 -1
  114. package/src/components/navigation/DrawerNavigationItem.tsx +7 -1
  115. package/src/components/navigation/NavigationItem.tsx +7 -1
  116. package/src/components/navigation/NavigationList.tsx +8 -1
  117. package/src/components/navigation/TabBar.tsx +8 -2
  118. package/src/components/navigation/TabBarItem.tsx +2 -1
  119. package/src/components/navigation/policy.test.ts +96 -0
  120. package/src/components/navigation/types.ts +7 -0
  121. package/src/components/tabs/Tab.tsx +17 -6
  122. package/src/components/tabs/types.ts +3 -0
  123. package/src/components/text-input/TextInput.tsx +10 -2
  124. package/src/components/text-input/types.ts +2 -0
  125. package/src/components/toast/Toast.tsx +10 -2
  126. package/src/components/toast/types.ts +2 -0
  127. package/src/components/tooltip/Tooltip.tsx +6 -4
  128. package/src/components/tooltip/types.ts +3 -0
  129. package/src/index.test.ts +1 -0
  130. package/src/index.ts +1 -0
  131. package/src/interactionPolicy.test.ts +86 -0
  132. package/src/interactionPolicy.ts +5 -0
  133. package/src/primitives/button-base/ButtonBase.tsx +4 -2
  134. package/src/primitives/button-base/types.ts +3 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../../src/components/toast/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAE7C,OAAO,EAAE,QAAQ,EAAE,MAAM,0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Aa,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;MAAA,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,eAAe,CAC5C;QAAA,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CACX;UAAA,CAAC,KAAK,CAAC,CAAC,CAAC,CACP,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CACnC;cAAA,CAAC,KAAK,CACR;YAAA,EAAE,IAAI,CAAC,CACR,CAAC,CAAC,CAAC,IAAI,CACR;UAAA,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CACnE;QAAA,EAAE,GAAG,CACL;QAAA,CAAC,SAAS,CAAC,CAAC,CAAC,CACX,CAAC,SAAS,CACR,kBAAkB,CAAC,sBAAsB,CACzC,iBAAiB,CAAC,QAAQ,CAC1B,OAAO,CAAC,CAAC,SAAS,CAAC,CACnB,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAEjD;YAAA,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,IAAI,CACvC;UAAA,EAAE,SAAS,CAAC,CACb,CAAC,CAAC,CAAC,IAAI,CACV;MAAA,EAAE,MAAM,CACV;IAAA,EAAE,OAAO,CAAC,CACX,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Pressable } from 'react-native';\n\nimport { Box, Inline, Surface } from '../../layout';\nimport { Text } from '../../primitives/text';\nimport type { SurfaceColor } from '../../surfaceColor';\nimport { useTheme } from '../../theme/ThemeContext';\nimport type { SurfaceTheme } from '../../theme/types';\nimport type { ToastProps } from './types';\n\nfunction resolveToastStatusColor(theme: SurfaceTheme, status: ToastProps['status']) {\n switch (status) {\n case 'success':\n return theme.semantics.success.base;\n case 'warning':\n return theme.semantics.warning.base;\n case 'error':\n return theme.semantics.error.base;\n case 'info':\n return theme.semantics.info.base;\n default:\n return theme.semantics.action.primary.base;\n }\n}\n\nfunction resolveToastStatusTextColor(status: ToastProps['status']): SurfaceColor {\n switch (status) {\n case 'success':\n return 'success';\n case 'warning':\n return 'warning';\n case 'error':\n return 'error';\n case 'info':\n return 'info';\n default:\n return 'primary';\n }\n}\n\nexport function Toast({ title, description, status = 'default', onDismiss, testID }: ToastProps) {\n const { theme } = useTheme();\n const statusColor = resolveToastStatusColor(theme, status);\n const statusTextColor = resolveToastStatusTextColor(status);\n\n return (\n <Surface\n p=\"m\"\n style={{\n borderLeftColor: statusColor,\n borderLeftWidth: 3,\n minWidth: 280,\n shadowOpacity: 0.14,\n shadowRadius: 12,\n shadowOffset: { width: 0, height: 6 },\n }}\n testID={testID}\n variant=\"raised\"\n >\n <Inline align=\"center\" justify=\"space-between\">\n <Box flex={1}>\n {title ? (\n <Text variant=\"label\" weight=\"medium\">\n {title}\n </Text>\n ) : null}\n {description ? <Text emphasis=\"muted\">{description}</Text> : null}\n </Box>\n {onDismiss ? (\n <Pressable\n accessibilityLabel=\"Dismiss notification\"\n accessibilityRole=\"button\"\n onPress={onDismiss}\n testID={testID ? `${testID}-dismiss` : undefined}\n >\n <Text color={statusTextColor}>×</Text>\n </Pressable>\n ) : null}\n </Inline>\n </Surface>\n );\n}\n"]}
1
+ {"version":3,"file":"Toast.js","sourceRoot":"","sources":["../../../src/components/toast/Toast.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA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AC,KAAK,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,IAAI,CACvC;UAAA,EAAE,SAAS,CAAC,CACb,CAAC,CAAC,CAAC,IAAI,CACV;MAAA,EAAE,MAAM,CACV;IAAA,EAAE,OAAO,CAAC,CACX,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Pressable } from 'react-native';\n\nimport { Box, Inline, Surface } from '../../layout';\nimport { Text } from '../../primitives/text';\nimport type { SurfaceColor } from '../../surfaceColor';\nimport { useTheme } from '../../theme/ThemeContext';\nimport type { SurfaceTheme } from '../../theme/types';\nimport type { ToastProps } from './types';\n\nfunction resolveToastStatusColor(theme: SurfaceTheme, status: ToastProps['status']) {\n switch (status) {\n case 'success':\n return theme.semantics.success.base;\n case 'warning':\n return theme.semantics.warning.base;\n case 'error':\n return theme.semantics.error.base;\n case 'info':\n return theme.semantics.info.base;\n default:\n return theme.semantics.action.primary.base;\n }\n}\n\nfunction resolveToastStatusTextColor(status: ToastProps['status']): SurfaceColor {\n switch (status) {\n case 'success':\n return 'success';\n case 'warning':\n return 'warning';\n case 'error':\n return 'error';\n case 'info':\n return 'info';\n default:\n return 'primary';\n }\n}\n\nexport function Toast({\n title,\n description,\n status = 'default',\n onDismiss,\n interactionPolicy = 'enabled',\n testID,\n}: ToastProps) {\n const { theme } = useTheme();\n const statusColor = resolveToastStatusColor(theme, status);\n const statusTextColor = resolveToastStatusTextColor(status);\n const passive = interactionPolicy === 'passive';\n\n return (\n <Surface\n p=\"m\"\n style={{\n borderLeftColor: statusColor,\n borderLeftWidth: 3,\n minWidth: 280,\n shadowOpacity: 0.14,\n shadowRadius: 12,\n shadowOffset: { width: 0, height: 6 },\n }}\n testID={testID}\n variant=\"raised\"\n >\n <Inline align=\"center\" justify=\"space-between\">\n <Box flex={1}>\n {title ? (\n <Text variant=\"label\" weight=\"medium\">\n {title}\n </Text>\n ) : null}\n {description ? <Text emphasis=\"muted\">{description}</Text> : null}\n </Box>\n {onDismiss ? (\n <Pressable\n accessibilityLabel=\"Dismiss notification\"\n accessibilityRole=\"button\"\n onPress={passive ? undefined : onDismiss}\n testID={testID ? `${testID}-dismiss` : undefined}\n >\n <Text color={statusTextColor}>×</Text>\n </Pressable>\n ) : null}\n </Inline>\n </Surface>\n );\n}\n"]}
@@ -1,4 +1,5 @@
1
1
  import type React from 'react';
2
+ import type { InteractionPolicy } from '../../interactionPolicy';
2
3
  import type { SurfaceStatusColor } from '../../surfaceColor';
3
4
  export type ToastStatus = 'default' | SurfaceStatusColor;
4
5
  export interface ToastProps {
@@ -6,6 +7,7 @@ export interface ToastProps {
6
7
  description?: React.ReactNode;
7
8
  status?: ToastStatus;
8
9
  onDismiss?: (() => void) | undefined;
10
+ interactionPolicy?: InteractionPolicy;
9
11
  testID?: string;
10
12
  }
11
13
  export interface ToastOptions extends Omit<ToastProps, 'onDismiss'> {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/toast/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAEzD,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACrC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/toast/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAE7D,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAEzD,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACxB,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC9B,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;IACrC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAa,SAAQ,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;CACb"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/toast/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { SurfaceStatusColor } from '../../surfaceColor';\n\nexport type ToastStatus = 'default' | SurfaceStatusColor;\n\nexport interface ToastProps {\n title?: React.ReactNode;\n description?: React.ReactNode;\n status?: ToastStatus;\n onDismiss?: (() => void) | undefined;\n testID?: string;\n}\n\nexport interface ToastOptions extends Omit<ToastProps, 'onDismiss'> {\n duration?: number;\n id?: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/toast/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { InteractionPolicy } from '../../interactionPolicy';\nimport type { SurfaceStatusColor } from '../../surfaceColor';\n\nexport type ToastStatus = 'default' | SurfaceStatusColor;\n\nexport interface ToastProps {\n title?: React.ReactNode;\n description?: React.ReactNode;\n status?: ToastStatus;\n onDismiss?: (() => void) | undefined;\n interactionPolicy?: InteractionPolicy;\n testID?: string;\n}\n\nexport interface ToastOptions extends Omit<ToastProps, 'onDismiss'> {\n duration?: number;\n id?: string;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { TooltipProps } from './types';
3
- export declare function Tooltip({ children, content, delay, placement, testID, }: TooltipProps): React.JSX.Element;
3
+ export declare function Tooltip({ children, content, delay, interactionPolicy, placement, testID, }: TooltipProps): React.JSX.Element;
4
4
  //# sourceMappingURL=Tooltip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAe5C,wBAAgB,OAAO,CAAC,EACtB,QAAQ,EACR,OAAO,EACP,KAAW,EACX,SAAiB,EACjB,MAAM,GACP,EAAE,YAAY,qBA+Ed"}
1
+ {"version":3,"file":"Tooltip.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAQ1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAe5C,wBAAgB,OAAO,CAAC,EACtB,QAAQ,EACR,OAAO,EACP,KAAW,EACX,iBAA6B,EAC7B,SAAiB,EACjB,MAAM,GACP,EAAE,YAAY,qBAgFd"}
@@ -11,13 +11,14 @@ function measureNode(node, callback) {
11
11
  callback({ height, width, x, y });
12
12
  });
13
13
  }
14
- export function Tooltip({ children, content, delay = 150, placement = 'top', testID, }) {
14
+ export function Tooltip({ children, content, delay = 150, interactionPolicy = 'enabled', placement = 'top', testID, }) {
15
15
  const { theme } = useTheme();
16
16
  const animation = resolveOverlayAnimation('tooltip');
17
17
  const anchorRef = React.useRef(null);
18
18
  const timeoutRef = React.useRef(null);
19
19
  const [visible, setVisible] = React.useState(false);
20
20
  const [layout, setLayout] = React.useState(null);
21
+ const passive = interactionPolicy === 'passive';
21
22
  const show = React.useCallback(() => {
22
23
  if (timeoutRef.current) {
23
24
  clearTimeout(timeoutRef.current);
@@ -46,7 +47,7 @@ export function Tooltip({ children, content, delay = 150, placement = 'top', tes
46
47
  ? layout.y + layout.height + animation.offset
47
48
  : 0;
48
49
  return (<View collapsable={false} ref={anchorRef} testID={testID ? `${testID}-anchor` : undefined}>
49
- <Pressable onBlur={hide} onFocus={show} onHoverIn={Platform.OS === 'web' ? show : undefined} onHoverOut={Platform.OS === 'web' ? hide : undefined}>
50
+ <Pressable onBlur={passive ? undefined : hide} onFocus={passive ? undefined : show} onHoverIn={Platform.OS === 'web' && !passive ? show : undefined} onHoverOut={Platform.OS === 'web' && !passive ? hide : undefined}>
50
51
  {children}
51
52
  </Pressable>
52
53
  <Portal layer="tooltip" visible={visible && Boolean(layout)}>
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAwB,QAAQ,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAE/E,OAAO,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AASpD,SAAS,WAAW,CAAC,IAAa,EAAE,QAA2C;IAC7E,MAAM,cAAc,GAAG,IA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C,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAErD;QAAA,CAAC,QAAQ,CACX;MAAA,EAAE,SAAS,CACX;MAAA,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC,CAC1D;QAAA,CAAC,IAAI,CACH,aAAa,CAAC,MAAM,CACpB,KAAK,CAAC,CAAC;YACL,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,UAAU;YACpB,GAAG,EAAE,UAAU;SAChB,CAAC,CAEF;UAAA,CAAC,OAAO,CACN,CAAC,CAAC,GAAG,CACL,KAAK,CAAC,CAAC;YACL,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO;SACjD,CAAC,CACF,MAAM,CAAC,CAAC,MAAM,CAAC,CACf,OAAO,CAAC,QAAQ,CAEhB;YAAA,CAAC,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CACxC;cAAA,CAAC,OAAO,CACV;YAAA,EAAE,IAAI,CACR;UAAA,EAAE,OAAO,CACX;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,MAAM,CACV;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { type LayoutRectangle, Platform, Pressable, View } from 'react-native';\n\nimport { Portal } from '../../internal/overlay/Portal';\nimport { resolveOverlayAnimation } from '../../internal/resolvers';\nimport { Surface } from '../../layout';\nimport { Text } from '../../primitives/text';\nimport { useTheme } from '../../theme/ThemeContext';\nimport type { TooltipProps } from './types';\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\nexport function Tooltip({\n children,\n content,\n delay = 150,\n placement = 'top',\n testID,\n}: TooltipProps) {\n const { theme } = useTheme();\n const animation = resolveOverlayAnimation('tooltip');\n const anchorRef = React.useRef<View | null>(null);\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n const [visible, setVisible] = React.useState(false);\n const [layout, setLayout] = React.useState<LayoutRectangle | null>(null);\n\n const show = React.useCallback(() => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n timeoutRef.current = setTimeout(() => {\n measureNode(anchorRef.current, setLayout);\n setVisible(true);\n }, delay);\n }, [delay]);\n\n const hide = React.useCallback(() => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n setVisible(false);\n }, []);\n\n React.useEffect(\n () => () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n },\n [],\n );\n\n const tooltipLeft = layout ? layout.x : 0;\n const tooltipTop =\n layout && placement === 'top'\n ? layout.y - animation.offset\n : layout\n ? layout.y + layout.height + animation.offset\n : 0;\n\n return (\n <View collapsable={false} ref={anchorRef} testID={testID ? `${testID}-anchor` : undefined}>\n <Pressable\n onBlur={hide}\n onFocus={show}\n onHoverIn={Platform.OS === 'web' ? show : undefined}\n onHoverOut={Platform.OS === 'web' ? hide : undefined}\n >\n {children}\n </Pressable>\n <Portal layer=\"tooltip\" visible={visible && Boolean(layout)}>\n <View\n pointerEvents=\"none\"\n style={{\n left: tooltipLeft,\n position: 'absolute',\n top: tooltipTop,\n }}\n >\n <Surface\n p=\"s\"\n style={{\n backgroundColor: theme.semantics.surface.inverse,\n }}\n testID={testID}\n variant=\"raised\"\n >\n <Text emphasis=\"inverse\" variant=\"caption\">\n {content}\n </Text>\n </Surface>\n </View>\n </Portal>\n </View>\n );\n}\n"]}
1
+ {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../src/components/tooltip/Tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAA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OAAO,CAAC,SAAS,CACxC;cAAA,CAAC,OAAO,CACV;YAAA,EAAE,IAAI,CACR;UAAA,EAAE,OAAO,CACX;QAAA,EAAE,IAAI,CACR;MAAA,EAAE,MAAM,CACV;IAAA,EAAE,IAAI,CAAC,CACR,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { type LayoutRectangle, Platform, Pressable, View } from 'react-native';\n\nimport { Portal } from '../../internal/overlay/Portal';\nimport { resolveOverlayAnimation } from '../../internal/resolvers';\nimport { Surface } from '../../layout';\nimport { Text } from '../../primitives/text';\nimport { useTheme } from '../../theme/ThemeContext';\nimport type { TooltipProps } from './types';\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\nexport function Tooltip({\n children,\n content,\n delay = 150,\n interactionPolicy = 'enabled',\n placement = 'top',\n testID,\n}: TooltipProps) {\n const { theme } = useTheme();\n const animation = resolveOverlayAnimation('tooltip');\n const anchorRef = React.useRef<View | null>(null);\n const timeoutRef = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n const [visible, setVisible] = React.useState(false);\n const [layout, setLayout] = React.useState<LayoutRectangle | null>(null);\n const passive = interactionPolicy === 'passive';\n\n const show = React.useCallback(() => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n\n timeoutRef.current = setTimeout(() => {\n measureNode(anchorRef.current, setLayout);\n setVisible(true);\n }, delay);\n }, [delay]);\n\n const hide = React.useCallback(() => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n timeoutRef.current = null;\n }\n setVisible(false);\n }, []);\n\n React.useEffect(\n () => () => {\n if (timeoutRef.current) {\n clearTimeout(timeoutRef.current);\n }\n },\n [],\n );\n\n const tooltipLeft = layout ? layout.x : 0;\n const tooltipTop =\n layout && placement === 'top'\n ? layout.y - animation.offset\n : layout\n ? layout.y + layout.height + animation.offset\n : 0;\n\n return (\n <View collapsable={false} ref={anchorRef} testID={testID ? `${testID}-anchor` : undefined}>\n <Pressable\n onBlur={passive ? undefined : hide}\n onFocus={passive ? undefined : show}\n onHoverIn={Platform.OS === 'web' && !passive ? show : undefined}\n onHoverOut={Platform.OS === 'web' && !passive ? hide : undefined}\n >\n {children}\n </Pressable>\n <Portal layer=\"tooltip\" visible={visible && Boolean(layout)}>\n <View\n pointerEvents=\"none\"\n style={{\n left: tooltipLeft,\n position: 'absolute',\n top: tooltipTop,\n }}\n >\n <Surface\n p=\"s\"\n style={{\n backgroundColor: theme.semantics.surface.inverse,\n }}\n testID={testID}\n variant=\"raised\"\n >\n <Text emphasis=\"inverse\" variant=\"caption\">\n {content}\n </Text>\n </Surface>\n </View>\n </Portal>\n </View>\n );\n}\n"]}
@@ -1,8 +1,10 @@
1
1
  import type React from 'react';
2
+ import type { InteractionPolicy } from '../../interactionPolicy';
2
3
  export interface TooltipProps {
3
4
  children?: React.ReactNode;
4
5
  content?: React.ReactNode;
5
6
  delay?: number;
7
+ interactionPolicy?: InteractionPolicy;
6
8
  placement?: 'top' | 'bottom';
7
9
  testID?: string;
8
10
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/tooltip/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;IACtC,SAAS,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/tooltip/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nexport interface TooltipProps {\n children?: React.ReactNode;\n content?: React.ReactNode;\n delay?: number;\n placement?: 'top' | 'bottom';\n testID?: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/components/tooltip/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\n\nimport type { InteractionPolicy } from '../../interactionPolicy';\n\nexport interface TooltipProps {\n children?: React.ReactNode;\n content?: React.ReactNode;\n delay?: number;\n interactionPolicy?: InteractionPolicy;\n placement?: 'top' | 'bottom';\n testID?: string;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -45,6 +45,7 @@ export { FontProvider, useFontContext } from './context/FontContext';
45
45
  export type { I18nInstance, TranslationRuntime, Translator } from './context/TranslationContext';
46
46
  export { TranslationProvider, useTranslationContext } from './context/TranslationContext';
47
47
  export * from './core/responsive';
48
+ export type { InteractionPolicy, InteractionPolicyProps } from './interactionPolicy';
48
49
  export * from './layout';
49
50
  export type { ButtonBaseProps } from './primitives/button-base';
50
51
  export { ButtonBase } from './primitives/button-base';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRo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E,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,cAAc,mBAAmB,CAAC;AAClC,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAOzC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export type { ActionSheetItemProps, ActionSheetProps } from './components/action-sheet';\nexport { ActionSheet, ActionSheetItem } from './components/action-sheet';\nexport type { BadgeProps } from './components/badge';\nexport { Badge } from './components/badge';\nexport type { ButtonIconSpec, ButtonProps } from './components/button';\nexport { Button } from './components/button';\nexport type { CardProps } from './components/card';\nexport { Card } from './components/card';\nexport type { CheckboxProps } from './components/checkbox';\nexport { Checkbox } from './components/checkbox';\nexport type { DrawerProps } from './components/drawer';\nexport { Drawer } from './components/drawer';\nexport type { FieldProps } from './components/field';\nexport { Field } from './components/field';\nexport type { HelperTextProps } from './components/helper-text';\nexport { HelperText } from './components/helper-text';\nexport type { IconButtonProps } from './components/icon-button';\nexport { IconButton } from './components/icon-button';\nexport type { LabelProps } from './components/label';\nexport { Label } from './components/label';\nexport type { ListItemProps } from './components/list-item';\nexport { ListItem } from './components/list-item';\nexport type { MenuAction, MenuActionIntent, MenuItem, MenuProps } from './components/menu';\nexport { Menu } from './components/menu';\nexport type { ModalProps } from './components/modal';\nexport { Modal } from './components/modal';\nexport type {\n DrawerNavigationItemProps,\n DrawerNavigationProps,\n NavigationItemIcon,\n NavigationItemProps,\n NavigationItemSpec,\n NavigationListProps,\n TabBarItemProps,\n TabBarProps,\n} from './components/navigation';\nexport {\n DrawerNavigation,\n DrawerNavigationItem,\n NavigationItem,\n NavigationList,\n TabBar,\n TabBarItem,\n} from './components/navigation';\nexport type { RadioProps } from './components/radio';\nexport { Radio } from './components/radio';\nexport type { SwitchProps } from './components/switch';\nexport { Switch } from './components/switch';\nexport type { TabListProps, TabPanelProps, TabProps, TabsProps } from './components/tabs';\nexport { Tab, TabList, TabPanel, Tabs } from './components/tabs';\nexport type { TextInputProps } from './components/text-input';\nexport { TextInput } from './components/text-input';\nexport type { TextareaProps } from './components/textarea';\nexport { Textarea } from './components/textarea';\nexport type { ToastOptions, ToastProps, ToastStatus } from './components/toast';\nexport { Toast, ToastProvider, useToast } from './components/toast';\nexport type { TooltipProps } from './components/tooltip';\nexport { Tooltip } from './components/tooltip';\nexport type { FontRuntime } from './context/FontContext';\nexport { FontProvider, useFontContext } from './context/FontContext';\nexport type { I18nInstance, TranslationRuntime, Translator } from './context/TranslationContext';\nexport { TranslationProvider, useTranslationContext } from './context/TranslationContext';\nexport * from './core/responsive';\nexport * from './layout';\nexport type { ButtonBaseProps } from './primitives/button-base';\nexport { ButtonBase } from './primitives/button-base';\nexport type { HeadingLevel, HeadingProps } from './primitives/heading';\nexport { Heading } from './primitives/heading';\nexport type { IconProps, IconProvider } from './primitives/icon';\nexport { Icon } from './primitives/icon';\nexport type { ImageFit, ImageProps, SurfaceImageSource } from './primitives/image';\nexport { Image } from './primitives/image';\nexport type { TextProps } from './primitives/text';\nexport { Text } from './primitives/text';\nexport type {\n SurfaceColor,\n SurfaceEmphasis,\n SurfacePaletteColor,\n SurfaceStatusColor,\n} from './surfaceColor';\nexport {\n SURFACE_COLORS,\n SURFACE_EMPHASES,\n SURFACE_PALETTE_COLORS,\n SURFACE_STATUS_COLORS,\n} from './surfaceColor';\nexport * from './theme';\nexport { isDeepEqual } from './utils/deepEqual';\nexport { deepMerge } from './utils/deepMerge';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEzE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAW3C,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,MAAM,EACN,UAAU,GACX,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEjE,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAEpE,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAErE,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAC1F,cAAc,mBAAmB,CAAC;AAElC,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEtD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAOzC,OAAO,EACL,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export type { ActionSheetItemProps, ActionSheetProps } from './components/action-sheet';\nexport { ActionSheet, ActionSheetItem } from './components/action-sheet';\nexport type { BadgeProps } from './components/badge';\nexport { Badge } from './components/badge';\nexport type { ButtonIconSpec, ButtonProps } from './components/button';\nexport { Button } from './components/button';\nexport type { CardProps } from './components/card';\nexport { Card } from './components/card';\nexport type { CheckboxProps } from './components/checkbox';\nexport { Checkbox } from './components/checkbox';\nexport type { DrawerProps } from './components/drawer';\nexport { Drawer } from './components/drawer';\nexport type { FieldProps } from './components/field';\nexport { Field } from './components/field';\nexport type { HelperTextProps } from './components/helper-text';\nexport { HelperText } from './components/helper-text';\nexport type { IconButtonProps } from './components/icon-button';\nexport { IconButton } from './components/icon-button';\nexport type { LabelProps } from './components/label';\nexport { Label } from './components/label';\nexport type { ListItemProps } from './components/list-item';\nexport { ListItem } from './components/list-item';\nexport type { MenuAction, MenuActionIntent, MenuItem, MenuProps } from './components/menu';\nexport { Menu } from './components/menu';\nexport type { ModalProps } from './components/modal';\nexport { Modal } from './components/modal';\nexport type {\n DrawerNavigationItemProps,\n DrawerNavigationProps,\n NavigationItemIcon,\n NavigationItemProps,\n NavigationItemSpec,\n NavigationListProps,\n TabBarItemProps,\n TabBarProps,\n} from './components/navigation';\nexport {\n DrawerNavigation,\n DrawerNavigationItem,\n NavigationItem,\n NavigationList,\n TabBar,\n TabBarItem,\n} from './components/navigation';\nexport type { RadioProps } from './components/radio';\nexport { Radio } from './components/radio';\nexport type { SwitchProps } from './components/switch';\nexport { Switch } from './components/switch';\nexport type { TabListProps, TabPanelProps, TabProps, TabsProps } from './components/tabs';\nexport { Tab, TabList, TabPanel, Tabs } from './components/tabs';\nexport type { TextInputProps } from './components/text-input';\nexport { TextInput } from './components/text-input';\nexport type { TextareaProps } from './components/textarea';\nexport { Textarea } from './components/textarea';\nexport type { ToastOptions, ToastProps, ToastStatus } from './components/toast';\nexport { Toast, ToastProvider, useToast } from './components/toast';\nexport type { TooltipProps } from './components/tooltip';\nexport { Tooltip } from './components/tooltip';\nexport type { FontRuntime } from './context/FontContext';\nexport { FontProvider, useFontContext } from './context/FontContext';\nexport type { I18nInstance, TranslationRuntime, Translator } from './context/TranslationContext';\nexport { TranslationProvider, useTranslationContext } from './context/TranslationContext';\nexport * from './core/responsive';\nexport type { InteractionPolicy, InteractionPolicyProps } from './interactionPolicy';\nexport * from './layout';\nexport type { ButtonBaseProps } from './primitives/button-base';\nexport { ButtonBase } from './primitives/button-base';\nexport type { HeadingLevel, HeadingProps } from './primitives/heading';\nexport { Heading } from './primitives/heading';\nexport type { IconProps, IconProvider } from './primitives/icon';\nexport { Icon } from './primitives/icon';\nexport type { ImageFit, ImageProps, SurfaceImageSource } from './primitives/image';\nexport { Image } from './primitives/image';\nexport type { TextProps } from './primitives/text';\nexport { Text } from './primitives/text';\nexport type {\n SurfaceColor,\n SurfaceEmphasis,\n SurfacePaletteColor,\n SurfaceStatusColor,\n} from './surfaceColor';\nexport {\n SURFACE_COLORS,\n SURFACE_EMPHASES,\n SURFACE_PALETTE_COLORS,\n SURFACE_STATUS_COLORS,\n} from './surfaceColor';\nexport * from './theme';\nexport { isDeepEqual } from './utils/deepEqual';\nexport { deepMerge } from './utils/deepMerge';\n"]}
@@ -0,0 +1,5 @@
1
+ export type InteractionPolicy = 'enabled' | 'passive';
2
+ export interface InteractionPolicyProps {
3
+ interactionPolicy?: InteractionPolicy;
4
+ }
5
+ //# sourceMappingURL=interactionPolicy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactionPolicy.d.ts","sourceRoot":"","sources":["../src/interactionPolicy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtD,MAAM,WAAW,sBAAsB;IACrC,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interactionPolicy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interactionPolicy.js","sourceRoot":"","sources":["../src/interactionPolicy.ts"],"names":[],"mappings":"","sourcesContent":["export type InteractionPolicy = 'enabled' | 'passive';\n\nexport interface InteractionPolicyProps {\n interactionPolicy?: InteractionPolicy;\n}\n"]}
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { ButtonBaseProps } from './types';
3
- export declare function ButtonBase({ children, disabled, onPress, onLongPress, accessibilityLabel, accessibilityRole, accessibilityState, style, testID, ...props }: ButtonBaseProps): React.JSX.Element;
3
+ export declare function ButtonBase({ children, disabled, interactionPolicy, onPress, onLongPress, accessibilityLabel, accessibilityRole, accessibilityState, style, testID, ...props }: ButtonBaseProps): React.JSX.Element;
4
4
  //# sourceMappingURL=ButtonBase.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonBase.d.ts","sourceRoot":"","sources":["../../../src/primitives/button-base/ButtonBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAgB/C,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,QAAgB,EAChB,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,iBAA4B,EAC5B,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,GAAG,KAAK,EACT,EAAE,eAAe,qBA0CjB"}
1
+ {"version":3,"file":"ButtonBase.d.ts","sourceRoot":"","sources":["../../../src/primitives/button-base/ButtonBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAgB/C,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,QAAgB,EAChB,iBAA6B,EAC7B,OAAO,EACP,WAAW,EACX,kBAAkB,EAClB,iBAA4B,EAC5B,kBAAkB,EAClB,KAAK,EACL,MAAM,EACN,GAAG,KAAK,EACT,EAAE,eAAe,qBA2CjB"}
@@ -12,18 +12,19 @@ function getInteractionState(pressableState, hovered, focused, disabled) {
12
12
  disabled,
13
13
  });
14
14
  }
15
- export function ButtonBase({ children, disabled = false, onPress, onLongPress, accessibilityLabel, accessibilityRole = 'button', accessibilityState, style, testID, ...props }) {
15
+ export function ButtonBase({ children, disabled = false, interactionPolicy = 'enabled', onPress, onLongPress, accessibilityLabel, accessibilityRole = 'button', accessibilityState, style, testID, ...props }) {
16
16
  const { theme } = useTheme();
17
17
  const { breakpoint } = useResponsiveRuntime();
18
18
  const [hovered, setHovered] = React.useState(false);
19
19
  const [focused, setFocused] = React.useState(false);
20
20
  const isWeb = Platform.OS === 'web';
21
21
  const resolvedBoxStyles = resolveBoxStyles(theme, breakpoint, props);
22
+ const passive = interactionPolicy === 'passive';
22
23
  return (<Pressable accessibilityLabel={accessibilityLabel} accessibilityRole={accessibilityRole} accessibilityState={{ ...accessibilityState, disabled }} disabled={disabled} onBlur={() => setFocused(false)} onFocus={() => {
23
24
  if (isWeb) {
24
25
  setFocused(true);
25
26
  }
26
- }} onHoverIn={isWeb ? () => setHovered(true) : undefined} onHoverOut={isWeb ? () => setHovered(false) : undefined} onLongPress={onLongPress} onPress={onPress} style={(pressableState) => {
27
+ }} onHoverIn={isWeb ? () => setHovered(true) : undefined} onHoverOut={isWeb ? () => setHovered(false) : undefined} onLongPress={passive ? undefined : onLongPress} onPress={passive ? undefined : onPress} style={(pressableState) => {
27
28
  const state = getInteractionState(pressableState, hovered, focused, disabled);
28
29
  return [
29
30
  resolvedBoxStyles,
@@ -1 +1 @@
1
- {"version":3,"file":"ButtonBase.js","sourceRoot":"","sources":["../../../src/primitives/button-base/ButtonBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAmC,MAAM,cAAc,CAAC;AAEpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAEL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;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;YACnB,CAAC;QACH,CAAC,CAAC,CACF,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CACtD,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CACxD,WAAW,CAAC,CAAC,WAAW,CAAC,CACzB,OAAO,CAAC,CAAC,OAAO,CAAC,CACjB,KAAK,CAAC,CAAC,CAAC,cAAc,EAAE,EAAE;YACxB,MAAM,KAAK,GAAG,mBAAmB,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;YAE9E,OAAO;gBACL,iBAAiB;gBACjB,sBAAsB,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC;gBAC1E,KAAK;aACN,CAAC;QACJ,CAAC,CAAC,CACF,MAAM,CAAC,CAAC,MAAM,CAAC,CAEf;MAAA,CAAC,CAAC,cAAc,EAAE,EAAE;YAClB,MAAM,KAAK,GAAG,mBAAmB,CAAC,cAAc,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;YAE9E,OAAO,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACrE,CAAC,CACH;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Platform, Pressable, type PressableStateCallbackType } from 'react-native';\n\nimport { useResponsiveRuntime } from '../../core/responsive';\nimport {\n type InteractionState,\n resolveFocusRingStyles,\n resolveInteractiveState,\n} from '../../internal/resolvers';\nimport { resolveBoxStyles } from '../../layout/helpers';\nimport { useTheme } from '../../theme/ThemeContext';\nimport type { ButtonBaseProps } from './types';\n\nfunction getInteractionState(\n pressableState: PressableStateCallbackType,\n hovered: boolean,\n focused: boolean,\n disabled: boolean,\n): InteractionState {\n return resolveInteractiveState({\n pressed: pressableState.pressed,\n hovered,\n focused,\n disabled,\n });\n}\n\nexport function ButtonBase({\n children,\n disabled = false,\n onPress,\n onLongPress,\n accessibilityLabel,\n accessibilityRole = 'button',\n accessibilityState,\n style,\n testID,\n ...props\n}: ButtonBaseProps) {\n const { theme } = useTheme();\n const { breakpoint } = useResponsiveRuntime();\n const [hovered, setHovered] = React.useState(false);\n const [focused, setFocused] = React.useState(false);\n const isWeb = Platform.OS === 'web';\n const resolvedBoxStyles = resolveBoxStyles(theme, breakpoint, props);\n\n return (\n <Pressable\n accessibilityLabel={accessibilityLabel}\n accessibilityRole={accessibilityRole}\n accessibilityState={{ ...accessibilityState, disabled }}\n disabled={disabled}\n onBlur={() => setFocused(false)}\n onFocus={() => {\n if (isWeb) {\n setFocused(true);\n }\n }}\n onHoverIn={isWeb ? () => setHovered(true) : undefined}\n onHoverOut={isWeb ? () => setHovered(false) : undefined}\n onLongPress={onLongPress}\n onPress={onPress}\n style={(pressableState) => {\n const state = getInteractionState(pressableState, hovered, focused, disabled);\n\n return [\n resolvedBoxStyles,\n resolveFocusRingStyles(theme.semantics.border.focus, state.focused, isWeb),\n style,\n ];\n }}\n testID={testID}\n >\n {(pressableState) => {\n const state = getInteractionState(pressableState, hovered, focused, disabled);\n\n return typeof children === 'function' ? children(state) : children;\n }}\n </Pressable>\n );\n}\n"]}
1
+ {"version":3,"file":"ButtonBase.js","sourceRoot":"","sources":["../../../src/primitives/button-base/ButtonBase.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAmC,MAAM,cAAc,CAAC;AAEpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAEL,sBAAsB,EACtB,uB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,CAAC,CAAC,QAAQ,CAAC;QACrE,CAAC,CACH;IAAA,EAAE,SAAS,CAAC,CACb,CAAC;AACJ,CAAC","sourcesContent":["import React from 'react';\nimport { Platform, Pressable, type PressableStateCallbackType } from 'react-native';\n\nimport { useResponsiveRuntime } from '../../core/responsive';\nimport {\n type InteractionState,\n resolveFocusRingStyles,\n resolveInteractiveState,\n} from '../../internal/resolvers';\nimport { resolveBoxStyles } from '../../layout/helpers';\nimport { useTheme } from '../../theme/ThemeContext';\nimport type { ButtonBaseProps } from './types';\n\nfunction getInteractionState(\n pressableState: PressableStateCallbackType,\n hovered: boolean,\n focused: boolean,\n disabled: boolean,\n): InteractionState {\n return resolveInteractiveState({\n pressed: pressableState.pressed,\n hovered,\n focused,\n disabled,\n });\n}\n\nexport function ButtonBase({\n children,\n disabled = false,\n interactionPolicy = 'enabled',\n onPress,\n onLongPress,\n accessibilityLabel,\n accessibilityRole = 'button',\n accessibilityState,\n style,\n testID,\n ...props\n}: ButtonBaseProps) {\n const { theme } = useTheme();\n const { breakpoint } = useResponsiveRuntime();\n const [hovered, setHovered] = React.useState(false);\n const [focused, setFocused] = React.useState(false);\n const isWeb = Platform.OS === 'web';\n const resolvedBoxStyles = resolveBoxStyles(theme, breakpoint, props);\n const passive = interactionPolicy === 'passive';\n\n return (\n <Pressable\n accessibilityLabel={accessibilityLabel}\n accessibilityRole={accessibilityRole}\n accessibilityState={{ ...accessibilityState, disabled }}\n disabled={disabled}\n onBlur={() => setFocused(false)}\n onFocus={() => {\n if (isWeb) {\n setFocused(true);\n }\n }}\n onHoverIn={isWeb ? () => setHovered(true) : undefined}\n onHoverOut={isWeb ? () => setHovered(false) : undefined}\n onLongPress={passive ? undefined : onLongPress}\n onPress={passive ? undefined : onPress}\n style={(pressableState) => {\n const state = getInteractionState(pressableState, hovered, focused, disabled);\n\n return [\n resolvedBoxStyles,\n resolveFocusRingStyles(theme.semantics.border.focus, state.focused, isWeb),\n style,\n ];\n }}\n testID={testID}\n >\n {(pressableState) => {\n const state = getInteractionState(pressableState, hovered, focused, disabled);\n\n return typeof children === 'function' ? children(state) : children;\n }}\n </Pressable>\n );\n}\n"]}
@@ -1,8 +1,9 @@
1
1
  import type React from 'react';
2
2
  import type { AccessibilityRole, AccessibilityState, GestureResponderEvent } from 'react-native';
3
+ import type { InteractionPolicyProps } from '../../interactionPolicy';
3
4
  import type { InteractionState } from '../../internal/resolvers/resolveInteractiveState';
4
5
  import type { BoxProps } from '../../layout';
5
- export interface ButtonBaseProps extends Omit<BoxProps, 'children' | 'pointerEvents'> {
6
+ export interface ButtonBaseProps extends Omit<BoxProps, 'children' | 'pointerEvents'>, InteractionPolicyProps {
6
7
  children?: React.ReactNode | ((state: InteractionState) => React.ReactNode);
7
8
  disabled?: boolean;
8
9
  onPress?: ((event: GestureResponderEvent) => void) | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/primitives/button-base/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAEjG,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AACzF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,WAAW,eAAgB,SAAQ,IAAI,CAAC,QAAQ,EAAE,UAAU,GAAG,eAAe,CAAC;IACnF,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,KAAK,EAAE,gBAAgB,KAAK,KAAK,CAAC,SAAS,CAAC,CAAC;IAC5E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAC/D,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,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ourceRoot":"","sources":["../../../src/primitives/button-base/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\nimport type { AccessibilityRole, AccessibilityState, GestureResponderEvent } from 'react-native';\n\nimport type { InteractionState } from '../../internal/resolvers/resolveInteractiveState';\nimport type { BoxProps } from '../../layout';\n\nexport interface ButtonBaseProps extends Omit<BoxProps, 'children' | 'pointerEvents'> {\n children?: React.ReactNode | ((state: InteractionState) => React.ReactNode);\n disabled?: boolean;\n onPress?: ((event: GestureResponderEvent) => void) | undefined;\n onLongPress?: ((event: GestureResponderEvent) => void) | undefined;\n accessibilityLabel?: string;\n accessibilityRole?: AccessibilityRole;\n accessibilityState?: AccessibilityState;\n testID?: string;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/primitives/button-base/types.ts"],"names":[],"mappings":"","sourcesContent":["import type React from 'react';\nimport type { AccessibilityRole, AccessibilityState, GestureResponderEvent } from 'react-native';\n\nimport type { InteractionPolicyProps } from '../../interactionPolicy';\nimport type { InteractionState } from '../../internal/resolvers/resolveInteractiveState';\nimport type { BoxProps } from '../../layout';\n\nexport interface ButtonBaseProps\n extends Omit<BoxProps, 'children' | 'pointerEvents'>, InteractionPolicyProps {\n children?: React.ReactNode | ((state: InteractionState) => React.ReactNode);\n disabled?: boolean;\n onPress?: ((event: GestureResponderEvent) => void) | undefined;\n onLongPress?: ((event: GestureResponderEvent) => void) | undefined;\n accessibilityLabel?: string;\n accessibilityRole?: AccessibilityRole;\n accessibilityState?: AccessibilityState;\n testID?: string;\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ankhorage/surface",
3
3
  "type": "module",
4
- "version": "2.0.3",
4
+ "version": "2.1.0",
5
5
  "description": "Stable UI foundation for React Native and React Native Web.",
6
6
  "homepage": "https://github.com/ankhorage/surface#readme",
7
7
  "bugs": {
@@ -18,10 +18,12 @@ export function ActionSheet({
18
18
  children,
19
19
  cancelLabel = 'Cancel',
20
20
  closeOnBackdrop = true,
21
+ interactionPolicy = 'enabled',
21
22
  testID,
22
23
  }: ActionSheetProps) {
23
24
  const { theme } = useTheme();
24
25
  const animation = resolveOverlayAnimation('modal');
26
+ const passive = interactionPolicy === 'passive';
25
27
 
26
28
  if (!visible) {
27
29
  return null;
@@ -40,7 +42,7 @@ export function ActionSheet({
40
42
  }}
41
43
  >
42
44
  <Pressable
43
- onPress={closeOnBackdrop ? onDismiss : undefined}
45
+ onPress={passive ? undefined : closeOnBackdrop ? onDismiss : undefined}
44
46
  style={{
45
47
  backgroundColor: theme.semantics.neutral.text,
46
48
  bottom: 0,
@@ -54,7 +56,7 @@ export function ActionSheet({
54
56
  />
55
57
  <FocusScope
56
58
  active={visible}
57
- onEscape={onDismiss}
59
+ onEscape={passive ? undefined : onDismiss}
58
60
  testID={testID ? `${testID}-focus` : undefined}
59
61
  >
60
62
  <Box
@@ -106,6 +108,7 @@ export function ActionSheet({
106
108
  {onDismiss ? (
107
109
  <ActionSheetItem
108
110
  label={cancelLabel}
111
+ interactionPolicy={interactionPolicy}
109
112
  onPress={onDismiss}
110
113
  testID={testID ? `${testID}-cancel` : undefined}
111
114
  />
@@ -13,6 +13,7 @@ export function ActionSheetItem({
13
13
  color,
14
14
  disabled = false,
15
15
  selected = false,
16
+ interactionPolicy = 'enabled',
16
17
  onPress,
17
18
  testID,
18
19
  }: ActionSheetItemProps) {
@@ -21,6 +22,7 @@ export function ActionSheetItem({
21
22
  accessibilityRole="button"
22
23
  accessibilityState={{ disabled, selected }}
23
24
  disabled={disabled}
25
+ interactionPolicy={interactionPolicy}
24
26
  onPress={onPress}
25
27
  radius="m"
26
28
  testID={testID}
@@ -1,5 +1,6 @@
1
1
  import type React from 'react';
2
2
 
3
+ import type { InteractionPolicy } from '../../interactionPolicy';
3
4
  import type { SurfaceColor } from '../../surfaceColor';
4
5
 
5
6
  export interface ActionSheetProps {
@@ -10,6 +11,7 @@ export interface ActionSheetProps {
10
11
  children?: React.ReactNode;
11
12
  cancelLabel?: React.ReactNode;
12
13
  closeOnBackdrop?: boolean;
14
+ interactionPolicy?: InteractionPolicy;
13
15
  testID?: string;
14
16
  }
15
17
 
@@ -21,6 +23,7 @@ export interface ActionSheetItemProps {
21
23
  color?: SurfaceColor;
22
24
  disabled?: boolean;
23
25
  selected?: boolean;
26
+ interactionPolicy?: InteractionPolicy;
24
27
  onPress?: (() => void) | undefined;
25
28
  testID?: string;
26
29
  }
@@ -14,10 +14,12 @@ export function Drawer({
14
14
  position = 'right',
15
15
  children,
16
16
  closeOnBackdrop = true,
17
+ interactionPolicy = 'enabled',
17
18
  testID,
18
19
  }: DrawerProps) {
19
20
  const { theme } = useTheme();
20
21
  const animation = resolveOverlayAnimation('drawer');
22
+ const passive = interactionPolicy === 'passive';
21
23
 
22
24
  if (!visible) {
23
25
  return null;
@@ -36,7 +38,7 @@ export function Drawer({
36
38
  }}
37
39
  >
38
40
  <Pressable
39
- onPress={closeOnBackdrop ? onDismiss : undefined}
41
+ onPress={passive ? undefined : closeOnBackdrop ? onDismiss : undefined}
40
42
  style={{
41
43
  backgroundColor: theme.semantics.neutral.text,
42
44
  bottom: 0,
@@ -50,7 +52,7 @@ export function Drawer({
50
52
  />
51
53
  <FocusScope
52
54
  active={visible}
53
- onEscape={onDismiss}
55
+ onEscape={passive ? undefined : onDismiss}
54
56
  testID={testID ? `${testID}-focus` : undefined}
55
57
  >
56
58
  <Box
@@ -1,10 +1,13 @@
1
1
  import type React from 'react';
2
2
 
3
+ import type { InteractionPolicy } from '../../interactionPolicy';
4
+
3
5
  export interface DrawerProps {
4
6
  visible: boolean;
5
7
  onDismiss?: (() => void) | undefined;
6
8
  position?: 'left' | 'right';
7
9
  children?: React.ReactNode;
8
10
  closeOnBackdrop?: boolean;
11
+ interactionPolicy?: InteractionPolicy;
9
12
  testID?: string;
10
13
  }
@@ -53,7 +53,14 @@ function renderActionContent(action: MenuAction, active: boolean) {
53
53
  );
54
54
  }
55
55
 
56
- export function Menu({ trigger, actions, dismiss, closeOnSelect = true, testID }: MenuProps) {
56
+ export function Menu({
57
+ trigger,
58
+ actions,
59
+ dismiss,
60
+ closeOnSelect = true,
61
+ interactionPolicy = 'enabled',
62
+ testID,
63
+ }: MenuProps) {
57
64
  const { theme } = useTheme();
58
65
  const { bindKeydown } = useFocusManager();
59
66
  const animation = resolveOverlayAnimation('menu');
@@ -61,6 +68,7 @@ export function Menu({ trigger, actions, dismiss, closeOnSelect = true, testID }
61
68
  const [open, setOpen] = React.useState(false);
62
69
  const [layout, setLayout] = React.useState<LayoutRectangle | null>(null);
63
70
  const [activeIndex, setActiveIndex] = React.useState(0);
71
+ const passive = interactionPolicy === 'passive';
64
72
 
65
73
  const closeMenu = React.useCallback(() => {
66
74
  setOpen(false);
@@ -99,6 +107,10 @@ export function Menu({ trigger, actions, dismiss, closeOnSelect = true, testID }
99
107
  }
100
108
 
101
109
  return bindKeydown((event) => {
110
+ if (passive) {
111
+ return;
112
+ }
113
+
102
114
  const { key } = event;
103
115
  if (key === 'ArrowDown' || key === 'ArrowUp' || key === 'Home' || key === 'End') {
104
116
  event.preventDefault();
@@ -118,12 +130,12 @@ export function Menu({ trigger, actions, dismiss, closeOnSelect = true, testID }
118
130
  closeMenu();
119
131
  }
120
132
  });
121
- }, [activateAction, actions, activeIndex, bindKeydown, closeMenu, open]);
133
+ }, [activateAction, actions, activeIndex, bindKeydown, closeMenu, open, passive]);
122
134
 
123
135
  return (
124
136
  <View collapsable={false} ref={anchorRef}>
125
137
  <ButtonBase
126
- onPress={open ? closeMenu : openMenu}
138
+ onPress={passive ? undefined : open ? closeMenu : openMenu}
127
139
  testID={testID ? `${testID}-trigger` : undefined}
128
140
  >
129
141
  {trigger}
@@ -140,7 +152,7 @@ export function Menu({ trigger, actions, dismiss, closeOnSelect = true, testID }
140
152
  }}
141
153
  >
142
154
  <Pressable
143
- onPress={closeMenu}
155
+ onPress={passive ? undefined : closeMenu}
144
156
  style={{
145
157
  bottom: 0,
146
158
  left: 0,
@@ -149,7 +161,7 @@ export function Menu({ trigger, actions, dismiss, closeOnSelect = true, testID }
149
161
  top: 0,
150
162
  }}
151
163
  />
152
- <FocusScope active={open} onEscape={closeMenu}>
164
+ <FocusScope active={open} onEscape={passive ? undefined : closeMenu}>
153
165
  <View
154
166
  style={{
155
167
  left: layout?.x ?? 0,
@@ -179,7 +191,7 @@ export function Menu({ trigger, actions, dismiss, closeOnSelect = true, testID }
179
191
  accessibilityState={{ disabled: action.disabled, selected }}
180
192
  disabled={action.disabled}
181
193
  key={action.id}
182
- onPress={() => activateAction(action)}
194
+ onPress={passive ? undefined : () => activateAction(action)}
183
195
  >
184
196
  <Box
185
197
  px="m"
@@ -1,5 +1,7 @@
1
1
  import type React from 'react';
2
2
 
3
+ import type { InteractionPolicy } from '../../interactionPolicy';
4
+
3
5
  export type MenuActionIntent = 'default' | 'danger';
4
6
 
5
7
  export interface MenuAction {
@@ -19,5 +21,6 @@ export interface MenuProps {
19
21
  actions: readonly MenuAction[];
20
22
  dismiss?: () => void;
21
23
  closeOnSelect?: boolean;
24
+ interactionPolicy?: InteractionPolicy;
22
25
  testID?: string;
23
26
  }
@@ -13,10 +13,12 @@ export function Modal({
13
13
  onDismiss,
14
14
  children,
15
15
  closeOnBackdrop = true,
16
+ interactionPolicy = 'enabled',
16
17
  testID,
17
18
  }: ModalProps) {
18
19
  const { theme } = useTheme();
19
20
  const animation = resolveOverlayAnimation('modal');
21
+ const passive = interactionPolicy === 'passive';
20
22
 
21
23
  if (!visible) {
22
24
  return null;
@@ -35,7 +37,7 @@ export function Modal({
35
37
  }}
36
38
  >
37
39
  <Pressable
38
- onPress={closeOnBackdrop ? onDismiss : undefined}
40
+ onPress={passive ? undefined : closeOnBackdrop ? onDismiss : undefined}
39
41
  style={{
40
42
  backgroundColor: theme.semantics.neutral.text,
41
43
  bottom: 0,
@@ -49,7 +51,7 @@ export function Modal({
49
51
  />
50
52
  <FocusScope
51
53
  active={visible}
52
- onEscape={onDismiss}
54
+ onEscape={passive ? undefined : onDismiss}
53
55
  testID={testID ? `${testID}-focus` : undefined}
54
56
  >
55
57
  <Center
@@ -1,9 +1,12 @@
1
1
  import type React from 'react';
2
2
 
3
+ import type { InteractionPolicy } from '../../interactionPolicy';
4
+
3
5
  export interface ModalProps {
4
6
  visible: boolean;
5
7
  onDismiss?: (() => void) | undefined;
6
8
  children?: React.ReactNode;
7
9
  closeOnBackdrop?: boolean;
10
+ interactionPolicy?: InteractionPolicy;
8
11
  testID?: string;
9
12
  }