@atlaskit/popup 1.3.8 → 1.4.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.
Files changed (35) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/__perf__/popup.tsx +1 -0
  3. package/codemods/{1.0.0-lite-mode.ts → 1.0.0-lite-mode.tsx} +0 -0
  4. package/codemods/__tests__/{1.0.0-lite-mode.ts → 1.0.0-lite-mode.tsx} +18 -19
  5. package/codemods/utils/{helpers.ts → helpers.tsx} +0 -0
  6. package/dist/cjs/index.js +4 -3
  7. package/dist/cjs/{PopperWrapper.js → popper-wrapper.js} +6 -5
  8. package/dist/cjs/{Popup.js → popup.js} +4 -2
  9. package/dist/cjs/{RepositionOnUpdate.js → reposition-on-update.js} +1 -0
  10. package/dist/cjs/{useCloseManager.js → use-close-manager.js} +6 -6
  11. package/dist/cjs/{useFocusManager.js → use-focus-manager.js} +2 -2
  12. package/dist/cjs/version.json +1 -1
  13. package/dist/es2019/index.js +3 -2
  14. package/dist/es2019/{PopperWrapper.js → popper-wrapper.js} +5 -4
  15. package/dist/es2019/{Popup.js → popup.js} +3 -1
  16. package/dist/es2019/{RepositionOnUpdate.js → reposition-on-update.js} +1 -0
  17. package/dist/es2019/{useCloseManager.js → use-close-manager.js} +8 -7
  18. package/dist/es2019/{useFocusManager.js → use-focus-manager.js} +1 -3
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/index.js +3 -2
  21. package/dist/esm/{PopperWrapper.js → popper-wrapper.js} +5 -4
  22. package/dist/esm/{Popup.js → popup.js} +3 -1
  23. package/dist/esm/{RepositionOnUpdate.js → reposition-on-update.js} +1 -0
  24. package/dist/esm/{useCloseManager.js → use-close-manager.js} +6 -6
  25. package/dist/esm/{useFocusManager.js → use-focus-manager.js} +1 -3
  26. package/dist/esm/version.json +1 -1
  27. package/dist/types/index.d.ts +1 -1
  28. package/dist/types/{PopperWrapper.d.ts → popper-wrapper.d.ts} +0 -0
  29. package/dist/types/{Popup.d.ts → popup.d.ts} +0 -0
  30. package/dist/types/{RepositionOnUpdate.d.ts → reposition-on-update.d.ts} +0 -0
  31. package/dist/types/types.d.ts +4 -4
  32. package/dist/types/{useCloseManager.d.ts → use-close-manager.d.ts} +0 -0
  33. package/dist/types/{useFocusManager.d.ts → use-focus-manager.d.ts} +0 -0
  34. package/package.json +12 -8
  35. package/report.api.md +172 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @atlaskit/popup
2
2
 
3
+ ## 1.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`01d80d395bc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/01d80d395bc) - pass event to onOpenChange consistently
8
+
9
+ ### Patch Changes
10
+
11
+ - [`8202e37941b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8202e37941b) - Internal code change turning on new linting rules.
12
+ - Updated dependencies
13
+
14
+ ## 1.3.10
15
+
16
+ ### Patch Changes
17
+
18
+ - [`8a5bdb3c844`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8a5bdb3c844) - Upgrading internal dependency (bind-event-listener) for improved internal types
19
+
20
+ ## 1.3.9
21
+
22
+ ### Patch Changes
23
+
24
+ - [`dcf8150c49c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/dcf8150c49c) - Allow `trigger` props to be applied to any HTML element tag without causing type errors for the `ref` type
25
+
3
26
  ## 1.3.8
4
27
 
5
28
  ### Patch Changes
@@ -14,6 +14,7 @@ function PopupStory() {
14
14
  trigger={(triggerProps) => (
15
15
  //@ts-ignore https://product-fabric.atlassian.net/browse/DST-1866
16
16
  <button
17
+ type="button"
17
18
  data-testid="popup-trigger"
18
19
  {...triggerProps}
19
20
  onClick={() => setIsOpen(!isOpen)}
@@ -1,5 +1,7 @@
1
1
  jest.autoMockOff();
2
2
 
3
+ import noop from '@atlaskit/ds-lib/noop';
4
+
3
5
  import transformer from '../1.0.0-lite-mode';
4
6
 
5
7
  const applyTransform = require('jscodeshift/dist/testUtils').applyTransform;
@@ -13,8 +15,6 @@ type TestArgs = {
13
15
  after?: () => void;
14
16
  };
15
17
 
16
- function noop() {}
17
-
18
18
  function check({
19
19
  it: name,
20
20
  original,
@@ -45,12 +45,12 @@ function check({
45
45
  }
46
46
 
47
47
  /**
48
- - `boundariesElement` has been replaced with two props: `boundary` and `rootBoundary`. The three supported values
49
- from the boundariesElement prop have been split between the two as follows:
50
- - `boundariesElement="scrollParents"` has been renamed: use `boundary="clippingParents"`.
51
- - `boundariesElement="window"` has been renamed: use `rootBoundary="document"`, and acts in a similar fashion.
52
- - `boundariesElement="viewport"` has been moved: use `rootBoundary="viewport"`.
53
- */
48
+ * - `boundariesElement` has been replaced with two props: `boundary` and `rootBoundary`. The three supported values
49
+ * from the boundariesElement prop have been split between the two as follows:
50
+ * - `boundariesElement="scrollParents"` has been renamed: use `boundary="clippingParents"`.
51
+ * - `boundariesElement="window"` has been renamed: use `rootBoundary="document"`, and acts in a similar fashion.
52
+ * - `boundariesElement="viewport"` has been moved: use `rootBoundary="viewport"`.
53
+ */
54
54
 
55
55
  describe('Convert boundaries props', () => {
56
56
  check({
@@ -179,8 +179,8 @@ describe('Convert boundaries props', () => {
179
179
 
180
180
  describe('Convert offset props', () => {
181
181
  /**
182
- `offset` prop is no longer a string, but an array of two integers (i.e. '0px 8px' is now [0, 8])
183
- */
182
+ * `offset` prop is no longer a string, but an array of two integers (i.e. '0px 8px' is now [0, 8])
183
+ */
184
184
  check({
185
185
  it: 'should convert offset from a string to an array of two integers',
186
186
  original: `
@@ -315,9 +315,8 @@ describe('Convert offset props', () => {
315
315
  `,
316
316
  });
317
317
  /**
318
- If a user is passing in an offset with vh, vw or % in the offset
319
- Let them know that's no longer supported
320
- */
318
+ * If a user is passing in an offset with vh, vw or % in the offset, let them know that's no longer supported
319
+ */
321
320
  check({
322
321
  it: 'should warn users using vh, vw or % in the offset',
323
322
  original: `
@@ -362,9 +361,8 @@ describe('Convert offset props', () => {
362
361
  });
363
362
 
364
363
  /**
365
- If a user is passing in a variable for offset then we should leave a comment to
366
- update it themselves
367
- */
364
+ * If a user is passing in a variable for offset then we should leave a comment to update it themselves
365
+ */
368
366
  check({
369
367
  it: 'warn users passing in a variable for an offset',
370
368
  original: `
@@ -490,9 +488,10 @@ describe('Convert offset props', () => {
490
488
  });
491
489
  });
492
490
 
493
- /** Render Props:
494
- - `scheduleUpdate`, for async updates, has been renamed to `update`, and now returns a Promise.
495
- */
491
+ /**
492
+ * Render Props:
493
+ * - `scheduleUpdate`, for async updates, has been renamed to `update`, and now returns a Promise.
494
+ */
496
495
  describe('Convert render props', () => {
497
496
  check({
498
497
  it: 'should rename schedulUpdate to `update`',
File without changes
package/dist/cjs/index.js CHANGED
@@ -6,12 +6,13 @@ Object.defineProperty(exports, "__esModule", {
6
6
  Object.defineProperty(exports, "Popup", {
7
7
  enumerable: true,
8
8
  get: function get() {
9
- return _Popup.Popup;
9
+ return _popup.Popup;
10
10
  }
11
11
  });
12
12
  exports.default = void 0;
13
13
 
14
- var _Popup = require("./Popup");
14
+ var _popup = require("./popup");
15
15
 
16
- var _default = _Popup.Popup;
16
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
17
+ var _default = _popup.Popup;
17
18
  exports.default = _default;
@@ -21,11 +21,11 @@ var _colors = require("@atlaskit/theme/colors");
21
21
 
22
22
  var _constants = require("@atlaskit/theme/constants");
23
23
 
24
- var _RepositionOnUpdate = require("./RepositionOnUpdate");
24
+ var _repositionOnUpdate = require("./reposition-on-update");
25
25
 
26
- var _useCloseManager = require("./useCloseManager");
26
+ var _useCloseManager = require("./use-close-manager");
27
27
 
28
- var _useFocusManager = require("./useFocusManager");
28
+ var _useFocusManager = require("./use-focus-manager");
29
29
 
30
30
  /** @jsx jsx */
31
31
  var popupStyles = (0, _core.css)({
@@ -128,7 +128,7 @@ function PopperWrapper(_ref) {
128
128
  // first on the browser address bar when using keyboard
129
129
  ,
130
130
  tabIndex: autoFocus ? 0 : undefined
131
- }, (0, _core.jsx)(_RepositionOnUpdate.RepositionOnUpdate, {
131
+ }, (0, _core.jsx)(_repositionOnUpdate.RepositionOnUpdate, {
132
132
  update: update
133
133
  }, content({
134
134
  update: update,
@@ -137,7 +137,8 @@ function PopperWrapper(_ref) {
137
137
  setInitialFocusRef: setInitialFocusRef
138
138
  })));
139
139
  });
140
- }
140
+ } // eslint-disable-next-line @repo/internal/react/require-jsdoc
141
+
141
142
 
142
143
  var _default = PopperWrapper;
143
144
  exports.default = _default;
@@ -19,7 +19,9 @@ var _portal = _interopRequireDefault(require("@atlaskit/portal"));
19
19
 
20
20
  var _constants = require("@atlaskit/theme/constants");
21
21
 
22
- var _PopperWrapper = _interopRequireDefault(require("./PopperWrapper"));
22
+ var _popperWrapper = _interopRequireDefault(require("./popper-wrapper"));
23
+
24
+ /* eslint-disable @repo/internal/react/require-jsdoc */
23
25
 
24
26
  /** @jsx jsx */
25
27
  var defaultLayer = _constants.layers.layer();
@@ -73,7 +75,7 @@ var Popup = /*#__PURE__*/(0, _react.memo)(function (_ref) {
73
75
  });
74
76
  }), isOpen && (0, _core.jsx)(_portal.default, {
75
77
  zIndex: zIndex
76
- }, (0, _core.jsx)(_PopperWrapper.default, {
78
+ }, (0, _core.jsx)(_popperWrapper.default, {
77
79
  content: content,
78
80
  isOpen: isOpen,
79
81
  placement: placement,
@@ -13,6 +13,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
13
13
 
14
14
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
15
 
16
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
16
17
  var RepositionOnUpdate = function RepositionOnUpdate(_ref) {
17
18
  var children = _ref.children,
18
19
  update = _ref.update;
@@ -22,9 +22,9 @@ var useCloseManager = function useCloseManager(_ref) {
22
22
  return noop;
23
23
  }
24
24
 
25
- var closePopup = function closePopup() {
25
+ var closePopup = function closePopup(event) {
26
26
  if (onClose) {
27
- onClose();
27
+ onClose(event);
28
28
  }
29
29
  }; // This check is required for cases where components like
30
30
  // Select or DDM are placed inside a Popup. A click
@@ -35,8 +35,8 @@ var useCloseManager = function useCloseManager(_ref) {
35
35
  // https://codesandbox.io/s/atlaskitpopup-default-forked-2eb87?file=/example.tsx:0-1788
36
36
 
37
37
 
38
- var onClick = function onClick(_ref2) {
39
- var target = _ref2.target;
38
+ var onClick = function onClick(event) {
39
+ var target = event.target;
40
40
  var doesDomNodeExist = document.body.contains(target);
41
41
 
42
42
  if (!doesDomNodeExist) {
@@ -47,7 +47,7 @@ var useCloseManager = function useCloseManager(_ref) {
47
47
  var isClickOnTrigger = triggerRef && triggerRef.contains(target);
48
48
 
49
49
  if (!isClickOnPopup && !isClickOnTrigger) {
50
- closePopup();
50
+ closePopup(event);
51
51
  }
52
52
  };
53
53
 
@@ -55,7 +55,7 @@ var useCloseManager = function useCloseManager(_ref) {
55
55
  var key = event.key;
56
56
 
57
57
  if (key === 'Escape' || key === 'Esc') {
58
- closePopup();
58
+ closePopup(event);
59
59
  }
60
60
  };
61
61
 
@@ -11,14 +11,14 @@ var _react = require("react");
11
11
 
12
12
  var _focusTrap = _interopRequireDefault(require("focus-trap"));
13
13
 
14
- var noop = function noop() {};
14
+ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
15
15
 
16
16
  var useFocusManager = function useFocusManager(_ref) {
17
17
  var popupRef = _ref.popupRef,
18
18
  initialFocusRef = _ref.initialFocusRef;
19
19
  (0, _react.useEffect)(function () {
20
20
  if (!popupRef) {
21
- return noop;
21
+ return _noop.default;
22
22
  }
23
23
 
24
24
  var trapConfig = {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.3.8",
3
+ "version": "1.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,3 +1,4 @@
1
- import { Popup } from './Popup';
2
- export { Popup };
1
+ import { Popup } from './popup';
2
+ export { Popup }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
3
+
3
4
  export default Popup;
@@ -6,9 +6,9 @@ import { css, jsx } from '@emotion/core';
6
6
  import { Popper } from '@atlaskit/popper';
7
7
  import { N0, N50A, N60A } from '@atlaskit/theme/colors';
8
8
  import { borderRadius, layers } from '@atlaskit/theme/constants';
9
- import { RepositionOnUpdate } from './RepositionOnUpdate';
10
- import { useCloseManager } from './useCloseManager';
11
- import { useFocusManager } from './useFocusManager';
9
+ import { RepositionOnUpdate } from './reposition-on-update';
10
+ import { useCloseManager } from './use-close-manager';
11
+ import { useFocusManager } from './use-focus-manager';
12
12
  const popupStyles = css({
13
13
  display: 'block',
14
14
  boxSizing: 'border-box',
@@ -104,6 +104,7 @@ function PopperWrapper({
104
104
  setInitialFocusRef
105
105
  })));
106
106
  });
107
- }
107
+ } // eslint-disable-next-line @repo/internal/react/require-jsdoc
108
+
108
109
 
109
110
  export default PopperWrapper;
@@ -1,10 +1,12 @@
1
+ /* eslint-disable @repo/internal/react/require-jsdoc */
2
+
1
3
  /** @jsx jsx */
2
4
  import { memo, useState } from 'react';
3
5
  import { jsx } from '@emotion/core';
4
6
  import { Manager, Reference } from '@atlaskit/popper';
5
7
  import Portal from '@atlaskit/portal';
6
8
  import { layers } from '@atlaskit/theme/constants';
7
- import PopperWrapper from './PopperWrapper';
9
+ import PopperWrapper from './popper-wrapper';
8
10
  const defaultLayer = layers.layer();
9
11
  export const Popup = /*#__PURE__*/memo(({
10
12
  isOpen,
@@ -1,4 +1,5 @@
1
1
  import React, { Fragment, useLayoutEffect, useRef } from 'react';
2
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
2
3
  export const RepositionOnUpdate = ({
3
4
  children,
4
5
  update
@@ -15,9 +15,9 @@ export const useCloseManager = ({
15
15
  return noop;
16
16
  }
17
17
 
18
- const closePopup = () => {
18
+ const closePopup = event => {
19
19
  if (onClose) {
20
- onClose();
20
+ onClose(event);
21
21
  }
22
22
  }; // This check is required for cases where components like
23
23
  // Select or DDM are placed inside a Popup. A click
@@ -28,9 +28,10 @@ export const useCloseManager = ({
28
28
  // https://codesandbox.io/s/atlaskitpopup-default-forked-2eb87?file=/example.tsx:0-1788
29
29
 
30
30
 
31
- const onClick = ({
32
- target
33
- }) => {
31
+ const onClick = event => {
32
+ const {
33
+ target
34
+ } = event;
34
35
  const doesDomNodeExist = document.body.contains(target);
35
36
 
36
37
  if (!doesDomNodeExist) {
@@ -41,7 +42,7 @@ export const useCloseManager = ({
41
42
  const isClickOnTrigger = triggerRef && triggerRef.contains(target);
42
43
 
43
44
  if (!isClickOnPopup && !isClickOnTrigger) {
44
- closePopup();
45
+ closePopup(event);
45
46
  }
46
47
  };
47
48
 
@@ -51,7 +52,7 @@ export const useCloseManager = ({
51
52
  } = event;
52
53
 
53
54
  if (key === 'Escape' || key === 'Esc') {
54
- closePopup();
55
+ closePopup(event);
55
56
  }
56
57
  };
57
58
 
@@ -1,8 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  import createFocusTrap from 'focus-trap';
3
-
4
- const noop = () => {};
5
-
3
+ import noop from '@atlaskit/ds-lib/noop';
6
4
  export const useFocusManager = ({
7
5
  popupRef,
8
6
  initialFocusRef
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.3.8",
3
+ "version": "1.4.0",
4
4
  "sideEffects": false
5
5
  }
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
- import { Popup } from './Popup';
2
- export { Popup };
1
+ import { Popup } from './popup';
2
+ export { Popup }; // eslint-disable-next-line @repo/internal/react/require-jsdoc
3
+
3
4
  export default Popup;
@@ -7,9 +7,9 @@ import { css, jsx } from '@emotion/core';
7
7
  import { Popper } from '@atlaskit/popper';
8
8
  import { N0, N50A, N60A } from '@atlaskit/theme/colors';
9
9
  import { borderRadius, layers } from '@atlaskit/theme/constants';
10
- import { RepositionOnUpdate } from './RepositionOnUpdate';
11
- import { useCloseManager } from './useCloseManager';
12
- import { useFocusManager } from './useFocusManager';
10
+ import { RepositionOnUpdate } from './reposition-on-update';
11
+ import { useCloseManager } from './use-close-manager';
12
+ import { useFocusManager } from './use-focus-manager';
13
13
  var popupStyles = css({
14
14
  display: 'block',
15
15
  boxSizing: 'border-box',
@@ -119,6 +119,7 @@ function PopperWrapper(_ref) {
119
119
  setInitialFocusRef: setInitialFocusRef
120
120
  })));
121
121
  });
122
- }
122
+ } // eslint-disable-next-line @repo/internal/react/require-jsdoc
123
+
123
124
 
124
125
  export default PopperWrapper;
@@ -1,12 +1,14 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
2
 
3
+ /* eslint-disable @repo/internal/react/require-jsdoc */
4
+
3
5
  /** @jsx jsx */
4
6
  import { memo, useState } from 'react';
5
7
  import { jsx } from '@emotion/core';
6
8
  import { Manager, Reference } from '@atlaskit/popper';
7
9
  import Portal from '@atlaskit/portal';
8
10
  import { layers } from '@atlaskit/theme/constants';
9
- import PopperWrapper from './PopperWrapper';
11
+ import PopperWrapper from './popper-wrapper';
10
12
  var defaultLayer = layers.layer();
11
13
  export var Popup = /*#__PURE__*/memo(function (_ref) {
12
14
  var isOpen = _ref.isOpen,
@@ -1,4 +1,5 @@
1
1
  import React, { Fragment, useLayoutEffect, useRef } from 'react';
2
+ // eslint-disable-next-line @repo/internal/react/require-jsdoc
2
3
  export var RepositionOnUpdate = function RepositionOnUpdate(_ref) {
3
4
  var children = _ref.children,
4
5
  update = _ref.update;
@@ -14,9 +14,9 @@ export var useCloseManager = function useCloseManager(_ref) {
14
14
  return noop;
15
15
  }
16
16
 
17
- var closePopup = function closePopup() {
17
+ var closePopup = function closePopup(event) {
18
18
  if (onClose) {
19
- onClose();
19
+ onClose(event);
20
20
  }
21
21
  }; // This check is required for cases where components like
22
22
  // Select or DDM are placed inside a Popup. A click
@@ -27,8 +27,8 @@ export var useCloseManager = function useCloseManager(_ref) {
27
27
  // https://codesandbox.io/s/atlaskitpopup-default-forked-2eb87?file=/example.tsx:0-1788
28
28
 
29
29
 
30
- var onClick = function onClick(_ref2) {
31
- var target = _ref2.target;
30
+ var onClick = function onClick(event) {
31
+ var target = event.target;
32
32
  var doesDomNodeExist = document.body.contains(target);
33
33
 
34
34
  if (!doesDomNodeExist) {
@@ -39,7 +39,7 @@ export var useCloseManager = function useCloseManager(_ref) {
39
39
  var isClickOnTrigger = triggerRef && triggerRef.contains(target);
40
40
 
41
41
  if (!isClickOnPopup && !isClickOnTrigger) {
42
- closePopup();
42
+ closePopup(event);
43
43
  }
44
44
  };
45
45
 
@@ -47,7 +47,7 @@ export var useCloseManager = function useCloseManager(_ref) {
47
47
  var key = event.key;
48
48
 
49
49
  if (key === 'Escape' || key === 'Esc') {
50
- closePopup();
50
+ closePopup(event);
51
51
  }
52
52
  };
53
53
 
@@ -1,8 +1,6 @@
1
1
  import { useEffect } from 'react';
2
2
  import createFocusTrap from 'focus-trap';
3
-
4
- var noop = function noop() {};
5
-
3
+ import noop from '@atlaskit/ds-lib/noop';
6
4
  export var useFocusManager = function useFocusManager(_ref) {
7
5
  var popupRef = _ref.popupRef,
8
6
  initialFocusRef = _ref.initialFocusRef;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.3.8",
3
+ "version": "1.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -1,4 +1,4 @@
1
- import { Popup } from './Popup';
1
+ import { Popup } from './popup';
2
2
  export type { ContentProps, PopupComponentProps, PopupProps, TriggerProps, } from './types';
3
3
  export { Popup };
4
4
  export default Popup;
File without changes
@@ -1,7 +1,7 @@
1
- import { ComponentType, CSSProperties, Dispatch, ReactNode, Ref, SetStateAction } from 'react';
1
+ import React, { ComponentType, CSSProperties, Dispatch, ReactNode, Ref, SetStateAction } from 'react';
2
2
  import { Placement, PopperChildrenProps } from '@atlaskit/popper';
3
3
  export interface TriggerProps {
4
- ref: Ref<HTMLElement>;
4
+ ref: Ref<any>;
5
5
  'aria-controls'?: string;
6
6
  'aria-expanded': boolean;
7
7
  'aria-haspopup': boolean;
@@ -21,7 +21,7 @@ export interface ContentProps {
21
21
  /**
22
22
  * Passed through from the parent popup.
23
23
  */
24
- onClose: (() => void) | undefined;
24
+ onClose?: BaseProps['onClose'];
25
25
  /**
26
26
  * Escape hatch to set the initial focus for a specific element when the popup is opened.
27
27
  */
@@ -115,7 +115,7 @@ interface BaseProps {
115
115
  * Generally this will be either when clicking away from the popup or pressing the escape key.
116
116
  * You'll want to use this to set open state accordingly and then pump it back into the `isOpen` prop.
117
117
  */
118
- onClose?(): void;
118
+ onClose?(event: Event | React.MouseEvent | React.KeyboardEvent): void;
119
119
  /**
120
120
  * The element that is shown when `isOpen` prop is `true`.
121
121
  * The result of the `content` prop will be placed as children here.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@atlaskit/popup",
3
- "version": "1.3.8",
3
+ "version": "1.4.0",
4
4
  "description": "A popup displays brief content in an overlay.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
7
7
  },
8
- "repository": "https://bitbucket.org/atlassian/atlassian-frontend",
8
+ "repository": "https://bitbucket.org/atlassian/atlassian-frontend-mirror",
9
9
  "author": "Atlassian Pty Ltd",
10
10
  "license": "Apache-2.0",
11
11
  "main": "dist/cjs/index.js",
@@ -13,26 +13,28 @@
13
13
  "module:es2019": "dist/es2019/index.js",
14
14
  "types": "dist/types/index.d.ts",
15
15
  "sideEffects": false,
16
- "atlaskit:src": "src/index.ts",
16
+ "atlaskit:src": "src/index.tsx",
17
17
  "af:exports": {
18
- ".": "./src/index.ts",
19
- "./types": "./src/types.ts"
18
+ ".": "./src/index.tsx",
19
+ "./types": "./src/types.tsx"
20
20
  },
21
21
  "atlassian": {
22
22
  "team": "Design System Team",
23
23
  "releaseModel": "scheduled",
24
24
  "website": {
25
- "name": "Popup"
25
+ "name": "Popup",
26
+ "category": "Components"
26
27
  }
27
28
  },
28
29
  "dependencies": {
30
+ "@atlaskit/ds-lib": "^2.1.0",
29
31
  "@atlaskit/popper": "^5.0.0",
30
32
  "@atlaskit/portal": "^4.0.0",
31
33
  "@atlaskit/theme": "^12.1.0",
32
34
  "@atlaskit/tokens": "^0.10.0",
33
35
  "@babel/runtime": "^7.0.0",
34
36
  "@emotion/core": "^10.0.9",
35
- "bind-event-listener": "^2.1.0",
37
+ "bind-event-listener": "^2.1.1",
36
38
  "focus-trap": "^2.4.5"
37
39
  },
38
40
  "peerDependencies": {
@@ -46,7 +48,7 @@
46
48
  "@atlaskit/menu": "^1.3.0",
47
49
  "@atlaskit/radio": "^5.3.0",
48
50
  "@atlaskit/section-message": "^6.1.0",
49
- "@atlaskit/select": "^15.0.0",
51
+ "@atlaskit/select": "^15.5.0",
50
52
  "@atlaskit/ssr": "*",
51
53
  "@atlaskit/textfield": "^5.1.7",
52
54
  "@atlaskit/toggle": "^12.4.4",
@@ -73,6 +75,8 @@
73
75
  "import-structure": "atlassian-conventions"
74
76
  },
75
77
  "@repo/internal": {
78
+ "dom-events": "use-bind-event-listener",
79
+ "design-system": "v1",
76
80
  "ui-components": "lite-mode",
77
81
  "analytics": "analytics-next",
78
82
  "theming": "tokens",
package/report.api.md ADDED
@@ -0,0 +1,172 @@
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
+ import { ComponentType } from 'react';
7
+ import { CSSProperties } from 'react';
8
+ import { Dispatch } from 'react';
9
+ import { FC } from 'react';
10
+ import { Placement } from '@atlaskit/popper';
11
+ import { PopperChildrenProps } from '@atlaskit/popper';
12
+ import { ReactNode } from 'react';
13
+ import { Ref } from 'react';
14
+ import { SetStateAction } from 'react';
15
+
16
+ declare interface BaseProps {
17
+ /**
18
+ * Used to either show or hide the popup.
19
+ * When set to `false` popup will not render anything to the DOM.
20
+ */
21
+ isOpen: boolean;
22
+ /**
23
+ * Render props for content that is displayed inside the popup.
24
+ */
25
+ content: (props: ContentProps) => React.ReactNode;
26
+ /**
27
+ * Id that is assigned to the popup container element.
28
+ */
29
+ id?: string;
30
+ /**
31
+ * Distance the popup should be offset from the reference in the format of [along, away] (units in px).
32
+ * Defaults to [0, 8] - which means the popup will be 8px away from the edge of the reference specified
33
+ * by the `placement` prop.
34
+ */
35
+ offset?: [number, number];
36
+ /**
37
+ * Placement of where the popup should be displayed relative to the trigger element.
38
+ * Defaults to `"auto"`.
39
+ */
40
+ placement?: Placement;
41
+ /**
42
+ * Defines a list of placements to try.
43
+ * When no space is available on the preferred placement,
44
+ * the modifier will test the ones provided in the list, and use the first useful one.
45
+ */
46
+ fallbackPlacements?: Placement[];
47
+ /**
48
+ * The boundary element that the popup will check for overflow.
49
+ * Defaults to `"clippingParents"` which are parent scroll containers,
50
+ * but can be set to any element.
51
+ */
52
+ boundary?: 'clippingParents' | HTMLElement;
53
+ /**
54
+ * The root boundary that the popup will check for overflow.
55
+ * Defaults to `"viewport"` but can be set to `"document"`.
56
+ */
57
+ rootBoundary?: 'viewport' | 'document';
58
+ /**
59
+ * Allows the Popup to be placed on the opposite side of its trigger if it does not fit in the viewport.
60
+ * Defaults to `true`.
61
+ */
62
+ shouldFlip?: boolean;
63
+ /**
64
+ * A `testId` prop is provided for specified elements,
65
+ * which is a unique string that appears as a data attribute `data-testid` in the rendered code,
66
+ * serving as a hook for automated tests.
67
+ */
68
+ testId?: string;
69
+ /**
70
+ * Handler that is called when the popup wants to close itself.
71
+ * Generally this will be either when clicking away from the popup or pressing the escape key.
72
+ * You'll want to use this to set open state accordingly and then pump it back into the `isOpen` prop.
73
+ */
74
+ onClose?(): void;
75
+ /**
76
+ * The element that is shown when `isOpen` prop is `true`.
77
+ * The result of the `content` prop will be placed as children here.
78
+ * Defaults to an element with an elevation of `e200` with _no padding_.
79
+ */
80
+ popupComponent?: ComponentType<PopupComponentProps>;
81
+ /**
82
+ * Controls whether the popup takes focus when opening.
83
+ * This changes the `popupComponent` component tabIndex to `null`.
84
+ * Defaults to `true`.
85
+ */
86
+ autoFocus?: boolean;
87
+ /**
88
+ * Controls if the event which handles clicks outside the popup is be bound with
89
+ * `capture: true`.
90
+ */
91
+ shouldUseCaptureOnOutsideClick?: boolean;
92
+ }
93
+
94
+ export declare interface ContentProps {
95
+ /**
96
+ * Will reposition the popup if any of the content has changed.
97
+ * Useful for when positions change and the popup was not aware.
98
+ */
99
+ update: PopperChildrenProps['update'];
100
+ /**
101
+ * Passed through from the parent popup.
102
+ */
103
+ isOpen: boolean;
104
+ /**
105
+ * Passed through from the parent popup.
106
+ */
107
+ onClose: (() => void) | undefined;
108
+ /**
109
+ * Escape hatch to set the initial focus for a specific element when the popup is opened.
110
+ */
111
+ setInitialFocusRef: Dispatch<SetStateAction<HTMLElement | null>>;
112
+ }
113
+
114
+ declare const Popup: FC<PopupProps>;
115
+ export { Popup };
116
+ export default Popup;
117
+
118
+ export declare interface PopupComponentProps {
119
+ /**
120
+ * Children passed passed through by the parent popup.
121
+ */
122
+ children: ReactNode;
123
+ /**
124
+ * Placement passed through by the parent popup.
125
+ */
126
+ 'data-placement': Placement;
127
+ /**
128
+ * Test id passed through by the parent popup.
129
+ */
130
+ 'data-testid'?: string;
131
+ /**
132
+ * Id passed through by the parent popup.
133
+ */
134
+ id?: string;
135
+ /**
136
+ * Ref that should be assigned to the root element.
137
+ */
138
+ ref: Ref<HTMLDivElement>;
139
+ /**
140
+ * Style that should be assigned to the root element.
141
+ */
142
+ style: CSSProperties;
143
+ /**
144
+ * Tab index passed through by the parent popup.
145
+ */
146
+ tabIndex: number | undefined;
147
+ }
148
+
149
+ export declare interface PopupProps extends BaseProps {
150
+ /**
151
+ * Render props used to anchor the popup to your content.
152
+ * Make this an interactive element,
153
+ * such as an `@atlaskit/button` component.
154
+ */
155
+ trigger: (props: TriggerProps) => React.ReactNode;
156
+ /**
157
+ * Z-index that the popup should be displayed in.
158
+ * This is passed to the portal component.
159
+ * Defaults to `layers.layer()` from `@atlaskit/theme`.
160
+ */
161
+ zIndex?: number;
162
+ }
163
+
164
+ export declare interface TriggerProps {
165
+ ref: Ref<any>;
166
+ 'aria-controls'?: string;
167
+ 'aria-expanded': boolean;
168
+ 'aria-haspopup': boolean;
169
+ }
170
+
171
+ export {};
172
+ ```