@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,289 @@
1
+ import { type ReactElement, type ReactNode, type Ref, type RefObject } from 'react';
2
+ import { type TAnimationPreset } from '../animations/types';
3
+ import { type TArrowPreset } from '../arrow/types';
4
+ import { type TPlacement } from '../internal/resolve-placement';
5
+ import { type TRoleRequiringAccessibleName, type TRoleWithImplicitName } from '../internal/role-types';
6
+ import { type TPopoverCloseReason } from '../popover/types';
7
+ /**
8
+ * Describes where to position a popover relative to its trigger.
9
+ *
10
+ * - `axis` — which axis the popover appears along (`'block'` = above/below, `'inline'` = left/right).
11
+ * Defaults to `'block'`.
12
+ * - `edge` — which end of the axis (`'start'` = above/left in LTR, `'end'` = below/right in LTR).
13
+ * Defaults to `'end'`.
14
+ * - `align` — where to align on the cross-axis (`'start'`, `'center'`, `'end'`).
15
+ * Defaults to `'center'`. Can be written explicitly for clarity.
16
+ *
17
+ * All fields are optional. The default `{}` means "below the trigger, centered"
18
+ * (equivalent to Popper.js `'bottom'`).
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * // Below trigger, centered (all defaults)
23
+ * placement={{}}
24
+ * placement={{ axis: 'block', edge: 'end', align: 'center' }}
25
+ *
26
+ * // Below trigger, aligned to the start (left in LTR)
27
+ * placement={{ align: 'start' }}
28
+ *
29
+ * // Above trigger, aligned to the end (right in LTR)
30
+ * placement={{ edge: 'start', align: 'end' }}
31
+ *
32
+ * // Right of trigger, centered
33
+ * placement={{ axis: 'inline' }}
34
+ * ```
35
+ */
36
+ export type TPlacementOptions = Partial<TPlacement>;
37
+ export type TPopupProps = {
38
+ /**
39
+ * Position of the popup relative to the trigger. Only the Popup compound uses
40
+ * placement; the low-level Popover primitive does not.
41
+ */
42
+ placement: TPlacementOptions;
43
+ /**
44
+ * Must contain `Popup.Trigger` and `Popup.Content`.
45
+ */
46
+ children: ReactNode;
47
+ /**
48
+ * Called when the popup is dismissed via light dismiss.
49
+ *
50
+ * The `reason` field indicates how the dismiss occurred:
51
+ * - `'escape'`: the user pressed the Escape key.
52
+ * - `'light-dismiss'`: the user clicked outside (or another auto-dismiss).
53
+ */
54
+ onClose: (args: {
55
+ reason: TPopoverCloseReason;
56
+ }) => void;
57
+ /**
58
+ * Called when the popup's open state changes.
59
+ *
60
+ * Receives the new open state and a reference to the popover element,
61
+ * which is useful for focus management (e.g. focusing the first interactive
62
+ * child on open via `getFirstFocusable` from `@atlaskit/top-layer/focus`).
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * <Popup
67
+ * onOpenChange={({ isOpen, element }) => {
68
+ * if (isOpen) {
69
+ * getFirstFocusable({ container: element })?.focus();
70
+ * }
71
+ * }}
72
+ * />
73
+ * ```
74
+ */
75
+ onOpenChange?: (args: {
76
+ isOpen: boolean;
77
+ element: HTMLDivElement;
78
+ }) => void;
79
+ /**
80
+ * Native popover attribute value. Default is `'auto'`.
81
+ *
82
+ * - `'auto'`: light dismiss (Escape, click-outside). Only one `popover="auto"` can be open at a time; opening another closes the previous.
83
+ * - `'hint'`: allows ephemeral UI (e.g. tooltips) to open without closing other `popover="auto"` popovers. Falls back to `popover="auto"` when unsupported.
84
+ * - `'manual'`: no light dismiss; the consumer controls show/hide entirely. Escape and click-outside do not close the popover.
85
+ */
86
+ mode?: 'auto' | 'hint' | 'manual';
87
+ /**
88
+ * Test ID applied to the popup content element.
89
+ */
90
+ testId?: string;
91
+ /**
92
+ * Forces the JavaScript positioning fallback even when the browser
93
+ * supports CSS Anchor Positioning. Useful for testing fallback
94
+ * behavior in any environment, including production.
95
+ */
96
+ forceFallbackPositioning?: boolean;
97
+ };
98
+ export type TPopupTriggerProps = {
99
+ /**
100
+ * The trigger element. Must accept a ref.
101
+ */
102
+ children: ReactElement;
103
+ };
104
+ /**
105
+ * All ARIA roles supported for popover content.
106
+ * Add new roles to the appropriate category in `internal/role-types.tsx` as needed.
107
+ */
108
+ export type TPopupRole = TRoleRequiringAccessibleName | TRoleWithImplicitName;
109
+ /**
110
+ * Props shared across all popover role variants.
111
+ *
112
+ * When inside the `<Popup>` compound component, `isOpen` is provided automatically
113
+ * via context (the browser manages visibility through `togglePopover()`).
114
+ *
115
+ * When used standalone (e.g. tooltip, spotlight), the consumer must provide `isOpen`
116
+ * to control visibility. If `animate` is provided, `isOpen` is required at the type
117
+ * level — this ensures exit animations always have a controlled lifecycle.
118
+ */
119
+ type TPopupContentBaseProps = {
120
+ children: ReactNode;
121
+ /**
122
+ * Ref to the underlying `<div popover>` element.
123
+ */
124
+ ref?: Ref<HTMLDivElement>;
125
+ /**
126
+ * Controls the width of the popover.
127
+ *
128
+ * - `'content'` (default): popover sizes to its content.
129
+ * - `'trigger'`: popover matches the trigger element's width exactly
130
+ * via CSS `anchor-size(width)`. Falls back to a one-off measurement
131
+ * of `triggerRef.current.offsetWidth` when CSS Anchor Positioning
132
+ * is not supported.
133
+ * - `'min-trigger'`: popover is at least as wide as the trigger, but
134
+ * can grow wider if content requires it. Uses `min-width: anchor-size(width)`.
135
+ * Falls back to a one-off measurement of the trigger's width.
136
+ */
137
+ width?: 'content' | 'trigger' | 'min-trigger';
138
+ /**
139
+ * Ref to the trigger element for anchor positioning.
140
+ * When absent, anchor positioning is skipped (consumer handles positioning).
141
+ */
142
+ triggerRef?: RefObject<HTMLElement | null>;
143
+ /**
144
+ * Position of the popover relative to the trigger.
145
+ */
146
+ placement?: TPlacementOptions;
147
+ /**
148
+ * Called when the popover is dismissed via light dismiss (Escape, click outside).
149
+ * When an animation preset is provided, `onClose` is called after the exit
150
+ * animation completes.
151
+ *
152
+ * The `reason` field indicates how the dismiss occurred:
153
+ * - `'escape'`: the user pressed the Escape key.
154
+ * - `'light-dismiss'`: the user clicked outside (or another auto-dismiss).
155
+ */
156
+ onClose?: (args: {
157
+ reason: TPopoverCloseReason;
158
+ }) => void;
159
+ /**
160
+ * Test ID applied to the popover content element.
161
+ */
162
+ testId?: string;
163
+ /**
164
+ * Gap between the popover and its trigger, in pixels.
165
+ * Defaults to 8 (design token `space.100`). Tooltip uses 4.
166
+ */
167
+ offset?: number;
168
+ /**
169
+ * Forces the JavaScript positioning fallback even when the browser
170
+ * supports CSS Anchor Positioning. Useful for testing fallback
171
+ * behavior in any environment, including production.
172
+ */
173
+ forceFallbackPositioning?: boolean;
174
+ /**
175
+ * Arrow preset from `@atlaskit/top-layer/arrow`.
176
+ *
177
+ * When provided, renders CSS arrows that automatically flip when the
178
+ * popover flips via `@position-try` fallbacks. The arrows inherit
179
+ * their background color from the popover element.
180
+ *
181
+ * @example
182
+ * ```tsx
183
+ * import { arrow } from '@atlaskit/top-layer/arrow';
184
+ *
185
+ * const myArrow = arrow();
186
+ * <Popup.Content arrow={myArrow} />
187
+ * ```
188
+ *
189
+ * Constraints:
190
+ * - `box-shadow` is disabled on the popover (incompatible with the
191
+ * `clip-path: inset() margin-box` technique)
192
+ * - `::before` and `::after` pseudo-elements are consumed by the arrows
193
+ * - Only works with CSS Anchor Positioning; no arrow in the JS fallback
194
+ */
195
+ arrow?: false | TArrowPreset;
196
+ /**
197
+ * Native popover attribute value. Default is `'auto'`.
198
+ *
199
+ * - `'auto'`: light dismiss (Escape, click-outside). Only one `popover="auto"` can be open at a time; opening another closes the previous.
200
+ * - `'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.
201
+ * - `'manual'`: no light dismiss; the consumer controls show/hide entirely (e.g. Flag). Escape and click-outside do not close the popover.
202
+ */
203
+ mode?: 'auto' | 'hint' | 'manual';
204
+ /**
205
+ * Animation preset for entry/exit transitions.
206
+ *
207
+ * - `TAnimationPreset`: a preset object (e.g. from `@atlaskit/top-layer/animations`).
208
+ * Entry animation plays via `@starting-style`, exit via `allow-discrete`.
209
+ * - `undefined` / `false`: no animation.
210
+ *
211
+ * When used standalone (outside `<Popup>` compound), pair with `isOpen` for exit
212
+ * animations to work correctly. Inside the compound, `isOpen` is provided via context.
213
+ *
214
+ * Animations use `@starting-style` and `allow-discrete` for progressive
215
+ * enhancement: browsers without support show/hide instantly.
216
+ */
217
+ animate?: false | TAnimationPreset;
218
+ /**
219
+ * Whether the popover is open.
220
+ *
221
+ * Controls `showPopover()` / `hidePopover()` on the underlying element.
222
+ * Inside the `<Popup>` compound, `isOpen` is provided automatically via context
223
+ * (the browser manages state through `togglePopover()`).
224
+ *
225
+ * For standalone usage, provide `isOpen` to control visibility — especially
226
+ * when `animate` is set, so the exit animation lifecycle works correctly.
227
+ *
228
+ * @example
229
+ * ```tsx
230
+ * <Popup.Content
231
+ * role="tooltip"
232
+ * isOpen={isVisible}
233
+ * animate={slideAndFade()}
234
+ * >
235
+ * Tooltip content
236
+ * </Popup.Content>
237
+ * ```
238
+ */
239
+ isOpen?: boolean;
240
+ };
241
+ /**
242
+ * Popup content props.
243
+ *
244
+ * Roles like `'dialog'`, `'alertdialog'`, and `'menu'` require an accessible
245
+ * name. Provide either `label` (aria-label) or `labelledBy` (aria-labelledby).
246
+ * TypeScript enforces this at compile time.
247
+ */
248
+ export type TPopupContentProps = TPopupContentBaseProps & (({
249
+ /**
250
+ * ARIA role for the popover. Roles that are ARIA landmarks (`dialog`,
251
+ * `alertdialog`, `menu`) require an accessible name.
252
+ */
253
+ role: TRoleRequiringAccessibleName;
254
+ } & ({
255
+ /**
256
+ * Accessible name via `aria-label`.
257
+ */
258
+ label: string;
259
+ /**
260
+ * Accessible name via `aria-labelledby`.
261
+ */
262
+ labelledBy?: string;
263
+ } | {
264
+ /**
265
+ * Accessible name via `aria-label`.
266
+ */
267
+ label?: string;
268
+ /**
269
+ * Accessible name via `aria-labelledby`.
270
+ */
271
+ labelledBy: string;
272
+ })) | {
273
+ /**
274
+ * ARIA role for the popover.
275
+ */
276
+ role: TRoleWithImplicitName;
277
+ /**
278
+ * Accessible name via `aria-label`.
279
+ */
280
+ label?: string;
281
+ /**
282
+ * Accessible name via `aria-labelledby`.
283
+ */
284
+ labelledBy?: string;
285
+ });
286
+ export type TPopupSurfaceProps = {
287
+ children: ReactNode;
288
+ };
289
+ export {};
@@ -0,0 +1,2 @@
1
+ export { useArrowNavigation, isAtCurrentMenuLevel } from './use-arrow-navigation';
2
+ export type { TUseArrowNavigationArgs } from './use-arrow-navigation';
@@ -0,0 +1,136 @@
1
+ import { type RefObject } from 'react';
2
+ import { type TFocusableFilter } from '../focus';
3
+ /**
4
+ * Returns true if the element belongs to the current menu level of the
5
+ * container — i.e. it is NOT inside a nested `role="menu"` sub-container.
6
+ *
7
+ * Uses `element.closest('[role="menu"]')` to determine the nearest menu
8
+ * scope. If the nearest scope is the container's own `role="menu"` element,
9
+ * the element belongs to this level. If it's a different (nested) menu,
10
+ * the element belongs to a child level and should be excluded.
11
+ *
12
+ * Supports two container patterns:
13
+ *
14
+ * **1. Container has `role="menu"` directly** (preferred — used by avatar-group):
15
+ * ```
16
+ * <div ref={containerRef} role="menu">
17
+ * <button role="menuitem" /> ← isAtCurrentMenuLevel → true
18
+ * <div role="menu"> ← nested sub-menu
19
+ * <button role="menuitem" /> ← isAtCurrentMenuLevel → false
20
+ * </div>
21
+ * </div>
22
+ * ```
23
+ * Uses the simple check: `element.closest('[role="menu"]') === container`
24
+ *
25
+ * **2. Container is a wrapper without `role="menu"`** (used by dropdown-menu,
26
+ * where `MenuGroup` owns `role="menu"` but doesn't accept a ref):
27
+ * ```
28
+ * <div ref={containerRef}> ← wrapper (no role="menu")
29
+ * <MenuGroup role="menu">
30
+ * <button role="menuitem" /> ← isAtCurrentMenuLevel → true
31
+ * <div role="menu"> ← nested sub-menu
32
+ * <button role="menuitem" /> ← isAtCurrentMenuLevel → false
33
+ * </div>
34
+ * </MenuGroup>
35
+ * </div>
36
+ * ```
37
+ * Falls back to walking the DOM to check that the element's closest
38
+ * `role="menu"` is the container's own menu (not doubly nested).
39
+ *
40
+ * Ideally all consumers should use pattern 1 (place the ref directly on the
41
+ * `role="menu"` element). Pattern 2 exists because `@atlaskit/menu`'s
42
+ * `MenuGroup` does not currently accept a ref. If `MenuGroup` gains ref
43
+ * support in the future, dropdown-menu should switch to pattern 1 and the
44
+ * fallback path can be removed.
45
+ *
46
+ * Used both as a `TFocusableFilter` (to scope getNextFocusable etc.) and as
47
+ * a guard to prevent parent menu handlers from acting on events that
48
+ * belong to a nested menu.
49
+ */
50
+ export declare function isAtCurrentMenuLevel(element: Element, container: HTMLElement): boolean;
51
+ export type TUseArrowNavigationArgs = {
52
+ /**
53
+ * Ref to the container element that holds the focusable items.
54
+ */
55
+ containerRef: RefObject<HTMLElement | null>;
56
+ /**
57
+ * Called when ArrowRight is pressed on a focused element with `aria-haspopup`.
58
+ *
59
+ * This follows the WAI-ARIA menu pattern: ArrowRight on a menu item that
60
+ * controls a submenu should open that submenu. The consumer decides *how*
61
+ * to open it (e.g. `trigger.click()`, imperative state update, etc.).
62
+ *
63
+ * Only fires when `filter` (if provided) confirms the focused element
64
+ * belongs to the current menu level.
65
+ */
66
+ onNestedOpen?: ({ trigger }: {
67
+ trigger: HTMLElement;
68
+ }) => void;
69
+ /**
70
+ * Called when ArrowLeft is pressed and the current menu is nested
71
+ * (i.e. the container is inside another `role="menu"`).
72
+ *
73
+ * This follows the WAI-ARIA menu pattern: ArrowLeft in a submenu
74
+ * should close it and return to the parent menu. The consumer
75
+ * decides *how* to close (e.g. calling their close handler).
76
+ */
77
+ onNestedClose?: () => void;
78
+ /**
79
+ * Called when the user presses Tab to exit the menu.
80
+ */
81
+ onClose: () => void;
82
+ /**
83
+ * When false, the keydown listener is not attached.
84
+ * Defaults to true.
85
+ */
86
+ isEnabled?: boolean;
87
+ /**
88
+ * Optional filter to restrict which focusable elements are navigated.
89
+ * When provided, only elements that pass the filter will be focused.
90
+ *
91
+ * The filter is also used as a guard on the currently focused element:
92
+ * if the focused element doesn't pass the filter, the handler bails out.
93
+ * This prevents parent menu handlers from acting on events that belong
94
+ * to a nested menu.
95
+ *
96
+ * A common filter is `isAtCurrentMenuLevel` which excludes items inside
97
+ * nested `role="menu"` sub-containers.
98
+ */
99
+ filter?: TFocusableFilter;
100
+ };
101
+ /**
102
+ * Provides arrow key navigation for menu containers.
103
+ *
104
+ * Uses the focusable helpers from `@atlaskit/top-layer/focus` to manage
105
+ * DOM-based focus movement within a container.
106
+ *
107
+ * - **ArrowDown / ArrowUp**: Move focus to the next/previous item (wraps).
108
+ * - **Home / End**: Move focus to the first/last item.
109
+ * - **Tab**: Calls `onClose` to exit the menu.
110
+ *
111
+ * When a `filter` is provided, it is used both for scoping focusable
112
+ * elements and as a guard to prevent parent menu handlers from acting
113
+ * on events that belong to a nested menu.
114
+ *
115
+ * @example Basic usage
116
+ * ```tsx
117
+ * useArrowNavigation({
118
+ * containerRef: menuRef,
119
+ * onClose: () => setIsOpen(false),
120
+ * isEnabled: isOpen,
121
+ * });
122
+ * ```
123
+ *
124
+ * @example With nested menu filter
125
+ * ```tsx
126
+ * import { useArrowNavigation, isAtCurrentMenuLevel } from '@atlaskit/top-layer/use-arrow-navigation';
127
+ *
128
+ * useArrowNavigation({
129
+ * containerRef: menuRef,
130
+ * onClose: () => setIsOpen(false),
131
+ * isEnabled: isOpen,
132
+ * filter: isAtCurrentMenuLevel,
133
+ * });
134
+ * ```
135
+ */
136
+ export declare function useArrowNavigation({ containerRef, onClose, onNestedOpen, onNestedClose, isEnabled, filter, }: TUseArrowNavigationArgs): void;
@@ -0,0 +1,45 @@
1
+ import { type RefObject } from 'react';
2
+ import { type TPopoverCloseReason } from '../popover/types';
3
+ type TUseSimpleLightDismissOptions = {
4
+ /**
5
+ * Ref to the popover element. Clicks inside this element will not trigger dismiss.
6
+ */
7
+ popoverRef: RefObject<HTMLElement | null>;
8
+ /**
9
+ * Whether the popover is currently open.
10
+ * Listeners are only bound when `isOpen` is `true`.
11
+ */
12
+ isOpen: boolean;
13
+ /**
14
+ * Called when a light-dismiss event occurs.
15
+ *
16
+ * - `reason: 'escape'` — the user pressed the Escape key.
17
+ * - `reason: 'light-dismiss'` — the user clicked outside the popover.
18
+ *
19
+ * **Note:** This hook provides simple, standalone light dismiss that does not
20
+ * participate in the browser's `popover="auto"` dismiss stack. Every active
21
+ * instance will fire independently — if multiple popovers use this hook,
22
+ * they will all receive dismiss events.
23
+ */
24
+ onClose: (args: {
25
+ reason: TPopoverCloseReason;
26
+ }) => void;
27
+ };
28
+ /**
29
+ * Simple light-dismiss hook for `popover="manual"` elements.
30
+ *
31
+ * Provides Escape-to-close and click-outside-to-close behavior without
32
+ * relying on the browser's `popover="auto"` light-dismiss stack.
33
+ *
34
+ * **No stacking awareness:** This hook does not track a popover stack.
35
+ * If multiple manual popovers are open and all use this hook, a single
36
+ * Escape press or outside click will dismiss **all of them simultaneously**.
37
+ * This is by design — the hook is intentionally simple for cases where
38
+ * only one manual popover is open at a time.
39
+ *
40
+ * For stacked/nested popovers that should dismiss one-at-a-time, use
41
+ * `popover="auto"` mode instead, which provides native stack-aware
42
+ * light dismiss via the browser's top-layer stack.
43
+ */
44
+ export declare function useSimpleLightDismiss({ popoverRef, isOpen, onClose, }: TUseSimpleLightDismissOptions): void;
45
+ export type { TUseSimpleLightDismissOptions };
@@ -0,0 +1,94 @@
1
+ import { type TAnimationPreset } from './types';
2
+ type TSlideAndFadeOptions = {
3
+ /**
4
+ * Slide distance in pixels. Defaults to `4`.
5
+ */
6
+ distance?: number;
7
+ };
8
+ /**
9
+ * Directional slide + opacity animation.
10
+ *
11
+ * The popover slides in from the direction opposite its placement edge
12
+ * (e.g. a `block-end` popover slides down from above).
13
+ *
14
+ * @param options.distance - Slide distance in pixels. Defaults to `4`.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * import { slideAndFade } from '@atlaskit/top-layer/animations';
19
+ *
20
+ * // Default 4px slide (tooltip)
21
+ * <Popup.Content animate={slideAndFade()} />
22
+ *
23
+ * // Custom 8px slide (popup / dropdown)
24
+ * <Popup.Content animate={slideAndFade({ distance: 8 })} />
25
+ * ```
26
+ */
27
+ export declare function slideAndFade(options?: TSlideAndFadeOptions): TAnimationPreset;
28
+ /**
29
+ * Simple opacity transition, no transform.
30
+ *
31
+ * Suitable for popup dialogs or content that does not need directional motion.
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * import { fade } from '@atlaskit/top-layer/animations';
36
+ *
37
+ * <Popup.Content animate={fade()} />
38
+ * ```
39
+ */
40
+ export declare function fade(): TAnimationPreset;
41
+ /**
42
+ * Scale from 0.95 + opacity transition.
43
+ *
44
+ * Suitable for menus, dropdowns, and select options.
45
+ *
46
+ * @example
47
+ * ```tsx
48
+ * import { scaleAndFade } from '@atlaskit/top-layer/animations';
49
+ *
50
+ * <Popup.Content animate={scaleAndFade()} />
51
+ * ```
52
+ */
53
+ export declare function scaleAndFade(): TAnimationPreset;
54
+ type TDialogSlideUpAndFadeOptions = {
55
+ /**
56
+ * Slide distance in pixels. Defaults to `12`.
57
+ */
58
+ distance?: number;
59
+ };
60
+ /**
61
+ * Slide up + opacity animation for dialogs.
62
+ *
63
+ * Entry slides up from below; exit slides up and out (asymmetric).
64
+ * Includes backdrop fade animation.
65
+ *
66
+ * @param options.distance - Slide distance in pixels. Defaults to `12`.
67
+ *
68
+ * @example
69
+ * ```tsx
70
+ * import { dialogSlideUpAndFade } from '@atlaskit/top-layer/animations';
71
+ *
72
+ * const animation = dialogSlideUpAndFade();
73
+ * <Dialog animate={animation} isOpen={isOpen} onClose={handleClose} label="...">
74
+ * ...
75
+ * </Dialog>
76
+ * ```
77
+ */
78
+ export declare function dialogSlideUpAndFade(options?: TDialogSlideUpAndFadeOptions): TAnimationPreset;
79
+ /**
80
+ * Simple opacity transition for dialogs, no transform.
81
+ *
82
+ * Includes backdrop fade animation.
83
+ *
84
+ * @example
85
+ * ```tsx
86
+ * import { dialogFade } from '@atlaskit/top-layer/animations';
87
+ *
88
+ * <Dialog animate={dialogFade()} isOpen={isOpen} onClose={handleClose} label="...">
89
+ * ...
90
+ * </Dialog>
91
+ * ```
92
+ */
93
+ export declare function dialogFade(): TAnimationPreset;
94
+ export {};
@@ -0,0 +1,42 @@
1
+ import { type TPlacementOptions } from '../popup/types';
2
+ /**
3
+ * A self-contained animation preset for top-layer elements (popovers and dialogs).
4
+ *
5
+ * Contains the CSS rules (injected once into `<head>`), a data-attribute name
6
+ * for CSS targeting, optional per-placement custom properties, and the exit
7
+ * duration used for a `transitionend` fallback timeout.
8
+ *
9
+ * Entry animation uses `@starting-style`.
10
+ * Exit animation uses `allow-discrete` on `display`/`overlay` to keep the
11
+ * element visible in the top layer while CSS transitions play.
12
+ */
13
+ export type TAnimationPreset = {
14
+ /**
15
+ * CSS to inject once into `document.head`, scoped via a data attribute
16
+ * (e.g. `[data-ds-popover-{name}]` or `[data-ds-dialog-{name}]`).
17
+ */
18
+ css: string;
19
+ /**
20
+ * Data attribute suffix for CSS targeting (e.g. `'slide-and-fade'`).
21
+ */
22
+ name: string;
23
+ /**
24
+ * Per-placement CSS custom properties (e.g. directional offset for
25
+ * `slideAndFade`). Only used by popover presets that vary by placement.
26
+ */
27
+ getProperties?: (args: {
28
+ placement: TPlacementOptions;
29
+ }) => Record<string, string>;
30
+ /**
31
+ * Exit duration in ms (for `transitionend` fallback timeout).
32
+ */
33
+ exitDurationMs: number;
34
+ };
35
+ /**
36
+ * @deprecated Use `TAnimationPreset` instead.
37
+ */
38
+ export type TPopoverAnimationPreset = TAnimationPreset;
39
+ /**
40
+ * @deprecated Use `TAnimationPreset` instead.
41
+ */
42
+ export type TDialogAnimationPreset = TAnimationPreset;
@@ -0,0 +1,24 @@
1
+ import { type TArrowPreset } from './types';
2
+ /**
3
+ * Creates an arrow preset for popover content.
4
+ *
5
+ * The returned object is passed to `PopoverContent`'s `arrow` prop.
6
+ * It carries the CSS string and fallback logic so that consumers who
7
+ * don't use arrows pay no bundle cost.
8
+ *
9
+ * The arrows inherit their background from the popover element.
10
+ * When `arrow` is active, `PopoverContent` does not reset `background`
11
+ * to `transparent`, allowing the UA default (`canvas`) or a consumer-set
12
+ * background to show through.
13
+ *
14
+ * @example
15
+ * ```tsx
16
+ * import { arrow } from '@atlaskit/top-layer/arrow';
17
+ *
18
+ * const myArrow = arrow();
19
+ *
20
+ * <Popup.Content arrow={myArrow} />
21
+ * ```
22
+ */
23
+ export declare const arrow: () => TArrowPreset;
24
+ export type { TArrowPreset } from './types';
@@ -0,0 +1,29 @@
1
+ import { type TPlacementOptions } from '../popup/types';
2
+ /**
3
+ * A self-contained arrow preset for PopoverContent.
4
+ *
5
+ * Contains the CSS rules (injected once into `<head>`), a data-attribute name
6
+ * for CSS targeting, and a function to compute `position-try-fallbacks` values
7
+ * that change both `position-area` and `margin` when the popover flips.
8
+ *
9
+ * Imported from `@atlaskit/top-layer/arrow` so that consumers who don't use
10
+ * arrows pay no bundle cost for the CSS string or fallback logic.
11
+ */
12
+ export type TArrowPreset = {
13
+ /**
14
+ * CSS to inject once into `document.head`, scoped to `[data-ds-popover-{name}]`.
15
+ */
16
+ css: string;
17
+ /**
18
+ * Data attribute suffix for CSS targeting (e.g. `'arrow'`).
19
+ */
20
+ name: string;
21
+ /**
22
+ * Returns the `position-try-fallbacks` value for a given placement.
23
+ * Uses named `@position-try` rules that update both `position-area`
24
+ * and `margin` so the correct arrow is revealed after a flip.
25
+ */
26
+ getTryFallbacks: (args: {
27
+ placement: TPlacementOptions;
28
+ }) => string;
29
+ };
@@ -0,0 +1,24 @@
1
+ import { type TDialogCloseReason } from './types';
2
+ /**
3
+ * Creates a synthetic DOM event from a `TDialogCloseReason`.
4
+ *
5
+ * Useful when bridging the Dialog primitive's `onClose({ reason })` callback
6
+ * to a legacy API that expects a `KeyboardEvent` or `MouseEvent` — for example,
7
+ * `@atlaskit/modal-dialog`'s `onClose(event, analyticsEvent)` contract.
8
+ *
9
+ * - `'escape'` → `KeyboardEvent('keydown', { key: 'Escape' })`
10
+ * - `'overlay-click'` → `MouseEvent('click')`
11
+ *
12
+ * @example
13
+ * ```tsx
14
+ * import { createCloseEvent } from '@atlaskit/top-layer/create-close-event';
15
+ * import { type TDialogCloseReason } from '@atlaskit/top-layer/dialog';
16
+ *
17
+ * function onDialogClose({ reason }: { reason: TDialogCloseReason }) {
18
+ * legacyOnClose(createCloseEvent({ reason }));
19
+ * }
20
+ * ```
21
+ */
22
+ export declare function createCloseEvent({ reason, }: {
23
+ reason: TDialogCloseReason;
24
+ }): KeyboardEvent | MouseEvent;