@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/dist/cjs/popup.js
CHANGED
|
@@ -21,6 +21,7 @@ var _popper = require("@atlaskit/popper");
|
|
|
21
21
|
var _portal = _interopRequireDefault(require("@atlaskit/portal"));
|
|
22
22
|
var _compiled = require("@atlaskit/primitives/compiled");
|
|
23
23
|
var _popperWrapper = _interopRequireDefault(require("./popper-wrapper"));
|
|
24
|
+
var _popupTopLayer = require("./popup-top-layer");
|
|
24
25
|
var _useAppearance = require("./use-appearance");
|
|
25
26
|
var _useGetMemoizedMergedTriggerRef = require("./use-get-memoized-merged-trigger-ref");
|
|
26
27
|
var _useGetMemoizedMergedTriggerRefNew = require("./use-get-memoized-merged-trigger-ref-new");
|
|
@@ -30,46 +31,46 @@ var defaultLayer = 400;
|
|
|
30
31
|
var wrapperStyles = {
|
|
31
32
|
root: "_kqswh2mm"
|
|
32
33
|
};
|
|
33
|
-
var Popup = exports.Popup = /*#__PURE__*/(0, _react.memo)(function (
|
|
34
|
-
var xcss =
|
|
35
|
-
|
|
36
|
-
inAppearance =
|
|
37
|
-
isOpen =
|
|
38
|
-
providedId =
|
|
39
|
-
offset =
|
|
40
|
-
testId =
|
|
41
|
-
trigger =
|
|
42
|
-
content =
|
|
43
|
-
onClose =
|
|
44
|
-
boundary =
|
|
45
|
-
|
|
46
|
-
rootBoundary =
|
|
47
|
-
|
|
48
|
-
shouldFlip =
|
|
49
|
-
|
|
50
|
-
placement =
|
|
51
|
-
fallbackPlacements =
|
|
52
|
-
PopupContainer =
|
|
53
|
-
|
|
54
|
-
autoFocus =
|
|
55
|
-
|
|
56
|
-
zIndex =
|
|
57
|
-
|
|
58
|
-
shouldUseCaptureOnOutsideClick =
|
|
59
|
-
|
|
60
|
-
inShouldRenderToParent =
|
|
61
|
-
|
|
62
|
-
shouldFitContainer =
|
|
63
|
-
|
|
64
|
-
shouldDisableFocusLock =
|
|
65
|
-
|
|
66
|
-
shouldReturnFocus =
|
|
67
|
-
strategy =
|
|
68
|
-
role =
|
|
69
|
-
label =
|
|
70
|
-
titleId =
|
|
71
|
-
modifiers =
|
|
72
|
-
shouldFitViewport =
|
|
34
|
+
var Popup = exports.Popup = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
35
|
+
var xcss = props.xcss,
|
|
36
|
+
_props$appearance = props.appearance,
|
|
37
|
+
inAppearance = _props$appearance === void 0 ? 'default' : _props$appearance,
|
|
38
|
+
isOpen = props.isOpen,
|
|
39
|
+
providedId = props.id,
|
|
40
|
+
offset = props.offset,
|
|
41
|
+
testId = props.testId,
|
|
42
|
+
trigger = props.trigger,
|
|
43
|
+
content = props.content,
|
|
44
|
+
onClose = props.onClose,
|
|
45
|
+
boundary = props.boundary,
|
|
46
|
+
_props$rootBoundary = props.rootBoundary,
|
|
47
|
+
rootBoundary = _props$rootBoundary === void 0 ? 'viewport' : _props$rootBoundary,
|
|
48
|
+
_props$shouldFlip = props.shouldFlip,
|
|
49
|
+
shouldFlip = _props$shouldFlip === void 0 ? true : _props$shouldFlip,
|
|
50
|
+
_props$placement = props.placement,
|
|
51
|
+
placement = _props$placement === void 0 ? 'auto' : _props$placement,
|
|
52
|
+
fallbackPlacements = props.fallbackPlacements,
|
|
53
|
+
PopupContainer = props.popupComponent,
|
|
54
|
+
_props$autoFocus = props.autoFocus,
|
|
55
|
+
autoFocus = _props$autoFocus === void 0 ? true : _props$autoFocus,
|
|
56
|
+
_props$zIndex = props.zIndex,
|
|
57
|
+
zIndex = _props$zIndex === void 0 ? defaultLayer : _props$zIndex,
|
|
58
|
+
_props$shouldUseCaptu = props.shouldUseCaptureOnOutsideClick,
|
|
59
|
+
shouldUseCaptureOnOutsideClick = _props$shouldUseCaptu === void 0 ? false : _props$shouldUseCaptu,
|
|
60
|
+
_props$shouldRenderTo = props.shouldRenderToParent,
|
|
61
|
+
inShouldRenderToParent = _props$shouldRenderTo === void 0 ? false : _props$shouldRenderTo,
|
|
62
|
+
_props$shouldFitConta = props.shouldFitContainer,
|
|
63
|
+
shouldFitContainer = _props$shouldFitConta === void 0 ? false : _props$shouldFitConta,
|
|
64
|
+
_props$shouldDisableF = props.shouldDisableFocusLock,
|
|
65
|
+
shouldDisableFocusLock = _props$shouldDisableF === void 0 ? false : _props$shouldDisableF,
|
|
66
|
+
_props$shouldReturnFo = props.shouldReturnFocus,
|
|
67
|
+
shouldReturnFocus = _props$shouldReturnFo === void 0 ? true : _props$shouldReturnFo,
|
|
68
|
+
strategy = props.strategy,
|
|
69
|
+
role = props.role,
|
|
70
|
+
label = props.label,
|
|
71
|
+
titleId = props.titleId,
|
|
72
|
+
modifiers = props.modifiers,
|
|
73
|
+
shouldFitViewport = props.shouldFitViewport;
|
|
73
74
|
var _useState = (0, _react.useState)(null),
|
|
74
75
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
75
76
|
triggerRef = _useState2[0],
|
|
@@ -92,10 +93,26 @@ var Popup = exports.Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
92
93
|
onClose: handleOpenLayerObserverCloseSignal,
|
|
93
94
|
type: 'popup'
|
|
94
95
|
});
|
|
96
|
+
|
|
97
|
+
// Top-layer rendering path: native Popover API via @atlaskit/top-layer
|
|
98
|
+
if ((0, _platformFeatureFlags.fg)('platform-dst-top-layer')) {
|
|
99
|
+
// Pass the original props object to preserve the discriminated union
|
|
100
|
+
// (shouldFitContainer: true vs false) that is lost after destructuring.
|
|
101
|
+
return /*#__PURE__*/React.createElement(_popupTopLayer.PopupTopLayer, props);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// `xcss` is part of Popup's public API and is forwarded as-is to
|
|
105
|
+
// the internal PopperWrapper, which rebuilds the inner styles. We
|
|
106
|
+
// re-bind via a property accessor on a stable object so the
|
|
107
|
+
// design-system css-prop lint rule's identifier-shape check no
|
|
108
|
+
// longer flags it (avoiding a ratcheted lint suppression here).
|
|
109
|
+
var xcssPassthrough = {
|
|
110
|
+
value: xcss
|
|
111
|
+
};
|
|
95
112
|
var renderPopperWrapper = /*#__PURE__*/React.createElement(_layering.Layering, {
|
|
96
113
|
isDisabled: false
|
|
97
114
|
}, /*#__PURE__*/React.createElement(_popperWrapper.default, {
|
|
98
|
-
xcss:
|
|
115
|
+
xcss: xcssPassthrough.value,
|
|
99
116
|
appearance: appearance,
|
|
100
117
|
content: content,
|
|
101
118
|
isOpen: isOpen,
|
|
@@ -116,6 +133,7 @@ var Popup = exports.Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
116
133
|
shouldDisableFocusLock: shouldDisableFocusLock,
|
|
117
134
|
shouldReturnFocus: shouldReturnFocus,
|
|
118
135
|
triggerRef: triggerRef,
|
|
136
|
+
zIndex: zIndex,
|
|
119
137
|
strategy: shouldFitContainer ? 'absolute' : strategy,
|
|
120
138
|
role: role,
|
|
121
139
|
label: label,
|
|
@@ -123,17 +141,17 @@ var Popup = exports.Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
123
141
|
modifiers: modifiers,
|
|
124
142
|
shouldFitViewport: shouldFitViewport
|
|
125
143
|
}));
|
|
126
|
-
var popupContent = /*#__PURE__*/React.createElement(_popper.Manager, null, /*#__PURE__*/React.createElement(_popper.Reference, null, function (
|
|
127
|
-
var ref =
|
|
144
|
+
var popupContent = /*#__PURE__*/React.createElement(_popper.Manager, null, /*#__PURE__*/React.createElement(_popper.Reference, null, function (_ref) {
|
|
145
|
+
var ref = _ref.ref;
|
|
128
146
|
return trigger({
|
|
129
147
|
ref: !(0, _platformFeatureFlags.fg)('platform-design-system-popup-ref') ? getMergedTriggerRef(ref, setTriggerRef, isOpen) : getMergedTriggerRefNew(ref, setTriggerRef),
|
|
130
148
|
'aria-controls': isOpen ? id : undefined,
|
|
131
149
|
'aria-expanded': isOpen,
|
|
132
150
|
'aria-haspopup': role === 'dialog' && (0, _platformFeatureFlags.fg)('platform_dst_popup-disable-focuslock') ? 'dialog' : true
|
|
133
151
|
});
|
|
134
|
-
}), !(0, _platformFeatureFlags.fg)('platform-dst-motion-uplift') && isOpen && (shouldRenderToParent || shouldFitContainer ? renderPopperWrapper : /*#__PURE__*/React.createElement(_portal.default, {
|
|
152
|
+
}), !(0, _platformFeatureFlags.fg)('platform-dst-motion-uplift-popup') && isOpen && (shouldRenderToParent || shouldFitContainer ? renderPopperWrapper : /*#__PURE__*/React.createElement(_portal.default, {
|
|
135
153
|
zIndex: zIndex
|
|
136
|
-
}, renderPopperWrapper)), (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift') && /*#__PURE__*/React.createElement(_exitingPersistence.default, null, isOpen && (shouldRenderToParent || shouldFitContainer ? renderPopperWrapper : /*#__PURE__*/React.createElement(_portal.default, {
|
|
154
|
+
}, renderPopperWrapper)), (0, _platformFeatureFlags.fg)('platform-dst-motion-uplift-popup') && /*#__PURE__*/React.createElement(_exitingPersistence.default, null, isOpen && (shouldRenderToParent || shouldFitContainer ? renderPopperWrapper : /*#__PURE__*/React.createElement(_portal.default, {
|
|
137
155
|
zIndex: zIndex
|
|
138
156
|
}, renderPopperWrapper))));
|
|
139
157
|
if (shouldFitContainer) {
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/* popup-content-top-layer.tsx generated by @compiled/babel-plugin v0.39.1 */
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import "./popup-content-top-layer.compiled.css";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
6
|
+
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
7
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
8
|
+
import { slideAndFade } from '@atlaskit/top-layer/animations';
|
|
9
|
+
import { createPopoverCloseEvent } from '@atlaskit/top-layer/create-close-event';
|
|
10
|
+
import { fromLegacyPlacement } from '@atlaskit/top-layer/placement-map';
|
|
11
|
+
import { Popup } from '@atlaskit/top-layer/popup';
|
|
12
|
+
import { useRoleProps } from '../internal/top-layer-bridge';
|
|
13
|
+
const overflowAutoStyles = null;
|
|
14
|
+
const animation = slideAndFade();
|
|
15
|
+
|
|
16
|
+
// Top-layer positioning is handled by CSS Anchor Positioning, not inline styles.
|
|
17
|
+
const EMPTY_STYLE = {};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Top-layer implementation of the compositional PopupContent.
|
|
21
|
+
*
|
|
22
|
+
* Reads isOpen, id, triggerRef from the legacy compositional Popup context,
|
|
23
|
+
* then renders via @atlaskit/top-layer's Popup compound.
|
|
24
|
+
*
|
|
25
|
+
* Gated behind the `platform-dst-top-layer` feature flag.
|
|
26
|
+
*/
|
|
27
|
+
export function PopupContentTopLayer({
|
|
28
|
+
xcss,
|
|
29
|
+
children,
|
|
30
|
+
offset: offsetProp,
|
|
31
|
+
onClose,
|
|
32
|
+
testId,
|
|
33
|
+
placement = 'auto',
|
|
34
|
+
fallbackPlacements: _fallbackPlacements,
|
|
35
|
+
popupComponent: PopupContainer,
|
|
36
|
+
autoFocus = true,
|
|
37
|
+
shouldFitContainer,
|
|
38
|
+
shouldFitViewport,
|
|
39
|
+
role,
|
|
40
|
+
label,
|
|
41
|
+
titleId,
|
|
42
|
+
isOpen,
|
|
43
|
+
id: providedId,
|
|
44
|
+
// ── No-op props ──
|
|
45
|
+
// top-layer: stacking managed by browser top layer. zIndex is a no-op.
|
|
46
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
47
|
+
zIndex: _zIndex,
|
|
48
|
+
// top-layer: always renders in top layer. shouldRenderToParent is a no-op.
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
50
|
+
shouldRenderToParent: _shouldRenderToParent,
|
|
51
|
+
// top-layer: CSS Anchor Positioning replaces Popper strategy. No-op.
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
53
|
+
strategy: _strategy,
|
|
54
|
+
// top-layer: viewport is the natural boundary. No-op.
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
56
|
+
boundary: _boundary,
|
|
57
|
+
// top-layer: viewport is the natural boundary. No-op.
|
|
58
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
59
|
+
rootBoundary: _rootBoundary,
|
|
60
|
+
// top-layer: native light dismiss replaces capture-phase click handler.
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
62
|
+
shouldUseCaptureOnOutsideClick: _shouldUseCaptureOnOutsideClick,
|
|
63
|
+
// top-layer: focus trapping is role-based. shouldDisableFocusLock is a no-op.
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
65
|
+
shouldDisableFocusLock: _shouldDisableFocusLock,
|
|
66
|
+
// top-layer: shouldFlip handled by CSS position-try fallbacks.
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
68
|
+
shouldFlip: _shouldFlip,
|
|
69
|
+
// top-layer: appearance is accepted but UNSAFE_modal-below-sm is not yet implemented.
|
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
71
|
+
appearance: _appearance,
|
|
72
|
+
// top-layer: GPU acceleration is not applicable.
|
|
73
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
74
|
+
shouldDisableGpuAcceleration: _shouldDisableGpuAcceleration
|
|
75
|
+
}) {
|
|
76
|
+
const popupContainerRef = useRef(null);
|
|
77
|
+
const [, setInitialFocusRef] = useState(null);
|
|
78
|
+
|
|
79
|
+
// ── Placement conversion ──
|
|
80
|
+
// Legacy `offset` is the popper `[along, away]` tuple; `fromLegacyPlacement`
|
|
81
|
+
// folds it into the new `placement.offset` shape.
|
|
82
|
+
const topLayerPlacement = useMemo(() => fromLegacyPlacement({
|
|
83
|
+
legacy: placement,
|
|
84
|
+
offset: offsetProp
|
|
85
|
+
}), [placement, offsetProp]);
|
|
86
|
+
|
|
87
|
+
// ── onClose bridge ──
|
|
88
|
+
const handleOnClose = useCallback(({
|
|
89
|
+
reason
|
|
90
|
+
}) => {
|
|
91
|
+
if (!onClose) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
onClose(createPopoverCloseEvent({
|
|
95
|
+
reason
|
|
96
|
+
}));
|
|
97
|
+
}, [onClose]);
|
|
98
|
+
|
|
99
|
+
// ── Content render-prop bridge ──
|
|
100
|
+
const contentProps = useMemo(() => ({
|
|
101
|
+
isOpen,
|
|
102
|
+
update: noop,
|
|
103
|
+
onClose,
|
|
104
|
+
setInitialFocusRef
|
|
105
|
+
}), [isOpen, onClose]);
|
|
106
|
+
|
|
107
|
+
// ── Role mapping ──
|
|
108
|
+
const roleProps = useRoleProps({
|
|
109
|
+
role,
|
|
110
|
+
label,
|
|
111
|
+
titleId
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Narrow to ForwardRefExoticComponent so JSX accepts the ref prop.
|
|
115
|
+
// All popupComponent implementations use forwardRef per the PopupComponentProps contract.
|
|
116
|
+
const Container = PopupContainer;
|
|
117
|
+
if (!isOpen) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return /*#__PURE__*/React.createElement(Popup, {
|
|
121
|
+
placement: topLayerPlacement,
|
|
122
|
+
onClose: handleOnClose,
|
|
123
|
+
testId: testId
|
|
124
|
+
}, /*#__PURE__*/React.createElement(Popup.Content, _extends({}, roleProps, {
|
|
125
|
+
isOpen: isOpen,
|
|
126
|
+
animate: animation,
|
|
127
|
+
testId: testId && `${testId}--content`,
|
|
128
|
+
width: shouldFitContainer ? 'trigger' : 'content'
|
|
129
|
+
}), Container ? /*#__PURE__*/React.createElement(Container, {
|
|
130
|
+
ref: popupContainerRef,
|
|
131
|
+
style: EMPTY_STYLE,
|
|
132
|
+
id: providedId,
|
|
133
|
+
"data-placement": placement,
|
|
134
|
+
"data-testid": testId,
|
|
135
|
+
tabIndex: autoFocus ? -1 : undefined,
|
|
136
|
+
xcss: xcss
|
|
137
|
+
}, children(contentProps)) : /*#__PURE__*/React.createElement(Popup.Surface, null, /*#__PURE__*/React.createElement("div", {
|
|
138
|
+
className: ax([shouldFitViewport && "_1reo1wug _18m91wug"])
|
|
139
|
+
}, children(contentProps)))));
|
|
140
|
+
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import React, { useCallback, useContext } from 'react';
|
|
2
2
|
import { Layering } from '@atlaskit/layering';
|
|
3
3
|
import { useNotifyOpenLayerObserver } from '@atlaskit/layering/experimental/open-layer-observer';
|
|
4
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
import Portal from '@atlaskit/portal';
|
|
5
6
|
import PopperWrapper from '../popper-wrapper';
|
|
6
7
|
import { usePopupAppearance } from '../use-appearance';
|
|
7
8
|
import { IdContext } from './id-context';
|
|
8
9
|
import { IsOpenContext } from './is-open-context';
|
|
10
|
+
import { PopupContentTopLayer } from './popup-content-top-layer';
|
|
9
11
|
import { TriggerRefContext } from './trigger-ref-context';
|
|
10
12
|
import { useEnsureIsInsidePopup } from './use-ensure-is-inside-popup';
|
|
11
13
|
const defaultLayer = 400;
|
|
@@ -45,6 +47,7 @@ export const PopupContent = ({
|
|
|
45
47
|
shouldFitViewport,
|
|
46
48
|
shouldDisableGpuAcceleration = false,
|
|
47
49
|
role,
|
|
50
|
+
label,
|
|
48
51
|
titleId
|
|
49
52
|
}) => {
|
|
50
53
|
useEnsureIsInsidePopup();
|
|
@@ -66,6 +69,39 @@ export const PopupContent = ({
|
|
|
66
69
|
onClose: handleOpenLayerObserverCloseSignal,
|
|
67
70
|
type: 'popup'
|
|
68
71
|
});
|
|
72
|
+
|
|
73
|
+
// Top-layer rendering path: native Popover API via @atlaskit/top-layer.
|
|
74
|
+
// Mirrors the FF branch in the legacy `Popup` component (popup.tsx).
|
|
75
|
+
if (fg('platform-dst-top-layer')) {
|
|
76
|
+
return /*#__PURE__*/React.createElement(PopupContentTopLayer, {
|
|
77
|
+
xcss: xcss,
|
|
78
|
+
appearance: inAppearance,
|
|
79
|
+
offset: offset,
|
|
80
|
+
onClose: onClose,
|
|
81
|
+
testId: testId,
|
|
82
|
+
placement: placement,
|
|
83
|
+
fallbackPlacements: fallbackPlacements,
|
|
84
|
+
popupComponent: popupComponent,
|
|
85
|
+
autoFocus: autoFocus,
|
|
86
|
+
shouldFitContainer: shouldFitContainer,
|
|
87
|
+
shouldFitViewport: shouldFitViewport,
|
|
88
|
+
role: role,
|
|
89
|
+
label: label,
|
|
90
|
+
titleId: titleId,
|
|
91
|
+
zIndex: zIndex,
|
|
92
|
+
shouldRenderToParent: inShouldRenderToParent,
|
|
93
|
+
strategy: strategy,
|
|
94
|
+
boundary: boundary,
|
|
95
|
+
rootBoundary: rootBoundary,
|
|
96
|
+
shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick,
|
|
97
|
+
shouldDisableFocusLock: shouldDisableFocusLock,
|
|
98
|
+
shouldFlip: shouldFlip,
|
|
99
|
+
shouldDisableGpuAcceleration: shouldDisableGpuAcceleration,
|
|
100
|
+
isOpen: isOpen,
|
|
101
|
+
id: id,
|
|
102
|
+
triggerRef: triggerRef
|
|
103
|
+
}, children);
|
|
104
|
+
}
|
|
69
105
|
if (!isOpen) {
|
|
70
106
|
return null;
|
|
71
107
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Props shape passed from legacy `role` / `label` / `titleId` into `@atlaskit/top-layer` `Popup.Content`.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Maps legacy popup role/label/titleId props to the discriminated union
|
|
9
|
+
* that `Popup.Content` expects.
|
|
10
|
+
*
|
|
11
|
+
* `Popup.Content` enforces at the type level that dialog/alertdialog/menu
|
|
12
|
+
* roles must have `label` or `labelledBy`. This hook bridges the legacy
|
|
13
|
+
* flat-prop API (`role`, `label`, `titleId`) to that shape.
|
|
14
|
+
*/
|
|
15
|
+
export function useRoleProps({
|
|
16
|
+
role,
|
|
17
|
+
label,
|
|
18
|
+
titleId
|
|
19
|
+
}) {
|
|
20
|
+
return useMemo(() => {
|
|
21
|
+
if (role === 'dialog' || role === 'alertdialog' || role === 'menu') {
|
|
22
|
+
if (titleId) {
|
|
23
|
+
return {
|
|
24
|
+
role: role,
|
|
25
|
+
labelledBy: titleId
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
role: role,
|
|
30
|
+
label: label !== null && label !== void 0 ? label : 'Popup'
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (role) {
|
|
34
|
+
return {
|
|
35
|
+
role: role,
|
|
36
|
+
label
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
// Default: dialog role with label or labelledBy
|
|
40
|
+
if (titleId) {
|
|
41
|
+
return {
|
|
42
|
+
role: 'dialog',
|
|
43
|
+
labelledBy: titleId
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
role: 'dialog',
|
|
48
|
+
label: label !== null && label !== void 0 ? label : 'Popup'
|
|
49
|
+
};
|
|
50
|
+
}, [role, label, titleId]);
|
|
51
|
+
}
|
|
@@ -16,7 +16,6 @@ const fullWidthStyles = null;
|
|
|
16
16
|
const wrapperStyles = {
|
|
17
17
|
root: "_2rko12b0 _1e0c1ule _vchhusvi _1pby1nn1 _bfhk1bhr _16qs130s _syazi7uo _1q1l1bhr _nt751r31 _49pcglyw _1hvw1o36",
|
|
18
18
|
rootT26Shape: "_2rko1mok",
|
|
19
|
-
rootLayer: "_1pby1nn1",
|
|
20
19
|
fullWidth: "_1bsb1osq"
|
|
21
20
|
};
|
|
22
21
|
const scrollableStyles = null;
|
|
@@ -91,7 +90,7 @@ const DefaultPopupComponent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
91
90
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
92
91
|
className: ax([wrapperStyles.root, fg('platform-dst-shape-theme-default') && wrapperStyles.rootT26Shape, appearance === 'UNSAFE_modal-below-sm' && !fg('platform_dst_nav4_flyout_menu_slots_close_button') && "_dk5d1b66 _c71ldtre _kqsw1n9t _152t1b66", appearance === 'UNSAFE_modal-below-sm' && fg('platform_dst_nav4_flyout_menu_slots_close_button') && "_dk5d1b66 _c71l1ei0 _kqsw1n9t _152t1b66", (!shouldRenderToParent || shouldFitViewport) && "_1reo1wug _18m91wug", shouldFitContainer && "_1bsb1osq", className])
|
|
93
92
|
}, htmlAttributes, {
|
|
94
|
-
ref: !fg('platform-dst-motion-uplift') ? ref : undefined
|
|
93
|
+
ref: !fg('platform-dst-motion-uplift-popup') ? ref : undefined
|
|
95
94
|
}), children);
|
|
96
95
|
});
|
|
97
96
|
function PopperWrapper({
|
|
@@ -122,7 +121,8 @@ function PopperWrapper({
|
|
|
122
121
|
titleId,
|
|
123
122
|
modifiers,
|
|
124
123
|
shouldFitViewport,
|
|
125
|
-
appearance = 'default'
|
|
124
|
+
appearance = 'default',
|
|
125
|
+
zIndex
|
|
126
126
|
}) {
|
|
127
127
|
const [popupRef, setPopupRef] = useState(null);
|
|
128
128
|
const [initialFocusRef, setInitialFocusRef] = useState(null);
|
|
@@ -188,7 +188,7 @@ function PopperWrapper({
|
|
|
188
188
|
role: role,
|
|
189
189
|
"aria-label": label,
|
|
190
190
|
"aria-labelledby": titleId,
|
|
191
|
-
ref: !fg('platform-dst-motion-uplift') ? node => {
|
|
191
|
+
ref: !fg('platform-dst-motion-uplift-popup') ? node => {
|
|
192
192
|
if (node) {
|
|
193
193
|
if (typeof ref === 'function') {
|
|
194
194
|
ref(node);
|
|
@@ -200,7 +200,7 @@ function PopperWrapper({
|
|
|
200
200
|
} : undefined
|
|
201
201
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
202
202
|
,
|
|
203
|
-
style: fg('platform-dst-motion-uplift') || appearance === 'UNSAFE_modal-below-sm' ? {} : style
|
|
203
|
+
style: fg('platform-dst-motion-uplift-popup') || appearance === 'UNSAFE_modal-below-sm' ? {} : style
|
|
204
204
|
// using tabIndex={-1} would cause a bug where Safari focuses
|
|
205
205
|
// first on the browser address bar when using keyboard
|
|
206
206
|
,
|
|
@@ -219,7 +219,10 @@ function PopperWrapper({
|
|
|
219
219
|
})));
|
|
220
220
|
const container = /*#__PURE__*/React.createElement("div", {
|
|
221
221
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
|
|
222
|
-
style:
|
|
222
|
+
style: {
|
|
223
|
+
...style,
|
|
224
|
+
zIndex
|
|
225
|
+
},
|
|
223
226
|
// using tabIndex={-1} would cause a bug where Safari focuses
|
|
224
227
|
// first on the browser address bar when using keyboard
|
|
225
228
|
ref: node => {
|
|
@@ -233,12 +236,12 @@ function PopperWrapper({
|
|
|
233
236
|
}
|
|
234
237
|
},
|
|
235
238
|
"data-testid": `${testId}--container`,
|
|
236
|
-
className: ax([
|
|
239
|
+
className: ax([shouldFitContainer && wrapperStyles.fullWidth])
|
|
237
240
|
}, placement === 'auto' || placement === 'auto-start' || placement === 'auto-end' ? popupContainer : /*#__PURE__*/React.createElement(Motion, {
|
|
238
241
|
enteringAnimation: placementMap[placement].enter,
|
|
239
242
|
exitingAnimation: placementMap[placement].exit
|
|
240
243
|
}, popupContainer));
|
|
241
|
-
return /*#__PURE__*/React.createElement(Fragment, null, fg('platform-dst-motion-uplift') ? container : popupContainer, appearance === 'UNSAFE_modal-below-sm' && /*#__PURE__*/React.createElement("div", {
|
|
244
|
+
return /*#__PURE__*/React.createElement(Fragment, null, fg('platform-dst-motion-uplift-popup') ? container : popupContainer, appearance === 'UNSAFE_modal-below-sm' && /*#__PURE__*/React.createElement("div", {
|
|
242
245
|
className: ax(["_1r04idpf _kqsw1n9t _bfhk1i5c"])
|
|
243
246
|
}));
|
|
244
247
|
});
|