@atlaskit/top-layer 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +23 -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/focus.js +6 -4
- package/dist/cjs/entry-points/use-anchor-position-at-point.js +12 -0
- package/dist/cjs/focus/get-first-focusable.js +19 -0
- package/dist/cjs/focus/get-focusables.js +30 -0
- package/dist/cjs/focus/get-last-focusable.js +19 -0
- package/dist/cjs/focus/get-next-focusable.js +43 -0
- package/dist/cjs/focus/is-in-same-layer.js +23 -0
- package/dist/cjs/focus/is-nested-layer-focused.js +32 -0
- package/dist/cjs/focus/selectors.js +19 -0
- package/dist/cjs/focus/types.js +1 -0
- package/dist/cjs/internal/ensure-preset-styles.js +1 -1
- package/dist/cjs/internal/reduced-motion.js +1 -1
- package/dist/cjs/internal/resolve-placement.js +2 -2
- package/dist/cjs/internal/role-to-aria-has-popup.js +37 -0
- package/dist/cjs/internal/role-types.js +1 -97
- package/dist/cjs/internal/should-focus-into-popover.js +19 -0
- package/dist/cjs/internal/slot.js +3 -3
- package/dist/cjs/internal/use-anchor-position-at-point.js +127 -0
- package/dist/cjs/internal/use-anchor-position.js +22 -33
- 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-focus-wrap.js +8 -5
- package/dist/cjs/internal/use-initial-focus.js +4 -4
- package/dist/cjs/internal/use-preset-styles.js +1 -1
- package/dist/cjs/internal/use-width-from-anchor.js +4 -4
- package/dist/cjs/placement-map/index.js +2 -2
- package/dist/cjs/placement-map/legacy-placements.js +2 -101
- package/dist/cjs/placement-map/placement-mapping.js +103 -0
- 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 +8 -7
- package/dist/cjs/testing/polyfill.js +8 -8
- package/dist/cjs/testing/to-be-visible.js +5 -5
- package/dist/cjs/use-arrow-navigation/is-at-current-menu-level.js +19 -12
- package/dist/cjs/use-arrow-navigation/use-arrow-navigation.js +7 -5
- 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/focus.js +3 -1
- package/dist/es2019/entry-points/use-anchor-position-at-point.js +1 -0
- package/dist/es2019/focus/get-first-focusable.js +14 -0
- package/dist/es2019/focus/get-focusables.js +19 -0
- package/dist/es2019/focus/get-last-focusable.js +14 -0
- package/dist/es2019/focus/get-next-focusable.js +38 -0
- package/dist/es2019/focus/is-in-same-layer.js +18 -0
- package/dist/es2019/focus/is-nested-layer-focused.js +28 -0
- package/dist/es2019/focus/selectors.js +11 -0
- package/dist/es2019/focus/types.js +0 -0
- package/dist/es2019/internal/ensure-preset-styles.js +1 -1
- package/dist/es2019/internal/reduced-motion.js +1 -1
- package/dist/es2019/internal/resolve-placement.js +2 -2
- package/dist/es2019/internal/role-to-aria-has-popup.js +32 -0
- package/dist/es2019/internal/role-types.js +0 -92
- package/dist/es2019/internal/should-focus-into-popover.js +14 -0
- package/dist/es2019/internal/slot.js +3 -3
- package/dist/es2019/internal/use-anchor-position-at-point.js +122 -0
- package/dist/es2019/internal/use-anchor-position.js +19 -19
- 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-focus-wrap.js +4 -1
- package/dist/es2019/internal/use-initial-focus.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/placement-map/index.js +1 -1
- package/dist/es2019/placement-map/legacy-placements.js +1 -100
- package/dist/es2019/placement-map/placement-mapping.js +97 -0
- 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/testing/polyfill.js +8 -8
- package/dist/es2019/testing/to-be-visible.js +5 -5
- package/dist/es2019/use-arrow-navigation/is-at-current-menu-level.js +19 -12
- package/dist/es2019/use-arrow-navigation/use-arrow-navigation.js +3 -1
- 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/focus.js +3 -1
- package/dist/esm/entry-points/use-anchor-position-at-point.js +1 -0
- package/dist/esm/focus/get-first-focusable.js +13 -0
- package/dist/esm/focus/get-focusables.js +24 -0
- package/dist/esm/focus/get-last-focusable.js +13 -0
- package/dist/esm/focus/get-next-focusable.js +37 -0
- package/dist/esm/focus/is-in-same-layer.js +17 -0
- package/dist/esm/focus/is-nested-layer-focused.js +27 -0
- package/dist/esm/focus/selectors.js +13 -0
- package/dist/esm/focus/types.js +0 -0
- package/dist/esm/internal/ensure-preset-styles.js +1 -1
- package/dist/esm/internal/reduced-motion.js +1 -1
- package/dist/esm/internal/resolve-placement.js +2 -2
- package/dist/esm/internal/role-to-aria-has-popup.js +31 -0
- package/dist/esm/internal/role-types.js +0 -90
- package/dist/esm/internal/should-focus-into-popover.js +13 -0
- package/dist/esm/internal/slot.js +3 -3
- package/dist/esm/internal/use-anchor-position-at-point.js +122 -0
- package/dist/esm/internal/use-anchor-position.js +22 -33
- 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-focus-wrap.js +4 -1
- package/dist/esm/internal/use-initial-focus.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/placement-map/index.js +1 -1
- package/dist/esm/placement-map/legacy-placements.js +1 -100
- package/dist/esm/placement-map/placement-mapping.js +97 -0
- 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/testing/polyfill.js +8 -8
- package/dist/esm/testing/to-be-visible.js +5 -5
- package/dist/esm/use-arrow-navigation/is-at-current-menu-level.js +19 -12
- package/dist/esm/use-arrow-navigation/use-arrow-navigation.js +3 -1
- 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/focus.d.ts +4 -2
- package/dist/types/entry-points/use-anchor-position-at-point.d.ts +1 -0
- package/dist/types/focus/get-first-focusable.d.ts +8 -0
- package/dist/types/focus/get-focusables.d.ts +13 -0
- package/dist/types/focus/get-last-focusable.d.ts +8 -0
- package/dist/types/focus/get-next-focusable.d.ts +13 -0
- package/dist/types/focus/is-in-same-layer.d.ts +8 -0
- package/dist/types/focus/is-nested-layer-focused.d.ts +8 -0
- package/dist/types/focus/selectors.d.ts +4 -0
- package/dist/types/focus/types.d.ts +5 -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/role-to-aria-has-popup.d.ts +13 -0
- package/dist/types/internal/role-types.d.ts +0 -19
- package/dist/types/internal/should-focus-into-popover.d.ts +8 -0
- package/dist/types/internal/slot.d.ts +4 -4
- package/dist/types/internal/use-anchor-position-at-point.d.ts +62 -0
- package/dist/types/internal/use-anchor-position.d.ts +6 -1
- 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/placement-map/index.d.ts +1 -1
- package/dist/types/placement-map/legacy-placements.d.ts +0 -12
- package/dist/types/placement-map/placement-mapping.d.ts +13 -0
- 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 +1 -1
- package/dist/types/testing/to-be-visible.d.ts +3 -3
- package/dist/types/use-arrow-navigation/use-arrow-navigation.d.ts +1 -1
- 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/focus.d.ts +4 -2
- package/dist/types-ts4.5/entry-points/use-anchor-position-at-point.d.ts +1 -0
- package/dist/types-ts4.5/focus/get-first-focusable.d.ts +8 -0
- package/dist/types-ts4.5/focus/get-focusables.d.ts +13 -0
- package/dist/types-ts4.5/focus/get-last-focusable.d.ts +8 -0
- package/dist/types-ts4.5/focus/get-next-focusable.d.ts +13 -0
- package/dist/types-ts4.5/focus/is-in-same-layer.d.ts +8 -0
- package/dist/types-ts4.5/focus/is-nested-layer-focused.d.ts +8 -0
- package/dist/types-ts4.5/focus/selectors.d.ts +4 -0
- package/dist/types-ts4.5/focus/types.d.ts +5 -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/role-to-aria-has-popup.d.ts +13 -0
- package/dist/types-ts4.5/internal/role-types.d.ts +0 -19
- package/dist/types-ts4.5/internal/should-focus-into-popover.d.ts +8 -0
- package/dist/types-ts4.5/internal/slot.d.ts +4 -4
- package/dist/types-ts4.5/internal/use-anchor-position-at-point.d.ts +62 -0
- package/dist/types-ts4.5/internal/use-anchor-position.d.ts +6 -1
- 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/placement-map/index.d.ts +1 -1
- package/dist/types-ts4.5/placement-map/legacy-placements.d.ts +0 -12
- package/dist/types-ts4.5/placement-map/placement-mapping.d.ts +13 -0
- 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 +1 -1
- package/dist/types-ts4.5/testing/to-be-visible.d.ts +3 -3
- package/dist/types-ts4.5/use-arrow-navigation/use-arrow-navigation.d.ts +1 -1
- package/dist/types-ts4.5/use-simple-light-dismiss/index.d.ts +1 -1
- package/package.json +1 -1
- package/use-anchor-position-at-point/package.json +17 -0
- package/dist/cjs/focus/focus.js +0 -169
- package/dist/cjs/focus/index.js +0 -24
- package/dist/es2019/focus/focus.js +0 -158
- package/dist/es2019/focus/index.js +0 -1
- package/dist/esm/focus/focus.js +0 -160
- package/dist/esm/focus/index.js +0 -1
- package/dist/types/focus/focus.d.ts +0 -50
- package/dist/types/focus/index.d.ts +0 -2
- package/dist/types-ts4.5/focus/focus.d.ts +0 -50
- package/dist/types-ts4.5/focus/index.d.ts +0 -2
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAnchorPositionAtPoint = useAnchorPositionAtPoint;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _useAnchorPosition = require("./use-anchor-position");
|
|
9
|
+
/**
|
|
10
|
+
* A point in viewport coordinates (CSS pixels) at which the synthetic
|
|
11
|
+
* anchor should be placed.
|
|
12
|
+
*
|
|
13
|
+
* Axis-named (`x`/`y`) rather than edge-named (`left`/`top`) so the
|
|
14
|
+
* shape is unambiguous in RTL writing modes — there is no ambiguity
|
|
15
|
+
* about whether a coordinate is logical (`inline-start`/`block-start`)
|
|
16
|
+
* or physical (`left`/`top`). Viewport coordinates are always
|
|
17
|
+
* physical, so we name them with the physical axis labels.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Styles the synthetic anchor as an invisible, zero-size point.
|
|
22
|
+
* Dynamic `inset-*` overrides are written by the positioning effect.
|
|
23
|
+
*
|
|
24
|
+
* Uses `Object.assign` rather than Compiled CSS (element is outside the React tree)
|
|
25
|
+
* or the internal `setStyle` helper (we own this element entirely — it is created
|
|
26
|
+
* and removed by this hook — so the snapshot/restore semantics `setStyle`
|
|
27
|
+
* provides for caller-owned elements would be dead work here).
|
|
28
|
+
*/
|
|
29
|
+
function applyStaticAnchorStyles(el) {
|
|
30
|
+
Object.assign(el.style, {
|
|
31
|
+
position: 'fixed',
|
|
32
|
+
// `top`/`left` rather than `inset-block-start`/`inset-inline-start`
|
|
33
|
+
// for consistency with the dynamic positioning effect below, which
|
|
34
|
+
// uses physical properties (see comment there for the rationale).
|
|
35
|
+
top: '0',
|
|
36
|
+
left: '0',
|
|
37
|
+
// Zero size — placement decides which side the popover sits on.
|
|
38
|
+
width: '0',
|
|
39
|
+
height: '0',
|
|
40
|
+
// Prevent the overlay from intercepting pointer events.
|
|
41
|
+
pointerEvents: 'none'
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// `useAnchorPosition` requires a real DOM element. When the caller only
|
|
46
|
+
// has a viewport coordinate (e.g. cursor at hover time), this hook
|
|
47
|
+
// manages a hidden `<div>` at that point and delegates the rest.
|
|
48
|
+
//
|
|
49
|
+
// The `<div>` is appended directly to `document.body` to escape any
|
|
50
|
+
// transformed ancestor, which would otherwise break `position: fixed`
|
|
51
|
+
// viewport-relative resolution.
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Positions a popover at a consumer-supplied viewport coordinate using a
|
|
55
|
+
* hidden synthetic anchor.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* function PointPositionedPopover({ popoverRef, placement, mousePos }) {
|
|
60
|
+
* useAnchorPositionAtPoint({
|
|
61
|
+
* popoverRef,
|
|
62
|
+
* placement,
|
|
63
|
+
* isEnabled: Boolean(mousePos),
|
|
64
|
+
* getPoint: () => {
|
|
65
|
+
* if (!mousePos) return null;
|
|
66
|
+
* return { x: mousePos.clientX, y: mousePos.clientY };
|
|
67
|
+
* },
|
|
68
|
+
* });
|
|
69
|
+
* return <Popover ref={popoverRef}>...</Popover>;
|
|
70
|
+
* }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
function useAnchorPositionAtPoint(_ref) {
|
|
74
|
+
var popoverRef = _ref.popoverRef,
|
|
75
|
+
placement = _ref.placement,
|
|
76
|
+
getPoint = _ref.getPoint,
|
|
77
|
+
_ref$isEnabled = _ref.isEnabled,
|
|
78
|
+
isEnabled = _ref$isEnabled === void 0 ? true : _ref$isEnabled;
|
|
79
|
+
var syntheticAnchorRef = (0, _react.useRef)(null);
|
|
80
|
+
|
|
81
|
+
// `getPoint` is kept in a ref so the layout effect can call the
|
|
82
|
+
// latest version without listing it as a dep — that would re-fire
|
|
83
|
+
// on every render and re-latch the point.
|
|
84
|
+
var getPointRef = (0, _react.useRef)(getPoint);
|
|
85
|
+
getPointRef.current = getPoint;
|
|
86
|
+
|
|
87
|
+
// Lazy element creation: the `<div>` is only created when both
|
|
88
|
+
// `isEnabled` is true AND `getPoint()` returns a non-null point.
|
|
89
|
+
// `useLayoutEffect` ensures the element exists before the inner
|
|
90
|
+
// `useAnchorPosition` (also a layout effect) reads the ref.
|
|
91
|
+
(0, _react.useLayoutEffect)(function () {
|
|
92
|
+
if (!isEnabled) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
var point = getPointRef.current();
|
|
96
|
+
if (!point) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
var anchor = document.createElement('div');
|
|
100
|
+
anchor.setAttribute('aria-hidden', 'true');
|
|
101
|
+
applyStaticAnchorStyles(anchor);
|
|
102
|
+
// `point.x`/`y` are physical viewport coordinates (from
|
|
103
|
+
// `MouseEvent.clientX/Y`), so map directly onto physical
|
|
104
|
+
// `left`/`top`. This is RTL-safe: `position: fixed` + physical
|
|
105
|
+
// insets is direction-independent. Using logical
|
|
106
|
+
// `inset-inline-start` would need `viewportWidth - point.x` in
|
|
107
|
+
// RTL to land at the same physical pixel.
|
|
108
|
+
anchor.style.top = "".concat(point.y, "px");
|
|
109
|
+
anchor.style.left = "".concat(point.x, "px");
|
|
110
|
+
document.body.appendChild(anchor);
|
|
111
|
+
syntheticAnchorRef.current = anchor;
|
|
112
|
+
return function cleanup() {
|
|
113
|
+
anchor.remove();
|
|
114
|
+
syntheticAnchorRef.current = null;
|
|
115
|
+
};
|
|
116
|
+
}, [isEnabled]);
|
|
117
|
+
|
|
118
|
+
// Mirror `isEnabled` so both hooks stay in sync — when disabled,
|
|
119
|
+
// neither this hook nor the inner one touches the popover, leaving
|
|
120
|
+
// any other positioning the consumer has set up free to take effect.
|
|
121
|
+
(0, _useAnchorPosition.useAnchorPosition)({
|
|
122
|
+
anchorRef: syntheticAnchorRef,
|
|
123
|
+
popoverRef: popoverRef,
|
|
124
|
+
placement: placement,
|
|
125
|
+
isEnabled: isEnabled
|
|
126
|
+
});
|
|
127
|
+
}
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.useAnchorPosition = useAnchorPosition;
|
|
8
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
9
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
10
8
|
var _react = require("react");
|
|
11
9
|
var _bindEventListener = require("bind-event-listener");
|
|
12
10
|
var _rafSchd = _interopRequireDefault(require("raf-schd"));
|
|
@@ -37,25 +35,15 @@ var _setStyle = require("./set-style");
|
|
|
37
35
|
// from `./resolve-placement` so search-and-jump lands at the source of truth.
|
|
38
36
|
|
|
39
37
|
/**
|
|
40
|
-
* 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
|
|
41
39
|
* `ResizeObserver` is `undefined`. Hoisted out of the effect to avoid
|
|
42
|
-
* allocating
|
|
40
|
+
* re-allocating on every run.
|
|
43
41
|
*/
|
|
44
|
-
var
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
key: "observe",
|
|
50
|
-
value: function observe() {}
|
|
51
|
-
}, {
|
|
52
|
-
key: "unobserve",
|
|
53
|
-
value: function unobserve() {}
|
|
54
|
-
}, {
|
|
55
|
-
key: "disconnect",
|
|
56
|
-
value: function disconnect() {}
|
|
57
|
-
}]);
|
|
58
|
-
}();
|
|
42
|
+
var noopResizeObserver = {
|
|
43
|
+
observe: function observe() {},
|
|
44
|
+
unobserve: function unobserve() {},
|
|
45
|
+
disconnect: function disconnect() {}
|
|
46
|
+
};
|
|
59
47
|
|
|
60
48
|
/**
|
|
61
49
|
* Returns true when the popover is currently open. Wrapped because the
|
|
@@ -212,19 +200,23 @@ function useStablePlacement(placement) {
|
|
|
212
200
|
* comparison is used internally so re-runs are skipped when the resolved
|
|
213
201
|
* placement shape is unchanged.
|
|
214
202
|
*/
|
|
215
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
216
203
|
function useAnchorPosition(_ref3) {
|
|
217
204
|
var anchorRef = _ref3.anchorRef,
|
|
218
205
|
popoverRef = _ref3.popoverRef,
|
|
219
206
|
_ref3$placement = _ref3.placement,
|
|
220
207
|
placement = _ref3$placement === void 0 ? {} : _ref3$placement,
|
|
221
208
|
_ref3$forceFallbackPo = _ref3.forceFallbackPositioning,
|
|
222
|
-
forceFallbackPositioning = _ref3$forceFallbackPo === void 0 ? false : _ref3$forceFallbackPo
|
|
209
|
+
forceFallbackPositioning = _ref3$forceFallbackPo === void 0 ? false : _ref3$forceFallbackPo,
|
|
210
|
+
_ref3$isEnabled = _ref3.isEnabled,
|
|
211
|
+
isEnabled = _ref3$isEnabled === void 0 ? true : _ref3$isEnabled;
|
|
223
212
|
var id = (0, _react.useId)();
|
|
224
213
|
// Stabilize `placement` object so the same object literal
|
|
225
214
|
// value returns an object with the same reference
|
|
226
215
|
var stablePlacement = useStablePlacement(placement);
|
|
227
216
|
(0, _react.useLayoutEffect)(function () {
|
|
217
|
+
if (!isEnabled) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
228
220
|
var trigger = anchorRef.current;
|
|
229
221
|
var popover = popoverRef.current;
|
|
230
222
|
if (!trigger || !popover) {
|
|
@@ -345,7 +337,7 @@ function useAnchorPosition(_ref3) {
|
|
|
345
337
|
return _undoPositioning;
|
|
346
338
|
}
|
|
347
339
|
|
|
348
|
-
//
|
|
340
|
+
// JS fallback
|
|
349
341
|
// The popover is already in the browser's top layer via popover="auto",
|
|
350
342
|
// so it does not need position:fixed. We only reset the UA defaults
|
|
351
343
|
// (inset: 0; margin: auto) and set top/left based on measurements.
|
|
@@ -414,20 +406,17 @@ function useAnchorPosition(_ref3) {
|
|
|
414
406
|
// Self-disconnects after one valid measurement; ongoing
|
|
415
407
|
// scroll/resize is handled by the window listeners below.
|
|
416
408
|
// `ResizeObserver` is missing in some non-DOM jest environments
|
|
417
|
-
// (e.g. post-office's `node` environment). Fall back to
|
|
418
|
-
//
|
|
419
|
-
// the popover positioned in the rare
|
|
420
|
-
// polyfilled `showPopover` but not
|
|
421
|
-
// browsers always have it.
|
|
422
|
-
|
|
423
|
-
// a new constructor on every effect run.
|
|
424
|
-
var ResizeObserverImpl = typeof ResizeObserver !== 'undefined' ? ResizeObserver : NoopResizeObserver;
|
|
425
|
-
var resizeObserver = new ResizeObserverImpl(function () {
|
|
409
|
+
// (e.g. post-office's `node` environment). Fall back to the
|
|
410
|
+
// module-scope `noopResizeObserver` stub there. The scroll/resize
|
|
411
|
+
// listeners below still keep the popover positioned in the rare
|
|
412
|
+
// case the consumer also polyfilled `showPopover` but not
|
|
413
|
+
// `ResizeObserver`. Real browsers always have it.
|
|
414
|
+
var resizeObserver = typeof ResizeObserver !== 'undefined' ? new ResizeObserver(function () {
|
|
426
415
|
if (popover.offsetWidth > 0 && popover.offsetHeight > 0) {
|
|
427
416
|
update();
|
|
428
417
|
resizeObserver.disconnect();
|
|
429
418
|
}
|
|
430
|
-
});
|
|
419
|
+
}) : noopResizeObserver;
|
|
431
420
|
|
|
432
421
|
// If the popover is already open by the time this effect runs (for
|
|
433
422
|
// example, the parent `useAnchorPosition` effect runs after the child
|
|
@@ -476,5 +465,5 @@ function useAnchorPosition(_ref3) {
|
|
|
476
465
|
popover.style.removeProperty('opacity');
|
|
477
466
|
});
|
|
478
467
|
return undoPositioning;
|
|
479
|
-
}, [anchorRef, popoverRef, stablePlacement, forceFallbackPositioning, id]);
|
|
468
|
+
}, [anchorRef, popoverRef, stablePlacement, forceFallbackPositioning, isEnabled, id]);
|
|
480
469
|
}
|
|
@@ -15,19 +15,19 @@ var _usePresetStyles = require("./use-preset-styles");
|
|
|
15
15
|
*
|
|
16
16
|
* Used by both `Popover` and `Dialog` to share the same animation lifecycle
|
|
17
17
|
* logic. Those components own their own show/hide mechanisms (showPopover /
|
|
18
|
-
* hidePopover vs showModal / close) and event handling
|
|
18
|
+
* hidePopover vs showModal / close) and event handling - this hook only
|
|
19
19
|
* manages the relationship between `isOpen` and when children are rendered.
|
|
20
20
|
*
|
|
21
21
|
* ## Problem
|
|
22
22
|
*
|
|
23
23
|
* We want to delay the unmount of children until a CSS exit transition has
|
|
24
24
|
* finished playing. If we unmount children the moment `isOpen` becomes
|
|
25
|
-
* `false`, the exit animation is never visible
|
|
25
|
+
* `false`, the exit animation is never visible - the content just disappears.
|
|
26
26
|
*
|
|
27
27
|
* ## How it works
|
|
28
28
|
*
|
|
29
29
|
* `showChildren` tracks whether the consumer's children should be in the DOM.
|
|
30
|
-
* It does not mirror `isOpen` exactly
|
|
30
|
+
* It does not mirror `isOpen` exactly - it intentionally lags behind during
|
|
31
31
|
* exit animations:
|
|
32
32
|
*
|
|
33
33
|
* ```
|
|
@@ -63,12 +63,12 @@ function useAnimatedVisibility(_ref) {
|
|
|
63
63
|
// or the user has enabled the "prefers reduced motion" OS setting.
|
|
64
64
|
var willAnimate = Boolean(animate) && !(0, _reducedMotion.prefersReducedMotion)();
|
|
65
65
|
|
|
66
|
-
//
|
|
66
|
+
// showChildren state
|
|
67
67
|
//
|
|
68
68
|
// This is the core of the hook. `showChildren` controls whether the
|
|
69
69
|
// consumer's children are in the DOM. The two `if` blocks below are
|
|
70
70
|
// intentionally written as synchronous state updates during render
|
|
71
|
-
// (React supports this pattern
|
|
71
|
+
// (React supports this pattern - setState during render is treated as
|
|
72
72
|
// a synchronous re-render before the browser paints).
|
|
73
73
|
//
|
|
74
74
|
// Mount path: isOpen went true but showChildren is still false → mount.
|
|
@@ -95,7 +95,7 @@ function useAnimatedVisibility(_ref) {
|
|
|
95
95
|
var onExitFinishRef = (0, _react.useRef)(onExitFinish);
|
|
96
96
|
onExitFinishRef.current = onExitFinish;
|
|
97
97
|
|
|
98
|
-
//
|
|
98
|
+
// Animated entry effect
|
|
99
99
|
//
|
|
100
100
|
// Fires `onEnterFinish` after the entry transition completes.
|
|
101
101
|
// When there is no animation, fires it immediately via a separate effect.
|
|
@@ -144,7 +144,7 @@ function useAnimatedVisibility(_ref) {
|
|
|
144
144
|
};
|
|
145
145
|
}, [isOpen, showChildren, willAnimate, preset === null || preset === void 0 ? void 0 : preset.enterDurationMs, elementRef]);
|
|
146
146
|
|
|
147
|
-
//
|
|
147
|
+
// Non-animated entry callback
|
|
148
148
|
//
|
|
149
149
|
// When there is no animation, fire `onEnterFinish` immediately on mount and after `isOpen` goes false->true.
|
|
150
150
|
// The initial value is false to make sure it fires on mount if the current `isOpen` is true.
|
|
@@ -158,7 +158,7 @@ function useAnimatedVisibility(_ref) {
|
|
|
158
158
|
}
|
|
159
159
|
}, [isOpen, willAnimate]);
|
|
160
160
|
|
|
161
|
-
//
|
|
161
|
+
// Animated exit effect
|
|
162
162
|
//
|
|
163
163
|
// Runs when all three conditions are true:
|
|
164
164
|
// • `isOpen` is false (consumer wants to close)
|
|
@@ -221,10 +221,10 @@ function useAnimatedVisibility(_ref) {
|
|
|
221
221
|
};
|
|
222
222
|
}, [isOpen, showChildren, willAnimate, preset === null || preset === void 0 ? void 0 : preset.exitDurationMs, elementRef]);
|
|
223
223
|
|
|
224
|
-
//
|
|
224
|
+
// Non-animated exit callback
|
|
225
225
|
//
|
|
226
226
|
// When there is no animation, children unmount synchronously (handled
|
|
227
|
-
// by the `if` block above). But `onExitFinish` still needs to fire
|
|
227
|
+
// by the `if` block above). But `onExitFinish` still needs to fire -
|
|
228
228
|
// we do that in a follow-up effect so the consumer can react to it.
|
|
229
229
|
//
|
|
230
230
|
// Uses a previous-value ref (`wasOpenRef`) to detect the exact
|
|
@@ -9,7 +9,7 @@ var _ensurePresetStyles = require("./ensure-preset-styles");
|
|
|
9
9
|
/**
|
|
10
10
|
* Normalizes the `animate` prop to a preset (or null) and ensures its CSS
|
|
11
11
|
* is injected once into document.head. Used by PopupContent, Popover, and
|
|
12
|
-
* DialogContent so they
|
|
12
|
+
* DialogContent so they do not duplicate this logic.
|
|
13
13
|
*/
|
|
14
14
|
function useAnimationPreset(animate) {
|
|
15
15
|
var preset = animate != null && animate !== false ? animate : null;
|
|
@@ -6,7 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.useFocusWrap = useFocusWrap;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _bindEventListener = require("bind-event-listener");
|
|
9
|
-
var
|
|
9
|
+
var _getFirstFocusable = require("../focus/get-first-focusable");
|
|
10
|
+
var _getLastFocusable = require("../focus/get-last-focusable");
|
|
11
|
+
var _getNextFocusable = require("../focus/get-next-focusable");
|
|
12
|
+
var _isNestedLayerFocused = require("../focus/is-nested-layer-focused");
|
|
10
13
|
/**
|
|
11
14
|
* Roles that require focus wrapping per WAI-ARIA APG.
|
|
12
15
|
*
|
|
@@ -62,7 +65,7 @@ function useFocusWrap(_ref) {
|
|
|
62
65
|
|
|
63
66
|
// If focus is already in a nested layer, then
|
|
64
67
|
// we continue to let that nested layer own focus
|
|
65
|
-
if ((0,
|
|
68
|
+
if ((0, _isNestedLayerFocused.isNestedLayerFocused)({
|
|
66
69
|
container: element
|
|
67
70
|
})) {
|
|
68
71
|
return;
|
|
@@ -75,7 +78,7 @@ function useFocusWrap(_ref) {
|
|
|
75
78
|
|
|
76
79
|
// Try to move to the next/previous focusable element relative
|
|
77
80
|
// to the currently focused element within the container.
|
|
78
|
-
var next = (0,
|
|
81
|
+
var next = (0, _getNextFocusable.getNextFocusable)({
|
|
79
82
|
container: element,
|
|
80
83
|
direction: direction
|
|
81
84
|
});
|
|
@@ -87,9 +90,9 @@ function useFocusWrap(_ref) {
|
|
|
87
90
|
// Nothing is currently focused inside the container (or the
|
|
88
91
|
// focused element is not in the focusable list). Fall back to
|
|
89
92
|
// the first or last focusable element depending on direction.
|
|
90
|
-
var fallback = direction === 'forwards' ? (0,
|
|
93
|
+
var fallback = direction === 'forwards' ? (0, _getFirstFocusable.getFirstFocusable)({
|
|
91
94
|
container: element
|
|
92
|
-
}) : (0,
|
|
95
|
+
}) : (0, _getLastFocusable.getLastFocusable)({
|
|
93
96
|
container: element
|
|
94
97
|
});
|
|
95
98
|
if (fallback) {
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useInitialFocus = useInitialFocus;
|
|
7
7
|
var _react = require("react");
|
|
8
|
-
var
|
|
8
|
+
var _getFirstFocusable = require("../focus/get-first-focusable");
|
|
9
9
|
/**
|
|
10
10
|
* Determines the correct element to receive initial focus within a popover,
|
|
11
11
|
* based on its ARIA role.
|
|
@@ -33,7 +33,7 @@ function getInitialFocusTarget(_ref) {
|
|
|
33
33
|
return autofocusEl;
|
|
34
34
|
}
|
|
35
35
|
// Fall back to first focusable element
|
|
36
|
-
return (0,
|
|
36
|
+
return (0, _getFirstFocusable.getFirstFocusable)({
|
|
37
37
|
container: container
|
|
38
38
|
});
|
|
39
39
|
}
|
|
@@ -44,7 +44,7 @@ function getInitialFocusTarget(_ref) {
|
|
|
44
44
|
// of the consumer component (e.g. dropdown-menu), because menu keyboard
|
|
45
45
|
// behavior varies by context (orientation, nesting, item type, control
|
|
46
46
|
// pattern). See: notes/outputs/menu-keyboard-decision.md
|
|
47
|
-
return (0,
|
|
47
|
+
return (0, _getFirstFocusable.getFirstFocusable)({
|
|
48
48
|
container: container
|
|
49
49
|
});
|
|
50
50
|
}
|
|
@@ -54,7 +54,7 @@ function getInitialFocusTarget(_ref) {
|
|
|
54
54
|
if (selectedOption) {
|
|
55
55
|
return selectedOption;
|
|
56
56
|
}
|
|
57
|
-
return (0,
|
|
57
|
+
return (0, _getFirstFocusable.getFirstFocusable)({
|
|
58
58
|
container: container
|
|
59
59
|
});
|
|
60
60
|
}
|
|
@@ -10,7 +10,7 @@ var _ensurePresetStyles = require("./ensure-preset-styles");
|
|
|
10
10
|
* Normalizes a preset prop to a value (or null) and ensures its CSS
|
|
11
11
|
* is injected once into `document.head`.
|
|
12
12
|
*
|
|
13
|
-
* Works with any preset that has `{ css, name }`
|
|
13
|
+
* Works with any preset that has `{ css, name }` - animation presets
|
|
14
14
|
* (TAnimationPreset) satisfies this shape.
|
|
15
15
|
*/
|
|
16
16
|
function usePresetStyles(_ref) {
|
|
@@ -9,8 +9,8 @@ var _setStyle = require("./set-style");
|
|
|
9
9
|
/**
|
|
10
10
|
* Sets the width of a popover element relative to its anchor element.
|
|
11
11
|
*
|
|
12
|
-
* - `'match-anchor'` → `width: anchor-size(width)`
|
|
13
|
-
* - `'min-anchor'` → `min-width: anchor-size(width)`
|
|
12
|
+
* - `'match-anchor'` → `width: anchor-size(width)` - popover matches anchor width exactly.
|
|
13
|
+
* - `'min-anchor'` → `min-width: anchor-size(width)` - popover is at least as wide as anchor,
|
|
14
14
|
* but can grow wider.
|
|
15
15
|
* - `'none'` → no explicit width is set (default behaviour)
|
|
16
16
|
*
|
|
@@ -35,7 +35,7 @@ function useWidthFromAnchor(_ref) {
|
|
|
35
35
|
var supportsAnchorSize = typeof CSS !== 'undefined' && typeof CSS.supports === 'function' && CSS.supports('width', 'anchor-size(width)');
|
|
36
36
|
if (mode === 'match-anchor') {
|
|
37
37
|
// Set an exact width matching the anchor.
|
|
38
|
-
// `min-inline-size` is intentionally NOT set here
|
|
38
|
+
// `min-inline-size` is intentionally NOT set here - it would override the
|
|
39
39
|
// explicit width constraint, allowing the popover to grow past the anchor's width.
|
|
40
40
|
if (supportsAnchorSize) {
|
|
41
41
|
return (0, _setStyle.setStyle)({
|
|
@@ -91,7 +91,7 @@ function useWidthFromAnchor(_ref) {
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
// No anchor available in JS fallback
|
|
94
|
+
// No anchor available in JS fallback - still apply min-inline-size.
|
|
95
95
|
return (0, _setStyle.setStyle)({
|
|
96
96
|
el: node,
|
|
97
97
|
styles: [minInlineSizeStyle]
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.fromLegacyPlacement = fromLegacyPlacement;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var
|
|
10
|
+
var _placementMapping = require("./placement-mapping");
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
12
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
13
|
/**
|
|
@@ -54,7 +54,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
54
54
|
function fromLegacyPlacement(_ref) {
|
|
55
55
|
var legacy = _ref.legacy,
|
|
56
56
|
offset = _ref.offset;
|
|
57
|
-
var basePlacement =
|
|
57
|
+
var basePlacement = _placementMapping.placementMapping[legacy];
|
|
58
58
|
if (!offset) {
|
|
59
59
|
return basePlacement;
|
|
60
60
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.LEGACY_PLACEMENTS = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Legacy Popper.js placement values (used by `@atlaskit/popper`,
|
|
9
9
|
* `@atlaskit/popup`, `@atlaskit/tooltip`, etc.). Re-exported from
|
|
@@ -11,103 +11,4 @@ exports.placementMapping = exports.LEGACY_PLACEMENTS = void 0;
|
|
|
11
11
|
* to enumerate every placement (e.g. for a settings dropdown). New code
|
|
12
12
|
* should use the object-based `TPlacementOptions` directly.
|
|
13
13
|
*/
|
|
14
|
-
|
|
15
|
-
var LEGACY_PLACEMENTS = exports.LEGACY_PLACEMENTS = ['auto', 'auto-start', 'auto-end', 'top', 'top-start', 'top-center', 'top-end', 'bottom', 'bottom-start', 'bottom-center', 'bottom-end', 'right', 'right-start', 'right-end', 'left', 'left-start', 'left-end'];
|
|
16
|
-
/**
|
|
17
|
-
* The full mapping record. Internal - use `fromLegacyPlacement` from the
|
|
18
|
-
* public entry-point so the offset-tuple translation is applied consistently.
|
|
19
|
-
*
|
|
20
|
-
* Note: `auto`, `auto-start`, `auto-end` map to `block-end` placements. This
|
|
21
|
-
* is a reduction in expressiveness vs Popper.js (which picked the best
|
|
22
|
-
* placement at runtime). CSS `position-try-fallbacks` flips at the edge but
|
|
23
|
-
* the initial placement is fixed. Migration consumers who relied on Popper's
|
|
24
|
-
* dynamic auto-flip should pick an explicit placement instead.
|
|
25
|
-
*/
|
|
26
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
27
|
-
var placementMapping = exports.placementMapping = {
|
|
28
|
-
top: {
|
|
29
|
-
axis: 'block',
|
|
30
|
-
edge: 'start',
|
|
31
|
-
align: 'center'
|
|
32
|
-
},
|
|
33
|
-
'top-start': {
|
|
34
|
-
axis: 'block',
|
|
35
|
-
edge: 'start',
|
|
36
|
-
align: 'start'
|
|
37
|
-
},
|
|
38
|
-
'top-center': {
|
|
39
|
-
axis: 'block',
|
|
40
|
-
edge: 'start',
|
|
41
|
-
align: 'center'
|
|
42
|
-
},
|
|
43
|
-
'top-end': {
|
|
44
|
-
axis: 'block',
|
|
45
|
-
edge: 'start',
|
|
46
|
-
align: 'end'
|
|
47
|
-
},
|
|
48
|
-
bottom: {
|
|
49
|
-
axis: 'block',
|
|
50
|
-
edge: 'end',
|
|
51
|
-
align: 'center'
|
|
52
|
-
},
|
|
53
|
-
'bottom-start': {
|
|
54
|
-
axis: 'block',
|
|
55
|
-
edge: 'end',
|
|
56
|
-
align: 'start'
|
|
57
|
-
},
|
|
58
|
-
'bottom-center': {
|
|
59
|
-
axis: 'block',
|
|
60
|
-
edge: 'end',
|
|
61
|
-
align: 'center'
|
|
62
|
-
},
|
|
63
|
-
'bottom-end': {
|
|
64
|
-
axis: 'block',
|
|
65
|
-
edge: 'end',
|
|
66
|
-
align: 'end'
|
|
67
|
-
},
|
|
68
|
-
right: {
|
|
69
|
-
axis: 'inline',
|
|
70
|
-
edge: 'end',
|
|
71
|
-
align: 'center'
|
|
72
|
-
},
|
|
73
|
-
'right-start': {
|
|
74
|
-
axis: 'inline',
|
|
75
|
-
edge: 'end',
|
|
76
|
-
align: 'start'
|
|
77
|
-
},
|
|
78
|
-
'right-end': {
|
|
79
|
-
axis: 'inline',
|
|
80
|
-
edge: 'end',
|
|
81
|
-
align: 'end'
|
|
82
|
-
},
|
|
83
|
-
left: {
|
|
84
|
-
axis: 'inline',
|
|
85
|
-
edge: 'start',
|
|
86
|
-
align: 'center'
|
|
87
|
-
},
|
|
88
|
-
'left-start': {
|
|
89
|
-
axis: 'inline',
|
|
90
|
-
edge: 'start',
|
|
91
|
-
align: 'start'
|
|
92
|
-
},
|
|
93
|
-
'left-end': {
|
|
94
|
-
axis: 'inline',
|
|
95
|
-
edge: 'start',
|
|
96
|
-
align: 'end'
|
|
97
|
-
},
|
|
98
|
-
auto: {
|
|
99
|
-
axis: 'block',
|
|
100
|
-
edge: 'end',
|
|
101
|
-
align: 'center'
|
|
102
|
-
},
|
|
103
|
-
'auto-start': {
|
|
104
|
-
axis: 'block',
|
|
105
|
-
edge: 'end',
|
|
106
|
-
align: 'start'
|
|
107
|
-
},
|
|
108
|
-
'auto-end': {
|
|
109
|
-
axis: 'block',
|
|
110
|
-
edge: 'end',
|
|
111
|
-
align: 'end'
|
|
112
|
-
}
|
|
113
|
-
};
|
|
14
|
+
var LEGACY_PLACEMENTS = exports.LEGACY_PLACEMENTS = ['auto', 'auto-start', 'auto-end', 'top', 'top-start', 'top-center', 'top-end', 'bottom', 'bottom-start', 'bottom-center', 'bottom-end', 'right', 'right-start', 'right-end', 'left', 'left-start', 'left-end'];
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.placementMapping = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* The full mapping record. Internal - use `fromLegacyPlacement` from the
|
|
9
|
+
* public entry-point so the offset-tuple translation is applied consistently.
|
|
10
|
+
*
|
|
11
|
+
* Note: `auto`, `auto-start`, `auto-end` map to `block-end` placements. This
|
|
12
|
+
* is a reduction in expressiveness vs Popper.js (which picked the best
|
|
13
|
+
* placement at runtime). CSS `position-try-fallbacks` flips at the edge but
|
|
14
|
+
* the initial placement is fixed. Migration consumers who relied on Popper's
|
|
15
|
+
* dynamic auto-flip should pick an explicit placement instead.
|
|
16
|
+
*/
|
|
17
|
+
var placementMapping = exports.placementMapping = {
|
|
18
|
+
top: {
|
|
19
|
+
axis: 'block',
|
|
20
|
+
edge: 'start',
|
|
21
|
+
align: 'center'
|
|
22
|
+
},
|
|
23
|
+
'top-start': {
|
|
24
|
+
axis: 'block',
|
|
25
|
+
edge: 'start',
|
|
26
|
+
align: 'start'
|
|
27
|
+
},
|
|
28
|
+
'top-center': {
|
|
29
|
+
axis: 'block',
|
|
30
|
+
edge: 'start',
|
|
31
|
+
align: 'center'
|
|
32
|
+
},
|
|
33
|
+
'top-end': {
|
|
34
|
+
axis: 'block',
|
|
35
|
+
edge: 'start',
|
|
36
|
+
align: 'end'
|
|
37
|
+
},
|
|
38
|
+
bottom: {
|
|
39
|
+
axis: 'block',
|
|
40
|
+
edge: 'end',
|
|
41
|
+
align: 'center'
|
|
42
|
+
},
|
|
43
|
+
'bottom-start': {
|
|
44
|
+
axis: 'block',
|
|
45
|
+
edge: 'end',
|
|
46
|
+
align: 'start'
|
|
47
|
+
},
|
|
48
|
+
'bottom-center': {
|
|
49
|
+
axis: 'block',
|
|
50
|
+
edge: 'end',
|
|
51
|
+
align: 'center'
|
|
52
|
+
},
|
|
53
|
+
'bottom-end': {
|
|
54
|
+
axis: 'block',
|
|
55
|
+
edge: 'end',
|
|
56
|
+
align: 'end'
|
|
57
|
+
},
|
|
58
|
+
right: {
|
|
59
|
+
axis: 'inline',
|
|
60
|
+
edge: 'end',
|
|
61
|
+
align: 'center'
|
|
62
|
+
},
|
|
63
|
+
'right-start': {
|
|
64
|
+
axis: 'inline',
|
|
65
|
+
edge: 'end',
|
|
66
|
+
align: 'start'
|
|
67
|
+
},
|
|
68
|
+
'right-end': {
|
|
69
|
+
axis: 'inline',
|
|
70
|
+
edge: 'end',
|
|
71
|
+
align: 'end'
|
|
72
|
+
},
|
|
73
|
+
left: {
|
|
74
|
+
axis: 'inline',
|
|
75
|
+
edge: 'start',
|
|
76
|
+
align: 'center'
|
|
77
|
+
},
|
|
78
|
+
'left-start': {
|
|
79
|
+
axis: 'inline',
|
|
80
|
+
edge: 'start',
|
|
81
|
+
align: 'start'
|
|
82
|
+
},
|
|
83
|
+
'left-end': {
|
|
84
|
+
axis: 'inline',
|
|
85
|
+
edge: 'start',
|
|
86
|
+
align: 'end'
|
|
87
|
+
},
|
|
88
|
+
auto: {
|
|
89
|
+
axis: 'block',
|
|
90
|
+
edge: 'end',
|
|
91
|
+
align: 'center'
|
|
92
|
+
},
|
|
93
|
+
'auto-start': {
|
|
94
|
+
axis: 'block',
|
|
95
|
+
edge: 'end',
|
|
96
|
+
align: 'start'
|
|
97
|
+
},
|
|
98
|
+
'auto-end': {
|
|
99
|
+
axis: 'block',
|
|
100
|
+
edge: 'end',
|
|
101
|
+
align: 'end'
|
|
102
|
+
}
|
|
103
|
+
};
|