@atlaskit/top-layer 0.12.1 → 0.12.2

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 (90) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/animations/presets.js +5 -5
  3. package/dist/cjs/dialog/create-close-event.js +1 -1
  4. package/dist/cjs/dialog/dialog-content.js +5 -5
  5. package/dist/cjs/internal/ensure-preset-styles.js +1 -1
  6. package/dist/cjs/internal/reduced-motion.js +1 -1
  7. package/dist/cjs/internal/resolve-placement.js +2 -2
  8. package/dist/cjs/internal/role-types.js +1 -1
  9. package/dist/cjs/internal/slot.js +3 -3
  10. package/dist/cjs/internal/use-anchor-position.js +15 -30
  11. package/dist/cjs/internal/use-animated-visibility.js +10 -10
  12. package/dist/cjs/internal/use-animation-preset.js +1 -1
  13. package/dist/cjs/internal/use-preset-styles.js +1 -1
  14. package/dist/cjs/internal/use-width-from-anchor.js +4 -4
  15. package/dist/cjs/popover/create-close-event.js +1 -1
  16. package/dist/cjs/popover/popover.js +3 -3
  17. package/dist/cjs/popup/popup-content.js +4 -4
  18. package/dist/cjs/testing/polyfill.js +8 -8
  19. package/dist/cjs/testing/to-be-visible.js +5 -5
  20. package/dist/cjs/use-arrow-navigation/is-at-current-menu-level.js +19 -12
  21. package/dist/cjs/use-simple-light-dismiss/index.js +3 -3
  22. package/dist/es2019/animations/presets.js +5 -5
  23. package/dist/es2019/dialog/create-close-event.js +1 -1
  24. package/dist/es2019/dialog/dialog-content.js +5 -5
  25. package/dist/es2019/internal/ensure-preset-styles.js +1 -1
  26. package/dist/es2019/internal/reduced-motion.js +1 -1
  27. package/dist/es2019/internal/resolve-placement.js +2 -2
  28. package/dist/es2019/internal/role-types.js +1 -1
  29. package/dist/es2019/internal/slot.js +3 -3
  30. package/dist/es2019/internal/use-anchor-position.js +13 -16
  31. package/dist/es2019/internal/use-animated-visibility.js +10 -10
  32. package/dist/es2019/internal/use-animation-preset.js +1 -1
  33. package/dist/es2019/internal/use-preset-styles.js +1 -1
  34. package/dist/es2019/internal/use-width-from-anchor.js +4 -4
  35. package/dist/es2019/popover/create-close-event.js +1 -1
  36. package/dist/es2019/popover/popover.js +3 -3
  37. package/dist/es2019/popup/popup-content.js +4 -4
  38. package/dist/es2019/testing/polyfill.js +8 -8
  39. package/dist/es2019/testing/to-be-visible.js +5 -5
  40. package/dist/es2019/use-arrow-navigation/is-at-current-menu-level.js +19 -12
  41. package/dist/es2019/use-simple-light-dismiss/index.js +3 -3
  42. package/dist/esm/animations/presets.js +5 -5
  43. package/dist/esm/dialog/create-close-event.js +1 -1
  44. package/dist/esm/dialog/dialog-content.js +5 -5
  45. package/dist/esm/internal/ensure-preset-styles.js +1 -1
  46. package/dist/esm/internal/reduced-motion.js +1 -1
  47. package/dist/esm/internal/resolve-placement.js +2 -2
  48. package/dist/esm/internal/role-types.js +1 -1
  49. package/dist/esm/internal/slot.js +3 -3
  50. package/dist/esm/internal/use-anchor-position.js +15 -30
  51. package/dist/esm/internal/use-animated-visibility.js +10 -10
  52. package/dist/esm/internal/use-animation-preset.js +1 -1
  53. package/dist/esm/internal/use-preset-styles.js +1 -1
  54. package/dist/esm/internal/use-width-from-anchor.js +4 -4
  55. package/dist/esm/popover/create-close-event.js +1 -1
  56. package/dist/esm/popover/popover.js +3 -3
  57. package/dist/esm/popup/popup-content.js +4 -4
  58. package/dist/esm/testing/polyfill.js +8 -8
  59. package/dist/esm/testing/to-be-visible.js +5 -5
  60. package/dist/esm/use-arrow-navigation/is-at-current-menu-level.js +19 -12
  61. package/dist/esm/use-simple-light-dismiss/index.js +3 -3
  62. package/dist/types/dialog/create-close-event.d.ts +1 -1
  63. package/dist/types/dialog/types.d.ts +8 -0
  64. package/dist/types/internal/reduced-motion.d.ts +1 -1
  65. package/dist/types/internal/resolve-placement.d.ts +2 -2
  66. package/dist/types/internal/slot.d.ts +4 -4
  67. package/dist/types/internal/use-animated-visibility.d.ts +3 -3
  68. package/dist/types/internal/use-animation-preset.d.ts +1 -1
  69. package/dist/types/internal/use-preset-styles.d.ts +1 -1
  70. package/dist/types/internal/use-width-from-anchor.d.ts +2 -2
  71. package/dist/types/popover/create-close-event.d.ts +1 -1
  72. package/dist/types/popover/popover.d.ts +1 -1
  73. package/dist/types/popup/popup-context.d.ts +1 -1
  74. package/dist/types/testing/to-be-visible.d.ts +3 -3
  75. package/dist/types/use-simple-light-dismiss/index.d.ts +1 -1
  76. package/dist/types-ts4.5/dialog/create-close-event.d.ts +1 -1
  77. package/dist/types-ts4.5/dialog/types.d.ts +8 -0
  78. package/dist/types-ts4.5/internal/reduced-motion.d.ts +1 -1
  79. package/dist/types-ts4.5/internal/resolve-placement.d.ts +2 -2
  80. package/dist/types-ts4.5/internal/slot.d.ts +4 -4
  81. package/dist/types-ts4.5/internal/use-animated-visibility.d.ts +3 -3
  82. package/dist/types-ts4.5/internal/use-animation-preset.d.ts +1 -1
  83. package/dist/types-ts4.5/internal/use-preset-styles.d.ts +1 -1
  84. package/dist/types-ts4.5/internal/use-width-from-anchor.d.ts +2 -2
  85. package/dist/types-ts4.5/popover/create-close-event.d.ts +1 -1
  86. package/dist/types-ts4.5/popover/popover.d.ts +1 -1
  87. package/dist/types-ts4.5/popup/popup-context.d.ts +1 -1
  88. package/dist/types-ts4.5/testing/to-be-visible.d.ts +3 -3
  89. package/dist/types-ts4.5/use-simple-light-dismiss/index.d.ts +1 -1
  90. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  import { getPlacement } from '../internal/resolve-placement';
2
2
 
3
- // ── slideAndFade ──
3
+ // slideAndFade
4
4
 
5
5
  function getSlideAndFadeProperties({
6
6
  placement,
@@ -123,7 +123,7 @@ export function slideAndFade(options) {
123
123
  };
124
124
  }
125
125
 
126
- // ── fade ──
126
+ // fade
127
127
 
128
128
  const FADE_CSS = `
129
129
  [data-ds-popover-fade] {
@@ -175,7 +175,7 @@ export function fade() {
175
175
  };
176
176
  }
177
177
 
178
- // ── scaleAndFade ──
178
+ // scaleAndFade
179
179
 
180
180
  const SCALE_AND_FADE_CSS = `
181
181
  [data-ds-popover-scale-and-fade] {
@@ -235,7 +235,7 @@ export function scaleAndFade() {
235
235
  // Dialog presets
236
236
  // ══════════════════════════════════════════════════════════════════════════════
237
237
 
238
- // ── dialogSlideUpAndFade ──
238
+ // dialogSlideUpAndFade
239
239
 
240
240
  const DIALOG_SLIDE_UP_AND_FADE_CSS = `
241
241
  [data-ds-dialog-slide-up-and-fade] {
@@ -322,7 +322,7 @@ export function dialogSlideUpAndFade(options) {
322
322
  };
323
323
  }
324
324
 
325
- // ── dialogFade ──
325
+ // dialogFade
326
326
 
327
327
  const DIALOG_FADE_CSS = `
328
328
  [data-ds-dialog-fade] {
@@ -2,7 +2,7 @@
2
2
  * Creates a synthetic DOM event from a `TDialogCloseReason`.
3
3
  *
4
4
  * Useful when bridging the Dialog primitive's `onClose({ reason })` callback
5
- * to a legacy API that expects a `KeyboardEvent` or `MouseEvent` — for example,
5
+ * to a legacy API that expects a `KeyboardEvent` or `MouseEvent` - for example,
6
6
  * `@atlaskit/modal-dialog`'s `onClose(event, analyticsEvent)` contract.
7
7
  *
8
8
  * - `'escape'` → `KeyboardEvent('keydown', { key: 'Escape' })`
@@ -49,7 +49,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
49
49
  const ownRef = useRef(null);
50
50
  const combinedRef = mergeRefs([ownRef, ref]);
51
51
 
52
- // ── Animation lifecycle ──
52
+ // Animation lifecycle
53
53
  const {
54
54
  showChildren,
55
55
  preset
@@ -60,7 +60,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
60
60
  onExitFinish
61
61
  });
62
62
 
63
- // ── Focus wrap ──
63
+ // Focus wrap
64
64
  // Native <dialog>.showModal() traps focus but wraps through <body> at
65
65
  // the boundary (A → B → C → body → A). This hook intercepts Tab to
66
66
  // wrap directly (A → B → C → A), matching the WAI-ARIA APG pattern.
@@ -69,7 +69,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
69
69
  role: 'dialog'
70
70
  });
71
71
 
72
- // ── Open layer observer registration ──
72
+ // Open layer observer registration
73
73
  // Notifies the open layer observer so app-coordination features
74
74
  // (open-count subscriptions) work with top-layer dialogs.
75
75
  useNotifyOpenLayerObserver({
@@ -100,7 +100,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
100
100
  }
101
101
  }, [isOpen]);
102
102
 
103
- // ── Handle native Escape (cancel event) ──
103
+ // Handle native Escape (cancel event)
104
104
  const handleCancel = useCallback(event => {
105
105
  event.preventDefault();
106
106
  onClose({
@@ -108,7 +108,7 @@ export const Dialog = /*#__PURE__*/forwardRef(function Dialog({
108
108
  });
109
109
  }, [onClose]);
110
110
 
111
- // ── Handle backdrop click ──
111
+ // Handle backdrop click
112
112
  // Attached via bind-event-listener rather than a React prop so we avoid
113
113
  // a11y lint suppressions on the <dialog> element.
114
114
  // Keyboard dismiss is already handled natively (Escape → onCancel above).
@@ -4,7 +4,7 @@
4
4
  * Each preset's CSS is injected at most once into `<head>`.
5
5
  * Shared by both PopoverContent and DialogContent.
6
6
  *
7
- * Note: injected `<style>` elements and the tracking Set are append-only —
7
+ * Note: injected `<style>` elements and the tracking Set are append-only -
8
8
  * they are never removed. This is intentional: the number of distinct
9
9
  * presets is bounded (handful of animation presets), so the
10
10
  * memory footprint is negligible. Removing styles would risk breaking
@@ -7,7 +7,7 @@ import once from '@atlaskit/ds-lib/once';
7
7
  *
8
8
  * The result is cached after the first call via `once`. This avoids
9
9
  * calling `matchMedia` on every render. The trade-off is that if a user
10
- * toggles the OS reduced-motion setting mid-session, the change won't
10
+ * toggles the OS reduced-motion setting mid-session, the change will not
11
11
  * take effect until the next page load. This is acceptable because
12
12
  * toggling this system-level preference mid-session is extremely rare,
13
13
  * and a page refresh is a reasonable expectation for system accessibility
@@ -25,8 +25,8 @@ const DEFAULT_GAP = "var(--ds-space-100, 8px)";
25
25
  * CSS length string (e.g. `token('space.100')`).
26
26
  *
27
27
  * The two offset axes are named for clarity at the call site:
28
- * - `gap` — distance away from the trigger along the placement axis
29
- * - `crossAxisShift` — nudge along the trigger edge (perpendicular to the placement axis)
28
+ * - `gap` - distance away from the trigger along the placement axis
29
+ * - `crossAxisShift` - nudge along the trigger edge (perpendicular to the placement axis)
30
30
  */
31
31
 
32
32
  /**
@@ -22,7 +22,7 @@
22
22
  * (e.g. a combobox labels its listbox, tooltip content IS the accessible name).
23
23
  */
24
24
 
25
- // ── Shared ARIA role discrimination types ──
25
+ // Shared ARIA role discrimination types
26
26
  //
27
27
  // These encode the WCAG 4.1.2 constraint: roles like `dialog`, `alertdialog`,
28
28
  // and `menu` MUST have an accessible name (either `label` or `labelledBy`).
@@ -21,14 +21,14 @@ function isSlotChild(child) {
21
21
  * Merges props (including ref) onto a single React element child.
22
22
  *
23
23
  * A safer alternative to raw `cloneElement` that:
24
- * 1. Guards with `isValidElement` — non-element children (strings,
24
+ * 1. Guards with `isValidElement` - non-element children (strings,
25
25
  * fragments, null) are returned as-is instead of crashing.
26
26
  * 2. Merges refs via `mergeRefs` so both the caller's ref and the
27
27
  * child's existing ref are honoured.
28
28
  * 3. Spreads any additional props (ARIA attributes, event handlers, etc.)
29
29
  * onto the child element.
30
30
  *
31
- * Event handlers (e.g. `onClick`) are **not** auto-merged — the caller's
31
+ * Event handlers (e.g. `onClick`) are **not** auto-merged - the caller's
32
32
  * handler replaces the child's. Compose handlers before passing them in.
33
33
  *
34
34
  * @example
@@ -43,7 +43,7 @@ export const Slot = /*#__PURE__*/forwardRef(function Slot(slotProps, ref) {
43
43
  children: rawChildren,
44
44
  ...props
45
45
  } = slotProps;
46
- // `SlotProps` intersects `Record<string, unknown>`, so `children` is typed as `unknown`.
46
+ // `TSlotProps` intersects `Record<string, unknown>`, so `children` is typed as `unknown`.
47
47
  const children = rawChildren;
48
48
  if (!isSlotChild(children)) {
49
49
  return children;
@@ -28,13 +28,13 @@ import { setStyle } from './set-style';
28
28
  // from `./resolve-placement` so search-and-jump lands at the source of truth.
29
29
 
30
30
  /**
31
- * Module-scope no-op `ResizeObserver` used in non-DOM jest environments where
31
+ * Module-scope no-op `ResizeObserver` stub used in non-DOM jest environments where
32
32
  * `ResizeObserver` is `undefined`. Hoisted out of the effect to avoid
33
- * allocating a new class declaration on every run.
33
+ * re-allocating on every run.
34
34
  */
35
- const NoopResizeObserver = class {
36
- observe() {}
37
- unobserve() {}
35
+ const noopResizeObserver = {
36
+ observe() {},
37
+ unobserve() {},
38
38
  disconnect() {}
39
39
  };
40
40
 
@@ -329,7 +329,7 @@ export function useAnchorPosition({
329
329
  return undoPositioning;
330
330
  }
331
331
 
332
- // ── JS fallback ──
332
+ // JS fallback
333
333
  // The popover is already in the browser's top layer via popover="auto",
334
334
  // so it does not need position:fixed. We only reset the UA defaults
335
335
  // (inset: 0; margin: auto) and set top/left based on measurements.
@@ -399,20 +399,17 @@ export function useAnchorPosition({
399
399
  // Self-disconnects after one valid measurement; ongoing
400
400
  // scroll/resize is handled by the window listeners below.
401
401
  // `ResizeObserver` is missing in some non-DOM jest environments
402
- // (e.g. post-office's `node` environment). Fall back to a no-op
403
- // observer there. The scroll/resize listeners below still keep
404
- // the popover positioned in the rare case the consumer also
405
- // polyfilled `showPopover` but not `ResizeObserver`. Real
406
- // browsers always have it. The `NoopResizeObserver` class is
407
- // hoisted to module scope (see top of file) so we do not allocate
408
- // a new constructor on every effect run.
409
- const ResizeObserverImpl = typeof ResizeObserver !== 'undefined' ? ResizeObserver : NoopResizeObserver;
410
- const resizeObserver = new ResizeObserverImpl(() => {
402
+ // (e.g. post-office's `node` environment). Fall back to the
403
+ // module-scope `noopResizeObserver` stub there. The scroll/resize
404
+ // listeners below still keep the popover positioned in the rare
405
+ // case the consumer also polyfilled `showPopover` but not
406
+ // `ResizeObserver`. Real browsers always have it.
407
+ const resizeObserver = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(() => {
411
408
  if (popover.offsetWidth > 0 && popover.offsetHeight > 0) {
412
409
  update();
413
410
  resizeObserver.disconnect();
414
411
  }
415
- });
412
+ }) : noopResizeObserver;
416
413
 
417
414
  // If the popover is already open by the time this effect runs (for
418
415
  // example, the parent `useAnchorPosition` effect runs after the child
@@ -7,19 +7,19 @@ import { usePresetStyles } from './use-preset-styles';
7
7
  *
8
8
  * Used by both `Popover` and `Dialog` to share the same animation lifecycle
9
9
  * logic. Those components own their own show/hide mechanisms (showPopover /
10
- * hidePopover vs showModal / close) and event handling — this hook only
10
+ * hidePopover vs showModal / close) and event handling - this hook only
11
11
  * manages the relationship between `isOpen` and when children are rendered.
12
12
  *
13
13
  * ## Problem
14
14
  *
15
15
  * We want to delay the unmount of children until a CSS exit transition has
16
16
  * finished playing. If we unmount children the moment `isOpen` becomes
17
- * `false`, the exit animation is never visible — the content just disappears.
17
+ * `false`, the exit animation is never visible - the content just disappears.
18
18
  *
19
19
  * ## How it works
20
20
  *
21
21
  * `showChildren` tracks whether the consumer's children should be in the DOM.
22
- * It does not mirror `isOpen` exactly — it intentionally lags behind during
22
+ * It does not mirror `isOpen` exactly - it intentionally lags behind during
23
23
  * exit animations:
24
24
  *
25
25
  * ```
@@ -56,12 +56,12 @@ export function useAnimatedVisibility({
56
56
  // or the user has enabled the "prefers reduced motion" OS setting.
57
57
  const willAnimate = Boolean(animate) && !prefersReducedMotion();
58
58
 
59
- // ── showChildren state ──
59
+ // showChildren state
60
60
  //
61
61
  // This is the core of the hook. `showChildren` controls whether the
62
62
  // consumer's children are in the DOM. The two `if` blocks below are
63
63
  // intentionally written as synchronous state updates during render
64
- // (React supports this pattern — setState during render is treated as
64
+ // (React supports this pattern - setState during render is treated as
65
65
  // a synchronous re-render before the browser paints).
66
66
  //
67
67
  // Mount path: isOpen went true but showChildren is still false → mount.
@@ -85,7 +85,7 @@ export function useAnimatedVisibility({
85
85
  const onExitFinishRef = useRef(onExitFinish);
86
86
  onExitFinishRef.current = onExitFinish;
87
87
 
88
- // ── Animated entry effect ──
88
+ // Animated entry effect
89
89
  //
90
90
  // Fires `onEnterFinish` after the entry transition completes.
91
91
  // When there is no animation, fires it immediately via a separate effect.
@@ -134,7 +134,7 @@ export function useAnimatedVisibility({
134
134
  };
135
135
  }, [isOpen, showChildren, willAnimate, preset === null || preset === void 0 ? void 0 : preset.enterDurationMs, elementRef]);
136
136
 
137
- // ── Non-animated entry callback ──
137
+ // Non-animated entry callback
138
138
  //
139
139
  // When there is no animation, fire `onEnterFinish` immediately on mount and after `isOpen` goes false->true.
140
140
  // The initial value is false to make sure it fires on mount if the current `isOpen` is true.
@@ -148,7 +148,7 @@ export function useAnimatedVisibility({
148
148
  }
149
149
  }, [isOpen, willAnimate]);
150
150
 
151
- // ── Animated exit effect ──
151
+ // Animated exit effect
152
152
  //
153
153
  // Runs when all three conditions are true:
154
154
  // • `isOpen` is false (consumer wants to close)
@@ -211,10 +211,10 @@ export function useAnimatedVisibility({
211
211
  };
212
212
  }, [isOpen, showChildren, willAnimate, preset === null || preset === void 0 ? void 0 : preset.exitDurationMs, elementRef]);
213
213
 
214
- // ── Non-animated exit callback ──
214
+ // Non-animated exit callback
215
215
  //
216
216
  // When there is no animation, children unmount synchronously (handled
217
- // by the `if` block above). But `onExitFinish` still needs to fire —
217
+ // by the `if` block above). But `onExitFinish` still needs to fire -
218
218
  // we do that in a follow-up effect so the consumer can react to it.
219
219
  //
220
220
  // Uses a previous-value ref (`wasOpenRef`) to detect the exact
@@ -3,7 +3,7 @@ import { ensurePresetStyles } from './ensure-preset-styles';
3
3
  /**
4
4
  * Normalizes the `animate` prop to a preset (or null) and ensures its CSS
5
5
  * is injected once into document.head. Used by PopupContent, Popover, and
6
- * DialogContent so they don't duplicate this logic.
6
+ * DialogContent so they do not duplicate this logic.
7
7
  */
8
8
  export function useAnimationPreset(animate) {
9
9
  const preset = animate != null && animate !== false ? animate : null;
@@ -4,7 +4,7 @@ import { ensurePresetStyles } from './ensure-preset-styles';
4
4
  * Normalizes a preset prop to a value (or null) and ensures its CSS
5
5
  * is injected once into `document.head`.
6
6
  *
7
- * Works with any preset that has `{ css, name }` — animation presets
7
+ * Works with any preset that has `{ css, name }` - animation presets
8
8
  * (TAnimationPreset) satisfies this shape.
9
9
  */
10
10
  export function usePresetStyles({
@@ -4,8 +4,8 @@ import { setStyle } from './set-style';
4
4
  /**
5
5
  * Sets the width of a popover element relative to its anchor element.
6
6
  *
7
- * - `'match-anchor'` → `width: anchor-size(width)` — popover matches anchor width exactly.
8
- * - `'min-anchor'` → `min-width: anchor-size(width)` — popover is at least as wide as anchor,
7
+ * - `'match-anchor'` → `width: anchor-size(width)` - popover matches anchor width exactly.
8
+ * - `'min-anchor'` → `min-width: anchor-size(width)` - popover is at least as wide as anchor,
9
9
  * but can grow wider.
10
10
  * - `'none'` → no explicit width is set (default behaviour)
11
11
  *
@@ -31,7 +31,7 @@ export function useWidthFromAnchor({
31
31
  const supportsAnchorSize = typeof CSS !== 'undefined' && typeof CSS.supports === 'function' && CSS.supports('width', 'anchor-size(width)');
32
32
  if (mode === 'match-anchor') {
33
33
  // Set an exact width matching the anchor.
34
- // `min-inline-size` is intentionally NOT set here — it would override the
34
+ // `min-inline-size` is intentionally NOT set here - it would override the
35
35
  // explicit width constraint, allowing the popover to grow past the anchor's width.
36
36
  if (supportsAnchorSize) {
37
37
  return setStyle({
@@ -87,7 +87,7 @@ export function useWidthFromAnchor({
87
87
  });
88
88
  }
89
89
 
90
- // No anchor available in JS fallback — still apply min-inline-size.
90
+ // No anchor available in JS fallback - still apply min-inline-size.
91
91
  return setStyle({
92
92
  el: node,
93
93
  styles: [minInlineSizeStyle]
@@ -2,7 +2,7 @@
2
2
  * Creates a synthetic DOM event from a `TPopoverCloseReason`.
3
3
  *
4
4
  * Useful when bridging the Popover primitive's `onClose({ reason })` callback
5
- * to a legacy API that expects a native DOM event — for example,
5
+ * to a legacy API that expects a native DOM event - for example,
6
6
  * `@atlaskit/inline-dialog`'s `onClose(event)` contract.
7
7
  *
8
8
  * - `'escape'` → `KeyboardEvent('keydown', { key: 'Escape' })`
@@ -45,7 +45,7 @@ const POPUP_ROLES = new Set(['menu', 'listbox', 'dialog', 'alertdialog', 'tree',
45
45
  * Unopinionated top-layer primitive.
46
46
  *
47
47
  * Manages only visibility (isOpen) and animation (animate). Has no knowledge
48
- * of positioning — compose with `useAnchorPosition` for anchor positioning
48
+ * of positioning - compose with `useAnchorPosition` for anchor positioning
49
49
  * and optionally `useWidthFromAnchor` for setting the width of a popover element
50
50
  * relative to its anchor trigger.
51
51
  *
@@ -96,7 +96,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
96
96
  onExitFinish
97
97
  });
98
98
 
99
- // ── Focus management ──
99
+ // Focus management
100
100
  // Initial focus: on open, moves focus into the popover (role-dependent).
101
101
  // Focus wrap: Tab/Shift+Tab cycle within the popover for dialog roles.
102
102
  // Focus restoration: handled natively by the Popover API. The browser
@@ -112,7 +112,7 @@ export const Popover = /*#__PURE__*/forwardRef(function Popover({
112
112
  role
113
113
  });
114
114
 
115
- // ── Open layer observer registration ──
115
+ // Open layer observer registration
116
116
  // Notifies the open layer observer so app-coordination features
117
117
  // (closeLayers(), open-count subscriptions) work with top-layer popovers.
118
118
  //
@@ -89,7 +89,7 @@ export const PopupContent = /*#__PURE__*/forwardRef(function PopupContent({
89
89
  // Note: onOpenChange composition is handled by handleOpenChange below,
90
90
  // which also adds nested-popover focus restoration.
91
91
 
92
- // ── Sync aria-haspopup on the trigger with the content's role ──
92
+ // Sync aria-haspopup on the trigger with the content's role
93
93
  const setAriaHasPopup = ctx === null || ctx === void 0 ? void 0 : ctx.setAriaHasPopup;
94
94
  useLayoutEffect(() => {
95
95
  setAriaHasPopup === null || setAriaHasPopup === void 0 ? void 0 : setAriaHasPopup(roleToAriaHasPopup({
@@ -97,7 +97,7 @@ export const PopupContent = /*#__PURE__*/forwardRef(function PopupContent({
97
97
  }));
98
98
  }, [role, setAriaHasPopup]);
99
99
 
100
- // ── Focus restoration ──
100
+ // Focus restoration
101
101
  // The native Popover API handles focus restoration automatically for
102
102
  // popover="auto" and popover="hint":
103
103
  // - Escape → restores focus to the previously focused element (the trigger)
@@ -124,7 +124,7 @@ export const PopupContent = /*#__PURE__*/forwardRef(function PopupContent({
124
124
  }
125
125
  consumerOnOpenChange === null || consumerOnOpenChange === void 0 ? void 0 : consumerOnOpenChange(args);
126
126
 
127
- // ── Nested popover focus restoration fallback ──
127
+ // Nested popover focus restoration fallback
128
128
  // The browser only captures `previouslyFocusedElement` for the
129
129
  // outermost popover="auto" in the stack. Inner (nested) popovers
130
130
  // have shouldRestoreFocus=false, so the browser will not restore
@@ -153,7 +153,7 @@ export const PopupContent = /*#__PURE__*/forwardRef(function PopupContent({
153
153
  }
154
154
  }, [consumerOnOpenChange, triggerRef, role, setPopupState, willAnimate]);
155
155
 
156
- // ── Anchor positioning ──
156
+ // Anchor positioning
157
157
  // Compose useAnchorPosition with Popover. The hook positions the popover
158
158
  // relative to the trigger element via CSS Anchor Positioning (with JS fallback).
159
159
  // Use ctx.popoverRef when inside the compound (so the trigger can also
@@ -107,7 +107,7 @@ function createToggleScheduler() {
107
107
  newState
108
108
  });
109
109
 
110
- // Task queue (setTimeout) — browser fires toggle after microtasks drain, not during
110
+ // Task queue (setTimeout) - browser fires toggle after microtasks drain, not during
111
111
  setTimeout(() => {
112
112
  const entry = pending.get(element);
113
113
  if (!entry) {
@@ -178,7 +178,7 @@ function createDialogToggleScheduler() {
178
178
  };
179
179
  }
180
180
 
181
- // ─── Popover API ────────────────────────────────────────────────────────────
181
+ // Popover API
182
182
  // Spec: https://html.spec.whatwg.org/multipage/popover.html
183
183
 
184
184
  // `popover` attribute valid values. Empty / "auto" -> "auto"; unknown -> "manual".
@@ -555,7 +555,7 @@ if (typeof HTMLElement !== 'undefined') {
555
555
  if (isPopoverOpen({
556
556
  element: this
557
557
  })) {
558
- return; // already showing — no-op
558
+ return; // already showing - no-op
559
559
  }
560
560
 
561
561
  // sync, cancelable on show only
@@ -731,7 +731,7 @@ if (typeof HTMLElement !== 'undefined') {
731
731
  }
732
732
  }
733
733
 
734
- // ─── HTMLDialogElement ──────────────────────────────────────────────────────
734
+ // HTMLDialogElement
735
735
  // Spec: https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element
736
736
 
737
737
  if (typeof HTMLDialogElement !== 'undefined') {
@@ -746,7 +746,7 @@ if (typeof HTMLDialogElement !== 'undefined') {
746
746
  }
747
747
  if (this.hasAttribute('open')) {
748
748
  if (this._isModal) {
749
- return; // already modal — no-op
749
+ return; // already modal - no-op
750
750
  }
751
751
  throw new DOMException(`Failed to execute 'showModal' on 'HTMLDialogElement': ${describeElement({
752
752
  element: this
@@ -770,7 +770,7 @@ if (typeof HTMLDialogElement !== 'undefined') {
770
770
  }
771
771
  if (typeof proto.show !== 'function') {
772
772
  proto.show = function show() {
773
- // Browser does not throw for disconnected elements on show — just no-op
773
+ // Browser does not throw for disconnected elements on show - just no-op
774
774
  if (!this.isConnected || this.hasAttribute('open')) {
775
775
  return;
776
776
  }
@@ -793,10 +793,10 @@ if (typeof HTMLDialogElement !== 'undefined') {
793
793
  if (typeof proto.close !== 'function') {
794
794
  proto.close = function close(returnValue) {
795
795
  if (!this.hasAttribute('open')) {
796
- return; // already closed — no-op
796
+ return; // already closed - no-op
797
797
  }
798
798
 
799
- // Sync beforetoggle (not cancelable) — matches browser behavior
799
+ // Sync beforetoggle (not cancelable) - matches browser behavior
800
800
  fireToggleEvent({
801
801
  element: this,
802
802
  type: 'beforetoggle',
@@ -5,13 +5,13 @@
5
5
  *
6
6
  * jest-dom's `toBeVisible()` does not know about the Popover API. In real
7
7
  * browsers the UA stylesheet hides `[popover]` with `display: none`, but
8
- * jsdom has no such stylesheet — so closed popovers incorrectly appear visible.
8
+ * jsdom has no such stylesheet - so closed popovers incorrectly appear visible.
9
9
  *
10
10
  * Raw jest-dom results in jsdom:
11
11
  *
12
- * closed popover / child → true (WRONG — should be false)
12
+ * closed popover / child → true (WRONG - should be false)
13
13
  * open popover / child → true (correct)
14
- * closed dialog / child → false (correct — jsdom natively hides <dialog>)
14
+ * closed dialog / child → false (correct - jsdom natively hides <dialog>)
15
15
  * open dialog / child → true (correct)
16
16
  *
17
17
  * We correct both false positives and false negatives:
@@ -62,7 +62,7 @@ expect.extend({
62
62
  const originalResult = originalToBeVisible.call(this, element);
63
63
  const topLayerState = nearestTopLayerState(element);
64
64
  if (originalResult.pass) {
65
- // Original says visible — override if nearest top-layer host is closed.
65
+ // Original says visible - override if nearest top-layer host is closed.
66
66
  if (topLayerState === 'closed') {
67
67
  return {
68
68
  pass: false,
@@ -72,7 +72,7 @@ expect.extend({
72
72
  return originalResult;
73
73
  }
74
74
 
75
- // Original says not visible — override if nearest top-layer host is open.
75
+ // Original says not visible - override if nearest top-layer host is open.
76
76
  // jsdom may hide [popover] elements even when they are logically open.
77
77
  if (topLayerState === 'open') {
78
78
  return {
@@ -1,5 +1,23 @@
1
1
  const menuScope = '[role="menu"]';
2
2
 
3
+ /**
4
+ * Recursively walks from `node` toward `container`, returning `true` when
5
+ * `container` is reached without crossing another `role="menu"` ancestor.
6
+ *
7
+ * Used by `isAtCurrentMenuLevel` (pattern 2) to determine if the
8
+ * `closestMenu` is owned by the wrapper container directly. Recursion
9
+ * avoids a mutable `let parent` walk and keeps the function body linear.
10
+ */
11
+ function reachesContainerWithoutNestedMenu(node, container) {
12
+ if (!node || node === container) {
13
+ return node === container;
14
+ }
15
+ if (node.getAttribute('role') === 'menu') {
16
+ return false;
17
+ }
18
+ return reachesContainerWithoutNestedMenu(node.parentElement, container);
19
+ }
20
+
3
21
  /**
4
22
  * Returns true if the element belongs to the current menu level of the
5
23
  * container, i.e. it is NOT inside a nested `role="menu"` sub-container.
@@ -66,16 +84,5 @@ export function isAtCurrentMenuLevel(element, container) {
66
84
 
67
85
  // Walk up from the closest menu to see if it is "owned" by this
68
86
  // container without passing through another role="menu" first.
69
- let parent = closestMenu.parentElement;
70
- while (parent && parent !== container) {
71
- if (parent.getAttribute('role') === 'menu') {
72
- // There is a parent menu between the closest menu and the
73
- // container, so the element is in a nested sub-menu.
74
- return false;
75
- }
76
- parent = parent.parentElement;
77
- }
78
-
79
- // The closest menu is directly inside the container (no nesting).
80
- return parent === container;
87
+ return reachesContainerWithoutNestedMenu(closestMenu.parentElement, container);
81
88
  }
@@ -9,7 +9,7 @@ import { bind } from 'bind-event-listener';
9
9
  * **No stacking awareness:** This hook does not track a popover stack.
10
10
  * If multiple manual popovers are open and all use this hook, a single
11
11
  * Escape press or outside click will dismiss **all of them simultaneously**.
12
- * This is by design — the hook is intentionally simple for cases where
12
+ * This is by design - the hook is intentionally simple for cases where
13
13
  * only one manual popover is open at a time.
14
14
  *
15
15
  * For stacked/nested popovers that should dismiss one-at-a-time, use
@@ -47,7 +47,7 @@ export function useSimpleLightDismiss({
47
47
  // (trigger onClick → setIsOpen(true) → React render → useEffect).
48
48
  // By the time this effect runs, the opening click has finished
49
49
  // bubbling. A capture-phase listener added now cannot retroactively
50
- // fire for that event — it only fires for *future* clicks.
50
+ // fire for that event - it only fires for *future* clicks.
51
51
  //
52
52
  // This avoids the need for timestamp guards or deferred binding.
53
53
  // eslint-disable-next-line @atlaskit/platform/no-direct-document-usage -- binding to document for light dismiss
@@ -59,7 +59,7 @@ export function useSimpleLightDismiss({
59
59
  return;
60
60
  }
61
61
 
62
- // If the click target is inside the popover, don't dismiss.
62
+ // If the click target is inside the popover, do not dismiss.
63
63
  if (event.target instanceof Node && el.contains(event.target)) {
64
64
  return;
65
65
  }
@@ -1,6 +1,6 @@
1
1
  import { getPlacement } from '../internal/resolve-placement';
2
2
 
3
- // ── slideAndFade ──
3
+ // slideAndFade
4
4
 
5
5
  function getSlideAndFadeProperties(_ref) {
6
6
  var placement = _ref.placement,
@@ -82,7 +82,7 @@ export function slideAndFade(options) {
82
82
  };
83
83
  }
84
84
 
85
- // ── fade ──
85
+ // fade
86
86
 
87
87
  var FADE_CSS = "\n[data-ds-popover-fade] {\n opacity: 0;\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-popover-fade]:popover-open {\n opacity: 1;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-popover-fade]:popover-open {\n opacity: 0;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-popover-fade],\n [data-ds-popover-fade]:popover-open {\n transition-duration: 0s;\n }\n}\n";
88
88
 
@@ -108,7 +108,7 @@ export function fade() {
108
108
  };
109
109
  }
110
110
 
111
- // ── scaleAndFade ──
111
+ // scaleAndFade
112
112
 
113
113
  var SCALE_AND_FADE_CSS = "\n[data-ds-popover-scale-and-fade] {\n opacity: 0;\n transform: scale(0.95);\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n transform 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-popover-scale-and-fade]:popover-open {\n opacity: 1;\n transform: none;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-popover-scale-and-fade]:popover-open {\n opacity: 0;\n transform: scale(0.95);\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-popover-scale-and-fade],\n [data-ds-popover-scale-and-fade]:popover-open {\n transition-duration: 0s;\n }\n}\n";
114
114
 
@@ -138,7 +138,7 @@ export function scaleAndFade() {
138
138
  // Dialog presets
139
139
  // ══════════════════════════════════════════════════════════════════════════════
140
140
 
141
- // ── dialogSlideUpAndFade ──
141
+ // dialogSlideUpAndFade
142
142
 
143
143
  var DIALOG_SLIDE_UP_AND_FADE_CSS = "\n[data-ds-dialog-slide-up-and-fade] {\n opacity: 0;\n transform: translateY(calc(-1 * var(--ds-dialog-ty, 12px)));\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n transform 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-slide-up-and-fade][open] {\n opacity: 1;\n transform: none;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-slide-up-and-fade][open] {\n opacity: 0;\n transform: translateY(var(--ds-dialog-ty, 12px));\n }\n}\n\n[data-ds-dialog-slide-up-and-fade]::backdrop {\n background-color: transparent;\n transition:\n background-color 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-slide-up-and-fade][open]::backdrop {\n background-color: var(--ds-blanket, #050C1F75);\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-slide-up-and-fade][open]::backdrop {\n background-color: transparent;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-dialog-slide-up-and-fade],\n [data-ds-dialog-slide-up-and-fade][open],\n [data-ds-dialog-slide-up-and-fade]::backdrop,\n [data-ds-dialog-slide-up-and-fade][open]::backdrop {\n transition-duration: 0s;\n }\n}\n";
144
144
 
@@ -174,7 +174,7 @@ export function dialogSlideUpAndFade(options) {
174
174
  };
175
175
  }
176
176
 
177
- // ── dialogFade ──
177
+ // dialogFade
178
178
 
179
179
  var DIALOG_FADE_CSS = "\n[data-ds-dialog-fade] {\n opacity: 0;\n transition:\n opacity 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-fade][open] {\n opacity: 1;\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-fade][open] {\n opacity: 0;\n }\n}\n\n[data-ds-dialog-fade]::backdrop {\n background-color: transparent;\n transition:\n background-color 175ms cubic-bezier(0.15, 1, 0.3, 1),\n overlay 175ms allow-discrete,\n display 175ms allow-discrete;\n}\n\n[data-ds-dialog-fade][open]::backdrop {\n background-color: var(--ds-blanket, #050C1F75);\n transition-duration: 350ms;\n}\n\n@starting-style {\n [data-ds-dialog-fade][open]::backdrop {\n background-color: transparent;\n }\n}\n\n@media (prefers-reduced-motion: reduce) {\n [data-ds-dialog-fade],\n [data-ds-dialog-fade][open],\n [data-ds-dialog-fade]::backdrop,\n [data-ds-dialog-fade][open]::backdrop {\n transition-duration: 0s;\n }\n}\n";
180
180