@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
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
42
|
+
const ModalFooter = (0, react_1.forwardRef)((_a, ref) => {
|
|
43
|
+
var { className } = _a, rest = __rest(_a, ["className"]);
|
|
44
|
+
return (react_1.default.createElement("div", Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)("navds-modal__footer", className) })));
|
|
45
|
+
});
|
|
46
|
+
exports.default = ModalFooter;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
26
|
+
var t = {};
|
|
27
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
28
|
+
t[p] = s[p];
|
|
29
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
30
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
31
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
32
|
+
t[p[i]] = s[p[i]];
|
|
33
|
+
}
|
|
34
|
+
return t;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
const react_1 = __importStar(require("react"));
|
|
41
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
42
|
+
const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
43
|
+
const button_1 = require("../button");
|
|
44
|
+
const ModalContext_1 = require("./ModalContext");
|
|
45
|
+
const ModalHeader = (0, react_1.forwardRef)((_a, ref) => {
|
|
46
|
+
var { children, className, closeButton = true } = _a, rest = __rest(_a, ["children", "className", "closeButton"]);
|
|
47
|
+
const context = (0, react_1.useContext)(ModalContext_1.ModalContext);
|
|
48
|
+
if (context === null) {
|
|
49
|
+
console.error("<Modal.Header> has to be used within a <Modal>");
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return (react_1.default.createElement("div", Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)("navds-modal__header", className) }),
|
|
53
|
+
context.closeHandler && closeButton && (react_1.default.createElement(button_1.Button, { type: "button", className: "navds-modal__button", size: "small", variant: "tertiary-neutral", onClick: context.closeHandler, icon: react_1.default.createElement(aksel_icons_1.XMarkIcon, { title: "Lukk modalvindu" }) })),
|
|
54
|
+
children));
|
|
55
|
+
});
|
|
56
|
+
exports.default = ModalHeader;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.useBodyScrollLock = exports.getCloseHandler = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
function getCloseHandler(modalRef, header, onBeforeClose) {
|
|
9
|
+
if (header && header.closeButton === false)
|
|
10
|
+
return undefined;
|
|
11
|
+
if (onBeforeClose) {
|
|
12
|
+
return () => { var _a; return onBeforeClose() !== false && ((_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.close()); };
|
|
13
|
+
}
|
|
14
|
+
return () => { var _a; return (_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.close(); };
|
|
15
|
+
}
|
|
16
|
+
exports.getCloseHandler = getCloseHandler;
|
|
17
|
+
function useBodyScrollLock(modalRef, bodyClass) {
|
|
18
|
+
react_1.default.useEffect(() => {
|
|
19
|
+
if (!modalRef.current)
|
|
20
|
+
return;
|
|
21
|
+
if (modalRef.current.open)
|
|
22
|
+
document.body.classList.add(bodyClass); // In case `open` is true initially
|
|
23
|
+
const observer = new MutationObserver(() => {
|
|
24
|
+
var _a;
|
|
25
|
+
if ((_a = modalRef.current) === null || _a === void 0 ? void 0 : _a.open)
|
|
26
|
+
document.body.classList.add(bodyClass);
|
|
27
|
+
else
|
|
28
|
+
document.body.classList.remove(bodyClass);
|
|
29
|
+
});
|
|
30
|
+
observer.observe(modalRef.current, {
|
|
31
|
+
attributes: true,
|
|
32
|
+
attributeFilter: ["open"],
|
|
33
|
+
});
|
|
34
|
+
return () => {
|
|
35
|
+
observer.disconnect();
|
|
36
|
+
document.body.classList.remove(bodyClass); // In case modal is unmounted before it's closed
|
|
37
|
+
};
|
|
38
|
+
}, [modalRef, bodyClass]);
|
|
39
|
+
}
|
|
40
|
+
exports.useBodyScrollLock = useBodyScrollLock;
|