@strapi/design-system 1.14.0-typescript.2 → 1.15.0-typescript.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.
|
@@ -8,5 +8,6 @@ export interface FocusTrapProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
8
8
|
* A boolean value to define whether the focus should be restored or not.
|
|
9
9
|
*/
|
|
10
10
|
restoreFocus?: boolean;
|
|
11
|
+
skipAutoFocus?: boolean;
|
|
11
12
|
}
|
|
12
|
-
export declare const FocusTrap: ({ onEscape, restoreFocus, ...props }: FocusTrapProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const FocusTrap: ({ onEscape, restoreFocus, skipAutoFocus, ...props }: FocusTrapProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,7 +7,7 @@ const React = require('react');
|
|
|
7
7
|
const getFocusableNodes = require('../helpers/getFocusableNodes.js');
|
|
8
8
|
const keyboardKeys = require('../helpers/keyboardKeys.js');
|
|
9
9
|
|
|
10
|
-
const FocusTrap = ({ onEscape, restoreFocus = true, ...props }) => {
|
|
10
|
+
const FocusTrap = ({ onEscape, restoreFocus = true, skipAutoFocus = false, ...props }) => {
|
|
11
11
|
const trappedRef = React.useRef(null);
|
|
12
12
|
/**
|
|
13
13
|
* Restore the focus to the previously focused element (often, it's the CTA that opened the trap)
|
|
@@ -27,7 +27,7 @@ const FocusTrap = ({ onEscape, restoreFocus = true, ...props }) => {
|
|
|
27
27
|
* Sends the focus to the first element of the focus trap tree
|
|
28
28
|
*/
|
|
29
29
|
React.useEffect(() => {
|
|
30
|
-
if (!trappedRef.current)
|
|
30
|
+
if (!trappedRef.current || skipAutoFocus)
|
|
31
31
|
return;
|
|
32
32
|
const focusableChildren = getFocusableNodes.getFocusableNodes(trappedRef.current);
|
|
33
33
|
if (focusableChildren.length > 0) {
|
|
@@ -37,7 +37,7 @@ const FocusTrap = ({ onEscape, restoreFocus = true, ...props }) => {
|
|
|
37
37
|
else {
|
|
38
38
|
console.warn('[FocusTrap]: it seems there are no focusable elements in the focus trap tree. Make sure there s at least one.');
|
|
39
39
|
}
|
|
40
|
-
}, []);
|
|
40
|
+
}, [skipAutoFocus]);
|
|
41
41
|
const handleKeyDown = (e) => {
|
|
42
42
|
if (e.key === keyboardKeys.KeyboardKeys.ESCAPE && onEscape) {
|
|
43
43
|
onEscape();
|
|
@@ -3,7 +3,7 @@ import { useRef, useEffect } from 'react';
|
|
|
3
3
|
import { getFocusableNodes } from '../helpers/getFocusableNodes.mjs';
|
|
4
4
|
import { KeyboardKeys } from '../helpers/keyboardKeys.mjs';
|
|
5
5
|
|
|
6
|
-
const FocusTrap = ({ onEscape, restoreFocus = true, ...props }) => {
|
|
6
|
+
const FocusTrap = ({ onEscape, restoreFocus = true, skipAutoFocus = false, ...props }) => {
|
|
7
7
|
const trappedRef = useRef(null);
|
|
8
8
|
/**
|
|
9
9
|
* Restore the focus to the previously focused element (often, it's the CTA that opened the trap)
|
|
@@ -23,7 +23,7 @@ const FocusTrap = ({ onEscape, restoreFocus = true, ...props }) => {
|
|
|
23
23
|
* Sends the focus to the first element of the focus trap tree
|
|
24
24
|
*/
|
|
25
25
|
useEffect(() => {
|
|
26
|
-
if (!trappedRef.current)
|
|
26
|
+
if (!trappedRef.current || skipAutoFocus)
|
|
27
27
|
return;
|
|
28
28
|
const focusableChildren = getFocusableNodes(trappedRef.current);
|
|
29
29
|
if (focusableChildren.length > 0) {
|
|
@@ -33,7 +33,7 @@ const FocusTrap = ({ onEscape, restoreFocus = true, ...props }) => {
|
|
|
33
33
|
else {
|
|
34
34
|
console.warn('[FocusTrap]: it seems there are no focusable elements in the focus trap tree. Make sure there s at least one.');
|
|
35
35
|
}
|
|
36
|
-
}, []);
|
|
36
|
+
}, [skipAutoFocus]);
|
|
37
37
|
const handleKeyDown = (e) => {
|
|
38
38
|
if (e.key === KeyboardKeys.ESCAPE && onEscape) {
|
|
39
39
|
onEscape();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/design-system",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0-typescript.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@codemirror/lang-json": "^6.0.1",
|
|
30
30
|
"@floating-ui/react-dom": "^2.0.4",
|
|
31
|
-
"@internationalized/date": "^3.5.
|
|
32
|
-
"@internationalized/number": "^3.
|
|
31
|
+
"@internationalized/date": "^3.5.1",
|
|
32
|
+
"@internationalized/number": "^3.5.0",
|
|
33
33
|
"@radix-ui/react-dismissable-layer": "^1.0.5",
|
|
34
34
|
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
|
35
35
|
"@radix-ui/react-focus-scope": "1.0.4",
|
|
36
|
-
"@strapi/ui-primitives": "^1.
|
|
36
|
+
"@strapi/ui-primitives": "^1.15.0-typescript.0",
|
|
37
37
|
"@uiw/react-codemirror": "^4.21.21",
|
|
38
38
|
"aria-hidden": "^1.2.3",
|
|
39
39
|
"compute-scroll-into-view": "^3.1.0",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"react-remove-scroll": "^2.5.7"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@playwright/test": "1.40.
|
|
45
|
-
"@strapi/icons": "^1.
|
|
44
|
+
"@playwright/test": "1.40.1",
|
|
45
|
+
"@strapi/icons": "^1.15.0-typescript.0",
|
|
46
46
|
"@types/react-router-dom": "^5.3.3",
|
|
47
47
|
"@types/styled-components": "^5.1.26",
|
|
48
48
|
"axe-playwright": "^1.2.3",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"styled-components": "^5.3.11"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"@strapi/icons": "1.
|
|
54
|
+
"@strapi/icons": "1.15.0-typescript.0",
|
|
55
55
|
"react": "^17.0.0 || ^18.0.0",
|
|
56
56
|
"react-dom": "^17.0.0 || ^18.0.0",
|
|
57
57
|
"react-router-dom": "^5.2.0",
|