@oslokommune/punkt-elements 16.7.0 → 16.7.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.
Files changed (193) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/accordionitem-_9AiCIvd.cjs +34 -0
  3. package/dist/{accordionitem-ZlaXvjt5.js → accordionitem-dCfSrxh5.js} +57 -55
  4. package/dist/alert-BtOk8yRH.cjs +33 -0
  5. package/dist/{alert-BuAXrnKl.js → alert-DlY2_grU.js} +48 -46
  6. package/dist/backlink-Ce5Vldop.js +49 -0
  7. package/dist/backlink-y3dwjKPC.cjs +13 -0
  8. package/dist/button-B_TXwNzt.cjs +27 -0
  9. package/dist/{button-DEyvt1LI.js → button-BiY-wlKF.js} +79 -77
  10. package/dist/calendar-B2pji2zn.cjs +90 -0
  11. package/dist/{calendar-S63oreVW.js → calendar-DhjQDC4C.js} +689 -687
  12. package/dist/card-BwMNB5Bb.cjs +87 -0
  13. package/dist/{card-DDiLfuO4.js → card-CGlmcMSR.js} +99 -97
  14. package/dist/checkbox-BsJZYA26.js +147 -0
  15. package/dist/checkbox-CTY8f_qn.cjs +31 -0
  16. package/dist/{combobox-BmxSecfE.js → combobox-DSB5WOxg.js} +223 -226
  17. package/dist/{combobox-Hb2V-fPX.cjs → combobox-DbICIgKG.cjs} +4 -4
  18. package/dist/consent-DkOQpbsg.cjs +11 -0
  19. package/dist/{consent-iXyx5v6J.js → consent-SNWV_mMU.js} +48 -46
  20. package/dist/datepicker-BEWl9iz3.cjs +273 -0
  21. package/dist/{datepicker-CZl7b8Na.js → datepicker-euHyzXnb.js} +341 -329
  22. package/dist/{heading-CKt7cVn7.js → heading-D2tVS6lS.js} +30 -28
  23. package/dist/heading-DrzbgDb6.cjs +1 -0
  24. package/dist/helptext-BKtU4mas.js +82 -0
  25. package/dist/helptext-DcRC7wW2.cjs +24 -0
  26. package/dist/icon-CxQcIa5F.js +105 -0
  27. package/dist/icon-q81vqPK_.cjs +9 -0
  28. package/dist/input-wrapper-Bs4CRNst.js +181 -0
  29. package/dist/input-wrapper-Bv9aqqVq.cjs +54 -0
  30. package/dist/link-C0rl-86s.cjs +7 -0
  31. package/dist/link-Cdqgl60z.js +55 -0
  32. package/dist/linkcard-Dimu7Rlx.cjs +13 -0
  33. package/dist/linkcard-Lbq_UhjZ.js +56 -0
  34. package/dist/{listbox-BQKDZvZn.js → listbox-Bia4_tvN.js} +131 -129
  35. package/dist/listbox-La2GZQei.cjs +106 -0
  36. package/dist/loader-D1ugDXGV.cjs +16 -0
  37. package/dist/{loader-Ci3CHU8k.js → loader-DyN6RGC5.js} +51 -49
  38. package/dist/messagebox-BGMVm2t9.js +71 -0
  39. package/dist/messagebox-M0yIgCz9.cjs +13 -0
  40. package/dist/modal-CMO1RtIi.cjs +36 -0
  41. package/dist/{modal-DzGe1g8Z.js → modal-DjPQDE-Z.js} +53 -51
  42. package/dist/pkt-accordion.cjs +1 -1
  43. package/dist/pkt-accordion.js +2 -2
  44. package/dist/pkt-alert.cjs +1 -1
  45. package/dist/pkt-alert.js +3 -4
  46. package/dist/pkt-backlink.cjs +1 -1
  47. package/dist/pkt-backlink.js +2 -3
  48. package/dist/pkt-breadcrumbs.cjs +11 -11
  49. package/dist/pkt-breadcrumbs.js +30 -28
  50. package/dist/pkt-button.cjs +1 -1
  51. package/dist/pkt-button.js +3 -4
  52. package/dist/pkt-calendar.cjs +1 -1
  53. package/dist/pkt-calendar.js +2 -3
  54. package/dist/pkt-card.cjs +1 -1
  55. package/dist/pkt-card.js +2 -3
  56. package/dist/pkt-checkbox.cjs +1 -1
  57. package/dist/pkt-checkbox.js +3 -4
  58. package/dist/pkt-combobox.cjs +1 -1
  59. package/dist/pkt-combobox.js +3 -4
  60. package/dist/pkt-consent.cjs +1 -1
  61. package/dist/pkt-consent.js +2 -3
  62. package/dist/pkt-datepicker.cjs +1 -1
  63. package/dist/pkt-datepicker.js +7 -8
  64. package/dist/pkt-header.cjs +35 -35
  65. package/dist/pkt-header.js +224 -218
  66. package/dist/pkt-heading.cjs +1 -1
  67. package/dist/pkt-heading.js +3 -4
  68. package/dist/pkt-helptext.cjs +1 -1
  69. package/dist/pkt-helptext.js +3 -4
  70. package/dist/pkt-icon.cjs +1 -1
  71. package/dist/pkt-icon.js +3 -4
  72. package/dist/pkt-index.cjs +1 -1
  73. package/dist/pkt-index.js +26 -26
  74. package/dist/pkt-input-wrapper.cjs +1 -1
  75. package/dist/pkt-input-wrapper.js +2 -3
  76. package/dist/pkt-link.cjs +1 -1
  77. package/dist/pkt-link.js +2 -3
  78. package/dist/pkt-linkcard.cjs +1 -1
  79. package/dist/pkt-linkcard.js +3 -4
  80. package/dist/pkt-listbox.cjs +1 -1
  81. package/dist/pkt-listbox.js +3 -4
  82. package/dist/pkt-loader.cjs +1 -1
  83. package/dist/pkt-loader.js +3 -4
  84. package/dist/pkt-messagebox.cjs +1 -1
  85. package/dist/pkt-messagebox.js +3 -4
  86. package/dist/pkt-modal.cjs +1 -1
  87. package/dist/pkt-modal.js +3 -4
  88. package/dist/pkt-progressbar.cjs +1 -1
  89. package/dist/pkt-progressbar.js +2 -3
  90. package/dist/pkt-radiobutton.cjs +1 -1
  91. package/dist/pkt-radiobutton.js +3 -4
  92. package/dist/pkt-select.cjs +1 -1
  93. package/dist/pkt-select.js +3 -4
  94. package/dist/pkt-tabs.cjs +1 -1
  95. package/dist/pkt-tabs.js +2 -2
  96. package/dist/pkt-tag.cjs +1 -1
  97. package/dist/pkt-tag.js +3 -4
  98. package/dist/pkt-textarea.cjs +1 -1
  99. package/dist/pkt-textarea.js +3 -4
  100. package/dist/pkt-textinput.cjs +1 -1
  101. package/dist/pkt-textinput.js +3 -4
  102. package/dist/pkt-timepicker.cjs +22 -19
  103. package/dist/pkt-timepicker.js +84 -76
  104. package/dist/progressbar-BqlMzkM_.cjs +21 -0
  105. package/dist/{progressbar-By7e0lEI.js → progressbar-sbHDFC12.js} +88 -88
  106. package/dist/radiobutton-5ZqVVtTT.cjs +31 -0
  107. package/dist/{radiobutton-6frNG9J_.js → radiobutton-D8Ai8ETa.js} +44 -42
  108. package/dist/select-De-n8on9.js +230 -0
  109. package/dist/select-dTWibR6_.cjs +49 -0
  110. package/dist/tabitem-B9-jeV97.js +334 -0
  111. package/dist/tabitem-BnhzqfW3.cjs +65 -0
  112. package/dist/tag-CbwO8yvD.cjs +27 -0
  113. package/dist/{tag-BuCpqaks.js → tag-D4FI5t3y.js} +42 -40
  114. package/dist/textarea-BmLaKzsc.cjs +50 -0
  115. package/dist/{textarea-Bzuymclz.js → textarea-CMiSJaYL.js} +62 -60
  116. package/dist/textinput-em9y4yrL.cjs +70 -0
  117. package/dist/{textinput-9lHjs4ce.js → textinput-r8udK0IX.js} +57 -55
  118. package/package.json +2 -2
  119. package/src/components/accordion/accordion.ts +6 -1
  120. package/src/components/accordion/accordionitem.ts +6 -1
  121. package/src/components/alert/alert.ts +6 -1
  122. package/src/components/backlink/backlink.ts +6 -1
  123. package/src/components/breadcrumbs/breadcrumbs.ts +6 -1
  124. package/src/components/button/button.ts +6 -1
  125. package/src/components/calendar/calendar.ts +6 -1
  126. package/src/components/card/card.ts +6 -1
  127. package/src/components/checkbox/checkbox.ts +6 -1
  128. package/src/components/combobox/combobox.ts +6 -1
  129. package/src/components/consent/consent.ts +6 -1
  130. package/src/components/datepicker/date-tags.ts +6 -1
  131. package/src/components/datepicker/datepicker-multiple.ts +6 -1
  132. package/src/components/datepicker/datepicker-popup.ts +6 -1
  133. package/src/components/datepicker/datepicker-range.ts +6 -1
  134. package/src/components/datepicker/datepicker-single.ts +6 -1
  135. package/src/components/datepicker/datepicker.ts +6 -1
  136. package/src/components/header/header-service.ts +6 -1
  137. package/src/components/header/header-user-menu.ts +6 -1
  138. package/src/components/header/header.ts +6 -1
  139. package/src/components/heading/heading.ts +6 -1
  140. package/src/components/helptext/helptext.ts +6 -1
  141. package/src/components/icon/icon.ts +6 -1
  142. package/src/components/input-wrapper/input-wrapper.ts +6 -1
  143. package/src/components/link/link.ts +6 -1
  144. package/src/components/linkcard/linkcard.ts +6 -1
  145. package/src/components/listbox/listbox.ts +6 -1
  146. package/src/components/loader/loader.ts +6 -1
  147. package/src/components/messagebox/messagebox.ts +6 -1
  148. package/src/components/modal/modal.ts +6 -1
  149. package/src/components/progressbar/progressbar.ts +6 -1
  150. package/src/components/radiobutton/radiobutton.ts +6 -1
  151. package/src/components/select/select.ts +6 -1
  152. package/src/components/tabs/tabitem.ts +6 -1
  153. package/src/components/tabs/tabs.ts +6 -1
  154. package/src/components/tag/tag.ts +6 -1
  155. package/src/components/textarea/textarea.ts +6 -1
  156. package/src/components/textinput/textinput.ts +6 -1
  157. package/src/components/timepicker/timepicker.ts +14 -2
  158. package/dist/accordionitem-D1Agl1bB.cjs +0 -34
  159. package/dist/alert-DFkFNTxh.cjs +0 -33
  160. package/dist/backlink-EiAXUUZP.cjs +0 -13
  161. package/dist/backlink-V4DAt17e.js +0 -47
  162. package/dist/button-DYv5Dg4M.cjs +0 -27
  163. package/dist/calendar-HIE9nxcc.cjs +0 -90
  164. package/dist/card-CyeH6l1c.cjs +0 -87
  165. package/dist/checkbox-BLlwTABj.cjs +0 -31
  166. package/dist/checkbox-ejBUa5qQ.js +0 -145
  167. package/dist/consent-ruWAEVXW.cjs +0 -11
  168. package/dist/datepicker-D2H7U6MS.cjs +0 -273
  169. package/dist/heading-Cvz8m1xL.cjs +0 -1
  170. package/dist/helptext-5Mzp65-F.cjs +0 -24
  171. package/dist/helptext-jIoWRcCF.js +0 -80
  172. package/dist/icon-BlKA8YuW.js +0 -103
  173. package/dist/icon-Bqj9oBbl.cjs +0 -9
  174. package/dist/input-wrapper-B0MkQ0IZ.cjs +0 -54
  175. package/dist/input-wrapper-B2JpK016.js +0 -179
  176. package/dist/link-R_lNhViF.cjs +0 -7
  177. package/dist/link-Z_GizclR.js +0 -53
  178. package/dist/linkcard-BlQvdB1a.js +0 -54
  179. package/dist/linkcard-C7HbSLlX.cjs +0 -13
  180. package/dist/listbox-CGgV9MAe.cjs +0 -106
  181. package/dist/loader-e2gs_1xz.cjs +0 -16
  182. package/dist/messagebox-Bf-XMlvW.js +0 -69
  183. package/dist/messagebox-D67w71VX.cjs +0 -13
  184. package/dist/modal-CyvEkbfQ.cjs +0 -36
  185. package/dist/progressbar-DsJ2B9Vm.cjs +0 -21
  186. package/dist/radiobutton-Bv-BZ1Hw.cjs +0 -31
  187. package/dist/select-CXZt1nHS.js +0 -228
  188. package/dist/select-WFhS4Vfp.cjs +0 -49
  189. package/dist/tabitem-CB8wkKmv.js +0 -332
  190. package/dist/tabitem-DZpspU4Q.cjs +0 -65
  191. package/dist/tag-X6xdjR0N.cjs +0 -27
  192. package/dist/textarea-DoeHJ7HR.cjs +0 -50
  193. package/dist/textinput-BNsLd26i.cjs +0 -70
@@ -0,0 +1,56 @@
1
+ import { t as c, b as a, n as r } from "./element-CPpT3rFQ.js";
2
+ import { P as k, s as f } from "./element-with-slot-Dqk6-TRR.js";
3
+ import "./icon-CxQcIa5F.js";
4
+ import { o as h } from "./if-defined-B0krMLad.js";
5
+ var d = Object.defineProperty, n = (i, o, s, m) => {
6
+ for (var t = void 0, l = i.length - 1, p; l >= 0; l--)
7
+ (p = i[l]) && (t = p(o, s, t) || t);
8
+ return t && d(o, s, t), t;
9
+ };
10
+ class e extends k {
11
+ constructor() {
12
+ super(...arguments), this.title = "", this.href = "#", this.iconName = "", this.external = !1, this.openInNewTab = !1, this.skin = "normal";
13
+ }
14
+ render() {
15
+ const o = ["pkt-linkcard", this.skin && `pkt-linkcard--${this.skin}`].filter(Boolean).join(" "), s = ["pkt-linkcard__title", this.external && "pkt-link pkt-link--external"].filter(Boolean).join(" ");
16
+ return a`
17
+ <a
18
+ href=${this.href}
19
+ class=${o}
20
+ target=${this.openInNewTab ? "_blank" : "_self"}
21
+ rel=${h(this.openInNewTab ? "noopener noreferrer" : void 0)}
22
+ >
23
+ ${this.iconName && a`<pkt-icon class="pkt-link__icon" name="${this.iconName}" />`}
24
+ ${this.title && a`<div class=${s}>${this.title}</div>`}
25
+
26
+ <div class="pkt-linkcard__text">${f(this)}</div>
27
+ </a>
28
+ `;
29
+ }
30
+ }
31
+ n([
32
+ r({ type: String, reflect: !0 })
33
+ ], e.prototype, "title");
34
+ n([
35
+ r({ type: String, reflect: !0 })
36
+ ], e.prototype, "href");
37
+ n([
38
+ r({ type: String, reflect: !0 })
39
+ ], e.prototype, "iconName");
40
+ n([
41
+ r({ type: Boolean, reflect: !0 })
42
+ ], e.prototype, "external");
43
+ n([
44
+ r({ type: Boolean, reflect: !0 })
45
+ ], e.prototype, "openInNewTab");
46
+ n([
47
+ r({ type: String, reflect: !0 })
48
+ ], e.prototype, "skin");
49
+ try {
50
+ c("pkt-linkcard")(e);
51
+ } catch {
52
+ console.warn("Forsøker å definere <pkt-linkcard>, men den er allerede definert");
53
+ }
54
+ export {
55
+ e as P
56
+ };
@@ -1,106 +1,106 @@
1
- import { P as v, b as d, A as h, s as _, n as o, t as O } from "./element-CPpT3rFQ.js";
1
+ import { t as v, P as _, b as d, A as h, s as O, n as c } from "./element-CPpT3rFQ.js";
2
2
  import { r as w } from "./state-C_1EOo3D.js";
3
3
  import { o as m } from "./if-defined-B0krMLad.js";
4
4
  import { c as $ } from "./repeat-BD8TKgJb.js";
5
- import { e as g } from "./class-map-CEnykyO_.js";
5
+ import { e as k } from "./class-map-CEnykyO_.js";
6
6
  import { u as S } from "./utils-DznhwRXm.js";
7
- const F = (e, t) => t && (e.find((s) => s.value === t) || e.find((s) => s.label === t)) || null, H = (e, t) => {
8
- if (!t) return -1;
9
- const s = e.findIndex((i) => i.value === t);
10
- return s >= 0 ? s : e.findIndex((i) => i.label === t);
11
- }, I = (e, t) => {
12
- if (!t) return [...e];
13
- const s = t.toLowerCase();
14
- return e.filter((i) => (i.fulltext || i.value + (i.label || "") + (i.prefix || "")).toLowerCase().includes(s));
15
- }, z = (e) => e.value + (e.label || "") + (e.prefix || ""), N = (e, t) => t !== null && e >= t, j = (e, t) => {
16
- if (!t) return { filtered: [...e], suggestion: null };
17
- const s = t.toLowerCase(), i = e.filter((l) => {
18
- var c;
19
- return (c = l.fulltext) == null ? void 0 : c.toLowerCase().includes(s);
20
- }), a = i.find(
21
- (l) => {
22
- var c;
23
- return !l.selected && ((c = l.label) == null ? void 0 : c.toLowerCase().startsWith(s));
7
+ const F = (s, e) => e && (s.find((t) => t.value === e) || s.find((t) => t.label === e)) || null, q = (s, e) => {
8
+ if (!e) return -1;
9
+ const t = s.findIndex((a) => a.value === e);
10
+ return t >= 0 ? t : s.findIndex((a) => a.label === e);
11
+ }, I = (s, e) => {
12
+ if (!e) return [...s];
13
+ const t = e.toLowerCase();
14
+ return s.filter((a) => (a.fulltext || a.value + (a.label || "") + (a.prefix || "")).toLowerCase().includes(t));
15
+ }, H = (s) => s.value + (s.label || "") + (s.prefix || ""), z = (s, e) => e !== null && s >= e, N = (s, e) => {
16
+ if (!e) return { filtered: [...s], suggestion: null };
17
+ const t = e.toLowerCase(), a = s.filter((o) => {
18
+ var l;
19
+ return (l = o.fulltext) == null ? void 0 : l.toLowerCase().includes(t);
20
+ }), i = a.find(
21
+ (o) => {
22
+ var l;
23
+ return !o.selected && ((l = o.label) == null ? void 0 : l.toLowerCase().startsWith(t));
24
24
  }
25
25
  ) || null;
26
- return { filtered: i, suggestion: a };
27
- }, W = (e, t, s, i) => {
28
- if (!e.trim())
26
+ return { filtered: a, suggestion: i };
27
+ }, W = (s, e, t, a) => {
28
+ if (!s.trim())
29
29
  return { addValueText: null, userInfoMessage: "" };
30
- const a = e.trim().toLowerCase(), l = t.find((p) => p.toLowerCase() === a), c = s.filter(
30
+ const i = s.trim().toLowerCase(), o = e.find((p) => p.toLowerCase() === i), l = t.filter(
31
31
  (p) => {
32
32
  var b;
33
- return ((b = p.label) == null ? void 0 : b.toLowerCase().includes(a)) || p.value.toLowerCase().includes(a);
33
+ return ((b = p.label) == null ? void 0 : b.toLowerCase().includes(i)) || p.value.toLowerCase().includes(i);
34
34
  }
35
- ), y = c.find(
35
+ ), y = l.find(
36
36
  (p) => {
37
37
  var b;
38
- return ((b = p.label) == null ? void 0 : b.toLowerCase()) === a || p.value.toLowerCase() === a;
38
+ return ((b = p.label) == null ? void 0 : b.toLowerCase()) === i || p.value.toLowerCase() === i;
39
39
  }
40
40
  );
41
- return (c.length === 0 || !y) && i ? { addValueText: e, userInfoMessage: "" } : c.length === 0 && !i ? { addValueText: null, userInfoMessage: "Ingen treff i søket" } : l ? { addValueText: null, userInfoMessage: "Verdien er allerede valgt" } : { addValueText: null, userInfoMessage: "" };
42
- }, C = (e) => /^[\p{L} ]$/u.test(e), L = (e = 500) => {
43
- let t = "", s;
44
- return { append: (l) => (t += l.toLowerCase(), s !== void 0 && clearTimeout(s), s = setTimeout(() => {
45
- t = "";
46
- }, e), t), reset: () => {
47
- t = "", s !== void 0 && (clearTimeout(s), s = void 0);
48
- }, getBuffer: () => t };
49
- }, M = (e, t) => {
50
- const s = t.toLowerCase();
51
- return e.findIndex((i) => {
52
- var a;
53
- return (a = i.textContent) == null ? void 0 : a.trim().toLowerCase().startsWith(s);
41
+ return (l.length === 0 || !y) && a ? { addValueText: s, userInfoMessage: "" } : l.length === 0 && !a ? { addValueText: null, userInfoMessage: "Ingen treff i søket" } : o ? { addValueText: null, userInfoMessage: "Verdien er allerede valgt" } : { addValueText: null, userInfoMessage: "" };
42
+ }, C = (s) => /^[\p{L} ]$/u.test(s), L = (s = 500) => {
43
+ let e = "", t;
44
+ return { append: (o) => (e += o.toLowerCase(), t !== void 0 && clearTimeout(t), t = setTimeout(() => {
45
+ e = "";
46
+ }, s), e), reset: () => {
47
+ e = "", t !== void 0 && (clearTimeout(t), t = void 0);
48
+ }, getBuffer: () => e };
49
+ }, M = (s, e) => {
50
+ const t = e.toLowerCase();
51
+ return s.findIndex((a) => {
52
+ var i;
53
+ return (i = a.textContent) == null ? void 0 : i.trim().toLowerCase().startsWith(t);
54
54
  });
55
- }, u = (e) => {
56
- e.scrollIntoView({ block: "nearest" }), window.setTimeout(() => e.focus(), 0);
57
- }, f = (e) => Array.from(
58
- e.querySelectorAll('[role="option"]:not([data-disabled])') || []
59
- ), E = (e) => {
60
- const t = e.nextElementSibling;
55
+ }, u = (s) => {
56
+ s.scrollIntoView({ block: "nearest" }), window.setTimeout(() => s.focus(), 0);
57
+ }, f = (s) => Array.from(
58
+ s.querySelectorAll('[role="option"]:not([data-disabled])') || []
59
+ ), E = (s) => {
60
+ const e = s.nextElementSibling;
61
+ e && u(e);
62
+ }, T = (s, e, t) => {
63
+ const a = s.previousElementSibling;
64
+ if (s.dataset.index === "0" && t) {
65
+ const i = e.querySelector('[role="searchbox"]');
66
+ i && u(i);
67
+ } else a && u(a);
68
+ }, x = (s) => {
69
+ const e = f(s);
70
+ e[0] && u(e[0]);
71
+ }, g = (s) => {
72
+ const e = f(s), t = e[e.length - 1];
61
73
  t && u(t);
62
- }, T = (e, t, s) => {
63
- const i = e.previousElementSibling;
64
- if (e.dataset.index === "0" && s) {
65
- const a = t.querySelector('[role="searchbox"]');
66
- a && u(a);
67
- } else i && u(i);
68
- }, x = (e) => {
69
- const t = f(e);
70
- t[0] && u(t[0]);
71
- }, k = (e) => {
72
- const t = f(e), s = t[t.length - 1];
73
- s && u(s);
74
- }, U = (e, t) => {
75
- if (t.disabled) return;
76
- const s = f(e);
77
- if (t.allowUserInput && t.customUserInput) {
78
- const a = e.querySelector('[data-type="new-option"]');
79
- if (a) {
80
- u(a);
74
+ }, U = (s, e) => {
75
+ if (e.disabled) return;
76
+ const t = f(s);
77
+ if (e.allowUserInput && e.customUserInput) {
78
+ const i = s.querySelector('[data-type="new-option"]');
79
+ if (i) {
80
+ u(i);
81
81
  return;
82
82
  }
83
83
  }
84
- const i = s.find((a) => a.dataset.selected === "true");
85
- if (i) {
86
- u(i);
84
+ const a = t.find((i) => i.dataset.selected === "true");
85
+ if (a) {
86
+ u(a);
87
87
  return;
88
88
  }
89
- if (t.includeSearch && !(document.activeElement instanceof HTMLInputElement)) {
90
- const a = e.querySelector('[role="searchbox"]');
91
- if (a) {
92
- window.setTimeout(() => a.focus(), 0);
89
+ if (e.includeSearch && !(document.activeElement instanceof HTMLInputElement)) {
90
+ const i = s.querySelector('[role="searchbox"]');
91
+ if (i) {
92
+ window.setTimeout(() => i.focus(), 0);
93
93
  return;
94
94
  }
95
95
  }
96
- s[0] && u(s[0]);
96
+ t[0] && u(t[0]);
97
97
  };
98
- var V = Object.defineProperty, B = Object.getOwnPropertyDescriptor, r = (e, t, s, i) => {
99
- for (var a = i > 1 ? void 0 : i ? B(t, s) : t, l = e.length - 1, c; l >= 0; l--)
100
- (c = e[l]) && (a = (i ? c(t, s, a) : c(a)) || a);
101
- return i && a && V(t, s, a), a;
98
+ var V = Object.defineProperty, r = (s, e, t, a) => {
99
+ for (var i = void 0, o = s.length - 1, l; o >= 0; o--)
100
+ (l = s[o]) && (i = l(e, t, i) || i);
101
+ return i && V(e, t, i), i;
102
102
  };
103
- let n = class extends v {
103
+ class n extends _ {
104
104
  constructor() {
105
105
  super(...arguments), this.id = S(), this.label = null, this.options = [], this.isOpen = !1, this.disabled = !1, this.includeSearch = !1, this.isMultiSelect = !1, this.allowUserInput = !1, this.maxIsReached = !1, this.customUserInput = null, this.searchPlaceholder = null, this.searchValue = null, this.maxLength = 0, this.userMessage = null, this._selectedOptions = 0, this.typeahead = L(), this._filteredOptions = [];
106
106
  }
@@ -114,8 +114,8 @@ let n = class extends v {
114
114
  updated(e) {
115
115
  (e.has("options") || e.has("searchValue")) && this.filterOptions(), super.updated(e);
116
116
  }
117
- attributeChangedCallback(e, t, s) {
118
- (e === "options" || e === "search-value") && this.filterOptions(), super.attributeChangedCallback(e, t, s);
117
+ attributeChangedCallback(e, t, a) {
118
+ (e === "options" || e === "search-value") && this.filterOptions(), super.attributeChangedCallback(e, t, a);
119
119
  }
120
120
  // Render methods
121
121
  get _hasOptions() {
@@ -124,7 +124,7 @@ let n = class extends v {
124
124
  render() {
125
125
  return d`
126
126
  <div
127
- class=${g({
127
+ class=${k({
128
128
  "pkt-listbox": !0,
129
129
  "pkt-listbox__open": this.isOpen,
130
130
  "pkt-txt-16-light": !0
@@ -154,8 +154,8 @@ let n = class extends v {
154
154
  role="presentation"
155
155
  tabindex="-1"
156
156
  value=${e.value}
157
- @change=${(s) => {
158
- s.stopPropagation();
157
+ @change=${(a) => {
158
+ a.stopPropagation();
159
159
  }}
160
160
  .checked=${e.selected}
161
161
  aria-labelledby=${this.id + "-option-label-" + t}
@@ -185,7 +185,7 @@ let n = class extends v {
185
185
  }}
186
186
  aria-selected=${e.selected ? "true" : "false"}
187
187
  @keydown=${this.handleOptionKeydown}
188
- class=${g({
188
+ class=${k({
189
189
  "pkt-listbox__option": !0,
190
190
  "pkt-listbox__option--selected": !!(!this.isMultiSelect && e.selected),
191
191
  "pkt-listbox__option--checkBox": this.isMultiSelect
@@ -258,7 +258,7 @@ let n = class extends v {
258
258
  type="text"
259
259
  aria-label="Søk i listen"
260
260
  form=""
261
- placeholder=${this.searchPlaceholder || _.forms.search.placeholder}
261
+ placeholder=${this.searchPlaceholder || O.forms.search.placeholder}
262
262
  @input=${this.handleSearchInput}
263
263
  @keydown=${this.handleSearchKeydown}
264
264
  .value=${this.searchValue}
@@ -297,7 +297,7 @@ let n = class extends v {
297
297
  }
298
298
  }
299
299
  handleOptionKeydown(e) {
300
- const t = e.currentTarget, s = t.dataset.value, i = t.dataset.type, a = t.dataset.selected === "true";
300
+ const t = e.currentTarget, a = t.dataset.value, i = t.dataset.type, o = t.dataset.selected === "true";
301
301
  if (!(!f(this).length && (!this.customUserInput || !this.allowUserInput && this.customUserInput) && i !== "new-option" && i !== "searchbox"))
302
302
  switch (e.key) {
303
303
  case " ":
@@ -305,7 +305,7 @@ let n = class extends v {
305
305
  this.toggleOption(t), e.preventDefault();
306
306
  break;
307
307
  case "Backspace":
308
- s && (a ? this.toggleOption(t) : this.closeOptions()), e.preventDefault();
308
+ a && (o ? this.toggleOption(t) : this.closeOptions()), e.preventDefault();
309
309
  break;
310
310
  case "Escape":
311
311
  this.closeOptions(), e.preventDefault();
@@ -314,7 +314,7 @@ let n = class extends v {
314
314
  this.tabClose();
315
315
  break;
316
316
  case "ArrowDown":
317
- e.altKey ? k(this) : i === "searchbox" || i === "new-option" ? x(this) : E(t), e.preventDefault();
317
+ e.altKey ? g(this) : i === "searchbox" || i === "new-option" ? x(this) : E(t), e.preventDefault();
318
318
  break;
319
319
  case "ArrowUp":
320
320
  if (e.altKey)
@@ -333,7 +333,7 @@ let n = class extends v {
333
333
  x(this), e.preventDefault();
334
334
  break;
335
335
  case "End":
336
- k(this), e.preventDefault();
336
+ g(this), e.preventDefault();
337
337
  break;
338
338
  default:
339
339
  (e.metaKey || e.ctrlKey) && e.key === "a" && (this.selectAll(), e.preventDefault()), C(e.key) && (this.handleTypeAhead(e.key), e.preventDefault());
@@ -353,10 +353,10 @@ let n = class extends v {
353
353
  toggleOption(e) {
354
354
  const t = e instanceof HTMLElement ? e.dataset.disabled : e.disabled;
355
355
  if (this.disabled || t) return;
356
- const s = e instanceof HTMLElement ? e.dataset.value : e.value;
356
+ const a = e instanceof HTMLElement ? e.dataset.value : e.value;
357
357
  this.dispatchEvent(
358
358
  new CustomEvent("option-toggle", {
359
- detail: s,
359
+ detail: a,
360
360
  bubbles: !1
361
361
  })
362
362
  );
@@ -375,64 +375,66 @@ let n = class extends v {
375
375
  this._filteredOptions = I(this.options, this.searchValue);
376
376
  }
377
377
  handleTypeAhead(e) {
378
- const t = this.typeahead.append(e), s = f(this), i = M(s, t);
379
- i >= 0 && u(s[i]);
378
+ const t = this.typeahead.append(e), a = f(this), i = M(a, t);
379
+ i >= 0 && u(a[i]);
380
380
  }
381
- };
381
+ }
382
382
  r([
383
- o({ type: String })
384
- ], n.prototype, "id", 2);
383
+ c({ type: String })
384
+ ], n.prototype, "id");
385
385
  r([
386
- o({ type: String })
387
- ], n.prototype, "label", 2);
386
+ c({ type: String })
387
+ ], n.prototype, "label");
388
388
  r([
389
- o({ type: Array })
390
- ], n.prototype, "options", 2);
389
+ c({ type: Array })
390
+ ], n.prototype, "options");
391
391
  r([
392
- o({ type: Boolean, reflect: !0, attribute: "is-open" })
393
- ], n.prototype, "isOpen", 2);
392
+ c({ type: Boolean, reflect: !0, attribute: "is-open" })
393
+ ], n.prototype, "isOpen");
394
394
  r([
395
- o({ type: Boolean })
396
- ], n.prototype, "disabled", 2);
395
+ c({ type: Boolean })
396
+ ], n.prototype, "disabled");
397
397
  r([
398
- o({ type: Boolean, attribute: "include-search" })
399
- ], n.prototype, "includeSearch", 2);
398
+ c({ type: Boolean, attribute: "include-search" })
399
+ ], n.prototype, "includeSearch");
400
400
  r([
401
- o({ type: Boolean, attribute: "is-multi-select" })
402
- ], n.prototype, "isMultiSelect", 2);
401
+ c({ type: Boolean, attribute: "is-multi-select" })
402
+ ], n.prototype, "isMultiSelect");
403
403
  r([
404
- o({ type: Boolean, attribute: "allow-user-input" })
405
- ], n.prototype, "allowUserInput", 2);
404
+ c({ type: Boolean, attribute: "allow-user-input" })
405
+ ], n.prototype, "allowUserInput");
406
406
  r([
407
- o({ type: Boolean, attribute: "max-is-reached" })
408
- ], n.prototype, "maxIsReached", 2);
407
+ c({ type: Boolean, attribute: "max-is-reached" })
408
+ ], n.prototype, "maxIsReached");
409
409
  r([
410
- o({ type: String, attribute: "custom-user-input" })
411
- ], n.prototype, "customUserInput", 2);
410
+ c({ type: String, attribute: "custom-user-input" })
411
+ ], n.prototype, "customUserInput");
412
412
  r([
413
- o({ type: String, attribute: "search-placeholder" })
414
- ], n.prototype, "searchPlaceholder", 2);
413
+ c({ type: String, attribute: "search-placeholder" })
414
+ ], n.prototype, "searchPlaceholder");
415
415
  r([
416
- o({ type: String, attribute: "search-value" })
417
- ], n.prototype, "searchValue", 2);
416
+ c({ type: String, attribute: "search-value" })
417
+ ], n.prototype, "searchValue");
418
418
  r([
419
- o({ type: Number, attribute: "max-length" })
420
- ], n.prototype, "maxLength", 2);
419
+ c({ type: Number, attribute: "max-length" })
420
+ ], n.prototype, "maxLength");
421
421
  r([
422
- o({ type: String, attribute: "user-message" })
423
- ], n.prototype, "userMessage", 2);
422
+ c({ type: String, attribute: "user-message" })
423
+ ], n.prototype, "userMessage");
424
424
  r([
425
425
  w()
426
- ], n.prototype, "_filteredOptions", 2);
427
- n = r([
428
- O("pkt-listbox")
429
- ], n);
426
+ ], n.prototype, "_filteredOptions");
427
+ try {
428
+ v("pkt-listbox")(n);
429
+ } catch {
430
+ console.warn("Forsøker å definere <pkt-listbox>, men den er allerede definert");
431
+ }
430
432
  export {
431
433
  n as P,
432
- j as a,
433
- z as b,
434
- H as c,
434
+ N as a,
435
+ H as b,
436
+ q as c,
435
437
  F as f,
436
438
  W as g,
437
- N as i
439
+ z as i
438
440
  };
@@ -0,0 +1,106 @@
1
+ "use strict";const a=require("./element-gR_VtSiD.cjs"),m=require("./state-Dg-53wQ8.cjs"),b=require("./if-defined-BOW3ODSj.cjs"),y=require("./repeat-Cfq8CDlf.cjs"),x=require("./class-map-CsENJXf1.cjs"),v=require("./utils-byXsEz1u.cjs"),_=(s,e)=>e&&(s.find(t=>t.value===e)||s.find(t=>t.label===e))||null,O=(s,e)=>{if(!e)return-1;const t=s.findIndex(n=>n.value===e);return t>=0?t:s.findIndex(n=>n.label===e)},w=(s,e)=>{if(!e)return[...s];const t=e.toLowerCase();return s.filter(n=>(n.fulltext||n.value+(n.label||"")+(n.prefix||"")).toLowerCase().includes(t))},$=s=>s.value+(s.label||"")+(s.prefix||""),S=(s,e)=>e!==null&&s>=e,I=(s,e)=>{if(!e)return{filtered:[...s],suggestion:null};const t=e.toLowerCase(),n=s.filter(c=>{var l;return(l=c.fulltext)==null?void 0:l.toLowerCase().includes(t)}),i=n.find(c=>{var l;return!c.selected&&((l=c.label)==null?void 0:l.toLowerCase().startsWith(t))})||null;return{filtered:n,suggestion:i}},C=(s,e,t,n)=>{if(!s.trim())return{addValueText:null,userInfoMessage:""};const i=s.trim().toLowerCase(),c=e.find(u=>u.toLowerCase()===i),l=t.filter(u=>{var h;return((h=u.label)==null?void 0:h.toLowerCase().includes(i))||u.value.toLowerCase().includes(i)}),g=l.find(u=>{var h;return((h=u.label)==null?void 0:h.toLowerCase())===i||u.value.toLowerCase()===i});return(l.length===0||!g)&&n?{addValueText:s,userInfoMessage:""}:l.length===0&&!n?{addValueText:null,userInfoMessage:"Ingen treff i søket"}:c?{addValueText:null,userInfoMessage:"Verdien er allerede valgt"}:{addValueText:null,userInfoMessage:""}},M=s=>/^[\p{L} ]$/u.test(s),L=(s=500)=>{let e="",t;return{append:c=>(e+=c.toLowerCase(),t!==void 0&&clearTimeout(t),t=setTimeout(()=>{e=""},s),e),reset:()=>{e="",t!==void 0&&(clearTimeout(t),t=void 0)},getBuffer:()=>e}},E=(s,e)=>{const t=e.toLowerCase();return s.findIndex(n=>{var i;return(i=n.textContent)==null?void 0:i.trim().toLowerCase().startsWith(t)})},d=s=>{s.scrollIntoView({block:"nearest"}),window.setTimeout(()=>s.focus(),0)},p=s=>Array.from(s.querySelectorAll('[role="option"]:not([data-disabled])')||[]),T=s=>{const e=s.nextElementSibling;e&&d(e)},U=(s,e,t)=>{const n=s.previousElementSibling;if(s.dataset.index==="0"&&t){const i=e.querySelector('[role="searchbox"]');i&&d(i)}else n&&d(n)},f=s=>{const e=p(s);e[0]&&d(e[0])},k=s=>{const e=p(s),t=e[e.length-1];t&&d(t)},A=(s,e)=>{if(e.disabled)return;const t=p(s);if(e.allowUserInput&&e.customUserInput){const i=s.querySelector('[data-type="new-option"]');if(i){d(i);return}}const n=t.find(i=>i.dataset.selected==="true");if(n){d(n);return}if(e.includeSearch&&!(document.activeElement instanceof HTMLInputElement)){const i=s.querySelector('[role="searchbox"]');if(i){window.setTimeout(()=>i.focus(),0);return}}t[0]&&d(t[0])};var V=Object.defineProperty,o=(s,e,t,n)=>{for(var i=void 0,c=s.length-1,l;c>=0;c--)(l=s[c])&&(i=l(e,t,i)||i);return i&&V(e,t,i),i};class r extends a.PktElement{constructor(){super(...arguments),this.id=v.uuidish(),this.label=null,this.options=[],this.isOpen=!1,this.disabled=!1,this.includeSearch=!1,this.isMultiSelect=!1,this.allowUserInput=!1,this.maxIsReached=!1,this.customUserInput=null,this.searchPlaceholder=null,this.searchValue=null,this.maxLength=0,this.userMessage=null,this._selectedOptions=0,this.typeahead=L(),this._filteredOptions=[]}connectedCallback(){super.connectedCallback(),this.includeSearch&&!this.searchValue&&(this.searchValue=""),this.options.length>0&&this.filterOptions(),this.setAttribute("tabindex","-1"),this.addEventListener("focus",this.focusFirstOrSelectedOption)}disconnectedCallback(){super.disconnectedCallback(),this.typeahead.reset()}updated(e){(e.has("options")||e.has("searchValue"))&&this.filterOptions(),super.updated(e)}attributeChangedCallback(e,t,n){(e==="options"||e==="search-value")&&this.filterOptions(),super.attributeChangedCallback(e,t,n)}get _hasOptions(){return this._filteredOptions.length>0||this.options.length>0}render(){return a.b`
2
+ <div
3
+ class=${x.e({"pkt-listbox":!0,"pkt-listbox__open":this.isOpen,"pkt-txt-16-light":!0})}
4
+ role=${b.o(this._hasOptions?"listbox":void 0)}
5
+ aria-multiselectable=${b.o(this._hasOptions&&this.isMultiSelect?"true":void 0)}
6
+ aria-label=${b.o(this._hasOptions?this.label??void 0:void 0)}
7
+ >
8
+ <div class="pkt-listbox__banners">
9
+ ${this.renderSearch()} ${this.renderMaximumReachedBanner()} ${this.renderUserMessage()}
10
+ ${this.renderEmptyMessage()} ${this.renderNewOptionBanner()}
11
+ </div>
12
+ <ul class="pkt-listbox__options" role="presentation">
13
+ ${this.renderList()}
14
+ </ul>
15
+ </div>
16
+ <div aria-live="polite" class="pkt-visually-hidden">${this.userMessage}</div>
17
+ `}renderCheckboxOrCheckIcon(e,t){return this.isMultiSelect?a.b`
18
+ <input
19
+ class="pkt-input-check__input-checkbox"
20
+ type="checkbox"
21
+ role="presentation"
22
+ tabindex="-1"
23
+ value=${e.value}
24
+ @change=${n=>{n.stopPropagation()}}
25
+ .checked=${e.selected}
26
+ aria-labelledby=${this.id+"-option-label-"+t}
27
+ ?disabled=${this.disabled||e.disabled||this.maxIsReached&&!e.selected}
28
+ />
29
+ `:e.selected?a.b`<pkt-icon name="check-big"></pkt-icon>`:a.A}renderEmptyMessage(){return this.options.length>0||this._filteredOptions.length>0||this.userMessage?a.A:a.b`<div class="pkt-listbox__banner pkt-listbox__banner--empty">
30
+ <pkt-icon
31
+ class="pkt-listbox__banner-icon"
32
+ name="exclamation-mark-circle"
33
+ size="large"
34
+ ></pkt-icon>
35
+ Tom liste
36
+ </div>`}renderList(){return a.b`
37
+ ${y.c(this._filteredOptions,e=>e.value,(e,t)=>a.b`
38
+ <li
39
+ @click=${()=>{this.toggleOption(e)}}
40
+ aria-selected=${e.selected?"true":"false"}
41
+ @keydown=${this.handleOptionKeydown}
42
+ class=${x.e({"pkt-listbox__option":!0,"pkt-listbox__option--selected":!!(!this.isMultiSelect&&e.selected),"pkt-listbox__option--checkBox":this.isMultiSelect})}
43
+ tabindex="${this.disabled||e.disabled?"-1":"0"}"
44
+ data-index=${t}
45
+ data-value=${e.value}
46
+ data-selected=${e.selected?"true":"false"}
47
+ ?data-disabled=${this.disabled||e.disabled||this.maxIsReached&&!e.selected}
48
+ aria-disabled=${this.disabled||e.disabled||this.maxIsReached&&!e.selected?"true":"false"}
49
+ role="option"
50
+ id=${`${this.id}-${t}`}
51
+ >
52
+ ${this.renderCheckboxOrCheckIcon(e,t)}
53
+ <span class="pkt-listbox__option-label" id=${this.id+"-option-label-"+t}>
54
+ ${e.prefix?a.b`<span class="pkt-listbox__option-prefix">${e.prefix}</span>`:a.A}
55
+ ${e.label||e.value}
56
+ </span>
57
+ ${e.description?a.b`<span class="pkt-listbox__option-description pkt-txt-14-light"
58
+ >${e.description}</span
59
+ >`:a.A}
60
+ </li>
61
+ `)}
62
+ `}renderNewOptionBanner(){return this.allowUserInput&&this.customUserInput?a.b`
63
+ <div
64
+ class="pkt-listbox__banner pkt-listbox__banner--new-option pkt-listbox__option"
65
+ data-type="new-option"
66
+ data-value=${this.customUserInput}
67
+ data-selected="false"
68
+ tabindex="0"
69
+ @click=${()=>this.toggleOption({value:this.customUserInput||""})}
70
+ @keydown=${this.handleOptionKeydown}
71
+ >
72
+ <pkt-icon class="pkt-listbox__banner-icon" name="plus-sign" size="large"></pkt-icon>
73
+ Legg til "${this.customUserInput}"
74
+ </div>
75
+ `:a.A}renderMaximumReachedBanner(){return this._selectedOptions=this.options.filter(e=>e.selected).length,this.isMultiSelect&&this._selectedOptions>0&&this.maxLength>0?a.b`
76
+ <div class="pkt-listbox__banner pkt-listbox__banner--maximum-reached">
77
+ ${this._selectedOptions} av maks ${this.maxLength} mulige er valgt.
78
+ </div>
79
+ `:a.A}renderUserMessage(){return this.userMessage?a.b`<div class="pkt-listbox__banner pkt-listbox__banner--user-message">
80
+ <pkt-icon
81
+ class="pkt-listbox__banner-icon"
82
+ name="exclamation-mark-circle"
83
+ size="large"
84
+ ></pkt-icon>
85
+ ${this.userMessage}
86
+ </div>`:a.A}renderSearch(){return this.includeSearch?a.b`
87
+ <div class="pkt-listbox__search">
88
+ <span class="pkt-listbox__search-icon">
89
+ <pkt-icon name="magnifying-glass-small" size="large"></pkt-icon>
90
+ </span>
91
+ <input
92
+ class="pkt-txt-16-light"
93
+ type="text"
94
+ aria-label="Søk i listen"
95
+ form=""
96
+ placeholder=${this.searchPlaceholder||a.strings.forms.search.placeholder}
97
+ @input=${this.handleSearchInput}
98
+ @keydown=${this.handleSearchKeydown}
99
+ .value=${this.searchValue}
100
+ data-type="searchbox"
101
+ ?disabled=${this.disabled}
102
+ ?readonly=${this.disabled}
103
+ role="searchbox"
104
+ />
105
+ </div>
106
+ `:a.A}handleSearchInput(e){this.searchValue=e.target.value,this.dispatchEvent(new CustomEvent("search",{detail:this.searchValue,bubbles:!1}))}handleSearchKeydown(e){switch(e.key){case"Enter":e.preventDefault();break;case"ArrowUp":case"Escape":this.closeOptions(),e.preventDefault();break;case"ArrowDown":this.focusFirstOrSelectedOption();break;case"Tab":this.tabClose();break}}handleOptionKeydown(e){const t=e.currentTarget,n=t.dataset.value,i=t.dataset.type,c=t.dataset.selected==="true";if(!(!p(this).length&&(!this.customUserInput||!this.allowUserInput&&this.customUserInput)&&i!=="new-option"&&i!=="searchbox"))switch(e.key){case" ":case"Enter":this.toggleOption(t),e.preventDefault();break;case"Backspace":n&&(c?this.toggleOption(t):this.closeOptions()),e.preventDefault();break;case"Escape":this.closeOptions(),e.preventDefault();break;case"Tab":this.tabClose();break;case"ArrowDown":e.altKey?k(this):i==="searchbox"||i==="new-option"?f(this):T(t),e.preventDefault();break;case"ArrowUp":if(e.altKey)f(this);else if(t.dataset.index==="0"&&this.includeSearch){const l=this.querySelector('[role="searchbox"]');l&&l.focus()}else if(t.dataset.index==="0"&&this.customUserInput){const l=this.querySelector('[data-type="new-option"]');l&&l.focus()}else U(t,this,this.includeSearch);e.preventDefault();break;case"Home":f(this),e.preventDefault();break;case"End":k(this),e.preventDefault();break;default:(e.metaKey||e.ctrlKey)&&e.key==="a"&&(this.selectAll(),e.preventDefault()),M(e.key)&&(this.handleTypeAhead(e.key),e.preventDefault());break}}focusFirstOrSelectedOption(){A(this,{disabled:this.disabled,allowUserInput:this.allowUserInput,customUserInput:this.customUserInput,includeSearch:this.includeSearch})}toggleOption(e){const t=e instanceof HTMLElement?e.dataset.disabled:e.disabled;if(this.disabled||t)return;const n=e instanceof HTMLElement?e.dataset.value:e.value;this.dispatchEvent(new CustomEvent("option-toggle",{detail:n,bubbles:!1}))}selectAll(){this.dispatchEvent(new CustomEvent("select-all",{bubbles:!1}))}closeOptions(){this.dispatchEvent(new CustomEvent("close-options",{bubbles:!1}))}tabClose(){this.dispatchEvent(new CustomEvent("tab-close",{bubbles:!1}))}filterOptions(){this._filteredOptions=w(this.options,this.searchValue)}handleTypeAhead(e){const t=this.typeahead.append(e),n=p(this),i=E(n,t);i>=0&&d(n[i])}}o([a.n({type:String})],r.prototype,"id");o([a.n({type:String})],r.prototype,"label");o([a.n({type:Array})],r.prototype,"options");o([a.n({type:Boolean,reflect:!0,attribute:"is-open"})],r.prototype,"isOpen");o([a.n({type:Boolean})],r.prototype,"disabled");o([a.n({type:Boolean,attribute:"include-search"})],r.prototype,"includeSearch");o([a.n({type:Boolean,attribute:"is-multi-select"})],r.prototype,"isMultiSelect");o([a.n({type:Boolean,attribute:"allow-user-input"})],r.prototype,"allowUserInput");o([a.n({type:Boolean,attribute:"max-is-reached"})],r.prototype,"maxIsReached");o([a.n({type:String,attribute:"custom-user-input"})],r.prototype,"customUserInput");o([a.n({type:String,attribute:"search-placeholder"})],r.prototype,"searchPlaceholder");o([a.n({type:String,attribute:"search-value"})],r.prototype,"searchValue");o([a.n({type:Number,attribute:"max-length"})],r.prototype,"maxLength");o([a.n({type:String,attribute:"user-message"})],r.prototype,"userMessage");o([m.r()],r.prototype,"_filteredOptions");try{a.t("pkt-listbox")(r)}catch{console.warn("Forsøker å definere <pkt-listbox>, men den er allerede definert")}exports.PktListbox=r;exports.buildFulltext=$;exports.findOptionByValue=_;exports.findOptionIndex=O;exports.findTypeaheadMatches=I;exports.getSearchInfoMessage=C;exports.isMaxSelectionReached=S;
@@ -0,0 +1,16 @@
1
+ "use strict";const d=require("./element-with-slot-ZX-up7jO.cjs"),p=require("./class-map-CsENJXf1.cjs"),t=require("./element-gR_VtSiD.cjs"),h=require("./state-Dg-53wQ8.cjs");require("./icon-q81vqPK_.cjs");var u=Object.defineProperty,s=(n,i,r,c)=>{for(var a=void 0,o=n.length-1,l;o>=0;o--)(l=n[o])&&(a=l(i,r,a)||a);return a&&u(i,r,a),a};window.pktAnimationPath=window.pktAnimationPath||"https://punkt-cdn.oslo.kommune.no/latest/animations/";class e extends d.PktElementWithSlot{constructor(){super(...arguments),this.delay=0,this.inline=!1,this.isLoading=!0,this.message=null,this.size="medium",this.variant="shapes",this.loadingAnimationPath=window.pktAnimationPath,this._shouldDisplayLoader=!1}connectedCallback(){super.connectedCallback(),this._shouldDisplayLoader=this.delay===0,this.delay>0&&this.setupLoader()}updated(i){i.has("delay")&&this.setupLoader()}render(){const i=p.e({"pkt-loader":!0,[`pkt-loader--${this.inline?"inline":"box"}`]:!0,[`pkt-loader--${this.size}`]:!0}),r=p.e({"pkt-contents":!0,"pkt-hide":this.isLoading});return t.b`<div
2
+ role="status"
3
+ aria-live="polite"
4
+ aria-busy=${this.isLoading?"true":"false"}
5
+ class=${i}
6
+ >
7
+ ${this.isLoading&&this._shouldDisplayLoader?t.b`<div class="pkt-loader__spinner">
8
+ <pkt-icon
9
+ name=${this.getVariant(this.variant)}
10
+ path=${this.loadingAnimationPath}
11
+ class="pkt-loader__svg pkt-loader__${this.variant}"
12
+ ></pkt-icon>
13
+ ${this.message&&t.b`<p>${this.message}</p>`}
14
+ </div>`:t.A}
15
+ <div class=${r}>${d.slotContent(this)}</div>
16
+ </div>`}getVariant(i){switch(i){case"blue":return"spinner-blue";case"rainbow":return"spinner";default:return"loader"}}setupLoader(){this.delay>0&&(this._shouldDisplayLoader=!1,setTimeout(()=>{this._shouldDisplayLoader=!0,this.requestUpdate()},this.delay))}}s([t.n({type:Number})],e.prototype,"delay");s([t.n({type:Boolean})],e.prototype,"inline");s([t.n({type:Boolean})],e.prototype,"isLoading");s([t.n({type:String})],e.prototype,"message");s([t.n({type:String})],e.prototype,"size");s([t.n({type:String})],e.prototype,"variant");s([t.n({type:String})],e.prototype,"loadingAnimationPath");s([h.r()],e.prototype,"_shouldDisplayLoader");try{t.t("pkt-loader")(e)}catch{console.warn("Forsøker å definere <pkt-loader>, men den er allerede definert")}exports.PktLoader=e;