@atlaskit/popup 1.8.1 → 1.8.3
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 +2 -1
- package/dist/cjs/use-focus-manager.js +19 -10
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/popper-wrapper.js +2 -1
- package/dist/es2019/use-focus-manager.js +18 -9
- package/dist/es2019/version.json +1 -1
- package/dist/esm/popper-wrapper.js +2 -1
- package/dist/esm/use-focus-manager.js +19 -10
- package/dist/esm/version.json +1 -1
- package/dist/types/types.d.ts +1 -0
- package/dist/types/use-focus-manager.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/dist/types-ts4.5/use-focus-manager.d.ts +1 -1
- package/package.json +2 -9
- package/tmp/api-report-tmp.d.ts +0 -81
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/popup
|
|
2
2
|
|
|
3
|
+
## 1.8.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`4ae083a7e66`](https://bitbucket.org/atlassian/atlassian-frontend/commits/4ae083a7e66) - Use `@af/accessibility-testing` for default jest-axe config and jest-axe import in accessibility testing.
|
|
8
|
+
|
|
9
|
+
## 1.8.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`472a62ce219`](https://bitbucket.org/atlassian/atlassian-frontend/commits/472a62ce219) - [ux] Fixes `autoFocus` functionality on upgrade of focus-trap to v7.
|
|
14
|
+
|
|
3
15
|
## 1.8.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -66,7 +66,8 @@ function PopperWrapper(_ref) {
|
|
|
66
66
|
setInitialFocusRef = _useState4[1];
|
|
67
67
|
(0, _useFocusManager.useFocusManager)({
|
|
68
68
|
initialFocusRef: initialFocusRef,
|
|
69
|
-
popupRef: popupRef
|
|
69
|
+
popupRef: popupRef,
|
|
70
|
+
autoFocus: autoFocus
|
|
70
71
|
});
|
|
71
72
|
(0, _useCloseManager.useCloseManager)({
|
|
72
73
|
isOpen: isOpen,
|
|
@@ -12,23 +12,32 @@ var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
|
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
13
|
var useFocusManager = function useFocusManager(_ref) {
|
|
14
14
|
var popupRef = _ref.popupRef,
|
|
15
|
-
initialFocusRef = _ref.initialFocusRef
|
|
15
|
+
initialFocusRef = _ref.initialFocusRef,
|
|
16
|
+
autoFocus = _ref.autoFocus;
|
|
16
17
|
(0, _react.useEffect)(function () {
|
|
17
18
|
if (!popupRef) {
|
|
18
19
|
return _noop.default;
|
|
19
20
|
}
|
|
20
|
-
var trapConfig = {
|
|
21
|
-
clickOutsideDeactivates: true,
|
|
22
|
-
escapeDeactivates: true,
|
|
23
|
-
initialFocus: initialFocusRef || popupRef,
|
|
24
|
-
fallbackFocus: popupRef,
|
|
25
|
-
returnFocusOnDeactivate: true
|
|
26
|
-
};
|
|
27
21
|
var focusTrap;
|
|
28
22
|
if ((0, _platformFeatureFlags.getBooleanFF)('platform.design-system-team.focus-trap-upgrade_p2cei')) {
|
|
23
|
+
var trapConfig = {
|
|
24
|
+
clickOutsideDeactivates: true,
|
|
25
|
+
escapeDeactivates: true,
|
|
26
|
+
// @ts-ignore: The multiple focus-trap packages is causing a type error that does not affect functionality
|
|
27
|
+
initialFocus: autoFocus ? initialFocusRef || popupRef : false,
|
|
28
|
+
fallbackFocus: popupRef,
|
|
29
|
+
returnFocusOnDeactivate: true
|
|
30
|
+
};
|
|
29
31
|
focusTrap = (0, _focusTrap.createFocusTrap)(popupRef, trapConfig);
|
|
30
32
|
} else {
|
|
31
|
-
|
|
33
|
+
var _trapConfig = {
|
|
34
|
+
clickOutsideDeactivates: true,
|
|
35
|
+
escapeDeactivates: true,
|
|
36
|
+
initialFocus: initialFocusRef || popupRef,
|
|
37
|
+
fallbackFocus: popupRef,
|
|
38
|
+
returnFocusOnDeactivate: true
|
|
39
|
+
};
|
|
40
|
+
focusTrap = (0, _focusTrapV.default)(popupRef, _trapConfig);
|
|
32
41
|
}
|
|
33
42
|
|
|
34
43
|
// wait for the popup to reposition itself before we focus
|
|
@@ -43,6 +52,6 @@ var useFocusManager = function useFocusManager(_ref) {
|
|
|
43
52
|
}
|
|
44
53
|
focusTrap.deactivate();
|
|
45
54
|
};
|
|
46
|
-
}, [popupRef, initialFocusRef]);
|
|
55
|
+
}, [popupRef, initialFocusRef, autoFocus]);
|
|
47
56
|
};
|
|
48
57
|
exports.useFocusManager = useFocusManager;
|
package/dist/cjs/version.json
CHANGED
|
@@ -5,23 +5,32 @@ import noop from '@atlaskit/ds-lib/noop';
|
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
export const useFocusManager = ({
|
|
7
7
|
popupRef,
|
|
8
|
-
initialFocusRef
|
|
8
|
+
initialFocusRef,
|
|
9
|
+
autoFocus
|
|
9
10
|
}) => {
|
|
10
11
|
useEffect(() => {
|
|
11
12
|
if (!popupRef) {
|
|
12
13
|
return noop;
|
|
13
14
|
}
|
|
14
|
-
const trapConfig = {
|
|
15
|
-
clickOutsideDeactivates: true,
|
|
16
|
-
escapeDeactivates: true,
|
|
17
|
-
initialFocus: initialFocusRef || popupRef,
|
|
18
|
-
fallbackFocus: popupRef,
|
|
19
|
-
returnFocusOnDeactivate: true
|
|
20
|
-
};
|
|
21
15
|
let focusTrap;
|
|
22
16
|
if (getBooleanFF('platform.design-system-team.focus-trap-upgrade_p2cei')) {
|
|
17
|
+
const trapConfig = {
|
|
18
|
+
clickOutsideDeactivates: true,
|
|
19
|
+
escapeDeactivates: true,
|
|
20
|
+
// @ts-ignore: The multiple focus-trap packages is causing a type error that does not affect functionality
|
|
21
|
+
initialFocus: autoFocus ? initialFocusRef || popupRef : false,
|
|
22
|
+
fallbackFocus: popupRef,
|
|
23
|
+
returnFocusOnDeactivate: true
|
|
24
|
+
};
|
|
23
25
|
focusTrap = createFocusTrap(popupRef, trapConfig);
|
|
24
26
|
} else {
|
|
27
|
+
const trapConfig = {
|
|
28
|
+
clickOutsideDeactivates: true,
|
|
29
|
+
escapeDeactivates: true,
|
|
30
|
+
initialFocus: initialFocusRef || popupRef,
|
|
31
|
+
fallbackFocus: popupRef,
|
|
32
|
+
returnFocusOnDeactivate: true
|
|
33
|
+
};
|
|
25
34
|
focusTrap = createFocusTrapV2(popupRef, trapConfig);
|
|
26
35
|
}
|
|
27
36
|
|
|
@@ -37,5 +46,5 @@ export const useFocusManager = ({
|
|
|
37
46
|
}
|
|
38
47
|
focusTrap.deactivate();
|
|
39
48
|
};
|
|
40
|
-
}, [popupRef, initialFocusRef]);
|
|
49
|
+
}, [popupRef, initialFocusRef, autoFocus]);
|
|
41
50
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -5,23 +5,32 @@ import noop from '@atlaskit/ds-lib/noop';
|
|
|
5
5
|
import { getBooleanFF } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
export var useFocusManager = function useFocusManager(_ref) {
|
|
7
7
|
var popupRef = _ref.popupRef,
|
|
8
|
-
initialFocusRef = _ref.initialFocusRef
|
|
8
|
+
initialFocusRef = _ref.initialFocusRef,
|
|
9
|
+
autoFocus = _ref.autoFocus;
|
|
9
10
|
useEffect(function () {
|
|
10
11
|
if (!popupRef) {
|
|
11
12
|
return noop;
|
|
12
13
|
}
|
|
13
|
-
var trapConfig = {
|
|
14
|
-
clickOutsideDeactivates: true,
|
|
15
|
-
escapeDeactivates: true,
|
|
16
|
-
initialFocus: initialFocusRef || popupRef,
|
|
17
|
-
fallbackFocus: popupRef,
|
|
18
|
-
returnFocusOnDeactivate: true
|
|
19
|
-
};
|
|
20
14
|
var focusTrap;
|
|
21
15
|
if (getBooleanFF('platform.design-system-team.focus-trap-upgrade_p2cei')) {
|
|
16
|
+
var trapConfig = {
|
|
17
|
+
clickOutsideDeactivates: true,
|
|
18
|
+
escapeDeactivates: true,
|
|
19
|
+
// @ts-ignore: The multiple focus-trap packages is causing a type error that does not affect functionality
|
|
20
|
+
initialFocus: autoFocus ? initialFocusRef || popupRef : false,
|
|
21
|
+
fallbackFocus: popupRef,
|
|
22
|
+
returnFocusOnDeactivate: true
|
|
23
|
+
};
|
|
22
24
|
focusTrap = createFocusTrap(popupRef, trapConfig);
|
|
23
25
|
} else {
|
|
24
|
-
|
|
26
|
+
var _trapConfig = {
|
|
27
|
+
clickOutsideDeactivates: true,
|
|
28
|
+
escapeDeactivates: true,
|
|
29
|
+
initialFocus: initialFocusRef || popupRef,
|
|
30
|
+
fallbackFocus: popupRef,
|
|
31
|
+
returnFocusOnDeactivate: true
|
|
32
|
+
};
|
|
33
|
+
focusTrap = createFocusTrapV2(popupRef, _trapConfig);
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
// wait for the popup to reposition itself before we focus
|
|
@@ -36,5 +45,5 @@ export var useFocusManager = function useFocusManager(_ref) {
|
|
|
36
45
|
}
|
|
37
46
|
focusTrap.deactivate();
|
|
38
47
|
};
|
|
39
|
-
}, [popupRef, initialFocusRef]);
|
|
48
|
+
}, [popupRef, initialFocusRef, autoFocus]);
|
|
40
49
|
};
|
package/dist/esm/version.json
CHANGED
package/dist/types/types.d.ts
CHANGED
|
@@ -164,6 +164,7 @@ export type CloseManagerHook = Pick<PopupProps, 'isOpen' | 'onClose'> & {
|
|
|
164
164
|
export type FocusManagerHook = {
|
|
165
165
|
popupRef: PopupRef;
|
|
166
166
|
initialFocusRef: HTMLElement | null;
|
|
167
|
+
autoFocus: boolean;
|
|
167
168
|
};
|
|
168
169
|
export type RepositionOnUpdateProps = {
|
|
169
170
|
update: PopperChildrenProps['update'];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FocusManagerHook } from './types';
|
|
2
|
-
export declare const useFocusManager: ({ popupRef, initialFocusRef, }: FocusManagerHook) => void;
|
|
2
|
+
export declare const useFocusManager: ({ popupRef, initialFocusRef, autoFocus, }: FocusManagerHook) => void;
|
|
@@ -167,6 +167,7 @@ export type CloseManagerHook = Pick<PopupProps, 'isOpen' | 'onClose'> & {
|
|
|
167
167
|
export type FocusManagerHook = {
|
|
168
168
|
popupRef: PopupRef;
|
|
169
169
|
initialFocusRef: HTMLElement | null;
|
|
170
|
+
autoFocus: boolean;
|
|
170
171
|
};
|
|
171
172
|
export type RepositionOnUpdateProps = {
|
|
172
173
|
update: PopperChildrenProps['update'];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { FocusManagerHook } from './types';
|
|
2
|
-
export declare const useFocusManager: ({ popupRef, initialFocusRef, }: FocusManagerHook) => void;
|
|
2
|
+
export declare const useFocusManager: ({ popupRef, initialFocusRef, autoFocus, }: FocusManagerHook) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/popup",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "A popup displays brief content in an overlay.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -52,16 +52,10 @@
|
|
|
52
52
|
"react-dom": "^16.8.0"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
|
+
"@af/accessibility-testing": "*",
|
|
55
56
|
"@atlaskit/button": "^16.8.0",
|
|
56
|
-
"@atlaskit/docs": "*",
|
|
57
57
|
"@atlaskit/icon": "^21.12.0",
|
|
58
|
-
"@atlaskit/menu": "^1.9.0",
|
|
59
|
-
"@atlaskit/radio": "^5.6.0",
|
|
60
|
-
"@atlaskit/section-message": "^6.4.0",
|
|
61
|
-
"@atlaskit/select": "^16.5.0",
|
|
62
58
|
"@atlaskit/ssr": "*",
|
|
63
|
-
"@atlaskit/textfield": "^5.5.0",
|
|
64
|
-
"@atlaskit/toggle": "^12.6.0",
|
|
65
59
|
"@atlaskit/visual-regression": "*",
|
|
66
60
|
"@atlaskit/webdriver-runner": "*",
|
|
67
61
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
@@ -69,7 +63,6 @@
|
|
|
69
63
|
"@testing-library/dom": "^8.17.1",
|
|
70
64
|
"@testing-library/react": "^12.1.5",
|
|
71
65
|
"ast-types": "^0.13.3",
|
|
72
|
-
"jest-axe": "^4.0.0",
|
|
73
66
|
"jscodeshift": "^0.13.0",
|
|
74
67
|
"raf-stub": "^2.0.1",
|
|
75
68
|
"react-dom": "^16.8.0",
|
package/tmp/api-report-tmp.d.ts
DELETED
|
@@ -1,81 +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
|
-
shouldUseCaptureOnOutsideClick?: boolean;
|
|
33
|
-
testId?: string;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// @public (undocumented)
|
|
37
|
-
export interface ContentProps {
|
|
38
|
-
isOpen: boolean;
|
|
39
|
-
onClose?: BaseProps['onClose'];
|
|
40
|
-
setInitialFocusRef: Dispatch<SetStateAction<HTMLElement | null>>;
|
|
41
|
-
update: PopperChildrenProps['update'];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// @public (undocumented)
|
|
45
|
-
const Popup: FC<PopupProps>;
|
|
46
|
-
export { Popup }
|
|
47
|
-
export default Popup;
|
|
48
|
-
|
|
49
|
-
// @public (undocumented)
|
|
50
|
-
export interface PopupComponentProps {
|
|
51
|
-
'data-placement': Placement;
|
|
52
|
-
'data-testid'?: string;
|
|
53
|
-
children: ReactNode;
|
|
54
|
-
id?: string;
|
|
55
|
-
ref: Ref<HTMLDivElement>;
|
|
56
|
-
style: CSSProperties;
|
|
57
|
-
tabIndex: number | undefined;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// @public (undocumented)
|
|
61
|
-
export interface PopupProps extends BaseProps {
|
|
62
|
-
shouldRenderToParent?: boolean;
|
|
63
|
-
trigger: (props: TriggerProps) => React_2.ReactNode;
|
|
64
|
-
zIndex?: number;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// @public (undocumented)
|
|
68
|
-
export interface TriggerProps {
|
|
69
|
-
// (undocumented)
|
|
70
|
-
'aria-controls'?: string;
|
|
71
|
-
// (undocumented)
|
|
72
|
-
'aria-expanded': boolean;
|
|
73
|
-
// (undocumented)
|
|
74
|
-
'aria-haspopup': boolean;
|
|
75
|
-
// (undocumented)
|
|
76
|
-
ref: Ref<any>;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// (No @packageDocumentation comment for this package)
|
|
80
|
-
|
|
81
|
-
```
|