@skatteetaten/ds-overlays 1.2.0 → 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.
- package/Modal/index.esm.js +14 -2
- package/Popover/index.esm.js +2 -2
- package/PopoverContent/index.esm.js +1 -1
- package/{PopoverContent-QCKf0esL.js → PopoverContent.esm.js} +1 -2
- package/index.esm.js +1 -1
- package/package.json +8 -6
- package/src/Modal/Modal.d.ts +0 -1
- package/src/PopoverContent/PopoverContent.d.ts +0 -1
- package/src/PopoverContext/PopoverContext.d.ts +0 -1
- package/src/PopoverTrigger/PopoverTrigger.d.ts +0 -1
package/Modal/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import { forwardRef, useId, useRef, useImperativeHandle } from 'react';
|
|
2
|
+
import { forwardRef, useId, useRef, useImperativeHandle, useEffect } from 'react';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
import { IconButton } from '@skatteetaten/ds-buttons';
|
|
5
5
|
import { dsI18n, SkatteetatenLogo, Separator, getCommonClassNameDefault } from '@skatteetaten/ds-core-utils';
|
|
@@ -42,6 +42,17 @@ shadowRootNode, onClose, children }, ref)=>{
|
|
|
42
42
|
});
|
|
43
43
|
const modalRef = useRef(null);
|
|
44
44
|
useImperativeHandle(ref, ()=>modalRef?.current);
|
|
45
|
+
useEffect(()=>{
|
|
46
|
+
/**
|
|
47
|
+
* Hvis konsument endrer children i en åpen modal, vil fokus settes til body og dismissOnEsc vil slutte å fungere.
|
|
48
|
+
* Setter derfor fokus tilbake til modalen.
|
|
49
|
+
*/ if (!dismissOnEsc && modalRef.current?.open && document.activeElement?.nodeName === 'BODY') {
|
|
50
|
+
modalRef.current.focus();
|
|
51
|
+
}
|
|
52
|
+
}, [
|
|
53
|
+
children,
|
|
54
|
+
dismissOnEsc
|
|
55
|
+
]);
|
|
45
56
|
const isClickOutside = (event)=>{
|
|
46
57
|
if (!(event.target instanceof HTMLElement)) {
|
|
47
58
|
return true;
|
|
@@ -78,7 +89,8 @@ shadowRootNode, onClose, children }, ref)=>{
|
|
|
78
89
|
"data-testid": dataTestId,
|
|
79
90
|
"aria-labelledby": headingId,
|
|
80
91
|
autoFocus: true,
|
|
81
|
-
/*
|
|
92
|
+
/* Må bruke onCancel i kombinasjon med onKeyDown siden to trykk på esc lukker modalen i chrome (https://issues.chromium.org/issues/41491338) */ onCancel: (e)=>!dismissOnEsc && e.preventDefault(),
|
|
93
|
+
onKeyDown: (e)=>{
|
|
82
94
|
if (e.key === 'Escape') {
|
|
83
95
|
if (dismissOnEsc) {
|
|
84
96
|
onClose?.();
|
package/Popover/index.esm.js
CHANGED
|
@@ -2,8 +2,8 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { useRef, useState, useEffect, useMemo } from 'react';
|
|
3
3
|
import { useFloating, autoUpdate, offset, flip, shift, arrow, useDismiss, useInteractions } from '@floating-ui/react';
|
|
4
4
|
import { useMediaQuery } from '@skatteetaten/ds-core-utils';
|
|
5
|
-
import { P as PopoverContent, a as getPopoverPositionDefault } from '../PopoverContent
|
|
6
|
-
export { g as getPopoverColorDefault, b as getPopoverRestoreFocusDefault } from '../PopoverContent
|
|
5
|
+
import { P as PopoverContent, a as getPopoverPositionDefault } from '../PopoverContent.esm.js';
|
|
6
|
+
export { g as getPopoverColorDefault, b as getPopoverRestoreFocusDefault } from '../PopoverContent.esm.js';
|
|
7
7
|
import { PopoverContext } from '../PopoverContext/index.esm.js';
|
|
8
8
|
import { PopoverTrigger } from '../PopoverTrigger/index.esm.js';
|
|
9
9
|
import 'react-i18next';
|
|
@@ -5,5 +5,5 @@ import '@floating-ui/react';
|
|
|
5
5
|
import '@skatteetaten/ds-buttons';
|
|
6
6
|
import '@skatteetaten/ds-core-utils';
|
|
7
7
|
import '@skatteetaten/ds-icons';
|
|
8
|
-
export { P as PopoverContent } from '../PopoverContent
|
|
8
|
+
export { P as PopoverContent } from '../PopoverContent.esm.js';
|
|
9
9
|
import '../PopoverContext/index.esm.js';
|
|
@@ -29,7 +29,7 @@ var styles = {
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
const PopoverContent = /*#__PURE__*/ forwardRef(({ id, className = getCommonClassNameDefault(), lang, 'data-testid': dataTestId, children }, ref)=>{
|
|
32
|
-
const { floatingData, interactions, arrowRef, isOpen, setIsOpen, color = getPopoverColorDefault(),
|
|
32
|
+
const { floatingData, interactions, arrowRef, isOpen, setIsOpen, color = getPopoverColorDefault(), shouldRestoreFocus = getPopoverRestoreFocusDefault(), onClose } = useContext(PopoverContext);
|
|
33
33
|
const { refs, floatingStyles, placement, middlewareData } = floatingData;
|
|
34
34
|
const { getFloatingProps } = interactions;
|
|
35
35
|
const { t } = useTranslation('Shared', {
|
|
@@ -69,7 +69,6 @@ const PopoverContent = /*#__PURE__*/ forwardRef(({ id, className = getCommonClas
|
|
|
69
69
|
}),
|
|
70
70
|
/*#__PURE__*/ jsx(IconButton, {
|
|
71
71
|
className: styles.popoverContentCloseButton,
|
|
72
|
-
size: isMobile ? 'small' : 'large',
|
|
73
72
|
svgPath: CancelSVGpath,
|
|
74
73
|
title: t('shared.Close'),
|
|
75
74
|
onClick: ()=>{
|
package/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Modal, getModalDismissOnEscDefault, getModalDismissOnOutsideClickDefault, getModalPaddingDefault, getModalVariantDefault } from './Modal/index.esm.js';
|
|
2
2
|
export { Popover } from './Popover/index.esm.js';
|
|
3
3
|
import { colorNamesArr } from '@skatteetaten/ds-core-utils';
|
|
4
|
-
export { g as getPopoverColorDefault, a as getPopoverPositionDefault, b as getPopoverRestoreFocusDefault } from './PopoverContent
|
|
4
|
+
export { g as getPopoverColorDefault, a as getPopoverPositionDefault, b as getPopoverRestoreFocusDefault } from './PopoverContent.esm.js';
|
|
5
5
|
import 'react/jsx-runtime';
|
|
6
6
|
import 'react';
|
|
7
7
|
import 'react-i18next';
|
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skatteetaten/ds-overlays",
|
|
3
3
|
"groupId": "no.skatteetaten.aurora",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"main": "./index.esm.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"module": "./index.esm.js",
|
|
8
|
+
"types": "./index.esm.d.ts",
|
|
8
9
|
"repository": {
|
|
9
10
|
"type": "git",
|
|
10
11
|
"url": "git+https://github.com/Skatteetaten/designsystemet.git"
|
|
11
12
|
},
|
|
13
|
+
"license": "Apache-2.0",
|
|
12
14
|
"homepage": "https://www.skatteetaten.no/stilogtone/designsystemet/",
|
|
13
15
|
"peerDependencies": {
|
|
14
16
|
"i18next": "^23",
|
|
15
17
|
"react": "^18",
|
|
16
18
|
"react-i18next": "^14",
|
|
17
|
-
"@skatteetaten/ds-core-utils": "1.
|
|
18
|
-
"@skatteetaten/ds-buttons": "1.
|
|
19
|
-
"@skatteetaten/ds-icons": "1.
|
|
20
|
-
"@skatteetaten/ds-typography": "1.
|
|
21
|
-
"@skatteetaten/ds-progress": "1.
|
|
19
|
+
"@skatteetaten/ds-core-utils": "1.4.0",
|
|
20
|
+
"@skatteetaten/ds-buttons": "1.4.0",
|
|
21
|
+
"@skatteetaten/ds-icons": "1.4.0",
|
|
22
|
+
"@skatteetaten/ds-typography": "1.4.0",
|
|
23
|
+
"@skatteetaten/ds-progress": "1.4.0",
|
|
22
24
|
"@floating-ui/react": "0.26.17"
|
|
23
25
|
},
|
|
24
26
|
"dependencies": {},
|
package/src/Modal/Modal.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { getModalDismissOnEscDefault, getModalDismissOnOutsideClickDefault, getModalPaddingDefault, getModalVariantDefault } from './defaults';
|
|
3
2
|
import { ModalProps } from './Modal.types';
|
|
4
3
|
export declare const Modal: import("react").ForwardRefExoticComponent<ModalProps & import("react").RefAttributes<HTMLDialogElement>>;
|