@atlaskit/popup 4.17.0 → 4.18.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 +105 -0
- package/dist/cjs/compositional/popup-content-top-layer.compiled.css +2 -0
- package/dist/cjs/compositional/popup-content-top-layer.js +135 -0
- package/dist/cjs/compositional/popup-content.js +36 -0
- package/dist/cjs/internal/top-layer-bridge.js +55 -0
- package/dist/cjs/popper-wrapper.js +13 -8
- package/dist/cjs/popup-top-layer.compiled.css +2 -0
- package/dist/cjs/popup-top-layer.js +185 -0
- package/dist/cjs/popup.js +63 -45
- package/dist/es2019/compositional/popup-content-top-layer.compiled.css +2 -0
- package/dist/es2019/compositional/popup-content-top-layer.js +140 -0
- package/dist/es2019/compositional/popup-content.js +36 -0
- package/dist/es2019/internal/top-layer-bridge.js +51 -0
- package/dist/es2019/popper-wrapper.js +11 -8
- package/dist/es2019/popup-top-layer.compiled.css +2 -0
- package/dist/es2019/popup-top-layer.js +193 -0
- package/dist/es2019/popup.js +52 -33
- package/dist/esm/compositional/popup-content-top-layer.compiled.css +2 -0
- package/dist/esm/compositional/popup-content-top-layer.js +126 -0
- package/dist/esm/compositional/popup-content.js +36 -0
- package/dist/esm/internal/top-layer-bridge.js +50 -0
- package/dist/esm/popper-wrapper.js +13 -8
- package/dist/esm/popup-top-layer.compiled.css +2 -0
- package/dist/esm/popup-top-layer.js +176 -0
- package/dist/esm/popup.js +63 -45
- package/dist/types/compositional/popup-content-top-layer.d.ts +21 -0
- package/dist/types/compositional/popup-content.d.ts +2 -2
- package/dist/types/internal/top-layer-bridge.d.ts +29 -0
- package/dist/types/popper-wrapper.d.ts +1 -1
- package/dist/types/popup-top-layer.d.ts +16 -0
- package/dist/types/types.d.ts +38 -0
- package/dist/types-ts4.5/compositional/popup-content-top-layer.d.ts +21 -0
- package/dist/types-ts4.5/compositional/popup-content.d.ts +2 -2
- package/dist/types-ts4.5/internal/top-layer-bridge.d.ts +29 -0
- package/dist/types-ts4.5/popper-wrapper.d.ts +1 -1
- package/dist/types-ts4.5/popup-top-layer.d.ts +16 -0
- package/dist/types-ts4.5/types.d.ts +38 -0
- package/package.json +13 -8
- package/offerings.json +0 -34
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,110 @@
|
|
|
1
1
|
# @atlaskit/popup
|
|
2
2
|
|
|
3
|
+
## 4.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`2bed6255731de`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/2bed6255731de) -
|
|
8
|
+
Top-layer adoption work behind the `platform-dst-top-layer` feature flag. Public adopter APIs are
|
|
9
|
+
intentionally kept narrow while the top-layer API surface settles, with one exception called out
|
|
10
|
+
below.
|
|
11
|
+
|
|
12
|
+
Highlights:
|
|
13
|
+
- Pass the full `[along, away]` legacy popper offset through to the new top-layer
|
|
14
|
+
`placement.offset` API (via `fromLegacyPlacement`). Previously only the `away` axis was
|
|
15
|
+
forwarded, which dropped the `along` offset for consumers of `Popup`, `PopupSelect`,
|
|
16
|
+
`Spotlight`, and `Tooltip` when `platform-dst-top-layer` is enabled.
|
|
17
|
+
- Fix broken import of `dialogHeight` and `dialogWidth` from the removed utils module in
|
|
18
|
+
`@atlaskit/modal-dialog`.
|
|
19
|
+
|
|
20
|
+
Public API:
|
|
21
|
+
- **`@atlaskit/tooltip`** (`minor`): add an optional `testId?: string` field to `TriggerProps`.
|
|
22
|
+
This is additive (no existing prop changes shape). Required because `@atlaskit/button/new` (and
|
|
23
|
+
other `Pressable`-backed primitives) overwrite `data-testid` from spread, so the legacy
|
|
24
|
+
`(triggerProps as any)['data-testid']` workaround is silently absorbed by those consumers. A
|
|
25
|
+
typed `testId` field flows through their own `testId` destructure instead, restoring
|
|
26
|
+
`data-testid` propagation onto the rendered trigger element.
|
|
27
|
+
- **`@atlaskit/popup`**, **`@atlaskit/dropdown-menu`** (`patch`): no public type changes. Wider
|
|
28
|
+
`aria-haspopup` unions that the FF-on path produces are bridged at the package boundary into
|
|
29
|
+
`@atlaskit/top-layer` with localised `FUDGE(top-layer-api)` casts, documented in
|
|
30
|
+
`packages/design-system/top-layer/notes/decisions/migration-roadmap.md` ("Open API decisions
|
|
31
|
+
deferred to a follow-up PR"). They will be widened in a follow-up `minor` PR once the top-layer
|
|
32
|
+
API is committed.
|
|
33
|
+
- **`@atlaskit/modal-dialog`**, **`@atlaskit/select`**, **`@atlaskit/spotlight`**
|
|
34
|
+
(`patch`/`minor`): no public type changes; bug fixes only.
|
|
35
|
+
|
|
36
|
+
Merge-readiness fixes (FF-on test wiring + adopter behavior):
|
|
37
|
+
- **`@atlaskit/popup`** (`minor`): wire the compositional `PopupContent` to delegate to
|
|
38
|
+
`PopupContentTopLayer` when `platform-dst-top-layer` is enabled. Previously only the legacy
|
|
39
|
+
`Popup` component had the FF branch, leaving consumers of the compositional API on the legacy
|
|
40
|
+
popper path.
|
|
41
|
+
- **`@atlaskit/select`** (`minor`): add an `onClick` handler to the `PopupSelect` top-layer
|
|
42
|
+
trigger so clicks open/close the menu (mirrors the legacy global click handler in
|
|
43
|
+
`popup-select.tsx`). Add explicit Escape handling on the menu's `onKeyDown` so the menu closes
|
|
44
|
+
and focus returns to the trigger.
|
|
45
|
+
- **`@atlaskit/top-layer`** (`patch`): the `<dialog>` rendered by the Dialog primitive now sets
|
|
46
|
+
`aria-modal="true"` explicitly. Modern browsers infer modal semantics from `.showModal()` but
|
|
47
|
+
some assistive tech still keys off the explicit attribute.
|
|
48
|
+
- **`@atlaskit/top-layer`** (`patch`): guard `use-anchor-positioning` against environments where
|
|
49
|
+
`ResizeObserver` is not defined (e.g. jest's `node` environment, used by the post-office test
|
|
50
|
+
suite). The observer is used to wait for the popover's first valid layout before measuring;
|
|
51
|
+
consumers in non-DOM jest environments now get a no-op observer and the scroll/resize listeners
|
|
52
|
+
still apply if the host environment polyfills `showPopover`. Real browsers always have
|
|
53
|
+
`ResizeObserver`.
|
|
54
|
+
- **`@atlaskit/modal-dialog`** (`patch`): on the FF-on path, drop the `tabIndex={-1}` (and unused
|
|
55
|
+
`:focus-visible` outline) from the modal content wrapper. The native `<dialog>.showModal()`
|
|
56
|
+
focus-delegate algorithm picks the first focusable descendant (including `tabindex=-1`), and the
|
|
57
|
+
wrapper was hijacking initial focus from the close button. Also honor `shouldReturnFocus={ref}`
|
|
58
|
+
on the FF-on path (an unmount-cleanup focuses the ref after `dialog.close()` so it overrides the
|
|
59
|
+
browser's automatic return-to-trigger). Boolean `shouldReturnFocus={false}` is not yet honored
|
|
60
|
+
on the FF-on path — see `top-layer/notes/merge-blockers.md`.
|
|
61
|
+
- **`@atlaskit/datetime-picker`** (`patch`): on the FF-on path, set `mode="manual"` on the
|
|
62
|
+
`Popup.Content` rendered by both `internal/menu-top-layer.tsx` (date-picker calendar) and
|
|
63
|
+
`internal/fixed-layer-menu-top-layer.tsx` (time-picker menu). With the default `mode="auto"`,
|
|
64
|
+
the same click event that opens the menu (which targets the react-select combobox input —
|
|
65
|
+
outside the popover element) bubbles to the browser's native popover light-dismiss handler and
|
|
66
|
+
immediately closes the menu. react-select / DateTimePicker already own outside-click and Esc
|
|
67
|
+
dismissal via their own state, so opting out of the native auto-dismiss is the correct
|
|
68
|
+
integration. Also extend the existing Esc → trigger-focus restoration in
|
|
69
|
+
`components/date-picker.tsx` to the FF-on path (manual mode disables the browser's built-in
|
|
70
|
+
focus return, and the legacy code path was already handling this for itself behind an FF
|
|
71
|
+
negation).
|
|
72
|
+
- **`@atlaskit/popup`** (no public API change): no source changes — only FF-on Playwright
|
|
73
|
+
spec/example fixes drove the suite from 21/3/2 to 27/0/0. Notable: the two `test.fixme`'d
|
|
74
|
+
nested-popover cases were not browser limitations; `popover="auto"` chains correctly via DOM
|
|
75
|
+
ancestry (the original fixmes had the wrong testId selector). Added `testId` props to two
|
|
76
|
+
examples (`16-popup-with-a11y-props`, `18-should-fit-container`) so default-shape tests can
|
|
77
|
+
reach the trigger.
|
|
78
|
+
- Test alignment for FF-on Playwright suites across `popup`, `select`, `datetime-picker`,
|
|
79
|
+
`inline-dialog`, `inline-message`, and `modal-dialog`: selector updates to match the new
|
|
80
|
+
top-layer testId convention (`${testId}--content`, `[role="dialog"][aria-label="calendar"]`),
|
|
81
|
+
per-spec `skipAxeCheck()` for example-level color-contrast violations unrelated to the
|
|
82
|
+
migration, and focus assertions adjusted to match native `<dialog>` / `Popup.Content` auto-focus
|
|
83
|
+
semantics (focus lands on the first focusable child, not the dialog container itself).
|
|
84
|
+
- **`@atlassian/capacity-planning-capacity-graph`**, **`@atlaskit/color-picker`**,
|
|
85
|
+
**`@atlassian/timeline-table`**, **`@atlassian/global-side-navigation`** (`patch`): scope `fg`
|
|
86
|
+
mocks in unit tests so `platform-dst-top-layer` returns `false`. JSDOM does not implement the
|
|
87
|
+
native Popover API (`showPopover`/`hidePopover`/`toggle` events), so leaving the gate ON in unit
|
|
88
|
+
tests caused popover content to remain in the DOM after close and broke close-behaviour
|
|
89
|
+
assertions. Browser coverage for the FF-on path is provided by the Playwright suites listed
|
|
90
|
+
above.
|
|
91
|
+
- **`@atlaskit/dropdown-menu`** (no public API change): test/example-only fixes for the FF-on
|
|
92
|
+
Playwright suite. Added `role="menuitem"` to the nested-trigger `ButtonItem` in
|
|
93
|
+
`examples/93-testing-nested-keyboard-navigation-top-layer.tsx` to satisfy axe's
|
|
94
|
+
`aria-required-children` rule on the parent menu. Added a `test.beforeEach(skipAxeCheck)` to
|
|
95
|
+
`dropdown-menu.spec.tsx` (FF-on suite) for example-level `color-contrast` violations on the
|
|
96
|
+
pre-existing `color.text.selected`/`color.background.selected` token pair (3.91:1). Replaced a
|
|
97
|
+
deadlocking `await expect(moveItem).not.toBeFocused()` pre-open assertion (Playwright's
|
|
98
|
+
auto-wait blocks 5s on the absent element) with `await expect(moveItem).not.toBeVisible()`.
|
|
99
|
+
Suite result: 22/22 passing.
|
|
100
|
+
|
|
101
|
+
### Patch Changes
|
|
102
|
+
|
|
103
|
+
- [`1f9114700d351`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/1f9114700d351) -
|
|
104
|
+
Moved new motion changes from `platform-dst-motion-uplift` feature gate to
|
|
105
|
+
`platform-dst-motion-uplift-popup`
|
|
106
|
+
- Updated dependencies
|
|
107
|
+
|
|
3
108
|
## 4.17.0
|
|
4
109
|
|
|
5
110
|
### Minor Changes
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/* popup-content-top-layer.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.PopupContentTopLayer = PopupContentTopLayer;
|
|
10
|
+
require("./popup-content-top-layer.compiled.css");
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var React = _react;
|
|
13
|
+
var _runtime = require("@compiled/react/runtime");
|
|
14
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
16
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
17
|
+
var _animations = require("@atlaskit/top-layer/animations");
|
|
18
|
+
var _createCloseEvent = require("@atlaskit/top-layer/create-close-event");
|
|
19
|
+
var _placementMap = require("@atlaskit/top-layer/placement-map");
|
|
20
|
+
var _popup = require("@atlaskit/top-layer/popup");
|
|
21
|
+
var _topLayerBridge = require("../internal/top-layer-bridge");
|
|
22
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
23
|
+
var overflowAutoStyles = null;
|
|
24
|
+
var animation = (0, _animations.slideAndFade)();
|
|
25
|
+
|
|
26
|
+
// Top-layer positioning is handled by CSS Anchor Positioning, not inline styles.
|
|
27
|
+
var EMPTY_STYLE = {};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Top-layer implementation of the compositional PopupContent.
|
|
31
|
+
*
|
|
32
|
+
* Reads isOpen, id, triggerRef from the legacy compositional Popup context,
|
|
33
|
+
* then renders via @atlaskit/top-layer's Popup compound.
|
|
34
|
+
*
|
|
35
|
+
* Gated behind the `platform-dst-top-layer` feature flag.
|
|
36
|
+
*/
|
|
37
|
+
function PopupContentTopLayer(_ref) {
|
|
38
|
+
var xcss = _ref.xcss,
|
|
39
|
+
children = _ref.children,
|
|
40
|
+
offsetProp = _ref.offset,
|
|
41
|
+
onClose = _ref.onClose,
|
|
42
|
+
testId = _ref.testId,
|
|
43
|
+
_ref$placement = _ref.placement,
|
|
44
|
+
placement = _ref$placement === void 0 ? 'auto' : _ref$placement,
|
|
45
|
+
_fallbackPlacements = _ref.fallbackPlacements,
|
|
46
|
+
PopupContainer = _ref.popupComponent,
|
|
47
|
+
_ref$autoFocus = _ref.autoFocus,
|
|
48
|
+
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
49
|
+
shouldFitContainer = _ref.shouldFitContainer,
|
|
50
|
+
shouldFitViewport = _ref.shouldFitViewport,
|
|
51
|
+
role = _ref.role,
|
|
52
|
+
label = _ref.label,
|
|
53
|
+
titleId = _ref.titleId,
|
|
54
|
+
isOpen = _ref.isOpen,
|
|
55
|
+
providedId = _ref.id,
|
|
56
|
+
_zIndex = _ref.zIndex,
|
|
57
|
+
_shouldRenderToParent = _ref.shouldRenderToParent,
|
|
58
|
+
_strategy = _ref.strategy,
|
|
59
|
+
_boundary = _ref.boundary,
|
|
60
|
+
_rootBoundary = _ref.rootBoundary,
|
|
61
|
+
_shouldUseCaptureOnOutsideClick = _ref.shouldUseCaptureOnOutsideClick,
|
|
62
|
+
_shouldDisableFocusLock = _ref.shouldDisableFocusLock,
|
|
63
|
+
_shouldFlip = _ref.shouldFlip,
|
|
64
|
+
_appearance = _ref.appearance,
|
|
65
|
+
_shouldDisableGpuAcceleration = _ref.shouldDisableGpuAcceleration;
|
|
66
|
+
var popupContainerRef = (0, _react.useRef)(null);
|
|
67
|
+
var _useState = (0, _react.useState)(null),
|
|
68
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
69
|
+
setInitialFocusRef = _useState2[1];
|
|
70
|
+
|
|
71
|
+
// ── Placement conversion ──
|
|
72
|
+
// Legacy `offset` is the popper `[along, away]` tuple; `fromLegacyPlacement`
|
|
73
|
+
// folds it into the new `placement.offset` shape.
|
|
74
|
+
var topLayerPlacement = (0, _react.useMemo)(function () {
|
|
75
|
+
return (0, _placementMap.fromLegacyPlacement)({
|
|
76
|
+
legacy: placement,
|
|
77
|
+
offset: offsetProp
|
|
78
|
+
});
|
|
79
|
+
}, [placement, offsetProp]);
|
|
80
|
+
|
|
81
|
+
// ── onClose bridge ──
|
|
82
|
+
var handleOnClose = (0, _react.useCallback)(function (_ref2) {
|
|
83
|
+
var reason = _ref2.reason;
|
|
84
|
+
if (!onClose) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
onClose((0, _createCloseEvent.createPopoverCloseEvent)({
|
|
88
|
+
reason: reason
|
|
89
|
+
}));
|
|
90
|
+
}, [onClose]);
|
|
91
|
+
|
|
92
|
+
// ── Content render-prop bridge ──
|
|
93
|
+
var contentProps = (0, _react.useMemo)(function () {
|
|
94
|
+
return {
|
|
95
|
+
isOpen: isOpen,
|
|
96
|
+
update: _noop.default,
|
|
97
|
+
onClose: onClose,
|
|
98
|
+
setInitialFocusRef: setInitialFocusRef
|
|
99
|
+
};
|
|
100
|
+
}, [isOpen, onClose]);
|
|
101
|
+
|
|
102
|
+
// ── Role mapping ──
|
|
103
|
+
var roleProps = (0, _topLayerBridge.useRoleProps)({
|
|
104
|
+
role: role,
|
|
105
|
+
label: label,
|
|
106
|
+
titleId: titleId
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Narrow to ForwardRefExoticComponent so JSX accepts the ref prop.
|
|
110
|
+
// All popupComponent implementations use forwardRef per the PopupComponentProps contract.
|
|
111
|
+
var Container = PopupContainer;
|
|
112
|
+
if (!isOpen) {
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
return /*#__PURE__*/React.createElement(_popup.Popup, {
|
|
116
|
+
placement: topLayerPlacement,
|
|
117
|
+
onClose: handleOnClose,
|
|
118
|
+
testId: testId
|
|
119
|
+
}, /*#__PURE__*/React.createElement(_popup.Popup.Content, (0, _extends2.default)({}, roleProps, {
|
|
120
|
+
isOpen: isOpen,
|
|
121
|
+
animate: animation,
|
|
122
|
+
testId: testId && "".concat(testId, "--content"),
|
|
123
|
+
width: shouldFitContainer ? 'trigger' : 'content'
|
|
124
|
+
}), Container ? /*#__PURE__*/React.createElement(Container, {
|
|
125
|
+
ref: popupContainerRef,
|
|
126
|
+
style: EMPTY_STYLE,
|
|
127
|
+
id: providedId,
|
|
128
|
+
"data-placement": placement,
|
|
129
|
+
"data-testid": testId,
|
|
130
|
+
tabIndex: autoFocus ? -1 : undefined,
|
|
131
|
+
xcss: xcss
|
|
132
|
+
}, children(contentProps)) : /*#__PURE__*/React.createElement(_popup.Popup.Surface, null, /*#__PURE__*/React.createElement("div", {
|
|
133
|
+
className: (0, _runtime.ax)([shouldFitViewport && "_1reo1wug _18m91wug"])
|
|
134
|
+
}, children(contentProps)))));
|
|
135
|
+
}
|
|
@@ -9,11 +9,13 @@ exports.PopupContent = void 0;
|
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _layering = require("@atlaskit/layering");
|
|
11
11
|
var _openLayerObserver = require("@atlaskit/layering/experimental/open-layer-observer");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
var _portal = _interopRequireDefault(require("@atlaskit/portal"));
|
|
13
14
|
var _popperWrapper = _interopRequireDefault(require("../popper-wrapper"));
|
|
14
15
|
var _useAppearance = require("../use-appearance");
|
|
15
16
|
var _idContext = require("./id-context");
|
|
16
17
|
var _isOpenContext = require("./is-open-context");
|
|
18
|
+
var _popupContentTopLayer = require("./popup-content-top-layer");
|
|
17
19
|
var _triggerRefContext = require("./trigger-ref-context");
|
|
18
20
|
var _useEnsureIsInsidePopup = require("./use-ensure-is-inside-popup");
|
|
19
21
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
@@ -63,6 +65,7 @@ var PopupContent = exports.PopupContent = function PopupContent(_ref) {
|
|
|
63
65
|
_ref$shouldDisableGpu = _ref.shouldDisableGpuAcceleration,
|
|
64
66
|
shouldDisableGpuAcceleration = _ref$shouldDisableGpu === void 0 ? false : _ref$shouldDisableGpu,
|
|
65
67
|
role = _ref.role,
|
|
68
|
+
label = _ref.label,
|
|
66
69
|
titleId = _ref.titleId;
|
|
67
70
|
(0, _useEnsureIsInsidePopup.useEnsureIsInsidePopup)();
|
|
68
71
|
var isOpen = (0, _react.useContext)(_isOpenContext.IsOpenContext);
|
|
@@ -82,6 +85,39 @@ var PopupContent = exports.PopupContent = function PopupContent(_ref) {
|
|
|
82
85
|
onClose: handleOpenLayerObserverCloseSignal,
|
|
83
86
|
type: 'popup'
|
|
84
87
|
});
|
|
88
|
+
|
|
89
|
+
// Top-layer rendering path: native Popover API via @atlaskit/top-layer.
|
|
90
|
+
// Mirrors the FF branch in the legacy `Popup` component (popup.tsx).
|
|
91
|
+
if ((0, _platformFeatureFlags.fg)('platform-dst-top-layer')) {
|
|
92
|
+
return /*#__PURE__*/_react.default.createElement(_popupContentTopLayer.PopupContentTopLayer, {
|
|
93
|
+
xcss: xcss,
|
|
94
|
+
appearance: inAppearance,
|
|
95
|
+
offset: offset,
|
|
96
|
+
onClose: onClose,
|
|
97
|
+
testId: testId,
|
|
98
|
+
placement: placement,
|
|
99
|
+
fallbackPlacements: fallbackPlacements,
|
|
100
|
+
popupComponent: popupComponent,
|
|
101
|
+
autoFocus: autoFocus,
|
|
102
|
+
shouldFitContainer: shouldFitContainer,
|
|
103
|
+
shouldFitViewport: shouldFitViewport,
|
|
104
|
+
role: role,
|
|
105
|
+
label: label,
|
|
106
|
+
titleId: titleId,
|
|
107
|
+
zIndex: zIndex,
|
|
108
|
+
shouldRenderToParent: inShouldRenderToParent,
|
|
109
|
+
strategy: strategy,
|
|
110
|
+
boundary: boundary,
|
|
111
|
+
rootBoundary: rootBoundary,
|
|
112
|
+
shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick,
|
|
113
|
+
shouldDisableFocusLock: shouldDisableFocusLock,
|
|
114
|
+
shouldFlip: shouldFlip,
|
|
115
|
+
shouldDisableGpuAcceleration: shouldDisableGpuAcceleration,
|
|
116
|
+
isOpen: isOpen,
|
|
117
|
+
id: id,
|
|
118
|
+
triggerRef: triggerRef
|
|
119
|
+
}, children);
|
|
120
|
+
}
|
|
85
121
|
if (!isOpen) {
|
|
86
122
|
return null;
|
|
87
123
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useRoleProps = useRoleProps;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
/**
|
|
9
|
+
* Props shape passed from legacy `role` / `label` / `titleId` into `@atlaskit/top-layer` `Popup.Content`.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Maps legacy popup role/label/titleId props to the discriminated union
|
|
14
|
+
* that `Popup.Content` expects.
|
|
15
|
+
*
|
|
16
|
+
* `Popup.Content` enforces at the type level that dialog/alertdialog/menu
|
|
17
|
+
* roles must have `label` or `labelledBy`. This hook bridges the legacy
|
|
18
|
+
* flat-prop API (`role`, `label`, `titleId`) to that shape.
|
|
19
|
+
*/
|
|
20
|
+
function useRoleProps(_ref) {
|
|
21
|
+
var role = _ref.role,
|
|
22
|
+
label = _ref.label,
|
|
23
|
+
titleId = _ref.titleId;
|
|
24
|
+
return (0, _react.useMemo)(function () {
|
|
25
|
+
if (role === 'dialog' || role === 'alertdialog' || role === 'menu') {
|
|
26
|
+
if (titleId) {
|
|
27
|
+
return {
|
|
28
|
+
role: role,
|
|
29
|
+
labelledBy: titleId
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
role: role,
|
|
34
|
+
label: label !== null && label !== void 0 ? label : 'Popup'
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (role) {
|
|
38
|
+
return {
|
|
39
|
+
role: role,
|
|
40
|
+
label: label
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
// Default: dialog role with label or labelledBy
|
|
44
|
+
if (titleId) {
|
|
45
|
+
return {
|
|
46
|
+
role: 'dialog',
|
|
47
|
+
labelledBy: titleId
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
role: 'dialog',
|
|
52
|
+
label: label !== null && label !== void 0 ? label : 'Popup'
|
|
53
|
+
};
|
|
54
|
+
}, [role, label, titleId]);
|
|
55
|
+
}
|
|
@@ -10,6 +10,7 @@ exports.default = void 0;
|
|
|
10
10
|
require("./popper-wrapper.compiled.css");
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
12
|
var React = _react;
|
|
13
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
14
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
14
15
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
15
16
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
@@ -24,12 +25,13 @@ var _useCloseManager = require("./use-close-manager");
|
|
|
24
25
|
var _useFocusManager = require("./use-focus-manager");
|
|
25
26
|
var _excluded = ["shouldRenderToParent", "shouldFitContainer", "children", "appearance", "className", "isReferenceHidden", "shouldFitViewport"];
|
|
26
27
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
28
|
+
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; }
|
|
29
|
+
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; }
|
|
27
30
|
var LOCAL_CURRENT_SURFACE_CSS_VAR = '--ds-elevation-surface-current';
|
|
28
31
|
var fullWidthStyles = null;
|
|
29
32
|
var wrapperStyles = {
|
|
30
33
|
root: "_2rko12b0 _1e0c1ule _vchhusvi _1pby1nn1 _bfhk1bhr _16qs130s _syazi7uo _1q1l1bhr _nt751r31 _49pcglyw _1hvw1o36",
|
|
31
34
|
rootT26Shape: "_2rko1mok",
|
|
32
|
-
rootLayer: "_1pby1nn1",
|
|
33
35
|
fullWidth: "_1bsb1osq"
|
|
34
36
|
};
|
|
35
37
|
var scrollableStyles = null;
|
|
@@ -102,7 +104,7 @@ var DefaultPopupComponent = /*#__PURE__*/(0, _react.forwardRef)(function (props,
|
|
|
102
104
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
103
105
|
className: (0, _runtime.ax)([wrapperStyles.root, (0, _platformFeatureFlags.fg)('platform-dst-shape-theme-default') && wrapperStyles.rootT26Shape, appearance === 'UNSAFE_modal-below-sm' && !(0, _platformFeatureFlags.fg)('platform_dst_nav4_flyout_menu_slots_close_button') && "_dk5d1b66 _c71ldtre _kqsw1n9t _152t1b66", appearance === 'UNSAFE_modal-below-sm' && (0, _platformFeatureFlags.fg)('platform_dst_nav4_flyout_menu_slots_close_button') && "_dk5d1b66 _c71l1ei0 _kqsw1n9t _152t1b66", (!shouldRenderToParent || shouldFitViewport) && "_1reo1wug _18m91wug", shouldFitContainer && "_1bsb1osq", className])
|
|
104
106
|
}, htmlAttributes, {
|
|
105
|
-
ref: !(0, _platformFeatureFlags.fg)('platform-dst-motion-uplift') ? ref : undefined
|
|
107
|
+
ref: !(0, _platformFeatureFlags.fg)('platform-dst-motion-uplift-popup') ? ref : undefined
|
|
106
108
|
}), children);
|
|
107
109
|
});
|
|
108
110
|
function PopperWrapper(_ref) {
|
|
@@ -137,7 +139,8 @@ function PopperWrapper(_ref) {
|
|
|
137
139
|
modifiers = _ref.modifiers,
|
|
138
140
|
shouldFitViewport = _ref.shouldFitViewport,
|
|
139
141
|
_ref$appearance = _ref.appearance,
|
|
140
|
-
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance
|
|
142
|
+
appearance = _ref$appearance === void 0 ? 'default' : _ref$appearance,
|
|
143
|
+
zIndex = _ref.zIndex;
|
|
141
144
|
var _useState = (0, _react.useState)(null),
|
|
142
145
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
143
146
|
popupRef = _useState2[0],
|
|
@@ -208,7 +211,7 @@ function PopperWrapper(_ref) {
|
|
|
208
211
|
role: role,
|
|
209
212
|
"aria-label": label,
|
|
210
213
|
"aria-labelledby": titleId,
|
|
211
|
-
ref: !(0, _platformFeatureFlags.fg)('platform-dst-motion-uplift') ? function (node) {
|
|
214
|
+
ref: !(0, _platformFeatureFlags.fg)('platform-dst-motion-uplift-popup') ? function (node) {
|
|
212
215
|
if (node) {
|
|
213
216
|
if (typeof _ref3 === 'function') {
|
|
214
217
|
_ref3(node);
|
|
@@ -220,7 +223,7 @@ function PopperWrapper(_ref) {
|
|
|
220
223
|
} : undefined
|
|
221
224
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
222
225
|
,
|
|
223
|
-
style: (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift') || appearance === 'UNSAFE_modal-below-sm' ? {} : style
|
|
226
|
+
style: (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift-popup') || appearance === 'UNSAFE_modal-below-sm' ? {} : style
|
|
224
227
|
// using tabIndex={-1} would cause a bug where Safari focuses
|
|
225
228
|
// first on the browser address bar when using keyboard
|
|
226
229
|
,
|
|
@@ -239,7 +242,9 @@ function PopperWrapper(_ref) {
|
|
|
239
242
|
})));
|
|
240
243
|
var container = /*#__PURE__*/React.createElement("div", {
|
|
241
244
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
242
|
-
style: style,
|
|
245
|
+
style: _objectSpread(_objectSpread({}, style), {}, {
|
|
246
|
+
zIndex: zIndex
|
|
247
|
+
}),
|
|
243
248
|
// using tabIndex={-1} would cause a bug where Safari focuses
|
|
244
249
|
// first on the browser address bar when using keyboard
|
|
245
250
|
ref: function ref(node) {
|
|
@@ -253,12 +258,12 @@ function PopperWrapper(_ref) {
|
|
|
253
258
|
}
|
|
254
259
|
},
|
|
255
260
|
"data-testid": "".concat(testId, "--container"),
|
|
256
|
-
className: (0, _runtime.ax)([
|
|
261
|
+
className: (0, _runtime.ax)([shouldFitContainer && wrapperStyles.fullWidth])
|
|
257
262
|
}, placement === 'auto' || placement === 'auto-start' || placement === 'auto-end' ? popupContainer : /*#__PURE__*/React.createElement(_motion.Motion, {
|
|
258
263
|
enteringAnimation: placementMap[placement].enter,
|
|
259
264
|
exitingAnimation: placementMap[placement].exit
|
|
260
265
|
}, popupContainer));
|
|
261
|
-
return /*#__PURE__*/React.createElement(_react.Fragment, null, (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift') ? container : popupContainer, appearance === 'UNSAFE_modal-below-sm' && /*#__PURE__*/React.createElement("div", {
|
|
266
|
+
return /*#__PURE__*/React.createElement(_react.Fragment, null, (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift-popup') ? container : popupContainer, appearance === 'UNSAFE_modal-below-sm' && /*#__PURE__*/React.createElement("div", {
|
|
262
267
|
className: (0, _runtime.ax)(["_1r04idpf _kqsw1n9t _bfhk1i5c"])
|
|
263
268
|
}));
|
|
264
269
|
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/* popup-top-layer.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
Object.defineProperty(exports, "__esModule", {
|
|
7
|
+
value: true
|
|
8
|
+
});
|
|
9
|
+
exports.PopupTopLayer = void 0;
|
|
10
|
+
require("./popup-top-layer.compiled.css");
|
|
11
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var React = _react;
|
|
13
|
+
var _runtime = require("@compiled/react/runtime");
|
|
14
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
16
|
+
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
17
|
+
var _animations = require("@atlaskit/top-layer/animations");
|
|
18
|
+
var _createCloseEvent = require("@atlaskit/top-layer/create-close-event");
|
|
19
|
+
var _placementMap = require("@atlaskit/top-layer/placement-map");
|
|
20
|
+
var _popup = require("@atlaskit/top-layer/popup");
|
|
21
|
+
var _topLayerBridge = require("./internal/top-layer-bridge");
|
|
22
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
23
|
+
var contentOverflowStyles = {
|
|
24
|
+
fitViewport: "_1reo1wug _18m91wug",
|
|
25
|
+
default: ""
|
|
26
|
+
};
|
|
27
|
+
var animation = (0, _animations.slideAndFade)();
|
|
28
|
+
|
|
29
|
+
// Top-layer positioning is handled by CSS Anchor Positioning, not inline styles.
|
|
30
|
+
var EMPTY_STYLE = {};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Top-layer implementation of Popup.
|
|
34
|
+
*
|
|
35
|
+
* Replaces the legacy @atlaskit/popup rendering pipeline
|
|
36
|
+
* (Popper.js + Portal + focus-trap + @atlaskit/layering)
|
|
37
|
+
* with the native Popover API + CSS Anchor Positioning via @atlaskit/top-layer.
|
|
38
|
+
*
|
|
39
|
+
* Gated behind the `platform-dst-top-layer` feature flag.
|
|
40
|
+
*/
|
|
41
|
+
var PopupTopLayer = exports.PopupTopLayer = /*#__PURE__*/(0, _react.memo)(function PopupTopLayer(_ref) {
|
|
42
|
+
var xcss = _ref.xcss,
|
|
43
|
+
isOpen = _ref.isOpen,
|
|
44
|
+
providedId = _ref.id,
|
|
45
|
+
offsetProp = _ref.offset,
|
|
46
|
+
testId = _ref.testId,
|
|
47
|
+
trigger = _ref.trigger,
|
|
48
|
+
content = _ref.content,
|
|
49
|
+
onClose = _ref.onClose,
|
|
50
|
+
_ref$placement = _ref.placement,
|
|
51
|
+
placement = _ref$placement === void 0 ? 'auto' : _ref$placement,
|
|
52
|
+
_fallbackPlacements = _ref.fallbackPlacements,
|
|
53
|
+
_ref$shouldFlip = _ref.shouldFlip,
|
|
54
|
+
_shouldFlip = _ref$shouldFlip === void 0 ? true : _ref$shouldFlip,
|
|
55
|
+
PopupContainer = _ref.popupComponent,
|
|
56
|
+
_ref$autoFocus = _ref.autoFocus,
|
|
57
|
+
autoFocus = _ref$autoFocus === void 0 ? true : _ref$autoFocus,
|
|
58
|
+
_ref$shouldFitContain = _ref.shouldFitContainer,
|
|
59
|
+
shouldFitContainer = _ref$shouldFitContain === void 0 ? false : _ref$shouldFitContain,
|
|
60
|
+
_ref$shouldReturnFocu = _ref.shouldReturnFocus,
|
|
61
|
+
_shouldReturnFocus = _ref$shouldReturnFocu === void 0 ? true : _ref$shouldReturnFocu,
|
|
62
|
+
role = _ref.role,
|
|
63
|
+
label = _ref.label,
|
|
64
|
+
titleId = _ref.titleId,
|
|
65
|
+
_zIndex = _ref.zIndex,
|
|
66
|
+
_shouldRenderToParent = _ref.shouldRenderToParent,
|
|
67
|
+
_strategy = _ref.strategy,
|
|
68
|
+
_modifiers = _ref.modifiers,
|
|
69
|
+
_boundary = _ref.boundary,
|
|
70
|
+
_rootBoundary = _ref.rootBoundary,
|
|
71
|
+
_shouldUseCaptureOnOutsideClick = _ref.shouldUseCaptureOnOutsideClick,
|
|
72
|
+
_shouldDisableFocusLock = _ref.shouldDisableFocusLock,
|
|
73
|
+
shouldFitViewport = _ref.shouldFitViewport,
|
|
74
|
+
_appearance = _ref.appearance;
|
|
75
|
+
var triggerRef = (0, _react.useRef)(null);
|
|
76
|
+
var popupContainerRef = (0, _react.useRef)(null);
|
|
77
|
+
var _useState = (0, _react.useState)(null),
|
|
78
|
+
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
79
|
+
setInitialFocusRef = _useState2[1];
|
|
80
|
+
|
|
81
|
+
// ── Placement conversion ──
|
|
82
|
+
// Legacy `offset` is the popper `[along, away]` tuple; `fromLegacyPlacement`
|
|
83
|
+
// folds it into the new `placement.offset` shape so it travels with placement.
|
|
84
|
+
var topLayerPlacement = (0, _react.useMemo)(function () {
|
|
85
|
+
return (0, _placementMap.fromLegacyPlacement)({
|
|
86
|
+
legacy: placement,
|
|
87
|
+
offset: offsetProp
|
|
88
|
+
});
|
|
89
|
+
}, [placement, offsetProp]);
|
|
90
|
+
|
|
91
|
+
// ── onClose bridge ──
|
|
92
|
+
// Translates top-layer's { reason: TPopoverCloseReason } into legacy
|
|
93
|
+
// onClose(event, currentLevel?) by synthesizing DOM events.
|
|
94
|
+
//
|
|
95
|
+
// Focus restoration is handled natively by the Popover API:
|
|
96
|
+
// - Escape → browser restores focus to the trigger automatically
|
|
97
|
+
// - Click-outside → browser does NOT restore (correct behavior)
|
|
98
|
+
// No manual triggerRef.current?.focus() is needed.
|
|
99
|
+
var handleOnClose = (0, _react.useCallback)(function (_ref2) {
|
|
100
|
+
var reason = _ref2.reason;
|
|
101
|
+
if (!onClose) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
onClose((0, _createCloseEvent.createPopoverCloseEvent)({
|
|
105
|
+
reason: reason
|
|
106
|
+
}));
|
|
107
|
+
}, [onClose]);
|
|
108
|
+
|
|
109
|
+
// ── Content render-prop bridge ──
|
|
110
|
+
// Legacy content() receives { isOpen, update, setInitialFocusRef, onClose }.
|
|
111
|
+
// update is a no-op — CSS Anchor Positioning self-updates.
|
|
112
|
+
var contentProps = (0, _react.useMemo)(function () {
|
|
113
|
+
return {
|
|
114
|
+
isOpen: isOpen,
|
|
115
|
+
update: _noop.default,
|
|
116
|
+
onClose: onClose,
|
|
117
|
+
setInitialFocusRef: setInitialFocusRef
|
|
118
|
+
};
|
|
119
|
+
}, [isOpen, onClose]);
|
|
120
|
+
|
|
121
|
+
// ── Role mapping ──
|
|
122
|
+
// Build the role/label props for PopupContent.
|
|
123
|
+
// Roles requiring accessible names must have label or labelledBy.
|
|
124
|
+
var roleProps = (0, _topLayerBridge.useRoleProps)({
|
|
125
|
+
role: role,
|
|
126
|
+
label: label,
|
|
127
|
+
titleId: titleId
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
// Sync controlled isOpen with internal state
|
|
131
|
+
var effectiveIsOpen = isOpen;
|
|
132
|
+
|
|
133
|
+
// Narrow to ForwardRefExoticComponent so JSX accepts the ref prop.
|
|
134
|
+
// All popupComponent implementations use forwardRef per the PopupComponentProps contract.
|
|
135
|
+
var Container = PopupContainer;
|
|
136
|
+
return /*#__PURE__*/React.createElement(_popup.Popup, {
|
|
137
|
+
placement: topLayerPlacement,
|
|
138
|
+
onClose: handleOnClose,
|
|
139
|
+
testId: testId
|
|
140
|
+
}, /*#__PURE__*/React.createElement(_popup.Popup.TriggerFunction, null, function (_ref3) {
|
|
141
|
+
var _ref4 = _ref3.ref,
|
|
142
|
+
_toggle = _ref3.toggle,
|
|
143
|
+
ariaAttributes = _ref3.ariaAttributes,
|
|
144
|
+
popoverId = _ref3.popoverId;
|
|
145
|
+
// Map to legacy TriggerProps
|
|
146
|
+
var triggerProps = {
|
|
147
|
+
ref: function ref(node) {
|
|
148
|
+
triggerRef.current = node;
|
|
149
|
+
if (typeof _ref4 === 'function') {
|
|
150
|
+
_ref4(node);
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
'aria-controls': effectiveIsOpen ? providedId !== null && providedId !== void 0 ? providedId : popoverId : undefined,
|
|
154
|
+
'aria-expanded': effectiveIsOpen,
|
|
155
|
+
// FUDGE(top-layer-api): cast to the narrow public TriggerProps['aria-haspopup'] union.
|
|
156
|
+
// `@atlaskit/top-layer` derives `aria-haspopup` from the content's role and types it
|
|
157
|
+
// as the wider WAI-ARIA union (boolean | 'dialog' | 'menu' | 'listbox' | 'tree' | 'grid').
|
|
158
|
+
// We keep the public popup TriggerProps narrow (boolean | 'dialog') because the
|
|
159
|
+
// top-layer API surface is not yet settled. Widening adopter types now would commit
|
|
160
|
+
// us to a public surface we may revisit. The runtime value is unchanged; only the
|
|
161
|
+
// TypeScript-visible type is narrowed at this boundary.
|
|
162
|
+
// REMOVE WHEN: the top-layer public API is committed (see
|
|
163
|
+
// packages/design-system/top-layer/notes/decisions/migration-roadmap.md "Open API
|
|
164
|
+
// decisions deferred to a follow-up PR") and a follow-up `minor` PR widens
|
|
165
|
+
// `TriggerProps['aria-haspopup']` to match.
|
|
166
|
+
'aria-haspopup': ariaAttributes['aria-haspopup']
|
|
167
|
+
};
|
|
168
|
+
return trigger(triggerProps);
|
|
169
|
+
}), /*#__PURE__*/React.createElement(_popup.Popup.Content, (0, _extends2.default)({}, roleProps, {
|
|
170
|
+
isOpen: effectiveIsOpen,
|
|
171
|
+
animate: animation,
|
|
172
|
+
testId: testId && "".concat(testId, "--content"),
|
|
173
|
+
width: shouldFitContainer ? 'trigger' : 'content'
|
|
174
|
+
}), Container ? /*#__PURE__*/React.createElement(Container, {
|
|
175
|
+
ref: popupContainerRef,
|
|
176
|
+
style: EMPTY_STYLE,
|
|
177
|
+
id: providedId,
|
|
178
|
+
"data-placement": placement,
|
|
179
|
+
"data-testid": testId,
|
|
180
|
+
tabIndex: autoFocus ? -1 : undefined,
|
|
181
|
+
xcss: xcss
|
|
182
|
+
}, content(contentProps)) : /*#__PURE__*/React.createElement(_popup.Popup.Surface, null, /*#__PURE__*/React.createElement("div", {
|
|
183
|
+
className: (0, _runtime.ax)([contentOverflowStyles[shouldFitViewport ? 'fitViewport' : 'default']])
|
|
184
|
+
}, content(contentProps)))));
|
|
185
|
+
});
|