@altinn/altinn-components 0.47.2 → 0.47.4
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,27 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as l } from "react/jsx-runtime";
|
|
3
3
|
import { c } from "../../index-L8X2o7IH.js";
|
|
4
|
-
import { useMemo as
|
|
5
|
-
import { Avatar as
|
|
6
|
-
import '../../assets/AvatarGroup.css';const
|
|
7
|
-
group:
|
|
8
|
-
item:
|
|
9
|
-
},
|
|
4
|
+
import { useMemo as h } from "react";
|
|
5
|
+
import { Avatar as A } from "./Avatar.js";
|
|
6
|
+
import '../../assets/AvatarGroup.css';const _ = "_group_1ts6c_1", y = "_item_1ts6c_10", t = {
|
|
7
|
+
group: _,
|
|
8
|
+
item: y
|
|
9
|
+
}, N = (o) => typeof o == "object" && o !== null && "items" in o, P = ({
|
|
10
10
|
items: o = [],
|
|
11
11
|
maxItemsCount: i = 4,
|
|
12
12
|
defaultType: r,
|
|
13
13
|
size: u,
|
|
14
14
|
className: m,
|
|
15
|
-
style: p
|
|
15
|
+
style: p,
|
|
16
|
+
maxItemsCountReachedLabel: g
|
|
16
17
|
}) => {
|
|
17
|
-
const s =
|
|
18
|
+
const s = h(() => o.slice(0, i).reverse(), [o, i]);
|
|
18
19
|
return o.length === 0 ? /* @__PURE__ */ l("div", { className: t.avatarGroup }) : /* @__PURE__ */ l("ul", { className: c(t.group, m), "data-size": u, "data-count": s == null ? void 0 : s.length, style: p, children: s.map((e, n) => {
|
|
19
|
-
const
|
|
20
|
+
const d = n === i - 1, f = e.customLabel || d ? g || o.length.toString() : void 0;
|
|
20
21
|
return /* @__PURE__ */ l("li", { className: c(t.item), children: /* @__PURE__ */ l(
|
|
21
|
-
|
|
22
|
+
A,
|
|
22
23
|
{
|
|
23
24
|
name: e.name,
|
|
24
|
-
customLabel:
|
|
25
|
+
customLabel: f,
|
|
25
26
|
imageUrl: e.imageUrl,
|
|
26
27
|
imageUrlAlt: e.imageUrlAlt,
|
|
27
28
|
type: (e == null ? void 0 : e.type) || r,
|
|
@@ -34,6 +35,6 @@ import '../../assets/AvatarGroup.css';const A = "_group_1ts6c_1", _ = "_item_1ts
|
|
|
34
35
|
}) });
|
|
35
36
|
};
|
|
36
37
|
export {
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
P as AvatarGroup,
|
|
39
|
+
N as isAvatarGroupProps
|
|
39
40
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as o, jsxs as
|
|
3
|
-
import { c as
|
|
4
|
-
import s, { forwardRef as
|
|
5
|
-
import { AccountMenu as
|
|
6
|
-
import { Button as
|
|
7
|
-
import { useRootContext as
|
|
2
|
+
import { jsx as o, jsxs as E } from "react/jsx-runtime";
|
|
3
|
+
import { c as S } from "../../index-L8X2o7IH.js";
|
|
4
|
+
import s, { forwardRef as y, useState as _, useEffect as b } from "react";
|
|
5
|
+
import { AccountMenu as F } from "../Account/AccountMenu.js";
|
|
6
|
+
import { Button as k } from "../Button/Button.js";
|
|
7
|
+
import { useRootContext as N } from "../RootProvider/RootProvider.js";
|
|
8
8
|
import "../Snackbar/useSnackbar.js";
|
|
9
|
-
import { SearchField as
|
|
10
|
-
import { S as
|
|
11
|
-
import { H as
|
|
12
|
-
import { u as
|
|
13
|
-
import '../../assets/AccountSelector.css';var
|
|
9
|
+
import { SearchField as R } from "../Forms/SearchField.js";
|
|
10
|
+
import { S as A } from "../../Spinner-BDXfwXIh.js";
|
|
11
|
+
import { H as M } from "../../Heading-By5DKz2H.js";
|
|
12
|
+
import { u as w } from "../../useId-BVFxCjkq.js";
|
|
13
|
+
import '../../assets/AccountSelector.css';var P = function(e, l) {
|
|
14
14
|
var r = {};
|
|
15
15
|
for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && l.indexOf(t) < 0 && (r[t] = e[t]);
|
|
16
16
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -18,9 +18,9 @@ import '../../assets/AccountSelector.css';var M = function(e, l) {
|
|
|
18
18
|
l.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[n]) && (r[t[n]] = e[t[n]]);
|
|
19
19
|
return r;
|
|
20
20
|
};
|
|
21
|
-
const
|
|
22
|
-
var { title: r, titleId: t } = e, n =
|
|
23
|
-
let i =
|
|
21
|
+
const T = y((e, l) => {
|
|
22
|
+
var { title: r, titleId: t } = e, n = P(e, ["title", "titleId"]);
|
|
23
|
+
let i = w();
|
|
24
24
|
return i = r ? t || "title-" + i : void 0, s.createElement(
|
|
25
25
|
"svg",
|
|
26
26
|
Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: l, "aria-labelledby": i }, n),
|
|
@@ -28,7 +28,7 @@ const P = v((e, l) => {
|
|
|
28
28
|
s.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M3.75 12a8.25 8.25 0 1 1 16.5 0 8.25 8.25 0 0 1-16.5 0M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25m4.03 9.28-3.5 3.5a.75.75 0 0 1-1.06 0l-3.5-3.5a.75.75 0 0 1 .53-1.28h7a.75.75 0 0 1 .53 1.28m-2.34.22h-3.38L12 13.44z", clipRule: "evenodd" })
|
|
29
29
|
);
|
|
30
30
|
});
|
|
31
|
-
var
|
|
31
|
+
var H = function(e, l) {
|
|
32
32
|
var r = {};
|
|
33
33
|
for (var t in e) Object.prototype.hasOwnProperty.call(e, t) && l.indexOf(t) < 0 && (r[t] = e[t]);
|
|
34
34
|
if (e != null && typeof Object.getOwnPropertySymbols == "function")
|
|
@@ -36,80 +36,82 @@ var A = function(e, l) {
|
|
|
36
36
|
l.indexOf(t[n]) < 0 && Object.prototype.propertyIsEnumerable.call(e, t[n]) && (r[t[n]] = e[t[n]]);
|
|
37
37
|
return r;
|
|
38
38
|
};
|
|
39
|
-
const
|
|
40
|
-
var { title: r, titleId: t } = e, n =
|
|
41
|
-
let i =
|
|
39
|
+
const V = y((e, l) => {
|
|
40
|
+
var { title: r, titleId: t } = e, n = H(e, ["title", "titleId"]);
|
|
41
|
+
let i = w();
|
|
42
42
|
return i = r ? t || "title-" + i : void 0, s.createElement(
|
|
43
43
|
"svg",
|
|
44
44
|
Object.assign({ xmlns: "http://www.w3.org/2000/svg", width: "1em", height: "1em", fill: "none", viewBox: "0 0 24 24", focusable: !1, role: "img", ref: l, "aria-labelledby": i }, n),
|
|
45
45
|
r ? s.createElement("title", { id: i }, r) : null,
|
|
46
46
|
s.createElement("path", { fill: "currentColor", fillRule: "evenodd", d: "M3.75 12a8.25 8.25 0 1 1 16.5 0 8.25 8.25 0 0 1-16.5 0M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25m.53 6.72a.75.75 0 0 0-1.06 0l-3.5 3.5a.75.75 0 0 0 .53 1.28h7a.75.75 0 0 0 .53-1.28zM12 10.56l1.69 1.69h-3.38z", clipRule: "evenodd" })
|
|
47
47
|
);
|
|
48
|
-
}),
|
|
49
|
-
accountSelector:
|
|
50
|
-
heading:
|
|
51
|
-
searchSection:
|
|
52
|
-
searchField:
|
|
53
|
-
accountMenu:
|
|
54
|
-
fullScreen:
|
|
55
|
-
virtualized:
|
|
56
|
-
btnIcon:
|
|
57
|
-
spinner:
|
|
58
|
-
},
|
|
59
|
-
const { currentId: n, openId: i,
|
|
60
|
-
|
|
61
|
-
l
|
|
62
|
-
}, [l,
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
48
|
+
}), B = "_accountSelector_1f74n_1", D = "_heading_1f74n_11", K = "_searchSection_1f74n_17", L = "_searchField_1f74n_22", U = "_accountMenu_1f74n_26", W = "_fullScreen_1f74n_34", $ = "_virtualized_1f74n_38", q = "_btnIcon_1f74n_42", G = "_spinner_1f74n_46", c = {
|
|
49
|
+
accountSelector: B,
|
|
50
|
+
heading: D,
|
|
51
|
+
searchSection: K,
|
|
52
|
+
searchField: L,
|
|
53
|
+
accountMenu: U,
|
|
54
|
+
fullScreen: W,
|
|
55
|
+
virtualized: $,
|
|
56
|
+
btnIcon: q,
|
|
57
|
+
spinner: G
|
|
58
|
+
}, ae = ({ accountMenu: e, forceOpenFullScreen: l, className: r, loading: t }) => {
|
|
59
|
+
const { currentId: n, openId: i, closeAll: f, languageCode: x } = N(), a = n === "accountFullscreen", [m, h] = _(""), [d, p] = _(l);
|
|
60
|
+
b(() => {
|
|
61
|
+
!l && d && a && f(), p(l);
|
|
62
|
+
}, [l]), b(() => {
|
|
63
|
+
d === !0 && !a && i("accountFullscreen");
|
|
64
|
+
}, [d, a, i]);
|
|
65
|
+
const { minimize: O, fullscreen: I, searchText: v, heading: z } = J(x), j = () => {
|
|
66
|
+
i(a ? "account" : "accountFullscreen");
|
|
67
|
+
}, C = (u) => {
|
|
68
|
+
var g;
|
|
69
|
+
(g = e.onSelectAccount) == null || g.call(e, u), f(), p(!1);
|
|
68
70
|
};
|
|
69
|
-
return t ? /* @__PURE__ */ o(
|
|
70
|
-
|
|
71
|
-
/* @__PURE__ */ o("div", { className:
|
|
72
|
-
|
|
71
|
+
return t ? /* @__PURE__ */ o(A, { "aria-hidden": !0, "data-color": "neutral", className: c.spinner }) : /* @__PURE__ */ E("div", { className: S(r, c.accountSelector), children: [
|
|
72
|
+
a && /* @__PURE__ */ o(M, { "data-size": "md", level: 2, className: c.heading, children: z }),
|
|
73
|
+
/* @__PURE__ */ o("div", { className: c.searchSection, children: /* @__PURE__ */ o(
|
|
74
|
+
R,
|
|
73
75
|
{
|
|
74
|
-
name:
|
|
75
|
-
placeholder:
|
|
76
|
-
value:
|
|
77
|
-
onChange: (u) =>
|
|
78
|
-
onClear: () =>
|
|
79
|
-
className:
|
|
76
|
+
name: v,
|
|
77
|
+
placeholder: v,
|
|
78
|
+
value: m,
|
|
79
|
+
onChange: (u) => h(u.target.value),
|
|
80
|
+
onClear: () => h(""),
|
|
81
|
+
className: c.searchField
|
|
80
82
|
}
|
|
81
83
|
) }),
|
|
82
84
|
/* @__PURE__ */ o(
|
|
83
85
|
"div",
|
|
84
86
|
{
|
|
85
|
-
className:
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
e.isVirtualized &&
|
|
87
|
+
className: S(
|
|
88
|
+
c.accountMenu,
|
|
89
|
+
a && c.fullScreen,
|
|
90
|
+
e.isVirtualized && c.virtualized
|
|
89
91
|
),
|
|
90
92
|
children: /* @__PURE__ */ o(
|
|
91
|
-
|
|
93
|
+
F,
|
|
92
94
|
{
|
|
93
95
|
...e,
|
|
94
|
-
onSelectAccount:
|
|
96
|
+
onSelectAccount: C,
|
|
95
97
|
keyboardEvents: !1,
|
|
96
|
-
search: { hidden: !0, name: "", value:
|
|
97
|
-
scrollRefStyles: !
|
|
98
|
+
search: { hidden: !0, name: "", value: m },
|
|
99
|
+
scrollRefStyles: !a && e.isVirtualized ? { maxHeight: "calc(40vh)" } : void 0
|
|
98
100
|
}
|
|
99
101
|
)
|
|
100
102
|
}
|
|
101
103
|
),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
d !== !0 && /* @__PURE__ */ o(
|
|
105
|
+
k,
|
|
104
106
|
{
|
|
105
|
-
icon:
|
|
107
|
+
icon: a ? /* @__PURE__ */ o(V, { className: c.btnIcon, "aria-hidden": "true" }) : /* @__PURE__ */ o(T, { className: c.btnIcon, "aria-hidden": "true" }),
|
|
106
108
|
variant: "text",
|
|
107
|
-
onClick:
|
|
108
|
-
children:
|
|
109
|
+
onClick: j,
|
|
110
|
+
children: a ? O : I
|
|
109
111
|
}
|
|
110
112
|
)
|
|
111
113
|
] });
|
|
112
|
-
},
|
|
114
|
+
}, J = (e) => {
|
|
113
115
|
switch (e) {
|
|
114
116
|
case "nn":
|
|
115
117
|
return {
|
|
@@ -135,5 +137,5 @@ const T = v((e, l) => {
|
|
|
135
137
|
}
|
|
136
138
|
};
|
|
137
139
|
export {
|
|
138
|
-
|
|
140
|
+
ae as AccountSelector
|
|
139
141
|
};
|
|
@@ -16,9 +16,11 @@ export interface AvatarGroupProps {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
/** Custom styles. */
|
|
18
18
|
style?: CSSProperties;
|
|
19
|
+
/** Custom Label for items counts reached **/
|
|
20
|
+
maxItemsCountReachedLabel?: string;
|
|
19
21
|
}
|
|
20
22
|
export declare const isAvatarGroupProps: (icon: unknown) => icon is AvatarGroupProps;
|
|
21
23
|
/**
|
|
22
24
|
* Avatar group component for displaying multiple avatars as a group.
|
|
23
25
|
*/
|
|
24
|
-
export declare const AvatarGroup: ({ items, maxItemsCount, defaultType, size, className, style, }: AvatarGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare const AvatarGroup: ({ items, maxItemsCount, defaultType, size, className, style, maxItemsCountReachedLabel, }: AvatarGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,7 +2,7 @@ import { StoryObj } from '@storybook/react-vite';
|
|
|
2
2
|
import { AvatarGroupProps } from '..';
|
|
3
3
|
declare const meta: {
|
|
4
4
|
title: string;
|
|
5
|
-
component: ({ items, maxItemsCount, defaultType, size, className, style, }: AvatarGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
component: ({ items, maxItemsCount, defaultType, size, className, style, maxItemsCountReachedLabel, }: AvatarGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
6
|
tags: string[];
|
|
7
7
|
parameters: {
|
|
8
8
|
layout: string;
|
|
@@ -18,4 +18,5 @@ type Story = StoryObj<typeof meta>;
|
|
|
18
18
|
export declare const People: Story;
|
|
19
19
|
export declare const Companies: Story;
|
|
20
20
|
export declare const CompanyAndPerson: Story;
|
|
21
|
+
export declare const CustomLabel: (args: AvatarGroupProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
22
|
export declare const MaxItemsCount: (args: AvatarGroupProps) => import("react/jsx-runtime").JSX.Element;
|