@atlaskit/top-layer 0.12.2 → 0.14.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 (245) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +61 -34
  3. package/dist/cjs/animations/presets.js +4 -4
  4. package/dist/cjs/entry-points/focus.js +6 -4
  5. package/dist/cjs/entry-points/get-aria-for-trigger.js +12 -0
  6. package/dist/cjs/entry-points/popover-surface.js +12 -0
  7. package/dist/cjs/entry-points/use-anchor-position-at-point.js +12 -0
  8. package/dist/cjs/entry-points/use-popover-id.js +21 -0
  9. package/dist/cjs/focus/get-first-focusable.js +19 -0
  10. package/dist/cjs/focus/get-focusables.js +30 -0
  11. package/dist/cjs/focus/get-last-focusable.js +19 -0
  12. package/dist/cjs/focus/get-next-focusable.js +43 -0
  13. package/dist/cjs/focus/is-in-same-layer.js +23 -0
  14. package/dist/cjs/focus/is-nested-layer-focused.js +32 -0
  15. package/dist/cjs/focus/selectors.js +19 -0
  16. package/dist/cjs/focus/types.js +1 -0
  17. package/dist/cjs/internal/get-aria-for-trigger.js +88 -0
  18. package/dist/cjs/internal/role-to-aria-has-popup.js +37 -0
  19. package/dist/cjs/internal/role-types.js +2 -35
  20. package/dist/cjs/internal/should-focus-into-popover.js +19 -0
  21. package/dist/cjs/internal/slot.js +1 -1
  22. package/dist/cjs/internal/use-anchor-position-at-point.js +127 -0
  23. package/dist/cjs/internal/use-anchor-position.js +36 -16
  24. package/dist/cjs/internal/use-focus-wrap.js +8 -5
  25. package/dist/cjs/internal/use-initial-focus.js +4 -4
  26. package/dist/cjs/placement-map/index.js +2 -2
  27. package/dist/cjs/placement-map/legacy-placements.js +2 -101
  28. package/dist/cjs/placement-map/placement-mapping.js +103 -0
  29. package/dist/cjs/popover/popover.js +79 -80
  30. package/dist/cjs/popover-surface/index.js +12 -0
  31. package/dist/cjs/{popup/popup-surface.js → popover-surface/popover-surface.js} +9 -12
  32. package/dist/cjs/testing/polyfill.js +9 -6
  33. package/dist/cjs/use-arrow-navigation/use-arrow-navigation.js +7 -5
  34. package/dist/es2019/animations/presets.js +4 -4
  35. package/dist/es2019/entry-points/focus.js +3 -1
  36. package/dist/es2019/entry-points/get-aria-for-trigger.js +1 -0
  37. package/dist/es2019/entry-points/popover-surface.js +1 -0
  38. package/dist/es2019/entry-points/use-anchor-position-at-point.js +1 -0
  39. package/dist/es2019/entry-points/use-popover-id.js +15 -0
  40. package/dist/es2019/focus/get-first-focusable.js +14 -0
  41. package/dist/es2019/focus/get-focusables.js +19 -0
  42. package/dist/es2019/focus/get-last-focusable.js +14 -0
  43. package/dist/es2019/focus/get-next-focusable.js +38 -0
  44. package/dist/es2019/focus/is-in-same-layer.js +18 -0
  45. package/dist/es2019/focus/is-nested-layer-focused.js +28 -0
  46. package/dist/es2019/focus/selectors.js +11 -0
  47. package/dist/es2019/focus/types.js +0 -0
  48. package/dist/es2019/internal/get-aria-for-trigger.js +84 -0
  49. package/dist/es2019/internal/role-to-aria-has-popup.js +32 -0
  50. package/dist/es2019/internal/role-types.js +0 -33
  51. package/dist/es2019/internal/should-focus-into-popover.js +14 -0
  52. package/dist/es2019/internal/slot.js +1 -1
  53. package/dist/es2019/internal/use-anchor-position-at-point.js +122 -0
  54. package/dist/es2019/internal/use-anchor-position.js +21 -14
  55. package/dist/es2019/internal/use-focus-wrap.js +4 -1
  56. package/dist/es2019/internal/use-initial-focus.js +1 -1
  57. package/dist/es2019/placement-map/index.js +1 -1
  58. package/dist/es2019/placement-map/legacy-placements.js +1 -100
  59. package/dist/es2019/placement-map/placement-mapping.js +97 -0
  60. package/dist/es2019/popover/popover.js +79 -80
  61. package/dist/es2019/popover-surface/index.js +1 -0
  62. package/dist/es2019/popover-surface/popover-surface.js +27 -0
  63. package/dist/es2019/testing/polyfill.js +9 -6
  64. package/dist/es2019/use-arrow-navigation/use-arrow-navigation.js +3 -1
  65. package/dist/esm/animations/presets.js +4 -4
  66. package/dist/esm/entry-points/focus.js +3 -1
  67. package/dist/esm/entry-points/get-aria-for-trigger.js +1 -0
  68. package/dist/esm/entry-points/popover-surface.js +1 -0
  69. package/dist/esm/entry-points/use-anchor-position-at-point.js +1 -0
  70. package/dist/esm/entry-points/use-popover-id.js +15 -0
  71. package/dist/esm/focus/get-first-focusable.js +13 -0
  72. package/dist/esm/focus/get-focusables.js +24 -0
  73. package/dist/esm/focus/get-last-focusable.js +13 -0
  74. package/dist/esm/focus/get-next-focusable.js +37 -0
  75. package/dist/esm/focus/is-in-same-layer.js +17 -0
  76. package/dist/esm/focus/is-nested-layer-focused.js +27 -0
  77. package/dist/esm/focus/selectors.js +13 -0
  78. package/dist/esm/focus/types.js +0 -0
  79. package/dist/esm/internal/get-aria-for-trigger.js +83 -0
  80. package/dist/esm/internal/role-to-aria-has-popup.js +31 -0
  81. package/dist/esm/internal/role-types.js +2 -34
  82. package/dist/esm/internal/should-focus-into-popover.js +13 -0
  83. package/dist/esm/internal/slot.js +1 -1
  84. package/dist/esm/internal/use-anchor-position-at-point.js +122 -0
  85. package/dist/esm/internal/use-anchor-position.js +36 -16
  86. package/dist/esm/internal/use-focus-wrap.js +4 -1
  87. package/dist/esm/internal/use-initial-focus.js +1 -1
  88. package/dist/esm/placement-map/index.js +1 -1
  89. package/dist/esm/placement-map/legacy-placements.js +1 -100
  90. package/dist/esm/placement-map/placement-mapping.js +97 -0
  91. package/dist/esm/popover/popover.js +79 -80
  92. package/dist/esm/popover-surface/index.js +1 -0
  93. package/dist/esm/popover-surface/popover-surface.js +26 -0
  94. package/dist/esm/testing/polyfill.js +9 -6
  95. package/dist/esm/use-arrow-navigation/use-arrow-navigation.js +3 -1
  96. package/dist/types/animations/presets.d.ts +4 -4
  97. package/dist/types/animations/types.d.ts +1 -1
  98. package/dist/types/dialog/types.d.ts +0 -8
  99. package/dist/types/entry-points/focus.d.ts +4 -2
  100. package/dist/types/entry-points/get-aria-for-trigger.d.ts +1 -0
  101. package/dist/types/entry-points/popover-surface.d.ts +2 -0
  102. package/dist/types/entry-points/popover.d.ts +1 -1
  103. package/dist/types/entry-points/use-anchor-position-at-point.d.ts +1 -0
  104. package/dist/types/entry-points/use-popover-id.d.ts +11 -0
  105. package/dist/types/focus/get-first-focusable.d.ts +8 -0
  106. package/dist/types/focus/get-focusables.d.ts +13 -0
  107. package/dist/types/focus/get-last-focusable.d.ts +8 -0
  108. package/dist/types/focus/get-next-focusable.d.ts +13 -0
  109. package/dist/types/focus/is-in-same-layer.d.ts +8 -0
  110. package/dist/types/focus/is-nested-layer-focused.d.ts +8 -0
  111. package/dist/types/focus/selectors.d.ts +4 -0
  112. package/dist/types/focus/types.d.ts +5 -0
  113. package/dist/types/internal/get-aria-for-trigger.d.ts +86 -0
  114. package/dist/types/internal/role-to-aria-has-popup.d.ts +13 -0
  115. package/dist/types/internal/role-types.d.ts +0 -12
  116. package/dist/types/internal/should-focus-into-popover.d.ts +8 -0
  117. package/dist/types/internal/slot.d.ts +2 -2
  118. package/dist/types/internal/use-anchor-position-at-point.d.ts +62 -0
  119. package/dist/types/internal/use-anchor-position.d.ts +6 -1
  120. package/dist/types/placement-map/index.d.ts +1 -1
  121. package/dist/types/placement-map/legacy-placements.d.ts +0 -12
  122. package/dist/types/placement-map/placement-mapping.d.ts +13 -0
  123. package/dist/types/popover/index.d.ts +1 -1
  124. package/dist/types/popover/popover.d.ts +6 -13
  125. package/dist/types/popover/types.d.ts +6 -5
  126. package/dist/types/popover-surface/index.d.ts +2 -0
  127. package/dist/types/popover-surface/popover-surface.d.ts +21 -0
  128. package/dist/types/use-arrow-navigation/use-arrow-navigation.d.ts +1 -1
  129. package/dist/types-ts4.5/animations/presets.d.ts +4 -4
  130. package/dist/types-ts4.5/animations/types.d.ts +1 -1
  131. package/dist/types-ts4.5/dialog/types.d.ts +0 -8
  132. package/dist/types-ts4.5/entry-points/focus.d.ts +4 -2
  133. package/dist/types-ts4.5/entry-points/get-aria-for-trigger.d.ts +1 -0
  134. package/dist/types-ts4.5/entry-points/popover-surface.d.ts +2 -0
  135. package/dist/types-ts4.5/entry-points/popover.d.ts +1 -1
  136. package/dist/types-ts4.5/entry-points/use-anchor-position-at-point.d.ts +1 -0
  137. package/dist/types-ts4.5/entry-points/use-popover-id.d.ts +11 -0
  138. package/dist/types-ts4.5/focus/get-first-focusable.d.ts +8 -0
  139. package/dist/types-ts4.5/focus/get-focusables.d.ts +13 -0
  140. package/dist/types-ts4.5/focus/get-last-focusable.d.ts +8 -0
  141. package/dist/types-ts4.5/focus/get-next-focusable.d.ts +13 -0
  142. package/dist/types-ts4.5/focus/is-in-same-layer.d.ts +8 -0
  143. package/dist/types-ts4.5/focus/is-nested-layer-focused.d.ts +8 -0
  144. package/dist/types-ts4.5/focus/selectors.d.ts +4 -0
  145. package/dist/types-ts4.5/focus/types.d.ts +5 -0
  146. package/dist/types-ts4.5/internal/get-aria-for-trigger.d.ts +86 -0
  147. package/dist/types-ts4.5/internal/role-to-aria-has-popup.d.ts +13 -0
  148. package/dist/types-ts4.5/internal/role-types.d.ts +0 -12
  149. package/dist/types-ts4.5/internal/should-focus-into-popover.d.ts +8 -0
  150. package/dist/types-ts4.5/internal/slot.d.ts +2 -2
  151. package/dist/types-ts4.5/internal/use-anchor-position-at-point.d.ts +62 -0
  152. package/dist/types-ts4.5/internal/use-anchor-position.d.ts +6 -1
  153. package/dist/types-ts4.5/placement-map/index.d.ts +1 -1
  154. package/dist/types-ts4.5/placement-map/legacy-placements.d.ts +0 -12
  155. package/dist/types-ts4.5/placement-map/placement-mapping.d.ts +13 -0
  156. package/dist/types-ts4.5/popover/index.d.ts +1 -1
  157. package/dist/types-ts4.5/popover/popover.d.ts +6 -13
  158. package/dist/types-ts4.5/popover/types.d.ts +6 -5
  159. package/dist/types-ts4.5/popover-surface/index.d.ts +2 -0
  160. package/dist/types-ts4.5/popover-surface/popover-surface.d.ts +21 -0
  161. package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +1 -1
  162. package/get-aria-for-trigger/package.json +17 -0
  163. package/package.json +3 -3
  164. package/popover-surface/package.json +17 -0
  165. package/use-anchor-position-at-point/package.json +17 -0
  166. package/use-popover-id/package.json +17 -0
  167. package/dist/cjs/entry-points/popup-surface.js +0 -12
  168. package/dist/cjs/entry-points/popup.js +0 -12
  169. package/dist/cjs/focus/focus.js +0 -169
  170. package/dist/cjs/focus/index.js +0 -24
  171. package/dist/cjs/popup/index.js +0 -37
  172. package/dist/cjs/popup/popup-content.js +0 -214
  173. package/dist/cjs/popup/popup-context.js +0 -25
  174. package/dist/cjs/popup/popup-provider.js +0 -15
  175. package/dist/cjs/popup/popup-trigger-function.js +0 -80
  176. package/dist/cjs/popup/popup-trigger.js +0 -66
  177. package/dist/cjs/popup/popup.js +0 -81
  178. package/dist/cjs/popup/types.js +0 -5
  179. package/dist/cjs/popup/use-maybe-popup-context.js +0 -17
  180. package/dist/cjs/popup/use-popup-context.js +0 -20
  181. package/dist/es2019/entry-points/popup-surface.js +0 -1
  182. package/dist/es2019/entry-points/popup.js +0 -1
  183. package/dist/es2019/focus/focus.js +0 -158
  184. package/dist/es2019/focus/index.js +0 -1
  185. package/dist/es2019/popup/index.js +0 -33
  186. package/dist/es2019/popup/popup-content.js +0 -206
  187. package/dist/es2019/popup/popup-context.js +0 -20
  188. package/dist/es2019/popup/popup-provider.js +0 -10
  189. package/dist/es2019/popup/popup-surface.js +0 -30
  190. package/dist/es2019/popup/popup-trigger-function.js +0 -75
  191. package/dist/es2019/popup/popup-trigger.js +0 -61
  192. package/dist/es2019/popup/popup.js +0 -67
  193. package/dist/es2019/popup/types.js +0 -1
  194. package/dist/es2019/popup/use-maybe-popup-context.js +0 -12
  195. package/dist/es2019/popup/use-popup-context.js +0 -15
  196. package/dist/esm/entry-points/popup-surface.js +0 -1
  197. package/dist/esm/entry-points/popup.js +0 -1
  198. package/dist/esm/focus/focus.js +0 -160
  199. package/dist/esm/focus/index.js +0 -1
  200. package/dist/esm/popup/index.js +0 -33
  201. package/dist/esm/popup/popup-content.js +0 -206
  202. package/dist/esm/popup/popup-context.js +0 -20
  203. package/dist/esm/popup/popup-provider.js +0 -10
  204. package/dist/esm/popup/popup-surface.js +0 -29
  205. package/dist/esm/popup/popup-trigger-function.js +0 -75
  206. package/dist/esm/popup/popup-trigger.js +0 -59
  207. package/dist/esm/popup/popup.js +0 -72
  208. package/dist/esm/popup/types.js +0 -1
  209. package/dist/esm/popup/use-maybe-popup-context.js +0 -12
  210. package/dist/esm/popup/use-popup-context.js +0 -15
  211. package/dist/types/entry-points/popup-surface.d.ts +0 -2
  212. package/dist/types/entry-points/popup.d.ts +0 -2
  213. package/dist/types/focus/focus.d.ts +0 -50
  214. package/dist/types/focus/index.d.ts +0 -2
  215. package/dist/types/popup/index.d.ts +0 -34
  216. package/dist/types/popup/popup-content.d.ts +0 -14
  217. package/dist/types/popup/popup-context.d.ts +0 -96
  218. package/dist/types/popup/popup-provider.d.ts +0 -10
  219. package/dist/types/popup/popup-surface.d.ts +0 -22
  220. package/dist/types/popup/popup-trigger-function.d.ts +0 -112
  221. package/dist/types/popup/popup-trigger.d.ts +0 -14
  222. package/dist/types/popup/popup.d.ts +0 -14
  223. package/dist/types/popup/types.d.ts +0 -321
  224. package/dist/types/popup/use-maybe-popup-context.d.ts +0 -8
  225. package/dist/types/popup/use-popup-context.d.ts +0 -7
  226. package/dist/types-ts4.5/entry-points/popup-surface.d.ts +0 -2
  227. package/dist/types-ts4.5/entry-points/popup.d.ts +0 -2
  228. package/dist/types-ts4.5/focus/focus.d.ts +0 -50
  229. package/dist/types-ts4.5/focus/index.d.ts +0 -2
  230. package/dist/types-ts4.5/popup/index.d.ts +0 -34
  231. package/dist/types-ts4.5/popup/popup-content.d.ts +0 -14
  232. package/dist/types-ts4.5/popup/popup-context.d.ts +0 -96
  233. package/dist/types-ts4.5/popup/popup-provider.d.ts +0 -10
  234. package/dist/types-ts4.5/popup/popup-surface.d.ts +0 -22
  235. package/dist/types-ts4.5/popup/popup-trigger-function.d.ts +0 -112
  236. package/dist/types-ts4.5/popup/popup-trigger.d.ts +0 -14
  237. package/dist/types-ts4.5/popup/popup.d.ts +0 -14
  238. package/dist/types-ts4.5/popup/types.d.ts +0 -321
  239. package/dist/types-ts4.5/popup/use-maybe-popup-context.d.ts +0 -8
  240. package/dist/types-ts4.5/popup/use-popup-context.d.ts +0 -7
  241. package/popup/package.json +0 -17
  242. package/popup-surface/package.json +0 -17
  243. /package/dist/cjs/{popup/popup-surface.compiled.css → popover-surface/popover-surface.compiled.css} +0 -0
  244. /package/dist/es2019/{popup/popup-surface.compiled.css → popover-surface/popover-surface.compiled.css} +0 -0
  245. /package/dist/esm/{popup/popup-surface.compiled.css → popover-surface/popover-surface.compiled.css} +0 -0
@@ -1,321 +0,0 @@
1
- import { type ReactElement, type ReactNode, type Ref, type RefObject } from 'react';
2
- import { type StrictXCSSProp } from '@atlaskit/css';
3
- import { type TAnimationPreset } from '../animations/types';
4
- import { type TPlacementOptions } from '../internal/resolve-placement';
5
- import { type TRoleRequiringAccessibleName, type TRoleWithImplicitName } from '../internal/role-types';
6
- import { type TPopoverCloseReason, type TWidthFromAnchorMode } from '../popover/types';
7
- /**
8
- * Describes where to position a popover relative to its trigger. All fields
9
- * are optional. The default `{}` means "below the trigger, centered, with a
10
- * `space.100` token gap" (equivalent to Popper.js `'bottom'`).
11
- *
12
- * - `axis`: `'block'` (above/below, default) or `'inline'` (left/right)
13
- * - `edge`: `'start'` or `'end'` (default)
14
- * - `align`: `'start'`, `'center'` (default), or `'end'`
15
- * - `offset.gap`: distance from the trigger toward the popover (default `token('space.100', '8px')`, accepts number or CSS string)
16
- * - `offset.crossAxisShift.value`: cross-axis shift (default `0`)
17
- * - `offset.crossAxisShift.direction`: `'forwards'` (default) or `'backwards'`
18
- *
19
- * @example
20
- * ```ts
21
- * placement={{ align: 'start' }} // Below trigger, aligned to start
22
- * placement={{ axis: 'inline' }} // Right of trigger, centered
23
- * placement={{ offset: { gap: 4 } }} // Tooltip-like gap
24
- * placement={{ offset: { crossAxisShift: { value: 4, direction: 'backwards' } } }}
25
- * ```
26
- */
27
- export { type TPlacementOptions } from '../internal/resolve-placement';
28
- /**
29
- * Props shared across all `Popup` modes.
30
- *
31
- * Mode-specific behaviour for `onClose` is encoded in the discriminated
32
- * union below: `'auto'` and `'hint'` modes accept an `onClose` handler
33
- * (called on light dismiss); `'manual'` mode forbids it (no light dismiss
34
- * exists, so a handler would be dead code).
35
- */
36
- type TPopupBaseProps = {
37
- /**
38
- * Position of the popup relative to the trigger. Only the Popup compound uses
39
- * placement; the low-level Popover primitive does not.
40
- *
41
- * Defaults to `{}` which means "below the trigger, centered, with a
42
- * `space.100` token gap".
43
- */
44
- placement?: TPlacementOptions;
45
- /**
46
- * Must contain `Popup.Trigger` and `Popup.Content`.
47
- */
48
- children: ReactNode;
49
- /**
50
- * Called when the popup's open state changes.
51
- *
52
- * Receives the new open state and a reference to the popover element,
53
- * which is useful for focus management (e.g. focusing the first interactive
54
- * child on open via `getFirstFocusable` from `@atlaskit/top-layer/focus`).
55
- *
56
- * @example
57
- * ```tsx
58
- * <Popup
59
- * onOpenChange={({ isOpen, element }) => {
60
- * if (isOpen) {
61
- * getFirstFocusable({ container: element })?.focus();
62
- * }
63
- * }}
64
- * />
65
- * ```
66
- */
67
- onOpenChange?: (args: {
68
- isOpen: boolean;
69
- element: HTMLDivElement;
70
- }) => void;
71
- /**
72
- * Test ID applied to the popup content element.
73
- */
74
- testId?: string;
75
- /**
76
- * Forces the JavaScript positioning fallback even when the browser
77
- * supports CSS Anchor Positioning. Useful for testing fallback
78
- * behavior in any environment, including production.
79
- */
80
- forceFallbackPositioning?: boolean;
81
- };
82
- /**
83
- * Props for the `Popup` compound.
84
- *
85
- * Discriminated on `mode`:
86
- * - `'auto'` (default) and `'hint'`: light dismiss is enabled; `onClose` is
87
- * optional and is called when the browser dismisses the popover.
88
- * - `'manual'`: no light dismiss; `onClose` is `never` since the consumer
89
- * owns show/hide entirely and there is no dismiss event to handle.
90
- */
91
- export type TPopupProps = TPopupBaseProps & ({
92
- /**
93
- * Native popover attribute value. Default is `'auto'`.
94
- *
95
- * - `'auto'`: light dismiss (Escape, click-outside). Only one
96
- * `popover="auto"` can be open at a time; opening another closes
97
- * the previous.
98
- * - `'hint'`: allows ephemeral UI (e.g. tooltips) to open without
99
- * closing other `popover="auto"` popovers. Falls back to
100
- * `popover="auto"` when unsupported.
101
- */
102
- mode?: 'auto' | 'hint';
103
- /**
104
- * Called when the popup is dismissed via light dismiss.
105
- *
106
- * The `reason` field indicates how the dismiss occurred:
107
- * - `'escape'`: the user pressed the Escape key.
108
- * - `'light-dismiss'`: the user clicked outside (or another auto-dismiss).
109
- */
110
- onClose?: (args: {
111
- reason: TPopoverCloseReason;
112
- }) => void;
113
- } | {
114
- /**
115
- * `'manual'`: no light dismiss; the consumer controls show/hide
116
- * entirely. Escape and click-outside do not close the popover.
117
- */
118
- mode: 'manual';
119
- /**
120
- * Manual mode has no dismiss event, so `onClose` is forbidden.
121
- * The consumer owns show/hide via their own state.
122
- */
123
- onClose?: never;
124
- });
125
- export type TPopupTriggerProps = {
126
- /**
127
- * The trigger element. Must accept a ref.
128
- */
129
- children: ReactElement;
130
- };
131
- /**
132
- * All ARIA roles supported for popover content.
133
- * Add new roles to the appropriate category in `internal/role-types.tsx` as needed.
134
- */
135
- export type TPopupRole = TRoleRequiringAccessibleName | TRoleWithImplicitName;
136
- /**
137
- * Props shared across all popover role variants.
138
- *
139
- * When inside the `<Popup>` compound component, `isOpen` is provided automatically
140
- * via context (the browser manages visibility through `togglePopover()`).
141
- *
142
- * When used standalone (e.g. tooltip, spotlight), the consumer must provide `isOpen`
143
- * to control visibility. If `animate` is provided, `isOpen` is required at the type
144
- * level. This ensures exit animations always have a controlled lifecycle.
145
- */
146
- type TPopupContentBaseProps = {
147
- children: ReactNode;
148
- /**
149
- * Ref to the underlying `<div popover>` element.
150
- */
151
- ref?: Ref<HTMLDivElement>;
152
- /**
153
- * HTML `id` attribute for the popover element.
154
- *
155
- * Provide this when using `Popup.Content` standalone (outside the
156
- * `<Popup>` compound). The consumer is responsible for wiring
157
- * `aria-controls` on their own trigger to this same id. Inside the
158
- * `<Popup>` compound, the id flows from context - passing it here is
159
- * unnecessary.
160
- */
161
- id?: string;
162
- /**
163
- * Controls the width of the popover relative to its anchor element.
164
- *
165
- * - `'none'` (default): popover sizes to its content, ignoring the anchor width.
166
- * - `'match-anchor'`: popover matches the anchor element's width exactly
167
- * via CSS `anchor-size(width)`. Falls back to a one-off measurement
168
- * of `anchorRef.current.offsetWidth` when CSS Anchor Positioning
169
- * is not supported.
170
- * - `'min-anchor'`: popover is at least as wide as the anchor, but
171
- * can grow wider if content requires it. Uses `min-width: anchor-size(width)`.
172
- * Falls back to a one-off measurement of the anchor's width.
173
- */
174
- widthFromAnchor?: TWidthFromAnchorMode;
175
- /**
176
- * Applies additional CSS styles to the popover root element using
177
- * design-system-safe xcss.
178
- *
179
- * @example
180
- * ```tsx
181
- * const styles = cssMap({ surface: { backgroundColor: token('elevation.surface.overlay') } });
182
- * <Popup.Content xcss={styles.surface} ... />
183
- * ```
184
- */
185
- xcss?: StrictXCSSProp<'backgroundColor', never>;
186
- /**
187
- * Ref to the trigger element for anchor positioning.
188
- * When absent, anchor positioning is skipped (consumer handles positioning).
189
- */
190
- triggerRef?: RefObject<HTMLElement | null>;
191
- /**
192
- * Position of the popover relative to the trigger.
193
- */
194
- placement?: TPlacementOptions;
195
- /**
196
- * Called when the popover is dismissed via light dismiss (Escape, click outside).
197
- * When an animation preset is provided, `onClose` is called after the exit
198
- * animation completes.
199
- *
200
- * The `reason` field indicates how the dismiss occurred:
201
- * - `'escape'`: the user pressed the Escape key.
202
- * - `'light-dismiss'`: the user clicked outside (or another auto-dismiss).
203
- */
204
- onClose?: (args: {
205
- reason: TPopoverCloseReason;
206
- }) => void;
207
- /**
208
- * Test ID applied to the popover content element.
209
- */
210
- testId?: string;
211
- /**
212
- * Forces the JavaScript positioning fallback even when the browser
213
- * supports CSS Anchor Positioning. Useful for testing fallback
214
- * behavior in any environment, including production.
215
- */
216
- forceFallbackPositioning?: boolean;
217
- /**
218
- * Native popover attribute value. Default is `'auto'`.
219
- *
220
- * - `'auto'`: light dismiss (Escape, click-outside). Only one `popover="auto"` can be open at a time; opening another closes the previous.
221
- * - `'hint'`: allows ephemeral UI (e.g. tooltips) to open without closing other `popover="auto"` popovers. When the browser does not support `popover="hint"`, the component automatically falls back to `popover="auto"`; this fallback is transparent to the consumer.
222
- * - `'manual'`: no light dismiss; the consumer controls show/hide entirely (e.g. Flag). Escape and click-outside do not close the popover.
223
- */
224
- mode?: 'auto' | 'hint' | 'manual';
225
- /**
226
- * Animation preset for entry/exit transitions.
227
- *
228
- * - `TAnimationPreset`: a preset object (e.g. from `@atlaskit/top-layer/animations`).
229
- * Entry animation plays via `@starting-style`, exit via `allow-discrete`.
230
- * - `undefined` / `false`: no animation.
231
- *
232
- * When used standalone (outside `<Popup>` compound), pair with `isOpen` for exit
233
- * animations to work correctly. Inside the compound, `isOpen` is provided via context.
234
- *
235
- * Animations use `@starting-style` and `allow-discrete` for progressive
236
- * enhancement: browsers without support show/hide instantly.
237
- */
238
- animate?: false | TAnimationPreset;
239
- /**
240
- * Whether the popover is open.
241
- *
242
- * Controls `showPopover()` / `hidePopover()` on the underlying element.
243
- * Inside the `<Popup>` compound, `isOpen` is provided automatically via context
244
- * (the browser manages state through `togglePopover()`).
245
- *
246
- * For standalone usage, provide `isOpen` to control visibility, especially
247
- * when `animate` is set, so the exit animation lifecycle works correctly.
248
- *
249
- * @example
250
- * ```tsx
251
- * <Popup.Content
252
- * role="tooltip"
253
- * isOpen={isVisible}
254
- * animate={slideAndFade()}
255
- * >
256
- * Tooltip content
257
- * </Popup.Content>
258
- * ```
259
- */
260
- isOpen?: boolean;
261
- /**
262
- * Called after the entry animation completes (or immediately on open when
263
- * there is no animation). Use this for lifecycle coordination that must
264
- * happen after the popup has fully animated in.
265
- */
266
- onEnterFinish?: () => void;
267
- /**
268
- * Called after the exit animation completes (or immediately on close when
269
- * there is no animation). Use this for lifecycle coordination that must
270
- * happen after the popup has fully animated out.
271
- */
272
- onExitFinish?: () => void;
273
- };
274
- /**
275
- * Popup content props.
276
- *
277
- * Roles like `'dialog'`, `'alertdialog'`, and `'menu'` require an accessible
278
- * name. Provide either `label` (aria-label) or `labelledBy` (aria-labelledby).
279
- * TypeScript enforces this at compile time.
280
- */
281
- export type TPopupContentProps = TPopupContentBaseProps & (({
282
- /**
283
- * ARIA role for the popover. Roles that are ARIA landmarks (`dialog`,
284
- * `alertdialog`, `menu`) require an accessible name.
285
- */
286
- role: TRoleRequiringAccessibleName;
287
- } & ({
288
- /**
289
- * Accessible name via `aria-label`.
290
- */
291
- label: string;
292
- /**
293
- * Accessible name via `aria-labelledby`.
294
- */
295
- labelledBy?: string;
296
- } | {
297
- /**
298
- * Accessible name via `aria-label`.
299
- */
300
- label?: string;
301
- /**
302
- * Accessible name via `aria-labelledby`.
303
- */
304
- labelledBy: string;
305
- })) | {
306
- /**
307
- * ARIA role for the popover.
308
- */
309
- role: TRoleWithImplicitName;
310
- /**
311
- * Accessible name via `aria-label`.
312
- */
313
- label?: string;
314
- /**
315
- * Accessible name via `aria-labelledby`.
316
- */
317
- labelledBy?: string;
318
- });
319
- export type TPopupSurfaceProps = {
320
- children: ReactNode;
321
- };
@@ -1,8 +0,0 @@
1
- import { type TPopupContextValue } from './popup-context';
2
- /**
3
- * Returns the popup context if available, or `null` when used outside `<Popup>`.
4
- *
5
- * Used by `PopupContent` to support standalone usage (e.g. tooltip)
6
- * where values are passed as props instead of coming from a compound component.
7
- */
8
- export declare function useMaybePopupContext(): TPopupContextValue | null;
@@ -1,7 +0,0 @@
1
- import { type TPopupContextValue } from './popup-context';
2
- /**
3
- * Returns the nearest `Popup` context value.
4
- *
5
- * Throws if called outside of a `<Popup>` compound component.
6
- */
7
- export declare function usePopupContext(): TPopupContextValue;
@@ -1,2 +0,0 @@
1
- export { PopupSurface } from '../popup/popup-surface';
2
- export type { TPopupSurfaceProps } from '../popup/types';
@@ -1,2 +0,0 @@
1
- export { Popup } from '../popup';
2
- export type { TPlacementOptions, TPopupProps, TPopupContentProps, TPopupRole, TPopupTriggerProps, TTriggerFunctionRenderProps, } from '../popup';
@@ -1,50 +0,0 @@
1
- /**
2
- * Focusable element selectors and navigation helpers.
3
- *
4
- * Uses CSS selectors to discover focusable elements within a container,
5
- * avoiding the need for a manual registration system. Disabled elements
6
- * (both HTML `disabled` attribute and `aria-disabled="true"`) and elements
7
- * with `tabindex="-1"` are excluded automatically.
8
- *
9
- * All public functions accept an optional `filter` callback to further
10
- * restrict which focusable elements are included.
11
- */
12
- /**
13
- * Returns `true` when `document.activeElement` is inside a nested top-layer
14
- * descendant of `container` (a `[popover]`, `<dialog>`, `[role="dialog"]` or
15
- * `[role="alertdialog"]` that is itself a descendant of `container`).
16
- */
17
- export declare function isNestedLayerFocused({ container }: {
18
- container: HTMLElement;
19
- }): boolean;
20
- /**
21
- * An optional callback to restrict which focusable elements are included.
22
- * Return `true` to include the element, `false` to skip it.
23
- */
24
- export type TFocusableFilter = (element: HTMLElement, container: HTMLElement) => boolean;
25
- /**
26
- * Returns the first focusable element within the container.
27
- */
28
- export declare function getFirstFocusable({ container, filter, }: {
29
- container: HTMLElement;
30
- filter?: TFocusableFilter;
31
- }): HTMLElement | null;
32
- /**
33
- * Returns the last focusable element within the container.
34
- */
35
- export declare function getLastFocusable({ container, filter, }: {
36
- container: HTMLElement;
37
- filter?: TFocusableFilter;
38
- }): HTMLElement | null;
39
- /**
40
- * Returns the next focusable element in the given direction relative to the
41
- * currently focused element within the container. Wraps around at both ends.
42
- *
43
- * Returns `null` if there is no focused element within the container or if
44
- * the focused element is not in the list of focusable elements.
45
- */
46
- export declare function getNextFocusable({ container, direction, filter, }: {
47
- container: HTMLElement;
48
- direction: 'forwards' | 'backwards';
49
- filter?: TFocusableFilter;
50
- }): HTMLElement | null;
@@ -1,2 +0,0 @@
1
- export { getFirstFocusable, getLastFocusable, getNextFocusable } from './focus';
2
- export type { TFocusableFilter } from './focus';
@@ -1,34 +0,0 @@
1
- import { PopupRoot } from './popup';
2
- import { PopupContent } from './popup-content';
3
- import { PopupSurface } from './popup-surface';
4
- import { PopupTrigger } from './popup-trigger';
5
- import { PopupTriggerFunction } from './popup-trigger-function';
6
- /**
7
- * Compound component for rendering content in the browser's top layer
8
- * using the native Popover API (`popover="auto"`).
9
- * Placement is owned by this compound: root provides it via context, Content applies it
10
- * (CSS Anchor Positioning or JS fallback).
11
- *
12
- * For default overlay styling (background, shadow, border-radius), see `PopupSurface` in the package examples.
13
- *
14
- * @example
15
- * ```tsx
16
- * <Popup placement={{ edge: 'end' }} onClose={handleClose}>
17
- * <Popup.Trigger>
18
- * <button>Open</button>
19
- * </Popup.Trigger>
20
- * <Popup.Content role="dialog" label="My popup">
21
- * Content goes here
22
- * </Popup.Content>
23
- * </Popup>
24
- * ```
25
- */
26
- declare const Popup: typeof PopupRoot & {
27
- Trigger: typeof PopupTrigger;
28
- TriggerFunction: typeof PopupTriggerFunction;
29
- Content: typeof PopupContent;
30
- Surface: typeof PopupSurface;
31
- };
32
- export { Popup };
33
- export type { TPlacementOptions, TPopupProps, TPopupContentProps, TPopupRole, TPopupSurfaceProps, TPopupTriggerProps, } from './types';
34
- export type { TTriggerFunctionRenderProps } from './popup-trigger-function';
@@ -1,14 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import React from 'react';
6
- import { type TPopupContentProps } from './types';
7
- /**
8
- * Thin context wrapper that composes `Popover` + `useAnchorPosition`.
9
- *
10
- * Used inside the `<Popup>` compound - reads triggerRef, placement, isOpen,
11
- * and onClose from context. For standalone usage (tooltip, spotlight, flag),
12
- * use `Popover` + `useAnchorPosition` directly.
13
- */
14
- export declare const PopupContent: React.ForwardRefExoticComponent<TPopupContentProps & React.RefAttributes<HTMLDivElement>>;
@@ -1,96 +0,0 @@
1
- import React, { type MutableRefObject, type RefObject } from 'react';
2
- import { type TAriaHasPopupValue } from '../internal/role-types';
3
- import { type TPopoverCloseReason } from '../popover/types';
4
- import { type TPlacementOptions } from './types';
5
- /**
6
- * Represents the lifecycle state of the popup.
7
- *
8
- * - `'closed'`: fully closed, not visible, no animation playing.
9
- * - `'animating-open'`: entry animation is playing (popup is opening but not yet settled).
10
- * - `'open'`: fully open, browser popover is showing, entry animation complete.
11
- * - `'animating-closed'`: exit animation is playing (popup is closing but still visible).
12
- *
13
- * Used to derive `aria-expanded` on the trigger:
14
- * - `aria-expanded` is `true` in `'animating-open'`, `'open'`, and `'animating-closed'`.
15
- *
16
- * This avoids screen readers announcing the popup as closed while it is
17
- * still visually present on screen during animations, and prevents consumers
18
- * that conditionally show/hide trigger UI based on `aria-expanded` from hiding
19
- * the trigger (and thus the popup anchor) mid-animation.
20
- */
21
- export type TPopupState = 'closed' | 'animating-open' | 'open' | 'animating-closed';
22
- export type TPopupContextValue = {
23
- /**
24
- * Auto-generated ID for the popover content element (used for aria-controls).
25
- */
26
- popoverId: string;
27
- /**
28
- * Requested placement.
29
- */
30
- placement: TPlacementOptions;
31
- /**
32
- * Called when the popover is dismissed via light dismiss.
33
- * `null` when mode is 'manual' (no light dismiss).
34
- */
35
- onClose: ((args: {
36
- reason: TPopoverCloseReason;
37
- }) => void) | null;
38
- /**
39
- * Mutable ref to the trigger element (set by Popup.Trigger / Popup.TriggerFunction).
40
- */
41
- triggerRef: MutableRefObject<HTMLElement | null>;
42
- /**
43
- * Ref to the popover content element (set by Popup.Content).
44
- */
45
- popoverRef: RefObject<HTMLDivElement | null>;
46
- /**
47
- * The full lifecycle state of the popup.
48
- *
49
- * See `TPopupState` for the full state machine description.
50
- */
51
- popupState: TPopupState;
52
- /**
53
- * Updates the popup lifecycle state. Called by `PopupContent` as animations
54
- * begin and complete.
55
- */
56
- setPopupState: (state: TPopupState) => void;
57
- /**
58
- * Consumer's onOpenChange callback, forwarded to the Popover.
59
- */
60
- onOpenChange?: (args: {
61
- isOpen: boolean;
62
- element: HTMLDivElement;
63
- }) => void;
64
- /**
65
- * Native popover mode. Flows from the Popup root to Content via context.
66
- */
67
- mode: 'auto' | 'hint' | 'manual';
68
- /**
69
- * The `aria-haspopup` value derived from the content's role.
70
- *
71
- * Set by `Popup.Content` via `setAriaHasPopup` when it renders.
72
- * Read by `Popup.Trigger` / `Popup.TriggerFunction` to set
73
- * the correct `aria-haspopup` on the trigger element.
74
- *
75
- * This flows the content's role to the trigger without requiring
76
- * the consumer to specify the role in two places. The trigger
77
- * renders with the default ('dialog') on first paint; Content's
78
- * layout effect updates it before the browser paints.
79
- */
80
- ariaHasPopup: TAriaHasPopupValue;
81
- /**
82
- * Updates `ariaHasPopup` - called by Content on mount/role change.
83
- */
84
- setAriaHasPopup: (value: TAriaHasPopupValue) => void;
85
- /**
86
- * Test ID prefix.
87
- */
88
- testId?: string;
89
- /**
90
- * Forces the JavaScript positioning fallback even when the browser
91
- * supports CSS Anchor Positioning. Useful for testing fallback
92
- * behavior in any environment, including production.
93
- */
94
- forceFallbackPositioning?: boolean;
95
- };
96
- export declare const PopupContext: React.Context<TPopupContextValue | null>;
@@ -1,10 +0,0 @@
1
- import { type Provider } from 'react';
2
- import { type TPopupContextValue } from './popup-context';
3
- /**
4
- * __Popup provider__
5
- *
6
- * Provides shared popup state (placement, popoverId, triggerRef,
7
- * isOpen, onClose) to compound child components such as `Popup.Trigger` and
8
- * `Popup.Content`.
9
- */
10
- export declare const PopupProvider: Provider<TPopupContextValue | null>;
@@ -1,22 +0,0 @@
1
- /**
2
- * @jsxRuntime classic
3
- * @jsx jsx
4
- */
5
- import React from 'react';
6
- import { type TPopupSurfaceProps } from './types';
7
- /**
8
- * Optional styled wrapper for popup content.
9
- *
10
- * Adds default visual styling (background, border-radius, box-shadow)
11
- * using design tokens. Consumers who want fully custom styling
12
- * should use `Popup.Content` without wrapping in `PopupSurface`.
13
- *
14
- * Exposed as `Popup.Surface` on the compound component.
15
- *
16
- * **Presentational primitive - `children`-only by design.** This component
17
- * intentionally exposes no `style`, `className`, `xcss`, `id`, or `ref`
18
- * props. If you need any of those, render your own wrapper element inside
19
- * `Popup.Content` instead - `PopupSurface` is the no-config "give me the
20
- * default ADS overlay look" surface, nothing more.
21
- */
22
- export declare function PopupSurface({ children }: TPopupSurfaceProps): React.ReactElement;