@altinn/altinn-components 0.68.2 → 0.68.3
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,20 +1,39 @@
|
|
|
1
|
-
const
|
|
1
|
+
const d = ({ fullName: a, type: o, reverseNameOrder: c }) => {
|
|
2
2
|
if (!a) return "";
|
|
3
|
-
const
|
|
3
|
+
const f = [
|
|
4
|
+
"enk",
|
|
5
|
+
"as",
|
|
6
|
+
"da",
|
|
7
|
+
"sa",
|
|
8
|
+
"asa",
|
|
9
|
+
"ba",
|
|
10
|
+
"ans",
|
|
11
|
+
"sti",
|
|
12
|
+
"nuf",
|
|
13
|
+
"se",
|
|
14
|
+
"fkf",
|
|
15
|
+
"kf",
|
|
16
|
+
"ks",
|
|
17
|
+
"iks",
|
|
18
|
+
"gfs",
|
|
19
|
+
"sf",
|
|
20
|
+
"hf",
|
|
21
|
+
"rhf"
|
|
22
|
+
], p = ["kommune", "fylkeskommune", "og"], u = ["von", "van", "der", "de", "la", "dos"], i = a.split(" "), m = (s) => {
|
|
4
23
|
if (!s.includes(".")) return !1;
|
|
5
|
-
const e = s.split(".").filter((
|
|
6
|
-
return e.length > 0 && e.every((
|
|
7
|
-
},
|
|
8
|
-
const
|
|
9
|
-
return
|
|
24
|
+
const e = s.split(".").filter((t) => t.length > 0);
|
|
25
|
+
return e.length > 0 && e.every((t) => t.length <= 3);
|
|
26
|
+
}, g = (s, e) => {
|
|
27
|
+
const t = e === i.length - 1, n = s.toLowerCase();
|
|
28
|
+
return o === "company" && t && f.includes(n) ? n.toUpperCase() : o === "company" && e > 0 && p.includes(n) || e > 0 && u.includes(n) ? n : m(s) ? s.toUpperCase() : n.split("-").map((l) => l.charAt(0).toUpperCase() + l.slice(1)).join("-");
|
|
10
29
|
};
|
|
11
|
-
let
|
|
12
|
-
if (
|
|
13
|
-
const [s, ...e] =
|
|
14
|
-
|
|
30
|
+
let r = i.map(g);
|
|
31
|
+
if (o === "person" && c && r.length > 1) {
|
|
32
|
+
const [s, ...e] = r;
|
|
33
|
+
r = [...e, s];
|
|
15
34
|
}
|
|
16
|
-
return
|
|
35
|
+
return r.join(" ");
|
|
17
36
|
};
|
|
18
37
|
export {
|
|
19
|
-
|
|
38
|
+
d as formatDisplayName
|
|
20
39
|
};
|
|
@@ -29,8 +29,21 @@ o("formatDisplayName", () => {
|
|
|
29
29
|
e(a({ fullName: "A.B. services AS", type: "company" })).toBe("A.B. Services AS");
|
|
30
30
|
}), t("does not treat long segments as abbreviations", () => {
|
|
31
31
|
e(a({ fullName: "test.company AS", type: "company" })).toBe("Test.company AS");
|
|
32
|
-
}), t("
|
|
33
|
-
e(a({ fullName: "TEST A.B.C", type: "person" })).toBe("Test A.
|
|
32
|
+
}), t("preserves and uppercases initials in person names", () => {
|
|
33
|
+
e(a({ fullName: "TEST A.B.C", type: "person" })).toBe("Test A.B.C"), e(a({ fullName: "ola j. k. nordmann", type: "person" })).toBe("Ola J. K. Nordmann");
|
|
34
|
+
}), o("legal entity suffixes", () => {
|
|
35
|
+
t.each(["se", "fkf", "kf", "ks", "iks", "gfs", "sf", "hf", "rhf", "sti"])(
|
|
36
|
+
'uppercases the "%s" suffix for companies',
|
|
37
|
+
(n) => {
|
|
38
|
+
e(a({ fullName: `test ${n}`, type: "company" })).toBe(`Test ${n.toUpperCase()}`);
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}), o("nobiliary particles", () => {
|
|
42
|
+
t("lowercases particles when not the first word", () => {
|
|
43
|
+
e(a({ fullName: "CHARLES DE GAULLE", type: "person" })).toBe("Charles de Gaulle"), e(a({ fullName: "LUDWIG VAN BEETHOVEN", type: "person" })).toBe("Ludwig van Beethoven");
|
|
44
|
+
}), t("capitalizes a particle when it is the first word", () => {
|
|
45
|
+
e(a({ fullName: "DE GAULLE CHARLES", type: "person" })).toBe("De Gaulle Charles");
|
|
46
|
+
});
|
|
34
47
|
}), o("municipalities (kommuner)", () => {
|
|
35
48
|
t('lowercases "kommune" for a single-word municipality', () => {
|
|
36
49
|
e(a({ fullName: "OSLO KOMMUNE", type: "company" })).toBe("Oslo kommune");
|