@oslokommune/punkt-elements 16.7.1 → 16.7.4

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 (286) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/accordion-BB1JrONI.cjs +34 -0
  3. package/dist/accordion-nNH87Y60.js +130 -0
  4. package/dist/alert-BEEnTiCb.cjs +33 -0
  5. package/dist/alert-ePJuDtmm.js +171 -0
  6. package/dist/async-directive-B9P1Qa0k.cjs +1 -0
  7. package/dist/async-directive-CaQiqjyV.js +55 -0
  8. package/dist/backlink-Ba03LlbB.cjs +13 -0
  9. package/dist/backlink-CiwXrQYD.js +38 -0
  10. package/dist/booleanish-BmcOU-43.js +11 -0
  11. package/dist/booleanish-jJLlnr6-.cjs +1 -0
  12. package/dist/breadcrumbs-CD1zib3s.cjs +43 -0
  13. package/dist/breadcrumbs-CpuVqWhF.js +76 -0
  14. package/dist/button-BIpd1xJh.js +95 -0
  15. package/dist/button-D-TOBaJB.cjs +27 -0
  16. package/dist/calendar-BzEtOJla.js +2031 -0
  17. package/dist/calendar-E5jJLt8D.cjs +90 -0
  18. package/dist/card-BYJu1MYm.js +339 -0
  19. package/dist/card-CUFhMVim.cjs +87 -0
  20. package/dist/checkbox-BARDb9iV.cjs +31 -0
  21. package/dist/checkbox-Cspxcvt_.js +111 -0
  22. package/dist/class-map-C8HuhNzZ.js +27 -0
  23. package/dist/class-map-CJ-msbHs.cjs +1 -0
  24. package/dist/classutils-DEL164Ur.js +7 -0
  25. package/dist/classutils-z8YsPlOf.cjs +1 -0
  26. package/dist/combobox-BcdLZRDU.js +984 -0
  27. package/dist/combobox-CGbFTWq_.cjs +135 -0
  28. package/dist/consent-DeB_5sWH.js +197 -0
  29. package/dist/consent-hwu7pp3S.cjs +11 -0
  30. package/dist/datepicker-DpmlsnH_.cjs +273 -0
  31. package/dist/datepicker-OVd8pmnZ.js +1125 -0
  32. package/dist/dialog-polyfill.esm-1hPr0gl9.js +280 -0
  33. package/dist/dialog-polyfill.esm-D3Oinvk0.cjs +1 -0
  34. package/dist/directive-3THFsVew.js +28 -0
  35. package/dist/directive-CJ2giQBZ.cjs +1 -0
  36. package/dist/directive-helpers-D1QSxY17.cjs +1 -0
  37. package/dist/directive-helpers-Dkv2gKgs.js +25 -0
  38. package/dist/element-DjtxO-1r.cjs +2 -0
  39. package/dist/element-cZ85T_aa.js +693 -0
  40. package/dist/element-with-slot-4J2o3SeU.js +166 -0
  41. package/dist/element-with-slot-CWoTGA1B.cjs +1 -0
  42. package/dist/header-DWgPgGfS.cjs +304 -0
  43. package/dist/header-a6ztVNp3.js +782 -0
  44. package/dist/heading-BgSWIRii.cjs +1 -0
  45. package/dist/heading-DiQLPxdf.js +73 -0
  46. package/dist/helptext-CCBKKLus.js +65 -0
  47. package/dist/helptext-D-3QfZv5.cjs +24 -0
  48. package/dist/icon-Co72KtgF.js +86 -0
  49. package/dist/icon-Dr8sfT2X.cjs +1 -0
  50. package/dist/if-defined-Cjj8qN-Z.js +5 -0
  51. package/dist/if-defined-XKOD_t_V.cjs +1 -0
  52. package/dist/index.d.ts +1 -2
  53. package/dist/input-element-B1yxcfz4.cjs +1 -0
  54. package/dist/input-element-Bw1s6NlF.js +643 -0
  55. package/dist/input-wrapper-BRuVELpK.cjs +54 -0
  56. package/dist/input-wrapper-CDyHTR1V.js +164 -0
  57. package/dist/input-wrapper-Dwd-_sKm.cjs +1 -0
  58. package/dist/input-wrapper-YfTmpSSY.js +117 -0
  59. package/dist/link-CKAFMz9j.js +89 -0
  60. package/dist/link-CyTCpI0k.cjs +7 -0
  61. package/dist/linkcard-B0KOGaGj.js +55 -0
  62. package/dist/linkcard-BE4-FewK.cjs +13 -0
  63. package/dist/listbox-DCA2JoPV.cjs +106 -0
  64. package/dist/listbox-DuBgTFvH.js +397 -0
  65. package/dist/loader-6kFZUErT.js +66 -0
  66. package/dist/loader-CX2rsC01.cjs +16 -0
  67. package/dist/messagebox-Cwlg5sOr.js +110 -0
  68. package/dist/messagebox-Din9X53b.cjs +13 -0
  69. package/dist/modal-C_wtsh9m.js +209 -0
  70. package/dist/modal-DS_wUOIv.cjs +36 -0
  71. package/dist/pkt-accordion.cjs +1 -1
  72. package/dist/pkt-accordion.js +2 -7
  73. package/dist/pkt-alert.cjs +1 -1
  74. package/dist/pkt-alert.js +2 -6
  75. package/dist/pkt-backlink.cjs +1 -1
  76. package/dist/pkt-backlink.js +2 -6
  77. package/dist/pkt-breadcrumbs.cjs +1 -43
  78. package/dist/pkt-breadcrumbs.js +2 -79
  79. package/dist/pkt-button.cjs +1 -1
  80. package/dist/pkt-button.js +2 -6
  81. package/dist/pkt-calendar.cjs +1 -1
  82. package/dist/pkt-calendar.js +2 -6
  83. package/dist/pkt-card.cjs +1 -1
  84. package/dist/pkt-card.js +2 -6
  85. package/dist/pkt-checkbox.cjs +1 -1
  86. package/dist/pkt-checkbox.js +2 -6
  87. package/dist/pkt-combobox.cjs +1 -1
  88. package/dist/pkt-combobox.js +2 -6
  89. package/dist/pkt-consent.cjs +1 -1
  90. package/dist/pkt-consent.js +2 -6
  91. package/dist/pkt-datepicker.cjs +1 -1
  92. package/dist/pkt-datepicker.js +5 -10
  93. package/dist/pkt-header.cjs +1 -304
  94. package/dist/pkt-header.js +2 -855
  95. package/dist/pkt-heading.cjs +1 -1
  96. package/dist/pkt-heading.js +2 -6
  97. package/dist/pkt-helptext.cjs +1 -1
  98. package/dist/pkt-helptext.js +2 -6
  99. package/dist/pkt-icon.cjs +1 -1
  100. package/dist/pkt-icon.js +2 -6
  101. package/dist/pkt-index.cjs +1 -1
  102. package/dist/pkt-index.js +30 -66
  103. package/dist/pkt-input-wrapper.cjs +1 -1
  104. package/dist/pkt-input-wrapper.js +2 -6
  105. package/dist/pkt-link.cjs +1 -1
  106. package/dist/pkt-link.js +2 -6
  107. package/dist/pkt-linkcard.cjs +1 -1
  108. package/dist/pkt-linkcard.js +2 -6
  109. package/dist/pkt-listbox.cjs +1 -1
  110. package/dist/pkt-listbox.js +2 -6
  111. package/dist/pkt-loader.cjs +1 -1
  112. package/dist/pkt-loader.js +2 -6
  113. package/dist/pkt-messagebox.cjs +1 -1
  114. package/dist/pkt-messagebox.js +2 -6
  115. package/dist/pkt-modal.cjs +1 -1
  116. package/dist/pkt-modal.js +2 -6
  117. package/dist/pkt-options-controller-CRrI6WMk.js +43 -0
  118. package/dist/pkt-options-controller-CXUGx134.cjs +1 -0
  119. package/dist/pkt-progressbar.cjs +1 -1
  120. package/dist/pkt-progressbar.js +2 -6
  121. package/dist/pkt-radiobutton.cjs +1 -1
  122. package/dist/pkt-radiobutton.js +2 -6
  123. package/dist/pkt-select.cjs +1 -1
  124. package/dist/pkt-select.js +2 -6
  125. package/dist/pkt-tabs.cjs +1 -1
  126. package/dist/pkt-tabs.js +2 -7
  127. package/dist/pkt-tag.cjs +1 -1
  128. package/dist/pkt-tag.js +2 -6
  129. package/dist/pkt-textarea.cjs +1 -1
  130. package/dist/pkt-textarea.js +2 -6
  131. package/dist/pkt-textinput.cjs +1 -1
  132. package/dist/pkt-textinput.js +2 -6
  133. package/dist/pkt-timepicker.cjs +1 -191
  134. package/dist/pkt-timepicker.js +2 -558
  135. package/dist/progressbar-CdXtmOBb.cjs +17 -0
  136. package/dist/progressbar-Dy9AiYQz.js +113 -0
  137. package/dist/radiobutton-GOnpUbCW.cjs +31 -0
  138. package/dist/radiobutton-V_KPbup_.js +84 -0
  139. package/dist/ref-BaJ0mBT_.cjs +1 -0
  140. package/dist/ref-RS8Uv6uC.js +30 -0
  141. package/dist/repeat-Cepr3469.js +57 -0
  142. package/dist/repeat-CqcDYBxr.cjs +1 -0
  143. package/dist/select-BSAFd8Wa.js +164 -0
  144. package/dist/select-C2i8sOk5.cjs +49 -0
  145. package/dist/tabs-D8nL9rWx.cjs +37 -0
  146. package/dist/tabs-Y7utmJi9.js +318 -0
  147. package/dist/tag-DLthw5b4.cjs +27 -0
  148. package/dist/tag-VwykmuQR.js +179 -0
  149. package/dist/textarea-D7aGOyDf.cjs +46 -0
  150. package/dist/textarea-DYOBhJrN.js +115 -0
  151. package/dist/textinput-BUgntXnM.js +124 -0
  152. package/dist/textinput-DFh8_9cx.cjs +70 -0
  153. package/dist/timepicker-BIfE7KKJ.cjs +191 -0
  154. package/dist/timepicker-DaSwn1FA.js +503 -0
  155. package/dist/utils-CUqCKGvp.js +7 -0
  156. package/dist/utils-CjAbIttF.cjs +1 -0
  157. package/package.json +6 -6
  158. package/src/components/accordion/accordion.ts +6 -1
  159. package/src/components/accordion/accordionitem.ts +6 -1
  160. package/src/components/alert/alert.test.ts +1 -1
  161. package/src/components/alert/alert.ts +12 -7
  162. package/src/components/backlink/backlink.ts +6 -1
  163. package/src/components/breadcrumbs/breadcrumbs.ts +6 -1
  164. package/src/components/button/button.ts +6 -1
  165. package/src/components/calendar/calendar.ts +6 -1
  166. package/src/components/card/card.ts +6 -1
  167. package/src/components/checkbox/checkbox.ts +6 -1
  168. package/src/components/combobox/combobox.ts +6 -1
  169. package/src/components/consent/consent.ts +6 -1
  170. package/src/components/datepicker/date-tags.ts +6 -1
  171. package/src/components/datepicker/datepicker-multiple.ts +6 -1
  172. package/src/components/datepicker/datepicker-popup.ts +6 -1
  173. package/src/components/datepicker/datepicker-range.ts +6 -1
  174. package/src/components/datepicker/datepicker-single.ts +6 -1
  175. package/src/components/datepicker/datepicker-utils.test.ts +16 -23
  176. package/src/components/datepicker/datepicker.ts +6 -1
  177. package/src/components/header/header-service.ts +6 -1
  178. package/src/components/header/header-user-menu.ts +6 -1
  179. package/src/components/header/header.ts +6 -1
  180. package/src/components/heading/heading.ts +6 -1
  181. package/src/components/helptext/helptext.ts +6 -1
  182. package/src/components/icon/icon.ts +6 -1
  183. package/src/components/input-wrapper/input-wrapper.ts +6 -1
  184. package/src/components/link/link.ts +6 -1
  185. package/src/components/linkcard/linkcard.ts +6 -1
  186. package/src/components/listbox/listbox.ts +6 -1
  187. package/src/components/loader/loader.ts +6 -1
  188. package/src/components/messagebox/messagebox.ts +6 -1
  189. package/src/components/modal/modal.ts +6 -1
  190. package/src/components/progressbar/progressbar.ts +6 -1
  191. package/src/components/radiobutton/radiobutton.ts +6 -1
  192. package/src/components/select/select.ts +6 -1
  193. package/src/components/tabs/tabitem.ts +6 -1
  194. package/src/components/tabs/tabs.ts +6 -1
  195. package/src/components/tag/tag.ts +6 -1
  196. package/src/components/textarea/textarea.ts +6 -1
  197. package/src/components/textinput/textinput.ts +6 -1
  198. package/src/components/timepicker/timepicker.ts +6 -1
  199. package/dist/accordionitem-D1Agl1bB.cjs +0 -34
  200. package/dist/accordionitem-ZlaXvjt5.js +0 -138
  201. package/dist/alert-BuAXrnKl.js +0 -115
  202. package/dist/alert-DFkFNTxh.cjs +0 -33
  203. package/dist/async-directive-CMzWMlZ5.js +0 -65
  204. package/dist/async-directive-DoMuclel.cjs +0 -5
  205. package/dist/backlink-EiAXUUZP.cjs +0 -13
  206. package/dist/backlink-V4DAt17e.js +0 -47
  207. package/dist/booleanish-BKVonob4.cjs +0 -1
  208. package/dist/booleanish-C9R0tdXH.js +0 -11
  209. package/dist/button-DEyvt1LI.js +0 -137
  210. package/dist/button-DYv5Dg4M.cjs +0 -27
  211. package/dist/calendar-HIE9nxcc.cjs +0 -90
  212. package/dist/calendar-S63oreVW.js +0 -2138
  213. package/dist/card-CyeH6l1c.cjs +0 -87
  214. package/dist/card-DDiLfuO4.js +0 -231
  215. package/dist/checkbox-BLlwTABj.cjs +0 -31
  216. package/dist/checkbox-ejBUa5qQ.js +0 -145
  217. package/dist/class-map-CEnykyO_.js +0 -34
  218. package/dist/class-map-CsENJXf1.cjs +0 -5
  219. package/dist/classutils-BwNK82ZQ.cjs +0 -1
  220. package/dist/classutils-RQs1k6D9.js +0 -7
  221. package/dist/combobox-BmxSecfE.js +0 -818
  222. package/dist/combobox-Hb2V-fPX.cjs +0 -135
  223. package/dist/consent-iXyx5v6J.js +0 -173
  224. package/dist/consent-ruWAEVXW.cjs +0 -11
  225. package/dist/datepicker-CZl7b8Na.js +0 -1158
  226. package/dist/datepicker-D2H7U6MS.cjs +0 -273
  227. package/dist/dialog-polyfill.esm-CPKZe7AL.cjs +0 -1
  228. package/dist/dialog-polyfill.esm-CbjBMXAG.js +0 -395
  229. package/dist/directive-C7oCP5Bh.cjs +0 -5
  230. package/dist/directive-helpers-BP2WOx60.cjs +0 -5
  231. package/dist/directive-helpers-rm-28gIj.js +0 -38
  232. package/dist/directive-oAbCiebi.js +0 -27
  233. package/dist/element-CPpT3rFQ.js +0 -638
  234. package/dist/element-gR_VtSiD.cjs +0 -27
  235. package/dist/element-with-slot-Dqk6-TRR.js +0 -240
  236. package/dist/element-with-slot-ZX-up7jO.cjs +0 -1
  237. package/dist/heading-CKt7cVn7.js +0 -101
  238. package/dist/heading-Cvz8m1xL.cjs +0 -1
  239. package/dist/helptext-5Mzp65-F.cjs +0 -24
  240. package/dist/helptext-jIoWRcCF.js +0 -80
  241. package/dist/icon-BlKA8YuW.js +0 -103
  242. package/dist/icon-Bqj9oBbl.cjs +0 -9
  243. package/dist/if-defined-B0krMLad.js +0 -10
  244. package/dist/if-defined-BOW3ODSj.cjs +0 -5
  245. package/dist/input-element-8nLwuQS4.js +0 -837
  246. package/dist/input-element-DdVhUvva.cjs +0 -1
  247. package/dist/input-wrapper-B0MkQ0IZ.cjs +0 -54
  248. package/dist/input-wrapper-B2JpK016.js +0 -179
  249. package/dist/input-wrapper-CDgenrYA.js +0 -6
  250. package/dist/input-wrapper-EoSAbU-U.cjs +0 -1
  251. package/dist/link-R_lNhViF.cjs +0 -7
  252. package/dist/link-Z_GizclR.js +0 -53
  253. package/dist/linkcard-BlQvdB1a.js +0 -54
  254. package/dist/linkcard-C7HbSLlX.cjs +0 -13
  255. package/dist/listbox-BQKDZvZn.js +0 -438
  256. package/dist/listbox-CGgV9MAe.cjs +0 -106
  257. package/dist/loader-Ci3CHU8k.js +0 -93
  258. package/dist/loader-e2gs_1xz.cjs +0 -16
  259. package/dist/messagebox-Bf-XMlvW.js +0 -69
  260. package/dist/messagebox-D67w71VX.cjs +0 -13
  261. package/dist/modal-CyvEkbfQ.cjs +0 -36
  262. package/dist/modal-DzGe1g8Z.js +0 -154
  263. package/dist/pkt-options-controller-5LXbEzuk.cjs +0 -1
  264. package/dist/pkt-options-controller-B5YalfCb.js +0 -39
  265. package/dist/progressbar-By7e0lEI.js +0 -162
  266. package/dist/progressbar-DsJ2B9Vm.cjs +0 -21
  267. package/dist/radiobutton-6frNG9J_.js +0 -111
  268. package/dist/radiobutton-Bv-BZ1Hw.cjs +0 -31
  269. package/dist/ref-Bg_Swj5w.js +0 -42
  270. package/dist/ref-CL-Xk9Xm.cjs +0 -5
  271. package/dist/repeat-BD8TKgJb.js +0 -61
  272. package/dist/repeat-Cfq8CDlf.cjs +0 -5
  273. package/dist/select-CXZt1nHS.js +0 -228
  274. package/dist/select-WFhS4Vfp.cjs +0 -49
  275. package/dist/state-C_1EOo3D.js +0 -12
  276. package/dist/state-Dg-53wQ8.cjs +0 -5
  277. package/dist/tabitem-CB8wkKmv.js +0 -332
  278. package/dist/tabitem-DZpspU4Q.cjs +0 -65
  279. package/dist/tag-BuCpqaks.js +0 -115
  280. package/dist/tag-X6xdjR0N.cjs +0 -27
  281. package/dist/textarea-Bzuymclz.js +0 -131
  282. package/dist/textarea-DoeHJ7HR.cjs +0 -50
  283. package/dist/textinput-9lHjs4ce.js +0 -150
  284. package/dist/textinput-BNsLd26i.cjs +0 -70
  285. package/dist/utils-DznhwRXm.js +0 -8
  286. package/dist/utils-byXsEz1u.cjs +0 -1
@@ -1,818 +0,0 @@
1
- import { n as r, A as m, b as c, t as M } from "./element-CPpT3rFQ.js";
2
- import { o as u } from "./if-defined-B0krMLad.js";
3
- import { e as I, n as y } from "./ref-Bg_Swj5w.js";
4
- import { e as w } from "./class-map-CEnykyO_.js";
5
- import { c as P } from "./repeat-BD8TKgJb.js";
6
- import { f, g as B, b as U, i as O, a as E, c as R } from "./listbox-BQKDZvZn.js";
7
- import { s as q } from "./element-with-slot-Dqk6-TRR.js";
8
- import { r as v } from "./state-C_1EOo3D.js";
9
- import { P as N } from "./input-element-8nLwuQS4.js";
10
- import { P as L } from "./pkt-options-controller-B5YalfCb.js";
11
- import "./input-wrapper-B2JpK016.js";
12
- import "./icon-BlKA8YuW.js";
13
- import "./tag-BuCpqaks.js";
14
- const j = (i, t, e) => {
15
- switch (i) {
16
- case ",":
17
- return e ? "addValue" : null;
18
- case "Enter":
19
- return "addValue";
20
- case "Tab":
21
- case "ArrowDown":
22
- return t ? null : "focusListbox";
23
- case "Escape":
24
- return "closeOptions";
25
- default:
26
- return null;
27
- }
28
- }, K = (i, t, e, s, l) => {
29
- if (!i) return { action: "none", value: null };
30
- const a = f(e, i);
31
- return !t.includes(i) && !a ? s ? { action: "addUserValue", value: i } : l ? { action: "none", value: null } : { action: "removeValue", value: t[0] } : a && !t.includes(a.value) ? { action: "selectOption", value: a.value } : { action: "none", value: null };
32
- }, W = (i, t, e, s, l) => i.trim().toLowerCase() ? {
33
- ...B(i, t, e, s),
34
- shouldRemoveValue: !1,
35
- shouldResetInput: !1
36
- } : {
37
- addValueText: null,
38
- userInfoMessage: "",
39
- shouldRemoveValue: !l && !!t[0],
40
- shouldResetInput: !0
41
- }, k = (i, t, e) => {
42
- const s = f(t, i);
43
- return e === "label" && (s != null && s.label) ? s.label : i;
44
- }, b = {
45
- markOptionSelected(i, t) {
46
- if (t) {
47
- for (const e of i)
48
- if (e.value === t) {
49
- e.selected = !0;
50
- break;
51
- }
52
- }
53
- },
54
- markOptionDeselected(i, t) {
55
- if (t) {
56
- for (const e of i)
57
- if (e.value === t) {
58
- e.selected = !1;
59
- break;
60
- }
61
- }
62
- },
63
- markAllSelected(i) {
64
- for (const t of i)
65
- t.selected = !0;
66
- },
67
- markAllDeselected(i) {
68
- for (const t of i)
69
- t.selected = !1;
70
- },
71
- removeUserAddedOptions(i) {
72
- return i.filter((t) => !t.userAdded);
73
- }
74
- }, C = {
75
- parseOptionsFromSlot(i) {
76
- const t = [];
77
- return i.forEach((e) => {
78
- if (!e.textContent && !e.getAttribute("value")) return;
79
- const s = {
80
- value: e.getAttribute("value") || e.textContent || "",
81
- label: e.textContent || e.getAttribute("value") || ""
82
- };
83
- e.getAttribute("data-prefix") && (s.prefix = e.getAttribute("data-prefix") || void 0), e.getAttribute("tagskincolor") && (s.tagSkinColor = e.getAttribute("tagskincolor")), e.getAttribute("description") && (s.description = e.getAttribute("description") || void 0), s.fulltext = U(s), t.push(s);
84
- }), t;
85
- }
86
- }, A = {
87
- /**
88
- * Ensures options have labels and fulltext set.
89
- * Also syncs selected state with current values.
90
- *
91
- * IMPORTANT: Mutates options in place to preserve referential identity
92
- * between this._options and this.options in the Lit component.
93
- */
94
- syncOptionsWithValues(i, t) {
95
- const e = [...t];
96
- return i.forEach((s) => {
97
- s.value && !s.label && (s.label = s.value), s.selected && !e.includes(s.value) && e.push(s.value), s.fulltext = U(s), s.selected = s.selected || e.includes(s.value);
98
- }), { options: i, newValues: e };
99
- },
100
- /**
101
- * Merges user-added options with new options, preserving user additions.
102
- */
103
- mergeWithUserAdded(i, t) {
104
- return [...t.filter((l) => (l == null ? void 0 : l.userAdded) && l.selected).filter(
105
- (l) => !(Array.isArray(i) ? i : []).some((a) => a.value === l.value)
106
- ), ...i];
107
- }
108
- }, G = { displayValueAs: { default: "label" } }, J = {
109
- props: G
110
- };
111
- var H = Object.defineProperty, h = (i, t, e, s) => {
112
- for (var l = void 0, a = i.length - 1, o; a >= 0; a--)
113
- (o = i[a]) && (l = o(t, e, l) || l);
114
- return l && H(t, e, l), l;
115
- };
116
- class n extends N {
117
- constructor() {
118
- super(), this.value = "", this.options = [], this.defaultOptions = [], this.allowUserInput = !1, this.typeahead = !1, this.includeSearch = !1, this.searchPlaceholder = "", this.multiple = !1, this.maxlength = null, this.displayValueAs = J.props.displayValueAs.default, this.tagPlacement = null, this.isOpen = !1, this._options = [], this._value = [], this._isOptionsOpen = !1, this._userInfoMessage = "", this._addValueText = null, this._maxIsReached = !1, this._search = "", this._inputFocus = !1, this._internalValueSync = !1, this._optionsFromSlot = !1, this._lastSlotGeneration = 0, this._suppressNextOpen = !1, this.inputRef = I(), this.triggerRef = I(), this.listboxRef = I(), this.optionsController = new L(this);
119
- }
120
- get _hasTextInput() {
121
- return this.typeahead || this.allowUserInput;
122
- }
123
- get _selectionDescription() {
124
- if (!(!this.multiple || this._value.length === 0))
125
- return `${this._value.length} valgt`;
126
- }
127
- /**
128
- * Focuses the appropriate trigger element after closing the listbox.
129
- * Select-only: the combobox input div. Editable: the text input.
130
- */
131
- focusTrigger() {
132
- var t, e;
133
- this._hasTextInput ? (t = this.inputRef.value) == null || t.focus() : (e = this.triggerRef.value) == null || e.focus();
134
- }
135
- /**
136
- * Parses the value prop into an internal string array.
137
- */
138
- parseValue() {
139
- return Array.isArray(this.value) ? this.multiple ? this.value : this.value.length > 0 ? [this.value[0]] : [] : this.value && this.multiple ? this.value.split(",") : this.value ? [this.value] : [];
140
- }
141
- /**
142
- * Updates the _maxIsReached state flag.
143
- */
144
- updateMaxReached() {
145
- this._maxIsReached = O(this._value.length, this.maxlength);
146
- }
147
- /**
148
- * Syncs the public value property from internal _value state and dispatches
149
- * events if the value content changed. Always sets this.value as a string
150
- * to prevent array→string reflect cascades.
151
- */
152
- syncValueAndDispatch(t) {
153
- const e = this._value, s = this.multiple ? e.join(",") : e[0] || "", l = Array.isArray(this.value) ? this.value.join(",") : String(this.value || "");
154
- if (s !== l && (this._internalValueSync = !0, this.value = s), (t == null ? void 0 : t.join(",")) !== e.join(",")) {
155
- const a = this.multiple ? [...e] : e[0] || "";
156
- this.onChange(a);
157
- } else e.length === 0 && t && t.length > 0 && this.clearInputValue();
158
- }
159
- /**
160
- * Override onChange to skip the base class touched guard.
161
- * The base class returns early on the first call (setting touched = true but not
162
- * dispatching events). Combobox needs consistent event dispatch regardless of
163
- * touched state.
164
- */
165
- onChange(t) {
166
- this.touched = !0, super.onChange(t);
167
- }
168
- /**
169
- * No-op override of the base class valueChanged.
170
- * The base class version sets both this.value AND this._value, which creates
171
- * an infinite _value → valueChanged → value → parseValue → _value loop.
172
- * Combobox handles value sync and event dispatch in syncValueAndDispatch() instead.
173
- */
174
- valueChanged() {
175
- }
176
- }
177
- h([
178
- r({ type: String, reflect: !0 })
179
- ], n.prototype, "value");
180
- h([
181
- r({ type: Array })
182
- ], n.prototype, "options");
183
- h([
184
- r({ type: Array, attribute: "default-options" })
185
- ], n.prototype, "defaultOptions");
186
- h([
187
- r({ type: Boolean, attribute: "allow-user-input" })
188
- ], n.prototype, "allowUserInput");
189
- h([
190
- r({ type: Boolean })
191
- ], n.prototype, "typeahead");
192
- h([
193
- r({ type: Boolean, attribute: "include-search" })
194
- ], n.prototype, "includeSearch");
195
- h([
196
- r({ type: String, attribute: "search-placeholder" })
197
- ], n.prototype, "searchPlaceholder");
198
- h([
199
- r({ type: Boolean })
200
- ], n.prototype, "multiple");
201
- h([
202
- r({ type: Number })
203
- ], n.prototype, "maxlength");
204
- h([
205
- r({ type: String, attribute: "display-value-as" })
206
- ], n.prototype, "displayValueAs");
207
- h([
208
- r({ type: String, attribute: "tag-placement" })
209
- ], n.prototype, "tagPlacement");
210
- h([
211
- r({ type: Boolean, attribute: "open" })
212
- ], n.prototype, "isOpen");
213
- h([
214
- v()
215
- ], n.prototype, "_options");
216
- h([
217
- v()
218
- ], n.prototype, "_value");
219
- h([
220
- v()
221
- ], n.prototype, "_isOptionsOpen");
222
- h([
223
- v()
224
- ], n.prototype, "_userInfoMessage");
225
- h([
226
- v()
227
- ], n.prototype, "_addValueText");
228
- h([
229
- v()
230
- ], n.prototype, "_maxIsReached");
231
- h([
232
- v()
233
- ], n.prototype, "_search");
234
- h([
235
- v()
236
- ], n.prototype, "_inputFocus");
237
- class z extends n {
238
- toggleValue(t) {
239
- var T, S;
240
- if (this.disabled) return;
241
- this.touched = !0, this._userInfoMessage = "", this._addValueText = null;
242
- const e = ((T = f(this.options, t)) == null ? void 0 : T.value) || null, s = this._value.includes(t || e || ""), l = !!e, a = ((S = this._options.find((D) => D.value === t)) == null ? void 0 : S.disabled) || !1, o = !(t != null && t.trim()), p = !this.multiple, d = this.multiple, V = O(this._value.length, this.maxlength);
243
- let _ = !1, x = !0, g = "", $ = "";
244
- a || (!l && this.allowUserInput && !o ? (this.addNewUserValue(t), g = "Ny verdi lagt til", _ = d) : !l && !this.allowUserInput ? (p && this._value[0] && this.removeValue(this._value[0]), x = !1, _ = !0, g = "Ingen treff i søket") : s ? (this.removeValue(e), _ = !0, p && this._hasTextInput && this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = "")) : o && p ? (this.removeAllSelected(), _ = !0) : p ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(e), _ = !1) : d && !V ? (this.setSelected(e), _ = !0) : d && V ? (g = "Maks antall valg nådd", x = !1, $ = t) : (p && this.removeAllSelected(), g = "Ingen gyldig verdi valgt", x = !1, _ = !0, $ = t), this._isOptionsOpen = _, _ || (p && this._hasTextInput && (this._suppressNextOpen = !0), window.setTimeout(() => {
245
- this.focusTrigger();
246
- }, 0)), this._userInfoMessage = g, this._search = $ || "", this.resetComboboxInput(x), d && this.updateMaxReached());
247
- }
248
- setSelected(t) {
249
- if (!this._value.includes(t)) {
250
- if (this.multiple && O(this._value.length, this.maxlength)) {
251
- this._userInfoMessage = "Maks antall valg nådd";
252
- return;
253
- }
254
- !this.multiple && this.removeAllSelected(), this._value = t ? [...this._value, t] : this._value, b.markOptionSelected(this._options, t), this.resetComboboxInput(!0);
255
- }
256
- }
257
- removeSelected(t) {
258
- if (!t) return;
259
- this._value = this._value.filter((s) => s !== t);
260
- const e = f(this.options, t);
261
- e && (b.markOptionDeselected(this.options, t), e.userAdded ? (this._options = [...this._options.filter((s) => s.value !== t)], this.options = [...this.options.filter((s) => s.value !== t)]) : this._options.some((s) => s.value === t) || (this._options = [...this._options, e]));
262
- }
263
- addAllOptions() {
264
- if (this.multiple) {
265
- if (this.maxlength && this._options.length > this.maxlength) {
266
- this._userInfoMessage = "For mange valgt";
267
- return;
268
- }
269
- this._value = this._options.map((t) => t.value), b.markAllSelected(this._options), this.requestUpdate();
270
- }
271
- }
272
- removeAllSelected() {
273
- this._value = [], b.markAllDeselected(this._options), this._options = b.removeUserAddedOptions(this._options), this.requestUpdate();
274
- }
275
- addValue() {
276
- var e;
277
- const t = ((e = this.inputRef.value) == null ? void 0 : e.value.trim()) || "";
278
- if (this._search = t, t && this._value.includes(t)) {
279
- this.resetComboboxInput(!0), this._userInfoMessage = "Verdien er allerede valgt";
280
- return;
281
- }
282
- this.toggleValue(t);
283
- }
284
- removeValue(t) {
285
- this._value = this.multiple ? this._value.filter((e) => e !== t) : [], this.removeSelected(t);
286
- }
287
- addNewUserValue(t) {
288
- if (!t || t.trim() === "") return;
289
- if (!this.multiple)
290
- this._value[0] && this.removeSelected(this._value[0]), this._value = [t];
291
- else if (!f(this.options, t)) {
292
- if (O(this._value.length, this.maxlength)) return;
293
- this._value = [...this._value, t];
294
- }
295
- const e = { value: t, label: t, userAdded: !0, selected: !0 };
296
- this.options = [e, ...this.options], this._options = [e, ...this._options], this.resetComboboxInput(!0), this.multiple || (this._isOptionsOpen = !1, this._hasTextInput && (this._suppressNextOpen = !0), window.setTimeout(() => {
297
- this.focusTrigger();
298
- }, 0)), this.requestUpdate();
299
- }
300
- resetComboboxInput(t = !0) {
301
- this._addValueText = null, this.inputRef.value && this.inputRef.value.type !== "hidden" && t && (this._search = "", this.multiple ? this.inputRef.value.value = "" : (this.inputRef.value.value = this._value[0] ? k(this._value[0], this.options, this.displayValueAs) : "", this._userInfoMessage = "")), this._options = [...this.options];
302
- }
303
- removeLastValue(t) {
304
- if (this._value.length === 0) return;
305
- t.preventDefault();
306
- const e = this._value[this._value.length - 1];
307
- e && this.removeSelected(e), this.updateMaxReached();
308
- }
309
- }
310
- class Q extends z {
311
- handleInput(t) {
312
- if (t.stopPropagation(), t.stopImmediatePropagation(), this.disabled) return;
313
- this.touched = !0;
314
- const e = t.target;
315
- if (this._search = e.value, this.checkForMatches(), this.typeahead)
316
- if (this._search) {
317
- const { filtered: s, suggestion: l } = E(this.options, this._search);
318
- this._options = s, t.inputType !== "deleteContentBackward" && (l != null && l.label) && this.inputRef.value && this.inputRef.value.type !== "hidden" && (e.value = l.label, window.setTimeout(
319
- () => e.setSelectionRange(this._search.length, e.value.length),
320
- 0
321
- ), e.selectionDirection = "backward");
322
- } else
323
- this._options = [...this.options];
324
- }
325
- handleFocus() {
326
- if (!this.disabled) {
327
- if (this._suppressNextOpen) {
328
- this._suppressNextOpen = !1, this._inputFocus = !0, this.requestUpdate();
329
- return;
330
- }
331
- !this.multiple && this._value[0] && this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = k(
332
- this._value[0],
333
- this.options,
334
- this.displayValueAs
335
- )), this._inputFocus = !0, this._search = "", this._options = [...this.options], this._isOptionsOpen = !0, this.onFocus(), this.requestUpdate();
336
- }
337
- }
338
- handleFocusOut(t) {
339
- var l, a;
340
- if (this.disabled || !this._isOptionsOpen) return;
341
- const e = t.relatedTarget;
342
- ((l = e == null ? void 0 : e.closest("pkt-combobox")) == null ? void 0 : l.id) === this.id || ((a = t.target) == null ? void 0 : a.getAttribute("data-focusfix")) === this.id || e === this.inputRef.value || e === this.triggerRef.value || this.closeAndProcessInput();
343
- }
344
- /**
345
- * Shared close logic used by both focusout and outside-click handlers.
346
- * Processes any pending input value, then closes the dropdown.
347
- */
348
- closeAndProcessInput() {
349
- if (this._inputFocus = !1, this._addValueText = null, this._userInfoMessage = "", this._search = "", this.inputRef.value && this.inputRef.value.type !== "hidden") {
350
- const t = this.inputRef.value.value;
351
- if (this.multiple) {
352
- if (t !== "") {
353
- const { action: e, value: s } = K(
354
- t,
355
- this._value,
356
- this.options,
357
- this.allowUserInput,
358
- this.multiple
359
- );
360
- switch (e) {
361
- case "addUserValue":
362
- this.addNewUserValue(s);
363
- break;
364
- case "selectOption":
365
- this.setSelected(s);
366
- break;
367
- case "removeValue":
368
- this.removeValue(s);
369
- break;
370
- }
371
- }
372
- } else if (!t)
373
- this._value[0] && this.removeSelected(this._value[0]);
374
- else {
375
- const e = f(this.options, t);
376
- e && e.value !== this._value[0] ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(e.value)) : !e && this.allowUserInput && (this._value[0] && this.removeSelected(this._value[0]), this.addNewUserValue(t));
377
- }
378
- !this.multiple && this._value[0] ? this.inputRef.value.value = k(
379
- this._value[0],
380
- this.options,
381
- this.displayValueAs
382
- ) : this.inputRef.value.value = "";
383
- }
384
- this._isOptionsOpen = !1, this.onBlur();
385
- }
386
- handleBlur() {
387
- this._inputFocus = !1, this.onBlur();
388
- }
389
- handleInputClick(t) {
390
- var e, s;
391
- if (this.disabled) {
392
- t.preventDefault(), t.stopImmediatePropagation();
393
- return;
394
- }
395
- this._hasTextInput ? ((e = this.inputRef.value) == null || e.focus(), this.requestUpdate()) : (t.stopImmediatePropagation(), t.preventDefault(), this._isOptionsOpen = !this._isOptionsOpen, this._isOptionsOpen && ((s = this.listboxRef.value) == null || s.focusFirstOrSelectedOption()));
396
- }
397
- handlePlaceholderClick(t) {
398
- this.disabled || (t.stopPropagation(), this._hasTextInput && this.inputRef.value ? (this.inputRef.value.focus(), this._inputFocus = !0, this.requestUpdate()) : (this._isOptionsOpen = !this._isOptionsOpen, this.requestUpdate()));
399
- }
400
- handleSelectOnlyKeydown(t) {
401
- var e, s;
402
- if (!this.disabled)
403
- switch (t.key) {
404
- case "Enter":
405
- case " ":
406
- case "ArrowDown":
407
- case "ArrowUp":
408
- t.preventDefault(), this._isOptionsOpen ? this._isOptionsOpen = !1 : (this._isOptionsOpen = !0, (e = this.listboxRef.value) == null || e.focusFirstOrSelectedOption());
409
- break;
410
- case "Escape":
411
- this._isOptionsOpen && (t.preventDefault(), this._isOptionsOpen = !1);
412
- break;
413
- case "Home":
414
- case "End":
415
- t.preventDefault(), this._isOptionsOpen || (this._isOptionsOpen = !0), (s = this.listboxRef.value) == null || s.focusFirstOrSelectedOption();
416
- break;
417
- case "ArrowLeft":
418
- this.multiple && this._value.length > 0 && (t.preventDefault(), this.focusTag(this._value.length - 1));
419
- break;
420
- case "Backspace":
421
- case "Delete":
422
- this.multiple && this._value.length > 0 && (t.preventDefault(), this.removeSelected(this._value[this._value.length - 1]));
423
- break;
424
- }
425
- }
426
- handleOptionToggled(t) {
427
- this.toggleValue(t.detail);
428
- }
429
- handleSearch(t) {
430
- t.stopPropagation(), this._search = t.detail.toLowerCase(), this.checkForMatches();
431
- }
432
- handleInputKeydown(t) {
433
- var s, l, a;
434
- if (t.key === "Backspace") {
435
- const o = !((s = this.inputRef.value) != null && s.value);
436
- !this._search && o && this.multiple && this._value.length > 0 && this.removeLastValue(t);
437
- return;
438
- }
439
- if (t.key === "ArrowLeft" && this.multiple && this._value.length > 0) {
440
- const o = this.inputRef.value;
441
- if (o && o.selectionStart === 0 && !o.value) {
442
- t.preventDefault(), this.focusTag(this._value.length - 1);
443
- return;
444
- }
445
- }
446
- const e = j(t.key, t.shiftKey, this.multiple);
447
- if (e && !(t.key === "Tab" && !this._isOptionsOpen)) {
448
- if (e === "focusListbox" && t.key === "Tab" && !((l = this.listboxRef.value) == null ? void 0 : l.querySelector(
449
- '[role="option"]:not([data-disabled]), [data-type="new-option"]'
450
- ))) {
451
- this.closeAndProcessInput();
452
- return;
453
- }
454
- switch (t.preventDefault(), e) {
455
- case "addValue":
456
- this.addValue();
457
- break;
458
- case "focusListbox":
459
- (a = this.listboxRef.value) == null || a.focusFirstOrSelectedOption();
460
- break;
461
- case "closeOptions":
462
- this._isOptionsOpen = !1;
463
- break;
464
- }
465
- }
466
- }
467
- handleTagRemove(t) {
468
- this.removeSelected(t), this._hasTextInput && this.inputRef.value && (this._inputFocus = !0, this.inputRef.value.focus(), this.requestUpdate());
469
- }
470
- getInsideTags() {
471
- return Array.from(
472
- this.querySelectorAll(".pkt-combobox__input .pkt-combobox__tag-list pkt-tag")
473
- );
474
- }
475
- focusTag(t) {
476
- var l;
477
- const e = this.getInsideTags();
478
- e.forEach((a, o) => {
479
- a.buttonTabindex = o === t ? 0 : -1;
480
- });
481
- const s = (l = e[t]) == null ? void 0 : l.querySelector("button");
482
- s == null || s.focus();
483
- }
484
- resetTagTabindices() {
485
- this.getInsideTags().forEach((e) => {
486
- e.buttonTabindex = -1;
487
- });
488
- }
489
- handleTagKeydown(t, e) {
490
- t.stopPropagation();
491
- const s = () => {
492
- var l;
493
- this.resetTagTabindices(), this._hasTextInput && this.inputRef.value ? this.inputRef.value.focus() : (l = this.triggerRef.value) == null || l.focus();
494
- };
495
- switch (t.key) {
496
- case "ArrowLeft":
497
- t.preventDefault(), e > 0 && this.focusTag(e - 1);
498
- break;
499
- case "ArrowRight":
500
- t.preventDefault(), e < this._value.length - 1 ? this.focusTag(e + 1) : s();
501
- break;
502
- case "Backspace":
503
- case "Delete":
504
- t.preventDefault();
505
- {
506
- const l = this._value[e], a = e >= this._value.length - 1 ? e - 1 : e;
507
- this.removeSelected(l), a >= 0 ? (this.requestUpdate(), this.updateComplete.then(() => this.focusTag(a))) : s();
508
- }
509
- break;
510
- case "Tab":
511
- this.resetTagTabindices();
512
- break;
513
- case "Escape":
514
- t.preventDefault(), s();
515
- break;
516
- }
517
- }
518
- checkForMatches() {
519
- var s;
520
- const t = ((s = this.inputRef.value) == null ? void 0 : s.value) || this._search || "", e = W(
521
- t,
522
- this._value,
523
- this.options,
524
- this.allowUserInput,
525
- this.multiple
526
- );
527
- if (e.shouldRemoveValue && this.removeValue(this._value[0]), e.shouldResetInput) {
528
- this.resetComboboxInput(!1);
529
- return;
530
- }
531
- this._addValueText = e.addValueText, this._userInfoMessage = e.userInfoMessage;
532
- }
533
- }
534
- var X = Object.getOwnPropertyDescriptor, Y = (i, t, e, s) => {
535
- for (var l = s > 1 ? void 0 : s ? X(t, e) : t, a = i.length - 1, o; a >= 0; a--)
536
- (o = i[a]) && (l = o(l) || l);
537
- return l;
538
- };
539
- let F = class extends Q {
540
- constructor() {
541
- super(...arguments), this.handleBodyClick = (i) => {
542
- this._isOptionsOpen && !this.contains(i.target) && this.closeAndProcessInput();
543
- };
544
- }
545
- // Lifecycle methods
546
- connectedCallback() {
547
- var i, t;
548
- if (super.connectedCallback(), document == null || document.body.addEventListener("click", this.handleBodyClick), this._options = [], this.defaultOptions && this.defaultOptions.length) {
549
- const e = ((i = this.options) == null ? void 0 : i.filter((s) => s.userAdded)) || [];
550
- this.options = [...e, ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options = Array.isArray(this.options) ? [...this.options] : [];
551
- }
552
- if ((t = this.optionsController) != null && t.nodes && this.optionsController.nodes.length) {
553
- const e = C.parseOptionsFromSlot(this.optionsController.nodes);
554
- e.length && (this.options = [...e], this._options = [...e], this._optionsFromSlot = !0, this._lastSlotGeneration = this.optionsController.generation);
555
- }
556
- }
557
- willUpdate(i) {
558
- if (this._optionsFromSlot && this.optionsController) {
559
- const t = this.optionsController.generation;
560
- if (t !== this._lastSlotGeneration) {
561
- this._lastSlotGeneration = t;
562
- const e = C.parseOptionsFromSlot(this.optionsController.nodes), s = this._options.filter((l) => l.userAdded);
563
- this.options = [...s, ...e];
564
- }
565
- }
566
- super.willUpdate(i);
567
- }
568
- disconnectedCallback() {
569
- super.disconnectedCallback(), document == null || document.body.removeEventListener("click", this.handleBodyClick);
570
- }
571
- firstUpdated(i) {
572
- this.defaultValue !== null && !this.value && (this.value = this.defaultValue), super.firstUpdated(i);
573
- }
574
- updated(i) {
575
- i.has("isOpen") && (this._isOptionsOpen = this.isOpen);
576
- const t = i.has("value"), e = i.has("_value");
577
- if (t && this._internalValueSync)
578
- this._internalValueSync = !1, e && this.syncValueAndDispatch(i.get("_value"));
579
- else if (t) {
580
- const l = [...this._value], a = this.parseValue();
581
- a.join(",") !== this._value.join(",") && (this._value = a), this.updateMaxReached(), this.syncValueAndDispatch(l);
582
- } else e && this.syncValueAndDispatch(i.get("_value"));
583
- if (i.has("defaultOptions") && this.defaultOptions.length) {
584
- const l = (Array.isArray(this.options) ? this.options : []).filter((a) => a.userAdded) || [];
585
- this.options = [...l, ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options = Array.isArray(this.options) ? [...this.options] : [];
586
- }
587
- if (i.has("options")) {
588
- const l = i.get("options") || this._options || [], a = A.mergeWithUserAdded(this.options, l);
589
- this._options = a, a.length > this.options.length && (this.options = a);
590
- const o = A.syncOptionsWithValues(this._options, this._value);
591
- if (this._options = o.options, o.newValues.length > this._value.length) {
592
- const p = [...this._value];
593
- this._value = o.newValues, this.syncValueAndDispatch(p);
594
- }
595
- }
596
- if (i.has("_search") && this.dispatchEvent(
597
- new CustomEvent("search", {
598
- detail: this._search,
599
- bubbles: !1
600
- })
601
- ), !this._isOptionsOpen && !this.multiple && this._hasTextInput && this.inputRef.value && this.inputRef.value.type !== "hidden") {
602
- const l = this._value[0] ? k(this._value[0], this.options, this.displayValueAs) : "";
603
- this.inputRef.value.value !== l && (this.inputRef.value.value = l);
604
- }
605
- super.updated(i);
606
- }
607
- /**
608
- * Override form reset to properly restore combobox state.
609
- * The base class deselects all options and sets value/defaultValue, but
610
- * combobox needs to re-sync _options with the restored values and clean up
611
- * user-added options and UI state.
612
- */
613
- formResetCallback() {
614
- this.touched = !1;
615
- const i = this.defaultValue || (this.multiple, "");
616
- this.value = i, this._value = this.parseValue(), this._options = this._options.filter((t) => !t.userAdded).map((t) => ({ ...t, selected: this._value.includes(t.value) })), this.options = this.options.filter((t) => !t.userAdded).map((t) => ({ ...t, selected: this._value.includes(t.value) })), this._search = "", this._isOptionsOpen = !1, this._userInfoMessage = "", this._addValueText = null, this._inputFocus = !1, this.updateMaxReached(), this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = ""), this.internals.setFormValue(""), this.internals.ariaInvalid = "false", this.requestUpdate();
617
- }
618
- attributeChangedCallback(i, t, e) {
619
- if (i === "options") {
620
- this._options = Array.isArray(this.options) ? [...this.options] : [];
621
- const s = A.syncOptionsWithValues(this._options, this._value);
622
- this._options = s.options, s.newValues.length > this._value.length && (this._value = s.newValues), this._search = "";
623
- }
624
- super.attributeChangedCallback(i, t, e);
625
- }
626
- // Render methods
627
- render() {
628
- return c`
629
- <pkt-input-wrapper
630
- .label=${this.label}
631
- .helptext=${this.helptext}
632
- .helptextDropdown=${u(this.helptextDropdown)}
633
- .helptextDropdownButton=${u(this.helptextDropdownButton)}
634
- ?fullwidth=${this.fullwidth}
635
- ?hasError=${this.hasError}
636
- ?inline=${this.inline}
637
- ?disabled=${this.disabled}
638
- .errorMessage=${this.errorMessage}
639
- ?optionalTag=${this.optionalTag}
640
- .optionalText=${this.optionalText}
641
- ?requiredTag=${this.requiredTag}
642
- .requiredText=${this.requiredText}
643
- .tagText=${this.tagText}
644
- useWrapper=${this.useWrapper}
645
- .forId=${this._hasTextInput ? this.id + "-input" : this.id + "-combobox"}
646
- ?hasFieldset=${!this._hasTextInput}
647
- class="pkt-combobox__wrapper"
648
- @labelClick=${this.handleInputClick}
649
- >
650
- <div class="pkt-contents" slot="helptext">${q(this, "helptext")}</div>
651
- <div class="pkt-combobox" @focusout=${this.handleFocusOut}>
652
- <div
653
- class=${w({
654
- "pkt-combobox__input": !0,
655
- "pkt-combobox__input--fullwidth": this.fullwidth,
656
- "pkt-combobox__input--open": this._isOptionsOpen,
657
- "pkt-combobox__input--error": this.hasError,
658
- "pkt-combobox__input--disabled": this.disabled
659
- })}
660
- id=${u(this._hasTextInput ? void 0 : `${this.id}-combobox`)}
661
- role=${u(this._hasTextInput ? void 0 : "combobox")}
662
- aria-expanded=${u(
663
- this._hasTextInput ? void 0 : this._isOptionsOpen ? "true" : "false"
664
- )}
665
- aria-controls=${u(this._hasTextInput ? void 0 : `${this.id}-listbox`)}
666
- aria-haspopup=${u(this._hasTextInput ? void 0 : "listbox")}
667
- aria-labelledby=${u(
668
- this._hasTextInput ? void 0 : `${this.id}-combobox-label`
669
- )}
670
- aria-activedescendant=${u(
671
- !this._hasTextInput && this._value[0] && f(this.options, this._value[0]) ? `${this.id}-listbox-${R(this._options, this._value[0])}` : void 0
672
- )}
673
- aria-description=${u(this._selectionDescription || void 0)}
674
- tabindex=${this._hasTextInput || this.disabled ? "-1" : "0"}
675
- @click=${this.handleInputClick}
676
- @keydown=${this._hasTextInput ? m : this.handleSelectOnlyKeydown}
677
- ${y(this.triggerRef)}
678
- >
679
- ${!this._hasTextInput && this.placeholder && (!this._value.length || this.multiple && this.tagPlacement == "outside") && !this._inputFocus ? c`<span class="pkt-combobox__placeholder" @click=${this.handlePlaceholderClick}
680
- >${this.placeholder}</span
681
- >` : this.tagPlacement !== "outside" ? this.renderSingleOrMultipleValues() : m}
682
- ${this.renderInputField()}
683
- <pkt-icon
684
- class=${w({
685
- "pkt-combobox__arrow-icon": !0,
686
- "pkt-combobox__arrow-icon--open": this._isOptionsOpen
687
- })}
688
- name="chevron-thin-down"
689
- aria-hidden="true"
690
- ></pkt-icon>
691
- </div>
692
-
693
- <pkt-listbox
694
- id="${this.id}-listbox"
695
- .options=${this._options}
696
- .isOpen=${this._isOptionsOpen}
697
- .searchPlaceholder=${this.searchPlaceholder}
698
- .label="Liste: ${this.label || ""}"
699
- ?include-search=${this.includeSearch}
700
- ?is-multi-select=${this.multiple}
701
- ?allow-user-input=${this.allowUserInput && !this._maxIsReached}
702
- ?max-is-reached=${this._maxIsReached}
703
- .customUserInput=${u(this._addValueText)}
704
- .userMessage=${this._userInfoMessage}
705
- @search=${this.handleSearch}
706
- @option-toggle=${this.handleOptionToggled}
707
- @select-all=${this.addAllOptions}
708
- @close-options=${() => this._isOptionsOpen = !1}
709
- @tab-close=${() => this.closeAndProcessInput()}
710
- .searchValue=${this._search || null}
711
- .maxLength=${this.maxlength || 0}
712
- ${y(this.listboxRef)}
713
- ></pkt-listbox>
714
- </div>
715
-
716
- ${this.tagPlacement === "outside" && this.multiple ? c`<div class="pkt-combobox__tags-outside">
717
- ${this.renderSingleOrMultipleValues()}
718
- </div>` : m}
719
- </pkt-input-wrapper>
720
- `;
721
- }
722
- renderInputField() {
723
- return this.typeahead || this.allowUserInput ? c`
724
- <div class="pkt-combobox__input-div combobox__input">
725
- <input
726
- type="text"
727
- id="${this.id}-input"
728
- name=${(this.name || this.id) + "-input"}
729
- placeholder=${u(
730
- !this._value.length || this.multiple && this.tagPlacement === "outside" ? this.placeholder : void 0
731
- )}
732
- @input=${this.handleInput}
733
- @change=${(i) => {
734
- i.stopPropagation(), i.stopImmediatePropagation();
735
- }}
736
- @keydown=${this.handleInputKeydown}
737
- @focus=${this.handleFocus}
738
- @blur=${this.handleBlur}
739
- autocomplete="off"
740
- role="combobox"
741
- aria-expanded=${this._isOptionsOpen ? "true" : "false"}
742
- aria-label=${u(this.label)}
743
- aria-autocomplete=${this.typeahead ? "both" : this.allowUserInput ? "list" : "none"}
744
- aria-controls="${this.id}-listbox"
745
- aria-activedescendant=${u(
746
- this._value[0] && f(this.options, this._value[0]) ? `${this.id}-listbox-${R(this._options, this._value[0])}` : void 0
747
- )}
748
- aria-description=${u(this._selectionDescription || void 0)}
749
- ${y(this.inputRef)}
750
- />
751
- </div>
752
- ` : c`
753
- <input
754
- type="hidden"
755
- id="${this.id}-input"
756
- name=${(this.name || this.id) + "-input"}
757
- .value=${this._value.join(",")}
758
- ${y(this.inputRef)}
759
- />
760
- `;
761
- }
762
- renderSingleOrMultipleValues() {
763
- if (!this.multiple && this._hasTextInput) return m;
764
- const i = !this.multiple, t = this.renderValueTag(f(this.options, this._value[0])), e = this.tagPlacement === "outside", s = c`
765
- <ul role="list" class="pkt-combobox__tag-list">
766
- ${P(
767
- this._value,
768
- (l) => l,
769
- (l, a) => {
770
- const o = f(this.options, l), p = o == null ? void 0 : o.tagSkinColor;
771
- return c`
772
- <li
773
- role="listitem"
774
- @click=${e ? m : (d) => d.stopPropagation()}
775
- @mousedown=${e ? m : (d) => d.preventDefault()}
776
- >
777
- <pkt-tag
778
- skin=${p || "blue-dark"}
779
- ?closeTag=${!this.disabled}
780
- .buttonTabindex=${e ? void 0 : -1}
781
- @close=${() => this.handleTagRemove(l)}
782
- @keydown=${e ? m : (d) => this.handleTagKeydown(d, a)}
783
- >
784
- ${this.renderValueTag(o)}
785
- </pkt-tag>
786
- </li>
787
- `;
788
- }
789
- )}
790
- </ul>
791
- `;
792
- return i ? t : s;
793
- }
794
- renderValueTag(i) {
795
- if (!i) return "";
796
- switch (this.displayValueAs) {
797
- case "prefixAndValue":
798
- return c`<span class="pkt-combobox__value" data-focusfix=${this.id}
799
- >${i.prefix || ""} ${i.value}</span
800
- >`;
801
- case "value":
802
- return c`<span class="pkt-combobox__value" data-focusfix=${this.id}
803
- >${i.value}</span
804
- >`;
805
- case "label":
806
- default:
807
- return c`<span class="pkt-combobox__value" data-focusfix=${this.id}
808
- >${i.label || i.value}</span
809
- >`;
810
- }
811
- }
812
- };
813
- F = Y([
814
- M("pkt-combobox")
815
- ], F);
816
- export {
817
- F as P
818
- };