@altinn/altinn-components 0.67.8 → 0.67.10

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,8 +1,8 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
- import '../../assets/MenuListDivider.css';const d = "_item_10r5c_1", n = "_divider_10r5c_6", i = {
3
- item: d,
2
+ import '../../assets/MenuListDivider.css';const s = "_item_10r5c_1", n = "_divider_10r5c_6", i = {
3
+ item: s,
4
4
  divider: n
5
- }, o = ({ ref: r, style: t, index: s }) => /* @__PURE__ */ e("li", { className: i.item, role: "presentation", ref: r, style: t, "data-index": s, children: /* @__PURE__ */ e("hr", { className: i.divider }) });
5
+ }, c = ({ ref: r, style: t, index: d }) => /* @__PURE__ */ e("li", { className: i.item, role: "presentation", "aria-hidden": "true", ref: r, style: t, "data-index": d, children: /* @__PURE__ */ e("hr", { className: i.divider }) });
6
6
  export {
7
- o as MenuListDivider
7
+ c as MenuListDivider
8
8
  };
@@ -1,6 +1,6 @@
1
- import { jsxs as l, Fragment as L, jsx as i } from "react/jsx-runtime";
2
- import { useMemo as N, useState as O, createElement as y } from "react";
3
- import { Button as E } from "../Button/Button.js";
1
+ import { jsxs as l, Fragment as N, jsx as i } from "react/jsx-runtime";
2
+ import { useMemo as O, useState as y, createElement as E } from "react";
3
+ import { Button as L } from "../Button/Button.js";
4
4
  import "../../index-p1eeF8LQ.js";
5
5
  import "../../tooltip-Ct39-719.js";
6
6
  import { s as X } from "../../ToolbarSearch-DyVcALSw.js";
@@ -17,7 +17,7 @@ const oo = ({
17
17
  filters: r,
18
18
  filterState: e = {},
19
19
  onFilterStateChange: t,
20
- addLabel: b = "Legg til filter",
20
+ addLabel: s = "Legg til filter",
21
21
  addNextLabel: T = "Legg til",
22
22
  resetLabel: j = "Nullstill",
23
23
  removeLabel: M = "Fjern filter",
@@ -25,39 +25,39 @@ const oo = ({
25
25
  getFilterLabel: x,
26
26
  virtualized: A,
27
27
  showResetButton: R = !0,
28
- controls: s
28
+ controls: a
29
29
  }) => {
30
- const { visibleFilters: a, hiddenFilters: d, onFilterAdd: f, onFilterChange: B, onFilterRemove: p } = w({
30
+ const { visibleFilters: p, hiddenFilters: d, onFilterAdd: f, onFilterChange: B, onFilterRemove: c } = w({
31
31
  filters: r,
32
32
  filterState: e,
33
33
  onFilterStateChange: t
34
- }), c = N(
34
+ }), g = O(
35
35
  () => r?.filter((o) => o.removable)?.map((o) => o.name) ?? [],
36
36
  [r]
37
- ), g = R && c.length > 0 && Object.values(e)?.some((o) => o && o?.length > 0), [u, h] = O(void 0), v = (o) => {
38
- h((m) => m === o ? void 0 : o);
39
- }, F = () => {
40
- h(void 0);
37
+ ), u = R && g.length > 0 && Object.values(e)?.some((o) => o && o?.length > 0), [h, v] = y(void 0), F = (o) => {
38
+ v((m) => m === o ? void 0 : o);
39
+ }, b = () => {
40
+ v(void 0);
41
41
  }, C = () => {
42
- for (const o of c)
43
- p(o);
42
+ for (const o of g)
43
+ c(o);
44
44
  t?.({});
45
45
  };
46
- return /* @__PURE__ */ l(L, { children: [
47
- a?.map((o, m) => {
46
+ return /* @__PURE__ */ l(N, { children: [
47
+ p?.map((o, m) => {
48
48
  const I = x?.(o?.name, e?.[o?.id]) ?? o?.label;
49
- return /* @__PURE__ */ y(
49
+ return /* @__PURE__ */ E(
50
50
  q,
51
51
  {
52
52
  ...o,
53
53
  disabled: n,
54
54
  submitLabel: k,
55
55
  key: m,
56
- onToggle: () => v(o.name),
57
- onClose: F,
58
- open: u === o.name,
56
+ onToggle: () => F(o.name),
57
+ onClose: b,
58
+ open: h === o.name,
59
59
  label: I,
60
- onRemove: () => p(o.name),
60
+ onRemove: () => c(o.name),
61
61
  removeLabel: M,
62
62
  onFilterChange: B,
63
63
  onFilterStateChange: t,
@@ -69,21 +69,22 @@ const oo = ({
69
69
  D,
70
70
  {
71
71
  name: "add",
72
- onToggle: () => v("add"),
73
- onClose: F,
74
- open: u === "add",
72
+ onToggle: () => F("add"),
73
+ onClose: b,
74
+ open: h === "add",
75
75
  items: d,
76
76
  onAdd: f,
77
- label: a?.length > 0 ? T : b,
78
- virtualized: A
77
+ label: p?.length > 0 ? T : s,
78
+ virtualized: A,
79
+ title: s
79
80
  }
80
81
  ),
81
- (g || s) && /* @__PURE__ */ l(z, { children: [
82
- !n && g && /* @__PURE__ */ l(E, { onClick: C, variant: "ghost", children: [
82
+ (u || a) && /* @__PURE__ */ l(z, { children: [
83
+ !n && u && /* @__PURE__ */ l(L, { onClick: C, variant: "ghost", children: [
83
84
  /* @__PURE__ */ i(X, { "aria-hidden": "true" }),
84
85
  /* @__PURE__ */ i("span", { children: j })
85
86
  ] }),
86
- s
87
+ a
87
88
  ] })
88
89
  ] });
89
90
  };
@@ -1,15 +1,15 @@
1
- import { jsx as t, jsxs as h } from "react/jsx-runtime";
2
- import { useRef as a, useEffect as y } from "react";
3
- import { Button as v } from "../Button/Button.js";
1
+ import { jsx as t, jsxs as y } from "react/jsx-runtime";
2
+ import { useRef as a, useEffect as v } from "react";
3
+ import { Button as w } from "../Button/Button.js";
4
4
  import "../../index-p1eeF8LQ.js";
5
5
  import "../../tooltip-Ct39-719.js";
6
- import { g as w, M as x } from "../../ToolbarSearch-DyVcALSw.js";
6
+ import { g as x, M as C } from "../../ToolbarSearch-DyVcALSw.js";
7
7
  import "../Typography/Link.js";
8
- import { useDropdownMenuController as C } from "../Menu/useDropdownMenuController.js";
8
+ import { useDropdownMenuController as R } from "../Menu/useDropdownMenuController.js";
9
9
  import "../GlobalMenu/GlobalMenuBase.js";
10
10
  import "../Snackbar/useSnackbar.js";
11
- import { S as R } from "../../Plus-Cj3oOc3N.js";
12
- const D = ({
11
+ import { S as I } from "../../Plus-Cj3oOc3N.js";
12
+ const L = ({
13
13
  label: i = "Legg til filter",
14
14
  items: d,
15
15
  groups: l = {},
@@ -17,29 +17,31 @@ const D = ({
17
17
  onToggle: u,
18
18
  onClose: c,
19
19
  open: r,
20
- dropdownSize: p = "sm"
20
+ title: p,
21
+ dropdownSize: f = "sm"
21
22
  }) => {
22
- const e = C({ id: "tool-filter-add" }), n = a(r), f = a(!1), s = d?.map((o) => ({
23
+ const e = R({ id: "tool-filter-add" }), n = a(r), g = a(!1), s = d?.map((o) => ({
23
24
  linkIcon: !0,
24
25
  ...o,
25
26
  onClick: () => m?.(o?.name ?? "")
26
27
  }));
27
- if (y(() => {
28
+ if (v(() => {
28
29
  const o = n.current;
29
30
  n.current = r, o && !r && e?.triggerRef?.current?.focus();
30
31
  }, [r, e.triggerRef]), !s?.length)
31
32
  return null;
32
- const g = () => {
33
+ const h = () => {
33
34
  const o = document.getElementById(e.menuId);
34
- f.current = !!o?.querySelector('[aria-haspopup="menu"][aria-expanded="true"]'), c();
35
+ g.current = !!o?.querySelector('[aria-haspopup="menu"][aria-expanded="true"]'), c();
35
36
  };
36
37
  return /* @__PURE__ */ t(
37
- w,
38
+ x,
38
39
  {
39
40
  variant: "drawer-dropdown",
40
- size: p,
41
- trigger: /* @__PURE__ */ h(
42
- v,
41
+ size: f,
42
+ title: p,
43
+ trigger: /* @__PURE__ */ y(
44
+ w,
43
45
  {
44
46
  variant: "secondary",
45
47
  style: {
@@ -51,18 +53,18 @@ const D = ({
51
53
  onClick: u,
52
54
  ref: e.triggerRef,
53
55
  children: [
54
- /* @__PURE__ */ t(R, { "aria-hidden": "true", focusable: "false" }),
56
+ /* @__PURE__ */ t(I, { "aria-hidden": "true", focusable: "false" }),
55
57
  /* @__PURE__ */ t("span", { children: i })
56
58
  ]
57
59
  }
58
60
  ),
59
61
  open: r,
60
- onClose: g,
62
+ onClose: h,
61
63
  ...e.dropdownA11yProps,
62
- children: /* @__PURE__ */ t(x, { groups: l, items: s, maxLevels: 1, keyboardEvents: r, open: r, ...e.menuA11yProps })
64
+ children: /* @__PURE__ */ t(C, { groups: l, items: s, maxLevels: 1, keyboardEvents: r, open: r, ...e.menuA11yProps })
63
65
  }
64
66
  );
65
67
  };
66
68
  export {
67
- D as ToolbarFilterAddMenu
69
+ L as ToolbarFilterAddMenu
68
70
  };
@@ -1,19 +1,19 @@
1
- const g = ({ fullName: a, type: r, reverseNameOrder: c }) => {
1
+ const g = ({ fullName: a, type: r, reverseNameOrder: l }) => {
2
2
  if (!a) return "";
3
- const p = ["enk", "as", "da", "sa", "asa", "ba", "ans", "sti", "nuf"], i = a.split(" "), f = (t) => {
4
- if (!t.includes(".")) return !1;
5
- const s = t.split(".").filter((e) => e.length > 0);
6
- return s.length > 0 && s.every((e) => e.length <= 3);
7
- }, u = (t, s) => {
8
- const e = s === i.length - 1, o = t.toLowerCase();
9
- return r === "company" && e && p.includes(o) ? o.toUpperCase() : r === "company" && f(t) ? t : o.split("-").map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("-");
3
+ const p = ["enk", "as", "da", "sa", "asa", "ba", "ans", "sti", "nuf"], u = ["kommune", "fylkeskommune", "og"], i = a.split(" "), f = (s) => {
4
+ if (!s.includes(".")) return !1;
5
+ const e = s.split(".").filter((n) => n.length > 0);
6
+ return e.length > 0 && e.every((n) => n.length <= 3);
7
+ }, m = (s, e) => {
8
+ const n = e === i.length - 1, t = s.toLowerCase();
9
+ return r === "company" && n && p.includes(t) ? t.toUpperCase() : r === "company" && e > 0 && u.includes(t) ? t : r === "company" && f(s) ? s : t.split("-").map((c) => c.charAt(0).toUpperCase() + c.slice(1)).join("-");
10
10
  };
11
- let n = i.map(u);
12
- if (r === "person" && c && n.length > 1) {
13
- const [t, ...s] = n;
14
- n = [...s, t];
11
+ let o = i.map(m);
12
+ if (r === "person" && l && o.length > 1) {
13
+ const [s, ...e] = o;
14
+ o = [...e, s];
15
15
  }
16
- return n.join(" ");
16
+ return o.join(" ");
17
17
  };
18
18
  export {
19
19
  g as formatDisplayName
@@ -1,35 +1,65 @@
1
- import { describe as s, it as e, expect as t } from "vitest";
1
+ import { describe as o, it as t, expect as e } from "vitest";
2
2
  import { formatDisplayName as a } from "./name.js";
3
- s("formatDisplayName", () => {
4
- e("formats a simple person name", () => {
5
- t(a({ fullName: "TEST TESTESEN", type: "person" })).toBe("Test Testesen");
6
- }), e("formats a person name with reordering (surname first)", () => {
7
- t(a({ fullName: "TESTESEN TEST", type: "person", reverseNameOrder: !0 })).toBe(
3
+ o("formatDisplayName", () => {
4
+ t("formats a simple person name", () => {
5
+ e(a({ fullName: "TEST TESTESEN", type: "person" })).toBe("Test Testesen");
6
+ }), t("formats a person name with reordering (surname first)", () => {
7
+ e(a({ fullName: "TESTESEN TEST", type: "person", reverseNameOrder: !0 })).toBe(
8
8
  "Test Testesen"
9
9
  );
10
- }), e("formats a person name with hyphenated last name", () => {
11
- t(a({ fullName: "TEST TESTY-TEST", type: "person" })).toBe("Test Testy-Test");
12
- }), e("formats a company name and uppercases legal entity suffix", () => {
13
- t(a({ fullName: "test as", type: "company" })).toBe("Test AS");
14
- }), e("formats a company name and uppercases legal entity suffix", () => {
15
- t(a({ fullName: "WORK AS FRIENDS AS", type: "company" })).toBe("Work As Friends AS");
16
- }), e("handles company names with hyphenation and suffix", () => {
17
- t(a({ fullName: "test testy-test da", type: "company" })).toBe("Test Testy-Test DA");
18
- }), e("returns empty string for empty input", () => {
19
- t(a({ fullName: "", type: "person" })).toBe("");
20
- }), e("preserves abbreviations with periods in company names", () => {
21
- t(a({ fullName: "A.B.C AS", type: "company" })).toBe("A.B.C AS");
22
- }), e("preserves multiple abbreviations in company name", () => {
23
- t(a({ fullName: "A.B.C X.Y.Z AS", type: "company" })).toBe("A.B.C X.Y.Z AS");
24
- }), e("preserves abbreviation and formats regular words in company name", () => {
25
- t(a({ fullName: "A.B.C consulting AS", type: "company" })).toBe("A.B.C Consulting AS");
26
- }), e("formats regular company name without abbreviations", () => {
27
- t(a({ fullName: "acme corporation AS", type: "company" })).toBe("Acme Corporation AS");
28
- }), e("preserves two-letter abbreviation with period", () => {
29
- t(a({ fullName: "A.B. services AS", type: "company" })).toBe("A.B. Services AS");
30
- }), e("does not treat long segments as abbreviations", () => {
31
- t(a({ fullName: "test.company AS", type: "company" })).toBe("Test.company AS");
32
- }), e("does not affect person names with periods", () => {
33
- t(a({ fullName: "TEST A.B.C", type: "person" })).toBe("Test A.b.c");
10
+ }), t("formats a person name with hyphenated last name", () => {
11
+ e(a({ fullName: "TEST TESTY-TEST", type: "person" })).toBe("Test Testy-Test");
12
+ }), t("formats a company name and uppercases legal entity suffix", () => {
13
+ e(a({ fullName: "test as", type: "company" })).toBe("Test AS");
14
+ }), t("formats a company name and uppercases legal entity suffix", () => {
15
+ e(a({ fullName: "WORK AS FRIENDS AS", type: "company" })).toBe("Work As Friends AS");
16
+ }), t("handles company names with hyphenation and suffix", () => {
17
+ e(a({ fullName: "test testy-test da", type: "company" })).toBe("Test Testy-Test DA");
18
+ }), t("returns empty string for empty input", () => {
19
+ e(a({ fullName: "", type: "person" })).toBe("");
20
+ }), t("preserves abbreviations with periods in company names", () => {
21
+ e(a({ fullName: "A.B.C AS", type: "company" })).toBe("A.B.C AS");
22
+ }), t("preserves multiple abbreviations in company name", () => {
23
+ e(a({ fullName: "A.B.C X.Y.Z AS", type: "company" })).toBe("A.B.C X.Y.Z AS");
24
+ }), t("preserves abbreviation and formats regular words in company name", () => {
25
+ e(a({ fullName: "A.B.C consulting AS", type: "company" })).toBe("A.B.C Consulting AS");
26
+ }), t("formats regular company name without abbreviations", () => {
27
+ e(a({ fullName: "acme corporation AS", type: "company" })).toBe("Acme Corporation AS");
28
+ }), t("preserves two-letter abbreviation with period", () => {
29
+ e(a({ fullName: "A.B. services AS", type: "company" })).toBe("A.B. Services AS");
30
+ }), t("does not treat long segments as abbreviations", () => {
31
+ e(a({ fullName: "test.company AS", type: "company" })).toBe("Test.company AS");
32
+ }), t("does not affect person names with periods", () => {
33
+ e(a({ fullName: "TEST A.B.C", type: "person" })).toBe("Test A.b.c");
34
+ }), o("municipalities (kommuner)", () => {
35
+ t('lowercases "kommune" for a single-word municipality', () => {
36
+ e(a({ fullName: "OSLO KOMMUNE", type: "company" })).toBe("Oslo kommune");
37
+ }), t('lowercases "kommune" for a multi-word place name', () => {
38
+ e(a({ fullName: "NORDRE LAND KOMMUNE", type: "company" })).toBe("Nordre Land kommune");
39
+ }), t("handles hyphenated municipality names", () => {
40
+ e(a({ fullName: "NORD-AURDAL KOMMUNE", type: "company" })).toBe("Nord-Aurdal kommune");
41
+ }), t("handles Norwegian characters in municipality names", () => {
42
+ e(a({ fullName: "BÆRUM KOMMUNE", type: "company" })).toBe("Bærum kommune"), e(a({ fullName: "TRØNDELAG FYLKESKOMMUNE", type: "company" })).toBe(
43
+ "Trøndelag fylkeskommune"
44
+ );
45
+ }), t('lowercases "fylkeskommune" for county municipalities', () => {
46
+ e(a({ fullName: "VIKEN FYLKESKOMMUNE", type: "company" })).toBe("Viken fylkeskommune");
47
+ }), t('lowercases the conjunction "og" in county municipality names', () => {
48
+ e(a({ fullName: "MØRE OG ROMSDAL FYLKESKOMMUNE", type: "company" })).toBe(
49
+ "Møre og Romsdal fylkeskommune"
50
+ ), e(a({ fullName: "TROMS OG FINNMARK FYLKESKOMMUNE", type: "company" })).toBe(
51
+ "Troms og Finnmark fylkeskommune"
52
+ );
53
+ }), t("keeps capitalizing subsequent words (e.g. sub-units)", () => {
54
+ e(a({ fullName: "OSLO KOMMUNE UTDANNINGSETATEN", type: "company" })).toBe(
55
+ "Oslo kommune Utdanningsetaten"
56
+ );
57
+ }), t('capitalizes "Kommune" when it is the first word of the name', () => {
58
+ e(a({ fullName: "KOMMUNE TEST AS", type: "company" })).toBe("Kommune Test AS");
59
+ }), t('capitalizes "Og" when it is the first word of the name', () => {
60
+ e(a({ fullName: "OG TEST AS", type: "company" })).toBe("Og Test AS");
61
+ }), t("does not lowercase generic nouns for person names", () => {
62
+ e(a({ fullName: "OLA KOMMUNE", type: "person" })).toBe("Ola Kommune");
63
+ });
34
64
  });
35
65
  });
@@ -25,12 +25,13 @@ export declare const Trash: () => import("react/jsx-runtime").JSX.Element;
25
25
  export declare const AllCompanies: () => import("react/jsx-runtime").JSX.Element;
26
26
  export declare const AllCompaniesLimit: () => import("react/jsx-runtime").JSX.Element;
27
27
  export declare const AllCompaniesPage: () => import("react/jsx-runtime").JSX.Element;
28
- export declare const Search: ({ pageId, title, description, query, children, }: {
28
+ export declare const Search: ({ pageId, title, hightlightWords, description, query, children, }: {
29
29
  pageId?: string;
30
30
  title?: string;
31
31
  description?: ReactNode;
32
32
  query?: UseInboxQuery;
33
33
  children?: ReactNode;
34
+ hightlightWords?: string[];
34
35
  }) => import("react/jsx-runtime").JSX.Element;
35
36
  export declare const SearchInbox: () => import("react/jsx-runtime").JSX.Element;
36
37
  export declare const SearchArchive: () => import("react/jsx-runtime").JSX.Element;
@@ -7,4 +7,4 @@ export interface ToolbarFilterAddMenuProps extends FilterProps {
7
7
  onClose: () => void;
8
8
  onAdd?: (name: string) => void;
9
9
  }
10
- export declare const ToolbarFilterAddMenu: ({ label, items, groups, onAdd, onToggle, onClose, open, dropdownSize, }: ToolbarFilterAddMenuProps) => import("react/jsx-runtime").JSX.Element | null;
10
+ export declare const ToolbarFilterAddMenu: ({ label, items, groups, onAdd, onToggle, onClose, open, title, dropdownSize, }: ToolbarFilterAddMenuProps) => import("react/jsx-runtime").JSX.Element | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@altinn/altinn-components",
3
- "version": "0.67.8",
3
+ "version": "0.67.10",
4
4
  "main": "dist/index.js",
5
5
  "files": [
6
6
  "dist/",