@altinn/altinn-components 0.37.0 → 0.38.0

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.
Files changed (41) hide show
  1. package/dist/assets/DrawerOrDropdown.css +1 -1
  2. package/dist/assets/Header.css +1 -1
  3. package/dist/assets/MenuItemBase.css +1 -1
  4. package/dist/components/Button/IconButton.js +9 -7
  5. package/dist/components/ContextMenu/ContextMenu.js +58 -43
  6. package/dist/components/Dropdown/DrawerOrDropdown.js +4 -4
  7. package/dist/components/Header/Header.js +42 -57
  8. package/dist/components/Header/LocaleButton.js +3 -2
  9. package/dist/components/Header/LocaleSwitcher.js +38 -23
  10. package/dist/components/Layout/Layout.js +27 -16
  11. package/dist/components/Layout/LayoutContent.js +4 -4
  12. package/dist/components/Menu/MenuBase.js +9 -9
  13. package/dist/components/Menu/MenuItemBase.js +31 -27
  14. package/dist/components/Menu/MenuItems.js +43 -37
  15. package/dist/components/Searchbar/Autocomplete.js +23 -30
  16. package/dist/components/Searchbar/Searchbar.js +4 -4
  17. package/dist/components/SkipLink/SkipLink.js +18 -0
  18. package/dist/components/SkipLink/index.js +4 -0
  19. package/dist/hooks/useEnterKey.js +8 -8
  20. package/dist/hooks/useMenu.js +43 -28
  21. package/dist/types/lib/components/Button/IconButton.d.ts +2 -1
  22. package/dist/types/lib/components/Dropdown/DrawerOrDropdown.d.ts +1 -1
  23. package/dist/types/lib/components/GlobalMenu/GlobalMenu.stories.d.ts +1 -0
  24. package/dist/types/lib/components/Header/LocaleButton.d.ts +2 -1
  25. package/dist/types/lib/components/Header/LocaleSwitcher.d.ts +2 -5
  26. package/dist/types/lib/components/Layout/Layout.d.ts +3 -1
  27. package/dist/types/lib/components/Layout/Layout.stories.d.ts +7 -1
  28. package/dist/types/lib/components/Layout/LayoutContent.d.ts +9 -2
  29. package/dist/types/lib/components/Menu/MenuBase.d.ts +4 -2
  30. package/dist/types/lib/components/Menu/MenuItem.d.ts +2 -1
  31. package/dist/types/lib/components/Menu/MenuItemBase.d.ts +3 -2
  32. package/dist/types/lib/components/Menu/MenuItems.d.ts +3 -1
  33. package/dist/types/lib/components/SkipLink/SkipLink.d.ts +9 -0
  34. package/dist/types/lib/components/SkipLink/SkipLink.stories.d.ts +15 -0
  35. package/dist/types/lib/components/SkipLink/index.d.ts +1 -0
  36. package/dist/types/lib/components/Transmission/Transmission.stories.d.ts +1 -1
  37. package/dist/types/lib/hooks/useEnterKey.d.ts +1 -1
  38. package/dist/types/lib/hooks/useMenu.d.ts +6 -2
  39. package/dist/types/lib/stories/Beta.stories.d.ts +11 -0
  40. package/package.json +1 -1
  41. package/dist/types/lib/components/Header/LocaleSwitcher.stories.d.ts +0 -19
@@ -1,79 +1,85 @@
1
1
  "use client";
2
- import { jsxs as c, jsx as d, Fragment as B } from "react/jsx-runtime";
3
- import { Fragment as E } from "react";
2
+ import { jsxs as c, jsx as d, Fragment as K } from "react/jsx-runtime";
3
+ import { useRef as R, Fragment as S } from "react";
4
4
  import "../../index-L8X2o7IH.js";
5
- import { useMenu as G } from "../../hooks/useMenu.js";
5
+ import { useMenu as _ } from "../../hooks/useMenu.js";
6
6
  import "../RootProvider/RootProvider.js";
7
- import { MenuItem as H } from "./MenuItem.js";
8
- import { MenuSearch as K } from "./MenuSearch.js";
9
- import { MenuHeader as S } from "./MenuHeader.js";
10
- import { MenuList as _, MenuListItem as i } from "./MenuBase.js";
7
+ import { MenuItem as $ } from "./MenuItem.js";
8
+ import { MenuSearch as q } from "./MenuSearch.js";
9
+ import { MenuHeader as w } from "./MenuHeader.js";
10
+ import { MenuList as A, MenuListItem as i } from "./MenuBase.js";
11
11
  import "../Snackbar/useSnackbar.js";
12
- const $ = ({
13
- level: h = 0,
12
+ const C = ({
13
+ level: f = 0,
14
14
  expanded: F,
15
- search: f,
15
+ search: h,
16
16
  items: j,
17
17
  groups: r = {},
18
18
  defaultItemSize: x,
19
19
  defaultItemColor: M,
20
20
  defaultItemTheme: I,
21
- defaultIconTheme: v,
22
- as: z
21
+ defaultIconTheme: b,
22
+ as: z,
23
+ keyboardEvents: E,
24
+ onSelect: L = () => {
25
+ }
23
26
  }) => {
24
- const { menu: b } = G({
27
+ const o = R(null), { menu: v } = _({
25
28
  items: j,
26
29
  groups: r,
27
30
  groupByKey: "groupId",
28
- keyboardEvents: !1
31
+ keyboardEvents: E ?? !1,
32
+ onSelect: L,
33
+ ref: o
29
34
  });
30
- return /* @__PURE__ */ c(_, { expanded: F, as: z, children: [
31
- f && /* @__PURE__ */ d(K, { ...f }),
32
- b.map((t, l) => {
33
- const n = (t == null ? void 0 : t.props) || {}, { title: y, divider: L = !0 } = n, T = b[l + 1];
34
- return /* @__PURE__ */ c(E, { children: [
35
- (h > 0 || l) && L ? /* @__PURE__ */ d(i, { role: "separator" }) : "",
36
- y && /* @__PURE__ */ d(i, { children: /* @__PURE__ */ d(S, { title: y }) }),
37
- t == null ? void 0 : t.items.filter((a) => {
38
- var m;
39
- return !((m = a.props) != null && m.hidden);
40
- }).map((a, m) => {
41
- const { active: k } = a, { groupId: q, ...e } = a.props || {}, { expanded: s } = e, o = t == null ? void 0 : t.items[m + 1];
35
+ return /* @__PURE__ */ c(A, { expanded: F, as: z, ref: o, children: [
36
+ h && /* @__PURE__ */ d(q, { ...h }),
37
+ v.map((t, l) => {
38
+ const n = (t == null ? void 0 : t.props) || {}, { title: y, divider: T = !0 } = n, k = v[l + 1];
39
+ return /* @__PURE__ */ c(S, { children: [
40
+ (f > 0 || l) && T ? /* @__PURE__ */ d(i, { role: "separator" }) : "",
41
+ y && /* @__PURE__ */ d(i, { children: /* @__PURE__ */ d(w, { title: y }) }),
42
+ t == null ? void 0 : t.items.filter((m) => {
43
+ var a;
44
+ return !((a = m.props) != null && a.hidden);
45
+ }).map((m, a) => {
46
+ const { active: B, onMouseEnter: G } = m, { groupId: D, ...e } = m.props || {}, { expanded: s } = e, H = t == null ? void 0 : t.items[a + 1];
42
47
  return /* @__PURE__ */ c(i, { expanded: s, children: [
43
48
  /* @__PURE__ */ d(
44
- H,
49
+ $,
45
50
  {
46
51
  ...e,
47
52
  size: (e == null ? void 0 : e.size) || (n == null ? void 0 : n.defaultItemSize) || x,
48
53
  color: (e == null ? void 0 : e.color) || (n == null ? void 0 : n.defaultItemColor) || M,
49
54
  theme: (e == null ? void 0 : e.theme) || (n == null ? void 0 : n.defaultItemTheme) || I,
50
- iconTheme: (e == null ? void 0 : e.iconTheme) || (n == null ? void 0 : n.defaultIconTheme) || v,
51
- active: k,
52
- tabIndex: e != null && e.disabled ? -1 : 0
55
+ iconTheme: (e == null ? void 0 : e.iconTheme) || (n == null ? void 0 : n.defaultIconTheme) || b,
56
+ active: B,
57
+ tabIndex: e != null && e.disabled ? -1 : e.tabIndex ?? 0,
58
+ onMouseEnter: G
53
59
  }
54
60
  ),
55
- s && (e == null ? void 0 : e.items) && /* @__PURE__ */ c(B, { children: [
61
+ s && (e == null ? void 0 : e.items) && /* @__PURE__ */ c(K, { children: [
56
62
  /* @__PURE__ */ d(
57
- $,
63
+ C,
58
64
  {
59
65
  expanded: s,
60
- level: h + 1,
66
+ level: f + 1,
61
67
  items: e == null ? void 0 : e.items,
62
68
  groups: r,
63
69
  defaultItemSize: x,
64
70
  defaultItemColor: M,
65
71
  defaultItemTheme: I,
66
- defaultIconTheme: v
72
+ defaultIconTheme: b
67
73
  }
68
74
  ),
69
- (T || o) && /* @__PURE__ */ d(i, { role: "separator", as: "div" })
75
+ (k || H) && /* @__PURE__ */ d(i, { role: "separator", as: "div" })
70
76
  ] })
71
- ] }, m);
77
+ ] }, a);
72
78
  })
73
79
  ] }, l);
74
80
  })
75
81
  ] });
76
82
  };
77
83
  export {
78
- $ as MenuItems
84
+ C as MenuItems
79
85
  };
@@ -1,47 +1,40 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import { useRef as k, createElement as l } from "react";
3
- import { useMenu as y } from "../../hooks/useMenu.js";
4
- import { useEnterKey as E } from "../../hooks/useEnterKey.js";
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import { useRef as y, createElement as b } from "react";
3
+ import { useMenu as v } from "../../hooks/useMenu.js";
5
4
  import "../../index-L8X2o7IH.js";
6
5
  import "../RootProvider/RootProvider.js";
7
- import { AutocompleteBase as h } from "./AutocompleteBase.js";
8
- import { AutocompleteGroup as x } from "./AutocompleteGroup.js";
9
- import { AutocompleteItem as g } from "./AutocompleteItem.js";
6
+ import { AutocompleteBase as E } from "./AutocompleteBase.js";
7
+ import { AutocompleteGroup as g } from "./AutocompleteGroup.js";
8
+ import { AutocompleteItem as h } from "./AutocompleteItem.js";
10
9
  import "../Snackbar/useSnackbar.js";
11
- const z = ({ className: p, items: n, id: a, groups: c = {}, expanded: i, onSelect: r }) => {
12
- const u = k(null);
13
- E(() => {
14
- var e;
15
- if (i) {
16
- const t = (e = u.current) == null ? void 0 : e.querySelector('[data-active="true"]');
17
- t && (t.tagName === "A" && t.hasAttribute("href") ? t.click() : t.dispatchEvent(new MouseEvent("click", { bubbles: !0 }))), r == null || r();
18
- }
19
- });
20
- const { menu: f, setActiveIndex: d } = y({
21
- items: n,
22
- groups: c,
10
+ const z = ({ className: u, items: s, id: i, groups: n = {}, expanded: e, onSelect: r }) => {
11
+ const m = y(null), { menu: c, setActiveIndex: f } = v({
12
+ items: s,
13
+ groups: n,
23
14
  groupByKey: "groupId",
24
- keyboardEvents: !0
15
+ keyboardEvents: e,
16
+ onSelect: r,
17
+ ref: m
25
18
  });
26
- return /* @__PURE__ */ m(h, { className: p, expanded: i, ref: u, id: a, children: f.map((e, t) => /* @__PURE__ */ l(x, { ...e.props, key: t }, /* @__PURE__ */ m("ul", { children: e.items.map((s, b) => {
19
+ return /* @__PURE__ */ t(E, { className: u, expanded: e, ref: m, id: i, children: c.map((p, a) => /* @__PURE__ */ b(g, { ...p.props, key: a }, /* @__PURE__ */ t("ul", { children: p.items.map((d, I) => {
27
20
  const {
28
- active: v,
21
+ active: l,
29
22
  menuIndex: A,
30
- props: { groupId: M, onClick: o, ...I }
31
- } = s;
32
- return /* @__PURE__ */ m(
33
- g,
23
+ props: { groupId: k, onClick: o, ...x }
24
+ } = d;
25
+ return /* @__PURE__ */ t(
26
+ h,
34
27
  {
35
28
  as: "button",
36
29
  tabIndex: -1,
37
- onMouseEnter: () => d(A),
38
- ...I,
30
+ onMouseEnter: () => f(A),
31
+ ...x,
39
32
  onClick: () => {
40
33
  o == null || o(), r == null || r();
41
34
  },
42
- active: v
35
+ active: l
43
36
  },
44
- b
37
+ I
45
38
  );
46
39
  }) }))) });
47
40
  };
@@ -6,7 +6,7 @@ import { SearchbarBase as T } from "./SearchbarBase.js";
6
6
  import { SearchbarField as A } from "./SearchbarField.js";
7
7
  import { Autocomplete as S } from "./Autocomplete.js";
8
8
  import "../Snackbar/useSnackbar.js";
9
- const k = ({
9
+ const q = ({
10
10
  className: g,
11
11
  autocomplete: a,
12
12
  expanded: e = !1,
@@ -20,8 +20,8 @@ const k = ({
20
20
  expanded: e,
21
21
  autocomplete: !!a,
22
22
  onBlurCapture: (t) => {
23
- var i, o, u, s, l, d, m, b;
24
- const c = (u = (o = (i = t.target) == null ? void 0 : i.attributes) == null ? void 0 : o.getNamedItem("data-testid")) == null ? void 0 : u.value;
23
+ var o, i, u, s, l, d, m, b;
24
+ const c = (u = (i = (o = t.target) == null ? void 0 : o.attributes) == null ? void 0 : i.getNamedItem("data-testid")) == null ? void 0 : u.value;
25
25
  (s = t == null ? void 0 : t.relatedTarget) != null && s.closest('[data-autocomplete="true"]') || t.relatedTarget === null || (c === "search-button-clear" || c === "search-button-close" || c === "searchbar-input" && ((l = t.relatedTarget) == null ? void 0 : l.getAttribute("data-testid")) !== "searchbar-input" && ((d = t.relatedTarget) == null ? void 0 : d.getAttribute("data-testid")) !== "search-button-clear" && ((m = t.relatedTarget) == null ? void 0 : m.getAttribute("data-testid")) !== "search-button-close" && ((b = t.relatedTarget) == null ? void 0 : b.getAttribute("data-testid")) !== "autocomplete-list") && (r == null || r());
26
26
  },
27
27
  children: [
@@ -40,5 +40,5 @@ const k = ({
40
40
  }
41
41
  );
42
42
  export {
43
- k as Searchbar
43
+ q as Searchbar
44
44
  };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { jsx as s } from "react/jsx-runtime";
3
+ import { c as a } from "../../lite-1fxw3LjI.js";
4
+ import { forwardRef as c } from "react";
5
+ const e = c(function({ children: i, className: r, ...o }, t) {
6
+ return s("a", { className: a("ds-skiplink", r), ...o, ref: t, children: i });
7
+ }), m = ({ color: n, size: i, children: r, href: o }) => /* @__PURE__ */ s(
8
+ e,
9
+ {
10
+ "data-color": n,
11
+ "data-size": i,
12
+ href: o,
13
+ children: r
14
+ }
15
+ );
16
+ export {
17
+ m as SkipLink
18
+ };
@@ -0,0 +1,4 @@
1
+ import { SkipLink as o } from "./SkipLink.js";
2
+ export {
3
+ o as SkipLink
4
+ };
@@ -1,15 +1,15 @@
1
1
  "use client";
2
- import { useEffect as c } from "react";
3
- const u = (e) => {
4
- c(() => {
5
- const t = (s) => {
6
- s.key === "Enter" && (e == null || e());
2
+ import { useEffect as d } from "react";
3
+ const s = (e) => {
4
+ d(() => {
5
+ const t = (u) => {
6
+ u.key === "Enter" && (e == null || e(u));
7
7
  };
8
- return document.addEventListener("keydown", t), () => {
9
- document.removeEventListener("keydown", t);
8
+ return document.addEventListener("keydown", t, !0), () => {
9
+ document.removeEventListener("keydown", t, !0);
10
10
  };
11
11
  }, [e]);
12
12
  };
13
13
  export {
14
- u as useEnterKey
14
+ s as useEnterKey
15
15
  };
@@ -1,40 +1,55 @@
1
1
  "use client";
2
- import { useState as w, useMemo as x, useCallback as i, useEffect as k } from "react";
2
+ import { useState as v, useMemo as w, useCallback as x, useEffect as m } from "react";
3
+ import { useEnterKey as b } from "./useEnterKey.js";
3
4
  const I = ({
4
- items: n,
5
- groups: f,
6
- groupByKey: u,
7
- keyboardEvents: a = !1,
8
- sortGroupBy: p
5
+ items: u,
6
+ groups: p,
7
+ groupByKey: c,
8
+ keyboardEvents: i = !1,
9
+ sortGroupBy: h,
10
+ onSelect: a,
11
+ ref: l
9
12
  }) => {
10
- const [l, d] = w(-1), h = x(() => {
11
- const r = n.reduce(
12
- (o, s) => {
13
- const e = u && s[u] ? s[u] : "ungrouped";
14
- return o[e] = o[e] || [], o[e].push(s), o;
13
+ const [f, s] = v(-1);
14
+ b(() => {
15
+ var n;
16
+ if (i) {
17
+ const e = (n = l && "current" in l ? l.current : null) == null ? void 0 : n.querySelector(
18
+ '[data-active="true"]'
19
+ );
20
+ e && (e.tagName === "A" && e.hasAttribute("href") ? e.click() : e.dispatchEvent(new MouseEvent("click", { bubbles: !0 }))), a == null || a();
21
+ }
22
+ });
23
+ const k = w(() => {
24
+ const n = u.reduce(
25
+ (r, o) => {
26
+ const t = c && o[c] ? o[c] : "ungrouped";
27
+ return r[t] = r[t] || [], r[t].push(o), r;
15
28
  },
16
29
  {}
17
- ), t = Object.values(r).flat();
18
- return Object.entries(r).sort(p || (() => 0)).map(([o, s]) => ({
19
- items: s.map((e) => ({
20
- menuIndex: t.indexOf(e),
21
- active: l === t.indexOf(e),
22
- props: e
30
+ ), e = Object.values(n).flat();
31
+ return Object.entries(n).sort(h || (() => 0)).map(([r, o]) => ({
32
+ items: o.map((t) => ({
33
+ menuIndex: e.indexOf(t),
34
+ active: f === e.indexOf(t),
35
+ onMouseEnter: () => {
36
+ s(e.indexOf(t));
37
+ },
38
+ props: t
23
39
  })),
24
- props: f[o] || {}
40
+ props: {
41
+ ...p[r] || {}
42
+ }
25
43
  }));
26
- }, [n, u, l, f]), c = i(
27
- (r) => {
28
- r.key === "ArrowDown" ? d((t) => (t + 1) % n.length) : r.key === "ArrowUp" && d((t) => (t - 1 + n.length) % n.length);
44
+ }, [u, c, f, p]), d = x(
45
+ (n) => {
46
+ n.key === "ArrowDown" ? (n.preventDefault(), s((e) => (e + 1) % u.length)) : n.key === "ArrowUp" && (n.preventDefault(), s((e) => (e - 1 + u.length) % u.length));
29
47
  },
30
- [n.length]
48
+ [u.length]
31
49
  );
32
- return k(() => {
33
- if (a)
34
- return d(0), document.addEventListener("keydown", c), () => {
35
- document.removeEventListener("keydown", c);
36
- };
37
- }, [c, a]), { menu: h, activeIndex: l, setActiveIndex: d };
50
+ return m(() => (i && (s(0), document.addEventListener("keydown", d)), () => {
51
+ document.removeEventListener("keydown", d);
52
+ }), [d, i]), { menu: k, activeIndex: f, setActiveIndex: s };
38
53
  };
39
54
  export {
40
55
  I as useMenu
@@ -12,5 +12,6 @@ export interface IconButtonProps {
12
12
  className?: string;
13
13
  onClick?: MouseEventHandler;
14
14
  dataTestId?: string;
15
+ onBlurCapture?: React.FocusEventHandler<HTMLButtonElement>;
15
16
  }
16
- export declare const IconButton: ({ variant, rounded, size, icon, iconSize, iconAltText, color, className, selected, onClick, dataTestId, }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
17
+ export declare const IconButton: ({ variant, rounded, size, icon, iconSize, iconAltText, color, className, selected, onClick, dataTestId, onBlurCapture, }: IconButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import { MouseEventHandler, ReactNode } from 'react';
2
2
  import { DrawerButtonProps } from '../';
3
3
  export interface DrawerOrDropdownProps {
4
- drawerTitle: string;
5
4
  children: ReactNode;
5
+ drawerTitle?: string;
6
6
  open?: boolean;
7
7
  onClose?: MouseEventHandler;
8
8
  drawerButton?: DrawerButtonProps;
@@ -28,3 +28,4 @@ export declare const CurrentAccount: (args: GlobalMenuProps) => import("react/js
28
28
  export declare const CompanyAccount: (args: GlobalMenuProps) => import("react/jsx-runtime").JSX.Element;
29
29
  export declare const SingleAccount: (args: GlobalMenuProps) => import("react/jsx-runtime").JSX.Element;
30
30
  export declare const Login: Story;
31
+ export declare const InterimMenu: (args: GlobalMenuProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,5 +3,6 @@ export interface LocaleButtonProps {
3
3
  id?: string;
4
4
  expanded?: boolean;
5
5
  onClick?: MouseEventHandler;
6
+ onBlurCapture?: React.FocusEventHandler<HTMLButtonElement>;
6
7
  }
7
- export declare const LocaleButton: ({ id, expanded, onClick }: LocaleButtonProps) => import("react/jsx-runtime").JSX.Element;
8
+ export declare const LocaleButton: ({ id, expanded, onClick, onBlurCapture }: LocaleButtonProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,7 @@
1
- import { ChangeEventHandler } from 'react';
2
1
  import { MenuOptionProps } from '../Menu';
3
2
  export interface LocaleSwitcherProps {
4
- id?: string;
5
3
  title?: string;
6
4
  options: MenuOptionProps[];
7
- className?: string;
8
- onChange?: ChangeEventHandler;
5
+ onSelect?: (value: string) => void;
9
6
  }
10
- export declare const LocaleSwitcher: ({ title, options, onChange }: LocaleSwitcherProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const LocaleSwitcher: ({ title, options, onSelect }: LocaleSwitcherProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,6 +3,7 @@ import { LayoutColor, LayoutTheme } from '.';
3
3
  import { FooterProps } from '../Footer';
4
4
  import { HeaderProps } from '../Header';
5
5
  import { MenuProps } from '../Menu';
6
+ import { SkipLinkProps } from '../SkipLink';
6
7
  interface SidebarProps {
7
8
  color?: LayoutColor;
8
9
  menu?: MenuProps;
@@ -20,6 +21,7 @@ export interface LayoutProps {
20
21
  sidebar?: SidebarProps;
21
22
  content?: ContentProps;
22
23
  children?: ReactNode;
24
+ skipLink?: SkipLinkProps;
23
25
  }
24
- export declare const Layout: ({ color, theme, header, footer, sidebar, content, children }: LayoutProps) => import("react/jsx-runtime").JSX.Element;
26
+ export declare const Layout: ({ color, theme, header, footer, sidebar, content, children, skipLink, }: LayoutProps) => import("react/jsx-runtime").JSX.Element;
25
27
  export {};
@@ -1,12 +1,18 @@
1
1
  import { LayoutProps } from '../';
2
2
  declare const meta: {
3
3
  title: string;
4
- component: ({ color, theme, header, footer, sidebar, content, children }: LayoutProps) => import("react/jsx-runtime").JSX.Element;
4
+ component: ({ color, theme, header, footer, sidebar, content, children, skipLink, }: LayoutProps) => import("react/jsx-runtime").JSX.Element;
5
5
  parameters: {
6
6
  layout: string;
7
7
  };
8
8
  args: {
9
9
  theme: "subtle";
10
+ skipLink: {
11
+ href: string;
12
+ color: import('..').Color;
13
+ size: import('..').Size;
14
+ children: string;
15
+ };
10
16
  header: import('..').HeaderProps;
11
17
  footer: import('..').FooterProps;
12
18
  sidebar: {
@@ -1,7 +1,14 @@
1
- import { LayoutBaseProps } from './LayoutBase';
1
+ import { ReactNode } from 'react';
2
+ import { LayoutColor } from './LayoutBase';
3
+ interface LayoutContentProps {
4
+ color?: LayoutColor;
5
+ children?: ReactNode;
6
+ id?: string;
7
+ }
2
8
  /**
3
9
  * Content layout container. Should be a child of LayoutBody.
4
10
  *
5
11
  *
6
12
  */
7
- export declare const LayoutContent: ({ color, children }: LayoutBaseProps) => import("react/jsx-runtime").JSX.Element;
13
+ export declare const LayoutContent: ({ color, children, id }: LayoutContentProps) => import("react/jsx-runtime").JSX.Element;
14
+ export {};
@@ -1,4 +1,4 @@
1
- import { ElementType, ReactNode } from 'react';
1
+ import { ElementType, MouseEventHandler, ReactNode } from 'react';
2
2
  import { Color } from '..';
3
3
  export type MenuColor = Color;
4
4
  export type MenuTheme = 'transparent' | 'default' | 'subtle';
@@ -17,6 +17,8 @@ export interface MenuListProps {
17
17
  expanded?: boolean;
18
18
  className?: string;
19
19
  children?: ReactNode;
20
+ ref?: React.Ref<HTMLUListElement>;
21
+ onMouseEnter?: MouseEventHandler;
20
22
  }
21
23
  export interface MenuListItemProps {
22
24
  as?: ElementType;
@@ -28,5 +30,5 @@ export interface MenuListItemProps {
28
30
  dataIndex?: number;
29
31
  }
30
32
  export declare const MenuBase: ({ as, color, theme, className, children }: MenuBaseProps) => import("react/jsx-runtime").JSX.Element;
31
- export declare const MenuList: ({ as, role, className, children }: MenuListProps) => import("react/jsx-runtime").JSX.Element;
33
+ export declare const MenuList: ({ as, role, className, children, ref, onMouseEnter }: MenuListProps) => import("react/jsx-runtime").JSX.Element;
32
34
  export declare const MenuListItem: ({ as, role, className, children, style, dataIndex, }: MenuListItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { ElementType, ReactNode } from 'react';
1
+ import { ElementType, MouseEventHandler, ReactNode } from 'react';
2
2
  import { BadgeProps, MenuItemColor, MenuItemIconProps, MenuItemLabelProps, MenuItemSize, MenuItemTheme } from '../';
3
3
  export interface MenuItemProps {
4
4
  id: string;
@@ -30,5 +30,6 @@ export interface MenuItemProps {
30
30
  className?: string;
31
31
  label?: ReactNode;
32
32
  items?: MenuItemProps[];
33
+ onMouseEnter?: MouseEventHandler;
33
34
  }
34
35
  export declare const MenuItem: ({ as, size, color, theme, collapsible, expanded, icon, iconTheme, iconBadge, title, description, badge, controls, linkIcon, label, ...rest }: MenuItemProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { ElementType, KeyboardEventHandler, ReactNode } from 'react';
1
+ import { ElementType, KeyboardEventHandler, MouseEventHandler, ReactNode } from 'react';
2
2
  import { Color } from '..';
3
3
  export type MenuItemColor = Color;
4
4
  export type MenuItemSize = 'sm' | 'md' | 'lg';
@@ -20,5 +20,6 @@ export interface MenuItemBaseProps {
20
20
  selected?: boolean;
21
21
  expanded?: boolean;
22
22
  children?: ReactNode;
23
+ onMouseEnter?: MouseEventHandler;
23
24
  }
24
- export declare const MenuItemBase: ({ interactive, as, color, theme, size, className, href, onClick, onKeyPress, tabIndex, hidden, selected, disabled, children, }: MenuItemBaseProps) => import("react/jsx-runtime").JSX.Element;
25
+ export declare const MenuItemBase: ({ interactive, as, color, theme, size, className, href, onClick, onKeyPress, tabIndex, hidden, selected, disabled, children, active, onMouseEnter, }: MenuItemBaseProps) => import("react/jsx-runtime").JSX.Element;
@@ -25,5 +25,7 @@ export interface MenuItemsProps {
25
25
  defaultItemTheme?: MenuItemTheme;
26
26
  defaultIconTheme?: IconTheme;
27
27
  as?: ElementType;
28
+ keyboardEvents?: boolean;
29
+ onSelect?: () => void;
28
30
  }
29
- export declare const MenuItems: ({ level, expanded, search, items, groups, defaultItemSize, defaultItemColor, defaultItemTheme, defaultIconTheme, as, }: MenuItemsProps) => import("react/jsx-runtime").JSX.Element;
31
+ export declare const MenuItems: ({ level, expanded, search, items, groups, defaultItemSize, defaultItemColor, defaultItemTheme, defaultIconTheme, as, keyboardEvents, onSelect, }: MenuItemsProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ import { Color, Size } from '../../types';
3
+ export interface SkipLinkProps {
4
+ color: Color;
5
+ size: Size;
6
+ children: ReactNode;
7
+ href: string;
8
+ }
9
+ export declare const SkipLink: ({ color, size, children, href }: SkipLinkProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { StoryFn } from '@storybook/react-vite';
2
+ import { SkipLink } from './SkipLink.tsx';
3
+ type Story = StoryFn<typeof SkipLink>;
4
+ declare const _default: {
5
+ title: string;
6
+ component: ({ color, size, children, href }: import('./SkipLink.tsx').SkipLinkProps) => import("react/jsx-runtime").JSX.Element;
7
+ args: {
8
+ href: string;
9
+ color: import('../index.ts').Color;
10
+ size: import('../index.ts').Size;
11
+ children: string;
12
+ };
13
+ };
14
+ export default _default;
15
+ export declare const Preview: Story;
@@ -0,0 +1 @@
1
+ export * from './SkipLink';
@@ -40,10 +40,10 @@ declare const meta: {
40
40
  onClick?: (() => void) | undefined;
41
41
  onKeyPress?: React.KeyboardEventHandler | undefined;
42
42
  tabIndex?: number | undefined;
43
+ onMouseEnter?: React.MouseEventHandler<HTMLDivElement> | undefined;
43
44
  description?: React.ReactNode | import('..').HeadingProps;
44
45
  collapsible?: boolean | undefined;
45
46
  linkIcon?: boolean | undefined;
46
- onMouseEnter?: React.MouseEventHandler<HTMLDivElement> | undefined;
47
47
  ariaLabel?: string | undefined;
48
48
  shadow?: import('..').Shadow | undefined;
49
49
  };
@@ -1 +1 @@
1
- export declare const useEnterKey: (onEnter?: () => void) => void;
1
+ export declare const useEnterKey: (onEnter?: (e: KeyboardEvent) => void) => void;
@@ -1,7 +1,9 @@
1
+ import { MouseEventHandler } from 'react';
1
2
  export interface UseMenuItemProps<T> {
2
3
  menuIndex: number;
3
- active?: boolean;
4
4
  props: T;
5
+ active?: boolean;
6
+ onMouseEnter?: MouseEventHandler;
5
7
  }
6
8
  export interface UseMenuGroup<T, V> {
7
9
  items: UseMenuItemProps<T>[];
@@ -15,8 +17,10 @@ export interface UseMenuOutput<T, V> {
15
17
  export interface UseMenuInput<T, V> {
16
18
  items: T[];
17
19
  groups: Record<string, V>;
20
+ ref?: React.Ref<HTMLElement>;
18
21
  groupByKey?: keyof T;
19
22
  keyboardEvents?: boolean;
20
23
  sortGroupBy?: (a: [string, T[]], b: [string, T[]]) => number;
24
+ onSelect?: () => void;
21
25
  }
22
- export declare const useMenu: <T, V>({ items, groups, groupByKey, keyboardEvents, sortGroupBy, }: UseMenuInput<T, V>) => UseMenuOutput<T, V>;
26
+ export declare const useMenu: <T, V>({ items, groups, groupByKey, keyboardEvents, sortGroupBy, onSelect, ref, }: UseMenuInput<T, V>) => UseMenuOutput<T, V>;
@@ -0,0 +1,11 @@
1
+ declare const meta: {
2
+ title: string;
3
+ tags: string[];
4
+ parameters: {
5
+ layout: string;
6
+ };
7
+ args: {};
8
+ };
9
+ export default meta;
10
+ export declare const InboxBeta: () => import("react/jsx-runtime").JSX.Element;
11
+ export declare const AdminBeta: () => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.37.0",
3
+ "version": "0.38.0",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",
@@ -1,19 +0,0 @@
1
- import { StoryObj } from '@storybook/react-vite';
2
- import { LocaleSwitcherProps } from './LocaleSwitcher';
3
- declare const meta: {
4
- title: string;
5
- component: ({ title, options, onChange }: LocaleSwitcherProps) => import("react/jsx-runtime").JSX.Element;
6
- tags: string[];
7
- parameters: {};
8
- args: {
9
- id?: string;
10
- title?: string;
11
- options: import('..').MenuOptionProps[];
12
- className?: string;
13
- onChange?: React.ChangeEventHandler;
14
- };
15
- };
16
- export default meta;
17
- type Story = StoryObj<typeof meta>;
18
- export declare const Default: Story;
19
- export declare const Controlled: (args: LocaleSwitcherProps) => import("react/jsx-runtime").JSX.Element;