@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
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/top-layer
2
2
 
3
+ ## 0.12.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [`7210e88c14f95`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/7210e88c14f95) -
8
+ Internal: align package with house authoring rules (style-only refactors).
9
+
10
+ ## 0.12.1
11
+
12
+ ### Patch Changes
13
+
14
+ - [`c3913985e2415`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/c3913985e2415) -
15
+ Internal: remove unused `src/arrow/` module. The `arrow()` preset and `TArrowPreset` type were
16
+ never exported from `package.json` and had no consumers in the codebase.
17
+
3
18
  ## 0.12.0
4
19
 
5
20
  ### Minor Changes
@@ -9,7 +9,7 @@ exports.fade = fade;
9
9
  exports.scaleAndFade = scaleAndFade;
10
10
  exports.slideAndFade = slideAndFade;
11
11
  var _resolvePlacement = require("../internal/resolve-placement");
12
- // ── slideAndFade ──
12
+ // slideAndFade
13
13
 
14
14
  function getSlideAndFadeProperties(_ref) {
15
15
  var placement = _ref.placement,
@@ -91,7 +91,7 @@ function slideAndFade(options) {
91
91
  };
92
92
  }
93
93
 
94
- // ── fade ──
94
+ // fade
95
95
 
96
96
  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";
97
97
 
@@ -117,7 +117,7 @@ function fade() {
117
117
  };
118
118
  }
119
119
 
120
- // ── scaleAndFade ──
120
+ // scaleAndFade
121
121
 
122
122
  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";
123
123
 
@@ -147,7 +147,7 @@ function scaleAndFade() {
147
147
  // Dialog presets
148
148
  // ══════════════════════════════════════════════════════════════════════════════
149
149
 
150
- // ── dialogSlideUpAndFade ──
150
+ // dialogSlideUpAndFade
151
151
 
152
152
  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";
153
153
 
@@ -183,7 +183,7 @@ function dialogSlideUpAndFade(options) {
183
183
  };
184
184
  }
185
185
 
186
- // ── dialogFade ──
186
+ // dialogFade
187
187
 
188
188
  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";
189
189
 
@@ -8,7 +8,7 @@ exports.createCloseEvent = createCloseEvent;
8
8
  * Creates a synthetic DOM event from a `TDialogCloseReason`.
9
9
  *
10
10
  * Useful when bridging the Dialog primitive's `onClose({ reason })` callback
11
- * to a legacy API that expects a `KeyboardEvent` or `MouseEvent` — for example,
11
+ * to a legacy API that expects a `KeyboardEvent` or `MouseEvent` - for example,
12
12
  * `@atlaskit/modal-dialog`'s `onClose(event, analyticsEvent)` contract.
13
13
  *
14
14
  * - `'escape'` → `KeyboardEvent('keydown', { key: 'Escape' })`
@@ -58,7 +58,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
58
58
  var ownRef = (0, _react.useRef)(null);
59
59
  var combinedRef = (0, _mergeRefs.default)([ownRef, ref]);
60
60
 
61
- // ── Animation lifecycle ──
61
+ // Animation lifecycle
62
62
  var _useAnimatedVisibilit = (0, _useAnimatedVisibility.useAnimatedVisibility)({
63
63
  isOpen: isOpen,
64
64
  animate: animate,
@@ -68,7 +68,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
68
68
  showChildren = _useAnimatedVisibilit.showChildren,
69
69
  preset = _useAnimatedVisibilit.preset;
70
70
 
71
- // ── Focus wrap ──
71
+ // Focus wrap
72
72
  // Native <dialog>.showModal() traps focus but wraps through <body> at
73
73
  // the boundary (A → B → C → body → A). This hook intercepts Tab to
74
74
  // wrap directly (A → B → C → A), matching the WAI-ARIA APG pattern.
@@ -77,7 +77,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
77
77
  role: 'dialog'
78
78
  });
79
79
 
80
- // ── Open layer observer registration ──
80
+ // Open layer observer registration
81
81
  // Notifies the open layer observer so app-coordination features
82
82
  // (open-count subscriptions) work with top-layer dialogs.
83
83
  (0, _openLayerObserver.useNotifyOpenLayerObserver)({
@@ -108,7 +108,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
108
108
  }
109
109
  }, [isOpen]);
110
110
 
111
- // ── Handle native Escape (cancel event) ──
111
+ // Handle native Escape (cancel event)
112
112
  var handleCancel = (0, _react.useCallback)(function (event) {
113
113
  event.preventDefault();
114
114
  onClose({
@@ -116,7 +116,7 @@ var Dialog = exports.Dialog = /*#__PURE__*/(0, _react.forwardRef)(function Dialo
116
116
  });
117
117
  }, [onClose]);
118
118
 
119
- // ── Handle backdrop click ──
119
+ // Handle backdrop click
120
120
  // Attached via bind-event-listener rather than a React prop so we avoid
121
121
  // a11y lint suppressions on the <dialog> element.
122
122
  // Keyboard dismiss is already handled natively (Escape → onCancel above).
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "isAtCurrentMenuLevel", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _useArrowNavigation.isAtCurrentMenuLevel;
9
+ return _isAtCurrentMenuLevel.isAtCurrentMenuLevel;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "useArrowNavigation", {
@@ -15,4 +15,5 @@ Object.defineProperty(exports, "useArrowNavigation", {
15
15
  return _useArrowNavigation.useArrowNavigation;
16
16
  }
17
17
  });
18
- var _useArrowNavigation = require("../use-arrow-navigation");
18
+ var _useArrowNavigation = require("../use-arrow-navigation");
19
+ var _isAtCurrentMenuLevel = require("../use-arrow-navigation/is-at-current-menu-level");
@@ -10,7 +10,7 @@ exports.ensurePresetStyles = ensurePresetStyles;
10
10
  * Each preset's CSS is injected at most once into `<head>`.
11
11
  * Shared by both PopoverContent and DialogContent.
12
12
  *
13
- * Note: injected `<style>` elements and the tracking Set are append-only —
13
+ * Note: injected `<style>` elements and the tracking Set are append-only -
14
14
  * they are never removed. This is intentional: the number of distinct
15
15
  * presets is bounded (handful of animation presets), so the
16
16
  * memory footprint is negligible. Removing styles would risk breaking
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.placementToPositionArea = placementToPositionArea;
7
+ var _resolvePlacement = require("./resolve-placement");
8
+ /**
9
+ * Resolves placement options to CSS `position-area` syntax.
10
+ *
11
+ * The `align` field represents the *visual* alignment:
12
+ * - `align: 'start'` means "aligned to the trigger's start edge" (left in LTR for block axis)
13
+ * - `align: 'end'` means "aligned to the trigger's end edge"
14
+ * - `align: 'center'` means centered (single-axis position-area)
15
+ *
16
+ * CSS `position-area` uses `span-*` keywords which indicate the *expansion direction*.
17
+ * Visual start-alignment requires `span-{cross-axis}-end` (expand toward end = start-aligned).
18
+ * This function handles the inversion internally.
19
+ *
20
+ * @example
21
+ * placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'center' } }) // → 'block-end'
22
+ * placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'start' } }) // → 'block-end span-inline-end'
23
+ * placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'end' } }) // → 'block-end span-inline-start'
24
+ */
25
+ function placementToPositionArea(_ref) {
26
+ var placement = _ref.placement;
27
+ var _getPlacement = (0, _resolvePlacement.getPlacement)({
28
+ placement: placement
29
+ }),
30
+ axis = _getPlacement.axis,
31
+ edge = _getPlacement.edge,
32
+ align = _getPlacement.align;
33
+ var edgeValue = "".concat(axis, "-").concat(edge);
34
+ if (align === 'center') {
35
+ return edgeValue;
36
+ }
37
+
38
+ // Cross-axis name: block ↔ inline
39
+ var crossAxis = axis === 'block' ? 'inline' : 'block';
40
+ // Invert align → CSS span direction: visual 'start' → span toward 'end'
41
+ var spanDir = align === 'start' ? 'end' : 'start';
42
+ return "".concat(edgeValue, " span-").concat(crossAxis, "-").concat(spanDir);
43
+ }
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.placementToTryFallbacks = placementToTryFallbacks;
8
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
+ var _resolvePlacement = require("./resolve-placement");
10
+ /**
11
+ * Returns `position-try-fallbacks` value based on placement.
12
+ *
13
+ * For centered placements, includes cross-axis aligned position-area
14
+ * values so the browser can shift the popover along the cross-axis
15
+ * when the centered position would overflow the viewport edge.
16
+ *
17
+ * Fallback order for centered placements (e.g. `block-end`):
18
+ * 1. Same edge, start-aligned (shift for near-edge overflow)
19
+ * 2. Same edge, end-aligned (shift for far-edge overflow)
20
+ * 3. Flipped edge, centered
21
+ * 4. Flipped edge, start-aligned
22
+ * 5. Flipped edge, end-aligned
23
+ *
24
+ * For aligned placements (start/end), includes the same-edge centered
25
+ * position as fallbacks so the browser can try centering when the aligned
26
+ * position would overflow, before flipping to the opposite edge.
27
+ *
28
+ * **Why `flip-inline flip-block` (or `flip-block flip-inline`) is included:**
29
+ *
30
+ * When a popup is in a viewport corner (e.g. inline-end align-end at the
31
+ * top-right), flipping only the primary axis (`flip-inline`) moves the popup
32
+ * to the left but keeps the same cross-axis span direction (e.g. upward),
33
+ * which is still off-screen. The combined keyword `flip-inline flip-block`
34
+ * mirrors the popup diagonally. It flips BOTH the position-area AND both
35
+ * inline and block margins simultaneously, placing the popup at the
36
+ * diagonally opposite corner where there is always space.
37
+ *
38
+ * Named `position-area` entries (e.g. `inline-start span-block-end`) in
39
+ * `position-try-fallbacks` do NOT update margins, so only the `flip-*`
40
+ * tactic keywords correctly flip the gap margin along with the position.
41
+ */
42
+ function placementToTryFallbacks(_ref) {
43
+ var placement = _ref.placement;
44
+ var _getPlacement = (0, _resolvePlacement.getPlacement)({
45
+ placement: placement
46
+ }),
47
+ axis = _getPlacement.axis,
48
+ edge = _getPlacement.edge,
49
+ align = _getPlacement.align;
50
+ var crossAxis = axis === 'block' ? 'inline' : 'block';
51
+ var flippedEdge = edge === 'start' ? 'end' : 'start';
52
+ var sameEdge = "".concat(axis, "-").concat(edge);
53
+ var oppositeEdge = "".concat(axis, "-").concat(flippedEdge);
54
+ var flipKeyword = axis === 'block' ? 'flip-block' : 'flip-inline';
55
+ var flipCrossKeyword = axis === 'block' ? 'flip-inline' : 'flip-block';
56
+
57
+ // Single algorithm: produce the shift list against any base alignment.
58
+ // For `align: 'start'` the "near" shift expands toward `end`; for
59
+ // `align: 'end'` it expands toward `start`; for `align: 'center'`
60
+ // either order is symmetric (we use end-then-start to match the
61
+ // historical fallback list).
62
+ function shifts(baseAlign, edgeKey) {
63
+ if (baseAlign === 'center') {
64
+ return ["".concat(edgeKey, " span-").concat(crossAxis, "-end"), "".concat(edgeKey, " span-").concat(crossAxis, "-start")];
65
+ }
66
+ var near = baseAlign === 'start' ? 'end' : 'start';
67
+ var far = baseAlign === 'start' ? 'start' : 'end';
68
+ return ["".concat(edgeKey, " span-").concat(crossAxis, "-").concat(near), edgeKey, "".concat(edgeKey, " span-").concat(crossAxis, "-").concat(far)];
69
+ }
70
+ if (align !== 'center') {
71
+ // Aligned (start/end): try same-edge shifts, then single-axis flip,
72
+ // then diagonal flip for corner overflow, then opposite-edge shifts.
73
+ // Legacy Popper fallback ordering for e.g. bottom-start:
74
+ // [bottom, bottom-end, top-start, top, top-end, auto].
75
+ return [].concat((0, _toConsumableArray2.default)(shifts(align, sameEdge)), [flipKeyword, "".concat(flipKeyword, " ").concat(flipCrossKeyword)], (0, _toConsumableArray2.default)(shifts(align, oppositeEdge))).join(', ');
76
+ }
77
+
78
+ // Centered: same-edge shifts, single-axis flip, opposite-edge shifts.
79
+ // Diagonal flip is unnecessary because centered placements expand
80
+ // equally in both cross-axis directions.
81
+ return [].concat((0, _toConsumableArray2.default)(shifts('center', sameEdge)), [flipKeyword], (0, _toConsumableArray2.default)(shifts('center', oppositeEdge))).join(', ');
82
+ }
@@ -13,7 +13,7 @@ var _once = _interopRequireDefault(require("@atlaskit/ds-lib/once"));
13
13
  *
14
14
  * The result is cached after the first call via `once`. This avoids
15
15
  * calling `matchMedia` on every render. The trade-off is that if a user
16
- * toggles the OS reduced-motion setting mid-session, the change won't
16
+ * toggles the OS reduced-motion setting mid-session, the change will not
17
17
  * take effect until the next page load. This is acceptable because
18
18
  * toggling this system-level preference mid-session is extremely rare,
19
19
  * and a page refresh is a reasonable expectation for system accessibility
@@ -30,8 +30,8 @@ var DEFAULT_GAP = "var(--ds-space-100, 8px)";
30
30
  * CSS length string (e.g. `token('space.100')`).
31
31
  *
32
32
  * The two offset axes are named for clarity at the call site:
33
- * - `gap` — distance away from the trigger along the placement axis
34
- * - `crossAxisShift` — nudge along the trigger edge (perpendicular to the placement axis)
33
+ * - `gap` - distance away from the trigger along the placement axis
34
+ * - `crossAxisShift` - nudge along the trigger edge (perpendicular to the placement axis)
35
35
  */
36
36
 
37
37
  /**
@@ -29,7 +29,7 @@ exports.shouldFocusIntoPopover = shouldFocusIntoPopover;
29
29
  * (e.g. a combobox labels its listbox, tooltip content IS the accessible name).
30
30
  */
31
31
 
32
- // ── Shared ARIA role discrimination types ──
32
+ // Shared ARIA role discrimination types
33
33
  //
34
34
  // These encode the WCAG 4.1.2 constraint: roles like `dialog`, `alertdialog`,
35
35
  // and `menu` MUST have an accessible name (either `label` or `labelledBy`).
@@ -32,14 +32,14 @@ function isSlotChild(child) {
32
32
  * Merges props (including ref) onto a single React element child.
33
33
  *
34
34
  * A safer alternative to raw `cloneElement` that:
35
- * 1. Guards with `isValidElement` — non-element children (strings,
35
+ * 1. Guards with `isValidElement` - non-element children (strings,
36
36
  * fragments, null) are returned as-is instead of crashing.
37
37
  * 2. Merges refs via `mergeRefs` so both the caller's ref and the
38
38
  * child's existing ref are honoured.
39
39
  * 3. Spreads any additional props (ARIA attributes, event handlers, etc.)
40
40
  * onto the child element.
41
41
  *
42
- * Event handlers (e.g. `onClick`) are **not** auto-merged — the caller's
42
+ * Event handlers (e.g. `onClick`) are **not** auto-merged - the caller's
43
43
  * handler replaces the child's. Compose handlers before passing them in.
44
44
  *
45
45
  * @example
@@ -52,7 +52,7 @@ function isSlotChild(child) {
52
52
  var Slot = exports.Slot = /*#__PURE__*/(0, _react.forwardRef)(function Slot(slotProps, ref) {
53
53
  var rawChildren = slotProps.children,
54
54
  props = (0, _objectWithoutProperties2.default)(slotProps, _excluded);
55
- // `SlotProps` intersects `Record<string, unknown>`, so `children` is typed as `unknown`.
55
+ // `TSlotProps` intersects `Record<string, unknown>`, so `children` is typed as `unknown`.
56
56
  var children = rawChildren;
57
57
  if (!isSlotChild(children)) {
58
58
  return children;
@@ -4,18 +4,15 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.placementToPositionArea = placementToPositionArea;
8
- exports.placementToTryFallbacks = placementToTryFallbacks;
9
7
  exports.useAnchorPosition = useAnchorPosition;
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
12
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
8
  var _react = require("react");
14
9
  var _bindEventListener = require("bind-event-listener");
15
10
  var _rafSchd = _interopRequireDefault(require("raf-schd"));
16
11
  var _once = _interopRequireDefault(require("@atlaskit/ds-lib/once"));
17
12
  var _anchorPositioningFallback = require("./anchor-positioning-fallback");
18
13
  var _combine = require("./combine");
14
+ var _placementToPositionArea = require("./placement-to-position-area");
15
+ var _placementToTryFallbacks = require("./placement-to-try-fallbacks");
19
16
  var _resolveCssLengthToPixels = require("./resolve-css-length-to-pixels");
20
17
  var _resolvePlacement = require("./resolve-placement");
21
18
  var _setStyle = require("./set-style");
@@ -38,137 +35,15 @@ var _setStyle = require("./set-style");
38
35
  // from `./resolve-placement` so search-and-jump lands at the source of truth.
39
36
 
40
37
  /**
41
- * Module-scope no-op `ResizeObserver` used in non-DOM jest environments where
38
+ * Module-scope no-op `ResizeObserver` stub used in non-DOM jest environments where
42
39
  * `ResizeObserver` is `undefined`. Hoisted out of the effect to avoid
43
- * allocating a new class declaration on every run.
40
+ * re-allocating on every run.
44
41
  */
45
- var NoopResizeObserver = /*#__PURE__*/function () {
46
- function NoopResizeObserver() {
47
- (0, _classCallCheck2.default)(this, NoopResizeObserver);
48
- }
49
- return (0, _createClass2.default)(NoopResizeObserver, [{
50
- key: "observe",
51
- value: function observe() {}
52
- }, {
53
- key: "unobserve",
54
- value: function unobserve() {}
55
- }, {
56
- key: "disconnect",
57
- value: function disconnect() {}
58
- }]);
59
- }();
60
-
61
- /**
62
- * Resolves placement options to CSS `position-area` syntax.
63
- *
64
- * The `align` field represents the *visual* alignment:
65
- * - `align: 'start'` means "aligned to the trigger's start edge" (left in LTR for block axis)
66
- * - `align: 'end'` means "aligned to the trigger's end edge"
67
- * - `align: 'center'` means centered (single-axis position-area)
68
- *
69
- * CSS `position-area` uses `span-*` keywords which indicate the *expansion direction*.
70
- * Visual start-alignment requires `span-{cross-axis}-end` (expand toward end = start-aligned).
71
- * This function handles the inversion internally.
72
- *
73
- * @example
74
- * placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'center' } }) // → 'block-end'
75
- * placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'start' } }) // → 'block-end span-inline-end'
76
- * placementToPositionArea({ placement: { axis: 'block', edge: 'end', align: 'end' } }) // → 'block-end span-inline-start'
77
- */
78
- function placementToPositionArea(_ref) {
79
- var placement = _ref.placement;
80
- var _getPlacement = (0, _resolvePlacement.getPlacement)({
81
- placement: placement
82
- }),
83
- axis = _getPlacement.axis,
84
- edge = _getPlacement.edge,
85
- align = _getPlacement.align;
86
- var edgeValue = "".concat(axis, "-").concat(edge);
87
- if (align === 'center') {
88
- return edgeValue;
89
- }
90
-
91
- // Cross-axis name: block ↔ inline
92
- var crossAxis = axis === 'block' ? 'inline' : 'block';
93
- // Invert align → CSS span direction: visual 'start' → span toward 'end'
94
- var spanDir = align === 'start' ? 'end' : 'start';
95
- return "".concat(edgeValue, " span-").concat(crossAxis, "-").concat(spanDir);
96
- }
97
-
98
- /**
99
- * Returns `position-try-fallbacks` value based on placement.
100
- *
101
- * For centered placements, includes cross-axis aligned position-area
102
- * values so the browser can shift the popover along the cross-axis
103
- * when the centered position would overflow the viewport edge.
104
- *
105
- * Fallback order for centered placements (e.g. `block-end`):
106
- * 1. Same edge, start-aligned (shift for near-edge overflow)
107
- * 2. Same edge, end-aligned (shift for far-edge overflow)
108
- * 3. Flipped edge, centered
109
- * 4. Flipped edge, start-aligned
110
- * 5. Flipped edge, end-aligned
111
- *
112
- * For aligned placements (start/end), includes the same-edge centered
113
- * position as fallbacks so the browser can try centering when the aligned
114
- * position would overflow, before flipping to the opposite edge.
115
- *
116
- * **Why `flip-inline flip-block` (or `flip-block flip-inline`) is included:**
117
- *
118
- * When a popup is in a viewport corner (e.g. inline-end align-end at the
119
- * top-right), flipping only the primary axis (`flip-inline`) moves the popup
120
- * to the left but keeps the same cross-axis span direction (e.g. upward),
121
- * which is still off-screen. The combined keyword `flip-inline flip-block`
122
- * mirrors the popup diagonally. It flips BOTH the position-area AND both
123
- * inline and block margins simultaneously, placing the popup at the
124
- * diagonally opposite corner where there is always space.
125
- *
126
- * Named `position-area` entries (e.g. `inline-start span-block-end`) in
127
- * `position-try-fallbacks` do NOT update margins, so only the `flip-*`
128
- * tactic keywords correctly flip the gap margin along with the position.
129
- */
130
- // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
131
- function placementToTryFallbacks(_ref2) {
132
- var placement = _ref2.placement;
133
- var _getPlacement2 = (0, _resolvePlacement.getPlacement)({
134
- placement: placement
135
- }),
136
- axis = _getPlacement2.axis,
137
- edge = _getPlacement2.edge,
138
- align = _getPlacement2.align;
139
- var crossAxis = axis === 'block' ? 'inline' : 'block';
140
- var flippedEdge = edge === 'start' ? 'end' : 'start';
141
- var sameEdge = "".concat(axis, "-").concat(edge);
142
- var oppositeEdge = "".concat(axis, "-").concat(flippedEdge);
143
- var flipKeyword = axis === 'block' ? 'flip-block' : 'flip-inline';
144
- var flipCrossKeyword = axis === 'block' ? 'flip-inline' : 'flip-block';
145
-
146
- // Single algorithm: produce the shift list against any base alignment.
147
- // For `align: 'start'` the "near" shift expands toward `end`; for
148
- // `align: 'end'` it expands toward `start`; for `align: 'center'`
149
- // either order is symmetric (we use end-then-start to match the
150
- // historical fallback list).
151
- function shifts(baseAlign, edgeKey) {
152
- if (baseAlign === 'center') {
153
- return ["".concat(edgeKey, " span-").concat(crossAxis, "-end"), "".concat(edgeKey, " span-").concat(crossAxis, "-start")];
154
- }
155
- var near = baseAlign === 'start' ? 'end' : 'start';
156
- var far = baseAlign === 'start' ? 'start' : 'end';
157
- return ["".concat(edgeKey, " span-").concat(crossAxis, "-").concat(near), edgeKey, "".concat(edgeKey, " span-").concat(crossAxis, "-").concat(far)];
158
- }
159
- if (align !== 'center') {
160
- // Aligned (start/end): try same-edge shifts, then single-axis flip,
161
- // then diagonal flip for corner overflow, then opposite-edge shifts.
162
- // Legacy Popper fallback ordering for e.g. bottom-start:
163
- // [bottom, bottom-end, top-start, top, top-end, auto].
164
- return [].concat((0, _toConsumableArray2.default)(shifts(align, sameEdge)), [flipKeyword, "".concat(flipKeyword, " ").concat(flipCrossKeyword)], (0, _toConsumableArray2.default)(shifts(align, oppositeEdge))).join(', ');
165
- }
166
-
167
- // Centered: same-edge shifts, single-axis flip, opposite-edge shifts.
168
- // Diagonal flip is unnecessary because centered placements expand
169
- // equally in both cross-axis directions.
170
- return [].concat((0, _toConsumableArray2.default)(shifts('center', sameEdge)), [flipKeyword], (0, _toConsumableArray2.default)(shifts('center', oppositeEdge))).join(', ');
171
- }
42
+ var noopResizeObserver = {
43
+ observe: function observe() {},
44
+ unobserve: function unobserve() {},
45
+ disconnect: function disconnect() {}
46
+ };
172
47
 
173
48
  /**
174
49
  * Returns true when the popover is currently open. Wrapped because the
@@ -201,9 +76,9 @@ var supportsAnchorPositioning = (0, _once.default)(function () {
201
76
  * For example, a `block-end` placement (popover below) gets
202
77
  * `margin-block-start: 8px` to push it away from the trigger's bottom edge.
203
78
  */
204
- function edgeMargin(_ref3) {
205
- var placement = _ref3.placement,
206
- offset = _ref3.offset;
79
+ function edgeMargin(_ref) {
80
+ var placement = _ref.placement,
81
+ offset = _ref.offset;
207
82
  var axis = placement.axis,
208
83
  edge = placement.edge;
209
84
  var value = offset;
@@ -244,10 +119,10 @@ function edgeMargin(_ref3) {
244
119
  * positive), `align: 'center'` uses START. Margin on the un-anchored side
245
120
  * has no effect under CSS Anchor Positioning.
246
121
  */
247
- function crossAxisShiftMargin(_ref4) {
248
- var placement = _ref4.placement,
249
- crossAxisShiftCssValue = _ref4.crossAxisShiftCssValue,
250
- direction = _ref4.direction;
122
+ function crossAxisShiftMargin(_ref2) {
123
+ var placement = _ref2.placement,
124
+ crossAxisShiftCssValue = _ref2.crossAxisShiftCssValue,
125
+ direction = _ref2.direction;
251
126
  var axis = placement.axis,
252
127
  align = placement.align;
253
128
  var directionSign = direction === 'forwards' ? 1 : -1;
@@ -326,13 +201,13 @@ function useStablePlacement(placement) {
326
201
  * placement shape is unchanged.
327
202
  */
328
203
  // eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
329
- function useAnchorPosition(_ref5) {
330
- var anchorRef = _ref5.anchorRef,
331
- popoverRef = _ref5.popoverRef,
332
- _ref5$placement = _ref5.placement,
333
- placement = _ref5$placement === void 0 ? {} : _ref5$placement,
334
- _ref5$forceFallbackPo = _ref5.forceFallbackPositioning,
335
- forceFallbackPositioning = _ref5$forceFallbackPo === void 0 ? false : _ref5$forceFallbackPo;
204
+ function useAnchorPosition(_ref3) {
205
+ var anchorRef = _ref3.anchorRef,
206
+ popoverRef = _ref3.popoverRef,
207
+ _ref3$placement = _ref3.placement,
208
+ placement = _ref3$placement === void 0 ? {} : _ref3$placement,
209
+ _ref3$forceFallbackPo = _ref3.forceFallbackPositioning,
210
+ forceFallbackPositioning = _ref3$forceFallbackPo === void 0 ? false : _ref3$forceFallbackPo;
336
211
  var id = (0, _react.useId)();
337
212
  // Stabilize `placement` object so the same object literal
338
213
  // value returns an object with the same reference
@@ -367,12 +242,12 @@ function useAnchorPosition(_ref5) {
367
242
  value: anchorName
368
243
  }, {
369
244
  property: 'position-area',
370
- value: placementToPositionArea({
245
+ value: (0, _placementToPositionArea.placementToPositionArea)({
371
246
  placement: stablePlacement
372
247
  })
373
248
  }, {
374
249
  property: 'position-try-fallbacks',
375
- value: placementToTryFallbacks({
250
+ value: (0, _placementToTryFallbacks.placementToTryFallbacks)({
376
251
  placement: stablePlacement
377
252
  })
378
253
  },
@@ -458,7 +333,7 @@ function useAnchorPosition(_ref5) {
458
333
  return _undoPositioning;
459
334
  }
460
335
 
461
- // ── JS fallback ──
336
+ // JS fallback
462
337
  // The popover is already in the browser's top layer via popover="auto",
463
338
  // so it does not need position:fixed. We only reset the UA defaults
464
339
  // (inset: 0; margin: auto) and set top/left based on measurements.
@@ -527,20 +402,17 @@ function useAnchorPosition(_ref5) {
527
402
  // Self-disconnects after one valid measurement; ongoing
528
403
  // scroll/resize is handled by the window listeners below.
529
404
  // `ResizeObserver` is missing in some non-DOM jest environments
530
- // (e.g. post-office's `node` environment). Fall back to a no-op
531
- // observer there. The scroll/resize listeners below still keep
532
- // the popover positioned in the rare case the consumer also
533
- // polyfilled `showPopover` but not `ResizeObserver`. Real
534
- // browsers always have it. The `NoopResizeObserver` class is
535
- // hoisted to module scope (see top of file) so we do not allocate
536
- // a new constructor on every effect run.
537
- var ResizeObserverImpl = typeof ResizeObserver !== 'undefined' ? ResizeObserver : NoopResizeObserver;
538
- var resizeObserver = new ResizeObserverImpl(function () {
405
+ // (e.g. post-office's `node` environment). Fall back to the
406
+ // module-scope `noopResizeObserver` stub there. The scroll/resize
407
+ // listeners below still keep the popover positioned in the rare
408
+ // case the consumer also polyfilled `showPopover` but not
409
+ // `ResizeObserver`. Real browsers always have it.
410
+ var resizeObserver = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(function () {
539
411
  if (popover.offsetWidth > 0 && popover.offsetHeight > 0) {
540
412
  update();
541
413
  resizeObserver.disconnect();
542
414
  }
543
- });
415
+ }) : noopResizeObserver;
544
416
 
545
417
  // If the popover is already open by the time this effect runs (for
546
418
  // example, the parent `useAnchorPosition` effect runs after the child