@altinn/altinn-components 0.38.14 → 0.38.16

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.
@@ -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
  };
@@ -3,7 +3,7 @@ import { Color } from '..';
3
3
  export type ButtonVariant = 'solid' | 'tinted' | 'outline' | 'dotted' | 'text' | 'link';
4
4
  export type ButtonSize = 'xs' | 'sm' | 'md' | 'lg' | 'custom';
5
5
  export type ButtonColor = Color | 'inherit';
6
- export interface ButtonBaseProps extends React.HTMLAttributes<HTMLButtonElement> {
6
+ export interface ButtonBaseProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
7
7
  /**
8
8
  * Change the default rendered element for the one passed as a child, merging their props and behavior.
9
9
  * @default false
@@ -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.14",
3
+ "version": "0.38.16",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",