@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(),
|
|
17
|
-
const
|
|
18
|
-
return
|
|
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:
|
|
35
|
+
icon: i ? B : _,
|
|
36
36
|
size: "md",
|
|
37
37
|
onIconClick: () => u(l),
|
|
38
38
|
onLabelClick: r[0].onClick,
|
|
39
|
-
ariaLabel:
|
|
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:
|
|
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:
|
|
49
|
-
return /* @__PURE__ */ t(y, { variant:
|
|
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
|
|
7
|
-
import { ButtonIcon as
|
|
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:
|
|
22
|
-
variant:
|
|
21
|
+
color: e = "accent",
|
|
22
|
+
variant: s = "solid",
|
|
23
23
|
currentAccount: m,
|
|
24
|
-
expanded:
|
|
24
|
+
expanded: I,
|
|
25
25
|
label: i = "Menu",
|
|
26
26
|
badge: n,
|
|
27
27
|
...r
|
|
28
|
-
}) =>
|
|
29
|
-
/* @__PURE__ */ o(
|
|
30
|
-
/* @__PURE__ */ o(
|
|
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:
|
|
33
|
-
/* @__PURE__ */ o(
|
|
34
|
-
/* @__PURE__ */ o(
|
|
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:
|
|
37
|
-
/* @__PURE__ */ o(
|
|
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
|
-
|
|
49
|
+
d,
|
|
40
50
|
{
|
|
41
51
|
className: a.loginIcon,
|
|
42
52
|
icon: /* @__PURE__ */ o(x, { className: a.icon, "aria-label": "Login Icon" })
|
package/dist/hooks/useMenu.js
CHANGED
|
@@ -1,56 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useEnterKey as
|
|
4
|
-
const
|
|
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:
|
|
8
|
+
keyboardEvents: o = !1,
|
|
9
9
|
sortGroupBy: h,
|
|
10
|
-
onSelect:
|
|
11
|
-
ref:
|
|
10
|
+
onSelect: l,
|
|
11
|
+
ref: a
|
|
12
12
|
}) => {
|
|
13
|
-
const [f, s] =
|
|
14
|
-
|
|
13
|
+
const [f, s] = w(-1);
|
|
14
|
+
A(() => {
|
|
15
15
|
var n;
|
|
16
|
-
if (
|
|
17
|
-
const e = (n =
|
|
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 }))),
|
|
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
|
|
23
|
+
const v = x(() => {
|
|
24
24
|
const n = u.reduce(
|
|
25
|
-
(r,
|
|
26
|
-
const t = c &&
|
|
27
|
-
return r[t] = r[t] || [], r[t].push(
|
|
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,
|
|
32
|
-
items:
|
|
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 =
|
|
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(() => (
|
|
53
|
+
return m(() => (o && (s(0), document.addEventListener("keydown", d)), () => {
|
|
51
54
|
document.removeEventListener("keydown", d);
|
|
52
|
-
}), [d,
|
|
55
|
+
}), [d, o]), { menu: v, activeIndex: f, setActiveIndex: s };
|
|
53
56
|
};
|
|
54
57
|
export {
|
|
55
|
-
|
|
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;
|