@navikt/ds-react 4.12.1 → 5.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/_docs.json +101 -127
- package/cjs/date/datepicker/DatePicker.js +1 -1
- package/cjs/date/hooks/useEscape.js +6 -1
- package/cjs/modal/Modal.js +85 -46
- package/cjs/modal/{ModalContent.js → ModalBody.js} +3 -3
- package/cjs/modal/ModalContext.js +8 -0
- package/cjs/modal/ModalFooter.js +46 -0
- package/cjs/modal/ModalHeader.js +56 -0
- package/cjs/modal/ModalUtils.js +40 -0
- package/cjs/modal/dialog-polyfill.js +833 -0
- package/cjs/popover/Popover.js +5 -2
- package/cjs/table/DataCell.js +1 -3
- package/cjs/table/ExpandableRow.js +2 -1
- package/cjs/table/HeaderCell.js +1 -4
- package/cjs/table/Table.js +1 -1
- package/esm/date/datepicker/DatePicker.d.ts +2 -2
- package/esm/date/datepicker/DatePicker.js +1 -1
- package/esm/date/datepicker/DatePicker.js.map +1 -1
- package/esm/date/hooks/useEscape.d.ts +2 -1
- package/esm/date/hooks/useEscape.js +6 -1
- package/esm/date/hooks/useEscape.js.map +1 -1
- package/esm/modal/Modal.d.ts +76 -51
- package/esm/modal/Modal.js +87 -48
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalBody.d.ts +6 -0
- package/esm/modal/{ModalContent.js → ModalBody.js} +4 -4
- package/esm/modal/ModalBody.js.map +1 -0
- package/esm/modal/ModalContext.d.ts +6 -0
- package/esm/modal/ModalContext.js +3 -0
- package/esm/modal/ModalContext.js.map +1 -0
- package/esm/modal/ModalFooter.d.ts +6 -0
- package/esm/modal/ModalFooter.js +19 -0
- package/esm/modal/ModalFooter.js.map +1 -0
- package/esm/modal/ModalHeader.d.ts +11 -0
- package/esm/modal/ModalHeader.js +29 -0
- package/esm/modal/ModalHeader.js.map +1 -0
- package/esm/modal/ModalUtils.d.ts +4 -0
- package/esm/modal/ModalUtils.js +33 -0
- package/esm/modal/ModalUtils.js.map +1 -0
- package/esm/modal/dialog-polyfill.d.ts +5 -0
- package/esm/modal/dialog-polyfill.js +832 -0
- package/esm/modal/dialog-polyfill.js.map +1 -0
- package/esm/modal/index.d.ts +3 -1
- package/esm/popover/Popover.js +6 -3
- package/esm/popover/Popover.js.map +1 -1
- package/esm/provider/Provider.d.ts +1 -6
- package/esm/provider/Provider.js.map +1 -1
- package/esm/table/DataCell.js +2 -4
- package/esm/table/DataCell.js.map +1 -1
- package/esm/table/ExpandableRow.js +2 -1
- package/esm/table/ExpandableRow.js.map +1 -1
- package/esm/table/HeaderCell.js +1 -4
- package/esm/table/HeaderCell.js.map +1 -1
- package/esm/table/Table.d.ts +2 -3
- package/esm/table/Table.js +1 -1
- package/esm/table/Table.js.map +1 -1
- package/package.json +3 -5
- package/src/date/datepicker/DatePicker.tsx +3 -3
- package/src/date/hooks/useEscape.tsx +8 -3
- package/src/modal/Modal.tsx +171 -121
- package/src/modal/ModalBody.tsx +14 -0
- package/src/modal/ModalContext.ts +6 -0
- package/src/modal/ModalFooter.tsx +14 -0
- package/src/modal/ModalHeader.tsx +42 -0
- package/src/modal/ModalUtils.ts +37 -0
- package/src/modal/dialog-polyfill.ts +980 -0
- package/src/modal/index.ts +3 -1
- package/src/modal/modal.stories.tsx +142 -59
- package/src/popover/Popover.tsx +6 -2
- package/src/provider/Provider.tsx +1 -6
- package/src/table/DataCell.tsx +1 -5
- package/src/table/ExpandableRow.tsx +2 -1
- package/src/table/HeaderCell.tsx +1 -5
- package/src/table/Table.tsx +3 -4
- package/src/table/stories/table-expandable.stories.tsx +37 -1
- package/src/table/stories/table.stories.tsx +4 -1
- package/esm/modal/ModalContent.d.ts +0 -10
- package/esm/modal/ModalContent.js.map +0 -1
- package/src/modal/ModalContent.tsx +0 -26
package/cjs/popover/Popover.js
CHANGED
|
@@ -44,6 +44,7 @@ const react_2 = __importStar(require("react"));
|
|
|
44
44
|
const __1 = require("..");
|
|
45
45
|
const util_1 = require("../util");
|
|
46
46
|
const PopoverContent_1 = __importDefault(require("./PopoverContent"));
|
|
47
|
+
const ModalContext_1 = require("../modal/ModalContext");
|
|
47
48
|
/**
|
|
48
49
|
* A component that displays a popover.
|
|
49
50
|
*
|
|
@@ -65,10 +66,12 @@ const PopoverContent_1 = __importDefault(require("./PopoverContent"));
|
|
|
65
66
|
* ```
|
|
66
67
|
*/
|
|
67
68
|
exports.Popover = (0, react_2.forwardRef)((_a, ref) => {
|
|
68
|
-
var { className, children, anchorEl, arrow = true, open, onClose, placement = "top", offset, strategy: userStrategy
|
|
69
|
+
var { className, children, anchorEl, arrow = true, open, onClose, placement = "top", offset, strategy: userStrategy, bubbleEscape = false } = _a, rest = __rest(_a, ["className", "children", "anchorEl", "arrow", "open", "onClose", "placement", "offset", "strategy", "bubbleEscape"]);
|
|
69
70
|
const arrowRef = (0, react_2.useRef)(null);
|
|
71
|
+
const isInModal = (0, react_2.useContext)(ModalContext_1.ModalContext) !== null;
|
|
72
|
+
const chosenStrategy = userStrategy !== null && userStrategy !== void 0 ? userStrategy : (isInModal ? "fixed" : "absolute");
|
|
70
73
|
const { x, y, strategy, context, update, refs, placement: flPlacement, middlewareData: { arrow: { x: arrowX, y: arrowY } = {} }, } = (0, react_1.useFloating)({
|
|
71
|
-
strategy:
|
|
74
|
+
strategy: chosenStrategy,
|
|
72
75
|
placement,
|
|
73
76
|
open: open,
|
|
74
77
|
onOpenChange: onClose,
|
package/cjs/table/DataCell.js
CHANGED
|
@@ -41,12 +41,10 @@ exports.DataCell = void 0;
|
|
|
41
41
|
const react_1 = __importStar(require("react"));
|
|
42
42
|
const clsx_1 = __importDefault(require("clsx"));
|
|
43
43
|
const __1 = require("..");
|
|
44
|
-
const Table_1 = require("./Table");
|
|
45
44
|
exports.DataCell = (0, react_1.forwardRef)((_a, ref) => {
|
|
46
45
|
var { className, children = "", align } = _a, rest = __rest(_a, ["className", "children", "align"]);
|
|
47
|
-
const context = (0, react_1.useContext)(Table_1.TableContext);
|
|
48
46
|
return (react_1.default.createElement(__1.BodyShort, Object.assign({ as: "td", ref: ref, className: (0, clsx_1.default)("navds-table__data-cell", className, {
|
|
49
47
|
[`navds-table__data-cell--align-${align}`]: align,
|
|
50
|
-
})
|
|
48
|
+
}) }, rest), children));
|
|
51
49
|
});
|
|
52
50
|
exports.default = exports.DataCell;
|
|
@@ -66,6 +66,7 @@ exports.ExpandableRow = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
66
66
|
react_1.default.createElement(Row_1.default, Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)("navds-table__expandable-row", className, {
|
|
67
67
|
"navds-table__expandable-row--open": isOpen,
|
|
68
68
|
"navds-table__expandable-row--expansion-disabled": expansionDisabled,
|
|
69
|
+
"navds-table__expandable-row--clickable": expandOnRowClick,
|
|
69
70
|
}), onClick: (e) => {
|
|
70
71
|
var _a;
|
|
71
72
|
!expansionDisabled && expandOnRowClick && onRowClick(e);
|
|
@@ -74,7 +75,7 @@ exports.ExpandableRow = (0, react_1.forwardRef)((_a, ref) => {
|
|
|
74
75
|
togglePlacement === "right" && children,
|
|
75
76
|
react_1.default.createElement(DataCell_1.default, { className: (0, clsx_1.default)("navds-table__toggle-expand-cell", {
|
|
76
77
|
"navds-table__toggle-expand-cell--open": isOpen,
|
|
77
|
-
}) }, !expansionDisabled && (react_1.default.createElement("button", {
|
|
78
|
+
}) }, !expansionDisabled && (react_1.default.createElement("button", { className: "navds-table__toggle-expand-button", type: "button", "aria-controls": id, "aria-expanded": isOpen, onClick: expansionHandler },
|
|
78
79
|
react_1.default.createElement(aksel_icons_1.ChevronDownIcon, { className: "navds-table__expandable-icon", title: isOpen ? "Vis mindre" : "Vis mer" })))),
|
|
79
80
|
togglePlacement === "left" && children),
|
|
80
81
|
react_1.default.createElement("tr", { className: "navds-table__expanded-row", "aria-hidden": !isOpen, id: id },
|
package/cjs/table/HeaderCell.js
CHANGED
|
@@ -38,15 +38,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
38
38
|
};
|
|
39
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
40
|
exports.HeaderCell = void 0;
|
|
41
|
-
const react_1 = __importStar(require("react"));
|
|
42
41
|
const clsx_1 = __importDefault(require("clsx"));
|
|
43
|
-
const
|
|
42
|
+
const react_1 = __importStar(require("react"));
|
|
44
43
|
exports.HeaderCell = (0, react_1.forwardRef)((_a, ref) => {
|
|
45
44
|
var { className, children, align } = _a, rest = __rest(_a, ["className", "children", "align"]);
|
|
46
|
-
const context = (0, react_1.useContext)(Table_1.TableContext);
|
|
47
45
|
return (react_1.default.createElement("th", Object.assign({ ref: ref, className: (0, clsx_1.default)("navds-table__header-cell", "navds-label", className, {
|
|
48
46
|
[`navds-table__header-cell--align-${align}`]: align,
|
|
49
|
-
"navds-label--small": (context === null || context === void 0 ? void 0 : context.size) === "small",
|
|
50
47
|
}) }, rest), children));
|
|
51
48
|
});
|
|
52
49
|
exports.default = exports.HeaderCell;
|
package/cjs/table/Table.js
CHANGED
|
@@ -82,7 +82,7 @@ exports.TableContext = (0, react_1.createContext)(null);
|
|
|
82
82
|
*/
|
|
83
83
|
exports.Table = (0, react_1.forwardRef)((_a, ref) => {
|
|
84
84
|
var { className, zebraStripes = false, size = "medium", onSortChange, sort } = _a, rest = __rest(_a, ["className", "zebraStripes", "size", "onSortChange", "sort"]);
|
|
85
|
-
return (react_1.default.createElement(exports.TableContext.Provider, { value: {
|
|
85
|
+
return (react_1.default.createElement(exports.TableContext.Provider, { value: { onSortChange, sort } },
|
|
86
86
|
react_1.default.createElement("table", Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)("navds-table", `navds-table--${size}`, className, {
|
|
87
87
|
"navds-table--zebra-stripes": zebraStripes,
|
|
88
88
|
}) }))));
|
|
@@ -82,9 +82,9 @@ export interface DatePickerDefaultProps extends Omit<React.HTMLAttributes<HTMLDi
|
|
|
82
82
|
onOpenToggle?: () => void;
|
|
83
83
|
/**
|
|
84
84
|
* Avoid using if possible!
|
|
85
|
-
* Changes what CSS position property to use
|
|
85
|
+
* Changes what CSS position property to use.
|
|
86
86
|
* You want to use "fixed" if parent wrapper has position relative, but you want popover to escape
|
|
87
|
-
* @default
|
|
87
|
+
* @default See Popover
|
|
88
88
|
*/
|
|
89
89
|
strategy?: "absolute" | "fixed";
|
|
90
90
|
/**
|
|
@@ -45,7 +45,7 @@ import { TableHead } from "./TableHead";
|
|
|
45
45
|
*/
|
|
46
46
|
export const DatePicker = forwardRef((_a, ref) => {
|
|
47
47
|
var _b;
|
|
48
|
-
var { children, locale = "nb", dropdownCaption, disabled = [], disableWeekends = false, showWeekNumber = false, selected, id, defaultSelected, className, wrapperClassName, open: _open, onClose, onOpenToggle, strategy
|
|
48
|
+
var { children, locale = "nb", dropdownCaption, disabled = [], disableWeekends = false, showWeekNumber = false, selected, id, defaultSelected, className, wrapperClassName, open: _open, onClose, onOpenToggle, strategy, bubbleEscape = false } = _a, rest = __rest(_a, ["children", "locale", "dropdownCaption", "disabled", "disableWeekends", "showWeekNumber", "selected", "id", "defaultSelected", "className", "wrapperClassName", "open", "onClose", "onOpenToggle", "strategy", "bubbleEscape"]);
|
|
49
49
|
const ariaId = useId(id);
|
|
50
50
|
const [open, setOpen] = useState(_open !== null && _open !== void 0 ? _open : false);
|
|
51
51
|
const wrapperRef = useRef(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatePicker.js","sourceRoot":"","sources":["../../../src/date/datepicker/DatePicker.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,SAAS,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5D,OAAO,EAEL,SAAS,EAET,OAAO,GAKR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CA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AC,EACtC,UAAU,EAAE;wBACV,OAAO,EAAE,eAAe;qBACzB,EACD,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE;wBAChB,OAAO,CACL,CAAC,eAAe,IAAI,SAAS,CAAC,GAAG,CAAC,CAAC;4BACnC,OAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CACvB,CAAC;oBACJ,CAAC,EACD,YAAY,EAAE,CAAC,EACf,YAAY,EAAE,KAAK,EACnB,MAAM,EAAE,MAAa,EACrB,SAAS,EAAE;wBACT,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,eAAe,IAAI,SAAS,CAAC,GAAG,CAAC;qBACpD,EACD,mBAAmB,EAAE;wBACnB,OAAO,EAAE,kBAAkB;qBAC5B,EACD,cAAc,EAAE,cAAc,EAC9B,UAAU,QACV,eAAe,UACX,IAAI,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,CAAC,EAC5B,CACM,CACX,CACG,CACe,CACxB,CAAC;AACJ,CAAC,CACqB,CAAC;AAEzB,UAAU,CAAC,UAAU,GAAG,oBAAoB,CAAC;AAC7C,UAAU,CAAC,KAAK,GAAG,eAAe,CAAC;AAEnC,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
export declare const useEscape: (open: boolean, setOpen: (openState: boolean) => void, focusRef: RefObject<HTMLElement>) => void;
|
|
@@ -4,7 +4,12 @@ export const useEscape = (open, setOpen, focusRef) => {
|
|
|
4
4
|
setOpen(false);
|
|
5
5
|
(focusRef === null || focusRef === void 0 ? void 0 : focusRef.current) && focusRef.current.focus();
|
|
6
6
|
}, [focusRef, setOpen]);
|
|
7
|
-
const escape = useCallback((
|
|
7
|
+
const escape = useCallback((event) => {
|
|
8
|
+
if (open && event.key === "Escape") {
|
|
9
|
+
event.preventDefault(); // This prevents modal from closing when using datepicker inside modal
|
|
10
|
+
handleClose();
|
|
11
|
+
}
|
|
12
|
+
}, [handleClose, open]);
|
|
8
13
|
useEffect(() => {
|
|
9
14
|
window.addEventListener("keydown", escape, false);
|
|
10
15
|
return () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEscape.js","sourceRoot":"","sources":["../../../src/date/hooks/useEscape.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"useEscape.js","sourceRoot":"","sources":["../../../src/date/hooks/useEscape.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAa,MAAM,OAAO,CAAC;AAE1D,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,IAAa,EACb,OAAqC,EACrC,QAAgC,EAChC,EAAE;IACF,MAAM,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE;QACnC,OAAO,CAAC,KAAK,CAAC,CAAC;QACf,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,KAAI,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IAChD,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IAExB,MAAM,MAAM,GAAG,WAAW,CACxB,CAAC,KAAoB,EAAE,EAAE;QACvB,IAAI,IAAI,IAAI,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE;YAClC,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,sEAAsE;YAC9F,WAAW,EAAE,CAAC;SACf;IACH,CAAC,EACD,CAAC,WAAW,EAAE,IAAI,CAAC,CACpB,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAElD,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QACvD,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;AACf,CAAC,CAAC"}
|
package/esm/modal/Modal.d.ts
CHANGED
|
@@ -1,64 +1,70 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
2
|
+
import ModalBody from "./ModalBody";
|
|
3
|
+
import ModalHeader from "./ModalHeader";
|
|
4
|
+
import ModalFooter from "./ModalFooter";
|
|
5
|
+
export interface ModalProps extends React.DialogHTMLAttributes<HTMLDialogElement> {
|
|
6
|
+
/**
|
|
7
|
+
* Content for the header. Alteratively you can use <Modal.Header> instead for more control,
|
|
8
|
+
* but then you have to set `aria-label` or `aria-labelledby` on the modal manually.
|
|
9
|
+
*/
|
|
10
|
+
header?: {
|
|
11
|
+
label?: string;
|
|
12
|
+
icon?: React.ReactNode;
|
|
13
|
+
heading: string;
|
|
14
|
+
/**
|
|
15
|
+
* Heading size
|
|
16
|
+
* @default "medium"
|
|
17
|
+
* */
|
|
18
|
+
size?: "medium" | "small";
|
|
19
|
+
/**
|
|
20
|
+
* Removes close-button (X) when false
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
closeButton?: boolean;
|
|
24
|
+
};
|
|
5
25
|
/**
|
|
6
26
|
* Modal content
|
|
7
27
|
*/
|
|
8
28
|
children: React.ReactNode;
|
|
9
29
|
/**
|
|
10
|
-
*
|
|
30
|
+
* Whether the modal should be visible or not.
|
|
31
|
+
* Remember to use the `onClose` callback to keep your local state in sync.
|
|
32
|
+
* You can also use `ref.current.openModal()` and `ref.current.close()`.
|
|
11
33
|
*/
|
|
12
|
-
open
|
|
34
|
+
open?: boolean;
|
|
13
35
|
/**
|
|
14
|
-
*
|
|
36
|
+
* Called when the modal has been closed
|
|
15
37
|
*/
|
|
16
|
-
onClose
|
|
38
|
+
onClose?: React.ReactEventHandler<HTMLDialogElement>;
|
|
17
39
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @
|
|
40
|
+
* Called when the user wants to close the modal (clicked the close button or pressed Esc).
|
|
41
|
+
* @returns Whether to close the modal
|
|
20
42
|
*/
|
|
21
|
-
|
|
43
|
+
onBeforeClose?: () => boolean | void;
|
|
22
44
|
/**
|
|
23
|
-
*
|
|
45
|
+
* Called when the user presses the Esc key, unless `onBeforeClose()` returns `false`.
|
|
24
46
|
*/
|
|
25
|
-
|
|
47
|
+
onCancel?: React.ReactEventHandler<HTMLDialogElement>;
|
|
26
48
|
/**
|
|
27
|
-
*
|
|
28
|
-
*/
|
|
29
|
-
|
|
49
|
+
* @default fit-content (up to 700px)
|
|
50
|
+
* */
|
|
51
|
+
width?: "medium" | "small" | number | string;
|
|
30
52
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @default true
|
|
33
|
-
*/
|
|
34
|
-
closeButton?: boolean;
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
*/
|
|
38
|
-
shouldCloseOnEsc?: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Allows custom styling of ReactModal, in accordance with their typing
|
|
53
|
+
* User defined classname for modal
|
|
41
54
|
*/
|
|
42
|
-
|
|
55
|
+
className?: string;
|
|
43
56
|
/**
|
|
44
|
-
*
|
|
57
|
+
* Sets aria-labelledby on modal.
|
|
58
|
+
* No need to set this manually if the `header` prop is used. A reference to `header.heading` will be created automatically.
|
|
59
|
+
* @warning If not using `header`, you should set either `aria-labelledby` or `aria-label`.
|
|
45
60
|
*/
|
|
46
|
-
parentSelector?(): HTMLElement;
|
|
47
61
|
"aria-labelledby"?: string;
|
|
48
|
-
"aria-describedby"?: string;
|
|
49
|
-
"aria-modal"?: boolean;
|
|
50
|
-
/**
|
|
51
|
-
* Sets aria-label on modal
|
|
52
|
-
* @warning This should be set if not using 'aria-labelledby' or 'aria-describedby'
|
|
53
|
-
*/
|
|
54
|
-
"aria-label"?: string;
|
|
55
62
|
}
|
|
56
|
-
interface ModalComponent extends
|
|
57
|
-
|
|
63
|
+
interface ModalComponent extends React.ForwardRefExoticComponent<ModalProps & React.RefAttributes<HTMLDialogElement>> {
|
|
64
|
+
Header: typeof ModalHeader;
|
|
65
|
+
Body: typeof ModalBody;
|
|
66
|
+
Footer: typeof ModalFooter;
|
|
58
67
|
}
|
|
59
|
-
type ModalLifecycle = {
|
|
60
|
-
setAppElement: (element: any) => void;
|
|
61
|
-
};
|
|
62
68
|
/**
|
|
63
69
|
* A component that displays a modal dialog.
|
|
64
70
|
*
|
|
@@ -66,23 +72,42 @@ type ModalLifecycle = {
|
|
|
66
72
|
* @see 🏷️ {@link ModalProps}
|
|
67
73
|
*
|
|
68
74
|
* @example
|
|
75
|
+
* State change with `useRef`
|
|
76
|
+
* ```jsx
|
|
77
|
+
* const ref = useRef<HTMLDialogElement>(null);
|
|
78
|
+
* <Button onClick={() => ref.current?.showModal()}>Open modal</Button>
|
|
79
|
+
* <Modal
|
|
80
|
+
* ref={ref}
|
|
81
|
+
* header={{
|
|
82
|
+
* label: "Optional label",
|
|
83
|
+
* icon: <FileIcon aria-hidden />,
|
|
84
|
+
* heading: "My heading",
|
|
85
|
+
* }}
|
|
86
|
+
* >
|
|
87
|
+
* <Modal.Body>
|
|
88
|
+
* <BodyLong>Hello world</BodyLong>
|
|
89
|
+
* </Modal.Body>
|
|
90
|
+
* <Modal.Footer>
|
|
91
|
+
* <Button>Save</Button>
|
|
92
|
+
* <Button type="button" variant="tertiary" onClick={() => ref.current?.close()}>Close</Button>
|
|
93
|
+
* </Modal.Footer>
|
|
94
|
+
* </Modal>
|
|
95
|
+
* ```
|
|
96
|
+
* @example
|
|
97
|
+
* State change with `useState`
|
|
69
98
|
* ```jsx
|
|
70
99
|
* const [open, setOpen] = useState(false);
|
|
71
|
-
*
|
|
72
100
|
* <Modal
|
|
73
101
|
* open={open}
|
|
74
|
-
*
|
|
75
|
-
* onClose={() => setOpen((x) => !x)}
|
|
102
|
+
* onClose={() => setOpen(false)}
|
|
76
103
|
* aria-labelledby="modal-heading"
|
|
77
104
|
* >
|
|
78
|
-
* <Modal.
|
|
79
|
-
* <Heading
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
* <BodyLong
|
|
83
|
-
*
|
|
84
|
-
* </BodyLong>
|
|
85
|
-
* </Modal.Content>
|
|
105
|
+
* <Modal.Header>
|
|
106
|
+
* <Heading level="1" size="large" id="modal-heading">My heading</Heading>
|
|
107
|
+
* </Modal.Header>
|
|
108
|
+
* <Modal.Body>
|
|
109
|
+
* <BodyLong>Hello world</BodyLong>
|
|
110
|
+
* </Modal.Body>
|
|
86
111
|
* </Modal>
|
|
87
112
|
* ```
|
|
88
113
|
*/
|
package/esm/modal/Modal.js
CHANGED
|
@@ -9,12 +9,16 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
|
-
import React, { forwardRef, useEffect, useMemo, useRef } from "react";
|
|
12
|
+
import React, { forwardRef, useContext, useEffect, useMemo, useRef, } from "react";
|
|
13
13
|
import cl from "clsx";
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import
|
|
14
|
+
import dialogPolyfill from "./dialog-polyfill";
|
|
15
|
+
import { Detail, Heading, mergeRefs, useId } from "..";
|
|
16
|
+
import ModalBody from "./ModalBody";
|
|
17
|
+
import ModalHeader from "./ModalHeader";
|
|
18
|
+
import ModalFooter from "./ModalFooter";
|
|
19
|
+
import { getCloseHandler, useBodyScrollLock } from "./ModalUtils";
|
|
20
|
+
import { ModalContext } from "./ModalContext";
|
|
21
|
+
const needPolyfill = typeof window !== "undefined" && window.HTMLDialogElement === undefined;
|
|
18
22
|
/**
|
|
19
23
|
* A component that displays a modal dialog.
|
|
20
24
|
*
|
|
@@ -22,64 +26,99 @@ import { XMarkIcon } from "@navikt/aksel-icons";
|
|
|
22
26
|
* @see 🏷️ {@link ModalProps}
|
|
23
27
|
*
|
|
24
28
|
* @example
|
|
29
|
+
* State change with `useRef`
|
|
30
|
+
* ```jsx
|
|
31
|
+
* const ref = useRef<HTMLDialogElement>(null);
|
|
32
|
+
* <Button onClick={() => ref.current?.showModal()}>Open modal</Button>
|
|
33
|
+
* <Modal
|
|
34
|
+
* ref={ref}
|
|
35
|
+
* header={{
|
|
36
|
+
* label: "Optional label",
|
|
37
|
+
* icon: <FileIcon aria-hidden />,
|
|
38
|
+
* heading: "My heading",
|
|
39
|
+
* }}
|
|
40
|
+
* >
|
|
41
|
+
* <Modal.Body>
|
|
42
|
+
* <BodyLong>Hello world</BodyLong>
|
|
43
|
+
* </Modal.Body>
|
|
44
|
+
* <Modal.Footer>
|
|
45
|
+
* <Button>Save</Button>
|
|
46
|
+
* <Button type="button" variant="tertiary" onClick={() => ref.current?.close()}>Close</Button>
|
|
47
|
+
* </Modal.Footer>
|
|
48
|
+
* </Modal>
|
|
49
|
+
* ```
|
|
50
|
+
* @example
|
|
51
|
+
* State change with `useState`
|
|
25
52
|
* ```jsx
|
|
26
53
|
* const [open, setOpen] = useState(false);
|
|
27
|
-
*
|
|
28
54
|
* <Modal
|
|
29
55
|
* open={open}
|
|
30
|
-
*
|
|
31
|
-
* onClose={() => setOpen((x) => !x)}
|
|
56
|
+
* onClose={() => setOpen(false)}
|
|
32
57
|
* aria-labelledby="modal-heading"
|
|
33
58
|
* >
|
|
34
|
-
* <Modal.
|
|
35
|
-
* <Heading
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* <BodyLong
|
|
39
|
-
*
|
|
40
|
-
* </BodyLong>
|
|
41
|
-
* </Modal.Content>
|
|
59
|
+
* <Modal.Header>
|
|
60
|
+
* <Heading level="1" size="large" id="modal-heading">My heading</Heading>
|
|
61
|
+
* </Modal.Header>
|
|
62
|
+
* <Modal.Body>
|
|
63
|
+
* <BodyLong>Hello world</BodyLong>
|
|
64
|
+
* </Modal.Body>
|
|
42
65
|
* </Modal>
|
|
43
66
|
* ```
|
|
44
67
|
*/
|
|
45
68
|
export const Modal = forwardRef((_a, ref) => {
|
|
46
|
-
var _b
|
|
47
|
-
var { children, open,
|
|
69
|
+
var _b;
|
|
70
|
+
var { header, children, open, onBeforeClose, onCancel, width, className, "aria-labelledby": ariaLabelledby, style } = _a, rest = __rest(_a, ["header", "children", "open", "onBeforeClose", "onCancel", "width", "className", "aria-labelledby", "style"]);
|
|
48
71
|
const modalRef = useRef(null);
|
|
49
72
|
const mergedRef = useMemo(() => mergeRefs([modalRef, ref]), [ref]);
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
73
|
+
const ariaLabelId = useId();
|
|
74
|
+
if (useContext(ModalContext)) {
|
|
75
|
+
console.error("Modals should not be nested");
|
|
76
|
+
}
|
|
53
77
|
useEffect(() => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const onModalCloseRequest = (e) => {
|
|
57
|
-
if (shouldCloseOnOverlayClick || e.type === "keydown") {
|
|
58
|
-
onClose();
|
|
78
|
+
if (needPolyfill && modalRef.current) {
|
|
79
|
+
dialogPolyfill.registerDialog(modalRef.current);
|
|
59
80
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
81
|
+
}, [modalRef]);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
// We need to have this in a useEffect so that the content renders before the modal is displayed,
|
|
84
|
+
// and in case `open` is true initially.
|
|
85
|
+
if (modalRef.current && open !== undefined) {
|
|
86
|
+
if (open && !modalRef.current.open) {
|
|
87
|
+
modalRef.current.showModal();
|
|
88
|
+
}
|
|
89
|
+
else if (!open && modalRef.current.open) {
|
|
90
|
+
modalRef.current.close();
|
|
91
|
+
}
|
|
67
92
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
93
|
+
}, [modalRef, open]);
|
|
94
|
+
useBodyScrollLock(modalRef, "navds-modal__document-body");
|
|
95
|
+
const isWidthPreset = typeof width === "string" && ["small", "medium"].includes(width);
|
|
96
|
+
return (React.createElement("dialog", Object.assign({ ref: mergedRef, className: cl("navds-modal", className, {
|
|
97
|
+
"navds-modal--polyfilled": needPolyfill,
|
|
98
|
+
"navds-modal--autowidth": !width,
|
|
99
|
+
[`navds-modal--${width}`]: isWidthPreset,
|
|
100
|
+
}), style: Object.assign(Object.assign({}, style), (!isWidthPreset ? { width } : {})), onCancel: (event) => {
|
|
101
|
+
// FYI: onCancel fires when you press Esc
|
|
102
|
+
if (onBeforeClose && onBeforeClose() === false) {
|
|
103
|
+
event.preventDefault();
|
|
104
|
+
}
|
|
105
|
+
else if (onCancel)
|
|
106
|
+
onCancel(event);
|
|
107
|
+
}, "aria-labelledby": !ariaLabelledby && !rest["aria-label"] && header
|
|
108
|
+
? ariaLabelId
|
|
109
|
+
: ariaLabelledby }, rest),
|
|
110
|
+
React.createElement(ModalContext.Provider, { value: {
|
|
111
|
+
closeHandler: getCloseHandler(modalRef, header, onBeforeClose),
|
|
112
|
+
} },
|
|
113
|
+
header && (React.createElement(ModalHeader, null,
|
|
114
|
+
header.label && (React.createElement(Detail, { className: "navds-modal__label" }, header.label)),
|
|
115
|
+
React.createElement(Heading, { size: (_b = header.size) !== null && _b !== void 0 ? _b : "medium", level: "1", id: ariaLabelId },
|
|
116
|
+
React.createElement("span", { className: "navds-modal__header-icon" }, header.icon),
|
|
117
|
+
header.heading))),
|
|
118
|
+
children)));
|
|
81
119
|
});
|
|
82
|
-
Modal.
|
|
83
|
-
Modal.
|
|
120
|
+
Modal.Header = ModalHeader;
|
|
121
|
+
Modal.Body = ModalBody;
|
|
122
|
+
Modal.Footer = ModalFooter;
|
|
84
123
|
export default Modal;
|
|
85
124
|
//# sourceMappingURL=Modal.js.map
|
package/esm/modal/Modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/modal/Modal.tsx"],"names":[],"mappings":";;;;;;;;;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
|
|
5
|
+
declare const ModalBody: React.ForwardRefExoticComponent<ModalBodyProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export default ModalBody;
|
|
@@ -11,9 +11,9 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import React, { forwardRef } from "react";
|
|
13
13
|
import cl from "clsx";
|
|
14
|
-
const
|
|
14
|
+
const ModalBody = forwardRef((_a, ref) => {
|
|
15
15
|
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
16
|
-
return (React.createElement("div", Object.assign({}, rest, { ref: ref, className: cl("navds-
|
|
16
|
+
return (React.createElement("div", Object.assign({}, rest, { ref: ref, className: cl("navds-modal__body", className) })));
|
|
17
17
|
});
|
|
18
|
-
export default
|
|
19
|
-
//# sourceMappingURL=
|
|
18
|
+
export default ModalBody;
|
|
19
|
+
//# sourceMappingURL=ModalBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalBody.js","sourceRoot":"","sources":["../../src/modal/ModalBody.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAMtB,MAAM,SAAS,GAAG,UAAU,CAC1B,CAAC,EAAsB,EAAE,GAAG,EAAE,EAAE;QAA/B,EAAE,SAAS,OAAW,EAAN,IAAI,cAApB,aAAsB,CAAF;IAAY,OAAA,CAC/B,6CAAS,IAAI,IAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,mBAAmB,EAAE,SAAS,CAAC,IAAI,CAC3E,CAAA;CAAA,CACF,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalContext.js","sourceRoot":"","sources":["../../src/modal/ModalContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAK1B,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC,aAAa,CAA2B,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ModalFooterProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
declare const ModalFooter: React.ForwardRefExoticComponent<ModalFooterProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
+
export default ModalFooter;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React, { forwardRef } from "react";
|
|
13
|
+
import cl from "clsx";
|
|
14
|
+
const ModalFooter = forwardRef((_a, ref) => {
|
|
15
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
16
|
+
return (React.createElement("div", Object.assign({}, rest, { ref: ref, className: cl("navds-modal__footer", className) })));
|
|
17
|
+
});
|
|
18
|
+
export default ModalFooter;
|
|
19
|
+
//# sourceMappingURL=ModalFooter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModalFooter.js","sourceRoot":"","sources":["../../src/modal/ModalFooter.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,MAAM,MAAM,CAAC;AAMtB,MAAM,WAAW,GAAG,UAAU,CAC5B,CAAC,EAAsB,EAAE,GAAG,EAAE,EAAE;QAA/B,EAAE,SAAS,OAAW,EAAN,IAAI,cAApB,aAAsB,CAAF;IAAY,OAAA,CAC/B,6CAAS,IAAI,IAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC,IAAI,CAC7E,CAAA;CAAA,CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface ModalHeaderProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
3
|
+
children?: React.ReactNode;
|
|
4
|
+
/**
|
|
5
|
+
* Removes close-button (X) when false
|
|
6
|
+
* @default true
|
|
7
|
+
*/
|
|
8
|
+
closeButton?: boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const ModalHeader: React.ForwardRefExoticComponent<ModalHeaderProps & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
export default ModalHeader;
|