@norges-domstoler/dds-components 0.0.0-dev-20260319072239 → 0.0.0-dev-20260319084855
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/dist/index.css +3 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +29 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +112 -104
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -3860,7 +3860,7 @@ type CookieBannerProps = BaseComponentPropsWithChildren<HTMLDivElement, {
|
|
|
3860
3860
|
/**Brekkpunkt for sammentrukket variant; Brukes på siden med detaljer om informasjonskapsler. */
|
|
3861
3861
|
collapsedBreakpoint?: Breakpoint;
|
|
3862
3862
|
} & Pick<ResponsiveProps, 'position' | 'top' | 'bottom' | 'left' | 'right' | 'width' | 'maxHeight'>>;
|
|
3863
|
-
declare function CookieBanner({ headerText, description, buttons, checkboxes, id, className, style, htmlProps, maxHeight, width, children, collapsedBreakpoint, ...rest }: CookieBannerProps): react_jsx_runtime.JSX.Element;
|
|
3863
|
+
declare function CookieBanner({ headerText, description, buttons, checkboxes, id, className, style, htmlProps, maxHeight, width, children, collapsedBreakpoint, ref, ...rest }: CookieBannerProps): react_jsx_runtime.JSX.Element;
|
|
3864
3864
|
declare namespace CookieBanner {
|
|
3865
3865
|
var displayName: string;
|
|
3866
3866
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3860,7 +3860,7 @@ type CookieBannerProps = BaseComponentPropsWithChildren<HTMLDivElement, {
|
|
|
3860
3860
|
/**Brekkpunkt for sammentrukket variant; Brukes på siden med detaljer om informasjonskapsler. */
|
|
3861
3861
|
collapsedBreakpoint?: Breakpoint;
|
|
3862
3862
|
} & Pick<ResponsiveProps, 'position' | 'top' | 'bottom' | 'left' | 'right' | 'width' | 'maxHeight'>>;
|
|
3863
|
-
declare function CookieBanner({ headerText, description, buttons, checkboxes, id, className, style, htmlProps, maxHeight, width, children, collapsedBreakpoint, ...rest }: CookieBannerProps): react_jsx_runtime.JSX.Element;
|
|
3863
|
+
declare function CookieBanner({ headerText, description, buttons, checkboxes, id, className, style, htmlProps, maxHeight, width, children, collapsedBreakpoint, ref, ...rest }: CookieBannerProps): react_jsx_runtime.JSX.Element;
|
|
3864
3864
|
declare namespace CookieBanner {
|
|
3865
3865
|
var displayName: string;
|
|
3866
3866
|
}
|
package/dist/index.js
CHANGED
|
@@ -878,36 +878,38 @@ function useElementHeight(element) {
|
|
|
878
878
|
|
|
879
879
|
// src/hooks/useFocusTrap/useFocusTrap.tsx
|
|
880
880
|
function useFocusTrap(active, initialFocusRef = void 0) {
|
|
881
|
-
const
|
|
882
|
-
(0, import_react5.
|
|
881
|
+
const containerRef = (0, import_react5.useRef)(null);
|
|
882
|
+
(0, import_react5.useLayoutEffect)(() => {
|
|
883
|
+
const container2 = containerRef.current;
|
|
884
|
+
if (!active || !container2) return;
|
|
885
|
+
if (initialFocusRef == null ? void 0 : initialFocusRef.current) {
|
|
886
|
+
initialFocusRef.current.focus();
|
|
887
|
+
} else {
|
|
888
|
+
container2.tabIndex = container2.tabIndex || -1;
|
|
889
|
+
container2.focus();
|
|
890
|
+
}
|
|
883
891
|
function handleFocus(e) {
|
|
884
|
-
if (e.key !== "Tab"
|
|
885
|
-
const
|
|
886
|
-
|
|
887
|
-
const
|
|
888
|
-
|
|
889
|
-
|
|
892
|
+
if (e.key !== "Tab") return;
|
|
893
|
+
const focusableEls = getFocusableElements(containerRef);
|
|
894
|
+
if (focusableEls.length < 1) return;
|
|
895
|
+
const firstEl = focusableEls[0];
|
|
896
|
+
const lastEl = focusableEls[focusableEls.length - 1];
|
|
897
|
+
const activeEl = document.activeElement;
|
|
898
|
+
if (!e.shiftKey && activeEl === lastEl) {
|
|
899
|
+
firstEl.focus();
|
|
890
900
|
e.preventDefault();
|
|
891
901
|
}
|
|
892
|
-
if (e.shiftKey &&
|
|
893
|
-
|
|
902
|
+
if (e.shiftKey && activeEl === firstEl) {
|
|
903
|
+
lastEl.focus();
|
|
894
904
|
e.preventDefault();
|
|
895
905
|
}
|
|
896
906
|
}
|
|
897
|
-
|
|
898
|
-
if (element && active) {
|
|
899
|
-
if (initialFocusRef == null ? void 0 : initialFocusRef.current) {
|
|
900
|
-
initialFocusRef.current.focus();
|
|
901
|
-
} else {
|
|
902
|
-
element.focus();
|
|
903
|
-
element.addEventListener("keydown", handleFocus);
|
|
904
|
-
}
|
|
905
|
-
}
|
|
907
|
+
document.addEventListener("keydown", handleFocus);
|
|
906
908
|
return () => {
|
|
907
|
-
|
|
909
|
+
document.removeEventListener("keydown", handleFocus);
|
|
908
910
|
};
|
|
909
911
|
}, [active]);
|
|
910
|
-
return
|
|
912
|
+
return containerRef;
|
|
911
913
|
}
|
|
912
914
|
|
|
913
915
|
// src/hooks/useIsMounted/useIsMounted.ts
|
|
@@ -6499,6 +6501,7 @@ var import_react38 = require("react");
|
|
|
6499
6501
|
|
|
6500
6502
|
// src/components/CookieBanner/CookieBanner.module.css
|
|
6501
6503
|
var CookieBanner_default = {
|
|
6504
|
+
container: "CookieBanner_container",
|
|
6502
6505
|
"checkbox-label": "CookieBanner_checkbox-label"
|
|
6503
6506
|
};
|
|
6504
6507
|
|
|
@@ -6548,9 +6551,12 @@ function CookieBanner({
|
|
|
6548
6551
|
width = "fit-content",
|
|
6549
6552
|
children,
|
|
6550
6553
|
collapsedBreakpoint,
|
|
6554
|
+
ref,
|
|
6551
6555
|
...rest
|
|
6552
6556
|
}) {
|
|
6553
6557
|
const { t } = useTranslation();
|
|
6558
|
+
const containerRef = useFocusTrap(true);
|
|
6559
|
+
const combinedRef = useCombinedRef(containerRef, ref);
|
|
6554
6560
|
const hasBp = !!collapsedBreakpoint;
|
|
6555
6561
|
const [isCollapsedOnBreakpoint, setIsCollapsedOnBreakpoint] = (0, import_react38.useState)(hasBp);
|
|
6556
6562
|
const generatedId = (0, import_react38.useId)();
|
|
@@ -6563,6 +6569,7 @@ function CookieBanner({
|
|
|
6563
6569
|
id,
|
|
6564
6570
|
cn(
|
|
6565
6571
|
className,
|
|
6572
|
+
CookieBanner_default.container,
|
|
6566
6573
|
utilStyles_default.scrollbar,
|
|
6567
6574
|
utilStyles_default["scrollable-y"],
|
|
6568
6575
|
typographyStyles_default["tertiary-medium"]
|
|
@@ -6571,6 +6578,7 @@ function CookieBanner({
|
|
|
6571
6578
|
htmlProps,
|
|
6572
6579
|
rest
|
|
6573
6580
|
),
|
|
6581
|
+
ref: combinedRef,
|
|
6574
6582
|
role: "region",
|
|
6575
6583
|
"aria-labelledby": headingId,
|
|
6576
6584
|
padding: styleUpToBreakpoint("x1", "sm", "x1.5"),
|