@atlaskit/top-layer 0.12.0 → 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 (156) hide show
  1. package/CHANGELOG.md +15 -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/entry-points/use-arrow-navigation.js +3 -2
  6. package/dist/cjs/internal/ensure-preset-styles.js +1 -1
  7. package/dist/cjs/internal/placement-to-position-area.js +43 -0
  8. package/dist/cjs/internal/placement-to-try-fallbacks.js +82 -0
  9. package/dist/cjs/internal/reduced-motion.js +1 -1
  10. package/dist/cjs/internal/resolve-placement.js +2 -2
  11. package/dist/cjs/internal/role-types.js +1 -1
  12. package/dist/cjs/internal/slot.js +3 -3
  13. package/dist/cjs/internal/use-anchor-position.js +33 -161
  14. package/dist/cjs/internal/use-animated-visibility.js +10 -10
  15. package/dist/cjs/internal/use-animation-preset.js +1 -1
  16. package/dist/cjs/internal/use-preset-styles.js +1 -1
  17. package/dist/cjs/internal/use-width-from-anchor.js +4 -4
  18. package/dist/cjs/popover/create-close-event.js +1 -1
  19. package/dist/cjs/popover/popover.js +3 -3
  20. package/dist/cjs/popup/popup-content.js +6 -6
  21. package/dist/cjs/popup/popup-context.js +2 -38
  22. package/dist/cjs/popup/popup-provider.js +15 -0
  23. package/dist/cjs/popup/popup-trigger-function.js +2 -2
  24. package/dist/cjs/popup/popup-trigger.js +2 -2
  25. package/dist/cjs/popup/popup.js +2 -2
  26. package/dist/cjs/popup/use-maybe-popup-context.js +17 -0
  27. package/dist/cjs/popup/use-popup-context.js +20 -0
  28. package/dist/cjs/testing/polyfill.js +8 -8
  29. package/dist/cjs/testing/to-be-visible.js +5 -5
  30. package/dist/cjs/use-arrow-navigation/index.js +3 -2
  31. package/dist/cjs/use-arrow-navigation/is-at-current-menu-level.js +94 -0
  32. package/dist/cjs/use-arrow-navigation/use-arrow-navigation.js +0 -82
  33. package/dist/cjs/use-simple-light-dismiss/index.js +3 -3
  34. package/dist/es2019/animations/presets.js +5 -5
  35. package/dist/es2019/dialog/create-close-event.js +1 -1
  36. package/dist/es2019/dialog/dialog-content.js +5 -5
  37. package/dist/es2019/entry-points/use-arrow-navigation.js +2 -1
  38. package/dist/es2019/internal/ensure-preset-styles.js +1 -1
  39. package/dist/es2019/internal/placement-to-position-area.js +40 -0
  40. package/dist/es2019/internal/placement-to-try-fallbacks.js +77 -0
  41. package/dist/es2019/internal/reduced-motion.js +1 -1
  42. package/dist/es2019/internal/resolve-placement.js +2 -2
  43. package/dist/es2019/internal/role-types.js +1 -1
  44. package/dist/es2019/internal/slot.js +3 -3
  45. package/dist/es2019/internal/use-anchor-position.js +15 -132
  46. package/dist/es2019/internal/use-animated-visibility.js +10 -10
  47. package/dist/es2019/internal/use-animation-preset.js +1 -1
  48. package/dist/es2019/internal/use-preset-styles.js +1 -1
  49. package/dist/es2019/internal/use-width-from-anchor.js +4 -4
  50. package/dist/es2019/popover/create-close-event.js +1 -1
  51. package/dist/es2019/popover/popover.js +3 -3
  52. package/dist/es2019/popup/popup-content.js +6 -5
  53. package/dist/es2019/popup/popup-context.js +2 -36
  54. package/dist/es2019/popup/popup-provider.js +10 -0
  55. package/dist/es2019/popup/popup-trigger-function.js +1 -1
  56. package/dist/es2019/popup/popup-trigger.js +2 -1
  57. package/dist/es2019/popup/popup.js +1 -1
  58. package/dist/es2019/popup/use-maybe-popup-context.js +12 -0
  59. package/dist/es2019/popup/use-popup-context.js +15 -0
  60. package/dist/es2019/testing/polyfill.js +8 -8
  61. package/dist/es2019/testing/to-be-visible.js +5 -5
  62. package/dist/es2019/use-arrow-navigation/index.js +2 -1
  63. package/dist/es2019/use-arrow-navigation/is-at-current-menu-level.js +88 -0
  64. package/dist/es2019/use-arrow-navigation/use-arrow-navigation.js +0 -81
  65. package/dist/es2019/use-simple-light-dismiss/index.js +3 -3
  66. package/dist/esm/animations/presets.js +5 -5
  67. package/dist/esm/dialog/create-close-event.js +1 -1
  68. package/dist/esm/dialog/dialog-content.js +5 -5
  69. package/dist/esm/entry-points/use-arrow-navigation.js +2 -1
  70. package/dist/esm/internal/ensure-preset-styles.js +1 -1
  71. package/dist/esm/internal/placement-to-position-area.js +38 -0
  72. package/dist/esm/internal/placement-to-try-fallbacks.js +76 -0
  73. package/dist/esm/internal/reduced-motion.js +1 -1
  74. package/dist/esm/internal/resolve-placement.js +2 -2
  75. package/dist/esm/internal/role-types.js +1 -1
  76. package/dist/esm/internal/slot.js +3 -3
  77. package/dist/esm/internal/use-anchor-position.js +31 -157
  78. package/dist/esm/internal/use-animated-visibility.js +10 -10
  79. package/dist/esm/internal/use-animation-preset.js +1 -1
  80. package/dist/esm/internal/use-preset-styles.js +1 -1
  81. package/dist/esm/internal/use-width-from-anchor.js +4 -4
  82. package/dist/esm/popover/create-close-event.js +1 -1
  83. package/dist/esm/popover/popover.js +3 -3
  84. package/dist/esm/popup/popup-content.js +6 -5
  85. package/dist/esm/popup/popup-context.js +2 -36
  86. package/dist/esm/popup/popup-provider.js +10 -0
  87. package/dist/esm/popup/popup-trigger-function.js +1 -1
  88. package/dist/esm/popup/popup-trigger.js +2 -1
  89. package/dist/esm/popup/popup.js +1 -1
  90. package/dist/esm/popup/use-maybe-popup-context.js +12 -0
  91. package/dist/esm/popup/use-popup-context.js +15 -0
  92. package/dist/esm/testing/polyfill.js +8 -8
  93. package/dist/esm/testing/to-be-visible.js +5 -5
  94. package/dist/esm/use-arrow-navigation/index.js +2 -1
  95. package/dist/esm/use-arrow-navigation/is-at-current-menu-level.js +88 -0
  96. package/dist/esm/use-arrow-navigation/use-arrow-navigation.js +0 -81
  97. package/dist/esm/use-simple-light-dismiss/index.js +3 -3
  98. package/dist/types/dialog/create-close-event.d.ts +1 -1
  99. package/dist/types/dialog/types.d.ts +8 -0
  100. package/dist/types/entry-points/use-arrow-navigation.d.ts +2 -1
  101. package/dist/types/internal/placement-to-position-area.d.ts +21 -0
  102. package/dist/types/internal/placement-to-try-fallbacks.d.ts +36 -0
  103. package/dist/types/internal/reduced-motion.d.ts +1 -1
  104. package/dist/types/internal/resolve-placement.d.ts +2 -2
  105. package/dist/types/internal/slot.d.ts +4 -4
  106. package/dist/types/internal/use-anchor-position.d.ts +0 -55
  107. package/dist/types/internal/use-animated-visibility.d.ts +3 -3
  108. package/dist/types/internal/use-animation-preset.d.ts +1 -1
  109. package/dist/types/internal/use-preset-styles.d.ts +1 -1
  110. package/dist/types/internal/use-width-from-anchor.d.ts +2 -2
  111. package/dist/types/popover/create-close-event.d.ts +1 -1
  112. package/dist/types/popover/popover.d.ts +1 -1
  113. package/dist/types/popup/popup-context.d.ts +2 -22
  114. package/dist/types/popup/popup-provider.d.ts +10 -0
  115. package/dist/types/popup/use-maybe-popup-context.d.ts +8 -0
  116. package/dist/types/popup/use-popup-context.d.ts +7 -0
  117. package/dist/types/testing/to-be-visible.d.ts +3 -3
  118. package/dist/types/use-arrow-navigation/index.d.ts +2 -1
  119. package/dist/types/use-arrow-navigation/is-at-current-menu-level.d.ts +48 -0
  120. package/dist/types/use-arrow-navigation/use-arrow-navigation.d.ts +0 -48
  121. package/dist/types/use-simple-light-dismiss/index.d.ts +1 -1
  122. package/dist/types-ts4.5/dialog/create-close-event.d.ts +1 -1
  123. package/dist/types-ts4.5/dialog/types.d.ts +8 -0
  124. package/dist/types-ts4.5/entry-points/use-arrow-navigation.d.ts +2 -1
  125. package/dist/types-ts4.5/internal/placement-to-position-area.d.ts +21 -0
  126. package/dist/types-ts4.5/internal/placement-to-try-fallbacks.d.ts +36 -0
  127. package/dist/types-ts4.5/internal/reduced-motion.d.ts +1 -1
  128. package/dist/types-ts4.5/internal/resolve-placement.d.ts +2 -2
  129. package/dist/types-ts4.5/internal/slot.d.ts +4 -4
  130. package/dist/types-ts4.5/internal/use-anchor-position.d.ts +0 -55
  131. package/dist/types-ts4.5/internal/use-animated-visibility.d.ts +3 -3
  132. package/dist/types-ts4.5/internal/use-animation-preset.d.ts +1 -1
  133. package/dist/types-ts4.5/internal/use-preset-styles.d.ts +1 -1
  134. package/dist/types-ts4.5/internal/use-width-from-anchor.d.ts +2 -2
  135. package/dist/types-ts4.5/popover/create-close-event.d.ts +1 -1
  136. package/dist/types-ts4.5/popover/popover.d.ts +1 -1
  137. package/dist/types-ts4.5/popup/popup-context.d.ts +2 -22
  138. package/dist/types-ts4.5/popup/popup-provider.d.ts +10 -0
  139. package/dist/types-ts4.5/popup/use-maybe-popup-context.d.ts +8 -0
  140. package/dist/types-ts4.5/popup/use-popup-context.d.ts +7 -0
  141. package/dist/types-ts4.5/testing/to-be-visible.d.ts +3 -3
  142. package/dist/types-ts4.5/use-arrow-navigation/index.d.ts +2 -1
  143. package/dist/types-ts4.5/use-arrow-navigation/is-at-current-menu-level.d.ts +48 -0
  144. package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +0 -48
  145. package/dist/types-ts4.5/use-simple-light-dismiss/index.d.ts +1 -1
  146. package/package.json +2 -2
  147. package/dist/cjs/arrow/index.js +0 -131
  148. package/dist/cjs/arrow/types.js +0 -5
  149. package/dist/es2019/arrow/index.js +0 -269
  150. package/dist/es2019/arrow/types.js +0 -1
  151. package/dist/esm/arrow/index.js +0 -124
  152. package/dist/esm/arrow/types.js +0 -1
  153. package/dist/types/arrow/index.d.ts +0 -24
  154. package/dist/types/arrow/types.d.ts +0 -29
  155. package/dist/types-ts4.5/arrow/index.d.ts +0 -24
  156. package/dist/types-ts4.5/arrow/types.d.ts +0 -29
@@ -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
  *
@@ -30,7 +30,7 @@ export function useWidthFromAnchor(_ref) {
30
30
  var supportsAnchorSize = typeof CSS !== 'undefined' && typeof CSS.supports === 'function' && CSS.supports('width', 'anchor-size(width)');
31
31
  if (mode === 'match-anchor') {
32
32
  // Set an exact width matching the anchor.
33
- // `min-inline-size` is intentionally NOT set here — it would override the
33
+ // `min-inline-size` is intentionally NOT set here - it would override the
34
34
  // explicit width constraint, allowing the popover to grow past the anchor's width.
35
35
  if (supportsAnchorSize) {
36
36
  return setStyle({
@@ -86,7 +86,7 @@ export function useWidthFromAnchor(_ref) {
86
86
  });
87
87
  }
88
88
 
89
- // No anchor available in JS fallback — still apply min-inline-size.
89
+ // No anchor available in JS fallback - still apply min-inline-size.
90
90
  return setStyle({
91
91
  el: node,
92
92
  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' })`
@@ -47,7 +47,7 @@ var POPUP_ROLES = new Set(['menu', 'listbox', 'dialog', 'alertdialog', 'tree', '
47
47
  * Unopinionated top-layer primitive.
48
48
  *
49
49
  * Manages only visibility (isOpen) and animation (animate). Has no knowledge
50
- * of positioning — compose with `useAnchorPosition` for anchor positioning
50
+ * of positioning - compose with `useAnchorPosition` for anchor positioning
51
51
  * and optionally `useWidthFromAnchor` for setting the width of a popover element
52
52
  * relative to its anchor trigger.
53
53
  *
@@ -96,7 +96,7 @@ export var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
96
96
  showChildren = _useAnimatedVisibilit.showChildren,
97
97
  preset = _useAnimatedVisibilit.preset;
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 var Popover = /*#__PURE__*/forwardRef(function Popover(_ref, ref) {
112
112
  role: 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
  //
@@ -8,7 +8,8 @@ import { roleToAriaHasPopup, shouldFocusIntoPopover } from '../internal/role-typ
8
8
  import { useAnchorPosition } from '../internal/use-anchor-position';
9
9
  import { useWidthFromAnchor } from '../internal/use-width-from-anchor';
10
10
  import { Popover } from '../popover/popover';
11
- import { useMaybePopupContext } from './popup-context';
11
+ import { useMaybePopupContext } from './use-maybe-popup-context';
12
+
12
13
  /**
13
14
  * Thin context wrapper that composes `Popover` + `useAnchorPosition`.
14
15
  *
@@ -88,7 +89,7 @@ export var PopupContent = /*#__PURE__*/forwardRef(function PopupContent(_ref, re
88
89
  // Note: onOpenChange composition is handled by handleOpenChange below,
89
90
  // which also adds nested-popover focus restoration.
90
91
 
91
- // ── Sync aria-haspopup on the trigger with the content's role ──
92
+ // Sync aria-haspopup on the trigger with the content's role
92
93
  var setAriaHasPopup = ctx === null || ctx === void 0 ? void 0 : ctx.setAriaHasPopup;
93
94
  useLayoutEffect(function () {
94
95
  setAriaHasPopup === null || setAriaHasPopup === void 0 || setAriaHasPopup(roleToAriaHasPopup({
@@ -96,7 +97,7 @@ export var PopupContent = /*#__PURE__*/forwardRef(function PopupContent(_ref, re
96
97
  }));
97
98
  }, [role, setAriaHasPopup]);
98
99
 
99
- // ── Focus restoration ──
100
+ // Focus restoration
100
101
  // The native Popover API handles focus restoration automatically for
101
102
  // popover="auto" and popover="hint":
102
103
  // - Escape → restores focus to the previously focused element (the trigger)
@@ -123,7 +124,7 @@ export var PopupContent = /*#__PURE__*/forwardRef(function PopupContent(_ref, re
123
124
  }
124
125
  consumerOnOpenChange === null || consumerOnOpenChange === void 0 || consumerOnOpenChange(args);
125
126
 
126
- // ── Nested popover focus restoration fallback ──
127
+ // Nested popover focus restoration fallback
127
128
  // The browser only captures `previouslyFocusedElement` for the
128
129
  // outermost popover="auto" in the stack. Inner (nested) popovers
129
130
  // have shouldRestoreFocus=false, so the browser will not restore
@@ -152,7 +153,7 @@ export var PopupContent = /*#__PURE__*/forwardRef(function PopupContent(_ref, re
152
153
  }
153
154
  }, [consumerOnOpenChange, triggerRef, role, setPopupState, willAnimate]);
154
155
 
155
- // ── Anchor positioning ──
156
+ // Anchor positioning
156
157
  // Compose useAnchorPosition with Popover. The hook positions the popover
157
158
  // relative to the trigger element via CSS Anchor Positioning (with JS fallback).
158
159
  // Use ctx.popoverRef when inside the compound (so the trigger can also
@@ -1,4 +1,4 @@
1
- import { createContext, useContext } from 'react';
1
+ import { createContext } from 'react';
2
2
 
3
3
  /**
4
4
  * Represents the lifecycle state of the popup.
@@ -17,38 +17,4 @@ import { createContext, useContext } from 'react';
17
17
  * the trigger (and thus the popup anchor) mid-animation.
18
18
  */
19
19
 
20
- var PopupContext = /*#__PURE__*/createContext(null);
21
-
22
- /**
23
- * __Popup provider__
24
- *
25
- * Provides shared popup state (placement, popoverId, triggerRef,
26
- * isOpen, onClose) to compound child components such as `Popup.Trigger` and
27
- * `Popup.Content`.
28
- */
29
- export var PopupProvider = PopupContext.Provider;
30
-
31
- /**
32
- * Returns the nearest `Popup` context value.
33
- *
34
- * Throws if called outside of a `<Popup>` compound component.
35
- */
36
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
37
- export function usePopupContext() {
38
- var ctx = useContext(PopupContext);
39
- if (ctx === null) {
40
- throw new Error('@atlaskit/top-layer: Popup compound components must be used within <Popup>.');
41
- }
42
- return ctx;
43
- }
44
-
45
- /**
46
- * Returns the popup context if available, or `null` when used outside `<Popup>`.
47
- *
48
- * Used by `PopupContent` to support standalone usage (e.g. tooltip)
49
- * where values are passed as props instead of coming from a compound component.
50
- */
51
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
52
- export function useMaybePopupContext() {
53
- return useContext(PopupContext);
54
- }
20
+ export var PopupContext = /*#__PURE__*/createContext(null);
@@ -0,0 +1,10 @@
1
+ import { PopupContext } from './popup-context';
2
+
3
+ /**
4
+ * __Popup provider__
5
+ *
6
+ * Provides shared popup state (placement, popoverId, triggerRef,
7
+ * isOpen, onClose) to compound child components such as `Popup.Trigger` and
8
+ * `Popup.Content`.
9
+ */
10
+ export var PopupProvider = PopupContext.Provider;
@@ -1,5 +1,5 @@
1
1
  import { useCallback, useMemo } from 'react';
2
- import { usePopupContext } from './popup-context';
2
+ import { usePopupContext } from './use-popup-context';
3
3
 
4
4
  /**
5
5
  * Props passed to the `TriggerFunction` render-prop child.
@@ -1,6 +1,7 @@
1
1
  import React, { isValidElement, useCallback } from 'react';
2
2
  import { Slot } from '../internal/slot';
3
- import { usePopupContext } from './popup-context';
3
+ import { usePopupContext } from './use-popup-context';
4
+
4
5
  /**
5
6
  * Wraps a single trigger element via `cloneElement`. Attaches aria
6
7
  * attributes, the toggle handler, and the anchor-name. `aria-haspopup`
@@ -1,6 +1,6 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
  import React, { useCallback, useId, useRef, useState } from 'react';
3
- import { PopupProvider } from './popup-context';
3
+ import { PopupProvider } from './popup-provider';
4
4
  /**
5
5
  * Popup compound: trigger + popover content.
6
6
  *
@@ -0,0 +1,12 @@
1
+ import { useContext } from 'react';
2
+ import { PopupContext } from './popup-context';
3
+
4
+ /**
5
+ * Returns the popup context if available, or `null` when used outside `<Popup>`.
6
+ *
7
+ * Used by `PopupContent` to support standalone usage (e.g. tooltip)
8
+ * where values are passed as props instead of coming from a compound component.
9
+ */
10
+ export function useMaybePopupContext() {
11
+ return useContext(PopupContext);
12
+ }
@@ -0,0 +1,15 @@
1
+ import { useContext } from 'react';
2
+ import { PopupContext } from './popup-context';
3
+
4
+ /**
5
+ * Returns the nearest `Popup` context value.
6
+ *
7
+ * Throws if called outside of a `<Popup>` compound component.
8
+ */
9
+ export function usePopupContext() {
10
+ var ctx = useContext(PopupContext);
11
+ if (ctx === null) {
12
+ throw new Error('@atlaskit/top-layer: Popup compound components must be used within <Popup>.');
13
+ }
14
+ return ctx;
15
+ }
@@ -102,7 +102,7 @@ function createToggleScheduler() {
102
102
  newState: newState
103
103
  });
104
104
 
105
- // Task queue (setTimeout) — browser fires toggle after microtasks drain, not during
105
+ // Task queue (setTimeout) - browser fires toggle after microtasks drain, not during
106
106
  setTimeout(function () {
107
107
  var entry = pending.get(element);
108
108
  if (!entry) {
@@ -172,7 +172,7 @@ function createDialogToggleScheduler() {
172
172
  };
173
173
  }
174
174
 
175
- // ─── Popover API ────────────────────────────────────────────────────────────
175
+ // Popover API
176
176
  // Spec: https://html.spec.whatwg.org/multipage/popover.html
177
177
 
178
178
  // `popover` attribute valid values. Empty / "auto" -> "auto"; unknown -> "manual".
@@ -535,7 +535,7 @@ if (typeof HTMLElement !== 'undefined') {
535
535
  if (isPopoverOpen({
536
536
  element: this
537
537
  })) {
538
- return; // already showing — no-op
538
+ return; // already showing - no-op
539
539
  }
540
540
 
541
541
  // sync, cancelable on show only
@@ -715,7 +715,7 @@ if (typeof HTMLElement !== 'undefined') {
715
715
  }
716
716
  }
717
717
 
718
- // ─── HTMLDialogElement ──────────────────────────────────────────────────────
718
+ // HTMLDialogElement
719
719
  // Spec: https://html.spec.whatwg.org/multipage/interactive-elements.html#the-dialog-element
720
720
 
721
721
  if (typeof HTMLDialogElement !== 'undefined') {
@@ -730,7 +730,7 @@ if (typeof HTMLDialogElement !== 'undefined') {
730
730
  }
731
731
  if (this.hasAttribute('open')) {
732
732
  if (this._isModal) {
733
- return; // already modal — no-op
733
+ return; // already modal - no-op
734
734
  }
735
735
  throw new DOMException("Failed to execute 'showModal' on 'HTMLDialogElement': ".concat(describeElement({
736
736
  element: this
@@ -754,7 +754,7 @@ if (typeof HTMLDialogElement !== 'undefined') {
754
754
  }
755
755
  if (typeof proto.show !== 'function') {
756
756
  proto.show = function show() {
757
- // Browser does not throw for disconnected elements on show — just no-op
757
+ // Browser does not throw for disconnected elements on show - just no-op
758
758
  if (!this.isConnected || this.hasAttribute('open')) {
759
759
  return;
760
760
  }
@@ -777,10 +777,10 @@ if (typeof HTMLDialogElement !== 'undefined') {
777
777
  if (typeof proto.close !== 'function') {
778
778
  proto.close = function close(returnValue) {
779
779
  if (!this.hasAttribute('open')) {
780
- return; // already closed — no-op
780
+ return; // already closed - no-op
781
781
  }
782
782
 
783
- // Sync beforetoggle (not cancelable) — matches browser behavior
783
+ // Sync beforetoggle (not cancelable) - matches browser behavior
784
784
  fireToggleEvent({
785
785
  element: this,
786
786
  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
  var originalResult = originalToBeVisible.call(this, element);
63
63
  var 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,
@@ -74,7 +74,7 @@ expect.extend({
74
74
  return originalResult;
75
75
  }
76
76
 
77
- // Original says not visible — override if nearest top-layer host is open.
77
+ // Original says not visible - override if nearest top-layer host is open.
78
78
  // jsdom may hide [popover] elements even when they are logically open.
79
79
  if (topLayerState === 'open') {
80
80
  return {
@@ -1 +1,2 @@
1
- export { useArrowNavigation, isAtCurrentMenuLevel } from './use-arrow-navigation';
1
+ export { useArrowNavigation } from './use-arrow-navigation';
2
+ export { isAtCurrentMenuLevel } from './is-at-current-menu-level';
@@ -0,0 +1,88 @@
1
+ var menuScope = '[role="menu"]';
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
+
21
+ /**
22
+ * Returns true if the element belongs to the current menu level of the
23
+ * container, i.e. it is NOT inside a nested `role="menu"` sub-container.
24
+ *
25
+ * Uses `element.closest('[role="menu"]')` to determine the nearest menu
26
+ * scope. If the nearest scope is the container's own `role="menu"` element,
27
+ * the element belongs to this level. If it is a different (nested) menu,
28
+ * the element belongs to a child level and should be excluded.
29
+ *
30
+ * Supports two container patterns:
31
+ *
32
+ * **1. Container has `role="menu"` directly** (preferred, used by avatar-group):
33
+ * ```
34
+ * <div ref={containerRef} role="menu">
35
+ * <button role="menuitem" /> ← isAtCurrentMenuLevel → true
36
+ * <div role="menu"> ← nested sub-menu
37
+ * <button role="menuitem" /> ← isAtCurrentMenuLevel → false
38
+ * </div>
39
+ * </div>
40
+ * ```
41
+ * Uses the simple check: `element.closest('[role="menu"]') === container`
42
+ *
43
+ * **2. Container is a wrapper without `role="menu"`** (used by dropdown-menu,
44
+ * where `MenuGroup` owns `role="menu"` but does not accept a ref):
45
+ * ```
46
+ * <div ref={containerRef}> ← wrapper (no role="menu")
47
+ * <MenuGroup role="menu">
48
+ * <button role="menuitem" /> ← isAtCurrentMenuLevel → true
49
+ * <div role="menu"> ← nested sub-menu
50
+ * <button role="menuitem" /> ← isAtCurrentMenuLevel → false
51
+ * </div>
52
+ * </MenuGroup>
53
+ * </div>
54
+ * ```
55
+ * Falls back to walking the DOM to check that the element's closest
56
+ * `role="menu"` is the container's own menu (not doubly nested).
57
+ *
58
+ * Ideally all consumers should use pattern 1 (place the ref directly on the
59
+ * `role="menu"` element). Pattern 2 exists because `@atlaskit/menu`'s
60
+ * `MenuGroup` does not currently accept a ref. If `MenuGroup` gains ref
61
+ * support in the future, dropdown-menu should switch to pattern 1 and the
62
+ * fallback path can be removed.
63
+ *
64
+ * Used both as a `TFocusableFilter` (to scope getNextFocusable etc.) and as
65
+ * a guard to prevent parent menu handlers from acting on events that
66
+ * belong to a nested menu.
67
+ */
68
+ export function isAtCurrentMenuLevel(element, container) {
69
+ var closestMenu = element.closest(menuScope);
70
+
71
+ // Container itself has role="menu". Element belongs to this level
72
+ // if its closest menu is the container.
73
+ if (container.getAttribute('role') === 'menu') {
74
+ return closestMenu === container;
75
+ }
76
+
77
+ // Container is a wrapper without role="menu" (e.g. dropdown-menu
78
+ // wraps a MenuGroup). The element belongs to the top level if its
79
+ // closest role="menu" ancestor is a direct child of the container,
80
+ // i.e. there is no nested role="menu" between them.
81
+ if (closestMenu === null) {
82
+ return true;
83
+ }
84
+
85
+ // Walk up from the closest menu to see if it is "owned" by this
86
+ // container without passing through another role="menu" first.
87
+ return reachesContainerWithoutNestedMenu(closestMenu.parentElement, container);
88
+ }
@@ -5,86 +5,6 @@ import { KEY_DOWN, KEY_END, KEY_HOME, KEY_TAB, KEY_UP } from '@atlaskit/ds-lib/k
5
5
  import { getFirstFocusable, getLastFocusable, getNextFocusable } from '../focus';
6
6
  var menuScope = '[role="menu"]';
7
7
 
8
- /**
9
- * Returns true if the element belongs to the current menu level of the
10
- * container, i.e. it is NOT inside a nested `role="menu"` sub-container.
11
- *
12
- * Uses `element.closest('[role="menu"]')` to determine the nearest menu
13
- * scope. If the nearest scope is the container's own `role="menu"` element,
14
- * the element belongs to this level. If it is a different (nested) menu,
15
- * the element belongs to a child level and should be excluded.
16
- *
17
- * Supports two container patterns:
18
- *
19
- * **1. Container has `role="menu"` directly** (preferred, used by avatar-group):
20
- * ```
21
- * <div ref={containerRef} role="menu">
22
- * <button role="menuitem" /> ← isAtCurrentMenuLevel → true
23
- * <div role="menu"> ← nested sub-menu
24
- * <button role="menuitem" /> ← isAtCurrentMenuLevel → false
25
- * </div>
26
- * </div>
27
- * ```
28
- * Uses the simple check: `element.closest('[role="menu"]') === container`
29
- *
30
- * **2. Container is a wrapper without `role="menu"`** (used by dropdown-menu,
31
- * where `MenuGroup` owns `role="menu"` but does not accept a ref):
32
- * ```
33
- * <div ref={containerRef}> ← wrapper (no role="menu")
34
- * <MenuGroup role="menu">
35
- * <button role="menuitem" /> ← isAtCurrentMenuLevel → true
36
- * <div role="menu"> ← nested sub-menu
37
- * <button role="menuitem" /> ← isAtCurrentMenuLevel → false
38
- * </div>
39
- * </MenuGroup>
40
- * </div>
41
- * ```
42
- * Falls back to walking the DOM to check that the element's closest
43
- * `role="menu"` is the container's own menu (not doubly nested).
44
- *
45
- * Ideally all consumers should use pattern 1 (place the ref directly on the
46
- * `role="menu"` element). Pattern 2 exists because `@atlaskit/menu`'s
47
- * `MenuGroup` does not currently accept a ref. If `MenuGroup` gains ref
48
- * support in the future, dropdown-menu should switch to pattern 1 and the
49
- * fallback path can be removed.
50
- *
51
- * Used both as a `TFocusableFilter` (to scope getNextFocusable etc.) and as
52
- * a guard to prevent parent menu handlers from acting on events that
53
- * belong to a nested menu.
54
- */
55
- export function isAtCurrentMenuLevel(element, container) {
56
- var closestMenu = element.closest(menuScope);
57
-
58
- // Container itself has role="menu". Element belongs to this level
59
- // if its closest menu is the container.
60
- if (container.getAttribute('role') === 'menu') {
61
- return closestMenu === container;
62
- }
63
-
64
- // Container is a wrapper without role="menu" (e.g. dropdown-menu
65
- // wraps a MenuGroup). The element belongs to the top level if its
66
- // closest role="menu" ancestor is a direct child of the container,
67
- // i.e. there is no nested role="menu" between them.
68
- if (closestMenu === null) {
69
- return true;
70
- }
71
-
72
- // Walk up from the closest menu to see if it is "owned" by this
73
- // container without passing through another role="menu" first.
74
- var parent = closestMenu.parentElement;
75
- while (parent && parent !== container) {
76
- if (parent.getAttribute('role') === 'menu') {
77
- // There is a parent menu between the closest menu and the
78
- // container, so the element is in a nested sub-menu.
79
- return false;
80
- }
81
- parent = parent.parentElement;
82
- }
83
-
84
- // The closest menu is directly inside the container (no nesting).
85
- return parent === container;
86
- }
87
-
88
8
  /**
89
9
  * Args for `useArrowNavigation`.
90
10
  *
@@ -135,7 +55,6 @@ export function isAtCurrentMenuLevel(element, container) {
135
55
  * });
136
56
  * ```
137
57
  */
138
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
139
58
  export function useArrowNavigation(_ref) {
140
59
  var containerRef = _ref.containerRef,
141
60
  onClose = _ref.onClose,
@@ -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
@@ -46,7 +46,7 @@ export function useSimpleLightDismiss(_ref) {
46
46
  // (trigger onClick → setIsOpen(true) → React render → useEffect).
47
47
  // By the time this effect runs, the opening click has finished
48
48
  // bubbling. A capture-phase listener added now cannot retroactively
49
- // fire for that event — it only fires for *future* clicks.
49
+ // fire for that event - it only fires for *future* clicks.
50
50
  //
51
51
  // This avoids the need for timestamp guards or deferred binding.
52
52
  // eslint-disable-next-line @atlaskit/platform/no-direct-document-usage -- binding to document for light dismiss
@@ -58,7 +58,7 @@ export function useSimpleLightDismiss(_ref) {
58
58
  return;
59
59
  }
60
60
 
61
- // If the click target is inside the popover, don't dismiss.
61
+ // If the click target is inside the popover, do not dismiss.
62
62
  if (event.target instanceof Node && el.contains(event.target)) {
63
63
  return;
64
64
  }
@@ -3,7 +3,7 @@ import type { TDialogCloseReason } from './types';
3
3
  * Creates a synthetic DOM event from a `TDialogCloseReason`.
4
4
  *
5
5
  * Useful when bridging the Dialog primitive's `onClose({ reason })` callback
6
- * to a legacy API that expects a `KeyboardEvent` or `MouseEvent` — for example,
6
+ * to a legacy API that expects a `KeyboardEvent` or `MouseEvent` - for example,
7
7
  * `@atlaskit/modal-dialog`'s `onClose(event, analyticsEvent)` contract.
8
8
  *
9
9
  * - `'escape'` → `KeyboardEvent('keydown', { key: 'Escape' })`
@@ -49,6 +49,14 @@ type TDialogBaseProps = {
49
49
  * Additional inline styles applied to the `<dialog>` element.
50
50
  *
51
51
  * Use for custom width, height, transform, or other overrides.
52
+ *
53
+ * Rule deviation: the house rules ban unbounded `style` props on
54
+ * components. `Dialog` is a low-level primitive that intentionally has
55
+ * no visual opinions of its own; consumers such as `@atlaskit/modal-dialog`
56
+ * must be able to set width, height, and transforms on the native
57
+ * `<dialog>` element. Removing this prop would be a breaking change
58
+ * and is tracked separately. Keep until an xcss-based replacement
59
+ * exists on the primitive.
52
60
  */
53
61
  style?: CSSProperties;
54
62
  /**
@@ -1,2 +1,3 @@
1
- export { useArrowNavigation, isAtCurrentMenuLevel } from '../use-arrow-navigation';
1
+ export { useArrowNavigation } from '../use-arrow-navigation';
2
2
  export type { TUseArrowNavigationArgs } from '../use-arrow-navigation';
3
+ export { isAtCurrentMenuLevel } from '../use-arrow-navigation/is-at-current-menu-level';
@@ -0,0 +1,21 @@
1
+ import { type TPlacementOptions } from '../internal/resolve-placement';
2
+ /**
3
+ * Resolves placement options to CSS `position-area` syntax.
4
+ *
5
+ * The `align` field represents the *visual* alignment:
6
+ * - `align: 'start'` means "aligned to the trigger's start edge" (left in LTR for block axis)
7
+ * - `align: 'end'` means "aligned to the trigger's end edge"
8
+ * - `align: 'center'` means centered (single-axis position-area)
9
+ *
10
+ * CSS `position-area` uses `span-*` keywords which indicate the *expansion direction*.
11
+ * Visual start-alignment requires `span-{cross-axis}-end` (expand toward end = start-aligned).
12
+ * This function handles the inversion internally.
13
+ *
14
+ * @example
15
+ * placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'center' } }) // → 'block-end'
16
+ * placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'start' } }) // → 'block-end span-inline-end'
17
+ * placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'end' } }) // → 'block-end span-inline-start'
18
+ */
19
+ export declare function placementToPositionArea({ placement }: {
20
+ placement: TPlacementOptions;
21
+ }): string;
@@ -0,0 +1,36 @@
1
+ import { type TPlacementOptions } from '../internal/resolve-placement';
2
+ /**
3
+ * Returns `position-try-fallbacks` value based on placement.
4
+ *
5
+ * For centered placements, includes cross-axis aligned position-area
6
+ * values so the browser can shift the popover along the cross-axis
7
+ * when the centered position would overflow the viewport edge.
8
+ *
9
+ * Fallback order for centered placements (e.g. `block-end`):
10
+ * 1. Same edge, start-aligned (shift for near-edge overflow)
11
+ * 2. Same edge, end-aligned (shift for far-edge overflow)
12
+ * 3. Flipped edge, centered
13
+ * 4. Flipped edge, start-aligned
14
+ * 5. Flipped edge, end-aligned
15
+ *
16
+ * For aligned placements (start/end), includes the same-edge centered
17
+ * position as fallbacks so the browser can try centering when the aligned
18
+ * position would overflow, before flipping to the opposite edge.
19
+ *
20
+ * **Why `flip-inline flip-block` (or `flip-block flip-inline`) is included:**
21
+ *
22
+ * When a popup is in a viewport corner (e.g. inline-end align-end at the
23
+ * top-right), flipping only the primary axis (`flip-inline`) moves the popup
24
+ * to the left but keeps the same cross-axis span direction (e.g. upward),
25
+ * which is still off-screen. The combined keyword `flip-inline flip-block`
26
+ * mirrors the popup diagonally. It flips BOTH the position-area AND both
27
+ * inline and block margins simultaneously, placing the popup at the
28
+ * diagonally opposite corner where there is always space.
29
+ *
30
+ * Named `position-area` entries (e.g. `inline-start span-block-end`) in
31
+ * `position-try-fallbacks` do NOT update margins, so only the `flip-*`
32
+ * tactic keywords correctly flip the gap margin along with the position.
33
+ */
34
+ export declare function placementToTryFallbacks({ placement }: {
35
+ placement: TPlacementOptions;
36
+ }): string;
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * The result is cached after the first call via `once`. This avoids
7
7
  * calling `matchMedia` on every render. The trade-off is that if a user
8
- * toggles the OS reduced-motion setting mid-session, the change won't
8
+ * toggles the OS reduced-motion setting mid-session, the change will not
9
9
  * take effect until the next page load. This is acceptable because
10
10
  * toggling this system-level preference mid-session is extremely rare,
11
11
  * and a page refresh is a reasonable expectation for system accessibility