@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.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/animations/presets.js +5 -5
- package/dist/cjs/dialog/create-close-event.js +1 -1
- package/dist/cjs/dialog/dialog-content.js +5 -5
- package/dist/cjs/entry-points/use-arrow-navigation.js +3 -2
- package/dist/cjs/internal/ensure-preset-styles.js +1 -1
- package/dist/cjs/internal/placement-to-position-area.js +43 -0
- package/dist/cjs/internal/placement-to-try-fallbacks.js +82 -0
- package/dist/cjs/internal/reduced-motion.js +1 -1
- package/dist/cjs/internal/resolve-placement.js +2 -2
- package/dist/cjs/internal/role-types.js +1 -1
- package/dist/cjs/internal/slot.js +3 -3
- package/dist/cjs/internal/use-anchor-position.js +33 -161
- package/dist/cjs/internal/use-animated-visibility.js +10 -10
- package/dist/cjs/internal/use-animation-preset.js +1 -1
- package/dist/cjs/internal/use-preset-styles.js +1 -1
- package/dist/cjs/internal/use-width-from-anchor.js +4 -4
- package/dist/cjs/popover/create-close-event.js +1 -1
- package/dist/cjs/popover/popover.js +3 -3
- package/dist/cjs/popup/popup-content.js +6 -6
- package/dist/cjs/popup/popup-context.js +2 -38
- package/dist/cjs/popup/popup-provider.js +15 -0
- package/dist/cjs/popup/popup-trigger-function.js +2 -2
- package/dist/cjs/popup/popup-trigger.js +2 -2
- package/dist/cjs/popup/popup.js +2 -2
- package/dist/cjs/popup/use-maybe-popup-context.js +17 -0
- package/dist/cjs/popup/use-popup-context.js +20 -0
- package/dist/cjs/testing/polyfill.js +8 -8
- package/dist/cjs/testing/to-be-visible.js +5 -5
- package/dist/cjs/use-arrow-navigation/index.js +3 -2
- package/dist/cjs/use-arrow-navigation/is-at-current-menu-level.js +94 -0
- package/dist/cjs/use-arrow-navigation/use-arrow-navigation.js +0 -82
- package/dist/cjs/use-simple-light-dismiss/index.js +3 -3
- package/dist/es2019/animations/presets.js +5 -5
- package/dist/es2019/dialog/create-close-event.js +1 -1
- package/dist/es2019/dialog/dialog-content.js +5 -5
- package/dist/es2019/entry-points/use-arrow-navigation.js +2 -1
- package/dist/es2019/internal/ensure-preset-styles.js +1 -1
- package/dist/es2019/internal/placement-to-position-area.js +40 -0
- package/dist/es2019/internal/placement-to-try-fallbacks.js +77 -0
- package/dist/es2019/internal/reduced-motion.js +1 -1
- package/dist/es2019/internal/resolve-placement.js +2 -2
- package/dist/es2019/internal/role-types.js +1 -1
- package/dist/es2019/internal/slot.js +3 -3
- package/dist/es2019/internal/use-anchor-position.js +15 -132
- package/dist/es2019/internal/use-animated-visibility.js +10 -10
- package/dist/es2019/internal/use-animation-preset.js +1 -1
- package/dist/es2019/internal/use-preset-styles.js +1 -1
- package/dist/es2019/internal/use-width-from-anchor.js +4 -4
- package/dist/es2019/popover/create-close-event.js +1 -1
- package/dist/es2019/popover/popover.js +3 -3
- package/dist/es2019/popup/popup-content.js +6 -5
- package/dist/es2019/popup/popup-context.js +2 -36
- package/dist/es2019/popup/popup-provider.js +10 -0
- package/dist/es2019/popup/popup-trigger-function.js +1 -1
- package/dist/es2019/popup/popup-trigger.js +2 -1
- package/dist/es2019/popup/popup.js +1 -1
- package/dist/es2019/popup/use-maybe-popup-context.js +12 -0
- package/dist/es2019/popup/use-popup-context.js +15 -0
- package/dist/es2019/testing/polyfill.js +8 -8
- package/dist/es2019/testing/to-be-visible.js +5 -5
- package/dist/es2019/use-arrow-navigation/index.js +2 -1
- package/dist/es2019/use-arrow-navigation/is-at-current-menu-level.js +88 -0
- package/dist/es2019/use-arrow-navigation/use-arrow-navigation.js +0 -81
- package/dist/es2019/use-simple-light-dismiss/index.js +3 -3
- package/dist/esm/animations/presets.js +5 -5
- package/dist/esm/dialog/create-close-event.js +1 -1
- package/dist/esm/dialog/dialog-content.js +5 -5
- package/dist/esm/entry-points/use-arrow-navigation.js +2 -1
- package/dist/esm/internal/ensure-preset-styles.js +1 -1
- package/dist/esm/internal/placement-to-position-area.js +38 -0
- package/dist/esm/internal/placement-to-try-fallbacks.js +76 -0
- package/dist/esm/internal/reduced-motion.js +1 -1
- package/dist/esm/internal/resolve-placement.js +2 -2
- package/dist/esm/internal/role-types.js +1 -1
- package/dist/esm/internal/slot.js +3 -3
- package/dist/esm/internal/use-anchor-position.js +31 -157
- package/dist/esm/internal/use-animated-visibility.js +10 -10
- package/dist/esm/internal/use-animation-preset.js +1 -1
- package/dist/esm/internal/use-preset-styles.js +1 -1
- package/dist/esm/internal/use-width-from-anchor.js +4 -4
- package/dist/esm/popover/create-close-event.js +1 -1
- package/dist/esm/popover/popover.js +3 -3
- package/dist/esm/popup/popup-content.js +6 -5
- package/dist/esm/popup/popup-context.js +2 -36
- package/dist/esm/popup/popup-provider.js +10 -0
- package/dist/esm/popup/popup-trigger-function.js +1 -1
- package/dist/esm/popup/popup-trigger.js +2 -1
- package/dist/esm/popup/popup.js +1 -1
- package/dist/esm/popup/use-maybe-popup-context.js +12 -0
- package/dist/esm/popup/use-popup-context.js +15 -0
- package/dist/esm/testing/polyfill.js +8 -8
- package/dist/esm/testing/to-be-visible.js +5 -5
- package/dist/esm/use-arrow-navigation/index.js +2 -1
- package/dist/esm/use-arrow-navigation/is-at-current-menu-level.js +88 -0
- package/dist/esm/use-arrow-navigation/use-arrow-navigation.js +0 -81
- package/dist/esm/use-simple-light-dismiss/index.js +3 -3
- package/dist/types/dialog/create-close-event.d.ts +1 -1
- package/dist/types/dialog/types.d.ts +8 -0
- package/dist/types/entry-points/use-arrow-navigation.d.ts +2 -1
- package/dist/types/internal/placement-to-position-area.d.ts +21 -0
- package/dist/types/internal/placement-to-try-fallbacks.d.ts +36 -0
- package/dist/types/internal/reduced-motion.d.ts +1 -1
- package/dist/types/internal/resolve-placement.d.ts +2 -2
- package/dist/types/internal/slot.d.ts +4 -4
- package/dist/types/internal/use-anchor-position.d.ts +0 -55
- package/dist/types/internal/use-animated-visibility.d.ts +3 -3
- package/dist/types/internal/use-animation-preset.d.ts +1 -1
- package/dist/types/internal/use-preset-styles.d.ts +1 -1
- package/dist/types/internal/use-width-from-anchor.d.ts +2 -2
- package/dist/types/popover/create-close-event.d.ts +1 -1
- package/dist/types/popover/popover.d.ts +1 -1
- package/dist/types/popup/popup-context.d.ts +2 -22
- package/dist/types/popup/popup-provider.d.ts +10 -0
- package/dist/types/popup/use-maybe-popup-context.d.ts +8 -0
- package/dist/types/popup/use-popup-context.d.ts +7 -0
- package/dist/types/testing/to-be-visible.d.ts +3 -3
- package/dist/types/use-arrow-navigation/index.d.ts +2 -1
- package/dist/types/use-arrow-navigation/is-at-current-menu-level.d.ts +48 -0
- package/dist/types/use-arrow-navigation/use-arrow-navigation.d.ts +0 -48
- package/dist/types/use-simple-light-dismiss/index.d.ts +1 -1
- package/dist/types-ts4.5/dialog/create-close-event.d.ts +1 -1
- package/dist/types-ts4.5/dialog/types.d.ts +8 -0
- package/dist/types-ts4.5/entry-points/use-arrow-navigation.d.ts +2 -1
- package/dist/types-ts4.5/internal/placement-to-position-area.d.ts +21 -0
- package/dist/types-ts4.5/internal/placement-to-try-fallbacks.d.ts +36 -0
- package/dist/types-ts4.5/internal/reduced-motion.d.ts +1 -1
- package/dist/types-ts4.5/internal/resolve-placement.d.ts +2 -2
- package/dist/types-ts4.5/internal/slot.d.ts +4 -4
- package/dist/types-ts4.5/internal/use-anchor-position.d.ts +0 -55
- package/dist/types-ts4.5/internal/use-animated-visibility.d.ts +3 -3
- package/dist/types-ts4.5/internal/use-animation-preset.d.ts +1 -1
- package/dist/types-ts4.5/internal/use-preset-styles.d.ts +1 -1
- package/dist/types-ts4.5/internal/use-width-from-anchor.d.ts +2 -2
- package/dist/types-ts4.5/popover/create-close-event.d.ts +1 -1
- package/dist/types-ts4.5/popover/popover.d.ts +1 -1
- package/dist/types-ts4.5/popup/popup-context.d.ts +2 -22
- package/dist/types-ts4.5/popup/popup-provider.d.ts +10 -0
- package/dist/types-ts4.5/popup/use-maybe-popup-context.d.ts +8 -0
- package/dist/types-ts4.5/popup/use-popup-context.d.ts +7 -0
- package/dist/types-ts4.5/testing/to-be-visible.d.ts +3 -3
- package/dist/types-ts4.5/use-arrow-navigation/index.d.ts +2 -1
- package/dist/types-ts4.5/use-arrow-navigation/is-at-current-menu-level.d.ts +48 -0
- package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +0 -48
- package/dist/types-ts4.5/use-simple-light-dismiss/index.d.ts +1 -1
- package/package.json +2 -2
- package/dist/cjs/arrow/index.js +0 -131
- package/dist/cjs/arrow/types.js +0 -5
- package/dist/es2019/arrow/index.js +0 -269
- package/dist/es2019/arrow/types.js +0 -1
- package/dist/esm/arrow/index.js +0 -124
- package/dist/esm/arrow/types.js +0 -1
- package/dist/types/arrow/index.d.ts +0 -24
- package/dist/types/arrow/types.d.ts +0 -29
- package/dist/types-ts4.5/arrow/index.d.ts +0 -24
- 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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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`
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
-
//
|
|
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
|
|
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
|
|
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`
|
|
34
|
-
* - `crossAxisShift`
|
|
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
|
-
//
|
|
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`
|
|
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
|
|
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
|
-
// `
|
|
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
|
|
40
|
+
* re-allocating on every run.
|
|
44
41
|
*/
|
|
45
|
-
var
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
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(
|
|
205
|
-
var placement =
|
|
206
|
-
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(
|
|
248
|
-
var placement =
|
|
249
|
-
crossAxisShiftCssValue =
|
|
250
|
-
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(
|
|
330
|
-
var anchorRef =
|
|
331
|
-
popoverRef =
|
|
332
|
-
|
|
333
|
-
placement =
|
|
334
|
-
|
|
335
|
-
forceFallbackPositioning =
|
|
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
|
-
//
|
|
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
|
|
531
|
-
//
|
|
532
|
-
// the popover positioned in the rare
|
|
533
|
-
// polyfilled `showPopover` but not
|
|
534
|
-
// browsers always have it.
|
|
535
|
-
|
|
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
|