@altinn/altinn-components 0.36.1 → 0.36.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/dist/assets/MenuItemsVirtual.css +1 -1
- package/dist/components/Header/Header.js +43 -41
- package/dist/components/Menu/MenuItemsVirtual.js +15 -15
- package/dist/hooks/useIsDesktop.js +15 -0
- package/dist/types/lib/components/Account/AccountMenu.stories.d.ts +1 -1
- package/dist/types/lib/hooks/useIsDesktop.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
.
|
|
1
|
+
._virtualScrollRef_15wg7_1{max-height:400px;overflow-y:auto}._virtualMenuListItem_15wg7_6{position:absolute;top:0;left:0;width:100%}._virtualMenuListItem_15wg7_6>*{margin:0}
|
|
@@ -1,86 +1,88 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { DropdownBase as
|
|
2
|
+
import { jsxs as c, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
import { DropdownBase as h } from "../Dropdown/DropdownBase.js";
|
|
4
4
|
import "../../index-L8X2o7IH.js";
|
|
5
|
-
import { DrawerBase as
|
|
5
|
+
import { DrawerBase as f } from "../Dropdown/DrawerBase.js";
|
|
6
6
|
import "react";
|
|
7
|
-
import { useRootContext as
|
|
8
|
-
import { GlobalMenu as
|
|
9
|
-
import { GlobalMenuButton as
|
|
10
|
-
import { HeaderBase as
|
|
11
|
-
import { HeaderLogo as
|
|
12
|
-
import { LocaleButton as
|
|
13
|
-
import { LocaleSwitcher as
|
|
14
|
-
import { Searchbar as
|
|
7
|
+
import { useRootContext as b } from "../RootProvider/RootProvider.js";
|
|
8
|
+
import { GlobalMenu as w } from "../GlobalMenu/GlobalMenu.js";
|
|
9
|
+
import { GlobalMenuButton as j } from "../GlobalMenu/GlobalMenuButton.js";
|
|
10
|
+
import { HeaderBase as B } from "./HeaderBase.js";
|
|
11
|
+
import { HeaderLogo as H } from "./HeaderLogo.js";
|
|
12
|
+
import { LocaleButton as L } from "./LocaleButton.js";
|
|
13
|
+
import { LocaleSwitcher as g } from "./LocaleSwitcher.js";
|
|
14
|
+
import { Searchbar as u } from "../Searchbar/Searchbar.js";
|
|
15
15
|
import "../Snackbar/useSnackbar.js";
|
|
16
|
-
import { HeaderGroup as
|
|
17
|
-
import { HeaderSearch as
|
|
18
|
-
import
|
|
19
|
-
|
|
16
|
+
import { HeaderGroup as S } from "./HeaderGroup.js";
|
|
17
|
+
import { HeaderSearch as v } from "./HeaderSearch.js";
|
|
18
|
+
import { useIsDesktop as D } from "../../hooks/useIsDesktop.js";
|
|
19
|
+
import '../../assets/Header.css';const I = "_drawer_1vzjh_1", y = "_dropdown_1vzjh_5", z = "_relative_1vzjh_19", a = {
|
|
20
|
+
drawer: I,
|
|
20
21
|
dropdown: y,
|
|
21
22
|
relative: z
|
|
22
|
-
},
|
|
23
|
-
const { currentId: o, toggleId: t, openId:
|
|
24
|
-
|
|
25
|
-
},
|
|
23
|
+
}, Z = ({ menu: r, locale: n, search: s, currentAccount: l, logo: x = {}, badge: C }) => {
|
|
24
|
+
const { currentId: o, toggleId: t, openId: _, closeAll: d } = b(), p = () => {
|
|
25
|
+
_("search");
|
|
26
|
+
}, i = () => {
|
|
26
27
|
t("search");
|
|
27
|
-
},
|
|
28
|
+
}, N = () => {
|
|
28
29
|
t("menu");
|
|
29
|
-
},
|
|
30
|
+
}, k = () => {
|
|
30
31
|
t("locale");
|
|
31
|
-
};
|
|
32
|
-
return /* @__PURE__ */
|
|
33
|
-
|
|
32
|
+
}, m = D();
|
|
33
|
+
return /* @__PURE__ */ c(
|
|
34
|
+
B,
|
|
34
35
|
{
|
|
35
36
|
currentId: o,
|
|
36
37
|
open: o === "search" || o === "menu" || o === "locale",
|
|
37
38
|
onClose: d,
|
|
38
39
|
children: [
|
|
39
|
-
/* @__PURE__ */ e(
|
|
40
|
-
/* @__PURE__ */
|
|
41
|
-
|
|
42
|
-
/* @__PURE__ */
|
|
40
|
+
/* @__PURE__ */ e(H, { ...x, className: a.logo }),
|
|
41
|
+
s && m && /* @__PURE__ */ e(v, { expanded: o === "search", children: /* @__PURE__ */ e(u, { ...s, expanded: o === "search", onClose: i, onFocus: p }) }),
|
|
42
|
+
/* @__PURE__ */ c(S, { children: [
|
|
43
|
+
n && /* @__PURE__ */ e("div", { className: a.relative, children: /* @__PURE__ */ e(L, { onClick: k, expanded: o === "locale" }) }),
|
|
44
|
+
/* @__PURE__ */ c("div", { className: a.relative, children: [
|
|
43
45
|
/* @__PURE__ */ e(
|
|
44
|
-
|
|
46
|
+
j,
|
|
45
47
|
{
|
|
46
|
-
badge:
|
|
47
|
-
currentAccount:
|
|
48
|
-
onClick:
|
|
48
|
+
badge: C,
|
|
49
|
+
currentAccount: l,
|
|
50
|
+
onClick: N,
|
|
49
51
|
expanded: o === "menu",
|
|
50
52
|
label: r == null ? void 0 : r.menuLabel
|
|
51
53
|
}
|
|
52
54
|
),
|
|
53
|
-
|
|
54
|
-
|
|
55
|
+
n && /* @__PURE__ */ e(
|
|
56
|
+
h,
|
|
55
57
|
{
|
|
56
58
|
layout: "desktop",
|
|
57
59
|
padding: !0,
|
|
58
60
|
placement: "right",
|
|
59
61
|
open: o === "locale",
|
|
60
62
|
className: a.dropdown,
|
|
61
|
-
children: /* @__PURE__ */ e(
|
|
63
|
+
children: /* @__PURE__ */ e(g, { ...n })
|
|
62
64
|
}
|
|
63
65
|
),
|
|
64
66
|
r && /* @__PURE__ */ e(
|
|
65
|
-
|
|
67
|
+
h,
|
|
66
68
|
{
|
|
67
69
|
layout: "desktop",
|
|
68
70
|
padding: !0,
|
|
69
71
|
placement: "right",
|
|
70
72
|
open: o === "menu",
|
|
71
73
|
className: a.dropdown,
|
|
72
|
-
children: /* @__PURE__ */ e(
|
|
74
|
+
children: /* @__PURE__ */ e(w, { ...r, currentAccount: l, onClose: d })
|
|
73
75
|
}
|
|
74
76
|
)
|
|
75
77
|
] })
|
|
76
78
|
] }),
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
r && /* @__PURE__ */ e(
|
|
79
|
+
s && !m && /* @__PURE__ */ e(v, { expanded: o === "search", children: /* @__PURE__ */ e(u, { ...s, expanded: o === "search", onClose: i, onFocus: p }) }),
|
|
80
|
+
n && /* @__PURE__ */ e(f, { open: o === "locale", className: a.drawer, children: /* @__PURE__ */ e(g, { ...n }) }),
|
|
81
|
+
r && /* @__PURE__ */ e(f, { open: o === "menu", className: a.drawer, children: /* @__PURE__ */ e(w, { ...r, currentAccount: l, onClose: d }) })
|
|
80
82
|
]
|
|
81
83
|
}
|
|
82
84
|
);
|
|
83
85
|
};
|
|
84
86
|
export {
|
|
85
|
-
|
|
87
|
+
Z as Header
|
|
86
88
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as v, jsx as i } from "react/jsx-runtime";
|
|
3
3
|
import { u as b } from "../../index-D-VWMqlv.js";
|
|
4
|
-
import { useRef as
|
|
4
|
+
import { useRef as g, useEffect as R } from "react";
|
|
5
5
|
import "../../index-L8X2o7IH.js";
|
|
6
|
-
import { useMenu as
|
|
6
|
+
import { useMenu as T } from "../../hooks/useMenu.js";
|
|
7
7
|
import "../RootProvider/RootProvider.js";
|
|
8
|
-
import { MenuItem as
|
|
9
|
-
import { MenuSearch as
|
|
10
|
-
import { MenuHeader as
|
|
11
|
-
import { MenuList as
|
|
8
|
+
import { MenuItem as V } from "./MenuItem.js";
|
|
9
|
+
import { MenuSearch as $ } from "./MenuSearch.js";
|
|
10
|
+
import { MenuHeader as j } from "./MenuHeader.js";
|
|
11
|
+
import { MenuList as k, MenuListItem as N } from "./MenuBase.js";
|
|
12
12
|
import "../Snackbar/useSnackbar.js";
|
|
13
|
-
import '../../assets/MenuItemsVirtual.css';const q = "
|
|
13
|
+
import '../../assets/MenuItemsVirtual.css';const q = "_virtualScrollRef_15wg7_1", B = "_virtualMenuListItem_15wg7_6", y = {
|
|
14
14
|
virtualScrollRef: q,
|
|
15
15
|
virtualMenuListItem: B
|
|
16
16
|
}, U = ({
|
|
@@ -24,12 +24,12 @@ import '../../assets/MenuItemsVirtual.css';const q = "_virtualScrollRef_14d4s_1"
|
|
|
24
24
|
defaultIconTheme: L,
|
|
25
25
|
scrollRefStyles: z
|
|
26
26
|
}) => {
|
|
27
|
-
const { menu: _ } =
|
|
27
|
+
const { menu: _ } = T({
|
|
28
28
|
items: I,
|
|
29
29
|
groups: M,
|
|
30
30
|
groupByKey: "groupId",
|
|
31
31
|
keyboardEvents: !1
|
|
32
|
-
}), m =
|
|
32
|
+
}), m = g(null), a = _.flatMap((t, e) => {
|
|
33
33
|
var u;
|
|
34
34
|
const E = (t == null ? void 0 : t.props) || {}, { title: c } = E, p = ((u = t == null ? void 0 : t.items) == null ? void 0 : u.filter((r) => {
|
|
35
35
|
var s;
|
|
@@ -55,26 +55,26 @@ import '../../assets/MenuItemsVirtual.css';const q = "_virtualScrollRef_14d4s_1"
|
|
|
55
55
|
estimateSize: () => 44,
|
|
56
56
|
getScrollElement: () => m.current
|
|
57
57
|
}), n = o.getVirtualItems();
|
|
58
|
-
return
|
|
58
|
+
return R(() => {
|
|
59
59
|
for (const t of n) {
|
|
60
60
|
const e = document.querySelector(`[data-index="${t.index}"]`);
|
|
61
61
|
e && o.measureElement(e);
|
|
62
62
|
}
|
|
63
|
-
}, [n]), /* @__PURE__ */ v(
|
|
64
|
-
l && /* @__PURE__ */ i(
|
|
63
|
+
}, [n]), /* @__PURE__ */ v(k, { children: [
|
|
64
|
+
l && /* @__PURE__ */ i($, { ...l }),
|
|
65
65
|
/* @__PURE__ */ i("div", { ref: m, className: y.virtualScrollRef, style: z, children: /* @__PURE__ */ i("div", { style: { position: "relative", height: `${o.getTotalSize()}px` }, children: n.map((t) => {
|
|
66
66
|
const e = a[t.index];
|
|
67
67
|
return e ? /* @__PURE__ */ v(
|
|
68
|
-
|
|
68
|
+
N,
|
|
69
69
|
{
|
|
70
70
|
dataIndex: t.index,
|
|
71
71
|
className: y.virtualMenuListItem,
|
|
72
72
|
style: { transform: `translateY(${t.start}px)` },
|
|
73
73
|
role: e.type === "separator" ? "separator" : void 0,
|
|
74
74
|
children: [
|
|
75
|
-
e.type === "title" && /* @__PURE__ */ i(
|
|
75
|
+
e.type === "title" && /* @__PURE__ */ i(j, { title: e.title }),
|
|
76
76
|
e.type === "item" && /* @__PURE__ */ i(
|
|
77
|
-
|
|
77
|
+
V,
|
|
78
78
|
{
|
|
79
79
|
...e.itemProps,
|
|
80
80
|
size: e.itemProps.size || x,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState as s, useEffect as r } from "react";
|
|
3
|
+
const e = 1024, d = () => {
|
|
4
|
+
const [i, n] = s(() => typeof window > "u" ? !1 : window.innerWidth >= e);
|
|
5
|
+
return r(() => {
|
|
6
|
+
n(window.innerWidth >= e);
|
|
7
|
+
const t = () => {
|
|
8
|
+
n(window.innerWidth >= e);
|
|
9
|
+
};
|
|
10
|
+
return window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
11
|
+
}, []), i;
|
|
12
|
+
};
|
|
13
|
+
export {
|
|
14
|
+
d as useIsDesktop
|
|
15
|
+
};
|
|
@@ -13,5 +13,5 @@ export declare const Default: Story;
|
|
|
13
13
|
export declare const Controlled: () => import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export declare const WithoutSubunits: Story;
|
|
15
15
|
export declare const WithGroups: Story;
|
|
16
|
-
export declare const VirtualizedMenu:
|
|
16
|
+
export declare const VirtualizedMenu: () => import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
export declare const WithToolbar: () => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsDesktop: () => boolean;
|