@altinn/altinn-components 0.50.4 → 0.50.6

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,22 +1,22 @@
1
1
  "use client";
2
2
  import { jsx as l } from "react/jsx-runtime";
3
- import { u as x } from "../../index-D-VWMqlv.js";
4
- import { useRef as I, useEffect as h } from "react";
3
+ import { u as h } from "../../index-D-VWMqlv.js";
4
+ import { useRef as v, useEffect as x } from "react";
5
5
  import "../../index-L8X2o7IH.js";
6
- import { AccountListItem as v } from "./AccountListItem.js";
6
+ import { AccountListItem as I } from "./AccountListItem.js";
7
7
  import { useMenu as _ } from "../../hooks/useMenu.js";
8
8
  import { Heading as L } from "../Typography/Heading.js";
9
9
  import "../RootProvider/RootProvider.js";
10
10
  import "../Snackbar/useSnackbar.js";
11
11
  import { Section as S } from "../Page/Section.js";
12
- import '../../assets/AccountListVirtual.css';const $ = "_virtualScrollRef_188ep_1", C = "_virtualList_188ep_9", P = "_virtualListItem_188ep_15", E = "_lastChild_188ep_31", z = "_virtualTitleItem_188ep_35", o = {
12
+ import '../../assets/AccountListVirtual.css';const $ = "_virtualScrollRef_188ep_1", C = "_virtualList_188ep_9", P = "_virtualListItem_188ep_15", z = "_lastChild_188ep_31", E = "_virtualTitleItem_188ep_35", o = {
13
13
  virtualScrollRef: $,
14
14
  virtualList: C,
15
15
  virtualListItem: P,
16
- lastChild: E,
17
- virtualTitleItem: z
16
+ lastChild: z,
17
+ virtualTitleItem: E
18
18
  }, j = ({ items: u, groups: d = {}, sortGroupBy: f }) => {
19
- const n = I(null), { menu: y } = _({
19
+ const n = v(null), { menu: y } = _({
20
20
  items: u,
21
21
  groups: d,
22
22
  groupByKey: "groupId",
@@ -31,8 +31,9 @@ import '../../assets/AccountListVirtual.css';const $ = "_virtualScrollRef_188ep_
31
31
  itemProps: s.props || {}
32
32
  }))
33
33
  ];
34
- }), m = x({
34
+ }), m = h({
35
35
  count: a.length,
36
+ useAnimationFrameWithResizeObserver: !0,
36
37
  gap: 8,
37
38
  estimateSize: (t) => {
38
39
  var c;
@@ -44,7 +45,7 @@ import '../../assets/AccountListVirtual.css';const $ = "_virtualScrollRef_188ep_
44
45
  },
45
46
  getScrollElement: () => n.current
46
47
  }), p = m.getVirtualItems();
47
- return h(() => {
48
+ return x(() => {
48
49
  var t, e, i;
49
50
  for (const r of p) {
50
51
  const s = ((t = n.current) == null ? void 0 : t.querySelector(`[data-index="${r.index}"]`)) ?? ((e = n.current) == null ? void 0 : e.querySelector(`[dataindex="${r.index}"]`)) ?? ((i = n.current) == null ? void 0 : i.querySelector(`[dataIndex="${r.index}"]`));
@@ -81,7 +82,7 @@ import '../../assets/AccountListVirtual.css';const $ = "_virtualScrollRef_188ep_
81
82
  "data-index": t.index,
82
83
  className: `${o.virtualListItem} ${c ? o.lastChild : ""}`,
83
84
  style: { transform: `translateY(${t.start}px)` },
84
- children: /* @__PURE__ */ l(v, { ...e.itemProps, containerAs: "div" })
85
+ children: /* @__PURE__ */ l(I, { ...e.itemProps, containerAs: "div" })
85
86
  },
86
87
  t.key
87
88
  );
@@ -1,79 +1,81 @@
1
- import { jsxs as k, jsx as q } from "react/jsx-runtime";
2
- import { c as A } from "../../index-L8X2o7IH.js";
3
- import { ListItemBase as C } from "./ListItemBase.js";
1
+ import { jsxs as N, jsx as n } from "react/jsx-runtime";
2
+ import { c as k } from "../../index-L8X2o7IH.js";
3
+ import { useId as q } from "react";
4
+ import { ListItemBase as A } from "./ListItemBase.js";
4
5
  import { ListItemHeader as D } from "./ListItemHeader.js";
5
6
  import '../../assets/ListItem.css';const E = "_item_1nwey_3", F = {
6
7
  item: E
7
- }, O = ({
8
- className: c,
9
- color: m,
10
- variant: n = "default",
11
- shadow: f = "xs",
12
- border: p = "none",
13
- loading: e,
14
- disabled: o,
8
+ }, P = ({
9
+ className: f,
10
+ color: o,
11
+ variant: l = "default",
12
+ shadow: p = "xs",
13
+ border: I = "none",
14
+ loading: m,
15
+ disabled: r,
15
16
  collapsible: a,
16
17
  expanded: t,
17
- size: r,
18
- icon: l,
18
+ size: i,
19
+ icon: u,
19
20
  label: s,
20
- title: u,
21
- description: L,
22
- badge: x,
23
- linkIcon: y = !1,
24
- select: I,
25
- selected: _,
26
- controls: h,
27
- children: j,
28
- interactive: i,
21
+ title: L,
22
+ description: h,
23
+ badge: y,
24
+ linkIcon: _ = !1,
25
+ select: d,
26
+ selected: j,
27
+ controls: x,
28
+ children: v,
29
+ interactive: e,
29
30
  id: w,
30
31
  containerAs: B,
31
- ...H
32
+ ...C
32
33
  }) => {
33
- const N = typeof s == "function" ? s() : s;
34
- return /* @__PURE__ */ k(
35
- C,
34
+ const H = typeof s == "function" ? s() : s, c = q();
35
+ return /* @__PURE__ */ N(
36
+ A,
36
37
  {
37
- className: A(F.item, c),
38
- size: r,
39
- color: m,
40
- variant: n,
41
- shadow: f,
42
- border: p,
43
- disabled: o,
44
- selected: _,
38
+ className: k(F.item, f),
39
+ size: i,
40
+ color: o,
41
+ variant: l,
42
+ shadow: p,
43
+ border: I,
44
+ disabled: r,
45
+ selected: j,
45
46
  expanded: t,
46
- loading: e,
47
- interactive: i,
47
+ loading: m,
48
+ interactive: e,
48
49
  id: w,
49
50
  as: B,
50
51
  children: [
51
- /* @__PURE__ */ q(
52
+ /* @__PURE__ */ n(
52
53
  D,
53
54
  {
54
- color: m,
55
- loading: e,
56
- linkIcon: y,
57
- disabled: o,
55
+ color: o,
56
+ loading: m,
57
+ linkIcon: _,
58
+ disabled: r,
58
59
  collapsible: a,
59
60
  expanded: t,
60
- select: I,
61
- title: u,
62
- size: r,
63
- description: L,
64
- icon: l,
65
- badge: x,
66
- controls: h,
67
- interactive: i,
68
- ...H,
69
- children: N
61
+ select: d,
62
+ title: L,
63
+ size: i,
64
+ description: h,
65
+ icon: u,
66
+ badge: y,
67
+ controls: x,
68
+ interactive: e,
69
+ ariaControlsId: t ? c : void 0,
70
+ ...C,
71
+ children: H
70
72
  }
71
73
  ),
72
- t ? j : null
74
+ t ? /* @__PURE__ */ n("div", { id: c, children: v }) : null
73
75
  ]
74
76
  }
75
77
  );
76
78
  };
77
79
  export {
78
- O as ListItem
80
+ P as ListItem
79
81
  };
@@ -1,102 +1,106 @@
1
- import { jsxs as i, jsx as e } from "react/jsx-runtime";
2
- import { c as E } from "../../index-L8X2o7IH.js";
3
- import { useId as w, isValidElement as z } from "react";
4
- import { Icon as A } from "../Icon/Icon.js";
5
- import { Badge as D } from "../Badge/Badge.js";
1
+ import { jsxs as i, jsx as t } from "react/jsx-runtime";
2
+ import { c as w } from "../../index-L8X2o7IH.js";
3
+ import { useId as z, isValidElement as A } from "react";
4
+ import { Icon as D } from "../Icon/Icon.js";
5
+ import { Badge as H } from "../Badge/Badge.js";
6
6
  import "../RootProvider/RootProvider.js";
7
- import { ListItemLink as H } from "./ListItemLink.js";
8
- import { ListItemLabel as R } from "./ListItemLabel.js";
9
- import { ListItemIcon as U } from "./ListItemIcon.js";
10
- import { ListItemControls as V } from "./ListItemControls.js";
11
- import { ListItemSelect as q } from "./ListItemSelect.js";
7
+ import { ListItemLink as R } from "./ListItemLink.js";
8
+ import { ListItemLabel as U } from "./ListItemLabel.js";
9
+ import { ListItemIcon as V } from "./ListItemIcon.js";
10
+ import { ListItemControls as q } from "./ListItemControls.js";
11
+ import { ListItemSelect as G } from "./ListItemSelect.js";
12
12
  import "../Snackbar/useSnackbar.js";
13
- import { S as G, a as J } from "../../ChevronUp-_BBfEirx.js";
14
- import { S as K } from "../../ChevronRight-ANFWmIs1.js";
15
- import '../../assets/ListItemHeader.css';const M = "_header_29hv7_1", O = "_label_29hv7_27", P = "_link_29hv7_43", Q = "_badge_29hv7_47", T = "_linkIcon_29hv7_51", W = "_linkFocus_29hv7_61", X = "_controls_29hv7_69", o = {
16
- header: M,
17
- label: O,
18
- link: P,
19
- badge: Q,
20
- linkIcon: T,
21
- linkFocus: W,
22
- controls: X
23
- }, ho = ({
24
- as: _,
25
- highlightWords: v,
13
+ import { S as J, a as K } from "../../ChevronUp-_BBfEirx.js";
14
+ import { S as M } from "../../ChevronRight-ANFWmIs1.js";
15
+ import '../../assets/ListItemHeader.css';const O = "_header_29hv7_1", P = "_label_29hv7_27", Q = "_link_29hv7_43", T = "_badge_29hv7_47", W = "_linkIcon_29hv7_51", X = "_linkFocus_29hv7_61", Y = "_controls_29hv7_69", o = {
16
+ header: O,
17
+ label: P,
18
+ link: Q,
19
+ badge: T,
20
+ linkIcon: W,
21
+ linkFocus: X,
22
+ controls: Y
23
+ }, _o = ({
24
+ as: f,
25
+ highlightWords: I,
26
26
  interactive: a = !0,
27
- color: f,
27
+ color: k,
28
28
  loading: s,
29
29
  disabled: r,
30
- collapsible: I,
31
- linkIcon: k,
32
- expanded: u,
33
- select: l,
30
+ collapsible: c,
31
+ linkIcon: u,
32
+ expanded: l,
33
+ select: m,
34
34
  href: L,
35
- onClick: b,
36
- onKeyPress: N,
35
+ onClick: N,
36
+ onKeyPress: b,
37
37
  tabIndex: S,
38
- size: c,
38
+ size: h,
39
39
  title: n,
40
40
  description: C,
41
- icon: x,
42
- active: m,
43
- badge: t,
44
- controls: d,
45
- className: y,
46
- children: F,
47
- ariaLabel: h
41
+ icon: y,
42
+ active: d,
43
+ badge: e,
44
+ controls: _,
45
+ className: F,
46
+ children: j,
47
+ ariaLabel: p,
48
+ ariaControlsId: x
48
49
  }) => {
49
- const p = I ? u ? G : J : k ? K : void 0, j = () => t && !s && typeof t == "object" && "label" in t ? /* @__PURE__ */ e(D, { ...t, className: o.badge }) : z(t) ? t : null, g = h !== void 0 ? h : typeof n == "string" ? n : void 0, B = w();
50
+ const v = c ? l ? J : K : u ? M : void 0, g = () => e && !s && typeof e == "object" && "label" in e ? /* @__PURE__ */ t(H, { ...e, className: o.badge }) : A(e) ? e : null, B = p !== void 0 ? p : typeof n == "string" ? n : void 0, E = z();
50
51
  return /* @__PURE__ */ i(
51
52
  "div",
52
53
  {
53
- className: E(o.header, y),
54
- "data-color": f,
54
+ className: w(o.header, F),
55
+ "data-color": k,
55
56
  "data-interactive": a,
56
- "data-size": c,
57
- "data-has-active-child": m,
57
+ "data-size": h,
58
+ "data-has-active-child": d,
58
59
  "aria-disabled": r,
59
60
  children: [
60
61
  /* @__PURE__ */ i(
61
- H,
62
+ R,
62
63
  {
63
- as: _,
64
+ as: f,
64
65
  href: L,
65
- onClick: b,
66
- onKeyPress: N,
66
+ onClick: N,
67
+ onKeyPress: b,
67
68
  tabIndex: S,
68
69
  loading: s,
69
70
  disabled: r || s,
70
- active: m,
71
- ariaLabel: g,
71
+ active: d,
72
+ ariaLabel: B,
72
73
  className: o.link,
74
+ expanded: l,
75
+ ariaControlsId: x,
76
+ collapsible: c,
73
77
  children: [
74
- a && /* @__PURE__ */ e("div", { className: o.linkFocus, "aria-hidden": "true" }),
75
- l && /* @__PURE__ */ e(q, { ...l, className: o.select }),
76
- /* @__PURE__ */ e(U, { loading: s, icon: x }),
77
- /* @__PURE__ */ e(
78
- R,
78
+ a && /* @__PURE__ */ t("div", { className: o.linkFocus, "aria-hidden": "true" }),
79
+ m && /* @__PURE__ */ t(G, { ...m, className: o.select }),
80
+ /* @__PURE__ */ t(V, { loading: s, icon: y }),
81
+ /* @__PURE__ */ t(
82
+ U,
79
83
  {
80
- size: c,
84
+ size: h,
81
85
  loading: s,
82
- highlightWords: v,
86
+ highlightWords: I,
83
87
  title: n,
84
88
  description: C,
85
- id: B,
89
+ id: E,
86
90
  className: o.label,
87
- children: F
91
+ children: j
88
92
  }
89
93
  )
90
94
  ]
91
95
  }
92
96
  ),
93
- /* @__PURE__ */ i(V, { className: o.controls, children: [
94
- d && !s && /* @__PURE__ */ e("span", { className: o.customControls, children: d }),
95
- j(),
96
- p && !r && /* @__PURE__ */ e("span", { className: o.linkIcon, children: /* @__PURE__ */ e(
97
- A,
97
+ /* @__PURE__ */ i(q, { className: o.controls, children: [
98
+ _ && !s && /* @__PURE__ */ t("span", { className: o.customControls, children: _ }),
99
+ g(),
100
+ v && !r && /* @__PURE__ */ t("span", { className: o.linkIcon, children: /* @__PURE__ */ t(
101
+ D,
98
102
  {
99
- svgElement: p,
103
+ svgElement: v,
100
104
  style: {
101
105
  fontSize: "1.5rem"
102
106
  }
@@ -108,5 +112,5 @@ import '../../assets/ListItemHeader.css';const M = "_header_29hv7_1", O = "_labe
108
112
  );
109
113
  };
110
114
  export {
111
- ho as ListItemHeader
115
+ _o as ListItemHeader
112
116
  };
@@ -1,8 +1,8 @@
1
- import { jsx as p } from "react/jsx-runtime";
2
- import { c as v } from "../../index-L8X2o7IH.js";
3
- import '../../assets/ListItemLink.css';const f = "_link_c8adz_1", l = {
4
- link: f
5
- }, I = ({
1
+ import { jsx as v } from "react/jsx-runtime";
2
+ import { c as p } from "../../index-L8X2o7IH.js";
3
+ import '../../assets/ListItemLink.css';const I = "_link_c8adz_1", l = {
4
+ link: I
5
+ }, z = ({
6
6
  as: u,
7
7
  loading: a,
8
8
  disabled: e,
@@ -10,35 +10,40 @@ import '../../assets/ListItemLink.css';const f = "_link_c8adz_1", l = {
10
10
  href: s,
11
11
  onClick: t,
12
12
  onKeyPress: i,
13
- className: m,
14
- active: o,
13
+ className: d,
14
+ active: _,
15
15
  ariaLabel: n,
16
16
  children: c,
17
- tabIndex: _ = 0
17
+ tabIndex: b = 0,
18
+ expanded: m,
19
+ collapsible: f,
20
+ ariaControlsId: k
18
21
  }) => {
19
22
  const r = u || "div";
20
23
  if (r === "div")
21
- return /* @__PURE__ */ p("div", { className: v(l.link, m), children: c });
22
- const b = !a && s || r !== "a" && n;
23
- return /* @__PURE__ */ p(
24
+ return /* @__PURE__ */ v("div", { className: p(l.link, d), children: c });
25
+ const A = !a && s || r !== "a" && n;
26
+ return /* @__PURE__ */ v(
24
27
  r,
25
28
  {
26
- className: v(l.link, m),
29
+ className: p(l.link, d),
27
30
  href: s,
28
- onKeyPress: (d) => {
29
- d.key === "Enter" && (t == null || t()), i == null || i(d);
31
+ onKeyPress: (o) => {
32
+ o.key === "Enter" && (t == null || t()), i == null || i(o);
30
33
  },
31
34
  onClick: t,
32
35
  "data-interactive": "true",
33
36
  "aria-disabled": a || e,
34
37
  "aria-selected": x,
35
- ...b && { "aria-label": n },
36
- "data-active": o,
37
- tabIndex: a || e ? -1 : _,
38
+ "aria-expanded": f ? m : void 0,
39
+ "aria-controls": m ? k : void 0,
40
+ ...A && { "aria-label": n },
41
+ "data-active": _,
42
+ tabIndex: a || e ? -1 : b,
38
43
  children: c
39
44
  }
40
45
  );
41
46
  };
42
47
  export {
43
- I as ListItemLink
48
+ z as ListItemLink
44
49
  };
@@ -1,25 +1,25 @@
1
1
  "use client";
2
2
  import { jsx as m, jsxs as L } from "react/jsx-runtime";
3
3
  import { u as k } from "../../index-D-VWMqlv.js";
4
- import { useRef as R, useState as A, useEffect as y, useMemo as D } from "react";
4
+ import { useRef as R, useState as A, useEffect as y, useMemo as W } from "react";
5
5
  import "../../index-L8X2o7IH.js";
6
- import { useMenu as K } from "../../hooks/useMenu.js";
6
+ import { useMenu as D } from "../../hooks/useMenu.js";
7
7
  import "../RootProvider/RootProvider.js";
8
- import { MenuItem as V } from "./MenuItem.js";
9
- import { MenuSearch as W } from "./MenuSearch.js";
8
+ import { MenuItem as K } from "./MenuItem.js";
9
+ import { MenuSearch as V } from "./MenuSearch.js";
10
10
  import { MenuHeader as j } from "./MenuHeader.js";
11
- import { MenuList as N, MenuListItem as U } from "./MenuBase.js";
11
+ import { MenuList as N, MenuListItem as F } from "./MenuBase.js";
12
12
  import "../Snackbar/useSnackbar.js";
13
- import '../../assets/MenuItemsVirtual.css';const Y = "_virtualScrollRef_nmoqo_1", F = "_virtualMenuListItem_nmoqo_8", M = {
14
- virtualScrollRef: Y,
15
- virtualMenuListItem: F
13
+ import '../../assets/MenuItemsVirtual.css';const O = "_virtualScrollRef_nmoqo_1", U = "_virtualMenuListItem_nmoqo_8", M = {
14
+ virtualScrollRef: O,
15
+ virtualMenuListItem: U
16
16
  }, se = ({
17
17
  level: E = 0,
18
18
  search: g,
19
19
  items: z,
20
20
  groups: T = {},
21
- defaultItemSize: P,
22
- defaultItemColor: b,
21
+ defaultItemSize: b,
22
+ defaultItemColor: P,
23
23
  defaultItemVariant: q,
24
24
  defaultIconTheme: $,
25
25
  keyboardEvents: f,
@@ -35,12 +35,12 @@ import '../../assets/MenuItemsVirtual.css';const Y = "_virtualScrollRef_nmoqo_1"
35
35
  window.removeEventListener("resize", n);
36
36
  };
37
37
  }, []);
38
- const I = D(() => x && S - x - 8 || 400, [S, x]), C = {
38
+ const I = W(() => x && S - x - 8 || 400, [S, x]), C = {
39
39
  ...{
40
40
  maxHeight: I <= 300 ? 300 : I
41
41
  },
42
42
  ...H
43
- }, { menu: _ } = K({
43
+ }, { menu: _ } = D({
44
44
  items: z,
45
45
  groups: T,
46
46
  groupByKey: "groupId",
@@ -68,6 +68,7 @@ import '../../assets/MenuItemsVirtual.css';const Y = "_virtualScrollRef_nmoqo_1"
68
68
  ];
69
69
  }), d = k({
70
70
  count: v.length,
71
+ useAnimationFrameWithResizeObserver: !0,
71
72
  gap: 8,
72
73
  estimateSize: () => 44,
73
74
  getScrollElement: () => c.current
@@ -128,7 +129,7 @@ import '../../assets/MenuItemsVirtual.css';const Y = "_virtualScrollRef_nmoqo_1"
128
129
  zIndex: 10,
129
130
  marginTop: "-0.5rem"
130
131
  },
131
- children: /* @__PURE__ */ m(W, { ...g })
132
+ children: /* @__PURE__ */ m(V, { ...g })
132
133
  }
133
134
  ),
134
135
  /* @__PURE__ */ m(
@@ -141,7 +142,7 @@ import '../../assets/MenuItemsVirtual.css';const Y = "_virtualScrollRef_nmoqo_1"
141
142
  children: h.map((n) => {
142
143
  const t = v[n.index];
143
144
  return t ? /* @__PURE__ */ L(
144
- U,
145
+ F,
145
146
  {
146
147
  dataIndex: n.index,
147
148
  className: M.virtualMenuListItem,
@@ -150,11 +151,11 @@ import '../../assets/MenuItemsVirtual.css';const Y = "_virtualScrollRef_nmoqo_1"
150
151
  children: [
151
152
  t.type === "title" && /* @__PURE__ */ m(j, { title: t.title }),
152
153
  t.type === "item" && /* @__PURE__ */ m(
153
- V,
154
+ K,
154
155
  {
155
156
  ...t.itemProps,
156
- size: t.itemProps.size || P,
157
- color: t.itemProps.color || b,
157
+ size: t.itemProps.size || b,
158
+ color: t.itemProps.color || P,
158
159
  variant: t.itemProps.variant || q,
159
160
  iconTheme: t.itemProps.iconTheme || $,
160
161
  active: t.active,
@@ -8,14 +8,14 @@ import { Menu as x } from "../Menu/Menu.js";
8
8
  import "../Snackbar/useSnackbar.js";
9
9
  import { ToolbarButton as T } from "./ToolbarButton.js";
10
10
  import { ToolbarFilterBase as B } from "./ToolbarFilterBase.js";
11
- const v = ({ label: t = "Legg til", items: p, id: e }) => {
12
- const { currentId: i, closeAll: a, toggleId: d } = f(), o = i === e, l = () => d(e), m = u();
13
- return /* @__PURE__ */ c(B, { expanded: o, onBlurCapture: (n) => {
14
- const s = n.relatedTarget;
15
- (!s || !n.currentTarget.contains(s)) && a();
11
+ const v = ({ label: t = "Legg til", items: a, id: e }) => {
12
+ const { currentId: l, closeAll: n, toggleId: d } = f(), o = l === e, m = () => d(e), s = u();
13
+ return /* @__PURE__ */ c(B, { expanded: o, onBlurCapture: (p) => {
14
+ const i = p.relatedTarget;
15
+ s && (!i || !p.currentTarget.contains(i)) && n();
16
16
  }, children: [
17
- /* @__PURE__ */ r(T, { type: "add", onToggle: l, "aria-expanded": o, children: t }),
18
- /* @__PURE__ */ r(g, { drawerTitle: t, open: o, children: /* @__PURE__ */ r(x, { color: "neutral", items: p, keyboardEvents: o && m }) })
17
+ /* @__PURE__ */ r(T, { type: "add", onToggle: m, "aria-expanded": o, children: t }),
18
+ /* @__PURE__ */ r(g, { drawerTitle: t, open: o, onClose: n, children: /* @__PURE__ */ r(x, { color: "neutral", items: a, keyboardEvents: o && s }) })
19
19
  ] });
20
20
  };
21
21
  export {
@@ -13,26 +13,26 @@ const G = (u, n) => Array.isArray(n) ? n.join(", ") : n, Q = ({
13
13
  label: n,
14
14
  name: o,
15
15
  filterState: s,
16
- options: T,
17
- optionGroups: y,
18
- onChange: b,
19
- onRemove: x,
16
+ options: y,
17
+ optionGroups: b,
18
+ onChange: x,
19
+ onRemove: A,
20
20
  buttonAltText: l = "Remove button",
21
21
  getSelectedLabel: a,
22
- showResultsLabel: A = "Show results",
23
- optionType: f,
22
+ showResultsLabel: f = "Show results",
23
+ optionType: h,
24
24
  id: e = `toolbar-filter-${o}`
25
25
  }) => {
26
- const { currentId: h, toggleId: v, closeAll: d } = j(), I = g(), k = (T ?? []).map((r) => {
26
+ const { currentId: v, toggleId: I, closeAll: d } = j(), m = g(), k = (y ?? []).map((r) => {
27
27
  const t = s == null ? void 0 : s[r.name || o];
28
28
  return {
29
29
  name: o,
30
30
  ...r,
31
31
  checked: Array.isArray(t) ? t.includes(r.value) : r.value === t
32
32
  };
33
- }), c = s == null ? void 0 : s[o], w = (a == null ? void 0 : a(o, c)) ?? G(o, c), m = () => v(e), p = h === e, B = (r) => {
33
+ }), c = s == null ? void 0 : s[o], w = (a == null ? void 0 : a(o, c)) ?? G(o, c), T = () => I(e), p = v === e, B = (r) => {
34
34
  const t = r.relatedTarget;
35
- (!t || !r.currentTarget.contains(t)) && d();
35
+ m && (!t || !r.currentTarget.contains(t)) && d();
36
36
  }, C = Array.isArray(c) ? c.length > 0 : typeof c < "u";
37
37
  return /* @__PURE__ */ D(R, { expanded: p, onBlurCapture: B, dataTestId: "filter-base-" + e, children: [
38
38
  /* @__PURE__ */ i(
@@ -41,10 +41,10 @@ const G = (u, n) => Array.isArray(n) ? n.join(", ") : n, Q = ({
41
41
  type: "select",
42
42
  removable: u,
43
43
  active: C,
44
- onToggle: m,
44
+ onToggle: T,
45
45
  ariaLabel: l,
46
46
  iconAltText: l,
47
- onRemove: x,
47
+ onRemove: A,
48
48
  dataTestId: e,
49
49
  tabIndex: p ? -1 : 0,
50
50
  children: w || n
@@ -57,18 +57,18 @@ const G = (u, n) => Array.isArray(n) ? n.join(", ") : n, Q = ({
57
57
  drawerTitle: n,
58
58
  onClose: d,
59
59
  drawerButton: {
60
- onClick: m,
61
- label: A
60
+ onClick: T,
61
+ label: f
62
62
  },
63
63
  children: /* @__PURE__ */ i(
64
64
  E,
65
65
  {
66
66
  name: o,
67
67
  options: k,
68
- optionGroups: y,
69
- onChange: b,
70
- optionType: f,
71
- keyboardEvents: p && I
68
+ optionGroups: b,
69
+ onChange: x,
70
+ optionType: h,
71
+ keyboardEvents: p && m
72
72
  }
73
73
  )
74
74
  }
@@ -1,14 +1,10 @@
1
1
  function e(r) {
2
2
  if (r)
3
3
  try {
4
- const t = new Date(r);
5
- return Number.isNaN(t.getTime()) ? r : t.toLocaleDateString("no-NO", {
6
- day: "2-digit",
7
- month: "2-digit",
8
- year: "numeric"
9
- });
10
- } catch (t) {
11
- return console.warn("Error formatting date:", t), r;
4
+ const [o, t, n] = r.split("-");
5
+ return !o || !t || !n ? r : `${n}.${t}.${o}`;
6
+ } catch (o) {
7
+ return console.warn("Error formatting date:", o), r;
12
8
  }
13
9
  }
14
10
  export {
@@ -1,15 +1,17 @@
1
- import { describe as d, test as o, expect as e } from "vitest";
1
+ import { describe as a, beforeEach as i, vi as d, test as o, expect as e } from "vitest";
2
2
  import { formatDate as t } from "./date.js";
3
- d("dateUtils", () => {
4
- d("formatDate", () => {
3
+ a("dateUtils", () => {
4
+ i(() => {
5
+ d.stubEnv("TZ", "UTC");
6
+ }), a("formatDate", () => {
5
7
  o("should format ISO date to Norwegian DD.MM.YYYY format", () => {
6
- e(t("1990-12-25")).toBe("25.12.1990"), e(t("2000-01-01")).toBe("01.01.2000"), e(t("1985-06-15")).toBe("15.06.1985");
8
+ e(t("1990-12-25")).toBe("25.12.1990"), e(t("2000-01-01")).toBe("01.01.2000"), e(t("1985-06-15")).toBe("15.06.1985"), d.stubEnv("TZ", "EST"), e(t("1990-12-25")).toBe("25.12.1990"), e(t("2000-01-01")).toBe("01.01.2000"), e(t("1985-06-15")).toBe("15.06.1985");
7
9
  }), o("should handle undefined input", () => {
8
10
  e(t(void 0)).toBeUndefined();
9
11
  }), o("should handle invalid date strings", () => {
10
12
  e(t("invalid-date")).toBe("invalid-date"), e(t("")).toBe(void 0);
11
13
  }), o("should handle edge cases", () => {
12
- e(t("2024-02-29")).toBe("29.02.2024"), e(t("2023-12-31")).toBe("31.12.2023");
14
+ e(t("2024-02-29")).toBe("29.02.2024"), e(t("2023-12-31")).toBe("31.12.2023"), d.stubEnv("TZ", "EST"), e(t("2024-02-29")).toBe("29.02.2024"), e(t("2023-12-31")).toBe("31.12.2023");
13
15
  });
14
16
  });
15
17
  });
@@ -59,6 +59,7 @@ declare const meta: {
59
59
  href?: string | undefined;
60
60
  onClick?: (() => void) | undefined;
61
61
  onKeyPress?: React.KeyboardEventHandler | undefined;
62
+ ariaControlsId?: string | undefined;
62
63
  favourite?: boolean | undefined;
63
64
  favouriteLabel?: string | undefined;
64
65
  onToggleFavourite?: ((id: string) => void) | undefined;
@@ -40,4 +40,4 @@ export interface ListItemHeaderProps extends ListItemLinkProps {
40
40
  /** Used as decerning text for the ListItem without title, defaults to title */
41
41
  ariaLabel?: string;
42
42
  }
43
- export declare const ListItemHeader: ({ as, highlightWords, interactive, color, loading, disabled, collapsible, linkIcon, expanded, select, href, onClick, onKeyPress, tabIndex, size, title, description, icon, active, badge, controls, className, children, ariaLabel, }: ListItemHeaderProps) => import("react/jsx-runtime").JSX.Element;
43
+ export declare const ListItemHeader: ({ as, highlightWords, interactive, color, loading, disabled, collapsible, linkIcon, expanded, select, href, onClick, onKeyPress, tabIndex, size, title, description, icon, active, badge, controls, className, children, ariaLabel, ariaControlsId, }: ListItemHeaderProps) => import("react/jsx-runtime").JSX.Element;
@@ -12,5 +12,8 @@ export interface ListItemLinkProps {
12
12
  className?: string;
13
13
  active?: boolean;
14
14
  children?: React.ReactNode;
15
+ expanded?: boolean;
16
+ collapsible?: boolean;
17
+ ariaControlsId?: string;
15
18
  }
16
- export declare const ListItemLink: ({ as, loading, disabled, selected, href, onClick, onKeyPress, className, active, ariaLabel, children, tabIndex, }: ListItemLinkProps) => import("react/jsx-runtime").JSX.Element;
19
+ export declare const ListItemLink: ({ as, loading, disabled, selected, href, onClick, onKeyPress, className, active, ariaLabel, children, tabIndex, expanded, collapsible, ariaControlsId, }: ListItemLinkProps) => import("react/jsx-runtime").JSX.Element;
@@ -50,6 +50,7 @@ declare const meta: {
50
50
  href?: string | undefined;
51
51
  onClick?: (() => void) | undefined;
52
52
  onKeyPress?: React.KeyboardEventHandler | undefined;
53
+ ariaControlsId?: string | undefined;
53
54
  }>) => import("react/jsx-runtime").JSX.Element)[];
54
55
  };
55
56
  export default meta;
@@ -49,6 +49,7 @@ declare const meta: {
49
49
  containerAs?: React.ElementType | undefined;
50
50
  shadow?: import('..').Shadow | undefined;
51
51
  collapsible?: boolean | undefined;
52
+ ariaControlsId?: string | undefined;
52
53
  };
53
54
  };
54
55
  export default meta;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.50.4",
3
+ "version": "0.50.6",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",