@altinn/altinn-components 0.56.24 → 0.56.26
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/components/GlobalHeader/AccountSelector.js +41 -37
- package/dist/hooks/useLockBodyScroll.js +14 -0
- package/dist/types/lib/components/GlobalHeader/AccountSelector.d.ts +3 -1
- package/dist/types/lib/components/GlobalHeader/AccountSelector.stories.d.ts +1 -1
- package/dist/types/lib/hooks/useLockBodyScroll.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,78 +1,82 @@
|
|
|
1
|
-
import { jsx as c, jsxs as
|
|
1
|
+
import { jsx as c, jsxs as S } from "react/jsx-runtime";
|
|
2
2
|
import { c as p } from "../../index-p1eeF8LQ.js";
|
|
3
3
|
import { useState as _, useEffect as g } from "react";
|
|
4
|
-
import {
|
|
4
|
+
import { useLockBodyScroll as L } from "../../hooks/useLockBodyScroll.js";
|
|
5
|
+
import { AccountMenu as A } from "../Account/AccountMenu.js";
|
|
5
6
|
import "../Button/Button.js";
|
|
6
7
|
import "react-dom";
|
|
7
|
-
import { useRootContext as
|
|
8
|
+
import { useRootContext as M } from "../RootProvider/RootProvider.js";
|
|
8
9
|
import "../Snackbar/useSnackbar.js";
|
|
9
|
-
import { S as
|
|
10
|
-
import { S as
|
|
11
|
-
import { H as
|
|
12
|
-
import '../../assets/AccountSelector.css';const
|
|
13
|
-
accountSelector:
|
|
14
|
-
heading:
|
|
15
|
-
searchSection:
|
|
16
|
-
searchField:
|
|
17
|
-
accountMenu:
|
|
18
|
-
virtualized:
|
|
19
|
-
spinner:
|
|
20
|
-
},
|
|
10
|
+
import { S as F } from "../../SearchField-QTfebYdU.js";
|
|
11
|
+
import { S as T } from "../../button-BB5sYVKY.js";
|
|
12
|
+
import { H as j, S as y } from "../../switch-Cemfhx0H.js";
|
|
13
|
+
import '../../assets/AccountSelector.css';const C = "_accountSelector_139de_1", H = "_heading_139de_11", V = "_searchSection_139de_17", I = "_searchField_139de_26", E = "_accountMenu_139de_30", R = "_virtualized_139de_38", $ = "_spinner_139de_47", n = {
|
|
14
|
+
accountSelector: C,
|
|
15
|
+
heading: H,
|
|
16
|
+
searchSection: V,
|
|
17
|
+
searchField: I,
|
|
18
|
+
accountMenu: E,
|
|
19
|
+
virtualized: R,
|
|
20
|
+
spinner: $
|
|
21
|
+
}, ee = ({
|
|
21
22
|
accountMenu: e,
|
|
22
23
|
forceOpenFullScreen: t,
|
|
23
24
|
className: i,
|
|
24
25
|
loading: v,
|
|
25
26
|
showDeletedUnits: s,
|
|
26
|
-
onShowDeletedUnitsChange:
|
|
27
|
+
onShowDeletedUnitsChange: k,
|
|
28
|
+
scrollLock: x
|
|
27
29
|
}) => {
|
|
28
|
-
const { openId: o, closeAll: l, languageCode: d
|
|
30
|
+
const { openId: o, closeAll: l, languageCode: d, currentId: z } = M();
|
|
31
|
+
L(x ? z === "account" : !1);
|
|
32
|
+
const [u, h] = _(""), [a, m] = _(t);
|
|
29
33
|
g(() => {
|
|
30
34
|
!t && a && l(), m(t);
|
|
31
35
|
}, [t]), g(() => {
|
|
32
36
|
a === !0 && o("account");
|
|
33
37
|
}, [a, o]);
|
|
34
|
-
const { searchText:
|
|
35
|
-
e.onSelectAccount?.(
|
|
38
|
+
const { searchText: f, heading: b, switchLabel: w } = B(d), N = (r) => {
|
|
39
|
+
e.onSelectAccount?.(r), l(), m(!1);
|
|
36
40
|
};
|
|
37
|
-
return v ? /* @__PURE__ */ c(
|
|
38
|
-
/* @__PURE__ */ c(
|
|
39
|
-
/* @__PURE__ */
|
|
41
|
+
return v ? /* @__PURE__ */ c(T, { "aria-hidden": !0, "data-color": "neutral", className: n.spinner }) : /* @__PURE__ */ S("div", { className: p(i, n.accountSelector), children: [
|
|
42
|
+
/* @__PURE__ */ c(j, { "data-size": "sm", level: 2, className: n.heading, children: b }),
|
|
43
|
+
/* @__PURE__ */ S("div", { className: n.searchSection, children: [
|
|
40
44
|
/* @__PURE__ */ c(
|
|
41
|
-
|
|
45
|
+
F,
|
|
42
46
|
{
|
|
43
|
-
name:
|
|
44
|
-
placeholder:
|
|
47
|
+
name: f,
|
|
48
|
+
placeholder: f,
|
|
45
49
|
value: u,
|
|
46
|
-
onChange: (
|
|
50
|
+
onChange: (r) => h(r.target.value),
|
|
47
51
|
onClear: () => h(""),
|
|
48
|
-
className:
|
|
52
|
+
className: n.searchField
|
|
49
53
|
}
|
|
50
54
|
),
|
|
51
55
|
s !== void 0 && /* @__PURE__ */ c(
|
|
52
|
-
|
|
56
|
+
y,
|
|
53
57
|
{
|
|
54
58
|
checked: s,
|
|
55
|
-
onChange: (
|
|
56
|
-
label:
|
|
59
|
+
onChange: (r) => k?.(r.target.checked),
|
|
60
|
+
label: w
|
|
57
61
|
}
|
|
58
62
|
)
|
|
59
63
|
] }),
|
|
60
|
-
/* @__PURE__ */ c("div", { className: p(
|
|
61
|
-
|
|
64
|
+
/* @__PURE__ */ c("div", { className: p(n.accountMenu, e.virtualized && n.virtualized), children: /* @__PURE__ */ c(
|
|
65
|
+
A,
|
|
62
66
|
{
|
|
63
67
|
...e,
|
|
64
|
-
onSelectAccount:
|
|
68
|
+
onSelectAccount: N,
|
|
65
69
|
keyboardEvents: !1,
|
|
66
70
|
search: {
|
|
67
71
|
hidden: !0,
|
|
68
72
|
name: "",
|
|
69
73
|
value: u,
|
|
70
|
-
getResultsLabel: (
|
|
74
|
+
getResultsLabel: (r) => K(r, d)
|
|
71
75
|
}
|
|
72
76
|
}
|
|
73
77
|
) })
|
|
74
78
|
] });
|
|
75
|
-
},
|
|
79
|
+
}, B = (e) => {
|
|
76
80
|
switch (e) {
|
|
77
81
|
case "nn":
|
|
78
82
|
return {
|
|
@@ -99,10 +103,10 @@ import '../../assets/AccountSelector.css';const T = "_accountSelector_139de_1",
|
|
|
99
103
|
switchLabel: "Vis slettede"
|
|
100
104
|
};
|
|
101
105
|
}
|
|
102
|
-
},
|
|
106
|
+
}, K = (e, t) => {
|
|
103
107
|
const i = t === "nb" || t === "nn";
|
|
104
108
|
return e === 0 ? i ? "Ingen treff" : "No hits" : i ? `${e} treff` : e === 1 ? "1 hit" : `${e} hits`;
|
|
105
109
|
};
|
|
106
110
|
export {
|
|
107
|
-
|
|
111
|
+
ee as AccountSelector
|
|
108
112
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect as n } from "react";
|
|
3
|
+
const c = (t) => {
|
|
4
|
+
n(() => {
|
|
5
|
+
if (!t) return;
|
|
6
|
+
const { overflow: e, paddingRight: d } = document.body.style, o = window.innerWidth - document.documentElement.clientWidth;
|
|
7
|
+
return document.body.style.overflow = "hidden", o > 0 && (document.body.style.paddingRight = `${o}px`), () => {
|
|
8
|
+
document.body.style.overflow = e, document.body.style.paddingRight = d;
|
|
9
|
+
};
|
|
10
|
+
}, [t]);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
c as useLockBodyScroll
|
|
14
|
+
};
|
|
@@ -11,5 +11,7 @@ export interface AccountSelectorProps {
|
|
|
11
11
|
showDeletedUnits?: boolean;
|
|
12
12
|
/** Function to handle changes to the include deleted accounts switch */
|
|
13
13
|
onShowDeletedUnitsChange?: (newValue: boolean) => void;
|
|
14
|
+
/** Enable scroll lock to prevent background scrolling **/
|
|
15
|
+
scrollLock?: boolean;
|
|
14
16
|
}
|
|
15
|
-
export declare const AccountSelector: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
export declare const AccountSelector: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, scrollLock, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccountSelectorProps } from './AccountSelector';
|
|
2
2
|
declare const meta: {
|
|
3
3
|
title: string;
|
|
4
|
-
component: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
component: ({ accountMenu, forceOpenFullScreen, className, loading, showDeletedUnits, onShowDeletedUnitsChange, scrollLock, }: AccountSelectorProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
tags: string[];
|
|
6
6
|
parameters: {
|
|
7
7
|
layout: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useLockBodyScroll: (locked: boolean) => void;
|