@sb1/ffe-modals-react 100.12.4 → 101.0.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/es/CloseButton.js +3 -26
- package/es/Modal.js +22 -46
- package/es/ModalBlock.js +2 -25
- package/es/texts.js +4 -4
- package/lib/CloseButton.js +8 -31
- package/lib/Modal.js +26 -50
- package/lib/ModalBlock.js +4 -27
- package/lib/texts.js +4 -4
- package/package.json +6 -6
package/es/CloseButton.js
CHANGED
|
@@ -1,33 +1,10 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import React from 'react';
|
|
24
2
|
import { Icon } from '@sb1/ffe-icons-react';
|
|
25
3
|
import { txt } from './texts';
|
|
26
4
|
import { SecondaryButton } from '@sb1/ffe-buttons-react';
|
|
27
5
|
import classNames from 'classnames';
|
|
28
|
-
|
|
29
|
-
export
|
|
30
|
-
|
|
31
|
-
return (React.createElement(SecondaryButton, __assign({ iconOnly: true, className: classNames('ffe-modal__close'), "aria-label": txt[locale].close }, rest),
|
|
6
|
+
const closeIcon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjQiPjxwYXRoIGQ9Ik00ODAtNDM3Ljg0NyAyNzcuMDc2LTIzNC45MjRxLTguMzA3IDguMzA4LTIwLjg4NCA4LjUtMTIuNTc2LjE5My0yMS4yNjgtOC41LTguNjkzLTguNjkyLTguNjkzLTIxLjA3NnQ4LjY5My0yMS4wNzZMNDM3Ljg0Ny00ODAgMjM0LjkyNC02ODIuOTI0cS04LjMwOC04LjMwNy04LjUtMjAuODg0LS4xOTMtMTIuNTc2IDguNS0yMS4yNjggOC42OTItOC42OTMgMjEuMDc2LTguNjkzdDIxLjA3NiA4LjY5M0w0ODAtNTIyLjE1M2wyMDIuOTI0LTIwMi45MjNxOC4zMDctOC4zMDggMjAuODg0LTguNSAxMi41NzYtLjE5MyAyMS4yNjggOC41IDguNjkzIDguNjkyIDguNjkzIDIxLjA3NnQtOC42OTMgMjEuMDc2TDUyMi4xNTMtNDgwbDIwMi45MjMgMjAyLjkyNHE4LjMwOCA4LjMwNyA4LjUgMjAuODg0LjE5MyAxMi41NzYtOC41IDIxLjI2OC04LjY5MiA4LjY5My0yMS4wNzYgOC42OTN0LTIxLjA3Ni04LjY5M0w0ODAtNDM3Ljg0N1oiLz48L3N2Zz4=';
|
|
7
|
+
export const CloseButton = ({ locale, ...rest }) => {
|
|
8
|
+
return (React.createElement(SecondaryButton, { iconOnly: true, className: classNames('ffe-modal__close'), "aria-label": txt[locale].close, ...rest },
|
|
32
9
|
React.createElement(Icon, { fileUrl: closeIcon, size: "md" })));
|
|
33
10
|
};
|
package/es/Modal.js
CHANGED
|
@@ -1,45 +1,22 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import React, { useEffect, useImperativeHandle, useState, useRef } from 'react';
|
|
24
2
|
import { createPortal } from 'react-dom';
|
|
25
3
|
import classnames from 'classnames';
|
|
26
4
|
import { CloseButton } from './CloseButton';
|
|
27
|
-
export
|
|
28
|
-
var children = _a.children, onClick = _a.onClick, ariaLabelledby = _a.ariaLabelledby, className = _a.className, _b = _a.locale, locale = _b === void 0 ? 'nb' : _b, onClose = _a.onClose, portalContainer = _a.portalContainer, rest = __rest(_a, ["children", "onClick", "ariaLabelledby", "className", "locale", "onClose", "portalContainer"]);
|
|
5
|
+
export const Modal = React.forwardRef(({ children, onClick, ariaLabelledby, className, locale = 'nb', onClose, portalContainer, ...rest }, ref) => {
|
|
29
6
|
// SSR does not have access to document/window etc.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
useImperativeHandle(ref,
|
|
35
|
-
open:
|
|
7
|
+
const [isClient, setIsClient] = useState(false);
|
|
8
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
9
|
+
const dialogRef = useRef(null);
|
|
10
|
+
const htmlOverflowY = useRef(isClient ? document.documentElement.style.overflowY : '');
|
|
11
|
+
useImperativeHandle(ref, () => ({
|
|
12
|
+
open: () => {
|
|
36
13
|
// Prevent opening an already open modal
|
|
37
14
|
if (!isOpen && dialogRef.current) {
|
|
38
15
|
setIsOpen(true);
|
|
39
16
|
dialogRef.current.showModal();
|
|
40
17
|
}
|
|
41
18
|
},
|
|
42
|
-
close:
|
|
19
|
+
close: () => {
|
|
43
20
|
// Prevent closing an already closed modal
|
|
44
21
|
if (isOpen && dialogRef.current) {
|
|
45
22
|
dialogRef.current.close();
|
|
@@ -50,17 +27,17 @@ export var Modal = React.forwardRef(function (_a, ref) {
|
|
|
50
27
|
return isOpen;
|
|
51
28
|
},
|
|
52
29
|
// Expose dialogRef directly
|
|
53
|
-
dialogRef
|
|
54
|
-
})
|
|
55
|
-
useEffect(
|
|
30
|
+
dialogRef,
|
|
31
|
+
}));
|
|
32
|
+
useEffect(() => {
|
|
56
33
|
setIsClient(true);
|
|
57
34
|
}, []);
|
|
58
|
-
useEffect(
|
|
35
|
+
useEffect(() => {
|
|
59
36
|
var _a;
|
|
60
|
-
|
|
37
|
+
const inShadow = isClient &&
|
|
61
38
|
((_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.getRootNode()) instanceof ShadowRoot;
|
|
62
39
|
if (inShadow) {
|
|
63
|
-
|
|
40
|
+
const html = document.documentElement;
|
|
64
41
|
if (isOpen) {
|
|
65
42
|
htmlOverflowY.current = html.style.overflowY;
|
|
66
43
|
html.style.overflowY = 'hidden';
|
|
@@ -70,17 +47,16 @@ export var Modal = React.forwardRef(function (_a, ref) {
|
|
|
70
47
|
}
|
|
71
48
|
}
|
|
72
49
|
}, [isClient, isOpen]);
|
|
73
|
-
useEffect(
|
|
50
|
+
useEffect(() => {
|
|
74
51
|
if (isOpen && dialogRef.current) {
|
|
75
52
|
dialogRef.current.focus();
|
|
76
53
|
}
|
|
77
54
|
}, [isOpen]);
|
|
78
|
-
useEffect(
|
|
55
|
+
useEffect(() => {
|
|
79
56
|
if (isClient &&
|
|
80
57
|
dialogRef.current &&
|
|
81
58
|
typeof dialogRef.current.showModal !== 'function') {
|
|
82
|
-
import('dialog-polyfill').then(
|
|
83
|
-
var dialogPolyfill = _a.default;
|
|
59
|
+
import('dialog-polyfill').then(({ default: dialogPolyfill }) => {
|
|
84
60
|
if (dialogRef.current) {
|
|
85
61
|
dialogPolyfill.registerDialog(dialogRef.current);
|
|
86
62
|
}
|
|
@@ -90,18 +66,18 @@ export var Modal = React.forwardRef(function (_a, ref) {
|
|
|
90
66
|
return isClient
|
|
91
67
|
? createPortal(
|
|
92
68
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
93
|
-
React.createElement("dialog",
|
|
94
|
-
|
|
69
|
+
React.createElement("dialog", { ...rest, ref: dialogRef, className: classnames('ffe-modal', className), "aria-labelledby": ariaLabelledby, onClick: event => {
|
|
70
|
+
const target = event.target;
|
|
95
71
|
if (target.nodeName === 'DIALOG') {
|
|
96
72
|
target.close();
|
|
97
73
|
}
|
|
98
74
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
99
|
-
}, onClose:
|
|
75
|
+
}, onClose: () => {
|
|
100
76
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
101
77
|
setIsOpen(false);
|
|
102
|
-
} }
|
|
78
|
+
} },
|
|
103
79
|
React.createElement("div", { className: "ffe-modal__body" },
|
|
104
|
-
React.createElement(CloseButton, { onClick:
|
|
80
|
+
React.createElement(CloseButton, { onClick: () => { var _a; return (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, locale: locale }),
|
|
105
81
|
children)), portalContainer !== null && portalContainer !== void 0 ? portalContainer : document.body)
|
|
106
82
|
: null;
|
|
107
83
|
});
|
package/es/ModalBlock.js
CHANGED
|
@@ -1,28 +1,5 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
-
var t = {};
|
|
14
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
-
t[p] = s[p];
|
|
16
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
-
t[p[i]] = s[p[i]];
|
|
20
|
-
}
|
|
21
|
-
return t;
|
|
22
|
-
};
|
|
23
1
|
import React from 'react';
|
|
24
2
|
import classnames from 'classnames';
|
|
25
|
-
export
|
|
26
|
-
|
|
27
|
-
return (React.createElement("div", __assign({ className: classnames('ffe-modal__block', className) }, rest)));
|
|
3
|
+
export const ModalBlock = ({ className, ...rest }) => {
|
|
4
|
+
return (React.createElement("div", { className: classnames('ffe-modal__block', className), ...rest }));
|
|
28
5
|
};
|
package/es/texts.js
CHANGED
package/lib/CloseButton.js
CHANGED
|
@@ -1,40 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
4
|
};
|
|
27
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
6
|
exports.CloseButton = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return (react_1.default.createElement(ffe_buttons_react_1.SecondaryButton, __assign({ iconOnly: true, className: (0, classnames_1.default)('ffe-modal__close'), "aria-label": texts_1.txt[locale].close }, rest),
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const ffe_icons_react_1 = require("@sb1/ffe-icons-react");
|
|
9
|
+
const texts_1 = require("./texts");
|
|
10
|
+
const ffe_buttons_react_1 = require("@sb1/ffe-buttons-react");
|
|
11
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
12
|
+
const closeIcon = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjQiPjxwYXRoIGQ9Ik00ODAtNDM3Ljg0NyAyNzcuMDc2LTIzNC45MjRxLTguMzA3IDguMzA4LTIwLjg4NCA4LjUtMTIuNTc2LjE5My0yMS4yNjgtOC41LTguNjkzLTguNjkyLTguNjkzLTIxLjA3NnQ4LjY5My0yMS4wNzZMNDM3Ljg0Ny00ODAgMjM0LjkyNC02ODIuOTI0cS04LjMwOC04LjMwNy04LjUtMjAuODg0LS4xOTMtMTIuNTc2IDguNS0yMS4yNjggOC42OTItOC42OTMgMjEuMDc2LTguNjkzdDIxLjA3NiA4LjY5M0w0ODAtNTIyLjE1M2wyMDIuOTI0LTIwMi45MjNxOC4zMDctOC4zMDggMjAuODg0LTguNSAxMi41NzYtLjE5MyAyMS4yNjggOC41IDguNjkzIDguNjkyIDguNjkzIDIxLjA3NnQtOC42OTMgMjEuMDc2TDUyMi4xNTMtNDgwbDIwMi45MjMgMjAyLjkyNHE4LjMwOCA4LjMwNyA4LjUgMjAuODg0LjE5MyAxMi41NzYtOC41IDIxLjI2OC04LjY5MiA4LjY5My0yMS4wNzYgOC42OTN0LTIxLjA3Ni04LjY5M0w0ODAtNDM3Ljg0N1oiLz48L3N2Zz4=';
|
|
13
|
+
const CloseButton = ({ locale, ...rest }) => {
|
|
14
|
+
return (react_1.default.createElement(ffe_buttons_react_1.SecondaryButton, { iconOnly: true, className: (0, classnames_1.default)('ffe-modal__close'), "aria-label": texts_1.txt[locale].close, ...rest },
|
|
38
15
|
react_1.default.createElement(ffe_icons_react_1.Icon, { fileUrl: closeIcon, size: "md" })));
|
|
39
16
|
};
|
|
40
17
|
exports.CloseButton = CloseButton;
|
package/lib/Modal.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -43,42 +32,30 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
43
32
|
return result;
|
|
44
33
|
};
|
|
45
34
|
})();
|
|
46
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
47
|
-
var t = {};
|
|
48
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
49
|
-
t[p] = s[p];
|
|
50
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
51
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
52
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
53
|
-
t[p[i]] = s[p[i]];
|
|
54
|
-
}
|
|
55
|
-
return t;
|
|
56
|
-
};
|
|
57
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
58
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
59
37
|
};
|
|
60
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
39
|
exports.Modal = void 0;
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
exports.Modal = react_1.default.forwardRef(
|
|
67
|
-
var children = _a.children, onClick = _a.onClick, ariaLabelledby = _a.ariaLabelledby, className = _a.className, _b = _a.locale, locale = _b === void 0 ? 'nb' : _b, onClose = _a.onClose, portalContainer = _a.portalContainer, rest = __rest(_a, ["children", "onClick", "ariaLabelledby", "className", "locale", "onClose", "portalContainer"]);
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const react_dom_1 = require("react-dom");
|
|
42
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
43
|
+
const CloseButton_1 = require("./CloseButton");
|
|
44
|
+
exports.Modal = react_1.default.forwardRef(({ children, onClick, ariaLabelledby, className, locale = 'nb', onClose, portalContainer, ...rest }, ref) => {
|
|
68
45
|
// SSR does not have access to document/window etc.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
(0, react_1.useImperativeHandle)(ref,
|
|
74
|
-
open:
|
|
46
|
+
const [isClient, setIsClient] = (0, react_1.useState)(false);
|
|
47
|
+
const [isOpen, setIsOpen] = (0, react_1.useState)(false);
|
|
48
|
+
const dialogRef = (0, react_1.useRef)(null);
|
|
49
|
+
const htmlOverflowY = (0, react_1.useRef)(isClient ? document.documentElement.style.overflowY : '');
|
|
50
|
+
(0, react_1.useImperativeHandle)(ref, () => ({
|
|
51
|
+
open: () => {
|
|
75
52
|
// Prevent opening an already open modal
|
|
76
53
|
if (!isOpen && dialogRef.current) {
|
|
77
54
|
setIsOpen(true);
|
|
78
55
|
dialogRef.current.showModal();
|
|
79
56
|
}
|
|
80
57
|
},
|
|
81
|
-
close:
|
|
58
|
+
close: () => {
|
|
82
59
|
// Prevent closing an already closed modal
|
|
83
60
|
if (isOpen && dialogRef.current) {
|
|
84
61
|
dialogRef.current.close();
|
|
@@ -89,17 +66,17 @@ exports.Modal = react_1.default.forwardRef(function (_a, ref) {
|
|
|
89
66
|
return isOpen;
|
|
90
67
|
},
|
|
91
68
|
// Expose dialogRef directly
|
|
92
|
-
dialogRef
|
|
93
|
-
})
|
|
94
|
-
(0, react_1.useEffect)(
|
|
69
|
+
dialogRef,
|
|
70
|
+
}));
|
|
71
|
+
(0, react_1.useEffect)(() => {
|
|
95
72
|
setIsClient(true);
|
|
96
73
|
}, []);
|
|
97
|
-
(0, react_1.useEffect)(
|
|
74
|
+
(0, react_1.useEffect)(() => {
|
|
98
75
|
var _a;
|
|
99
|
-
|
|
76
|
+
const inShadow = isClient &&
|
|
100
77
|
((_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.getRootNode()) instanceof ShadowRoot;
|
|
101
78
|
if (inShadow) {
|
|
102
|
-
|
|
79
|
+
const html = document.documentElement;
|
|
103
80
|
if (isOpen) {
|
|
104
81
|
htmlOverflowY.current = html.style.overflowY;
|
|
105
82
|
html.style.overflowY = 'hidden';
|
|
@@ -109,17 +86,16 @@ exports.Modal = react_1.default.forwardRef(function (_a, ref) {
|
|
|
109
86
|
}
|
|
110
87
|
}
|
|
111
88
|
}, [isClient, isOpen]);
|
|
112
|
-
(0, react_1.useEffect)(
|
|
89
|
+
(0, react_1.useEffect)(() => {
|
|
113
90
|
if (isOpen && dialogRef.current) {
|
|
114
91
|
dialogRef.current.focus();
|
|
115
92
|
}
|
|
116
93
|
}, [isOpen]);
|
|
117
|
-
(0, react_1.useEffect)(
|
|
94
|
+
(0, react_1.useEffect)(() => {
|
|
118
95
|
if (isClient &&
|
|
119
96
|
dialogRef.current &&
|
|
120
97
|
typeof dialogRef.current.showModal !== 'function') {
|
|
121
|
-
Promise.resolve().then(
|
|
122
|
-
var dialogPolyfill = _a.default;
|
|
98
|
+
Promise.resolve().then(() => __importStar(require('dialog-polyfill'))).then(({ default: dialogPolyfill }) => {
|
|
123
99
|
if (dialogRef.current) {
|
|
124
100
|
dialogPolyfill.registerDialog(dialogRef.current);
|
|
125
101
|
}
|
|
@@ -129,18 +105,18 @@ exports.Modal = react_1.default.forwardRef(function (_a, ref) {
|
|
|
129
105
|
return isClient
|
|
130
106
|
? (0, react_dom_1.createPortal)(
|
|
131
107
|
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
|
|
132
|
-
react_1.default.createElement("dialog",
|
|
133
|
-
|
|
108
|
+
react_1.default.createElement("dialog", { ...rest, ref: dialogRef, className: (0, classnames_1.default)('ffe-modal', className), "aria-labelledby": ariaLabelledby, onClick: event => {
|
|
109
|
+
const target = event.target;
|
|
134
110
|
if (target.nodeName === 'DIALOG') {
|
|
135
111
|
target.close();
|
|
136
112
|
}
|
|
137
113
|
onClick === null || onClick === void 0 ? void 0 : onClick(event);
|
|
138
|
-
}, onClose:
|
|
114
|
+
}, onClose: () => {
|
|
139
115
|
onClose === null || onClose === void 0 ? void 0 : onClose();
|
|
140
116
|
setIsOpen(false);
|
|
141
|
-
} }
|
|
117
|
+
} },
|
|
142
118
|
react_1.default.createElement("div", { className: "ffe-modal__body" },
|
|
143
|
-
react_1.default.createElement(CloseButton_1.CloseButton, { onClick:
|
|
119
|
+
react_1.default.createElement(CloseButton_1.CloseButton, { onClick: () => { var _a; return (_a = dialogRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, locale: locale }),
|
|
144
120
|
children)), portalContainer !== null && portalContainer !== void 0 ? portalContainer : document.body)
|
|
145
121
|
: null;
|
|
146
122
|
});
|
package/lib/ModalBlock.js
CHANGED
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
14
|
-
var t = {};
|
|
15
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
16
|
-
t[p] = s[p];
|
|
17
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
18
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
19
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
20
|
-
t[p[i]] = s[p[i]];
|
|
21
|
-
}
|
|
22
|
-
return t;
|
|
23
|
-
};
|
|
24
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
25
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
26
4
|
};
|
|
27
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
6
|
exports.ModalBlock = void 0;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return (react_1.default.createElement("div", __assign({ className: (0, classnames_1.default)('ffe-modal__block', className) }, rest)));
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
9
|
+
const ModalBlock = ({ className, ...rest }) => {
|
|
10
|
+
return (react_1.default.createElement("div", { className: (0, classnames_1.default)('ffe-modal__block', className), ...rest }));
|
|
34
11
|
};
|
|
35
12
|
exports.ModalBlock = ModalBlock;
|
package/lib/texts.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.txt = void 0;
|
|
4
|
-
|
|
4
|
+
const nb = {
|
|
5
5
|
close: 'Lukk',
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
const nn = {
|
|
8
8
|
close: 'Lukk',
|
|
9
9
|
};
|
|
10
|
-
|
|
10
|
+
const en = {
|
|
11
11
|
close: 'Close',
|
|
12
12
|
};
|
|
13
|
-
exports.txt = { nb
|
|
13
|
+
exports.txt = { nb, nn, en };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-modals-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "101.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "SpareBank 1",
|
|
6
6
|
"files": [
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"test:watch": "ffe-buildtool jest --watch"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@sb1/ffe-icons-react": "^
|
|
28
|
-
"@sb1/ffe-modals": "^
|
|
27
|
+
"@sb1/ffe-icons-react": "^101.0.0",
|
|
28
|
+
"@sb1/ffe-modals": "^101.0.0",
|
|
29
29
|
"classnames": "^2.5.1",
|
|
30
30
|
"dialog-polyfill": "^0.5.6"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@sb1/ffe-buildtool": "^
|
|
34
|
-
"eslint": "^
|
|
33
|
+
"@sb1/ffe-buildtool": "^101.0.0",
|
|
34
|
+
"eslint": "^10.2.0",
|
|
35
35
|
"react": "^18.2.0",
|
|
36
36
|
"react-dom": "^18.2.0"
|
|
37
37
|
},
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "7714019dbb9001551cb5d1c262c58afd609d4fb0"
|
|
45
45
|
}
|