@atlaskit/popup 1.10.2 → 1.11.1
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 +12 -0
- package/dist/cjs/popper-wrapper.js +7 -3
- package/dist/cjs/use-focus-manager.js +33 -12
- package/dist/es2019/popper-wrapper.js +5 -3
- package/dist/es2019/use-focus-manager.js +33 -12
- package/dist/esm/popper-wrapper.js +7 -3
- package/dist/esm/use-focus-manager.js +33 -12
- package/dist/types/types.d.ts +1 -1
- package/dist/types/use-focus-manager.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +4 -0
- package/dist/types-ts4.5/popper-wrapper.d.ts +4 -0
- package/dist/types-ts4.5/popup.d.ts +5 -0
- package/dist/types-ts4.5/reposition-on-update.d.ts +3 -0
- package/dist/types-ts4.5/types.d.ts +180 -0
- package/dist/types-ts4.5/use-close-manager.d.ts +2 -0
- package/dist/types-ts4.5/use-focus-manager.d.ts +2 -0
- package/package.json +9 -3
- package/tmp/api-report-tmp.d.ts +82 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/popup
|
|
2
2
|
|
|
3
|
+
## 1.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#41322](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41322) [`f54519b315c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f54519b315c) - This removes the error in console when passing `shouldRenderToParent` prop.
|
|
8
|
+
|
|
9
|
+
## 1.11.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#41251](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41251) [`b0a2a8d78c6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b0a2a8d78c6) - [ux] We are testing removing the `focus-trap` package for a smaller sharper implementation of focus management behind a feature flag. If this fix is successful it will be available in a later release.
|
|
14
|
+
|
|
3
15
|
## 1.10.2
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
9
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
10
11
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
12
|
var _react = require("react");
|
|
12
13
|
var _react2 = require("@emotion/react");
|
|
@@ -17,6 +18,7 @@ var _tokens = require("@atlaskit/tokens");
|
|
|
17
18
|
var _repositionOnUpdate = require("./reposition-on-update");
|
|
18
19
|
var _useCloseManager = require("./use-close-manager");
|
|
19
20
|
var _useFocusManager = require("./use-focus-manager");
|
|
21
|
+
var _excluded = ["shouldRenderToParent", "children"];
|
|
20
22
|
var _css;
|
|
21
23
|
/** @jsx jsx */
|
|
22
24
|
var popupStyles = (0, _react2.css)((_css = {
|
|
@@ -34,12 +36,14 @@ var popupOverflowStyles = (0, _react2.css)({
|
|
|
34
36
|
overflow: 'auto'
|
|
35
37
|
});
|
|
36
38
|
var DefaultPopupComponent = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
37
|
-
var shouldRenderToParent = props.shouldRenderToParent
|
|
39
|
+
var shouldRenderToParent = props.shouldRenderToParent,
|
|
40
|
+
children = props.children,
|
|
41
|
+
htmlAttributes = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
38
42
|
return (0, _react2.jsx)("div", (0, _extends2.default)({
|
|
39
43
|
css: [popupStyles, !shouldRenderToParent && popupOverflowStyles]
|
|
40
|
-
},
|
|
44
|
+
}, htmlAttributes, {
|
|
41
45
|
ref: ref
|
|
42
|
-
}));
|
|
46
|
+
}), children);
|
|
43
47
|
});
|
|
44
48
|
function PopperWrapper(_ref) {
|
|
45
49
|
var isOpen = _ref.isOpen,
|
|
@@ -8,34 +8,55 @@ exports.useFocusManager = void 0;
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _focusTrap = _interopRequireDefault(require("focus-trap"));
|
|
10
10
|
var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
11
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
11
12
|
var useFocusManager = exports.useFocusManager = function useFocusManager(_ref) {
|
|
12
|
-
var
|
|
13
|
-
|
|
13
|
+
var initialFocusRef = _ref.initialFocusRef,
|
|
14
|
+
popupRef = _ref.popupRef;
|
|
14
15
|
(0, _react.useEffect)(function () {
|
|
15
16
|
if (!popupRef) {
|
|
16
17
|
return _noop.default;
|
|
17
18
|
}
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
var previouslyFocusedElement;
|
|
20
|
+
var focusTrap;
|
|
21
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.remove-focus-trap-from-popup_3q7sk')) {
|
|
22
|
+
previouslyFocusedElement = document.activeElement;
|
|
23
|
+
} else {
|
|
24
|
+
var trapConfig = {
|
|
25
|
+
clickOutsideDeactivates: true,
|
|
26
|
+
escapeDeactivates: true,
|
|
27
|
+
initialFocus: initialFocusRef || popupRef,
|
|
28
|
+
fallbackFocus: popupRef,
|
|
29
|
+
returnFocusOnDeactivate: true
|
|
30
|
+
};
|
|
31
|
+
focusTrap = (0, _focusTrap.default)(popupRef, trapConfig);
|
|
32
|
+
}
|
|
26
33
|
var frameId = null;
|
|
27
34
|
|
|
28
35
|
// wait for the popup to reposition itself before we focus
|
|
29
36
|
frameId = requestAnimationFrame(function () {
|
|
30
37
|
frameId = null;
|
|
31
|
-
|
|
38
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.remove-focus-trap-from-popup_3q7sk')) {
|
|
39
|
+
if (initialFocusRef && initialFocusRef.focus) {
|
|
40
|
+
initialFocusRef.focus();
|
|
41
|
+
} else {
|
|
42
|
+
popupRef.focus();
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
focusTrap.activate();
|
|
46
|
+
}
|
|
32
47
|
});
|
|
33
48
|
return function () {
|
|
34
49
|
if (frameId != null) {
|
|
35
50
|
cancelAnimationFrame(frameId);
|
|
36
51
|
frameId = null;
|
|
37
52
|
}
|
|
38
|
-
|
|
53
|
+
if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.remove-focus-trap-from-popup_3q7sk')) {
|
|
54
|
+
if (previouslyFocusedElement && previouslyFocusedElement.focus) {
|
|
55
|
+
previouslyFocusedElement.focus();
|
|
56
|
+
}
|
|
57
|
+
} else {
|
|
58
|
+
focusTrap.deactivate();
|
|
59
|
+
}
|
|
39
60
|
};
|
|
40
61
|
}, [popupRef, initialFocusRef]);
|
|
41
62
|
};
|
|
@@ -27,13 +27,15 @@ const popupOverflowStyles = css({
|
|
|
27
27
|
});
|
|
28
28
|
const DefaultPopupComponent = /*#__PURE__*/forwardRef((props, ref) => {
|
|
29
29
|
const {
|
|
30
|
-
shouldRenderToParent
|
|
30
|
+
shouldRenderToParent,
|
|
31
|
+
children,
|
|
32
|
+
...htmlAttributes
|
|
31
33
|
} = props;
|
|
32
34
|
return jsx("div", _extends({
|
|
33
35
|
css: [popupStyles, !shouldRenderToParent && popupOverflowStyles]
|
|
34
|
-
},
|
|
36
|
+
}, htmlAttributes, {
|
|
35
37
|
ref: ref
|
|
36
|
-
}));
|
|
38
|
+
}), children);
|
|
37
39
|
});
|
|
38
40
|
function PopperWrapper({
|
|
39
41
|
isOpen,
|
|
@@ -1,35 +1,56 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import createFocusTrap from 'focus-trap';
|
|
3
3
|
import noop from '@atlaskit/ds-lib/noop';
|
|
4
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
export const useFocusManager = ({
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
initialFocusRef,
|
|
7
|
+
popupRef
|
|
7
8
|
}) => {
|
|
8
9
|
useEffect(() => {
|
|
9
10
|
if (!popupRef) {
|
|
10
11
|
return noop;
|
|
11
12
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
let previouslyFocusedElement;
|
|
14
|
+
let focusTrap;
|
|
15
|
+
if (getBooleanFF('platform.design-system-team.remove-focus-trap-from-popup_3q7sk')) {
|
|
16
|
+
previouslyFocusedElement = document.activeElement;
|
|
17
|
+
} else {
|
|
18
|
+
const trapConfig = {
|
|
19
|
+
clickOutsideDeactivates: true,
|
|
20
|
+
escapeDeactivates: true,
|
|
21
|
+
initialFocus: initialFocusRef || popupRef,
|
|
22
|
+
fallbackFocus: popupRef,
|
|
23
|
+
returnFocusOnDeactivate: true
|
|
24
|
+
};
|
|
25
|
+
focusTrap = createFocusTrap(popupRef, trapConfig);
|
|
26
|
+
}
|
|
20
27
|
let frameId = null;
|
|
21
28
|
|
|
22
29
|
// wait for the popup to reposition itself before we focus
|
|
23
30
|
frameId = requestAnimationFrame(() => {
|
|
24
31
|
frameId = null;
|
|
25
|
-
|
|
32
|
+
if (getBooleanFF('platform.design-system-team.remove-focus-trap-from-popup_3q7sk')) {
|
|
33
|
+
if (initialFocusRef && initialFocusRef.focus) {
|
|
34
|
+
initialFocusRef.focus();
|
|
35
|
+
} else {
|
|
36
|
+
popupRef.focus();
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
focusTrap.activate();
|
|
40
|
+
}
|
|
26
41
|
});
|
|
27
42
|
return () => {
|
|
28
43
|
if (frameId != null) {
|
|
29
44
|
cancelAnimationFrame(frameId);
|
|
30
45
|
frameId = null;
|
|
31
46
|
}
|
|
32
|
-
|
|
47
|
+
if (getBooleanFF('platform.design-system-team.remove-focus-trap-from-popup_3q7sk')) {
|
|
48
|
+
if (previouslyFocusedElement && previouslyFocusedElement.focus) {
|
|
49
|
+
previouslyFocusedElement.focus();
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
focusTrap.deactivate();
|
|
53
|
+
}
|
|
33
54
|
};
|
|
34
55
|
}, [popupRef, initialFocusRef]);
|
|
35
56
|
};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
2
|
import _extends from "@babel/runtime/helpers/extends";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
5
|
+
var _excluded = ["shouldRenderToParent", "children"];
|
|
4
6
|
var _css;
|
|
5
7
|
/** @jsx jsx */
|
|
6
8
|
import { forwardRef, useMemo, useState } from 'react';
|
|
@@ -27,12 +29,14 @@ var popupOverflowStyles = css({
|
|
|
27
29
|
overflow: 'auto'
|
|
28
30
|
});
|
|
29
31
|
var DefaultPopupComponent = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
30
|
-
var shouldRenderToParent = props.shouldRenderToParent
|
|
32
|
+
var shouldRenderToParent = props.shouldRenderToParent,
|
|
33
|
+
children = props.children,
|
|
34
|
+
htmlAttributes = _objectWithoutProperties(props, _excluded);
|
|
31
35
|
return jsx("div", _extends({
|
|
32
36
|
css: [popupStyles, !shouldRenderToParent && popupOverflowStyles]
|
|
33
|
-
},
|
|
37
|
+
}, htmlAttributes, {
|
|
34
38
|
ref: ref
|
|
35
|
-
}));
|
|
39
|
+
}), children);
|
|
36
40
|
});
|
|
37
41
|
function PopperWrapper(_ref) {
|
|
38
42
|
var isOpen = _ref.isOpen,
|
|
@@ -1,34 +1,55 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
2
|
import createFocusTrap from 'focus-trap';
|
|
3
3
|
import noop from '@atlaskit/ds-lib/noop';
|
|
4
|
+
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
4
5
|
export var useFocusManager = function useFocusManager(_ref) {
|
|
5
|
-
var
|
|
6
|
-
|
|
6
|
+
var initialFocusRef = _ref.initialFocusRef,
|
|
7
|
+
popupRef = _ref.popupRef;
|
|
7
8
|
useEffect(function () {
|
|
8
9
|
if (!popupRef) {
|
|
9
10
|
return noop;
|
|
10
11
|
}
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
var previouslyFocusedElement;
|
|
13
|
+
var focusTrap;
|
|
14
|
+
if (getBooleanFF('platform.design-system-team.remove-focus-trap-from-popup_3q7sk')) {
|
|
15
|
+
previouslyFocusedElement = document.activeElement;
|
|
16
|
+
} else {
|
|
17
|
+
var trapConfig = {
|
|
18
|
+
clickOutsideDeactivates: true,
|
|
19
|
+
escapeDeactivates: true,
|
|
20
|
+
initialFocus: initialFocusRef || popupRef,
|
|
21
|
+
fallbackFocus: popupRef,
|
|
22
|
+
returnFocusOnDeactivate: true
|
|
23
|
+
};
|
|
24
|
+
focusTrap = createFocusTrap(popupRef, trapConfig);
|
|
25
|
+
}
|
|
19
26
|
var frameId = null;
|
|
20
27
|
|
|
21
28
|
// wait for the popup to reposition itself before we focus
|
|
22
29
|
frameId = requestAnimationFrame(function () {
|
|
23
30
|
frameId = null;
|
|
24
|
-
|
|
31
|
+
if (getBooleanFF('platform.design-system-team.remove-focus-trap-from-popup_3q7sk')) {
|
|
32
|
+
if (initialFocusRef && initialFocusRef.focus) {
|
|
33
|
+
initialFocusRef.focus();
|
|
34
|
+
} else {
|
|
35
|
+
popupRef.focus();
|
|
36
|
+
}
|
|
37
|
+
} else {
|
|
38
|
+
focusTrap.activate();
|
|
39
|
+
}
|
|
25
40
|
});
|
|
26
41
|
return function () {
|
|
27
42
|
if (frameId != null) {
|
|
28
43
|
cancelAnimationFrame(frameId);
|
|
29
44
|
frameId = null;
|
|
30
45
|
}
|
|
31
|
-
|
|
46
|
+
if (getBooleanFF('platform.design-system-team.remove-focus-trap-from-popup_3q7sk')) {
|
|
47
|
+
if (previouslyFocusedElement && previouslyFocusedElement.focus) {
|
|
48
|
+
previouslyFocusedElement.focus();
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
focusTrap.deactivate();
|
|
52
|
+
}
|
|
32
53
|
};
|
|
33
54
|
}, [popupRef, initialFocusRef]);
|
|
34
55
|
};
|
package/dist/types/types.d.ts
CHANGED
|
@@ -168,8 +168,8 @@ export type CloseManagerHook = Pick<PopupProps, 'isOpen' | 'onClose'> & {
|
|
|
168
168
|
shouldUseCaptureOnOutsideClick?: boolean;
|
|
169
169
|
};
|
|
170
170
|
export type FocusManagerHook = {
|
|
171
|
-
popupRef: PopupRef;
|
|
172
171
|
initialFocusRef: HTMLElement | null;
|
|
172
|
+
popupRef: PopupRef;
|
|
173
173
|
};
|
|
174
174
|
export type RepositionOnUpdateProps = {
|
|
175
175
|
update: PopperChildrenProps['update'];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FocusManagerHook } from './types';
|
|
2
|
-
export declare const useFocusManager: ({
|
|
2
|
+
export declare const useFocusManager: ({ initialFocusRef, popupRef, }: FocusManagerHook) => void;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx } from '@emotion/react';
|
|
2
|
+
import { PopperWrapperProps } from './types';
|
|
3
|
+
declare function PopperWrapper({ isOpen, id, offset, testId, content, fallbackPlacements, onClose, boundary, rootBoundary, shouldFlip, placement, popupComponent: PopupContainer, autoFocus, triggerRef, shouldUseCaptureOnOutsideClick, shouldRenderToParent, }: PopperWrapperProps): jsx.JSX.Element;
|
|
4
|
+
export default PopperWrapper;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import React, { ComponentType, CSSProperties, Dispatch, ReactNode, Ref, SetStateAction } from 'react';
|
|
2
|
+
import { Placement, PopperChildrenProps } from '@atlaskit/popper';
|
|
3
|
+
export interface TriggerProps {
|
|
4
|
+
ref: Ref<any>;
|
|
5
|
+
'aria-controls'?: string;
|
|
6
|
+
'aria-expanded': boolean;
|
|
7
|
+
'aria-haspopup': boolean;
|
|
8
|
+
}
|
|
9
|
+
export type PopupRef = HTMLDivElement | null;
|
|
10
|
+
export type TriggerRef = HTMLElement | HTMLButtonElement | null;
|
|
11
|
+
export interface ContentProps {
|
|
12
|
+
/**
|
|
13
|
+
* Will reposition the popup if any of the content has changed.
|
|
14
|
+
* Useful for when positions change and the popup was not aware.
|
|
15
|
+
*/
|
|
16
|
+
update: PopperChildrenProps['update'];
|
|
17
|
+
/**
|
|
18
|
+
* Passed through from the parent popup.
|
|
19
|
+
*/
|
|
20
|
+
isOpen: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Passed through from the parent popup.
|
|
23
|
+
*/
|
|
24
|
+
onClose?: BaseProps['onClose'];
|
|
25
|
+
/**
|
|
26
|
+
* Escape hatch to set the initial focus for a specific element when the popup is opened.
|
|
27
|
+
*/
|
|
28
|
+
setInitialFocusRef: Dispatch<SetStateAction<HTMLElement | null>>;
|
|
29
|
+
}
|
|
30
|
+
export interface PopupComponentProps {
|
|
31
|
+
/**
|
|
32
|
+
* Children passed passed through by the parent popup.
|
|
33
|
+
*/
|
|
34
|
+
children: ReactNode;
|
|
35
|
+
/**
|
|
36
|
+
* Placement passed through by the parent popup.
|
|
37
|
+
*/
|
|
38
|
+
'data-placement': Placement;
|
|
39
|
+
/**
|
|
40
|
+
* Test id passed through by the parent popup.
|
|
41
|
+
*/
|
|
42
|
+
'data-testid'?: string;
|
|
43
|
+
/**
|
|
44
|
+
* Id passed through by the parent popup.
|
|
45
|
+
*/
|
|
46
|
+
id?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Ref that should be assigned to the root element.
|
|
49
|
+
*/
|
|
50
|
+
ref: Ref<HTMLDivElement>;
|
|
51
|
+
/**
|
|
52
|
+
* Style that should be assigned to the root element.
|
|
53
|
+
*/
|
|
54
|
+
style: CSSProperties;
|
|
55
|
+
/**
|
|
56
|
+
* Tab index passed through by the parent popup.
|
|
57
|
+
*/
|
|
58
|
+
tabIndex: number | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* The root element where the popup should be rendered.
|
|
61
|
+
* Defaults to `false`.
|
|
62
|
+
*/
|
|
63
|
+
shouldRenderToParent?: boolean;
|
|
64
|
+
}
|
|
65
|
+
interface BaseProps {
|
|
66
|
+
/**
|
|
67
|
+
* Used to either show or hide the popup.
|
|
68
|
+
* When set to `false` popup will not render anything to the DOM.
|
|
69
|
+
*/
|
|
70
|
+
isOpen: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Render props for content that is displayed inside the popup.
|
|
73
|
+
*/
|
|
74
|
+
content: (props: ContentProps) => React.ReactNode;
|
|
75
|
+
/**
|
|
76
|
+
* Id that is assigned to the popup container element.
|
|
77
|
+
*/
|
|
78
|
+
id?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Distance the popup should be offset from the reference in the format of [along, away] (units in px).
|
|
81
|
+
* Defaults to [0, 8] - which means the popup will be 8px away from the edge of the reference specified
|
|
82
|
+
* by the `placement` prop.
|
|
83
|
+
*/
|
|
84
|
+
offset?: [
|
|
85
|
+
number,
|
|
86
|
+
number
|
|
87
|
+
];
|
|
88
|
+
/**
|
|
89
|
+
* Placement of where the popup should be displayed relative to the trigger element.
|
|
90
|
+
* Defaults to `"auto"`.
|
|
91
|
+
*/
|
|
92
|
+
placement?: Placement;
|
|
93
|
+
/**
|
|
94
|
+
* Defines a list of placements to try.
|
|
95
|
+
* When no space is available on the preferred placement,
|
|
96
|
+
* the modifier will test the ones provided in the list, and use the first suitable one.
|
|
97
|
+
* If no fallback placements are suitable, it reverts back to the original placement.
|
|
98
|
+
*/
|
|
99
|
+
fallbackPlacements?: Placement[];
|
|
100
|
+
/**
|
|
101
|
+
* The boundary element that the popup will check for overflow.
|
|
102
|
+
* Defaults to `"clippingParents"` which are parent scroll containers,
|
|
103
|
+
* but can be set to any element.
|
|
104
|
+
*/
|
|
105
|
+
boundary?: 'clippingParents' | HTMLElement;
|
|
106
|
+
/**
|
|
107
|
+
* The root boundary that the popup will check for overflow.
|
|
108
|
+
* Defaults to `"viewport"` but can be set to `"document"`.
|
|
109
|
+
*/
|
|
110
|
+
rootBoundary?: 'viewport' | 'document';
|
|
111
|
+
/**
|
|
112
|
+
* Allows the Popup to be placed on the opposite side of its trigger if it does not fit in the viewport.
|
|
113
|
+
* Defaults to `true`.
|
|
114
|
+
*/
|
|
115
|
+
shouldFlip?: boolean;
|
|
116
|
+
/**
|
|
117
|
+
* A `testId` prop is provided for specified elements,
|
|
118
|
+
* which is a unique string that appears as a data attribute `data-testid` in the rendered code,
|
|
119
|
+
* serving as a hook for automated tests.
|
|
120
|
+
*/
|
|
121
|
+
testId?: string;
|
|
122
|
+
/**
|
|
123
|
+
* Handler that is called when the popup wants to close itself.
|
|
124
|
+
* Generally this will be either when clicking away from the popup or pressing the escape key.
|
|
125
|
+
* You'll want to use this to set open state accordingly and then pump it back into the `isOpen` prop.
|
|
126
|
+
*/
|
|
127
|
+
onClose?(event: Event | React.MouseEvent | React.KeyboardEvent): void;
|
|
128
|
+
/**
|
|
129
|
+
* The element that is shown when `isOpen` prop is `true`.
|
|
130
|
+
* The result of the `content` prop will be placed as children here.
|
|
131
|
+
* Defaults to an element with an elevation of `e200` with _no padding_.
|
|
132
|
+
*/
|
|
133
|
+
popupComponent?: ComponentType<PopupComponentProps>;
|
|
134
|
+
/**
|
|
135
|
+
* Controls whether the popup takes focus when opening.
|
|
136
|
+
* This changes the `popupComponent` component tabIndex to `null`.
|
|
137
|
+
* Defaults to `true`.
|
|
138
|
+
*/
|
|
139
|
+
autoFocus?: boolean;
|
|
140
|
+
/**
|
|
141
|
+
* Controls if the event which handles clicks outside the popup is be bound with
|
|
142
|
+
* `capture: true`.
|
|
143
|
+
*/
|
|
144
|
+
shouldUseCaptureOnOutsideClick?: boolean;
|
|
145
|
+
/**
|
|
146
|
+
* The root element where the popup should be rendered.
|
|
147
|
+
* Defaults to `false`.
|
|
148
|
+
*/
|
|
149
|
+
shouldRenderToParent?: boolean;
|
|
150
|
+
}
|
|
151
|
+
export interface PopupProps extends BaseProps {
|
|
152
|
+
/**
|
|
153
|
+
* Render props used to anchor the popup to your content.
|
|
154
|
+
* Make this an interactive element,
|
|
155
|
+
* such as an `@atlaskit/button` component.
|
|
156
|
+
*/
|
|
157
|
+
trigger: (props: TriggerProps) => React.ReactNode;
|
|
158
|
+
/**
|
|
159
|
+
* Z-index that the popup should be displayed in.
|
|
160
|
+
* This is passed to the portal component.
|
|
161
|
+
* Defaults to `layers.layer()` from `@atlaskit/theme`.
|
|
162
|
+
*/
|
|
163
|
+
zIndex?: number;
|
|
164
|
+
}
|
|
165
|
+
export interface PopperWrapperProps extends BaseProps {
|
|
166
|
+
triggerRef: TriggerRef;
|
|
167
|
+
}
|
|
168
|
+
export type CloseManagerHook = Pick<PopupProps, 'isOpen' | 'onClose'> & {
|
|
169
|
+
popupRef: PopupRef;
|
|
170
|
+
triggerRef: TriggerRef;
|
|
171
|
+
shouldUseCaptureOnOutsideClick?: boolean;
|
|
172
|
+
};
|
|
173
|
+
export type FocusManagerHook = {
|
|
174
|
+
initialFocusRef: HTMLElement | null;
|
|
175
|
+
popupRef: PopupRef;
|
|
176
|
+
};
|
|
177
|
+
export type RepositionOnUpdateProps = {
|
|
178
|
+
update: PopperChildrenProps['update'];
|
|
179
|
+
};
|
|
180
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/popup",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"description": "A popup displays brief content in an overlay.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -37,10 +37,11 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@atlaskit/ds-lib": "^2.2.0",
|
|
39
39
|
"@atlaskit/layering": "^0.2.0",
|
|
40
|
+
"@atlaskit/platform-feature-flags": "*",
|
|
40
41
|
"@atlaskit/popper": "^5.5.0",
|
|
41
42
|
"@atlaskit/portal": "^4.3.0",
|
|
42
43
|
"@atlaskit/theme": "^12.6.0",
|
|
43
|
-
"@atlaskit/tokens": "^1.
|
|
44
|
+
"@atlaskit/tokens": "^1.26.0",
|
|
44
45
|
"@babel/runtime": "^7.0.0",
|
|
45
46
|
"@emotion/react": "^11.7.1",
|
|
46
47
|
"bind-event-listener": "^2.1.1",
|
|
@@ -94,5 +95,10 @@
|
|
|
94
95
|
}
|
|
95
96
|
},
|
|
96
97
|
"homepage": "https://atlassian.design/components/popup/",
|
|
97
|
-
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
98
|
+
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1",
|
|
99
|
+
"platform-feature-flags": {
|
|
100
|
+
"platform.design-system-team.remove-focus-trap-from-popup_3q7sk": {
|
|
101
|
+
"type": "boolean"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
98
104
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
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
|
+
```
|