@navikt/ds-react 5.18.1 → 5.18.3
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/cjs/date/parts/DateWrapper.js +2 -2
- package/cjs/form/search/Search.js +1 -1
- package/cjs/modal/Modal.context.js +9 -0
- package/cjs/modal/Modal.js +3 -6
- package/cjs/modal/ModalHeader.js +2 -6
- package/cjs/popover/Popover.js +2 -2
- package/cjs/tooltip/Tooltip.js +3 -3
- package/cjs/util/create-context.js +9 -5
- package/esm/date/parts/DateWrapper.js +3 -3
- package/esm/date/parts/DateWrapper.js.map +1 -1
- package/esm/form/search/Search.js +1 -1
- package/esm/modal/Modal.context.d.ts +9 -0
- package/esm/modal/Modal.context.js +6 -0
- package/esm/modal/Modal.context.js.map +1 -0
- package/esm/modal/Modal.js +3 -6
- package/esm/modal/Modal.js.map +1 -1
- package/esm/modal/ModalHeader.js +3 -7
- package/esm/modal/ModalHeader.js.map +1 -1
- package/esm/popover/Popover.js +2 -2
- package/esm/popover/Popover.js.map +1 -1
- package/esm/tooltip/Tooltip.js +4 -4
- package/esm/tooltip/Tooltip.js.map +1 -1
- package/esm/util/create-context.d.ts +2 -5
- package/esm/util/create-context.js +10 -6
- package/esm/util/create-context.js.map +1 -1
- package/package.json +3 -3
- package/src/accordion/accordion.stories.tsx +121 -135
- package/src/chat/chat.stories.tsx +284 -206
- package/src/date/parts/DateWrapper.tsx +3 -3
- package/src/form/search/Search.tsx +3 -3
- package/src/modal/Modal.context.ts +13 -0
- package/src/modal/Modal.tsx +6 -8
- package/src/modal/ModalHeader.tsx +3 -7
- package/src/popover/Popover.tsx +2 -2
- package/src/table/stories/{table.stories.tsx → table-1.stories.tsx} +117 -94
- package/src/table/stories/{table-expandable.stories.tsx → table-2-expandable.stories.tsx} +6 -32
- package/src/table/stories/{table-async.stories.tsx → table-3-async.stories.tsx} +1 -1
- package/src/table/stories/tests/table.stories.tsx +3 -0
- package/src/tabs/Tabs.test.tsx +109 -0
- package/src/toggle-group/ToggleGroup.test.tsx +54 -0
- package/src/tooltip/Tooltip.tsx +4 -10
- package/src/typography/stories/bodylong.stories.tsx +47 -1
- package/src/typography/stories/bodyshort.stories.tsx +48 -2
- package/src/typography/stories/detail.stories.tsx +30 -1
- package/src/typography/stories/error-message.stories.tsx +32 -1
- package/src/typography/stories/heading.stories.tsx +30 -1
- package/src/typography/stories/label.stories.tsx +36 -1
- package/src/util/create-context.tsx +26 -15
- package/cjs/modal/ModalContext.js +0 -8
- package/esm/modal/ModalContext.d.ts +0 -7
- package/esm/modal/ModalContext.js +0 -3
- package/esm/modal/ModalContext.js.map +0 -1
- package/src/modal/ModalContext.ts +0 -7
|
@@ -31,13 +31,13 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
31
31
|
const react_1 = __importStar(require("react"));
|
|
32
32
|
const button_1 = require("../../button");
|
|
33
33
|
const modal_1 = require("../../modal");
|
|
34
|
-
const
|
|
34
|
+
const Modal_context_1 = require("../../modal/Modal.context");
|
|
35
35
|
const popover_1 = require("../../popover");
|
|
36
36
|
const hooks_1 = require("../../util/hooks");
|
|
37
37
|
const labels_1 = require("../utils/labels");
|
|
38
38
|
const DateWrapper = ({ open, children, onClose, anchor, locale, variant, popoverProps, }) => {
|
|
39
39
|
const modalRef = (0, react_1.useRef)(null);
|
|
40
|
-
const isInModal = (0,
|
|
40
|
+
const isInModal = (0, Modal_context_1.useModalContext)(false) !== undefined;
|
|
41
41
|
const hideModal = (0, hooks_1.useMedia)("screen and (min-width: 768px)", true) && !isInModal;
|
|
42
42
|
if (hideModal) {
|
|
43
43
|
return (react_1.default.createElement(popover_1.Popover, Object.assign({ arrow: false, anchorEl: anchor, open: open, onClose: onClose, placement: "bottom-start", role: "dialog", className: (0, clsx_1.default)("navds-date__popover", {
|
|
@@ -104,7 +104,7 @@ exports.Search = (0, react_1.forwardRef)((props, ref) => {
|
|
|
104
104
|
react_1.default.createElement("div", { className: "navds-search__wrapper" },
|
|
105
105
|
react_1.default.createElement("div", { className: "navds-search__wrapper-inner" },
|
|
106
106
|
variant === "simple" && (react_1.default.createElement(aksel_icons_1.MagnifyingGlassIcon, { "aria-hidden": true, className: "navds-search__search-icon" })),
|
|
107
|
-
react_1.default.createElement("input", Object.assign({ ref: mergedRef }, (0, util_1.omit)(rest, ["error", "errorId", "size", "readOnly"]), inputProps, { value: value !== null && value !== void 0 ? value : internalValue, onChange: (e) => handleChange(e.target.value), type: "search", role: role !== null && role !== void 0 ? role :
|
|
107
|
+
react_1.default.createElement("input", Object.assign({ ref: mergedRef }, (0, util_1.omit)(rest, ["error", "errorId", "size", "readOnly"]), inputProps, { value: value !== null && value !== void 0 ? value : internalValue, onChange: (e) => handleChange(e.target.value), type: "search", role: role !== null && role !== void 0 ? role : "searchbox", className: (0, clsx_1.default)(className, "navds-search__input", `navds-search__input--${variant}`, "navds-text-field__input", "navds-body-short", `navds-body-short--${size}`) }, (htmlSize ? { size: Number(htmlSize) } : {}))),
|
|
108
108
|
(value !== null && value !== void 0 ? value : internalValue) && clearButton && (react_1.default.createElement("button", { type: "button", onClick: (e) => handleClear({ trigger: "Click", event: e }), className: "navds-search__button-clear" },
|
|
109
109
|
react_1.default.createElement("span", { className: "navds-sr-only" }, clearButtonLabel ? clearButtonLabel : "Tøm"),
|
|
110
110
|
react_1.default.createElement(aksel_icons_1.XMarkIcon, { "aria-hidden": true })))),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.useModalContext = exports.ModalContextProvider = void 0;
|
|
5
|
+
const create_context_1 = require("../util/create-context");
|
|
6
|
+
_a = (0, create_context_1.createContext)({
|
|
7
|
+
name: "ModalContext",
|
|
8
|
+
errorMessage: "<Modal.Header> must be used within a <Modal>",
|
|
9
|
+
}), exports.ModalContextProvider = _a[0], exports.useModalContext = _a[1];
|
package/cjs/modal/Modal.js
CHANGED
|
@@ -48,8 +48,8 @@ const typography_1 = require("../typography");
|
|
|
48
48
|
const composeEventHandlers_1 = require("../util/composeEventHandlers");
|
|
49
49
|
const hooks_1 = require("../util/hooks");
|
|
50
50
|
const useMergeRefs_1 = require("../util/hooks/useMergeRefs");
|
|
51
|
+
const Modal_context_1 = require("./Modal.context");
|
|
51
52
|
const ModalBody_1 = __importDefault(require("./ModalBody"));
|
|
52
|
-
const ModalContext_1 = require("./ModalContext");
|
|
53
53
|
const ModalFooter_1 = __importDefault(require("./ModalFooter"));
|
|
54
54
|
const ModalHeader_1 = __importDefault(require("./ModalHeader"));
|
|
55
55
|
const ModalUtils_1 = require("./ModalUtils");
|
|
@@ -109,7 +109,7 @@ exports.Modal = (0, react_2.forwardRef)((_a, ref) => {
|
|
|
109
109
|
const rootElement = (_b = (0, provider_1.useProvider)()) === null || _b === void 0 ? void 0 : _b.rootElement;
|
|
110
110
|
const portalNode = (0, react_1.useFloatingPortalNode)({ root: rootElement });
|
|
111
111
|
const dateContext = (0, react_2.useContext)(context_1.DateContext);
|
|
112
|
-
const modalContext = (0,
|
|
112
|
+
const modalContext = (0, Modal_context_1.useModalContext)(false);
|
|
113
113
|
if (modalContext && !dateContext) {
|
|
114
114
|
console.error("Modals should not be nested");
|
|
115
115
|
}
|
|
@@ -171,10 +171,7 @@ exports.Modal = (0, react_2.forwardRef)((_a, ref) => {
|
|
|
171
171
|
const component = (
|
|
172
172
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
173
173
|
react_2.default.createElement("dialog", Object.assign({}, rest, { ref: mergedRef, className: mergedClassName, style: mergedStyle, onCancel: (0, composeEventHandlers_1.composeEventHandlers)(onCancel, handleModalCancel), onClick: (0, composeEventHandlers_1.composeEventHandlers)(onClick, handleModalClick), "aria-labelledby": mergedAriaLabelledBy }),
|
|
174
|
-
react_2.default.createElement(
|
|
175
|
-
closeHandler: (0, ModalUtils_1.getCloseHandler)(modalRef, header, onBeforeClose),
|
|
176
|
-
ref: modalRef,
|
|
177
|
-
} },
|
|
174
|
+
react_2.default.createElement(Modal_context_1.ModalContextProvider, { closeHandler: (0, ModalUtils_1.getCloseHandler)(modalRef, header, onBeforeClose), ref: modalRef },
|
|
178
175
|
header && (react_2.default.createElement(ModalHeader_1.default, null,
|
|
179
176
|
header.label && (react_2.default.createElement(typography_1.Detail, { className: "navds-modal__label" }, header.label)),
|
|
180
177
|
react_2.default.createElement(typography_1.Heading, { size: (_c = header.size) !== null && _c !== void 0 ? _c : "medium", level: "1", id: ariaLabelId },
|
package/cjs/modal/ModalHeader.js
CHANGED
|
@@ -41,14 +41,10 @@ const clsx_1 = __importDefault(require("clsx"));
|
|
|
41
41
|
const react_1 = __importStar(require("react"));
|
|
42
42
|
const aksel_icons_1 = require("@navikt/aksel-icons");
|
|
43
43
|
const button_1 = require("../button");
|
|
44
|
-
const
|
|
44
|
+
const Modal_context_1 = require("./Modal.context");
|
|
45
45
|
const ModalHeader = (0, react_1.forwardRef)((_a, ref) => {
|
|
46
46
|
var { children, className, closeButton = true } = _a, rest = __rest(_a, ["children", "className", "closeButton"]);
|
|
47
|
-
const context = (0,
|
|
48
|
-
if (context === null) {
|
|
49
|
-
console.error("<Modal.Header> has to be used within a <Modal>");
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
47
|
+
const context = (0, Modal_context_1.useModalContext)();
|
|
52
48
|
return (react_1.default.createElement("div", Object.assign({}, rest, { ref: ref, className: (0, clsx_1.default)("navds-modal__header", className) }),
|
|
53
49
|
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
50
|
children));
|
package/cjs/popover/Popover.js
CHANGED
|
@@ -42,7 +42,7 @@ const react_1 = require("@floating-ui/react");
|
|
|
42
42
|
const clsx_1 = __importDefault(require("clsx"));
|
|
43
43
|
const react_2 = __importStar(require("react"));
|
|
44
44
|
const context_1 = require("../date/context");
|
|
45
|
-
const
|
|
45
|
+
const Modal_context_1 = require("../modal/Modal.context");
|
|
46
46
|
const hooks_1 = require("../util/hooks");
|
|
47
47
|
const useMergeRefs_1 = require("../util/hooks/useMergeRefs");
|
|
48
48
|
const PopoverContent_1 = __importDefault(require("./PopoverContent"));
|
|
@@ -69,7 +69,7 @@ const PopoverContent_1 = __importDefault(require("./PopoverContent"));
|
|
|
69
69
|
exports.Popover = (0, react_2.forwardRef)((_a, ref) => {
|
|
70
70
|
var { className, children, anchorEl, arrow = true, open, onClose, placement = "top", offset, strategy: userStrategy, flip: _flip = true } = _a, rest = __rest(_a, ["className", "children", "anchorEl", "arrow", "open", "onClose", "placement", "offset", "strategy", "flip"]);
|
|
71
71
|
const arrowRef = (0, react_2.useRef)(null);
|
|
72
|
-
const isInModal = (0,
|
|
72
|
+
const isInModal = (0, Modal_context_1.useModalContext)(false) !== undefined;
|
|
73
73
|
const isInDatepicker = (0, react_2.useContext)(context_1.DateContext) !== null;
|
|
74
74
|
const chosenStrategy = userStrategy !== null && userStrategy !== void 0 ? userStrategy : (isInModal ? "fixed" : "absolute");
|
|
75
75
|
const chosenFlip = isInDatepicker ? false : _flip;
|
package/cjs/tooltip/Tooltip.js
CHANGED
|
@@ -41,7 +41,7 @@ exports.Tooltip = void 0;
|
|
|
41
41
|
const react_1 = require("@floating-ui/react");
|
|
42
42
|
const clsx_1 = __importDefault(require("clsx"));
|
|
43
43
|
const react_2 = __importStar(require("react"));
|
|
44
|
-
const
|
|
44
|
+
const Modal_context_1 = require("../modal/Modal.context");
|
|
45
45
|
const Portal_1 = __importDefault(require("../overlays/portal/Portal"));
|
|
46
46
|
const typography_1 = require("../typography");
|
|
47
47
|
const hooks_1 = require("../util/hooks");
|
|
@@ -68,7 +68,7 @@ exports.Tooltip = (0, react_2.forwardRef)((_a, ref) => {
|
|
|
68
68
|
onChange: onOpenChange,
|
|
69
69
|
});
|
|
70
70
|
const arrowRef = (0, react_2.useRef)(null);
|
|
71
|
-
const modalContext = (0,
|
|
71
|
+
const modalContext = (0, Modal_context_1.useModalContext)(false);
|
|
72
72
|
const rootElement = modalContext ? modalContext.ref.current : undefined;
|
|
73
73
|
const { x, y, strategy, context, placement, middlewareData: { arrow: { x: arrowX, y: arrowY } = {}, hide: { referenceHidden } = {}, }, refs, } = (0, react_1.useFloating)({
|
|
74
74
|
placement: _placement,
|
|
@@ -110,7 +110,7 @@ exports.Tooltip = (0, react_2.forwardRef)((_a, ref) => {
|
|
|
110
110
|
(0, react_2.cloneElement)(children, getReferenceProps(Object.assign(Object.assign({}, children.props), { ref: childMergedRef, "aria-describedby": _open
|
|
111
111
|
? (0, clsx_1.default)(ariaId, children === null || children === void 0 ? void 0 : children.props["aria-describedby"])
|
|
112
112
|
: children === null || children === void 0 ? void 0 : children.props["aria-describedby"] }))),
|
|
113
|
-
react_2.default.createElement(Portal_1.default, { rootElement: rootElement }, _open && (react_2.default.createElement("div", Object.assign({}, getFloatingProps(Object.assign(Object.assign({}, rest), { ref: mergedRef, style: {
|
|
113
|
+
react_2.default.createElement(Portal_1.default, { rootElement: rootElement, asChild: true }, _open && (react_2.default.createElement("div", Object.assign({}, getFloatingProps(Object.assign(Object.assign({}, rest), { ref: mergedRef, style: {
|
|
114
114
|
position: strategy,
|
|
115
115
|
top: y !== null && y !== void 0 ? y : 0,
|
|
116
116
|
left: x !== null && x !== void 0 ? x : 0,
|
|
@@ -48,17 +48,21 @@ function getErrorMessage(hook, provider) {
|
|
|
48
48
|
function createContext(options = {}) {
|
|
49
49
|
const { name, hookName = "useContext", providerName = "Provider", errorMessage, defaultValue, } = options;
|
|
50
50
|
const Context = (0, react_1.createContext)(defaultValue);
|
|
51
|
-
|
|
51
|
+
/**
|
|
52
|
+
* We use forwardRef to allow `ref` to be used as a regular context value
|
|
53
|
+
* @see https://reactjs.org/docs/forwarding-refs.html#forwarding-refs-to-dom-components
|
|
54
|
+
*/
|
|
55
|
+
const Provider = (0, react_1.forwardRef)((_a, ref) => {
|
|
52
56
|
var { children } = _a, context = __rest(_a, ["children"]);
|
|
53
57
|
// Only re-memoize when prop values change
|
|
54
58
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
59
|
const value = react_1.default.useMemo(() => context, Object.values(context));
|
|
56
|
-
return react_1.default.createElement(Context.Provider, { value: value }, children);
|
|
57
|
-
}
|
|
58
|
-
function useContext() {
|
|
60
|
+
return (react_1.default.createElement(Context.Provider, { value: ref ? Object.assign(Object.assign({}, value), { ref }) : value }, children));
|
|
61
|
+
});
|
|
62
|
+
function useContext(strict = true) {
|
|
59
63
|
var _a;
|
|
60
64
|
const context = (0, react_1.useContext)(Context);
|
|
61
|
-
if (!context) {
|
|
65
|
+
if (!context && strict) {
|
|
62
66
|
const error = new Error(errorMessage !== null && errorMessage !== void 0 ? errorMessage : getErrorMessage(hookName, providerName));
|
|
63
67
|
error.name = "ContextError";
|
|
64
68
|
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, error, useContext);
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import cl from "clsx";
|
|
2
|
-
import React, {
|
|
2
|
+
import React, { useRef } from "react";
|
|
3
3
|
import { Button } from "../../button";
|
|
4
4
|
import { Modal } from "../../modal";
|
|
5
|
-
import {
|
|
5
|
+
import { useModalContext } from "../../modal/Modal.context";
|
|
6
6
|
import { Popover } from "../../popover";
|
|
7
7
|
import { useMedia } from "../../util/hooks";
|
|
8
8
|
import { modalCloseButtonLabel, modalLabel } from "../utils/labels";
|
|
9
9
|
export const DateWrapper = ({ open, children, onClose, anchor, locale, variant, popoverProps, }) => {
|
|
10
10
|
const modalRef = useRef(null);
|
|
11
|
-
const isInModal =
|
|
11
|
+
const isInModal = useModalContext(false) !== undefined;
|
|
12
12
|
const hideModal = useMedia("screen and (min-width: 768px)", true) && !isInModal;
|
|
13
13
|
if (hideModal) {
|
|
14
14
|
return (React.createElement(Popover, Object.assign({ arrow: false, anchorEl: anchor, open: open, onClose: onClose, placement: "bottom-start", role: "dialog", className: cl("navds-date__popover", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateWrapper.js","sourceRoot":"","sources":["../../../src/date/parts/DateWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,
|
|
1
|
+
{"version":3,"file":"DateWrapper.js","sourceRoot":"","sources":["../../../src/date/parts/DateWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAepE,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAC1B,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,MAAM,EACN,MAAM,EACN,OAAO,EACP,YAAY,GACK,EAAE,EAAE;IACrB,MAAM,QAAQ,GAAG,MAAM,CAAoB,IAAI,CAAC,CAAC;IACjD,MAAM,SAAS,GAAG,eAAe,CAAC,KAAK,CAAC,KAAK,SAAS,CAAC;IACvD,MAAM,SAAS,GACb,QAAQ,CAAC,+BAA+B,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;IAEhE,IAAI,SAAS,EAAE,CAAC;QACd,OAAO,CACL,oBAAC,OAAO,kBACN,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,cAAc,EACxB,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE;gBACnC,YAAY,EAAE,OAAO,KAAK,OAAO;aAClC,CAAC,EACF,IAAI,EAAE,KAAK,IACP,YAAY,GAEf,QAAQ,CACD,CACX,CAAC;IACJ,CAAC;IACD,OAAO,CACL,oBAAC,KAAK,IACJ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;YACjB,KAAK,CAAC,eAAe,EAAE,CAAC;YACxB,OAAO,EAAE,CAAC;QACZ,CAAC,gBACW,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,EACvC,SAAS,EAAE,EAAE,CAAC,mBAAmB,EAAE;YACjC,0BAA0B,EAAE,SAAS;YACrC,YAAY,EAAE,OAAO,KAAK,OAAO;SAClC,CAAC,EACF,oBAAoB;QAEpB,6BAAK,SAAS,EAAC,wBAAwB;YACpC,QAAQ;YACT,oBAAC,MAAM,IACL,OAAO,EAAC,UAAU,EAClB,OAAO,EAAE,GAAG,EAAE,WAAC,OAAA,MAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,0CAAE,KAAK,EAAE,CAAA,EAAA,EACzC,IAAI,EAAC,OAAO,EACZ,IAAI,EAAC,QAAQ,IAEZ,qBAAqB,CAAC,MAAM,CAAC,CACvB,CACL,CACA,CACT,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -75,7 +75,7 @@ export const Search = forwardRef((props, ref) => {
|
|
|
75
75
|
React.createElement("div", { className: "navds-search__wrapper" },
|
|
76
76
|
React.createElement("div", { className: "navds-search__wrapper-inner" },
|
|
77
77
|
variant === "simple" && (React.createElement(MagnifyingGlassIcon, { "aria-hidden": true, className: "navds-search__search-icon" })),
|
|
78
|
-
React.createElement("input", Object.assign({ ref: mergedRef }, omit(rest, ["error", "errorId", "size", "readOnly"]), inputProps, { value: value !== null && value !== void 0 ? value : internalValue, onChange: (e) => handleChange(e.target.value), type: "search", role: role !== null && role !== void 0 ? role :
|
|
78
|
+
React.createElement("input", Object.assign({ ref: mergedRef }, omit(rest, ["error", "errorId", "size", "readOnly"]), inputProps, { value: value !== null && value !== void 0 ? value : internalValue, onChange: (e) => handleChange(e.target.value), type: "search", role: role !== null && role !== void 0 ? role : "searchbox", className: cl(className, "navds-search__input", `navds-search__input--${variant}`, "navds-text-field__input", "navds-body-short", `navds-body-short--${size}`) }, (htmlSize ? { size: Number(htmlSize) } : {}))),
|
|
79
79
|
(value !== null && value !== void 0 ? value : internalValue) && clearButton && (React.createElement("button", { type: "button", onClick: (e) => handleClear({ trigger: "Click", event: e }), className: "navds-search__button-clear" },
|
|
80
80
|
React.createElement("span", { className: "navds-sr-only" }, clearButtonLabel ? clearButtonLabel : "Tøm"),
|
|
81
81
|
React.createElement(XMarkIcon, { "aria-hidden": true })))),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ModalContextProps {
|
|
3
|
+
closeHandler?: React.MouseEventHandler<HTMLButtonElement>;
|
|
4
|
+
ref: React.RefObject<HTMLDialogElement>;
|
|
5
|
+
}
|
|
6
|
+
export declare const ModalContextProvider: React.ForwardRefExoticComponent<Omit<ModalContextProps & {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}, "ref"> & React.RefAttributes<unknown>>, useModalContext: <S extends boolean = true>(strict?: S) => S extends true ? ModalContextProps : ModalContextProps | undefined;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Modal.context.js","sourceRoot":"","sources":["../../src/modal/Modal.context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAOvD,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,eAAe,CAAC,GAClD,aAAa,CAAoB;IAC/B,IAAI,EAAE,cAAc;IACpB,YAAY,EAAE,8CAA8C;CAC7D,CAAC,CAAC"}
|
package/esm/modal/Modal.js
CHANGED
|
@@ -19,8 +19,8 @@ import { Detail, Heading } from "../typography";
|
|
|
19
19
|
import { composeEventHandlers } from "../util/composeEventHandlers";
|
|
20
20
|
import { useId } from "../util/hooks";
|
|
21
21
|
import { useMergeRefs } from "../util/hooks/useMergeRefs";
|
|
22
|
+
import { ModalContextProvider, useModalContext } from "./Modal.context";
|
|
22
23
|
import ModalBody from "./ModalBody";
|
|
23
|
-
import { ModalContext } from "./ModalContext";
|
|
24
24
|
import ModalFooter from "./ModalFooter";
|
|
25
25
|
import ModalHeader from "./ModalHeader";
|
|
26
26
|
import { getCloseHandler, useBodyScrollLock } from "./ModalUtils";
|
|
@@ -80,7 +80,7 @@ export const Modal = forwardRef((_a, ref) => {
|
|
|
80
80
|
const rootElement = (_b = useProvider()) === null || _b === void 0 ? void 0 : _b.rootElement;
|
|
81
81
|
const portalNode = useFloatingPortalNode({ root: rootElement });
|
|
82
82
|
const dateContext = useContext(DateContext);
|
|
83
|
-
const modalContext =
|
|
83
|
+
const modalContext = useModalContext(false);
|
|
84
84
|
if (modalContext && !dateContext) {
|
|
85
85
|
console.error("Modals should not be nested");
|
|
86
86
|
}
|
|
@@ -142,10 +142,7 @@ export const Modal = forwardRef((_a, ref) => {
|
|
|
142
142
|
const component = (
|
|
143
143
|
// eslint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions
|
|
144
144
|
React.createElement("dialog", Object.assign({}, rest, { ref: mergedRef, className: mergedClassName, style: mergedStyle, onCancel: composeEventHandlers(onCancel, handleModalCancel), onClick: composeEventHandlers(onClick, handleModalClick), "aria-labelledby": mergedAriaLabelledBy }),
|
|
145
|
-
React.createElement(
|
|
146
|
-
closeHandler: getCloseHandler(modalRef, header, onBeforeClose),
|
|
147
|
-
ref: modalRef,
|
|
148
|
-
} },
|
|
145
|
+
React.createElement(ModalContextProvider, { closeHandler: getCloseHandler(modalRef, header, onBeforeClose), ref: modalRef },
|
|
149
146
|
header && (React.createElement(ModalHeader, null,
|
|
150
147
|
header.label && (React.createElement(Detail, { className: "navds-modal__label" }, header.label)),
|
|
151
148
|
React.createElement(Heading, { size: (_c = header.size) !== null && _c !== void 0 ? _c : "medium", level: "1", id: ariaLabelId },
|
package/esm/modal/Modal.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/modal/Modal.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,
|
|
1
|
+
{"version":3,"file":"Modal.js","sourceRoot":"","sources":["../../src/modal/Modal.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACzE,OAAO,EAAE,YAAY,EAAE,MAAM,WAA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AoB,CAAC,QAAQ,EAAE,iBAAiB,CAAC,EAC3D,OAAO,EAAE,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,CAAC,qBACvC,oBAAoB;QAErC,oBAAC,oBAAoB,IACnB,YAAY,EAAE,eAAe,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,CAAC,EAC9D,GAAG,EAAE,QAAQ;YAEZ,MAAM,IAAI,CACT,oBAAC,WAAW;gBACT,MAAM,CAAC,KAAK,IAAI,CACf,oBAAC,MAAM,IAAC,SAAS,EAAC,oBAAoB,IAAE,MAAM,CAAC,KAAK,CAAU,CAC/D;gBACD,oBAAC,OAAO,IACN,IAAI,EAAE,MAAA,MAAM,CAAC,IAAI,mCAAI,QAAQ,EAC7B,KAAK,EAAC,GAAG,EACT,EAAE,EAAE,WAAW;oBAEf,8BAAM,SAAS,EAAC,0BAA0B,IAAE,MAAM,CAAC,IAAI,CAAQ;oBAC9D,MAAM,CAAC,OAAO,CACP,CACE,CACf;YAEA,QAAQ,CACY,CAChB,CACV,CAAC;IAEF,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,UAAU;YAAE,OAAO,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CACgB,CAAC;AAEpB,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;AAC3B,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;AACvB,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC;AAE3B,eAAe,KAAK,CAAC"}
|
package/esm/modal/ModalHeader.js
CHANGED
|
@@ -10,17 +10,13 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import cl from "clsx";
|
|
13
|
-
import React, { forwardRef
|
|
13
|
+
import React, { forwardRef } from "react";
|
|
14
14
|
import { XMarkIcon } from "@navikt/aksel-icons";
|
|
15
15
|
import { Button } from "../button";
|
|
16
|
-
import {
|
|
16
|
+
import { useModalContext } from "./Modal.context";
|
|
17
17
|
const ModalHeader = forwardRef((_a, ref) => {
|
|
18
18
|
var { children, className, closeButton = true } = _a, rest = __rest(_a, ["children", "className", "closeButton"]);
|
|
19
|
-
const context =
|
|
20
|
-
if (context === null) {
|
|
21
|
-
console.error("<Modal.Header> has to be used within a <Modal>");
|
|
22
|
-
return null;
|
|
23
|
-
}
|
|
19
|
+
const context = useModalContext();
|
|
24
20
|
return (React.createElement("div", Object.assign({}, rest, { ref: ref, className: cl("navds-modal__header", className) }),
|
|
25
21
|
context.closeHandler && closeButton && (React.createElement(Button, { type: "button", className: "navds-modal__button", size: "small", variant: "tertiary-neutral", onClick: context.closeHandler, icon: React.createElement(XMarkIcon, { title: "Lukk modalvindu" }) })),
|
|
26
22
|
children));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModalHeader.js","sourceRoot":"","sources":["../../src/modal/ModalHeader.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"ModalHeader.js","sourceRoot":"","sources":["../../src/modal/ModalHeader.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAWlD,MAAM,WAAW,GAAG,UAAU,CAC5B,CAAC,EAAoD,EAAE,GAAG,EAAE,EAAE;QAA7D,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,GAAG,IAAI,OAAW,EAAN,IAAI,cAAlD,wCAAoD,CAAF;IACjD,MAAM,OAAO,GAAG,eAAe,EAAE,CAAC;IAElC,OAAO,CACL,6CAAS,IAAI,IAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,qBAAqB,EAAE,SAAS,CAAC;QACrE,OAAO,CAAC,YAAY,IAAI,WAAW,IAAI,CACtC,oBAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,qBAAqB,EAC/B,IAAI,EAAC,OAAO,EACZ,OAAO,EAAC,kBAAkB,EAC1B,OAAO,EAAE,OAAO,CAAC,YAAY,EAC7B,IAAI,EAAE,oBAAC,SAAS,IAAC,KAAK,EAAC,iBAAiB,GAAG,GAC3C,CACH;QACA,QAAQ,CACL,CACP,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/esm/popover/Popover.js
CHANGED
|
@@ -13,7 +13,7 @@ import { autoUpdate, arrow as flArrow, offset as flOffset, flip, shift, useClick
|
|
|
13
13
|
import cl from "clsx";
|
|
14
14
|
import React, { forwardRef, useCallback, useContext, useRef, } from "react";
|
|
15
15
|
import { DateContext } from "../date/context";
|
|
16
|
-
import {
|
|
16
|
+
import { useModalContext } from "../modal/Modal.context";
|
|
17
17
|
import { useClientLayoutEffect, useEventListener } from "../util/hooks";
|
|
18
18
|
import { useMergeRefs } from "../util/hooks/useMergeRefs";
|
|
19
19
|
import PopoverContent from "./PopoverContent";
|
|
@@ -40,7 +40,7 @@ import PopoverContent from "./PopoverContent";
|
|
|
40
40
|
export const Popover = forwardRef((_a, ref) => {
|
|
41
41
|
var { className, children, anchorEl, arrow = true, open, onClose, placement = "top", offset, strategy: userStrategy, flip: _flip = true } = _a, rest = __rest(_a, ["className", "children", "anchorEl", "arrow", "open", "onClose", "placement", "offset", "strategy", "flip"]);
|
|
42
42
|
const arrowRef = useRef(null);
|
|
43
|
-
const isInModal =
|
|
43
|
+
const isInModal = useModalContext(false) !== undefined;
|
|
44
44
|
const isInDatepicker = useContext(DateContext) !== null;
|
|
45
45
|
const chosenStrategy = userStrategy !== null && userStrategy !== void 0 ? userStrategy : (isInModal ? "fixed" : "absolute");
|
|
46
46
|
const chosenFlip = isInDatepicker ? false : _flip;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../src/popover/Popover.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EACL,UAAU,EACV,KAAK,IAAI,OAAO,EAChB,MAAM,IAAI,QAAQ,EAClB,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EACX,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAEZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Popover.js","sourceRoot":"","sources":["../../src/popover/Popover.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EACL,UAAU,EACV,KAAK,IAAI,OAAO,EAChB,MAAM,IAAI,QAAQ,EAClB,IAAI,EACJ,KAAK,EACL,QAAQ,EACR,UAAU,EACV,WAAW,EACX,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,EAEZ,UAAU,EACV,WAAW,EACX,UAAU,EACV,MAAM,GACP,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,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E,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACxC,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GACvC,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAEpD,SAAS,EAAC,sBAAsB,GAChC,CACH,CACG,CACP,CAAC;AACJ,CAAC,CACkB,CAAC;AAEtB,OAAO,CAAC,OAAO,GAAG,cAAc,CAAC;AAEjC,eAAe,OAAO,CAAC"}
|
package/esm/tooltip/Tooltip.js
CHANGED
|
@@ -11,8 +11,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
};
|
|
12
12
|
import { autoUpdate, arrow as flArrow, flip, offset, safePolygon, shift, useDismiss, useFloating, useFocus, useHover, useInteractions, } from "@floating-ui/react";
|
|
13
13
|
import cl from "clsx";
|
|
14
|
-
import React, { cloneElement, forwardRef,
|
|
15
|
-
import {
|
|
14
|
+
import React, { cloneElement, forwardRef, useRef } from "react";
|
|
15
|
+
import { useModalContext } from "../modal/Modal.context";
|
|
16
16
|
import Portal from "../overlays/portal/Portal";
|
|
17
17
|
import { Detail } from "../typography";
|
|
18
18
|
import { useId } from "../util/hooks";
|
|
@@ -39,7 +39,7 @@ export const Tooltip = forwardRef((_a, ref) => {
|
|
|
39
39
|
onChange: onOpenChange,
|
|
40
40
|
});
|
|
41
41
|
const arrowRef = useRef(null);
|
|
42
|
-
const modalContext =
|
|
42
|
+
const modalContext = useModalContext(false);
|
|
43
43
|
const rootElement = modalContext ? modalContext.ref.current : undefined;
|
|
44
44
|
const { x, y, strategy, context, placement, middlewareData: { arrow: { x: arrowX, y: arrowY } = {}, hide: { referenceHidden } = {}, }, refs, } = useFloating({
|
|
45
45
|
placement: _placement,
|
|
@@ -81,7 +81,7 @@ export const Tooltip = forwardRef((_a, ref) => {
|
|
|
81
81
|
cloneElement(children, getReferenceProps(Object.assign(Object.assign({}, children.props), { ref: childMergedRef, "aria-describedby": _open
|
|
82
82
|
? cl(ariaId, children === null || children === void 0 ? void 0 : children.props["aria-describedby"])
|
|
83
83
|
: children === null || children === void 0 ? void 0 : children.props["aria-describedby"] }))),
|
|
84
|
-
React.createElement(Portal, { rootElement: rootElement }, _open && (React.createElement("div", Object.assign({}, getFloatingProps(Object.assign(Object.assign({}, rest), { ref: mergedRef, style: {
|
|
84
|
+
React.createElement(Portal, { rootElement: rootElement, asChild: true }, _open && (React.createElement("div", Object.assign({}, getFloatingProps(Object.assign(Object.assign({}, rest), { ref: mergedRef, style: {
|
|
85
85
|
position: strategy,
|
|
86
86
|
top: y !== null && y !== void 0 ? y : 0,
|
|
87
87
|
left: x !== null && x !== void 0 ? x : 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EACL,UAAU,EACV,KAAK,IAAI,OAAO,EAChB,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../src/tooltip/Tooltip.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,EACL,UAAU,EACV,KAAK,IAAI,OAAO,EAChB,IAAI,EACJ,MAAM,EACN,WAAW,EACX,KAAK,EACL,UAAU,EACV,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,MAAM,MAAM,CAAC;AACtB,OAAO,KAAK,EAAE,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|
16
16
|
children: React.ReactNode;
|
|
17
17
|
};
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
() => T
|
|
21
|
-
];
|
|
22
|
-
export declare function createContext<T>(options?: CreateContextOptions<T>): CreateContextReturn<T>;
|
|
18
|
+
export declare function createContext<T>(options?: CreateContextOptions<T>): readonly [React.ForwardRefExoticComponent<React.PropsWithoutRef<ProviderProps<T>> & React.RefAttributes<unknown>>, <S extends boolean = true>(strict?: S) => Context<S, T>];
|
|
19
|
+
type Context<S, T> = S extends true ? T : T | undefined;
|
|
23
20
|
export {};
|
|
@@ -15,24 +15,28 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
15
15
|
* - https://github.com/radix-ui/primitives/blob/main/packages/react/context/src/createContext.tsx
|
|
16
16
|
* - https://github.com/chakra-ui/chakra-ui/blob/5ec0be610b5a69afba01a9c22365155c1b519136/packages/hooks/context/src/index.ts
|
|
17
17
|
*/
|
|
18
|
-
import React, { createContext as createReactContext, useContext as useReactContext, } from "react";
|
|
18
|
+
import React, { createContext as createReactContext, forwardRef, useContext as useReactContext, } from "react";
|
|
19
19
|
function getErrorMessage(hook, provider) {
|
|
20
20
|
return `${hook} returned \`undefined\`. Seems you forgot to wrap component within ${provider}`;
|
|
21
21
|
}
|
|
22
22
|
export function createContext(options = {}) {
|
|
23
23
|
const { name, hookName = "useContext", providerName = "Provider", errorMessage, defaultValue, } = options;
|
|
24
24
|
const Context = createReactContext(defaultValue);
|
|
25
|
-
|
|
25
|
+
/**
|
|
26
|
+
* We use forwardRef to allow `ref` to be used as a regular context value
|
|
27
|
+
* @see https://reactjs.org/docs/forwarding-refs.html#forwarding-refs-to-dom-components
|
|
28
|
+
*/
|
|
29
|
+
const Provider = forwardRef((_a, ref) => {
|
|
26
30
|
var { children } = _a, context = __rest(_a, ["children"]);
|
|
27
31
|
// Only re-memoize when prop values change
|
|
28
32
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
33
|
const value = React.useMemo(() => context, Object.values(context));
|
|
30
|
-
return React.createElement(Context.Provider, { value: value }, children);
|
|
31
|
-
}
|
|
32
|
-
function useContext() {
|
|
34
|
+
return (React.createElement(Context.Provider, { value: ref ? Object.assign(Object.assign({}, value), { ref }) : value }, children));
|
|
35
|
+
});
|
|
36
|
+
function useContext(strict = true) {
|
|
33
37
|
var _a;
|
|
34
38
|
const context = useReactContext(Context);
|
|
35
|
-
if (!context) {
|
|
39
|
+
if (!context && strict) {
|
|
36
40
|
const error = new Error(errorMessage !== null && errorMessage !== void 0 ? errorMessage : getErrorMessage(hookName, providerName));
|
|
37
41
|
error.name = "ContextError";
|
|
38
42
|
(_a = Error.captureStackTrace) === null || _a === void 0 ? void 0 : _a.call(Error, error, useContext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-context.js","sourceRoot":"","sources":["../../src/util/create-context.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,EACZ,aAAa,IAAI,kBAAkB,EACnC,UAAU,IAAI,eAAe,GAC9B,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"create-context.js","sourceRoot":"","sources":["../../src/util/create-context.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,EACZ,aAAa,IAAI,kBAAkB,EACnC,UAAU,EACV,UAAU,IAAI,eAAe,GAC9B,MAAM,OAAO,CAAC;AAYf,SAAS,eAAe,CAAC,IAAY,EAAE,QAAgB;IACrD,OAAO,GAAG,IAAI,sEAAsE,QAAQ,EAAE,CAAC;AACjG,CAAC;AAED,MAAM,UAAU,aAAa,CAAI,UAAmC,EAAE;IACpE,MAAM,EACJ,IAAI,EACJ,QAAQ,GAAG,YAAY,EACvB,YAAY,GAAG,UAAU,EACzB,YAAY,EACZ,YAAY,GACb,GAAG,OAAO,CAAC;IAEZ,MAAM,OAAO,GAAG,kBAAkB,CAAgB,YAAY,CAAC,CAAC;IAEhE;;;OAGG;IACH,MAAM,QAAQ,GAAG,UAAU,CACzB,CAAC,EAA0C,EAAE,GAAG,EAAE,EAAE;YAAnD,EAAE,QAAQ,OAAgC,EAA3B,OAAO,cAAtB,YAAwB,CAAF;QACrB,0CAA0C;QAC1C,uDAAuD;QACvD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAM,CAAC;QAExE,OAAO,CACL,oBAAC,OAAO,CAAC,QAAQ,IAAC,KAAK,EAAE,GAAG,CAAC,CAAC,iCAAM,KAAK,KAAE,GAAG,IAAG,CAAC,CAAC,KAAK,IACrD,QAAQ,CACQ,CACpB,CAAC;IACJ,CAAC,CACF,CAAC;IAEF,SAAS,UAAU,CACjB,SAAY,IAAS;;QAErB,MAAM,OAAO,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;QAEzC,IAAI,CAAC,OAAO,IAAI,MAAM,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,IAAI,KAAK,CACrB,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,eAAe,CAAC,QAAQ,EAAE,YAAY,CAAC,CACxD,CAAC;YACF,KAAK,CAAC,IAAI,GAAG,cAAc,CAAC;YAC5B,MAAA,KAAK,CAAC,iBAAiB,sDAAG,KAAK,EAAE,UAAU,CAAC,CAAC;YAC7C,MAAM,KAAK,CAAC;QACd,CAAC;QAED,OAAO,OAAwB,CAAC;IAClC,CAAC;IAED,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAE3B,OAAO,CAAC,QAAQ,EAAE,UAAU,CAAU,CAAC;AACzC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navikt/ds-react",
|
|
3
|
-
"version": "5.18.
|
|
3
|
+
"version": "5.18.3",
|
|
4
4
|
"description": "Aksel react-components for NAV designsystem",
|
|
5
5
|
"author": "Aksel | NAV designsystem team",
|
|
6
6
|
"license": "MIT",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@floating-ui/react": "0.25.4",
|
|
41
|
-
"@navikt/aksel-icons": "^5.18.
|
|
42
|
-
"@navikt/ds-tokens": "^5.18.
|
|
41
|
+
"@navikt/aksel-icons": "^5.18.3",
|
|
42
|
+
"@navikt/ds-tokens": "^5.18.3",
|
|
43
43
|
"@radix-ui/react-tabs": "1.0.0",
|
|
44
44
|
"@radix-ui/react-toggle-group": "1.0.0",
|
|
45
45
|
"clsx": "^1.2.1",
|