@atlaskit/top-layer 0.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 (300) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +151 -0
  3. package/animations/package.json +17 -0
  4. package/arrow/package.json +17 -0
  5. package/create-close-event/package.json +17 -0
  6. package/dialog/package.json +17 -0
  7. package/dialog-scroll-lock/package.json +17 -0
  8. package/dist/cjs/animations/presets.js +199 -0
  9. package/dist/cjs/animations/types.js +5 -0
  10. package/dist/cjs/arrow/index.js +130 -0
  11. package/dist/cjs/arrow/types.js +5 -0
  12. package/dist/cjs/dialog/create-close-event.js +39 -0
  13. package/dist/cjs/dialog/dialog-content.compiled.css +14 -0
  14. package/dist/cjs/dialog/dialog-content.js +144 -0
  15. package/dist/cjs/dialog/index.js +19 -0
  16. package/dist/cjs/dialog/types.js +5 -0
  17. package/dist/cjs/dialog-scroll-lock/index.js +46 -0
  18. package/dist/cjs/entry-points/animations.js +36 -0
  19. package/dist/cjs/entry-points/arrow.js +12 -0
  20. package/dist/cjs/entry-points/create-close-event.js +19 -0
  21. package/dist/cjs/entry-points/dialog-scroll-lock.js +12 -0
  22. package/dist/cjs/entry-points/dialog.js +12 -0
  23. package/dist/cjs/entry-points/focus.js +24 -0
  24. package/dist/cjs/entry-points/placement-map.js +18 -0
  25. package/dist/cjs/entry-points/popover.js +12 -0
  26. package/dist/cjs/entry-points/popup-surface.js +12 -0
  27. package/dist/cjs/entry-points/popup.js +12 -0
  28. package/dist/cjs/entry-points/use-anchor-position.js +12 -0
  29. package/dist/cjs/entry-points/use-arrow-navigation.js +18 -0
  30. package/dist/cjs/entry-points/use-simple-light-dismiss.js +12 -0
  31. package/dist/cjs/focus/focus.js +115 -0
  32. package/dist/cjs/focus/index.js +24 -0
  33. package/dist/cjs/index.js +8 -0
  34. package/dist/cjs/internal/anchor-positioning-fallback.js +154 -0
  35. package/dist/cjs/internal/combine.js +29 -0
  36. package/dist/cjs/internal/ensure-preset-styles.js +34 -0
  37. package/dist/cjs/internal/reduced-motion.js +27 -0
  38. package/dist/cjs/internal/resolve-placement.js +24 -0
  39. package/dist/cjs/internal/role-types.js +66 -0
  40. package/dist/cjs/internal/set-style.js +42 -0
  41. package/dist/cjs/internal/slot.js +65 -0
  42. package/dist/cjs/internal/use-anchor-positioning.js +336 -0
  43. package/dist/cjs/internal/use-animated-visibility.js +169 -0
  44. package/dist/cjs/internal/use-animation-preset.js +24 -0
  45. package/dist/cjs/internal/use-focus-wrap.js +94 -0
  46. package/dist/cjs/internal/use-initial-focus.js +112 -0
  47. package/dist/cjs/internal/use-preset-styles.js +27 -0
  48. package/dist/cjs/placement-map/index.js +147 -0
  49. package/dist/cjs/popover/create-close-event.js +44 -0
  50. package/dist/cjs/popover/index.js +19 -0
  51. package/dist/cjs/popover/popover.compiled.css +13 -0
  52. package/dist/cjs/popover/popover.js +251 -0
  53. package/dist/cjs/popover/types.js +5 -0
  54. package/dist/cjs/popup/index.js +37 -0
  55. package/dist/cjs/popup/popup-content.js +201 -0
  56. package/dist/cjs/popup/popup-context.js +42 -0
  57. package/dist/cjs/popup/popup-surface.compiled.css +5 -0
  58. package/dist/cjs/popup/popup-surface.js +30 -0
  59. package/dist/cjs/popup/popup-trigger-function.js +74 -0
  60. package/dist/cjs/popup/popup-trigger.js +82 -0
  61. package/dist/cjs/popup/popup.js +70 -0
  62. package/dist/cjs/popup/types.js +5 -0
  63. package/dist/cjs/use-arrow-navigation/index.js +18 -0
  64. package/dist/cjs/use-arrow-navigation/use-arrow-navigation.js +245 -0
  65. package/dist/cjs/use-simple-light-dismiss/index.js +84 -0
  66. package/dist/es2019/animations/presets.js +375 -0
  67. package/dist/es2019/animations/types.js +1 -0
  68. package/dist/es2019/arrow/index.js +249 -0
  69. package/dist/es2019/arrow/types.js +1 -0
  70. package/dist/es2019/dialog/create-close-event.js +34 -0
  71. package/dist/es2019/dialog/dialog-content.compiled.css +14 -0
  72. package/dist/es2019/dialog/dialog-content.js +138 -0
  73. package/dist/es2019/dialog/index.js +2 -0
  74. package/dist/es2019/dialog/types.js +1 -0
  75. package/dist/es2019/dialog-scroll-lock/index.js +41 -0
  76. package/dist/es2019/entry-points/animations.js +1 -0
  77. package/dist/es2019/entry-points/arrow.js +1 -0
  78. package/dist/es2019/entry-points/create-close-event.js +2 -0
  79. package/dist/es2019/entry-points/dialog-scroll-lock.js +1 -0
  80. package/dist/es2019/entry-points/dialog.js +1 -0
  81. package/dist/es2019/entry-points/focus.js +1 -0
  82. package/dist/es2019/entry-points/placement-map.js +1 -0
  83. package/dist/es2019/entry-points/popover.js +1 -0
  84. package/dist/es2019/entry-points/popup-surface.js +1 -0
  85. package/dist/es2019/entry-points/popup.js +1 -0
  86. package/dist/es2019/entry-points/use-anchor-position.js +1 -0
  87. package/dist/es2019/entry-points/use-arrow-navigation.js +1 -0
  88. package/dist/es2019/entry-points/use-simple-light-dismiss.js +1 -0
  89. package/dist/es2019/focus/focus.js +107 -0
  90. package/dist/es2019/focus/index.js +1 -0
  91. package/dist/es2019/index.js +7 -0
  92. package/dist/es2019/internal/anchor-positioning-fallback.js +153 -0
  93. package/dist/es2019/internal/combine.js +18 -0
  94. package/dist/es2019/internal/ensure-preset-styles.js +29 -0
  95. package/dist/es2019/internal/reduced-motion.js +21 -0
  96. package/dist/es2019/internal/resolve-placement.js +19 -0
  97. package/dist/es2019/internal/role-types.js +61 -0
  98. package/dist/es2019/internal/set-style.js +39 -0
  99. package/dist/es2019/internal/slot.js +57 -0
  100. package/dist/es2019/internal/use-anchor-positioning.js +330 -0
  101. package/dist/es2019/internal/use-animated-visibility.js +159 -0
  102. package/dist/es2019/internal/use-animation-preset.js +18 -0
  103. package/dist/es2019/internal/use-focus-wrap.js +90 -0
  104. package/dist/es2019/internal/use-initial-focus.js +109 -0
  105. package/dist/es2019/internal/use-preset-styles.js +22 -0
  106. package/dist/es2019/placement-map/index.js +142 -0
  107. package/dist/es2019/popover/create-close-event.js +39 -0
  108. package/dist/es2019/popover/index.js +2 -0
  109. package/dist/es2019/popover/popover.compiled.css +13 -0
  110. package/dist/es2019/popover/popover.js +240 -0
  111. package/dist/es2019/popover/types.js +1 -0
  112. package/dist/es2019/popup/index.js +33 -0
  113. package/dist/es2019/popup/popup-content.js +192 -0
  114. package/dist/es2019/popup/popup-context.js +34 -0
  115. package/dist/es2019/popup/popup-surface.compiled.css +5 -0
  116. package/dist/es2019/popup/popup-surface.js +24 -0
  117. package/dist/es2019/popup/popup-trigger-function.js +69 -0
  118. package/dist/es2019/popup/popup-trigger.js +76 -0
  119. package/dist/es2019/popup/popup.js +56 -0
  120. package/dist/es2019/popup/types.js +1 -0
  121. package/dist/es2019/use-arrow-navigation/index.js +1 -0
  122. package/dist/es2019/use-arrow-navigation/use-arrow-navigation.js +238 -0
  123. package/dist/es2019/use-simple-light-dismiss/index.js +79 -0
  124. package/dist/esm/animations/presets.js +190 -0
  125. package/dist/esm/animations/types.js +1 -0
  126. package/dist/esm/arrow/index.js +123 -0
  127. package/dist/esm/arrow/types.js +1 -0
  128. package/dist/esm/dialog/create-close-event.js +33 -0
  129. package/dist/esm/dialog/dialog-content.compiled.css +14 -0
  130. package/dist/esm/dialog/dialog-content.js +135 -0
  131. package/dist/esm/dialog/index.js +2 -0
  132. package/dist/esm/dialog/types.js +1 -0
  133. package/dist/esm/dialog-scroll-lock/index.js +41 -0
  134. package/dist/esm/entry-points/animations.js +1 -0
  135. package/dist/esm/entry-points/arrow.js +1 -0
  136. package/dist/esm/entry-points/create-close-event.js +2 -0
  137. package/dist/esm/entry-points/dialog-scroll-lock.js +1 -0
  138. package/dist/esm/entry-points/dialog.js +1 -0
  139. package/dist/esm/entry-points/focus.js +1 -0
  140. package/dist/esm/entry-points/placement-map.js +1 -0
  141. package/dist/esm/entry-points/popover.js +1 -0
  142. package/dist/esm/entry-points/popup-surface.js +1 -0
  143. package/dist/esm/entry-points/popup.js +1 -0
  144. package/dist/esm/entry-points/use-anchor-position.js +1 -0
  145. package/dist/esm/entry-points/use-arrow-navigation.js +1 -0
  146. package/dist/esm/entry-points/use-simple-light-dismiss.js +1 -0
  147. package/dist/esm/focus/focus.js +107 -0
  148. package/dist/esm/focus/index.js +1 -0
  149. package/dist/esm/index.js +7 -0
  150. package/dist/esm/internal/anchor-positioning-fallback.js +147 -0
  151. package/dist/esm/internal/combine.js +23 -0
  152. package/dist/esm/internal/ensure-preset-styles.js +28 -0
  153. package/dist/esm/internal/reduced-motion.js +21 -0
  154. package/dist/esm/internal/resolve-placement.js +18 -0
  155. package/dist/esm/internal/role-types.js +60 -0
  156. package/dist/esm/internal/set-style.js +36 -0
  157. package/dist/esm/internal/slot.js +59 -0
  158. package/dist/esm/internal/use-anchor-positioning.js +323 -0
  159. package/dist/esm/internal/use-animated-visibility.js +162 -0
  160. package/dist/esm/internal/use-animation-preset.js +18 -0
  161. package/dist/esm/internal/use-focus-wrap.js +89 -0
  162. package/dist/esm/internal/use-initial-focus.js +107 -0
  163. package/dist/esm/internal/use-preset-styles.js +21 -0
  164. package/dist/esm/placement-map/index.js +141 -0
  165. package/dist/esm/popover/create-close-event.js +38 -0
  166. package/dist/esm/popover/index.js +2 -0
  167. package/dist/esm/popover/popover.compiled.css +13 -0
  168. package/dist/esm/popover/popover.js +242 -0
  169. package/dist/esm/popover/types.js +1 -0
  170. package/dist/esm/popup/index.js +33 -0
  171. package/dist/esm/popup/popup-content.js +192 -0
  172. package/dist/esm/popup/popup-context.js +34 -0
  173. package/dist/esm/popup/popup-surface.compiled.css +5 -0
  174. package/dist/esm/popup/popup-surface.js +23 -0
  175. package/dist/esm/popup/popup-trigger-function.js +69 -0
  176. package/dist/esm/popup/popup-trigger.js +74 -0
  177. package/dist/esm/popup/popup.js +61 -0
  178. package/dist/esm/popup/types.js +1 -0
  179. package/dist/esm/use-arrow-navigation/index.js +1 -0
  180. package/dist/esm/use-arrow-navigation/use-arrow-navigation.js +238 -0
  181. package/dist/esm/use-simple-light-dismiss/index.js +78 -0
  182. package/dist/types/animations/presets.d.ts +94 -0
  183. package/dist/types/animations/types.d.ts +42 -0
  184. package/dist/types/arrow/index.d.ts +24 -0
  185. package/dist/types/arrow/types.d.ts +29 -0
  186. package/dist/types/dialog/create-close-event.d.ts +24 -0
  187. package/dist/types/dialog/dialog-content.d.ts +20 -0
  188. package/dist/types/dialog/index.d.ts +3 -0
  189. package/dist/types/dialog/types.d.ts +92 -0
  190. package/dist/types/dialog-scroll-lock/index.d.ts +24 -0
  191. package/dist/types/entry-points/animations.d.ts +2 -0
  192. package/dist/types/entry-points/arrow.d.ts +2 -0
  193. package/dist/types/entry-points/create-close-event.d.ts +4 -0
  194. package/dist/types/entry-points/dialog-scroll-lock.d.ts +1 -0
  195. package/dist/types/entry-points/dialog.d.ts +2 -0
  196. package/dist/types/entry-points/focus.d.ts +2 -0
  197. package/dist/types/entry-points/placement-map.d.ts +2 -0
  198. package/dist/types/entry-points/popover.d.ts +2 -0
  199. package/dist/types/entry-points/popup-surface.d.ts +2 -0
  200. package/dist/types/entry-points/popup.d.ts +2 -0
  201. package/dist/types/entry-points/use-anchor-position.d.ts +1 -0
  202. package/dist/types/entry-points/use-arrow-navigation.d.ts +2 -0
  203. package/dist/types/entry-points/use-simple-light-dismiss.d.ts +2 -0
  204. package/dist/types/focus/focus.d.ts +42 -0
  205. package/dist/types/focus/index.d.ts +2 -0
  206. package/dist/types/index.d.ts +0 -0
  207. package/dist/types/internal/anchor-positioning-fallback.d.ts +24 -0
  208. package/dist/types/internal/combine.d.ts +14 -0
  209. package/dist/types/internal/ensure-preset-styles.d.ts +6 -0
  210. package/dist/types/internal/reduced-motion.d.ts +14 -0
  211. package/dist/types/internal/resolve-placement.d.ts +16 -0
  212. package/dist/types/internal/role-types.d.ts +62 -0
  213. package/dist/types/internal/set-style.d.ts +28 -0
  214. package/dist/types/internal/slot.d.ts +29 -0
  215. package/dist/types/internal/use-anchor-positioning.d.ts +95 -0
  216. package/dist/types/internal/use-animated-visibility.d.ts +74 -0
  217. package/dist/types/internal/use-animation-preset.d.ts +11 -0
  218. package/dist/types/internal/use-focus-wrap.d.ts +20 -0
  219. package/dist/types/internal/use-initial-focus.d.ts +21 -0
  220. package/dist/types/internal/use-preset-styles.d.ts +15 -0
  221. package/dist/types/placement-map/index.d.ts +55 -0
  222. package/dist/types/popover/create-close-event.d.ts +26 -0
  223. package/dist/types/popover/index.d.ts +3 -0
  224. package/dist/types/popover/popover.d.ts +22 -0
  225. package/dist/types/popover/types.d.ts +153 -0
  226. package/dist/types/popup/index.d.ts +34 -0
  227. package/dist/types/popup/popup-content.d.ts +14 -0
  228. package/dist/types/popup/popup-context.d.ts +96 -0
  229. package/dist/types/popup/popup-surface.d.ts +16 -0
  230. package/dist/types/popup/popup-trigger-function.d.ts +108 -0
  231. package/dist/types/popup/popup-trigger.d.ts +23 -0
  232. package/dist/types/popup/popup.d.ts +14 -0
  233. package/dist/types/popup/types.d.ts +289 -0
  234. package/dist/types/use-arrow-navigation/index.d.ts +2 -0
  235. package/dist/types/use-arrow-navigation/use-arrow-navigation.d.ts +136 -0
  236. package/dist/types/use-simple-light-dismiss/index.d.ts +45 -0
  237. package/dist/types-ts4.5/animations/presets.d.ts +94 -0
  238. package/dist/types-ts4.5/animations/types.d.ts +42 -0
  239. package/dist/types-ts4.5/arrow/index.d.ts +24 -0
  240. package/dist/types-ts4.5/arrow/types.d.ts +29 -0
  241. package/dist/types-ts4.5/dialog/create-close-event.d.ts +24 -0
  242. package/dist/types-ts4.5/dialog/dialog-content.d.ts +20 -0
  243. package/dist/types-ts4.5/dialog/index.d.ts +3 -0
  244. package/dist/types-ts4.5/dialog/types.d.ts +92 -0
  245. package/dist/types-ts4.5/dialog-scroll-lock/index.d.ts +24 -0
  246. package/dist/types-ts4.5/entry-points/animations.d.ts +2 -0
  247. package/dist/types-ts4.5/entry-points/arrow.d.ts +2 -0
  248. package/dist/types-ts4.5/entry-points/create-close-event.d.ts +4 -0
  249. package/dist/types-ts4.5/entry-points/dialog-scroll-lock.d.ts +1 -0
  250. package/dist/types-ts4.5/entry-points/dialog.d.ts +2 -0
  251. package/dist/types-ts4.5/entry-points/focus.d.ts +2 -0
  252. package/dist/types-ts4.5/entry-points/placement-map.d.ts +2 -0
  253. package/dist/types-ts4.5/entry-points/popover.d.ts +2 -0
  254. package/dist/types-ts4.5/entry-points/popup-surface.d.ts +2 -0
  255. package/dist/types-ts4.5/entry-points/popup.d.ts +2 -0
  256. package/dist/types-ts4.5/entry-points/use-anchor-position.d.ts +1 -0
  257. package/dist/types-ts4.5/entry-points/use-arrow-navigation.d.ts +2 -0
  258. package/dist/types-ts4.5/entry-points/use-simple-light-dismiss.d.ts +2 -0
  259. package/dist/types-ts4.5/focus/focus.d.ts +42 -0
  260. package/dist/types-ts4.5/focus/index.d.ts +2 -0
  261. package/dist/types-ts4.5/index.d.ts +0 -0
  262. package/dist/types-ts4.5/internal/anchor-positioning-fallback.d.ts +24 -0
  263. package/dist/types-ts4.5/internal/combine.d.ts +14 -0
  264. package/dist/types-ts4.5/internal/ensure-preset-styles.d.ts +6 -0
  265. package/dist/types-ts4.5/internal/reduced-motion.d.ts +14 -0
  266. package/dist/types-ts4.5/internal/resolve-placement.d.ts +16 -0
  267. package/dist/types-ts4.5/internal/role-types.d.ts +62 -0
  268. package/dist/types-ts4.5/internal/set-style.d.ts +28 -0
  269. package/dist/types-ts4.5/internal/slot.d.ts +29 -0
  270. package/dist/types-ts4.5/internal/use-anchor-positioning.d.ts +95 -0
  271. package/dist/types-ts4.5/internal/use-animated-visibility.d.ts +74 -0
  272. package/dist/types-ts4.5/internal/use-animation-preset.d.ts +11 -0
  273. package/dist/types-ts4.5/internal/use-focus-wrap.d.ts +20 -0
  274. package/dist/types-ts4.5/internal/use-initial-focus.d.ts +21 -0
  275. package/dist/types-ts4.5/internal/use-preset-styles.d.ts +15 -0
  276. package/dist/types-ts4.5/placement-map/index.d.ts +55 -0
  277. package/dist/types-ts4.5/popover/create-close-event.d.ts +26 -0
  278. package/dist/types-ts4.5/popover/index.d.ts +3 -0
  279. package/dist/types-ts4.5/popover/popover.d.ts +22 -0
  280. package/dist/types-ts4.5/popover/types.d.ts +153 -0
  281. package/dist/types-ts4.5/popup/index.d.ts +34 -0
  282. package/dist/types-ts4.5/popup/popup-content.d.ts +14 -0
  283. package/dist/types-ts4.5/popup/popup-context.d.ts +96 -0
  284. package/dist/types-ts4.5/popup/popup-surface.d.ts +16 -0
  285. package/dist/types-ts4.5/popup/popup-trigger-function.d.ts +108 -0
  286. package/dist/types-ts4.5/popup/popup-trigger.d.ts +23 -0
  287. package/dist/types-ts4.5/popup/popup.d.ts +14 -0
  288. package/dist/types-ts4.5/popup/types.d.ts +289 -0
  289. package/dist/types-ts4.5/use-arrow-navigation/index.d.ts +2 -0
  290. package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +136 -0
  291. package/dist/types-ts4.5/use-simple-light-dismiss/index.d.ts +45 -0
  292. package/focus/package.json +17 -0
  293. package/package.json +95 -0
  294. package/placement-map/package.json +17 -0
  295. package/popover/package.json +17 -0
  296. package/popup/package.json +17 -0
  297. package/popup-surface/package.json +17 -0
  298. package/use-anchor-position/package.json +17 -0
  299. package/use-arrow-navigation/package.json +17 -0
  300. package/use-simple-light-dismiss/package.json +17 -0
@@ -0,0 +1,192 @@
1
+ /* popup-content.tsx generated by @compiled/babel-plugin v0.39.1 */
2
+ import _extends from "@babel/runtime/helpers/extends";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React, { forwardRef, useCallback, useLayoutEffect, useRef } from 'react';
5
+ import mergeRefs from '@atlaskit/ds-lib/merge-refs';
6
+ import { roleToAriaHasPopup } from '../internal/role-types';
7
+ import { useAnchorPosition } from '../internal/use-anchor-positioning';
8
+ import { usePresetStyles } from '../internal/use-preset-styles';
9
+ import { Popover } from '../popover/popover';
10
+ import { useMaybePopupContext } from './popup-context';
11
+ /**
12
+ * Thin context wrapper that composes `Popover` + `useAnchorPosition`.
13
+ *
14
+ * Used inside the `<Popup>` compound — reads triggerRef, placement, isOpen,
15
+ * and onClose from context. For standalone usage (tooltip, spotlight, flag),
16
+ * use `Popover` + `useAnchorPosition` directly.
17
+ */
18
+ export var PopupContent = /*#__PURE__*/forwardRef(function PopupContent(_ref, ref) {
19
+ var _ref2, _ref3, _ctx$popoverRef;
20
+ var children = _ref.children,
21
+ role = _ref.role,
22
+ label = _ref.label,
23
+ labelledBy = _ref.labelledBy,
24
+ animate = _ref.animate,
25
+ arrow = _ref.arrow,
26
+ mode = _ref.mode,
27
+ _ref$width = _ref.width,
28
+ width = _ref$width === void 0 ? 'content' : _ref$width,
29
+ isOpenProp = _ref.isOpen,
30
+ triggerRefProp = _ref.triggerRef,
31
+ placementProp = _ref.placement,
32
+ onCloseProp = _ref.onClose,
33
+ testIdProp = _ref.testId,
34
+ offsetProp = _ref.offset,
35
+ forceFallbackPositioningProp = _ref.forceFallbackPositioning;
36
+ // When inside <Popup>, context provides defaults. Props always win.
37
+ var ctx = useMaybePopupContext();
38
+ var triggerRef = triggerRefProp !== null && triggerRefProp !== void 0 ? triggerRefProp : ctx === null || ctx === void 0 ? void 0 : ctx.triggerRef;
39
+ var placement = (_ref2 = placementProp !== null && placementProp !== void 0 ? placementProp : ctx === null || ctx === void 0 ? void 0 : ctx.placement) !== null && _ref2 !== void 0 ? _ref2 : {};
40
+ var onClose = onCloseProp !== null && onCloseProp !== void 0 ? onCloseProp : ctx === null || ctx === void 0 ? void 0 : ctx.onClose;
41
+ var testId = testIdProp !== null && testIdProp !== void 0 ? testIdProp : ctx === null || ctx === void 0 ? void 0 : ctx.testId;
42
+ var forceFallbackPositioning = forceFallbackPositioningProp !== null && forceFallbackPositioningProp !== void 0 ? forceFallbackPositioningProp : ctx === null || ctx === void 0 ? void 0 : ctx.forceFallbackPositioning;
43
+
44
+ // Resolve isOpen: prop wins, then context.
45
+ // Inside the <Popup> compound, ctx.isOpen tracks the browser's toggle state.
46
+ var isOpen = (_ref3 = isOpenProp !== null && isOpenProp !== void 0 ? isOpenProp : ctx === null || ctx === void 0 ? void 0 : ctx.isOpen) !== null && _ref3 !== void 0 ? _ref3 : false;
47
+
48
+ // Combine internal state sync with consumer's onOpenChange callback.
49
+ // The Popup compound needs setIsOpen to keep aria-expanded on the trigger
50
+ // in sync, and the consumer may also want to respond to open/close events
51
+ // (e.g. for focus management).
52
+ var setIsOpen = ctx === null || ctx === void 0 ? void 0 : ctx.setIsOpen;
53
+ var consumerOnOpenChange = ctx === null || ctx === void 0 ? void 0 : ctx.onOpenChange;
54
+ // Note: onOpenChange composition is handled by handleOpenChange below,
55
+ // which also adds nested-popover focus restoration.
56
+
57
+ // ── Sync aria-haspopup on the trigger with the content's role ──
58
+ var setAriaHasPopup = ctx === null || ctx === void 0 ? void 0 : ctx.setAriaHasPopup;
59
+ useLayoutEffect(function () {
60
+ setAriaHasPopup === null || setAriaHasPopup === void 0 || setAriaHasPopup(roleToAriaHasPopup({
61
+ role: role
62
+ }));
63
+ }, [role, setAriaHasPopup]);
64
+
65
+ // ── Focus restoration ──
66
+ // The native Popover API handles focus restoration automatically for
67
+ // popover="auto" and popover="hint":
68
+ // - Escape → restores focus to the previously focused element (the trigger)
69
+ // - Click-outside → does NOT restore (correct: the user clicked deliberately)
70
+ // - hidePopover() → restores focus to the previously focused element
71
+ //
72
+ // However, for **nested** popover="auto" popovers, the browser only captures
73
+ // `previouslyFocusedElement` for the outermost popover in the auto stack.
74
+ // Inner popovers have `shouldRestoreFocus=false` per the spec, so the browser
75
+ // does not restore focus when they close.
76
+ //
77
+ // To handle this, we listen for the close transition via `onOpenChange` and
78
+ // restore focus to the trigger if the browser didn't. This runs after the
79
+ // browser's native restoration (which happens synchronously during hidePopover),
80
+ // so it only takes effect when the browser skipped restoration (nested case).
81
+ //
82
+ // See: notes/architecture/focus-restoration.md
83
+ var handleOpenChange = useCallback(function (args) {
84
+ // Sync compound state
85
+ setIsOpen === null || setIsOpen === void 0 || setIsOpen(args.isOpen);
86
+ consumerOnOpenChange === null || consumerOnOpenChange === void 0 || consumerOnOpenChange(args);
87
+
88
+ // ── Nested popover focus restoration fallback ──
89
+ // The browser only captures `previouslyFocusedElement` for the
90
+ // outermost popover="auto" in the stack. Inner (nested) popovers
91
+ // have shouldRestoreFocus=false, so the browser won't restore
92
+ // focus when they close.
93
+ //
94
+ // We detect this case by checking if focus is still inside the
95
+ // closing popover element. If it is, the browser didn't restore,
96
+ // and we need to move focus to the trigger ourselves.
97
+ //
98
+ // This does NOT fire for:
99
+ // - Outermost popovers (browser already restored to trigger)
100
+ // - Click-outside (focus is on the clicked element, not in popover)
101
+ if (!args.isOpen) {
102
+ var trigger = triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current;
103
+ var focusStillInPopover = trigger && args.element.contains(document.activeElement);
104
+ if (focusStillInPopover) {
105
+ var shouldRestore = role === 'dialog' || role === 'alertdialog' || role === 'menu' || role === 'listbox';
106
+ if (shouldRestore) {
107
+ trigger.focus({
108
+ preventScroll: true
109
+ });
110
+ }
111
+ }
112
+ }
113
+ }, [setIsOpen, consumerOnOpenChange, triggerRef, role]);
114
+
115
+ // ── Anchor positioning ──
116
+ // Compose useAnchorPosition with Popover. The hook positions the popover
117
+ // relative to the trigger element via CSS Anchor Positioning (with JS fallback).
118
+ // Use ctx.popoverRef when inside the compound (so the trigger can also
119
+ // reach the same DOM element for togglePopover). Otherwise use a local ref.
120
+ var localRef = useRef(null);
121
+ var popoverRef = (_ctx$popoverRef = ctx === null || ctx === void 0 ? void 0 : ctx.popoverRef) !== null && _ctx$popoverRef !== void 0 ? _ctx$popoverRef : localRef;
122
+ var arrowPreset = usePresetStyles({
123
+ preset: arrow
124
+ });
125
+ useAnchorPosition({
126
+ anchorRef: triggerRef !== null && triggerRef !== void 0 ? triggerRef : {
127
+ current: null
128
+ },
129
+ popoverRef: popoverRef,
130
+ placement: placement,
131
+ offset: offsetProp,
132
+ forceFallbackPositioning: forceFallbackPositioning,
133
+ arrow: arrowPreset !== null && arrowPreset !== void 0 ? arrowPreset : undefined
134
+ });
135
+
136
+ // ── Width: match trigger ──
137
+ // When width="trigger" or width="min-trigger", size the popover relative
138
+ // to the trigger element. Uses CSS `anchor-size(width)` when supported,
139
+ // falling back to a one-off measurement of the trigger's offsetWidth.
140
+ useLayoutEffect(function () {
141
+ if (width === 'content') {
142
+ return;
143
+ }
144
+ var node = popoverRef.current;
145
+ if (!node) {
146
+ return;
147
+ }
148
+ var cssProperty = width === 'trigger' ? 'width' : 'min-width';
149
+ var anchorValue = 'anchor-size(width)';
150
+
151
+ // Feature-detect `anchor-size()` specifically (not just `anchor-name`)
152
+ // so the JS fallback fires correctly in browsers that support anchor
153
+ // positioning but not anchor sizing.
154
+ var supportsAnchorSize = typeof CSS !== 'undefined' && typeof CSS.supports === 'function' && CSS.supports('width', 'anchor-size(width)');
155
+ if (supportsAnchorSize) {
156
+ node.style.setProperty(cssProperty, anchorValue);
157
+ } else {
158
+ // JS fallback: one-off read of the trigger's width.
159
+ var trigger = triggerRef === null || triggerRef === void 0 ? void 0 : triggerRef.current;
160
+ if (trigger) {
161
+ node.style.setProperty(cssProperty, "".concat(trigger.offsetWidth, "px"));
162
+ }
163
+ }
164
+ return function () {
165
+ node.style.removeProperty(cssProperty);
166
+ };
167
+ }, [width, popoverRef, triggerRef]);
168
+
169
+ // Merge: the popoverRef (shared with trigger + positioning) and the forwarded ref.
170
+ var combinedRef = mergeRefs([popoverRef, ref]);
171
+
172
+ // TPopupContentProps already validates the discriminated union (role + label,
173
+ // mode + onClose) at its API boundary. Popover accepts TPopoverInternalProps
174
+ // internally so individual prop forwarding doesn't need to re-prove the union.
175
+ var popoverProps = {
176
+ isOpen: isOpen,
177
+ animate: animate,
178
+ placement: placement,
179
+ mode: mode,
180
+ role: role,
181
+ label: label,
182
+ labelledBy: labelledBy,
183
+ onClose: onClose !== null && onClose !== void 0 ? onClose : undefined,
184
+ onOpenChange: handleOpenChange,
185
+ testId: testId,
186
+ children: children,
187
+ id: ctx === null || ctx === void 0 ? void 0 : ctx.popoverId
188
+ };
189
+ return /*#__PURE__*/React.createElement(Popover, _extends({
190
+ ref: combinedRef
191
+ }, popoverProps));
192
+ });
@@ -0,0 +1,34 @@
1
+ import { createContext, useContext } from 'react';
2
+ var PopupContext = /*#__PURE__*/createContext(null);
3
+
4
+ /**
5
+ * __Popup provider__
6
+ *
7
+ * Provides shared popup state (placement, popoverId, triggerRef,
8
+ * isOpen, onClose) to compound child components such as `Popup.Trigger` and
9
+ * `Popup.Content`.
10
+ */
11
+ export var PopupProvider = PopupContext.Provider;
12
+
13
+ /**
14
+ * Returns the nearest `Popup` context value.
15
+ *
16
+ * Throws if called outside of a `<Popup>` compound component.
17
+ */
18
+ export function usePopupContext() {
19
+ var ctx = useContext(PopupContext);
20
+ if (ctx === null) {
21
+ throw new Error('@atlaskit/top-layer: Popup compound components must be used within <Popup>.');
22
+ }
23
+ return ctx;
24
+ }
25
+
26
+ /**
27
+ * Returns the popup context if available, or `null` when used outside `<Popup>`.
28
+ *
29
+ * Used by `PopupContent` to support standalone usage (e.g. tooltip)
30
+ * where values are passed as props instead of coming from a compound component.
31
+ */
32
+ export function useMaybePopupContext() {
33
+ return useContext(PopupContext);
34
+ }
@@ -0,0 +1,5 @@
1
+
2
+ ._2rkofajl{border-radius:var(--ds-radius-small,3px)}._16qs130s{box-shadow:var(--ds-shadow-overlay,0 8px 9pt #1e1f2126,0 0 1px #1e1f214f)}
3
+ ._18m91wug{overflow-y:auto}
4
+ ._1reo1wug{overflow-x:auto}
5
+ ._bfhk1bhr{background-color:var(--ds-surface-overlay,#fff)}
@@ -0,0 +1,23 @@
1
+ /* popup-surface.tsx generated by @compiled/babel-plugin v0.39.1 */
2
+ import "./popup-surface.compiled.css";
3
+ import { ax, ix } from "@compiled/react/runtime";
4
+ import React from 'react';
5
+ var styles = {
6
+ root: "_2rkofajl _1reo1wug _18m91wug _bfhk1bhr _16qs130s"
7
+ };
8
+
9
+ /**
10
+ * Optional styled wrapper for popup content.
11
+ *
12
+ * Adds default visual styling (background, border-radius, box-shadow)
13
+ * using design tokens. Consumers who want fully custom styling
14
+ * should use `Popup.Content` without wrapping in `PopupSurface`.
15
+ *
16
+ * Exposed as `Popup.Surface` on the compound component.
17
+ */
18
+ export function PopupSurface(_ref) {
19
+ var children = _ref.children;
20
+ return /*#__PURE__*/React.createElement("div", {
21
+ className: ax([styles.root])
22
+ }, children);
23
+ }
@@ -0,0 +1,69 @@
1
+ import { useCallback, useMemo } from 'react';
2
+ import { usePopupContext } from './popup-context';
3
+
4
+ /**
5
+ * Props passed to the `TriggerFunction` render-prop child.
6
+ */
7
+
8
+ /**
9
+ * Render-prop alternative to `Popup.Trigger`.
10
+ *
11
+ * Use when you need full control over the trigger element — for example,
12
+ * to compose your own trigger with custom event handlers, wrap a third-party
13
+ * component, or build a trigger from multiple elements.
14
+ *
15
+ * `Popup.Trigger` uses `cloneElement` internally, which limits composability.
16
+ * `Popup.TriggerFunction` hands you the raw props and lets you wire them up.
17
+ *
18
+ * **Note:** This sub-component uses a render-prop pattern and is not
19
+ * compatible with React Server Components (RSC). It must be used inside
20
+ * a client component boundary (`'use client'`).
21
+ *
22
+ * @example
23
+ * ```tsx
24
+ * <Popup placement={{ edge: 'end' }} onClose={handleClose}>
25
+ * <Popup.TriggerFunction>
26
+ * {({ ref, toggle, ariaAttributes }) => (
27
+ * <button ref={ref} onClick={toggle} {...ariaAttributes}>
28
+ * Open
29
+ * </button>
30
+ * )}
31
+ * </Popup.TriggerFunction>
32
+ * <Popup.Content role="dialog" label="My popup">
33
+ * Content
34
+ * </Popup.Content>
35
+ * </Popup>
36
+ * ```
37
+ */
38
+ export function PopupTriggerFunction(_ref) {
39
+ var children = _ref.children;
40
+ var _usePopupContext = usePopupContext(),
41
+ triggerRef = _usePopupContext.triggerRef,
42
+ popoverRef = _usePopupContext.popoverRef,
43
+ popoverId = _usePopupContext.popoverId,
44
+ isOpen = _usePopupContext.isOpen,
45
+ ariaHasPopup = _usePopupContext.ariaHasPopup;
46
+ var ref = useCallback(function (node) {
47
+ triggerRef.current = node;
48
+ }, [triggerRef]);
49
+ var toggle = useCallback(function () {
50
+ var popoverEl = popoverRef.current;
51
+ if (popoverEl) {
52
+ popoverEl.togglePopover();
53
+ }
54
+ }, [popoverRef]);
55
+ var ariaAttributes = useMemo(function () {
56
+ return {
57
+ 'aria-expanded': isOpen,
58
+ 'aria-controls': popoverId,
59
+ 'aria-haspopup': ariaHasPopup
60
+ };
61
+ }, [isOpen, popoverId, ariaHasPopup]);
62
+ return children({
63
+ ref: ref,
64
+ isOpen: isOpen,
65
+ popoverId: popoverId,
66
+ toggle: toggle,
67
+ ariaAttributes: ariaAttributes
68
+ });
69
+ }
@@ -0,0 +1,74 @@
1
+ import React, { isValidElement, useCallback } from 'react';
2
+ import { Slot } from '../internal/slot';
3
+ import { usePopupContext } from './popup-context';
4
+ /**
5
+ * Wraps the trigger element. Attaches aria attributes and handles
6
+ * click to toggle the popover. Sets the anchor-name on the trigger
7
+ * for CSS Anchor Positioning.
8
+ *
9
+ * `aria-haspopup` is derived from the content's role via context
10
+ * (set by `Popup.Content`). This ensures the trigger always matches
11
+ * the content's semantic role without the consumer specifying it
12
+ * in two places.
13
+ *
14
+ * **Limitation:** Uses `cloneElement` internally (via `Slot`), which is
15
+ * incompatible with Compiled's `css` prop on the direct child element.
16
+ * The `@jsx jsx` pragma transforms the child before `cloneElement` can
17
+ * inject `onClick` and `ref` onto the DOM node, preventing the popover
18
+ * from opening.
19
+ *
20
+ * If you need Compiled `css` on the trigger, use `Popup.TriggerFunction`
21
+ * instead — it hands you raw props via a render-prop and avoids
22
+ * `cloneElement` entirely.
23
+ */
24
+ export function PopupTrigger(_ref) {
25
+ var children = _ref.children;
26
+ var _usePopupContext = usePopupContext(),
27
+ triggerRef = _usePopupContext.triggerRef,
28
+ popoverRef = _usePopupContext.popoverRef,
29
+ popoverId = _usePopupContext.popoverId,
30
+ isOpen = _usePopupContext.isOpen,
31
+ ariaHasPopup = _usePopupContext.ariaHasPopup;
32
+ var childOnClick = /*#__PURE__*/isValidElement(children) ? children.props.onClick : undefined;
33
+
34
+ // Use a ref to track the latest isOpen value so the click handler
35
+ // doesn't need isOpen in its dependency array (which would recreate
36
+ // the handler on every open/close, breaking cloneElement identity).
37
+ var isOpenRef = React.useRef(isOpen);
38
+ isOpenRef.current = isOpen;
39
+ var handleClick = useCallback(function (event) {
40
+ var popoverEl = popoverRef.current;
41
+ if (popoverEl) {
42
+ // For popover="auto", clicking the trigger (which is outside
43
+ // the popover) can cause the browser's built-in light-dismiss
44
+ // to fire before our click handler runs. This means by the time
45
+ // we get here, the DOM may have already closed the popover.
46
+ //
47
+ // We use React's `isOpen` state (via ref) rather than the DOM
48
+ // state to determine intent:
49
+ // - If React thinks it was open → the user wants to close.
50
+ // The browser already did this via light-dismiss, so do nothing.
51
+ // - If React thinks it was closed → the user wants to open.
52
+ // Call showPopover().
53
+ if (!isOpenRef.current) {
54
+ try {
55
+ popoverEl.showPopover();
56
+ } catch (_unused) {
57
+ // Already showing — safe to ignore.
58
+ }
59
+ }
60
+ // When isOpenRef.current is true, the browser's light-dismiss
61
+ // already closed the popover and fired the toggle event, which
62
+ // will update React state via handleToggle → setIsOpen(false).
63
+ // No action needed here.
64
+ }
65
+ childOnClick === null || childOnClick === void 0 || childOnClick(event);
66
+ }, [popoverRef, childOnClick]);
67
+ return /*#__PURE__*/React.createElement(Slot, {
68
+ ref: triggerRef,
69
+ onClick: handleClick,
70
+ "aria-expanded": isOpen,
71
+ "aria-controls": popoverId,
72
+ "aria-haspopup": ariaHasPopup
73
+ }, children);
74
+ }
@@ -0,0 +1,61 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
+ import React, { useCallback, useId, useRef, useState } from 'react';
3
+ import { PopupProvider } from './popup-context';
4
+ /**
5
+ * Popup compound — trigger + popover content.
6
+ *
7
+ * Use when a button opens anchored content (dropdown, menu, dialog).
8
+ * The browser manages visibility via `togglePopover()` — the consumer
9
+ * never manages `isOpen`. For custom trigger lifecycles (hover, timers,
10
+ * external state), use `Popover` directly instead.
11
+ *
12
+ * Provides context (triggerRef, placement, isOpen, onClose, mode) that
13
+ * `Popup.Content` reads and forwards to the underlying `Popover`.
14
+ */
15
+ export function PopupRoot(props) {
16
+ var _props$mode;
17
+ var placement = props.placement,
18
+ children = props.children,
19
+ testId = props.testId,
20
+ forceFallbackPositioning = props.forceFallbackPositioning,
21
+ onOpenChange = props.onOpenChange;
22
+ var mode = (_props$mode = props.mode) !== null && _props$mode !== void 0 ? _props$mode : 'auto';
23
+ var onClose = mode === 'manual' ? null : props.onClose;
24
+ var id = useId();
25
+ // Regex is intentional — `replaceAll` is not available in our supported
26
+ // browser matrix. `useId()` returns IDs containing colons (e.g. `:r1:`)
27
+ // which are invalid in CSS selectors and `popover` target attributes.
28
+ var sanitizedId = id.replace(/:/g, '');
29
+ var popoverId = "popover-".concat(sanitizedId);
30
+ var triggerRef = useRef(null);
31
+ var popoverRef = useRef(null);
32
+ var _useState = useState(false),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ isOpen = _useState2[0],
35
+ setIsOpen = _useState2[1];
36
+ var _useState3 = useState('dialog'),
37
+ _useState4 = _slicedToArray(_useState3, 2),
38
+ ariaHasPopup = _useState4[0],
39
+ setAriaHasPopup = _useState4[1];
40
+ var handleClose = useCallback(function (args) {
41
+ onClose === null || onClose === void 0 || onClose(args);
42
+ }, [onClose]);
43
+ var contextValue = {
44
+ popoverId: popoverId,
45
+ placement: placement,
46
+ onClose: mode === 'manual' ? null : handleClose,
47
+ triggerRef: triggerRef,
48
+ popoverRef: popoverRef,
49
+ isOpen: isOpen,
50
+ setIsOpen: setIsOpen,
51
+ onOpenChange: onOpenChange,
52
+ mode: mode,
53
+ ariaHasPopup: ariaHasPopup,
54
+ setAriaHasPopup: setAriaHasPopup,
55
+ testId: testId,
56
+ forceFallbackPositioning: forceFallbackPositioning
57
+ };
58
+ return /*#__PURE__*/React.createElement(PopupProvider, {
59
+ value: contextValue
60
+ }, children);
61
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export { useArrowNavigation, isAtCurrentMenuLevel } from './use-arrow-navigation';