@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.
@@ -1 +1 @@
1
- ._virtualScrollRef_14d4s_1{max-height:400px}._virtualMenuListItem_14d4s_5{position:absolute;top:0;left:0;width:100%}._virtualMenuListItem_14d4s_5>*{margin:0}
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 s, jsx as e } from "react/jsx-runtime";
3
- import { DropdownBase as i } from "../Dropdown/DropdownBase.js";
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 p } from "../Dropdown/DrawerBase.js";
5
+ import { DrawerBase as f } from "../Dropdown/DrawerBase.js";
6
6
  import "react";
7
- import { useRootContext as C } from "../RootProvider/RootProvider.js";
8
- import { GlobalMenu as m } from "../GlobalMenu/GlobalMenu.js";
9
- import { GlobalMenuButton as N } from "../GlobalMenu/GlobalMenuButton.js";
10
- import { HeaderBase as b } from "./HeaderBase.js";
11
- import { HeaderLogo as j } from "./HeaderLogo.js";
12
- import { LocaleButton as B } from "./LocaleButton.js";
13
- import { LocaleSwitcher as h } from "./LocaleSwitcher.js";
14
- import { Searchbar as H } from "../Searchbar/Searchbar.js";
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 L } from "./HeaderGroup.js";
17
- import { HeaderSearch as S } from "./HeaderSearch.js";
18
- import '../../assets/Header.css';const k = "_drawer_1vzjh_1", y = "_dropdown_1vzjh_5", z = "_relative_1vzjh_19", a = {
19
- drawer: k,
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
- }, W = ({ menu: r, locale: l, search: c, currentAccount: n, logo: f = {}, badge: w }) => {
23
- const { currentId: o, toggleId: t, openId: g, closeAll: d } = C(), u = () => {
24
- g("search");
25
- }, v = () => {
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
- }, x = () => {
30
+ }, k = () => {
30
31
  t("locale");
31
- };
32
- return /* @__PURE__ */ s(
33
- b,
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(j, { ...f, className: a.logo }),
40
- /* @__PURE__ */ s(L, { children: [
41
- l && /* @__PURE__ */ e("div", { className: a.relative, children: /* @__PURE__ */ e(B, { onClick: x, expanded: o === "locale" }) }),
42
- /* @__PURE__ */ s("div", { className: a.relative, children: [
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
- N,
46
+ j,
45
47
  {
46
- badge: w,
47
- currentAccount: n,
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
- l && /* @__PURE__ */ e(
54
- i,
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(h, { ...l })
63
+ children: /* @__PURE__ */ e(g, { ...n })
62
64
  }
63
65
  ),
64
66
  r && /* @__PURE__ */ e(
65
- i,
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(m, { ...r, currentAccount: n, onClose: d })
74
+ children: /* @__PURE__ */ e(w, { ...r, currentAccount: l, onClose: d })
73
75
  }
74
76
  )
75
77
  ] })
76
78
  ] }),
77
- c && /* @__PURE__ */ e(S, { expanded: o === "search", children: /* @__PURE__ */ e(H, { ...c, expanded: o === "search", onClose: v, onFocus: u }) }),
78
- l && /* @__PURE__ */ e(p, { open: o === "locale", className: a.drawer, children: /* @__PURE__ */ e(h, { ...l }) }),
79
- r && /* @__PURE__ */ e(p, { open: o === "menu", className: a.drawer, children: /* @__PURE__ */ e(m, { ...r, currentAccount: n, onClose: d }) })
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
- W as Header
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 R, useEffect as T } from "react";
4
+ import { useRef as g, useEffect as R } from "react";
5
5
  import "../../index-L8X2o7IH.js";
6
- import { useMenu as V } from "../../hooks/useMenu.js";
6
+ import { useMenu as T } from "../../hooks/useMenu.js";
7
7
  import "../RootProvider/RootProvider.js";
8
- import { MenuItem as $ } from "./MenuItem.js";
9
- import { MenuSearch as j } from "./MenuSearch.js";
10
- import { MenuHeader as k } from "./MenuHeader.js";
11
- import { MenuList as N, MenuListItem as g } from "./MenuBase.js";
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 = "_virtualScrollRef_14d4s_1", B = "_virtualMenuListItem_14d4s_5", y = {
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: _ } = V({
27
+ const { menu: _ } = T({
28
28
  items: I,
29
29
  groups: M,
30
30
  groupByKey: "groupId",
31
31
  keyboardEvents: !1
32
- }), m = R(null), a = _.flatMap((t, e) => {
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 T(() => {
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(N, { children: [
64
- l && /* @__PURE__ */ i(j, { ...l }),
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
- g,
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(k, { title: e.title }),
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: Story;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.36.1",
3
+ "version": "0.36.3",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",