@altinn/altinn-components 0.47.3 → 0.47.5

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,64 +1,71 @@
1
1
  "use client";
2
2
  import { jsx as x } from "react/jsx-runtime";
3
- import { useState as R, useEffect as S } from "react";
3
+ import { useState as R, useEffect as S, useMemo as j } from "react";
4
4
  import "../../index-L8X2o7IH.js";
5
5
  import "../RootProvider/RootProvider.js";
6
- import { Menu as j } from "../Menu/Menu.js";
6
+ import { Menu as k } from "../Menu/Menu.js";
7
7
  import "../Snackbar/useSnackbar.js";
8
- const k = (d) => `${d} hits`, D = ({
9
- items: d = [],
10
- groups: v = {},
11
- search: t,
12
- filterAccount: C,
13
- onSelectAccount: u,
8
+ const y = (u) => `${u} hits`, D = ({
9
+ items: u = [],
10
+ groups: C = {},
11
+ search: l,
12
+ filterAccount: w,
13
+ onSelectAccount: d,
14
14
  currentAccount: e,
15
15
  isVirtualized: L,
16
- keyboardEvents: w,
16
+ keyboardEvents: M,
17
17
  scrollRefStyles: F
18
18
  }) => {
19
- var r;
20
- const p = d.map((o) => ({
19
+ var p;
20
+ const r = u.map((o) => ({
21
21
  ...o,
22
22
  title: (o == null ? void 0 : o.title) || o.name,
23
23
  groupId: o.groupId || "search",
24
24
  selected: o.selected ?? (e == null ? void 0 : e.id) === o.id,
25
25
  onClick: () => {
26
- !o.disabled && (u == null || u(o.id));
26
+ !o.disabled && (d == null || d(o.id));
27
27
  }
28
- })), [l, i] = R("");
28
+ })), [t, a] = R("");
29
29
  S(() => {
30
- (t == null ? void 0 : t.value) !== void 0 && i(t.value);
31
- }, [t == null ? void 0 : t.value]);
32
- const b = C || ((o, a) => {
33
- var g, f, s;
34
- return ((g = o == null ? void 0 : o.name) == null ? void 0 : g.toLowerCase().includes(a.toLowerCase())) || ((s = (f = o == null ? void 0 : o.description) == null ? void 0 : f.toString()) == null ? void 0 : s.toLowerCase().includes(a.toLowerCase()));
35
- }), n = l ? p.filter((o) => b(o, l)).map((o) => ({
36
- ...o,
37
- groupId: "search",
38
- title: (o == null ? void 0 : o.title) || o.name,
39
- highlightWords: [l]
40
- })) : p, I = l ? {
30
+ (l == null ? void 0 : l.value) !== void 0 && a(l.value);
31
+ }, [l == null ? void 0 : l.value]);
32
+ const i = w || ((o, f) => {
33
+ var s, g, v;
34
+ return ((s = o == null ? void 0 : o.name) == null ? void 0 : s.toLowerCase().includes(f.toLowerCase())) || ((v = (g = o == null ? void 0 : o.description) == null ? void 0 : g.toString()) == null ? void 0 : v.toLowerCase().includes(f.toLowerCase()));
35
+ }), n = j(() => t ? Array.from(
36
+ new Map(
37
+ r.filter((o) => i(o, t)).map((o) => [
38
+ o.id,
39
+ {
40
+ ...o,
41
+ groupId: "search",
42
+ title: (o == null ? void 0 : o.title) || o.name,
43
+ highlightWords: [t]
44
+ }
45
+ ])
46
+ ).values()
47
+ ) : r, [r, t, i]), b = t ? {
41
48
  search: {
42
- title: ((r = t == null ? void 0 : t.getResultsLabel) == null ? void 0 : r.call(t, n.length)) ?? k(n.length)
49
+ title: ((p = l == null ? void 0 : l.getResultsLabel) == null ? void 0 : p.call(l, n.length)) ?? y(n.length)
43
50
  }
44
- } : v, M = {
51
+ } : C, I = {
45
52
  name: "account-search",
46
- value: l,
47
- placeholder: (t == null ? void 0 : t.placeholder) ?? "Find account",
48
- onChange: (o) => i(o.target.value),
49
- onClear: () => i("")
53
+ value: t,
54
+ placeholder: (l == null ? void 0 : l.placeholder) ?? "Find account",
55
+ onChange: (o) => a(o.target.value),
56
+ onClear: () => a("")
50
57
  }, c = [
51
58
  ...n.length > 0 ? n : [{ id: "search", groupId: "search", hidden: !0 }]
52
59
  ];
53
60
  return /* @__PURE__ */ x(
54
- j,
61
+ k,
55
62
  {
56
63
  variant: "default",
57
- search: t && !t.hidden ? M : void 0,
58
- groups: I,
64
+ search: l && !l.hidden ? I : void 0,
65
+ groups: b,
59
66
  items: c,
60
67
  isVirtualized: L,
61
- keyboardEvents: w,
68
+ keyboardEvents: M,
62
69
  scrollRefStyles: F
63
70
  }
64
71
  );
@@ -1,24 +1,23 @@
1
1
  import { jsx as d } from "react/jsx-runtime";
2
2
  import { c as s } from "../../index-L8X2o7IH.js";
3
- import '../../assets/DrawerBase.css';const c = "_drawer_tvpob_1", m = {
4
- drawer: c
3
+ import '../../assets/DrawerBase.css';const m = "_drawer_tvpob_1", c = {
4
+ drawer: m
5
5
  }, w = ({
6
6
  placement: a = "inline",
7
- open: t = !1,
8
- className: e,
9
- children: o,
10
- as: r = "div",
7
+ open: e = !1,
8
+ className: t,
9
+ children: r,
10
+ as: o = "div",
11
11
  dataLayout: n = "mobile"
12
12
  }) => /* @__PURE__ */ d(
13
- r,
13
+ o,
14
14
  {
15
- className: s(m.drawer, e),
15
+ className: s(c.drawer, t),
16
16
  "data-placement": a,
17
17
  "data-variant": "default",
18
- "data-color": "company",
19
- "data-expanded": t,
18
+ "data-expanded": e,
20
19
  "data-layout": n,
21
- children: o
20
+ children: r
22
21
  }
23
22
  );
24
23
  export {
@@ -1,16 +1,16 @@
1
1
  "use client";
2
- import { jsx as o, jsxs as O } from "react/jsx-runtime";
3
- import { c as g } from "../../index-L8X2o7IH.js";
4
- import s, { forwardRef as v, useState as z, useEffect as j } from "react";
5
- import { AccountMenu as C } from "../Account/AccountMenu.js";
6
- import { Button as E } from "../Button/Button.js";
7
- import { useRootContext as k } from "../RootProvider/RootProvider.js";
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 F } from "../Forms/SearchField.js";
10
- import { S as N } from "../../Spinner-BDXfwXIh.js";
11
- import { H as R } from "../../Heading-By5DKz2H.js";
12
- import { u as _ } from "../../useId-BVFxCjkq.js";
13
- import '../../assets/AccountSelector.css';var M = function(e, l) {
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 P = v((e, l) => {
22
- var { title: r, titleId: t } = e, n = M(e, ["title", "titleId"]);
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 A = function(e, l) {
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 T = v((e, l) => {
40
- var { title: r, titleId: t } = e, n = A(e, ["title", "titleId"]);
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
- }), H = "_accountSelector_1f74n_1", V = "_heading_1f74n_11", B = "_searchSection_1f74n_17", D = "_searchField_1f74n_22", K = "_accountMenu_1f74n_26", L = "_fullScreen_1f74n_34", U = "_virtualized_1f74n_38", W = "_btnIcon_1f74n_42", $ = "_spinner_1f74n_46", a = {
49
- accountSelector: H,
50
- heading: V,
51
- searchSection: B,
52
- searchField: D,
53
- accountMenu: K,
54
- fullScreen: L,
55
- virtualized: U,
56
- btnIcon: W,
57
- spinner: $
58
- }, ie = ({ accountMenu: e, forceOpenFullScreen: l, className: r, loading: t }) => {
59
- const { currentId: n, openId: i, toggleId: d, languageCode: S } = k(), c = n === "accountFullscreen", [f, m] = z(""), { minimize: b, fullscreen: y, searchText: h, heading: w } = q(S);
60
- j(() => {
61
- l === !0 && !c ? i("accountFullscreen") : l === !1 && c && d("accountFullscreen");
62
- }, [l, c, i, d]);
63
- const x = () => {
64
- i(c ? "account" : "accountFullscreen");
65
- }, I = (u) => {
66
- var p;
67
- (p = e.onSelectAccount) == null || p.call(e, u), d(c ? "accountFullscreen" : "account");
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(N, { "aria-hidden": !0, "data-color": "neutral", className: a.spinner }) : /* @__PURE__ */ O("div", { className: g(r, a.accountSelector), children: [
70
- c && /* @__PURE__ */ o(R, { "data-size": "md", level: 2, className: a.heading, children: w }),
71
- /* @__PURE__ */ o("div", { className: a.searchSection, children: /* @__PURE__ */ o(
72
- F,
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: h,
75
- placeholder: h,
76
- value: f,
77
- onChange: (u) => m(u.target.value),
78
- onClear: () => m(""),
79
- className: a.searchField
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: g(
86
- a.accountMenu,
87
- c && a.fullScreen,
88
- e.isVirtualized && a.virtualized
87
+ className: S(
88
+ c.accountMenu,
89
+ a && c.fullScreen,
90
+ e.isVirtualized && c.virtualized
89
91
  ),
90
92
  children: /* @__PURE__ */ o(
91
- C,
93
+ F,
92
94
  {
93
95
  ...e,
94
- onSelectAccount: I,
96
+ onSelectAccount: C,
95
97
  keyboardEvents: !1,
96
- search: { hidden: !0, name: "", value: f },
97
- scrollRefStyles: !c && e.isVirtualized ? { maxHeight: "calc(40vh)" } : void 0
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
- l !== !0 && /* @__PURE__ */ o(
103
- E,
104
+ d !== !0 && /* @__PURE__ */ o(
105
+ k,
104
106
  {
105
- icon: c ? /* @__PURE__ */ o(T, { className: a.btnIcon, "aria-hidden": "true" }) : /* @__PURE__ */ o(P, { className: a.btnIcon, "aria-hidden": "true" }),
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: x,
108
- children: c ? b : y
109
+ onClick: j,
110
+ children: a ? O : I
109
111
  }
110
112
  )
111
113
  ] });
112
- }, q = (e) => {
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
- ie as AccountSelector
140
+ ae as AccountSelector
139
141
  };
@@ -50,3 +50,4 @@ export declare const WithEnglishLanguage: (args: LayoutStoryArgs) => import("rea
50
50
  export declare const StickySidebar: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
51
51
  export declare const HiddenSidebar: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
52
52
  export declare const Fullscreen: (args: LayoutStoryArgs) => import("react/jsx-runtime").JSX.Element;
53
+ export declare const Profile: (args: LayoutStoryArgs) => 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.47.3",
3
+ "version": "0.47.5",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",