@sb1/ffe-modals-react 0.3.3 → 0.3.4
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/Modal.js +3 -3
- package/lib/Modal.js +3 -3
- package/package.json +2 -2
- package/types/Modal.d.ts +3 -0
package/es/Modal.js
CHANGED
|
@@ -25,8 +25,8 @@ import { createPortal } from 'react-dom';
|
|
|
25
25
|
import classnames from 'classnames';
|
|
26
26
|
import { CloseButton } from './CloseButton';
|
|
27
27
|
export var Modal = React.forwardRef(function (_a, ref) {
|
|
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, rest = __rest(_a, ["children", "onClick", "ariaLabelledby", "className", "locale", "onClose"]);
|
|
29
|
-
var
|
|
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, _c = _a.portalContainer, portalContainer = _c === void 0 ? document.body : _c, rest = __rest(_a, ["children", "onClick", "ariaLabelledby", "className", "locale", "onClose", "portalContainer"]);
|
|
29
|
+
var _d = useState(false), isOpen = _d[0], setIsOpen = _d[1];
|
|
30
30
|
var modalRef = useRef(null);
|
|
31
31
|
var htmlOverflowY = useRef(document.documentElement.style.overflowY);
|
|
32
32
|
useImperativeHandle(ref, function () { return ({
|
|
@@ -68,5 +68,5 @@ export var Modal = React.forwardRef(function (_a, ref) {
|
|
|
68
68
|
} }),
|
|
69
69
|
React.createElement("div", { className: "ffe-modal__body" },
|
|
70
70
|
React.createElement(CloseButton, { onClick: function () { var _a; return (_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, locale: locale }),
|
|
71
|
-
children)),
|
|
71
|
+
children)), portalContainer);
|
|
72
72
|
});
|
package/lib/Modal.js
CHANGED
|
@@ -54,8 +54,8 @@ var react_dom_1 = require("react-dom");
|
|
|
54
54
|
var classnames_1 = __importDefault(require("classnames"));
|
|
55
55
|
var CloseButton_1 = require("./CloseButton");
|
|
56
56
|
exports.Modal = react_1.default.forwardRef(function (_a, ref) {
|
|
57
|
-
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, rest = __rest(_a, ["children", "onClick", "ariaLabelledby", "className", "locale", "onClose"]);
|
|
58
|
-
var
|
|
57
|
+
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, _c = _a.portalContainer, portalContainer = _c === void 0 ? document.body : _c, rest = __rest(_a, ["children", "onClick", "ariaLabelledby", "className", "locale", "onClose", "portalContainer"]);
|
|
58
|
+
var _d = (0, react_1.useState)(false), isOpen = _d[0], setIsOpen = _d[1];
|
|
59
59
|
var modalRef = (0, react_1.useRef)(null);
|
|
60
60
|
var htmlOverflowY = (0, react_1.useRef)(document.documentElement.style.overflowY);
|
|
61
61
|
(0, react_1.useImperativeHandle)(ref, function () { return ({
|
|
@@ -97,5 +97,5 @@ exports.Modal = react_1.default.forwardRef(function (_a, ref) {
|
|
|
97
97
|
} }),
|
|
98
98
|
react_1.default.createElement("div", { className: "ffe-modal__body" },
|
|
99
99
|
react_1.default.createElement(CloseButton_1.CloseButton, { onClick: function () { var _a; return (_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.close(); }, locale: locale }),
|
|
100
|
-
children)),
|
|
100
|
+
children)), portalContainer);
|
|
101
101
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sb1/ffe-modals-react",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "SpareBank 1",
|
|
6
6
|
"files": [
|
|
@@ -40,5 +40,5 @@
|
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "8260c42bcd273417732bc5628b25e9d1545c0704"
|
|
44
44
|
}
|
package/types/Modal.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
2
3
|
import { Locale } from './types';
|
|
3
4
|
export interface ModalProps extends React.ComponentPropsWithoutRef<'dialog'> {
|
|
4
5
|
/** Id of modal heading */
|
|
@@ -7,6 +8,8 @@ export interface ModalProps extends React.ComponentPropsWithoutRef<'dialog'> {
|
|
|
7
8
|
locale?: Locale;
|
|
8
9
|
/** Called when dialog is closed */
|
|
9
10
|
onClose?: () => void;
|
|
11
|
+
/** Container for portal, default is document.body */
|
|
12
|
+
portalContainer?: Parameters<typeof createPortal>[1];
|
|
10
13
|
}
|
|
11
14
|
export type ModalHandle = {
|
|
12
15
|
readonly open: () => void;
|