@atlaskit/popup 1.11.4 → 1.11.6

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,17 @@
1
1
  # @atlaskit/popup
2
2
 
3
+ ## 1.11.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#67435](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/67435) [`7949bd7f5cb6`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/7949bd7f5cb6) - Support to disable pointer-events on iframe when popup is open to fix issue of clicking on iframe won't close popup
8
+
9
+ ## 1.11.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#40944](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/40944) [`c6b7d977655`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c6b7d977655) - Memoize the Popup Trigger's ref to avoid unnecessary renders.
14
+
3
15
  ## 1.11.4
4
16
 
5
17
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import Button from '@atlaskit/button';
3
+ import Button from '@atlaskit/button/new';
4
4
 
5
5
  import Popup from '../src';
6
6
 
package/__perf__/open.tsx CHANGED
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- import Button from '@atlaskit/button';
3
+ import Button from '@atlaskit/button/new';
4
4
 
5
5
  import Popup from '../src';
6
6
 
@@ -11,6 +11,8 @@ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/h
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _react = require("react");
13
13
  var _react2 = require("@emotion/react");
14
+ var _layering = require("@atlaskit/layering");
15
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
14
16
  var _popper = require("@atlaskit/popper");
15
17
  var _colors = require("@atlaskit/theme/colors");
16
18
  var _constants = require("@atlaskit/theme/constants");
@@ -35,6 +37,15 @@ var popupStyles = (0, _react2.css)((_css = {
35
37
  var popupOverflowStyles = (0, _react2.css)({
36
38
  overflow: 'auto'
37
39
  });
40
+
41
+ // disables iframe pointer events while popup is open, except if iframe is nested inside popup
42
+ // solves an issue of popup not being closed on iframe click
43
+ var blockPointerEventsOnExternalIframeStyles = (0, _react2.css)({
44
+ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
45
+ 'iframe:not([data-ds--level] iframe)': {
46
+ pointerEvents: 'none'
47
+ }
48
+ });
38
49
  var DefaultPopupComponent = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
39
50
  var shouldRenderToParent = props.shouldRenderToParent,
40
51
  children = props.children,
@@ -84,6 +95,8 @@ function PopperWrapper(_ref) {
84
95
  triggerRef: triggerRef,
85
96
  shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick
86
97
  });
98
+ var _UNSAFE_useLayering = (0, _layering.UNSAFE_useLayering)(),
99
+ currentLevel = _UNSAFE_useLayering.currentLevel;
87
100
  var modifiers = (0, _react.useMemo)(function () {
88
101
  return [{
89
102
  name: 'flip',
@@ -106,6 +119,7 @@ function PopperWrapper(_ref) {
106
119
  update = _ref2.update;
107
120
  return (0, _react2.jsx)(PopupContainer, {
108
121
  id: id,
122
+ "data-ds--level": currentLevel,
109
123
  "data-placement": placement,
110
124
  "data-testid": testId,
111
125
  ref: function ref(node) {
@@ -124,7 +138,9 @@ function PopperWrapper(_ref) {
124
138
  ,
125
139
  tabIndex: autoFocus ? 0 : undefined,
126
140
  shouldRenderToParent: shouldRenderToParent
127
- }, (0, _react2.jsx)(_repositionOnUpdate.RepositionOnUpdate, {
141
+ }, (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.iframe_gojiv') && (0, _react2.jsx)(_react2.Global, {
142
+ styles: blockPointerEventsOnExternalIframeStyles
143
+ }), (0, _react2.jsx)(_repositionOnUpdate.RepositionOnUpdate, {
128
144
  update: update
129
145
  }, content({
130
146
  update: update,
package/dist/cjs/popup.js CHANGED
@@ -8,6 +8,7 @@ exports.default = exports.Popup = void 0;
8
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
9
  var _react = require("react");
10
10
  var _react2 = require("@emotion/react");
11
+ var _memoizeOne = _interopRequireDefault(require("memoize-one"));
11
12
  var _layering = require("@atlaskit/layering");
12
13
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var _popper = require("@atlaskit/popper");
@@ -47,6 +48,33 @@ var Popup = exports.Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
47
48
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
48
49
  triggerRef = _useState2[0],
49
50
  setTriggerRef = _useState2[1];
51
+
52
+ /*
53
+ * Get a memoized functional ref for use within this Popup's Trigger.
54
+ * This is still very volatile to change as `prop.isOpen` will regularly change, but it's better than nothing.
55
+ * This is memoized within our component as to not be shared across all Popup instances, just this one.
56
+ *
57
+ * This is complex because the inputs are split across three different scopes:
58
+ * - `props.isOpen`
59
+ * - `useState.setTriggerRef`
60
+ * - `renderProps.ref`
61
+ */
62
+ var _useState3 = (0, _react.useState)(function () {
63
+ return (0, _memoizeOne.default)(function (ref, setTriggerRef, isOpen) {
64
+ return function (node) {
65
+ if (node && isOpen) {
66
+ if (typeof ref === 'function') {
67
+ ref(node);
68
+ } else if (ref) {
69
+ ref.current = node;
70
+ }
71
+ setTriggerRef(node);
72
+ }
73
+ };
74
+ });
75
+ }),
76
+ _useState4 = (0, _slicedToArray2.default)(_useState3, 1),
77
+ getMergedTriggerRef = _useState4[0];
50
78
  var renderPopperWrapper = (0, _react2.jsx)(_layering.UNSAFE_LAYERING, {
51
79
  isDisabled: (0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.layering_popup_1cnzt') ? false : true
52
80
  }, (0, _react2.jsx)(_popperWrapper.default, {
@@ -68,18 +96,9 @@ var Popup = exports.Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
68
96
  triggerRef: triggerRef
69
97
  }));
70
98
  return (0, _react2.jsx)(_popper.Manager, null, (0, _react2.jsx)(_popper.Reference, null, function (_ref2) {
71
- var _ref3 = _ref2.ref;
99
+ var ref = _ref2.ref;
72
100
  return trigger({
73
- ref: function ref(node) {
74
- if (node && isOpen) {
75
- if (typeof _ref3 === 'function') {
76
- _ref3(node);
77
- } else {
78
- _ref3.current = node;
79
- }
80
- setTriggerRef(node);
81
- }
82
- },
101
+ ref: getMergedTriggerRef(ref, setTriggerRef, isOpen),
83
102
  'aria-controls': id,
84
103
  'aria-expanded': isOpen,
85
104
  'aria-haspopup': true
@@ -1,7 +1,9 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  /** @jsx jsx */
3
3
  import { forwardRef, useMemo, useState } from 'react';
4
- import { css, jsx } from '@emotion/react';
4
+ import { css, Global, jsx } from '@emotion/react';
5
+ import { UNSAFE_useLayering } from '@atlaskit/layering';
6
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
5
7
  import { Popper } from '@atlaskit/popper';
6
8
  import { N0, N50A, N60A } from '@atlaskit/theme/colors';
7
9
  import { layers } from '@atlaskit/theme/constants';
@@ -25,6 +27,15 @@ const popupStyles = css({
25
27
  const popupOverflowStyles = css({
26
28
  overflow: 'auto'
27
29
  });
30
+
31
+ // disables iframe pointer events while popup is open, except if iframe is nested inside popup
32
+ // solves an issue of popup not being closed on iframe click
33
+ const blockPointerEventsOnExternalIframeStyles = css({
34
+ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
35
+ 'iframe:not([data-ds--level] iframe)': {
36
+ pointerEvents: 'none'
37
+ }
38
+ });
28
39
  const DefaultPopupComponent = /*#__PURE__*/forwardRef((props, ref) => {
29
40
  const {
30
41
  shouldRenderToParent,
@@ -68,6 +79,9 @@ function PopperWrapper({
68
79
  triggerRef,
69
80
  shouldUseCaptureOnOutsideClick
70
81
  });
82
+ const {
83
+ currentLevel
84
+ } = UNSAFE_useLayering();
71
85
  const modifiers = useMemo(() => [{
72
86
  name: 'flip',
73
87
  enabled: shouldFlip,
@@ -89,6 +103,7 @@ function PopperWrapper({
89
103
  }) => {
90
104
  return jsx(PopupContainer, {
91
105
  id: id,
106
+ "data-ds--level": currentLevel,
92
107
  "data-placement": placement,
93
108
  "data-testid": testId,
94
109
  ref: node => {
@@ -107,7 +122,9 @@ function PopperWrapper({
107
122
  ,
108
123
  tabIndex: autoFocus ? 0 : undefined,
109
124
  shouldRenderToParent: shouldRenderToParent
110
- }, jsx(RepositionOnUpdate, {
125
+ }, getBooleanFF('platform.design-system-team.iframe_gojiv') && jsx(Global, {
126
+ styles: blockPointerEventsOnExternalIframeStyles
127
+ }), jsx(RepositionOnUpdate, {
111
128
  update: update
112
129
  }, content({
113
130
  update,
@@ -2,6 +2,7 @@
2
2
  /** @jsx jsx */
3
3
  import { memo, useState } from 'react';
4
4
  import { jsx } from '@emotion/react';
5
+ import memoizeOne from 'memoize-one';
5
6
  import { UNSAFE_LAYERING } from '@atlaskit/layering';
6
7
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
8
  import { Manager, Reference } from '@atlaskit/popper';
@@ -29,6 +30,29 @@ export const Popup = /*#__PURE__*/memo(({
29
30
  shouldRenderToParent = false
30
31
  }) => {
31
32
  const [triggerRef, setTriggerRef] = useState(null);
33
+
34
+ /*
35
+ * Get a memoized functional ref for use within this Popup's Trigger.
36
+ * This is still very volatile to change as `prop.isOpen` will regularly change, but it's better than nothing.
37
+ * This is memoized within our component as to not be shared across all Popup instances, just this one.
38
+ *
39
+ * This is complex because the inputs are split across three different scopes:
40
+ * - `props.isOpen`
41
+ * - `useState.setTriggerRef`
42
+ * - `renderProps.ref`
43
+ */
44
+ const [getMergedTriggerRef] = useState(() => memoizeOne((ref, setTriggerRef, isOpen) => {
45
+ return node => {
46
+ if (node && isOpen) {
47
+ if (typeof ref === 'function') {
48
+ ref(node);
49
+ } else if (ref) {
50
+ ref.current = node;
51
+ }
52
+ setTriggerRef(node);
53
+ }
54
+ };
55
+ }));
32
56
  const renderPopperWrapper = jsx(UNSAFE_LAYERING, {
33
57
  isDisabled: getBooleanFF('platform.design-system-team.layering_popup_1cnzt') ? false : true
34
58
  }, jsx(PopperWrapper, {
@@ -53,16 +77,7 @@ export const Popup = /*#__PURE__*/memo(({
53
77
  ref
54
78
  }) => {
55
79
  return trigger({
56
- ref: node => {
57
- if (node && isOpen) {
58
- if (typeof ref === 'function') {
59
- ref(node);
60
- } else {
61
- ref.current = node;
62
- }
63
- setTriggerRef(node);
64
- }
65
- },
80
+ ref: getMergedTriggerRef(ref, setTriggerRef, isOpen),
66
81
  'aria-controls': id,
67
82
  'aria-expanded': isOpen,
68
83
  'aria-haspopup': true
@@ -6,7 +6,9 @@ var _excluded = ["shouldRenderToParent", "children"];
6
6
  var _css;
7
7
  /** @jsx jsx */
8
8
  import { forwardRef, useMemo, useState } from 'react';
9
- import { css, jsx } from '@emotion/react';
9
+ import { css, Global, jsx } from '@emotion/react';
10
+ import { UNSAFE_useLayering } from '@atlaskit/layering';
11
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
10
12
  import { Popper } from '@atlaskit/popper';
11
13
  import { N0, N50A, N60A } from '@atlaskit/theme/colors';
12
14
  import { layers } from '@atlaskit/theme/constants';
@@ -28,6 +30,15 @@ var popupStyles = css((_css = {
28
30
  var popupOverflowStyles = css({
29
31
  overflow: 'auto'
30
32
  });
33
+
34
+ // disables iframe pointer events while popup is open, except if iframe is nested inside popup
35
+ // solves an issue of popup not being closed on iframe click
36
+ var blockPointerEventsOnExternalIframeStyles = css({
37
+ // eslint-disable-next-line @atlaskit/design-system/no-nested-styles
38
+ 'iframe:not([data-ds--level] iframe)': {
39
+ pointerEvents: 'none'
40
+ }
41
+ });
31
42
  var DefaultPopupComponent = /*#__PURE__*/forwardRef(function (props, ref) {
32
43
  var shouldRenderToParent = props.shouldRenderToParent,
33
44
  children = props.children,
@@ -77,6 +88,8 @@ function PopperWrapper(_ref) {
77
88
  triggerRef: triggerRef,
78
89
  shouldUseCaptureOnOutsideClick: shouldUseCaptureOnOutsideClick
79
90
  });
91
+ var _UNSAFE_useLayering = UNSAFE_useLayering(),
92
+ currentLevel = _UNSAFE_useLayering.currentLevel;
80
93
  var modifiers = useMemo(function () {
81
94
  return [{
82
95
  name: 'flip',
@@ -99,6 +112,7 @@ function PopperWrapper(_ref) {
99
112
  update = _ref2.update;
100
113
  return jsx(PopupContainer, {
101
114
  id: id,
115
+ "data-ds--level": currentLevel,
102
116
  "data-placement": placement,
103
117
  "data-testid": testId,
104
118
  ref: function ref(node) {
@@ -117,7 +131,9 @@ function PopperWrapper(_ref) {
117
131
  ,
118
132
  tabIndex: autoFocus ? 0 : undefined,
119
133
  shouldRenderToParent: shouldRenderToParent
120
- }, jsx(RepositionOnUpdate, {
134
+ }, getBooleanFF('platform.design-system-team.iframe_gojiv') && jsx(Global, {
135
+ styles: blockPointerEventsOnExternalIframeStyles
136
+ }), jsx(RepositionOnUpdate, {
121
137
  update: update
122
138
  }, content({
123
139
  update: update,
package/dist/esm/popup.js CHANGED
@@ -3,6 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  /** @jsx jsx */
4
4
  import { memo, useState } from 'react';
5
5
  import { jsx } from '@emotion/react';
6
+ import memoizeOne from 'memoize-one';
6
7
  import { UNSAFE_LAYERING } from '@atlaskit/layering';
7
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
8
9
  import { Manager, Reference } from '@atlaskit/popper';
@@ -39,6 +40,33 @@ export var Popup = /*#__PURE__*/memo(function (_ref) {
39
40
  _useState2 = _slicedToArray(_useState, 2),
40
41
  triggerRef = _useState2[0],
41
42
  setTriggerRef = _useState2[1];
43
+
44
+ /*
45
+ * Get a memoized functional ref for use within this Popup's Trigger.
46
+ * This is still very volatile to change as `prop.isOpen` will regularly change, but it's better than nothing.
47
+ * This is memoized within our component as to not be shared across all Popup instances, just this one.
48
+ *
49
+ * This is complex because the inputs are split across three different scopes:
50
+ * - `props.isOpen`
51
+ * - `useState.setTriggerRef`
52
+ * - `renderProps.ref`
53
+ */
54
+ var _useState3 = useState(function () {
55
+ return memoizeOne(function (ref, setTriggerRef, isOpen) {
56
+ return function (node) {
57
+ if (node && isOpen) {
58
+ if (typeof ref === 'function') {
59
+ ref(node);
60
+ } else if (ref) {
61
+ ref.current = node;
62
+ }
63
+ setTriggerRef(node);
64
+ }
65
+ };
66
+ });
67
+ }),
68
+ _useState4 = _slicedToArray(_useState3, 1),
69
+ getMergedTriggerRef = _useState4[0];
42
70
  var renderPopperWrapper = jsx(UNSAFE_LAYERING, {
43
71
  isDisabled: getBooleanFF('platform.design-system-team.layering_popup_1cnzt') ? false : true
44
72
  }, jsx(PopperWrapper, {
@@ -60,18 +88,9 @@ export var Popup = /*#__PURE__*/memo(function (_ref) {
60
88
  triggerRef: triggerRef
61
89
  }));
62
90
  return jsx(Manager, null, jsx(Reference, null, function (_ref2) {
63
- var _ref3 = _ref2.ref;
91
+ var ref = _ref2.ref;
64
92
  return trigger({
65
- ref: function ref(node) {
66
- if (node && isOpen) {
67
- if (typeof _ref3 === 'function') {
68
- _ref3(node);
69
- } else {
70
- _ref3.current = node;
71
- }
72
- setTriggerRef(node);
73
- }
74
- },
93
+ ref: getMergedTriggerRef(ref, setTriggerRef, isOpen),
75
94
  'aria-controls': id,
76
95
  'aria-expanded': isOpen,
77
96
  'aria-haspopup': true
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import { FC } from 'react';
2
+ import { type FC } from 'react';
3
3
  import { PopupProps } from './types';
4
4
  export declare const Popup: FC<PopupProps>;
5
5
  export default Popup;
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import { FC } from 'react';
2
+ import { type FC } from 'react';
3
3
  import { PopupProps } from './types';
4
4
  export declare const Popup: FC<PopupProps>;
5
5
  export default Popup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.11.4",
3
+ "version": "1.11.6",
4
4
  "description": "A popup displays brief content in an overlay.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -44,11 +44,12 @@
44
44
  "@atlaskit/popper": "^5.5.0",
45
45
  "@atlaskit/portal": "^4.4.0",
46
46
  "@atlaskit/theme": "^12.6.0",
47
- "@atlaskit/tokens": "^1.28.0",
47
+ "@atlaskit/tokens": "^1.33.0",
48
48
  "@babel/runtime": "^7.0.0",
49
49
  "@emotion/react": "^11.7.1",
50
50
  "bind-event-listener": "^2.1.1",
51
- "focus-trap": "^2.4.5"
51
+ "focus-trap": "^2.4.5",
52
+ "memoize-one": "^6.0.0"
52
53
  },
53
54
  "peerDependencies": {
54
55
  "react": "^16.8.0",
@@ -57,8 +58,8 @@
57
58
  "devDependencies": {
58
59
  "@af/accessibility-testing": "*",
59
60
  "@af/visual-regression": "*",
60
- "@atlaskit/button": "^16.13.0",
61
- "@atlaskit/icon": "^21.12.0",
61
+ "@atlaskit/button": "^17.2.0",
62
+ "@atlaskit/icon": "^22.0.0",
62
63
  "@atlaskit/ssr": "*",
63
64
  "@atlaskit/visual-regression": "*",
64
65
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
@@ -101,6 +102,9 @@
101
102
  "platform-feature-flags": {
102
103
  "platform.design-system-team.layering_popup_1cnzt": {
103
104
  "type": "boolean"
105
+ },
106
+ "platform.design-system-team.iframe_gojiv": {
107
+ "type": "boolean"
104
108
  }
105
109
  },
106
110
  "homepage": "https://atlassian.design/components/popup/",
@@ -1,82 +0,0 @@
1
- ## API Report File for "@atlaskit/popup"
2
-
3
- > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4
-
5
- ```ts
6
-
7
- import { ComponentType } from 'react';
8
- import { CSSProperties } from 'react';
9
- import { Dispatch } from 'react';
10
- import { FC } from 'react';
11
- import { Placement } from '@atlaskit/popper';
12
- import { PopperChildrenProps } from '@atlaskit/popper';
13
- import { default as React_2 } from 'react';
14
- import { ReactNode } from 'react';
15
- import { Ref } from 'react';
16
- import { SetStateAction } from 'react';
17
-
18
- // @public (undocumented)
19
- interface BaseProps {
20
- autoFocus?: boolean;
21
- boundary?: 'clippingParents' | HTMLElement;
22
- content: (props: ContentProps) => React_2.ReactNode;
23
- fallbackPlacements?: Placement[];
24
- id?: string;
25
- isOpen: boolean;
26
- offset?: [number, number];
27
- onClose?(event: Event | React_2.KeyboardEvent | React_2.MouseEvent): void;
28
- placement?: Placement;
29
- popupComponent?: ComponentType<PopupComponentProps>;
30
- rootBoundary?: 'document' | 'viewport';
31
- shouldFlip?: boolean;
32
- shouldRenderToParent?: boolean;
33
- shouldUseCaptureOnOutsideClick?: boolean;
34
- testId?: string;
35
- }
36
-
37
- // @public (undocumented)
38
- export interface ContentProps {
39
- isOpen: boolean;
40
- onClose?: BaseProps['onClose'];
41
- setInitialFocusRef: Dispatch<SetStateAction<HTMLElement | null>>;
42
- update: PopperChildrenProps['update'];
43
- }
44
-
45
- // @public (undocumented)
46
- const Popup: FC<PopupProps>;
47
- export { Popup }
48
- export default Popup;
49
-
50
- // @public (undocumented)
51
- export interface PopupComponentProps {
52
- 'data-placement': Placement;
53
- 'data-testid'?: string;
54
- children: ReactNode;
55
- id?: string;
56
- ref: Ref<HTMLDivElement>;
57
- shouldRenderToParent?: boolean;
58
- style: CSSProperties;
59
- tabIndex: number | undefined;
60
- }
61
-
62
- // @public (undocumented)
63
- export interface PopupProps extends BaseProps {
64
- trigger: (props: TriggerProps) => React_2.ReactNode;
65
- zIndex?: number;
66
- }
67
-
68
- // @public (undocumented)
69
- export interface TriggerProps {
70
- // (undocumented)
71
- 'aria-controls'?: string;
72
- // (undocumented)
73
- 'aria-expanded': boolean;
74
- // (undocumented)
75
- 'aria-haspopup': boolean;
76
- // (undocumented)
77
- ref: Ref<any>;
78
- }
79
-
80
- // (No @packageDocumentation comment for this package)
81
-
82
- ```