@altinn/altinn-components 0.38.13 → 0.38.15

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.
@@ -13,9 +13,9 @@ import '../../assets/DialogActions.css';const k = "_action_m3crc_1", I = "_combo
13
13
  action: k,
14
14
  comboButton: I
15
15
  }, T = ({ items: c, maxItems: s = 2, id: l = "dialog-actions", expandAltLabel: a }) => {
16
- const { currentId: d, closeAll: p, toggleId: u } = v(), e = d === l, r = g(() => (c || []).filter((n) => !n.hidden).sort((n, o) => {
17
- const i = ["primary", "secondary", "tertiary"];
18
- return i.indexOf(n == null ? void 0 : n.priority) - i.indexOf(o == null ? void 0 : o.priority);
16
+ const { currentId: d, closeAll: p, toggleId: u } = v(), i = d === l, r = g(() => (c || []).filter((n) => !n.hidden).sort((n, o) => {
17
+ const e = ["primary", "secondary", "tertiary"];
18
+ return e.indexOf(n == null ? void 0 : n.priority) - e.indexOf(o == null ? void 0 : o.priority);
19
19
  }), [c]);
20
20
  if (!r.length || s <= 0)
21
21
  return null;
@@ -32,21 +32,21 @@ import '../../assets/DialogActions.css';const k = "_action_m3crc_1", I = "_combo
32
32
  C,
33
33
  {
34
34
  variant: "solid",
35
- icon: e ? B : _,
35
+ icon: i ? B : _,
36
36
  size: "md",
37
37
  onIconClick: () => u(l),
38
38
  onLabelClick: r[0].onClick,
39
- ariaLabel: e ? "chevron up icon" : "chevron down icon",
39
+ ariaLabel: i ? "chevron up icon" : "chevron down icon",
40
40
  iconAltText: a,
41
41
  children: r[0].label
42
42
  }
43
43
  ),
44
- /* @__PURE__ */ t(b, { open: e, onClose: p, children: /* @__PURE__ */ t(x, { items: n }) })
44
+ i && /* @__PURE__ */ t(b, { open: i, onClose: p, children: /* @__PURE__ */ t(x, { items: n }) })
45
45
  ] });
46
46
  }
47
47
  return /* @__PURE__ */ t("section", { className: m.action, children: r.map((n, o) => {
48
- const { priority: i, id: w, ...h } = n;
49
- return /* @__PURE__ */ t(y, { variant: i === "primary" ? "solid" : "outline", size: "md", ...h, children: n.label }, "button-" + o);
48
+ const { priority: e, id: w, ...h } = n;
49
+ return /* @__PURE__ */ t(y, { variant: e === "primary" ? "solid" : "outline", size: "md", ...h, children: n.label }, "button-" + o);
50
50
  }) });
51
51
  };
52
52
  export {
@@ -3,8 +3,8 @@ import { c as f } from "../../index-L8X2o7IH.js";
3
3
  import "react";
4
4
  import { Badge as _ } from "../Badge/Badge.js";
5
5
  import { ButtonBase as p } from "../Button/ButtonBase.js";
6
- import { ButtonLabel as d } from "../Button/ButtonLabel.js";
7
- import { ButtonIcon as I } from "../Button/ButtonIcon.js";
6
+ import { ButtonLabel as u } from "../Button/ButtonLabel.js";
7
+ import { ButtonIcon as d } from "../Button/ButtonIcon.js";
8
8
  import "../RootProvider/RootProvider.js";
9
9
  import "../Snackbar/useSnackbar.js";
10
10
  import { S as g } from "../../XMark-DIqxCTTQ.js";
@@ -18,25 +18,35 @@ import '../../assets/GlobalMenuButton.css';const N = "_button_af7mx_1", b = "_lo
18
18
  }, z = ({
19
19
  className: t,
20
20
  as: c = "button",
21
- color: s = "accent",
22
- variant: e = "solid",
21
+ color: e = "accent",
22
+ variant: s = "solid",
23
23
  currentAccount: m,
24
- expanded: u,
24
+ expanded: I,
25
25
  label: i = "Menu",
26
26
  badge: n,
27
27
  ...r
28
- }) => u ? /* @__PURE__ */ l(p, { ...r, as: c, variant: e, color: s, className: f(a.button, t), children: [
29
- /* @__PURE__ */ o(d, { children: i }),
30
- /* @__PURE__ */ o(I, { className: a.closeIcon, icon: /* @__PURE__ */ o(g, { className: a.icon, "aria-label": "Close Icon" }) }),
28
+ }) => I ? /* @__PURE__ */ l(p, { ...r, as: c, variant: s, color: e, className: f(a.button, t), children: [
29
+ /* @__PURE__ */ o(u, { children: i }),
30
+ /* @__PURE__ */ o(d, { className: a.closeIcon, icon: /* @__PURE__ */ o(g, { className: a.icon, "aria-label": "Close Icon" }) }),
31
31
  n && /* @__PURE__ */ o(_, { ...n, className: a.badge })
32
- ] }) : m ? /* @__PURE__ */ l(p, { ...r, as: c, variant: e, color: s, className: f(a.button, t), children: [
33
- /* @__PURE__ */ o(d, { children: i }),
34
- /* @__PURE__ */ o(I, { className: a.avatar, icon: { type: m.type, name: m.name } }),
32
+ ] }) : m ? /* @__PURE__ */ l(p, { ...r, as: c, variant: s, color: e, className: f(a.button, t), children: [
33
+ /* @__PURE__ */ o(u, { children: i }),
34
+ /* @__PURE__ */ o(
35
+ d,
36
+ {
37
+ className: a.avatar,
38
+ icon: {
39
+ type: m.type,
40
+ name: m.name,
41
+ outline: !0
42
+ }
43
+ }
44
+ ),
35
45
  n && /* @__PURE__ */ o(_, { ...n, className: a.badge })
36
- ] }) : /* @__PURE__ */ l(p, { ...r, as: c, variant: e, color: s, className: f(a.button, t), children: [
37
- /* @__PURE__ */ o(d, { children: i }),
46
+ ] }) : /* @__PURE__ */ l(p, { ...r, as: c, variant: s, color: e, className: f(a.button, t), children: [
47
+ /* @__PURE__ */ o(u, { children: i }),
38
48
  /* @__PURE__ */ o(
39
- I,
49
+ d,
40
50
  {
41
51
  className: a.loginIcon,
42
52
  icon: /* @__PURE__ */ o(x, { className: a.icon, "aria-label": "Login Icon" })
@@ -1,56 +1,59 @@
1
1
  "use client";
2
- import { useState as v, useMemo as w, useCallback as x, useEffect as m } from "react";
3
- import { useEnterKey as b } from "./useEnterKey.js";
4
- const I = ({
2
+ import { useState as w, useMemo as x, useCallback as k, useEffect as m } from "react";
3
+ import { useEnterKey as A } from "./useEnterKey.js";
4
+ const M = ({
5
5
  items: u,
6
6
  groups: p,
7
7
  groupByKey: c,
8
- keyboardEvents: i = !1,
8
+ keyboardEvents: o = !1,
9
9
  sortGroupBy: h,
10
- onSelect: a,
11
- ref: l
10
+ onSelect: l,
11
+ ref: a
12
12
  }) => {
13
- const [f, s] = v(-1);
14
- b(() => {
13
+ const [f, s] = w(-1);
14
+ A(() => {
15
15
  var n;
16
- if (i) {
17
- const e = (n = l && "current" in l ? l.current : null) == null ? void 0 : n.querySelector(
16
+ if (o) {
17
+ const e = (n = a && "current" in a ? a.current : null) == null ? void 0 : n.querySelector(
18
18
  '[data-active="true"]'
19
19
  );
20
- e && (e.tagName === "A" && e.hasAttribute("href") ? e.click() : e.dispatchEvent(new MouseEvent("click", { bubbles: !0 }))), a == null || a();
20
+ e && (e.tagName === "A" && e.hasAttribute("href") ? e.click() : e.dispatchEvent(new MouseEvent("click", { bubbles: !0 }))), l == null || l();
21
21
  }
22
22
  });
23
- const k = w(() => {
23
+ const v = x(() => {
24
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;
25
+ (r, i) => {
26
+ const t = c && i[c] ? i[c] : "ungrouped";
27
+ return r[t] = r[t] || [], r[t].push(i), r;
28
28
  },
29
29
  {}
30
30
  ), e = Object.values(n).flat();
31
- return Object.entries(n).sort(h || (() => 0)).map(([r, o]) => ({
32
- items: o.map((t) => ({
31
+ return Object.entries(n).sort(h || (() => 0)).map(([r, i]) => ({
32
+ items: i.map((t) => ({
33
33
  menuIndex: e.indexOf(t),
34
34
  active: f === e.indexOf(t),
35
- onMouseEnter: () => {
35
+ onMouseEnter: o ? () => {
36
36
  s(e.indexOf(t));
37
- },
37
+ } : void 0,
38
+ onMouseLeave: o ? () => {
39
+ s(-1);
40
+ } : void 0,
38
41
  props: t
39
42
  })),
40
43
  props: {
41
44
  ...p[r] || {}
42
45
  }
43
46
  }));
44
- }, [u, c, f, p]), d = x(
47
+ }, [u, c, f, p]), d = k(
45
48
  (n) => {
46
49
  n.key === "ArrowDown" ? (n.preventDefault(), s((e) => (e + 1) % u.length)) : n.key === "ArrowUp" && (n.preventDefault(), s((e) => (e - 1 + u.length) % u.length));
47
50
  },
48
51
  [u.length]
49
52
  );
50
- return m(() => (i && (s(0), document.addEventListener("keydown", d)), () => {
53
+ return m(() => (o && (s(0), document.addEventListener("keydown", d)), () => {
51
54
  document.removeEventListener("keydown", d);
52
- }), [d, i]), { menu: k, activeIndex: f, setActiveIndex: s };
55
+ }), [d, o]), { menu: v, activeIndex: f, setActiveIndex: s };
53
56
  };
54
57
  export {
55
- I as useMenu
58
+ M as useMenu
56
59
  };
@@ -25,4 +25,3 @@ export default meta;
25
25
  export declare const Preview: (args: LayoutProps) => import("react/jsx-runtime").JSX.Element;
26
26
  export declare const HiddenSidebar: (args: LayoutProps) => import("react/jsx-runtime").JSX.Element;
27
27
  export declare const Fullscreen: (args: LayoutProps) => import("react/jsx-runtime").JSX.Element;
28
- export declare const WithBanner: (args: LayoutProps) => 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.38.13",
3
+ "version": "0.38.15",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",