@oslokommune/punkt-elements 16.7.3 → 16.7.7

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 (248) 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 -5
  75. package/dist/pkt-backlink.cjs +1 -1
  76. package/dist/pkt-backlink.js +2 -5
  77. package/dist/pkt-breadcrumbs.cjs +1 -43
  78. package/dist/pkt-breadcrumbs.js +2 -81
  79. package/dist/pkt-button.cjs +1 -1
  80. package/dist/pkt-button.js +2 -5
  81. package/dist/pkt-calendar.cjs +1 -1
  82. package/dist/pkt-calendar.js +2 -5
  83. package/dist/pkt-card.cjs +1 -1
  84. package/dist/pkt-card.js +2 -5
  85. package/dist/pkt-checkbox.cjs +1 -1
  86. package/dist/pkt-checkbox.js +2 -5
  87. package/dist/pkt-combobox.cjs +1 -1
  88. package/dist/pkt-combobox.js +2 -5
  89. package/dist/pkt-consent.cjs +1 -1
  90. package/dist/pkt-consent.js +2 -5
  91. package/dist/pkt-datepicker.cjs +1 -1
  92. package/dist/pkt-datepicker.js +5 -9
  93. package/dist/pkt-header.cjs +1 -304
  94. package/dist/pkt-header.js +2 -861
  95. package/dist/pkt-heading.cjs +1 -1
  96. package/dist/pkt-heading.js +2 -5
  97. package/dist/pkt-helptext.cjs +1 -1
  98. package/dist/pkt-helptext.js +2 -5
  99. package/dist/pkt-icon.cjs +1 -1
  100. package/dist/pkt-icon.js +2 -5
  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 -5
  105. package/dist/pkt-link.cjs +1 -1
  106. package/dist/pkt-link.js +2 -5
  107. package/dist/pkt-linkcard.cjs +1 -1
  108. package/dist/pkt-linkcard.js +2 -5
  109. package/dist/pkt-listbox.cjs +1 -1
  110. package/dist/pkt-listbox.js +2 -5
  111. package/dist/pkt-loader.cjs +1 -1
  112. package/dist/pkt-loader.js +2 -5
  113. package/dist/pkt-messagebox.cjs +1 -1
  114. package/dist/pkt-messagebox.js +2 -5
  115. package/dist/pkt-modal.cjs +1 -1
  116. package/dist/pkt-modal.js +2 -5
  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 -5
  121. package/dist/pkt-radiobutton.cjs +1 -1
  122. package/dist/pkt-radiobutton.js +2 -5
  123. package/dist/pkt-select.cjs +1 -1
  124. package/dist/pkt-select.js +2 -5
  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 -5
  129. package/dist/pkt-textarea.cjs +1 -1
  130. package/dist/pkt-textarea.js +2 -5
  131. package/dist/pkt-textinput.cjs +1 -1
  132. package/dist/pkt-textinput.js +2 -5
  133. package/dist/pkt-timepicker.cjs +1 -191
  134. package/dist/pkt-timepicker.js +2 -560
  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/alert/alert.test.ts +1 -1
  159. package/src/components/alert/alert.ts +6 -6
  160. package/src/components/datepicker/datepicker-utils.test.ts +16 -23
  161. package/dist/accordionitem-_9AiCIvd.cjs +0 -34
  162. package/dist/accordionitem-dCfSrxh5.js +0 -140
  163. package/dist/alert-BtOk8yRH.cjs +0 -33
  164. package/dist/alert-DlY2_grU.js +0 -117
  165. package/dist/async-directive-CMzWMlZ5.js +0 -65
  166. package/dist/async-directive-DoMuclel.cjs +0 -5
  167. package/dist/backlink-Ce5Vldop.js +0 -49
  168. package/dist/backlink-y3dwjKPC.cjs +0 -13
  169. package/dist/booleanish-BKVonob4.cjs +0 -1
  170. package/dist/booleanish-C9R0tdXH.js +0 -11
  171. package/dist/button-B_TXwNzt.cjs +0 -27
  172. package/dist/button-BiY-wlKF.js +0 -139
  173. package/dist/calendar-B2pji2zn.cjs +0 -90
  174. package/dist/calendar-DhjQDC4C.js +0 -2140
  175. package/dist/card-BwMNB5Bb.cjs +0 -87
  176. package/dist/card-CGlmcMSR.js +0 -233
  177. package/dist/checkbox-BsJZYA26.js +0 -147
  178. package/dist/checkbox-CTY8f_qn.cjs +0 -31
  179. package/dist/class-map-CEnykyO_.js +0 -34
  180. package/dist/class-map-CsENJXf1.cjs +0 -5
  181. package/dist/classutils-BwNK82ZQ.cjs +0 -1
  182. package/dist/classutils-RQs1k6D9.js +0 -7
  183. package/dist/combobox-DSB5WOxg.js +0 -815
  184. package/dist/combobox-DbICIgKG.cjs +0 -135
  185. package/dist/consent-DkOQpbsg.cjs +0 -11
  186. package/dist/consent-SNWV_mMU.js +0 -175
  187. package/dist/datepicker-BEWl9iz3.cjs +0 -273
  188. package/dist/datepicker-euHyzXnb.js +0 -1170
  189. package/dist/dialog-polyfill.esm-CPKZe7AL.cjs +0 -1
  190. package/dist/dialog-polyfill.esm-CbjBMXAG.js +0 -395
  191. package/dist/directive-C7oCP5Bh.cjs +0 -5
  192. package/dist/directive-helpers-BP2WOx60.cjs +0 -5
  193. package/dist/directive-helpers-rm-28gIj.js +0 -38
  194. package/dist/directive-oAbCiebi.js +0 -27
  195. package/dist/element-CPpT3rFQ.js +0 -638
  196. package/dist/element-gR_VtSiD.cjs +0 -27
  197. package/dist/element-with-slot-Dqk6-TRR.js +0 -240
  198. package/dist/element-with-slot-ZX-up7jO.cjs +0 -1
  199. package/dist/heading-D2tVS6lS.js +0 -103
  200. package/dist/heading-DrzbgDb6.cjs +0 -1
  201. package/dist/helptext-BKtU4mas.js +0 -82
  202. package/dist/helptext-DcRC7wW2.cjs +0 -24
  203. package/dist/icon-CxQcIa5F.js +0 -105
  204. package/dist/icon-q81vqPK_.cjs +0 -9
  205. package/dist/if-defined-B0krMLad.js +0 -10
  206. package/dist/if-defined-BOW3ODSj.cjs +0 -5
  207. package/dist/input-element-8nLwuQS4.js +0 -837
  208. package/dist/input-element-DdVhUvva.cjs +0 -1
  209. package/dist/input-wrapper-Bs4CRNst.js +0 -181
  210. package/dist/input-wrapper-Bv9aqqVq.cjs +0 -54
  211. package/dist/input-wrapper-CDgenrYA.js +0 -6
  212. package/dist/input-wrapper-EoSAbU-U.cjs +0 -1
  213. package/dist/link-C0rl-86s.cjs +0 -7
  214. package/dist/link-Cdqgl60z.js +0 -55
  215. package/dist/linkcard-Dimu7Rlx.cjs +0 -13
  216. package/dist/linkcard-Lbq_UhjZ.js +0 -56
  217. package/dist/listbox-Bia4_tvN.js +0 -440
  218. package/dist/listbox-La2GZQei.cjs +0 -106
  219. package/dist/loader-D1ugDXGV.cjs +0 -16
  220. package/dist/loader-DyN6RGC5.js +0 -95
  221. package/dist/messagebox-BGMVm2t9.js +0 -71
  222. package/dist/messagebox-M0yIgCz9.cjs +0 -13
  223. package/dist/modal-CMO1RtIi.cjs +0 -36
  224. package/dist/modal-DjPQDE-Z.js +0 -156
  225. package/dist/pkt-options-controller-5LXbEzuk.cjs +0 -1
  226. package/dist/pkt-options-controller-B5YalfCb.js +0 -39
  227. package/dist/progressbar-BqlMzkM_.cjs +0 -21
  228. package/dist/progressbar-sbHDFC12.js +0 -162
  229. package/dist/radiobutton-5ZqVVtTT.cjs +0 -31
  230. package/dist/radiobutton-D8Ai8ETa.js +0 -113
  231. package/dist/ref-Bg_Swj5w.js +0 -42
  232. package/dist/ref-CL-Xk9Xm.cjs +0 -5
  233. package/dist/repeat-BD8TKgJb.js +0 -61
  234. package/dist/repeat-Cfq8CDlf.cjs +0 -5
  235. package/dist/select-De-n8on9.js +0 -230
  236. package/dist/select-dTWibR6_.cjs +0 -49
  237. package/dist/state-C_1EOo3D.js +0 -12
  238. package/dist/state-Dg-53wQ8.cjs +0 -5
  239. package/dist/tabitem-B9-jeV97.js +0 -334
  240. package/dist/tabitem-BnhzqfW3.cjs +0 -65
  241. package/dist/tag-CbwO8yvD.cjs +0 -27
  242. package/dist/tag-D4FI5t3y.js +0 -117
  243. package/dist/textarea-BmLaKzsc.cjs +0 -50
  244. package/dist/textarea-CMiSJaYL.js +0 -133
  245. package/dist/textinput-em9y4yrL.cjs +0 -70
  246. package/dist/textinput-r8udK0IX.js +0 -152
  247. package/dist/utils-DznhwRXm.js +0 -8
  248. package/dist/utils-byXsEz1u.cjs +0 -1
@@ -0,0 +1,984 @@
1
+ import { c as e, d as t, l as n, o as r, r as i, s as a } from "./element-cZ85T_aa.js";
2
+ import { t as o } from "./class-map-C8HuhNzZ.js";
3
+ import { n as s } from "./element-with-slot-4J2o3SeU.js";
4
+ import "./icon-Co72KtgF.js";
5
+ import { t as c } from "./if-defined-Cjj8qN-Z.js";
6
+ import { n as l, t as u } from "./ref-RS8Uv6uC.js";
7
+ import "./tag-VwykmuQR.js";
8
+ import { t as d } from "./repeat-Cepr3469.js";
9
+ import { a as f, c as p, i as m, o as h, r as g, s as _ } from "./listbox-DuBgTFvH.js";
10
+ import { t as v } from "./input-element-Bw1s6NlF.js";
11
+ import { t as y } from "./pkt-options-controller-CRrI6WMk.js";
12
+ import "./input-wrapper-YfTmpSSY.js";
13
+ //#region ../../shared-utils/combobox/input-utils.ts
14
+ var b = (e, t, n) => {
15
+ switch (e) {
16
+ case ",": return n ? "addValue" : null;
17
+ case "Enter": return "addValue";
18
+ case "Tab":
19
+ case "ArrowDown": return t ? null : "focusListbox";
20
+ case "Escape": return "closeOptions";
21
+ default: return null;
22
+ }
23
+ }, x = (e, t, n, r, i) => {
24
+ if (!e) return {
25
+ action: "none",
26
+ value: null
27
+ };
28
+ let a = m(n, e);
29
+ return !t.includes(e) && !a ? r ? {
30
+ action: "addUserValue",
31
+ value: e
32
+ } : i ? {
33
+ action: "none",
34
+ value: null
35
+ } : {
36
+ action: "removeValue",
37
+ value: t[0]
38
+ } : a && !t.includes(a.value) ? {
39
+ action: "selectOption",
40
+ value: a.value
41
+ } : {
42
+ action: "none",
43
+ value: null
44
+ };
45
+ }, S = (e, t, n, r, i) => e.trim().toLowerCase() ? {
46
+ ..._(e, t, n, r),
47
+ shouldRemoveValue: !1,
48
+ shouldResetInput: !1
49
+ } : {
50
+ addValueText: null,
51
+ userInfoMessage: "",
52
+ shouldRemoveValue: !i && !!t[0],
53
+ shouldResetInput: !0
54
+ }, C = (e, t, n) => {
55
+ let r = m(t, e);
56
+ return n === "label" && r?.label ? r.label : e;
57
+ }, w = {
58
+ markOptionSelected(e, t) {
59
+ if (t) {
60
+ for (let n of e) if (n.value === t) {
61
+ n.selected = !0;
62
+ break;
63
+ }
64
+ }
65
+ },
66
+ markOptionDeselected(e, t) {
67
+ if (t) {
68
+ for (let n of e) if (n.value === t) {
69
+ n.selected = !1;
70
+ break;
71
+ }
72
+ }
73
+ },
74
+ markAllSelected(e) {
75
+ for (let t of e) t.selected = !0;
76
+ },
77
+ markAllDeselected(e) {
78
+ for (let t of e) t.selected = !1;
79
+ },
80
+ removeUserAddedOptions(e) {
81
+ return e.filter((e) => !e.userAdded);
82
+ }
83
+ }, T = { parseOptionsFromSlot(e) {
84
+ let t = [];
85
+ return e.forEach((e) => {
86
+ if (!e.textContent && !e.getAttribute("value")) return;
87
+ let n = {
88
+ value: e.getAttribute("value") || e.textContent || "",
89
+ label: e.textContent || e.getAttribute("value") || ""
90
+ };
91
+ e.getAttribute("data-prefix") && (n.prefix = e.getAttribute("data-prefix") || void 0), e.getAttribute("tagskincolor") && (n.tagSkinColor = e.getAttribute("tagskincolor")), e.getAttribute("description") && (n.description = e.getAttribute("description") || void 0), n.fulltext = g(n), t.push(n);
92
+ }), t;
93
+ } }, E = {
94
+ syncOptionsWithValues(e, t) {
95
+ let n = [...t];
96
+ return e.forEach((e) => {
97
+ e.value && !e.label && (e.label = e.value), e.selected && !n.includes(e.value) && n.push(e.value), e.fulltext = g(e), e.selected = e.selected || n.includes(e.value);
98
+ }), {
99
+ options: e,
100
+ newValues: n
101
+ };
102
+ },
103
+ mergeWithUserAdded(e, t) {
104
+ return [...t.filter((e) => e?.userAdded && e.selected).filter((t) => !(Array.isArray(e) ? e : []).some((e) => e.value === t.value)), ...e];
105
+ }
106
+ }, D = {
107
+ name: "pkt-combobox",
108
+ react: "PktCombobox",
109
+ "css-class": "pkt-combobox",
110
+ isElement: !0,
111
+ isPureReact: !0,
112
+ props: {
113
+ name: {
114
+ type: "string",
115
+ name: "Navn",
116
+ description: "Navn som brukes i skjema ved innsending",
117
+ category: "tech"
118
+ },
119
+ id: {
120
+ type: "string",
121
+ name: "ID",
122
+ description: "Unik ID for feltet",
123
+ category: "tech"
124
+ },
125
+ label: {
126
+ type: "string",
127
+ name: "Etikett/label",
128
+ description: "Tekst som vises over feltet",
129
+ category: "contents"
130
+ },
131
+ placeholder: {
132
+ name: "Hint",
133
+ description: "Spesifiserer en kort hint som beskriver forventet verdi av feltet.",
134
+ type: "string",
135
+ category: "contents",
136
+ required: !1
137
+ },
138
+ multiple: {
139
+ type: "boolean",
140
+ name: "Flervalg",
141
+ default: !1,
142
+ description: "Mulighet for å velge flere valg",
143
+ category: "functionality"
144
+ },
145
+ tagPlacement: {
146
+ attribute: "tag-placement",
147
+ type: ["inside", "outside"],
148
+ name: "Plassering av tags i flervalg",
149
+ description: "Plassering av valgte verdier i feltet ved flervalg",
150
+ category: "functionality",
151
+ showIf: { multiple: !0 }
152
+ },
153
+ maxlength: {
154
+ type: "number",
155
+ name: "Maks antall i flervalg",
156
+ description: "Maks antall valg dersom flervalg er aktivert",
157
+ category: "functionality",
158
+ showIf: { multiple: !0 }
159
+ },
160
+ typeahead: {
161
+ type: "boolean",
162
+ name: "Typeahead",
163
+ default: !1,
164
+ description: "Mulighet for automatisk utfylling av feltet fra listen over valg",
165
+ category: "functionality"
166
+ },
167
+ includeSearch: {
168
+ attribute: "include-search",
169
+ type: "boolean",
170
+ name: "Inkluder søk",
171
+ description: "Mulighet for å søke etter valg inni dropdown",
172
+ category: "functionality"
173
+ },
174
+ allowUserInput: {
175
+ attribute: "allow-user-input",
176
+ type: "boolean",
177
+ name: "Brukervalgte verdier",
178
+ description: "Mulighet for å skrive inn egne verdier",
179
+ category: "functionality"
180
+ },
181
+ searchPlaceholder: {
182
+ attribute: "search-placeholder",
183
+ type: "string",
184
+ name: "Søke-plassholder",
185
+ description: "Plassholdertekst for søkefeltet i dropdown",
186
+ category: "contents",
187
+ showIf: { includeSearch: !0 }
188
+ },
189
+ displayValueAs: {
190
+ attribute: "display-value-as",
191
+ type: [
192
+ "label",
193
+ "value",
194
+ "prefixAndValue"
195
+ ],
196
+ name: "Visning av valgt verdi",
197
+ description: "Hvordan valgt verdi vises i feltet",
198
+ default: "label",
199
+ category: "ui"
200
+ },
201
+ value: {
202
+ name: "Verdi",
203
+ type: "string",
204
+ description: "Valgt verdi. Streng ved enkelt valg, array av strenger ved flervalg.",
205
+ category: "tech"
206
+ },
207
+ helptext: {
208
+ type: "string",
209
+ name: "Hjelpetekst",
210
+ description: "Hjelpetekst som vises over feltet",
211
+ category: "contents"
212
+ },
213
+ helptextDropdown: {
214
+ type: "string",
215
+ name: "Utvidet hjelpetekst",
216
+ description: "Hjelpetekst som vises i en lukket boks man kan åpne",
217
+ category: "contents"
218
+ },
219
+ helptextDropdownButton: {
220
+ type: "string",
221
+ name: "Knappetekst for hjelpetekst",
222
+ description: "Tekst som vises på knappen for å åpne/lukke utvidet hjelpetekst",
223
+ category: "contents",
224
+ default: "Les mer"
225
+ },
226
+ disabled: {
227
+ type: "boolean",
228
+ name: "Deaktivert",
229
+ description: "Feltet er deaktivert",
230
+ category: "tech"
231
+ },
232
+ hasError: {
233
+ type: "boolean",
234
+ name: "Feil",
235
+ description: "Feltet har en feil",
236
+ category: "ui"
237
+ },
238
+ errorMessage: {
239
+ type: "string",
240
+ name: "Feilmelding",
241
+ description: "Tekst som vises under feltet ved feil",
242
+ category: "contents"
243
+ },
244
+ required: {
245
+ type: "boolean",
246
+ name: "Påkrevd",
247
+ description: "Feltet må fylles ut",
248
+ category: "tech"
249
+ },
250
+ requiredTag: {
251
+ type: "boolean",
252
+ name: "Påkrevd-merking",
253
+ description: "Viser en merking som indikerer at feltet er påkrevd",
254
+ category: "ui"
255
+ },
256
+ requiredText: {
257
+ type: "string",
258
+ name: "Påkrevd-tekst",
259
+ description: "Tekst som vises i påkrevd-merkingen",
260
+ category: "contents"
261
+ },
262
+ optionalTag: {
263
+ type: "boolean",
264
+ name: "Valgfritt-merking",
265
+ description: "Viser en merking som indikerer at feltet er valgfritt",
266
+ category: "ui"
267
+ },
268
+ optionalText: {
269
+ type: "string",
270
+ name: "Valgfritt-tekst",
271
+ description: "Tekst som vises i valgfritt-merkingen",
272
+ category: "contents"
273
+ },
274
+ tagText: {
275
+ type: "string",
276
+ name: "Tag-tekst",
277
+ description: "Tekst som vises i en tag ved siden av label",
278
+ category: "ui"
279
+ },
280
+ fullwidth: {
281
+ type: "boolean",
282
+ name: "Full bredde",
283
+ description: "Skal feltet ta opp hele bredden?",
284
+ category: "ui"
285
+ },
286
+ defaultOptions: {
287
+ attribute: "default-options",
288
+ name: "Initielle valg (default options)",
289
+ description: "Liste over valg som kan velges, om options sendes inn som array med objekter (denne vil ikke modifiseres ved endring innad i komponenten)",
290
+ type: "array",
291
+ default: [],
292
+ previewDefault: [
293
+ {
294
+ value: "bfr",
295
+ label: "Frogner"
296
+ },
297
+ {
298
+ value: "bgo",
299
+ label: "Gamle Oslo"
300
+ },
301
+ {
302
+ value: "bgr",
303
+ label: "Grorud"
304
+ },
305
+ {
306
+ value: "bxx",
307
+ label: "Andre bydeler"
308
+ }
309
+ ],
310
+ items: {
311
+ type: "object",
312
+ properties: {
313
+ value: {
314
+ type: "string",
315
+ description: "Verdi som sendes ved valg"
316
+ },
317
+ label: {
318
+ type: "string",
319
+ description: "Tekst som vises for valget"
320
+ },
321
+ prefix: {
322
+ type: "string",
323
+ description: "Tekst som vises før valget"
324
+ },
325
+ description: {
326
+ type: "string",
327
+ description: "Beskrivelse av valget"
328
+ },
329
+ disabled: {
330
+ type: "boolean",
331
+ description: "Valget er deaktivert"
332
+ },
333
+ selected: {
334
+ type: "boolean",
335
+ description: "Valget er valgt"
336
+ },
337
+ tagSkinColor: {
338
+ type: [
339
+ "blue",
340
+ "blue-dark",
341
+ "blue-light",
342
+ "green",
343
+ "red",
344
+ "yellow",
345
+ "beige",
346
+ "gray",
347
+ "grey"
348
+ ],
349
+ description: "Farge på tag"
350
+ }
351
+ },
352
+ required: ["value"]
353
+ },
354
+ category: "contents"
355
+ },
356
+ options: {
357
+ name: "Valg",
358
+ type: "array",
359
+ description: "Liste over valg som kan velges, om options sendes inn som array med objekter",
360
+ default: [],
361
+ items: {
362
+ type: "object",
363
+ properties: {
364
+ value: {
365
+ type: "string",
366
+ description: "Verdi som sendes ved valg"
367
+ },
368
+ label: {
369
+ type: "string",
370
+ description: "Tekst som vises for valget"
371
+ },
372
+ prefix: {
373
+ type: "string",
374
+ description: "Tekst som vises før valget"
375
+ },
376
+ description: {
377
+ type: "string",
378
+ description: "Beskrivelse av valget"
379
+ },
380
+ disabled: {
381
+ type: "boolean",
382
+ description: "Valget er deaktivert"
383
+ },
384
+ selected: {
385
+ type: "boolean",
386
+ description: "Valget er valgt"
387
+ },
388
+ tagSkinColor: {
389
+ type: [
390
+ "blue",
391
+ "blue-dark",
392
+ "blue-light",
393
+ "green",
394
+ "red",
395
+ "yellow",
396
+ "beige",
397
+ "gray",
398
+ "grey"
399
+ ],
400
+ description: "Farge på tag"
401
+ }
402
+ },
403
+ required: ["value"]
404
+ },
405
+ category: "contents"
406
+ }
407
+ },
408
+ events: {
409
+ change: {
410
+ type: "Event",
411
+ description: "Returnerer valgt verdi som streng. Ved flervalg returneres kommaseparerte verdier."
412
+ },
413
+ "value-change": {
414
+ type: "CustomEvent",
415
+ description: "Returnerer valgt verdi. Ved enkeltvalg en streng, ved flervalg en <code>string[]</code>."
416
+ },
417
+ search: {
418
+ type: "CustomEvent",
419
+ description: "Returnerer søketeksten som streng i <code>event.detail</code> når brukeren skriver i søkefeltet"
420
+ },
421
+ toggleHelpText: {
422
+ type: "CustomEvent",
423
+ description: "Returnerer <code>event.detail { isOpen: true }</code> eller <code>event.detail { isOpen: false }</code> når hjelpeteksten åpnes eller lukkes"
424
+ }
425
+ }
426
+ }, O = class extends v {
427
+ constructor() {
428
+ 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 = D.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 = u(), this.triggerRef = u(), this.listboxRef = u(), this.optionsController = new y(this);
429
+ }
430
+ get _hasTextInput() {
431
+ return this.typeahead || this.allowUserInput;
432
+ }
433
+ get _selectionDescription() {
434
+ if (!(!this.multiple || this._value.length === 0)) return `${this._value.length} valgt`;
435
+ }
436
+ focusTrigger() {
437
+ this._hasTextInput ? this.inputRef.value?.focus() : this.triggerRef.value?.focus();
438
+ }
439
+ parseValue() {
440
+ 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] : [];
441
+ }
442
+ updateMaxReached() {
443
+ this._maxIsReached = p(this._value.length, this.maxlength);
444
+ }
445
+ syncValueAndDispatch(e) {
446
+ let t = this._value, n = this.multiple ? t.join(",") : t[0] || "";
447
+ if (n !== (Array.isArray(this.value) ? this.value.join(",") : String(this.value || "")) && (this._internalValueSync = !0, this.value = n), e?.join(",") !== t.join(",")) {
448
+ let e = this.multiple ? [...t] : t[0] || "";
449
+ this.onChange(e);
450
+ } else t.length === 0 && e && e.length > 0 && this.clearInputValue();
451
+ }
452
+ onChange(e) {
453
+ this.touched = !0, super.onChange(e);
454
+ }
455
+ valueChanged() {}
456
+ };
457
+ i([a({
458
+ type: String,
459
+ reflect: !0
460
+ })], O.prototype, "value", void 0), i([a({ type: Array })], O.prototype, "options", void 0), i([a({
461
+ type: Array,
462
+ attribute: "default-options"
463
+ })], O.prototype, "defaultOptions", void 0), i([a({
464
+ type: Boolean,
465
+ attribute: "allow-user-input"
466
+ })], O.prototype, "allowUserInput", void 0), i([a({ type: Boolean })], O.prototype, "typeahead", void 0), i([a({
467
+ type: Boolean,
468
+ attribute: "include-search"
469
+ })], O.prototype, "includeSearch", void 0), i([a({
470
+ type: String,
471
+ attribute: "search-placeholder"
472
+ })], O.prototype, "searchPlaceholder", void 0), i([a({ type: Boolean })], O.prototype, "multiple", void 0), i([a({ type: Number })], O.prototype, "maxlength", void 0), i([a({
473
+ type: String,
474
+ attribute: "display-value-as"
475
+ })], O.prototype, "displayValueAs", void 0), i([a({
476
+ type: String,
477
+ attribute: "tag-placement"
478
+ })], O.prototype, "tagPlacement", void 0), i([a({
479
+ type: Boolean,
480
+ attribute: "open"
481
+ })], O.prototype, "isOpen", void 0), i([r()], O.prototype, "_options", void 0), i([r()], O.prototype, "_value", void 0), i([r()], O.prototype, "_isOptionsOpen", void 0), i([r()], O.prototype, "_userInfoMessage", void 0), i([r()], O.prototype, "_addValueText", void 0), i([r()], O.prototype, "_maxIsReached", void 0), i([r()], O.prototype, "_search", void 0), i([r()], O.prototype, "_inputFocus", void 0);
482
+ //#endregion
483
+ //#region src/components/combobox/combobox-value.ts
484
+ var k = class extends O {
485
+ toggleValue(e) {
486
+ if (this.disabled) return;
487
+ this.touched = !0, this._userInfoMessage = "", this._addValueText = null;
488
+ let t = m(this.options, e)?.value || null, n = this._value.includes(e || t || ""), r = !!t, i = this._options.find((t) => t.value === e)?.disabled || !1, a = !e?.trim(), o = !this.multiple, s = this.multiple, c = p(this._value.length, this.maxlength), l = !1, u = !0, d = "", f = "";
489
+ i || (!r && this.allowUserInput && !a ? (this.addNewUserValue(e), d = "Ny verdi lagt til", l = s) : !r && !this.allowUserInput ? (o && this._value[0] && this.removeValue(this._value[0]), u = !1, l = !0, d = "Ingen treff i søket") : n ? (this.removeValue(t), l = !0, o && this._hasTextInput && this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = "")) : a && o ? (this.removeAllSelected(), l = !0) : o ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(t), l = !1) : s && !c ? (this.setSelected(t), l = !0) : s && c ? (d = "Maks antall valg nådd", u = !1, f = e) : (o && this.removeAllSelected(), d = "Ingen gyldig verdi valgt", u = !1, l = !0, f = e), this._isOptionsOpen = l, l || (o && this._hasTextInput && (this._suppressNextOpen = !0), window.setTimeout(() => {
490
+ this.focusTrigger();
491
+ }, 0)), this._userInfoMessage = d, this._search = f || "", this.resetComboboxInput(u), s && this.updateMaxReached());
492
+ }
493
+ setSelected(e) {
494
+ if (!this._value.includes(e)) {
495
+ if (this.multiple && p(this._value.length, this.maxlength)) {
496
+ this._userInfoMessage = "Maks antall valg nådd";
497
+ return;
498
+ }
499
+ !this.multiple && this.removeAllSelected(), this._value = e ? [...this._value, e] : this._value, w.markOptionSelected(this._options, e), this.resetComboboxInput(!0);
500
+ }
501
+ }
502
+ removeSelected(e) {
503
+ if (!e) return;
504
+ this._value = this._value.filter((t) => t !== e);
505
+ let t = m(this.options, e);
506
+ t && (w.markOptionDeselected(this.options, e), t.userAdded ? (this._options = [...this._options.filter((t) => t.value !== e)], this.options = [...this.options.filter((t) => t.value !== e)]) : this._options.some((t) => t.value === e) || (this._options = [...this._options, t]));
507
+ }
508
+ addAllOptions() {
509
+ if (this.multiple) {
510
+ if (this.maxlength && this._options.length > this.maxlength) {
511
+ this._userInfoMessage = "For mange valgt";
512
+ return;
513
+ }
514
+ this._value = this._options.map((e) => e.value), w.markAllSelected(this._options), this.requestUpdate();
515
+ }
516
+ }
517
+ removeAllSelected() {
518
+ this._value = [], w.markAllDeselected(this._options), this._options = w.removeUserAddedOptions(this._options), this.requestUpdate();
519
+ }
520
+ addValue() {
521
+ let e = this.inputRef.value?.value.trim() || "";
522
+ if (this._search = e, e && this._value.includes(e)) {
523
+ this.resetComboboxInput(!0), this._userInfoMessage = "Verdien er allerede valgt";
524
+ return;
525
+ }
526
+ this.toggleValue(e);
527
+ }
528
+ removeValue(e) {
529
+ this._value = this.multiple ? this._value.filter((t) => t !== e) : [], this.removeSelected(e);
530
+ }
531
+ addNewUserValue(e) {
532
+ if (!e || e.trim() === "") return;
533
+ if (!this.multiple) this._value[0] && this.removeSelected(this._value[0]), this._value = [e];
534
+ else if (!m(this.options, e)) {
535
+ if (p(this._value.length, this.maxlength)) return;
536
+ this._value = [...this._value, e];
537
+ }
538
+ let t = {
539
+ value: e,
540
+ label: e,
541
+ userAdded: !0,
542
+ selected: !0
543
+ };
544
+ this.options = [t, ...this.options], this._options = [t, ...this._options], this.resetComboboxInput(!0), this.multiple || (this._isOptionsOpen = !1, this._hasTextInput && (this._suppressNextOpen = !0), window.setTimeout(() => {
545
+ this.focusTrigger();
546
+ }, 0)), this.requestUpdate();
547
+ }
548
+ resetComboboxInput(e = !0) {
549
+ this._addValueText = null, this.inputRef.value && this.inputRef.value.type !== "hidden" && e && (this._search = "", this.multiple ? this.inputRef.value.value = "" : (this.inputRef.value.value = this._value[0] ? C(this._value[0], this.options, this.displayValueAs) : "", this._userInfoMessage = "")), this._options = [...this.options];
550
+ }
551
+ removeLastValue(e) {
552
+ if (this._value.length === 0) return;
553
+ e.preventDefault();
554
+ let t = this._value[this._value.length - 1];
555
+ t && this.removeSelected(t), this.updateMaxReached();
556
+ }
557
+ }, A = class extends k {
558
+ handleInput(e) {
559
+ if (e.stopPropagation(), e.stopImmediatePropagation(), this.disabled) return;
560
+ this.touched = !0;
561
+ let t = e.target;
562
+ if (this._search = t.value, this.checkForMatches(), this.typeahead) if (this._search) {
563
+ let { filtered: n, suggestion: r } = h(this.options, this._search);
564
+ this._options = n, e.inputType !== "deleteContentBackward" && r?.label && this.inputRef.value && this.inputRef.value.type !== "hidden" && (t.value = r.label, window.setTimeout(() => t.setSelectionRange(this._search.length, t.value.length), 0), t.selectionDirection = "backward");
565
+ } else this._options = [...this.options];
566
+ }
567
+ handleFocus() {
568
+ if (!this.disabled) {
569
+ if (this._suppressNextOpen) {
570
+ this._suppressNextOpen = !1, this._inputFocus = !0, this.requestUpdate();
571
+ return;
572
+ }
573
+ !this.multiple && this._value[0] && this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = C(this._value[0], this.options, this.displayValueAs)), this._inputFocus = !0, this._search = "", this._options = [...this.options], this._isOptionsOpen = !0, this.onFocus(), this.requestUpdate();
574
+ }
575
+ }
576
+ handleFocusOut(e) {
577
+ if (this.disabled || !this._isOptionsOpen) return;
578
+ let t = e.relatedTarget;
579
+ t?.closest("pkt-combobox")?.id === this.id || e.target?.getAttribute("data-focusfix") === this.id || t === this.inputRef.value || t === this.triggerRef.value || this.closeAndProcessInput();
580
+ }
581
+ closeAndProcessInput() {
582
+ if (this._inputFocus = !1, this._addValueText = null, this._userInfoMessage = "", this._search = "", this.inputRef.value && this.inputRef.value.type !== "hidden") {
583
+ let e = this.inputRef.value.value;
584
+ if (!this.multiple) if (!e) this._value[0] && this.removeSelected(this._value[0]);
585
+ else {
586
+ let t = m(this.options, e);
587
+ t && t.value !== this._value[0] ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(t.value)) : !t && this.allowUserInput && (this._value[0] && this.removeSelected(this._value[0]), this.addNewUserValue(e));
588
+ }
589
+ else if (e !== "") {
590
+ let { action: t, value: n } = x(e, this._value, this.options, this.allowUserInput, this.multiple);
591
+ switch (t) {
592
+ case "addUserValue":
593
+ this.addNewUserValue(n);
594
+ break;
595
+ case "selectOption":
596
+ this.setSelected(n);
597
+ break;
598
+ case "removeValue":
599
+ this.removeValue(n);
600
+ break;
601
+ }
602
+ }
603
+ !this.multiple && this._value[0] ? this.inputRef.value.value = C(this._value[0], this.options, this.displayValueAs) : this.inputRef.value.value = "";
604
+ }
605
+ this._isOptionsOpen = !1, this.onBlur();
606
+ }
607
+ handleBlur() {
608
+ this._inputFocus = !1, this.onBlur();
609
+ }
610
+ handleInputClick(e) {
611
+ if (this.disabled) {
612
+ e.preventDefault(), e.stopImmediatePropagation();
613
+ return;
614
+ }
615
+ this._hasTextInput ? (this.inputRef.value?.focus(), this.requestUpdate()) : (e.stopImmediatePropagation(), e.preventDefault(), this._isOptionsOpen = !this._isOptionsOpen, this._isOptionsOpen && this.listboxRef.value?.focusFirstOrSelectedOption());
616
+ }
617
+ handlePlaceholderClick(e) {
618
+ this.disabled || (e.stopPropagation(), this._hasTextInput && this.inputRef.value ? (this.inputRef.value.focus(), this._inputFocus = !0, this.requestUpdate()) : (this._isOptionsOpen = !this._isOptionsOpen, this.requestUpdate()));
619
+ }
620
+ handleSelectOnlyKeydown(e) {
621
+ if (!this.disabled) switch (e.key) {
622
+ case "Enter":
623
+ case " ":
624
+ case "ArrowDown":
625
+ case "ArrowUp":
626
+ e.preventDefault(), this._isOptionsOpen ? this._isOptionsOpen = !1 : (this._isOptionsOpen = !0, this.listboxRef.value?.focusFirstOrSelectedOption());
627
+ break;
628
+ case "Escape":
629
+ this._isOptionsOpen &&= (e.preventDefault(), !1);
630
+ break;
631
+ case "Home":
632
+ case "End":
633
+ e.preventDefault(), this._isOptionsOpen ||= !0, this.listboxRef.value?.focusFirstOrSelectedOption();
634
+ break;
635
+ case "ArrowLeft":
636
+ this.multiple && this._value.length > 0 && (e.preventDefault(), this.focusTag(this._value.length - 1));
637
+ break;
638
+ case "Backspace":
639
+ case "Delete":
640
+ this.multiple && this._value.length > 0 && (e.preventDefault(), this.removeSelected(this._value[this._value.length - 1]));
641
+ break;
642
+ }
643
+ }
644
+ handleOptionToggled(e) {
645
+ this.toggleValue(e.detail);
646
+ }
647
+ handleSearch(e) {
648
+ e.stopPropagation(), this._search = e.detail.toLowerCase(), this.checkForMatches();
649
+ }
650
+ handleInputKeydown(e) {
651
+ if (e.key === "Backspace") {
652
+ let t = !this.inputRef.value?.value;
653
+ !this._search && t && this.multiple && this._value.length > 0 && this.removeLastValue(e);
654
+ return;
655
+ }
656
+ if (e.key === "ArrowLeft" && this.multiple && this._value.length > 0) {
657
+ let t = this.inputRef.value;
658
+ if (t && t.selectionStart === 0 && !t.value) {
659
+ e.preventDefault(), this.focusTag(this._value.length - 1);
660
+ return;
661
+ }
662
+ }
663
+ let t = b(e.key, e.shiftKey, this.multiple);
664
+ if (t && !(e.key === "Tab" && !this._isOptionsOpen)) {
665
+ if (t === "focusListbox" && e.key === "Tab" && !this.listboxRef.value?.querySelector("[role=\"option\"]:not([data-disabled]), [data-type=\"new-option\"]")) {
666
+ this.closeAndProcessInput();
667
+ return;
668
+ }
669
+ switch (e.preventDefault(), t) {
670
+ case "addValue":
671
+ this.addValue();
672
+ break;
673
+ case "focusListbox":
674
+ this.listboxRef.value?.focusFirstOrSelectedOption();
675
+ break;
676
+ case "closeOptions":
677
+ this._isOptionsOpen = !1;
678
+ break;
679
+ }
680
+ }
681
+ }
682
+ handleTagRemove(e) {
683
+ this.removeSelected(e), this._hasTextInput && this.inputRef.value && (this._inputFocus = !0, this.inputRef.value.focus(), this.requestUpdate());
684
+ }
685
+ getInsideTags() {
686
+ return Array.from(this.querySelectorAll(".pkt-combobox__input .pkt-combobox__tag-list pkt-tag"));
687
+ }
688
+ focusTag(e) {
689
+ let t = this.getInsideTags();
690
+ t.forEach((t, n) => {
691
+ t.buttonTabindex = n === e ? 0 : -1;
692
+ }), (t[e]?.querySelector("button"))?.focus();
693
+ }
694
+ resetTagTabindices() {
695
+ this.getInsideTags().forEach((e) => {
696
+ e.buttonTabindex = -1;
697
+ });
698
+ }
699
+ handleTagKeydown(e, t) {
700
+ e.stopPropagation();
701
+ let n = () => {
702
+ this.resetTagTabindices(), this._hasTextInput && this.inputRef.value ? this.inputRef.value.focus() : this.triggerRef.value?.focus();
703
+ };
704
+ switch (e.key) {
705
+ case "ArrowLeft":
706
+ e.preventDefault(), t > 0 && this.focusTag(t - 1);
707
+ break;
708
+ case "ArrowRight":
709
+ e.preventDefault(), t < this._value.length - 1 ? this.focusTag(t + 1) : n();
710
+ break;
711
+ case "Backspace":
712
+ case "Delete":
713
+ e.preventDefault();
714
+ {
715
+ let e = this._value[t], r = t >= this._value.length - 1 ? t - 1 : t;
716
+ this.removeSelected(e), r >= 0 ? (this.requestUpdate(), this.updateComplete.then(() => this.focusTag(r))) : n();
717
+ }
718
+ break;
719
+ case "Tab":
720
+ this.resetTagTabindices();
721
+ break;
722
+ case "Escape":
723
+ e.preventDefault(), n();
724
+ break;
725
+ }
726
+ }
727
+ checkForMatches() {
728
+ let e = S(this.inputRef.value?.value || this._search || "", this._value, this.options, this.allowUserInput, this.multiple);
729
+ if (e.shouldRemoveValue && this.removeValue(this._value[0]), e.shouldResetInput) {
730
+ this.resetComboboxInput(!1);
731
+ return;
732
+ }
733
+ this._addValueText = e.addValueText, this._userInfoMessage = e.userInfoMessage;
734
+ }
735
+ }, j = class extends A {
736
+ constructor(...e) {
737
+ super(...e), this.handleBodyClick = (e) => {
738
+ this._isOptionsOpen && !this.contains(e.target) && this.closeAndProcessInput();
739
+ };
740
+ }
741
+ connectedCallback() {
742
+ if (super.connectedCallback(), document?.body.addEventListener("click", this.handleBodyClick), this._options = [], this.defaultOptions && this.defaultOptions.length && (this.options = [...this.options?.filter((e) => e.userAdded) || [], ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options = Array.isArray(this.options) ? [...this.options] : []), this.optionsController?.nodes && this.optionsController.nodes.length) {
743
+ let e = T.parseOptionsFromSlot(this.optionsController.nodes);
744
+ e.length && (this.options = [...e], this._options = [...e], this._optionsFromSlot = !0, this._lastSlotGeneration = this.optionsController.generation);
745
+ }
746
+ }
747
+ willUpdate(e) {
748
+ if (this._optionsFromSlot && this.optionsController) {
749
+ let e = this.optionsController.generation;
750
+ if (e !== this._lastSlotGeneration) {
751
+ this._lastSlotGeneration = e;
752
+ let t = T.parseOptionsFromSlot(this.optionsController.nodes);
753
+ this.options = [...this._options.filter((e) => e.userAdded), ...t];
754
+ }
755
+ }
756
+ super.willUpdate(e);
757
+ }
758
+ disconnectedCallback() {
759
+ super.disconnectedCallback(), document?.body.removeEventListener("click", this.handleBodyClick);
760
+ }
761
+ firstUpdated(e) {
762
+ this.defaultValue !== null && !this.value && (this.value = this.defaultValue), super.firstUpdated(e);
763
+ }
764
+ updated(e) {
765
+ e.has("isOpen") && (this._isOptionsOpen = this.isOpen);
766
+ let t = e.has("value"), n = e.has("_value");
767
+ if (t && this._internalValueSync) this._internalValueSync = !1, n && this.syncValueAndDispatch(e.get("_value"));
768
+ else if (t) {
769
+ let e = [...this._value], t = this.parseValue();
770
+ t.join(",") !== this._value.join(",") && (this._value = t), this.updateMaxReached(), this.syncValueAndDispatch(e);
771
+ } else n && this.syncValueAndDispatch(e.get("_value"));
772
+ if (e.has("defaultOptions") && this.defaultOptions.length && (this.options = [...(Array.isArray(this.options) ? this.options : []).filter((e) => e.userAdded) || [], ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options = Array.isArray(this.options) ? [...this.options] : []), e.has("options")) {
773
+ let t = e.get("options") || this._options || [], n = E.mergeWithUserAdded(this.options, t);
774
+ this._options = n, n.length > this.options.length && (this.options = n);
775
+ let r = E.syncOptionsWithValues(this._options, this._value);
776
+ if (this._options = r.options, r.newValues.length > this._value.length) {
777
+ let e = [...this._value];
778
+ this._value = r.newValues, this.syncValueAndDispatch(e);
779
+ }
780
+ }
781
+ if (e.has("_search") && this.dispatchEvent(new CustomEvent("search", {
782
+ detail: this._search,
783
+ bubbles: !1
784
+ })), !this._isOptionsOpen && !this.multiple && this._hasTextInput && this.inputRef.value && this.inputRef.value.type !== "hidden") {
785
+ let e = this._value[0] ? C(this._value[0], this.options, this.displayValueAs) : "";
786
+ this.inputRef.value.value !== e && (this.inputRef.value.value = e);
787
+ }
788
+ super.updated(e);
789
+ }
790
+ formResetCallback() {
791
+ this.touched = !1, this.value = this.defaultValue || (this.multiple, ""), this._value = this.parseValue(), this._options = this._options.filter((e) => !e.userAdded).map((e) => ({
792
+ ...e,
793
+ selected: this._value.includes(e.value)
794
+ })), this.options = this.options.filter((e) => !e.userAdded).map((e) => ({
795
+ ...e,
796
+ selected: this._value.includes(e.value)
797
+ })), 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();
798
+ }
799
+ attributeChangedCallback(e, t, n) {
800
+ if (e === "options") {
801
+ this._options = Array.isArray(this.options) ? [...this.options] : [];
802
+ let e = E.syncOptionsWithValues(this._options, this._value);
803
+ this._options = e.options, e.newValues.length > this._value.length && (this._value = e.newValues), this._search = "";
804
+ }
805
+ super.attributeChangedCallback(e, t, n);
806
+ }
807
+ render() {
808
+ return t`
809
+ <pkt-input-wrapper
810
+ .label=${this.label}
811
+ .helptext=${this.helptext}
812
+ .helptextDropdown=${c(this.helptextDropdown)}
813
+ .helptextDropdownButton=${c(this.helptextDropdownButton)}
814
+ ?fullwidth=${this.fullwidth}
815
+ ?hasError=${this.hasError}
816
+ ?inline=${this.inline}
817
+ ?disabled=${this.disabled}
818
+ .errorMessage=${this.errorMessage}
819
+ ?optionalTag=${this.optionalTag}
820
+ .optionalText=${this.optionalText}
821
+ ?requiredTag=${this.requiredTag}
822
+ .requiredText=${this.requiredText}
823
+ .tagText=${this.tagText}
824
+ useWrapper=${this.useWrapper}
825
+ .forId=${this._hasTextInput ? this.id + "-input" : this.id + "-combobox"}
826
+ ?hasFieldset=${!this._hasTextInput}
827
+ class="pkt-combobox__wrapper"
828
+ @labelClick=${this.handleInputClick}
829
+ >
830
+ <div class="pkt-contents" slot="helptext">${s(this, "helptext")}</div>
831
+ <div class="pkt-combobox" @focusout=${this.handleFocusOut}>
832
+ <div
833
+ class=${o({
834
+ "pkt-combobox__input": !0,
835
+ "pkt-combobox__input--fullwidth": this.fullwidth,
836
+ "pkt-combobox__input--open": this._isOptionsOpen,
837
+ "pkt-combobox__input--error": this.hasError,
838
+ "pkt-combobox__input--disabled": this.disabled
839
+ })}
840
+ id=${c(this._hasTextInput ? void 0 : `${this.id}-combobox`)}
841
+ role=${c(this._hasTextInput ? void 0 : "combobox")}
842
+ aria-expanded=${c(this._hasTextInput ? void 0 : this._isOptionsOpen ? "true" : "false")}
843
+ aria-controls=${c(this._hasTextInput ? void 0 : `${this.id}-listbox`)}
844
+ aria-haspopup=${c(this._hasTextInput ? void 0 : "listbox")}
845
+ aria-labelledby=${c(this._hasTextInput ? void 0 : `${this.id}-combobox-label`)}
846
+ aria-activedescendant=${c(!this._hasTextInput && this._value[0] && m(this.options, this._value[0]) ? `${this.id}-listbox-${f(this._options, this._value[0])}` : void 0)}
847
+ aria-description=${c(this._selectionDescription || void 0)}
848
+ tabindex=${this._hasTextInput || this.disabled ? "-1" : "0"}
849
+ @click=${this.handleInputClick}
850
+ @keydown=${this._hasTextInput ? n : this.handleSelectOnlyKeydown}
851
+ ${l(this.triggerRef)}
852
+ >
853
+ ${!this._hasTextInput && this.placeholder && (!this._value.length || this.multiple && this.tagPlacement == "outside") && !this._inputFocus ? t`<span class="pkt-combobox__placeholder" @click=${this.handlePlaceholderClick}
854
+ >${this.placeholder}</span
855
+ >` : this.tagPlacement === "outside" ? n : this.renderSingleOrMultipleValues()}
856
+ ${this.renderInputField()}
857
+ <pkt-icon
858
+ class=${o({
859
+ "pkt-combobox__arrow-icon": !0,
860
+ "pkt-combobox__arrow-icon--open": this._isOptionsOpen
861
+ })}
862
+ name="chevron-thin-down"
863
+ aria-hidden="true"
864
+ ></pkt-icon>
865
+ </div>
866
+
867
+ <pkt-listbox
868
+ id="${this.id}-listbox"
869
+ .options=${this._options}
870
+ .isOpen=${this._isOptionsOpen}
871
+ .searchPlaceholder=${this.searchPlaceholder}
872
+ .label="Liste: ${this.label || ""}"
873
+ ?include-search=${this.includeSearch}
874
+ ?is-multi-select=${this.multiple}
875
+ ?allow-user-input=${this.allowUserInput && !this._maxIsReached}
876
+ ?max-is-reached=${this._maxIsReached}
877
+ .customUserInput=${c(this._addValueText)}
878
+ .userMessage=${this._userInfoMessage}
879
+ @search=${this.handleSearch}
880
+ @option-toggle=${this.handleOptionToggled}
881
+ @select-all=${this.addAllOptions}
882
+ @close-options=${() => this._isOptionsOpen = !1}
883
+ @tab-close=${() => this.closeAndProcessInput()}
884
+ .searchValue=${this._search || null}
885
+ .maxLength=${this.maxlength || 0}
886
+ ${l(this.listboxRef)}
887
+ ></pkt-listbox>
888
+ </div>
889
+
890
+ ${this.tagPlacement === "outside" && this.multiple ? t`<div class="pkt-combobox__tags-outside">
891
+ ${this.renderSingleOrMultipleValues()}
892
+ </div>` : n}
893
+ </pkt-input-wrapper>
894
+ `;
895
+ }
896
+ renderInputField() {
897
+ return this.typeahead || this.allowUserInput ? t`
898
+ <div class="pkt-combobox__input-div combobox__input">
899
+ <input
900
+ type="text"
901
+ id="${this.id}-input"
902
+ name=${(this.name || this.id) + "-input"}
903
+ placeholder=${c(!this._value.length || this.multiple && this.tagPlacement === "outside" ? this.placeholder : void 0)}
904
+ @input=${this.handleInput}
905
+ @change=${(e) => {
906
+ e.stopPropagation(), e.stopImmediatePropagation();
907
+ }}
908
+ @keydown=${this.handleInputKeydown}
909
+ @focus=${this.handleFocus}
910
+ @blur=${this.handleBlur}
911
+ autocomplete="off"
912
+ role="combobox"
913
+ aria-expanded=${this._isOptionsOpen ? "true" : "false"}
914
+ aria-label=${c(this.label)}
915
+ aria-autocomplete=${this.typeahead ? "both" : this.allowUserInput ? "list" : "none"}
916
+ aria-controls="${this.id}-listbox"
917
+ aria-activedescendant=${c(this._value[0] && m(this.options, this._value[0]) ? `${this.id}-listbox-${f(this._options, this._value[0])}` : void 0)}
918
+ aria-description=${c(this._selectionDescription || void 0)}
919
+ ${l(this.inputRef)}
920
+ />
921
+ </div>
922
+ ` : t`
923
+ <input
924
+ type="hidden"
925
+ id="${this.id}-input"
926
+ name=${(this.name || this.id) + "-input"}
927
+ .value=${this._value.join(",")}
928
+ ${l(this.inputRef)}
929
+ />
930
+ `;
931
+ }
932
+ renderSingleOrMultipleValues() {
933
+ if (!this.multiple && this._hasTextInput) return n;
934
+ let e = !this.multiple, r = this.renderValueTag(m(this.options, this._value[0])), i = this.tagPlacement === "outside", a = t`
935
+ <ul role="list" class="pkt-combobox__tag-list">
936
+ ${d(this._value, (e) => e, (e, r) => {
937
+ let a = m(this.options, e), o = a?.tagSkinColor;
938
+ return t`
939
+ <li
940
+ role="listitem"
941
+ @click=${i ? n : (e) => e.stopPropagation()}
942
+ @mousedown=${i ? n : (e) => e.preventDefault()}
943
+ >
944
+ <pkt-tag
945
+ skin=${o || "blue-dark"}
946
+ ?closeTag=${!this.disabled}
947
+ .buttonTabindex=${i ? void 0 : -1}
948
+ @close=${() => this.handleTagRemove(e)}
949
+ @keydown=${i ? n : (e) => this.handleTagKeydown(e, r)}
950
+ >
951
+ ${this.renderValueTag(a)}
952
+ </pkt-tag>
953
+ </li>
954
+ `;
955
+ })}
956
+ </ul>
957
+ `;
958
+ return e ? r : a;
959
+ }
960
+ renderValueTag(e) {
961
+ if (!e) return "";
962
+ switch (this.displayValueAs) {
963
+ case "prefixAndValue": return t`<span class="pkt-combobox__value" data-focusfix=${this.id}
964
+ >${e.prefix || ""} ${e.value}</span
965
+ >`;
966
+ case "value": return t`<span class="pkt-combobox__value" data-focusfix=${this.id}
967
+ >${e.value}</span
968
+ >`;
969
+ default: return t`<span class="pkt-combobox__value" data-focusfix=${this.id}
970
+ >${e.label || e.value}</span
971
+ >`;
972
+ }
973
+ }
974
+ };
975
+ try {
976
+ e("pkt-combobox")(j);
977
+ } catch {
978
+ console.warn("Forsøker å definere <pkt-combobox>, men den er allerede definert");
979
+ }
980
+ //#endregion
981
+ //#region src/components/combobox/index.ts
982
+ var M = j;
983
+ //#endregion
984
+ export { j as n, M as t };