@atlaskit/popup 1.24.1 → 1.25.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 CHANGED
@@ -1,5 +1,29 @@
1
1
  # @atlaskit/popup
2
2
 
3
+ ## 1.25.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#138688](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/138688)
8
+ [`961d97994618c`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/961d97994618c) -
9
+ Adds `shouldFitViewport` prop which will apply `max-width` and `max-height` to contain the
10
+ popper/popup within the viewport.
11
+
12
+ ### Patch Changes
13
+
14
+ - [#138585](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/138585)
15
+ [`b72c2c7f9a2fd`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/b72c2c7f9a2fd) -
16
+ Support to close all layers when clicking outside under feature flag
17
+ - Updated dependencies
18
+
19
+ ## 1.24.2
20
+
21
+ ### Patch Changes
22
+
23
+ - [#136611](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136611)
24
+ [`9755fb019113f`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/9755fb019113f) -
25
+ Clean up emotion Globals usage
26
+
3
27
  ## 1.24.1
4
28
 
5
29
  ### Patch Changes
@@ -129,7 +129,8 @@ var PopupContent = exports.PopupContent = function PopupContent(_ref4) {
129
129
  shouldRenderToParent = _ref4.shouldRenderToParent,
130
130
  _ref4$shouldDisableFo = _ref4.shouldDisableFocusLock,
131
131
  shouldDisableFocusLock = _ref4$shouldDisableFo === void 0 ? false : _ref4$shouldDisableFo,
132
- shouldFitContainer = _ref4.shouldFitContainer;
132
+ shouldFitContainer = _ref4.shouldFitContainer,
133
+ shouldFitViewport = _ref4.shouldFitViewport;
133
134
  useEnsureIsInsidePopup();
134
135
  var isOpen = (0, _react.useContext)(IsOpenContext);
135
136
  var id = (0, _react.useContext)(IdContext);
@@ -158,7 +159,8 @@ var PopupContent = exports.PopupContent = function PopupContent(_ref4) {
158
159
  shouldRenderToParent: shouldRenderToParent,
159
160
  shouldDisableFocusLock: shouldDisableFocusLock,
160
161
  triggerRef: triggerRef,
161
- strategy: strategy
162
+ strategy: strategy,
163
+ shouldFitViewport: shouldFitViewport
162
164
  }));
163
165
  if (shouldRenderToParent) {
164
166
  return popperWrapper;
@@ -13,7 +13,6 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
13
13
  var _react = require("react");
14
14
  var _react2 = require("@emotion/react");
15
15
  var _layering = require("@atlaskit/layering");
16
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
17
16
  var _popper = require("@atlaskit/popper");
18
17
  var _colors = require("@atlaskit/theme/colors");
19
18
  var _constants = require("@atlaskit/theme/constants");
@@ -27,7 +26,6 @@ var _css;
27
26
  * @jsxRuntime classic
28
27
  * @jsx jsx
29
28
  */
30
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
31
29
  var popupFullWidthStyles = (0, _react2.css)({
32
30
  width: '100%'
33
31
  });
@@ -49,15 +47,6 @@ var popupStyles = (0, _react2.css)((_css = {
49
47
  var popupOverflowStyles = (0, _react2.css)({
50
48
  overflow: 'auto'
51
49
  });
52
-
53
- // disables iframe pointer events while popup is open, except if iframe is nested inside popup
54
- // solves an issue of popup not being closed on iframe click
55
- var blockPointerEventsOnExternalIframeStyles = (0, _react2.css)({
56
- // eslint-disable-next-line @atlaskit/design-system/no-nested-styles, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
57
- 'iframe:not([data-ds--level] iframe)': {
58
- pointerEvents: 'none'
59
- }
60
- });
61
50
  var DefaultPopupComponent = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
62
51
  var shouldRenderToParent = props.shouldRenderToParent,
63
52
  shouldFitContainer = props.shouldFitContainer,
@@ -97,7 +86,8 @@ function PopperWrapper(_ref) {
97
86
  role = _ref.role,
98
87
  label = _ref.label,
99
88
  titleId = _ref.titleId,
100
- modifiers = _ref.modifiers;
89
+ modifiers = _ref.modifiers,
90
+ shouldFitViewport = _ref.shouldFitViewport;
101
91
  var _useState = (0, _react.useState)(null),
102
92
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
103
93
  popupRef = _useState2[0],
@@ -148,7 +138,8 @@ function PopperWrapper(_ref) {
148
138
  placement: placement,
149
139
  offset: offset,
150
140
  modifiers: mergedModifiers,
151
- strategy: strategy
141
+ strategy: strategy,
142
+ shouldFitViewport: shouldFitViewport
152
143
  }, function (_ref2) {
153
144
  var _ref3 = _ref2.ref,
154
145
  style = _ref2.style,
@@ -181,9 +172,7 @@ function PopperWrapper(_ref) {
181
172
  tabIndex: autoFocus ? 0 : undefined,
182
173
  shouldRenderToParent: shouldRenderToParent,
183
174
  shouldFitContainer: shouldFitContainer
184
- }, (0, _platformFeatureFlags.fg)('platform.design-system-team.iframe_gojiv') && (0, _react2.jsx)(_react2.Global, {
185
- styles: blockPointerEventsOnExternalIframeStyles
186
- }), (0, _react2.jsx)(_repositionOnUpdate.RepositionOnUpdate, {
175
+ }, (0, _react2.jsx)(_repositionOnUpdate.RepositionOnUpdate, {
187
176
  update: update
188
177
  }, content({
189
178
  update: update,
package/dist/cjs/popup.js CHANGED
@@ -65,7 +65,8 @@ var Popup = exports.Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
65
65
  role = _ref.role,
66
66
  label = _ref.label,
67
67
  titleId = _ref.titleId,
68
- modifiers = _ref.modifiers;
68
+ modifiers = _ref.modifiers,
69
+ shouldFitViewport = _ref.shouldFitViewport;
69
70
  var _useState = (0, _react.useState)(null),
70
71
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
71
72
  triggerRef = _useState2[0],
@@ -100,7 +101,8 @@ var Popup = exports.Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
100
101
  role: role,
101
102
  label: label,
102
103
  titleId: titleId,
103
- modifiers: modifiers
104
+ modifiers: modifiers,
105
+ shouldFitViewport: shouldFitViewport
104
106
  }));
105
107
  var popupContent = (0, _react2.jsx)(_popper.Manager, null, (0, _react2.jsx)(_popper.Reference, null, function (_ref2) {
106
108
  var ref = _ref2.ref;
@@ -36,7 +36,16 @@ var useCloseManager = exports.useCloseManager = function useCloseManager(_ref) {
36
36
  }
37
37
  var closePopup = function closePopup(event) {
38
38
  if (onClose) {
39
- onClose(event);
39
+ if ((0, _platformFeatureFlags.fg)('sibling-dropdown-close-issue')) {
40
+ var _currentLevel = null;
41
+ if (event.target instanceof HTMLElement) {
42
+ var _event$target$closest;
43
+ _currentLevel = (_event$target$closest = event.target.closest("[data-ds--level]")) === null || _event$target$closest === void 0 ? void 0 : _event$target$closest.getAttribute('data-ds--level');
44
+ }
45
+ _currentLevel ? onClose(event, Number(_currentLevel)) : onClose(event);
46
+ } else {
47
+ onClose(event);
48
+ }
40
49
  }
41
50
  if (shouldDisableFocusTrap && (0, _platformFeatureFlags.fg)('platform_dst_popup-disable-focuslock')) {
42
51
  // Restoring the normal focus order for trigger.
@@ -61,8 +70,19 @@ var useCloseManager = exports.useCloseManager = function useCloseManager(_ref) {
61
70
  return;
62
71
  }
63
72
  if (isLayerDisabled()) {
64
- //if it is a disabled layer, we need to disable its click listener.
65
- return;
73
+ //if it is a disabled layer, and we clicked inside a higher layer
74
+ //we will disable the click event
75
+ if ((0, _platformFeatureFlags.fg)('design-system-closed-all-when-click-outside')) {
76
+ if (target instanceof HTMLElement) {
77
+ var _target$closest;
78
+ var levelOfClickedLayer = (_target$closest = target.closest) === null || _target$closest === void 0 || (_target$closest = _target$closest.call(target, "[data-ds--level]")) === null || _target$closest === void 0 ? void 0 : _target$closest.getAttribute('data-ds--level');
79
+ if (levelOfClickedLayer && Number(levelOfClickedLayer) > currentLevel) {
80
+ return;
81
+ }
82
+ }
83
+ } else {
84
+ return;
85
+ }
66
86
  }
67
87
  var isClickOnPopup = popupRef && popupRef.contains(target);
68
88
  var isClickOnTrigger = triggerRef && triggerRef.contains(target);
@@ -108,7 +108,8 @@ export const PopupContent = ({
108
108
  shouldUseCaptureOnOutsideClick = false,
109
109
  shouldRenderToParent,
110
110
  shouldDisableFocusLock = false,
111
- shouldFitContainer
111
+ shouldFitContainer,
112
+ shouldFitViewport
112
113
  }) => {
113
114
  useEnsureIsInsidePopup();
114
115
  const isOpen = useContext(IsOpenContext);
@@ -138,7 +139,8 @@ export const PopupContent = ({
138
139
  shouldRenderToParent: shouldRenderToParent,
139
140
  shouldDisableFocusLock: shouldDisableFocusLock,
140
141
  triggerRef: triggerRef,
141
- strategy: strategy
142
+ strategy: strategy,
143
+ shouldFitViewport: shouldFitViewport
142
144
  }));
143
145
  if (shouldRenderToParent) {
144
146
  return popperWrapper;
@@ -4,11 +4,8 @@ import _extends from "@babel/runtime/helpers/extends";
4
4
  * @jsx jsx
5
5
  */
6
6
  import { forwardRef, useMemo, useState } from 'react';
7
-
8
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
9
- import { css, Global, jsx } from '@emotion/react';
7
+ import { css, jsx } from '@emotion/react';
10
8
  import { UNSAFE_useLayering } from '@atlaskit/layering';
11
- import { fg } from '@atlaskit/platform-feature-flags';
12
9
  import { Popper } from '@atlaskit/popper';
13
10
  import { N0, N50A, N60A } from '@atlaskit/theme/colors';
14
11
  import { layers } from '@atlaskit/theme/constants';
@@ -39,15 +36,6 @@ const popupStyles = css({
39
36
  const popupOverflowStyles = css({
40
37
  overflow: 'auto'
41
38
  });
42
-
43
- // disables iframe pointer events while popup is open, except if iframe is nested inside popup
44
- // solves an issue of popup not being closed on iframe click
45
- const blockPointerEventsOnExternalIframeStyles = css({
46
- // eslint-disable-next-line @atlaskit/design-system/no-nested-styles, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
47
- 'iframe:not([data-ds--level] iframe)': {
48
- pointerEvents: 'none'
49
- }
50
- });
51
39
  const DefaultPopupComponent = /*#__PURE__*/forwardRef((props, ref) => {
52
40
  const {
53
41
  shouldRenderToParent,
@@ -86,7 +74,8 @@ function PopperWrapper({
86
74
  role,
87
75
  label,
88
76
  titleId,
89
- modifiers
77
+ modifiers,
78
+ shouldFitViewport
90
79
  }) {
91
80
  const [popupRef, setPopupRef] = useState(null);
92
81
  const [initialFocusRef, setInitialFocusRef] = useState(null);
@@ -131,7 +120,8 @@ function PopperWrapper({
131
120
  placement: placement,
132
121
  offset: offset,
133
122
  modifiers: mergedModifiers,
134
- strategy: strategy
123
+ strategy: strategy,
124
+ shouldFitViewport: shouldFitViewport
135
125
  }, ({
136
126
  ref,
137
127
  style,
@@ -165,9 +155,7 @@ function PopperWrapper({
165
155
  tabIndex: autoFocus ? 0 : undefined,
166
156
  shouldRenderToParent: shouldRenderToParent,
167
157
  shouldFitContainer: shouldFitContainer
168
- }, fg('platform.design-system-team.iframe_gojiv') && jsx(Global, {
169
- styles: blockPointerEventsOnExternalIframeStyles
170
- }), jsx(RepositionOnUpdate, {
158
+ }, jsx(RepositionOnUpdate, {
171
159
  update: update
172
160
  }, content({
173
161
  update,
@@ -46,7 +46,8 @@ export const Popup = /*#__PURE__*/memo(({
46
46
  role,
47
47
  label,
48
48
  titleId,
49
- modifiers
49
+ modifiers,
50
+ shouldFitViewport
50
51
  }) => {
51
52
  const [triggerRef, setTriggerRef] = useState(null);
52
53
  const getMergedTriggerRef = useGetMemoizedMergedTriggerRef();
@@ -79,7 +80,8 @@ export const Popup = /*#__PURE__*/memo(({
79
80
  role: role,
80
81
  label: label,
81
82
  titleId: titleId,
82
- modifiers: modifiers
83
+ modifiers: modifiers,
84
+ shouldFitViewport: shouldFitViewport
83
85
  }));
84
86
  const popupContent = jsx(Manager, null, jsx(Reference, null, ({
85
87
  ref
@@ -31,7 +31,16 @@ export const useCloseManager = ({
31
31
  }
32
32
  const closePopup = event => {
33
33
  if (onClose) {
34
- onClose(event);
34
+ if (fg('sibling-dropdown-close-issue')) {
35
+ let currentLevel = null;
36
+ if (event.target instanceof HTMLElement) {
37
+ var _event$target$closest;
38
+ currentLevel = (_event$target$closest = event.target.closest(`[data-ds--level]`)) === null || _event$target$closest === void 0 ? void 0 : _event$target$closest.getAttribute('data-ds--level');
39
+ }
40
+ currentLevel ? onClose(event, Number(currentLevel)) : onClose(event);
41
+ } else {
42
+ onClose(event);
43
+ }
35
44
  }
36
45
  if (shouldDisableFocusTrap && fg('platform_dst_popup-disable-focuslock')) {
37
46
  // Restoring the normal focus order for trigger.
@@ -58,8 +67,19 @@ export const useCloseManager = ({
58
67
  return;
59
68
  }
60
69
  if (isLayerDisabled()) {
61
- //if it is a disabled layer, we need to disable its click listener.
62
- return;
70
+ //if it is a disabled layer, and we clicked inside a higher layer
71
+ //we will disable the click event
72
+ if (fg('design-system-closed-all-when-click-outside')) {
73
+ if (target instanceof HTMLElement) {
74
+ var _target$closest, _target$closest$call;
75
+ const levelOfClickedLayer = (_target$closest = target.closest) === null || _target$closest === void 0 ? void 0 : (_target$closest$call = _target$closest.call(target, `[data-ds--level]`)) === null || _target$closest$call === void 0 ? void 0 : _target$closest$call.getAttribute('data-ds--level');
76
+ if (levelOfClickedLayer && Number(levelOfClickedLayer) > currentLevel) {
77
+ return;
78
+ }
79
+ }
80
+ } else {
81
+ return;
82
+ }
63
83
  }
64
84
  const isClickOnPopup = popupRef && popupRef.contains(target);
65
85
  const isClickOnTrigger = triggerRef && triggerRef.contains(target);
@@ -119,7 +119,8 @@ export var PopupContent = function PopupContent(_ref4) {
119
119
  shouldRenderToParent = _ref4.shouldRenderToParent,
120
120
  _ref4$shouldDisableFo = _ref4.shouldDisableFocusLock,
121
121
  shouldDisableFocusLock = _ref4$shouldDisableFo === void 0 ? false : _ref4$shouldDisableFo,
122
- shouldFitContainer = _ref4.shouldFitContainer;
122
+ shouldFitContainer = _ref4.shouldFitContainer,
123
+ shouldFitViewport = _ref4.shouldFitViewport;
123
124
  useEnsureIsInsidePopup();
124
125
  var isOpen = useContext(IsOpenContext);
125
126
  var id = useContext(IdContext);
@@ -148,7 +149,8 @@ export var PopupContent = function PopupContent(_ref4) {
148
149
  shouldRenderToParent: shouldRenderToParent,
149
150
  shouldDisableFocusLock: shouldDisableFocusLock,
150
151
  triggerRef: triggerRef,
151
- strategy: strategy
152
+ strategy: strategy,
153
+ shouldFitViewport: shouldFitViewport
152
154
  }));
153
155
  if (shouldRenderToParent) {
154
156
  return popperWrapper;
@@ -10,11 +10,8 @@ var _css;
10
10
  * @jsx jsx
11
11
  */
12
12
  import { forwardRef, useMemo, useState } from 'react';
13
-
14
- // eslint-disable-next-line @atlaskit/ui-styling-standard/no-global-styles, @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
15
- import { css, Global, jsx } from '@emotion/react';
13
+ import { css, jsx } from '@emotion/react';
16
14
  import { UNSAFE_useLayering } from '@atlaskit/layering';
17
- import { fg } from '@atlaskit/platform-feature-flags';
18
15
  import { Popper } from '@atlaskit/popper';
19
16
  import { N0, N50A, N60A } from '@atlaskit/theme/colors';
20
17
  import { layers } from '@atlaskit/theme/constants';
@@ -43,15 +40,6 @@ var popupStyles = css((_css = {
43
40
  var popupOverflowStyles = css({
44
41
  overflow: 'auto'
45
42
  });
46
-
47
- // disables iframe pointer events while popup is open, except if iframe is nested inside popup
48
- // solves an issue of popup not being closed on iframe click
49
- var blockPointerEventsOnExternalIframeStyles = css({
50
- // eslint-disable-next-line @atlaskit/design-system/no-nested-styles, @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
51
- 'iframe:not([data-ds--level] iframe)': {
52
- pointerEvents: 'none'
53
- }
54
- });
55
43
  var DefaultPopupComponent = /*#__PURE__*/forwardRef(function (props, ref) {
56
44
  var shouldRenderToParent = props.shouldRenderToParent,
57
45
  shouldFitContainer = props.shouldFitContainer,
@@ -91,7 +79,8 @@ function PopperWrapper(_ref) {
91
79
  role = _ref.role,
92
80
  label = _ref.label,
93
81
  titleId = _ref.titleId,
94
- modifiers = _ref.modifiers;
82
+ modifiers = _ref.modifiers,
83
+ shouldFitViewport = _ref.shouldFitViewport;
95
84
  var _useState = useState(null),
96
85
  _useState2 = _slicedToArray(_useState, 2),
97
86
  popupRef = _useState2[0],
@@ -142,7 +131,8 @@ function PopperWrapper(_ref) {
142
131
  placement: placement,
143
132
  offset: offset,
144
133
  modifiers: mergedModifiers,
145
- strategy: strategy
134
+ strategy: strategy,
135
+ shouldFitViewport: shouldFitViewport
146
136
  }, function (_ref2) {
147
137
  var _ref3 = _ref2.ref,
148
138
  style = _ref2.style,
@@ -175,9 +165,7 @@ function PopperWrapper(_ref) {
175
165
  tabIndex: autoFocus ? 0 : undefined,
176
166
  shouldRenderToParent: shouldRenderToParent,
177
167
  shouldFitContainer: shouldFitContainer
178
- }, fg('platform.design-system-team.iframe_gojiv') && jsx(Global, {
179
- styles: blockPointerEventsOnExternalIframeStyles
180
- }), jsx(RepositionOnUpdate, {
168
+ }, jsx(RepositionOnUpdate, {
181
169
  update: update
182
170
  }, content({
183
171
  update: update,
package/dist/esm/popup.js CHANGED
@@ -57,7 +57,8 @@ export var Popup = /*#__PURE__*/memo(function (_ref) {
57
57
  role = _ref.role,
58
58
  label = _ref.label,
59
59
  titleId = _ref.titleId,
60
- modifiers = _ref.modifiers;
60
+ modifiers = _ref.modifiers,
61
+ shouldFitViewport = _ref.shouldFitViewport;
61
62
  var _useState = useState(null),
62
63
  _useState2 = _slicedToArray(_useState, 2),
63
64
  triggerRef = _useState2[0],
@@ -92,7 +93,8 @@ export var Popup = /*#__PURE__*/memo(function (_ref) {
92
93
  role: role,
93
94
  label: label,
94
95
  titleId: titleId,
95
- modifiers: modifiers
96
+ modifiers: modifiers,
97
+ shouldFitViewport: shouldFitViewport
96
98
  }));
97
99
  var popupContent = jsx(Manager, null, jsx(Reference, null, function (_ref2) {
98
100
  var ref = _ref2.ref;
@@ -28,7 +28,16 @@ export var useCloseManager = function useCloseManager(_ref) {
28
28
  }
29
29
  var closePopup = function closePopup(event) {
30
30
  if (onClose) {
31
- onClose(event);
31
+ if (fg('sibling-dropdown-close-issue')) {
32
+ var _currentLevel = null;
33
+ if (event.target instanceof HTMLElement) {
34
+ var _event$target$closest;
35
+ _currentLevel = (_event$target$closest = event.target.closest("[data-ds--level]")) === null || _event$target$closest === void 0 ? void 0 : _event$target$closest.getAttribute('data-ds--level');
36
+ }
37
+ _currentLevel ? onClose(event, Number(_currentLevel)) : onClose(event);
38
+ } else {
39
+ onClose(event);
40
+ }
32
41
  }
33
42
  if (shouldDisableFocusTrap && fg('platform_dst_popup-disable-focuslock')) {
34
43
  // Restoring the normal focus order for trigger.
@@ -53,8 +62,19 @@ export var useCloseManager = function useCloseManager(_ref) {
53
62
  return;
54
63
  }
55
64
  if (isLayerDisabled()) {
56
- //if it is a disabled layer, we need to disable its click listener.
57
- return;
65
+ //if it is a disabled layer, and we clicked inside a higher layer
66
+ //we will disable the click event
67
+ if (fg('design-system-closed-all-when-click-outside')) {
68
+ if (target instanceof HTMLElement) {
69
+ var _target$closest;
70
+ var levelOfClickedLayer = (_target$closest = target.closest) === null || _target$closest === void 0 || (_target$closest = _target$closest.call(target, "[data-ds--level]")) === null || _target$closest === void 0 ? void 0 : _target$closest.getAttribute('data-ds--level');
71
+ if (levelOfClickedLayer && Number(levelOfClickedLayer) > currentLevel) {
72
+ return;
73
+ }
74
+ }
75
+ } else {
76
+ return;
77
+ }
58
78
  }
59
79
  var isClickOnPopup = popupRef && popupRef.contains(target);
60
80
  var isClickOnTrigger = triggerRef && triggerRef.contains(target);
@@ -36,7 +36,7 @@ export type PopupTriggerProps = {
36
36
  * It must be a child of the Popup component.
37
37
  */
38
38
  export declare const PopupTrigger: ({ children }: PopupTriggerProps) => JSX.Element;
39
- type CommonContentPopupProps = Pick<LegacyPopupProps, 'boundary' | 'offset' | 'onClose' | 'testId' | 'placement' | 'fallbackPlacements' | 'popupComponent' | 'shouldFlip' | 'rootBoundary' | 'autoFocus' | 'shouldRenderToParent' | 'shouldUseCaptureOnOutsideClick' | 'shouldDisableFocusLock' | 'strategy' | 'zIndex'> & {
39
+ type CommonContentPopupProps = Pick<LegacyPopupProps, 'boundary' | 'offset' | 'onClose' | 'testId' | 'placement' | 'fallbackPlacements' | 'popupComponent' | 'shouldFlip' | 'rootBoundary' | 'autoFocus' | 'shouldRenderToParent' | 'shouldUseCaptureOnOutsideClick' | 'shouldDisableFocusLock' | 'strategy' | 'zIndex' | 'shouldFitViewport'> & {
40
40
  children: (props: ContentProps) => React.ReactNode;
41
41
  };
42
42
  type ShouldFitContainerContentPopupProps = CommonContentPopupProps & {
@@ -55,5 +55,5 @@ export type PopupContentProps = ShouldFitContainerContentPopupProps | StandardPo
55
55
  *
56
56
  * It must be a child of the Popup component.
57
57
  */
58
- export declare const PopupContent: ({ children, boundary, offset, strategy, onClose, testId, rootBoundary, shouldFlip, placement, fallbackPlacements, popupComponent, autoFocus, zIndex, shouldUseCaptureOnOutsideClick, shouldRenderToParent, shouldDisableFocusLock, shouldFitContainer, }: PopupContentProps) => JSX.Element | null;
58
+ export declare const PopupContent: ({ children, boundary, offset, strategy, onClose, testId, rootBoundary, shouldFlip, placement, fallbackPlacements, popupComponent, autoFocus, zIndex, shouldUseCaptureOnOutsideClick, shouldRenderToParent, shouldDisableFocusLock, shouldFitContainer, shouldFitViewport, }: PopupContentProps) => JSX.Element | null;
59
59
  export {};
@@ -1,4 +1,4 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import { type PopperWrapperProps } from './types';
3
- declare function PopperWrapper({ isOpen, id, offset, testId, content, fallbackPlacements, onClose, boundary, rootBoundary, shouldFlip, placement, popupComponent: PopupContainer, autoFocus, triggerRef, shouldUseCaptureOnOutsideClick, shouldRenderToParent, shouldFitContainer, shouldDisableFocusLock, shouldReturnFocus, strategy, role, label, titleId, modifiers, }: PopperWrapperProps): jsx.JSX.Element;
3
+ declare function PopperWrapper({ isOpen, id, offset, testId, content, fallbackPlacements, onClose, boundary, rootBoundary, shouldFlip, placement, popupComponent: PopupContainer, autoFocus, triggerRef, shouldUseCaptureOnOutsideClick, shouldRenderToParent, shouldFitContainer, shouldDisableFocusLock, shouldReturnFocus, strategy, role, label, titleId, modifiers, shouldFitViewport, }: PopperWrapperProps): jsx.JSX.Element;
4
4
  export default PopperWrapper;
@@ -5,6 +5,7 @@ export interface TriggerProps {
5
5
  'aria-controls'?: string;
6
6
  'aria-expanded': boolean;
7
7
  'aria-haspopup': boolean | 'dialog';
8
+ 'data-ds--level'?: string;
8
9
  }
9
10
  export type PopupRef = HTMLDivElement | null;
10
11
  export type TriggerRef = HTMLElement | HTMLButtonElement | null;
@@ -133,7 +134,7 @@ interface BaseProps {
133
134
  * This happens either when clicking away from the popup or pressing the escape key.
134
135
  * You'll want to use this to set open state accordingly, and then pump it back into the `isOpen` prop.
135
136
  */
136
- onClose?(event: Event | React.MouseEvent | React.KeyboardEvent): void;
137
+ onClose?(event: Event | React.MouseEvent | React.KeyboardEvent, currentLevel?: number | any): void;
137
138
  /**
138
139
  * The element that is shown when `isOpen` prop is `true`.
139
140
  * The result of the `content` prop will be placed as children here.
@@ -199,6 +200,11 @@ interface BaseProps {
199
200
  * for more details - https://popper.js.org/docs/v1/#modifiers
200
201
  */
201
202
  modifiers?: Partial<Modifier<string, object>>[];
203
+ /**
204
+ * Determines if the popup will have a `max-width` and `max-height` set to
205
+ * constrain it to the viewport.
206
+ */
207
+ shouldFitViewport?: boolean;
202
208
  }
203
209
  interface InternalPopupProps extends BaseProps {
204
210
  /**
@@ -36,7 +36,7 @@ export type PopupTriggerProps = {
36
36
  * It must be a child of the Popup component.
37
37
  */
38
38
  export declare const PopupTrigger: ({ children }: PopupTriggerProps) => JSX.Element;
39
- type CommonContentPopupProps = Pick<LegacyPopupProps, 'boundary' | 'offset' | 'onClose' | 'testId' | 'placement' | 'fallbackPlacements' | 'popupComponent' | 'shouldFlip' | 'rootBoundary' | 'autoFocus' | 'shouldRenderToParent' | 'shouldUseCaptureOnOutsideClick' | 'shouldDisableFocusLock' | 'strategy' | 'zIndex'> & {
39
+ type CommonContentPopupProps = Pick<LegacyPopupProps, 'boundary' | 'offset' | 'onClose' | 'testId' | 'placement' | 'fallbackPlacements' | 'popupComponent' | 'shouldFlip' | 'rootBoundary' | 'autoFocus' | 'shouldRenderToParent' | 'shouldUseCaptureOnOutsideClick' | 'shouldDisableFocusLock' | 'strategy' | 'zIndex' | 'shouldFitViewport'> & {
40
40
  children: (props: ContentProps) => React.ReactNode;
41
41
  };
42
42
  type ShouldFitContainerContentPopupProps = CommonContentPopupProps & {
@@ -55,5 +55,5 @@ export type PopupContentProps = ShouldFitContainerContentPopupProps | StandardPo
55
55
  *
56
56
  * It must be a child of the Popup component.
57
57
  */
58
- export declare const PopupContent: ({ children, boundary, offset, strategy, onClose, testId, rootBoundary, shouldFlip, placement, fallbackPlacements, popupComponent, autoFocus, zIndex, shouldUseCaptureOnOutsideClick, shouldRenderToParent, shouldDisableFocusLock, shouldFitContainer, }: PopupContentProps) => JSX.Element | null;
58
+ export declare const PopupContent: ({ children, boundary, offset, strategy, onClose, testId, rootBoundary, shouldFlip, placement, fallbackPlacements, popupComponent, autoFocus, zIndex, shouldUseCaptureOnOutsideClick, shouldRenderToParent, shouldDisableFocusLock, shouldFitContainer, shouldFitViewport, }: PopupContentProps) => JSX.Element | null;
59
59
  export {};
@@ -1,4 +1,4 @@
1
1
  import { jsx } from '@emotion/react';
2
2
  import { type PopperWrapperProps } from './types';
3
- declare function PopperWrapper({ isOpen, id, offset, testId, content, fallbackPlacements, onClose, boundary, rootBoundary, shouldFlip, placement, popupComponent: PopupContainer, autoFocus, triggerRef, shouldUseCaptureOnOutsideClick, shouldRenderToParent, shouldFitContainer, shouldDisableFocusLock, shouldReturnFocus, strategy, role, label, titleId, modifiers, }: PopperWrapperProps): jsx.JSX.Element;
3
+ declare function PopperWrapper({ isOpen, id, offset, testId, content, fallbackPlacements, onClose, boundary, rootBoundary, shouldFlip, placement, popupComponent: PopupContainer, autoFocus, triggerRef, shouldUseCaptureOnOutsideClick, shouldRenderToParent, shouldFitContainer, shouldDisableFocusLock, shouldReturnFocus, strategy, role, label, titleId, modifiers, shouldFitViewport, }: PopperWrapperProps): jsx.JSX.Element;
4
4
  export default PopperWrapper;
@@ -5,6 +5,7 @@ export interface TriggerProps {
5
5
  'aria-controls'?: string;
6
6
  'aria-expanded': boolean;
7
7
  'aria-haspopup': boolean | 'dialog';
8
+ 'data-ds--level'?: string;
8
9
  }
9
10
  export type PopupRef = HTMLDivElement | null;
10
11
  export type TriggerRef = HTMLElement | HTMLButtonElement | null;
@@ -136,7 +137,7 @@ interface BaseProps {
136
137
  * This happens either when clicking away from the popup or pressing the escape key.
137
138
  * You'll want to use this to set open state accordingly, and then pump it back into the `isOpen` prop.
138
139
  */
139
- onClose?(event: Event | React.MouseEvent | React.KeyboardEvent): void;
140
+ onClose?(event: Event | React.MouseEvent | React.KeyboardEvent, currentLevel?: number | any): void;
140
141
  /**
141
142
  * The element that is shown when `isOpen` prop is `true`.
142
143
  * The result of the `content` prop will be placed as children here.
@@ -202,6 +203,11 @@ interface BaseProps {
202
203
  * for more details - https://popper.js.org/docs/v1/#modifiers
203
204
  */
204
205
  modifiers?: Partial<Modifier<string, object>>[];
206
+ /**
207
+ * Determines if the popup will have a `max-width` and `max-height` set to
208
+ * constrain it to the viewport.
209
+ */
210
+ shouldFitViewport?: boolean;
205
211
  }
206
212
  interface InternalPopupProps extends BaseProps {
207
213
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.24.1",
3
+ "version": "1.25.0",
4
4
  "description": "A popup displays brief content in an overlay.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -39,7 +39,7 @@
39
39
  "@atlaskit/ds-lib": "^2.5.0",
40
40
  "@atlaskit/layering": "^0.4.0",
41
41
  "@atlaskit/platform-feature-flags": "^0.3.0",
42
- "@atlaskit/popper": "^6.2.0",
42
+ "@atlaskit/popper": "^6.3.0",
43
43
  "@atlaskit/portal": "^4.9.0",
44
44
  "@atlaskit/primitives": "^12.1.0",
45
45
  "@atlaskit/theme": "^13.0.0",
@@ -60,10 +60,10 @@
60
60
  "@af/integration-testing": "*",
61
61
  "@af/visual-regression": "*",
62
62
  "@atlaskit/button": "^20.1.0",
63
- "@atlaskit/icon": "^22.15.0",
63
+ "@atlaskit/icon": "^22.16.0",
64
64
  "@atlaskit/ssr": "*",
65
65
  "@atlaskit/textfield": "^6.5.0",
66
- "@atlaskit/toggle": "^13.3.0",
66
+ "@atlaskit/toggle": "^13.4.0",
67
67
  "@atlaskit/visual-regression": "*",
68
68
  "@atlassian/feature-flags-test-utils": "*",
69
69
  "@testing-library/dom": "^10.1.0",
@@ -103,14 +103,17 @@
103
103
  }
104
104
  },
105
105
  "platform-feature-flags": {
106
- "platform.design-system-team.iframe_gojiv": {
107
- "type": "boolean"
108
- },
109
106
  "platform_dst_popup-disable-focuslock": {
110
107
  "type": "boolean"
111
108
  },
112
109
  "platform-design-system-dsp-20476-dropdown-menu": {
113
110
  "type": "boolean"
111
+ },
112
+ "design-system-closed-all-when-click-outside": {
113
+ "type": "boolean"
114
+ },
115
+ "sibling-dropdown-close-issue": {
116
+ "type": "boolean"
114
117
  }
115
118
  },
116
119
  "homepage": "https://atlassian.design/components/popup/"