@oslokommune/punkt-elements 16.7.3 → 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 (248) hide show
  1. package/CHANGELOG.md +18 -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
@@ -1,815 +0,0 @@
1
- import { n as p, t as M, A as b, b as d } from "./element-CPpT3rFQ.js";
2
- import { o as r } from "./if-defined-B0krMLad.js";
3
- import { e as A, n as O } from "./ref-Bg_Swj5w.js";
4
- import { e as w } from "./class-map-CEnykyO_.js";
5
- import { c as D } from "./repeat-BD8TKgJb.js";
6
- import { f as c, g as P, b as F, i as k, a as B, c as R } from "./listbox-Bia4_tvN.js";
7
- import { s as E } from "./element-with-slot-Dqk6-TRR.js";
8
- import { r as m } from "./state-C_1EOo3D.js";
9
- import { P as q } from "./input-element-8nLwuQS4.js";
10
- import { P as N } from "./pkt-options-controller-B5YalfCb.js";
11
- import "./input-wrapper-Bs4CRNst.js";
12
- import "./icon-CxQcIa5F.js";
13
- import "./tag-D4FI5t3y.js";
14
- const L = (a, t, e) => {
15
- switch (a) {
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
- }, j = (a, t, e, s, i) => {
29
- if (!a) return { action: "none", value: null };
30
- const l = c(e, a);
31
- return !t.includes(a) && !l ? s ? { action: "addUserValue", value: a } : i ? { action: "none", value: null } : { action: "removeValue", value: t[0] } : l && !t.includes(l.value) ? { action: "selectOption", value: l.value } : { action: "none", value: null };
32
- }, K = (a, t, e, s, i) => a.trim().toLowerCase() ? {
33
- ...P(a, t, e, s),
34
- shouldRemoveValue: !1,
35
- shouldResetInput: !1
36
- } : {
37
- addValueText: null,
38
- userInfoMessage: "",
39
- shouldRemoveValue: !i && !!t[0],
40
- shouldResetInput: !0
41
- }, $ = (a, t, e) => {
42
- const s = c(t, a);
43
- return e === "label" && (s != null && s.label) ? s.label : a;
44
- }, x = {
45
- markOptionSelected(a, t) {
46
- if (t) {
47
- for (const e of a)
48
- if (e.value === t) {
49
- e.selected = !0;
50
- break;
51
- }
52
- }
53
- },
54
- markOptionDeselected(a, t) {
55
- if (t) {
56
- for (const e of a)
57
- if (e.value === t) {
58
- e.selected = !1;
59
- break;
60
- }
61
- }
62
- },
63
- markAllSelected(a) {
64
- for (const t of a)
65
- t.selected = !0;
66
- },
67
- markAllDeselected(a) {
68
- for (const t of a)
69
- t.selected = !1;
70
- },
71
- removeUserAddedOptions(a) {
72
- return a.filter((t) => !t.userAdded);
73
- }
74
- }, C = {
75
- parseOptionsFromSlot(a) {
76
- const t = [];
77
- return a.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 = F(s), t.push(s);
84
- }), t;
85
- }
86
- }, V = {
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(a, t) {
95
- const e = [...t];
96
- return a.forEach((s) => {
97
- s.value && !s.label && (s.label = s.value), s.selected && !e.includes(s.value) && e.push(s.value), s.fulltext = F(s), s.selected = s.selected || e.includes(s.value);
98
- }), { options: a, newValues: e };
99
- },
100
- /**
101
- * Merges user-added options with new options, preserving user additions.
102
- */
103
- mergeWithUserAdded(a, t) {
104
- return [...t.filter((i) => (i == null ? void 0 : i.userAdded) && i.selected).filter(
105
- (i) => !(Array.isArray(a) ? a : []).some((l) => l.value === i.value)
106
- ), ...a];
107
- }
108
- }, W = { displayValueAs: { default: "label" } }, G = {
109
- props: W
110
- };
111
- var J = Object.defineProperty, h = (a, t, e, s) => {
112
- for (var i = void 0, l = a.length - 1, o; l >= 0; l--)
113
- (o = a[l]) && (i = o(t, e, i) || i);
114
- return i && J(t, e, i), i;
115
- };
116
- class n extends q {
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 = G.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 = A(), this.triggerRef = A(), this.listboxRef = A(), this.optionsController = new N(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 = k(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] || "", i = Array.isArray(this.value) ? this.value.join(",") : String(this.value || "");
154
- if (s !== i && (this._internalValueSync = !0, this.value = s), (t == null ? void 0 : t.join(",")) !== e.join(",")) {
155
- const l = this.multiple ? [...e] : e[0] || "";
156
- this.onChange(l);
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
- p({ type: String, reflect: !0 })
179
- ], n.prototype, "value");
180
- h([
181
- p({ type: Array })
182
- ], n.prototype, "options");
183
- h([
184
- p({ type: Array, attribute: "default-options" })
185
- ], n.prototype, "defaultOptions");
186
- h([
187
- p({ type: Boolean, attribute: "allow-user-input" })
188
- ], n.prototype, "allowUserInput");
189
- h([
190
- p({ type: Boolean })
191
- ], n.prototype, "typeahead");
192
- h([
193
- p({ type: Boolean, attribute: "include-search" })
194
- ], n.prototype, "includeSearch");
195
- h([
196
- p({ type: String, attribute: "search-placeholder" })
197
- ], n.prototype, "searchPlaceholder");
198
- h([
199
- p({ type: Boolean })
200
- ], n.prototype, "multiple");
201
- h([
202
- p({ type: Number })
203
- ], n.prototype, "maxlength");
204
- h([
205
- p({ type: String, attribute: "display-value-as" })
206
- ], n.prototype, "displayValueAs");
207
- h([
208
- p({ type: String, attribute: "tag-placement" })
209
- ], n.prototype, "tagPlacement");
210
- h([
211
- p({ type: Boolean, attribute: "open" })
212
- ], n.prototype, "isOpen");
213
- h([
214
- m()
215
- ], n.prototype, "_options");
216
- h([
217
- m()
218
- ], n.prototype, "_value");
219
- h([
220
- m()
221
- ], n.prototype, "_isOptionsOpen");
222
- h([
223
- m()
224
- ], n.prototype, "_userInfoMessage");
225
- h([
226
- m()
227
- ], n.prototype, "_addValueText");
228
- h([
229
- m()
230
- ], n.prototype, "_maxIsReached");
231
- h([
232
- m()
233
- ], n.prototype, "_search");
234
- h([
235
- m()
236
- ], n.prototype, "_inputFocus");
237
- class H 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 = c(this.options, t)) == null ? void 0 : T.value) || null, s = this._value.includes(t || e || ""), i = !!e, l = ((S = this._options.find((U) => U.value === t)) == null ? void 0 : S.disabled) || !1, o = !(t != null && t.trim()), u = !this.multiple, _ = this.multiple, v = k(this._value.length, this.maxlength);
243
- let f = !1, y = !0, g = "", I = "";
244
- l || (!i && this.allowUserInput && !o ? (this.addNewUserValue(t), g = "Ny verdi lagt til", f = _) : !i && !this.allowUserInput ? (u && this._value[0] && this.removeValue(this._value[0]), y = !1, f = !0, g = "Ingen treff i søket") : s ? (this.removeValue(e), f = !0, u && this._hasTextInput && this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = "")) : o && u ? (this.removeAllSelected(), f = !0) : u ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(e), f = !1) : _ && !v ? (this.setSelected(e), f = !0) : _ && v ? (g = "Maks antall valg nådd", y = !1, I = t) : (u && this.removeAllSelected(), g = "Ingen gyldig verdi valgt", y = !1, f = !0, I = t), this._isOptionsOpen = f, f || (u && this._hasTextInput && (this._suppressNextOpen = !0), window.setTimeout(() => {
245
- this.focusTrigger();
246
- }, 0)), this._userInfoMessage = g, this._search = I || "", this.resetComboboxInput(y), _ && this.updateMaxReached());
247
- }
248
- setSelected(t) {
249
- if (!this._value.includes(t)) {
250
- if (this.multiple && k(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, x.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 = c(this.options, t);
261
- e && (x.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), x.markAllSelected(this._options), this.requestUpdate();
270
- }
271
- }
272
- removeAllSelected() {
273
- this._value = [], x.markAllDeselected(this._options), this._options = x.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 (!c(this.options, t)) {
292
- if (k(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] ? $(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 z extends H {
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: i } = B(this.options, this._search);
318
- this._options = s, t.inputType !== "deleteContentBackward" && (i != null && i.label) && this.inputRef.value && this.inputRef.value.type !== "hidden" && (e.value = i.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 = $(
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 i, l;
340
- if (this.disabled || !this._isOptionsOpen) return;
341
- const e = t.relatedTarget;
342
- ((i = e == null ? void 0 : e.closest("pkt-combobox")) == null ? void 0 : i.id) === this.id || ((l = t.target) == null ? void 0 : l.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 } = j(
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 = c(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 = $(
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, i, l;
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 = L(t.key, t.shiftKey, this.multiple);
447
- if (e && !(t.key === "Tab" && !this._isOptionsOpen)) {
448
- if (e === "focusListbox" && t.key === "Tab" && !((i = this.listboxRef.value) == null ? void 0 : i.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
- (l = this.listboxRef.value) == null || l.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 i;
477
- const e = this.getInsideTags();
478
- e.forEach((l, o) => {
479
- l.buttonTabindex = o === t ? 0 : -1;
480
- });
481
- const s = (i = e[t]) == null ? void 0 : i.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 i;
493
- this.resetTagTabindices(), this._hasTextInput && this.inputRef.value ? this.inputRef.value.focus() : (i = this.triggerRef.value) == null || i.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 i = this._value[e], l = e >= this._value.length - 1 ? e - 1 : e;
507
- this.removeSelected(i), l >= 0 ? (this.requestUpdate(), this.updateComplete.then(() => this.focusTag(l))) : 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 = K(
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
- class Q extends z {
535
- constructor() {
536
- super(...arguments), this.handleBodyClick = (t) => {
537
- this._isOptionsOpen && !this.contains(t.target) && this.closeAndProcessInput();
538
- };
539
- }
540
- // Lifecycle methods
541
- connectedCallback() {
542
- var t, e;
543
- if (super.connectedCallback(), document == null || document.body.addEventListener("click", this.handleBodyClick), this._options = [], this.defaultOptions && this.defaultOptions.length) {
544
- const s = ((t = this.options) == null ? void 0 : t.filter((i) => i.userAdded)) || [];
545
- this.options = [...s, ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options = Array.isArray(this.options) ? [...this.options] : [];
546
- }
547
- if ((e = this.optionsController) != null && e.nodes && this.optionsController.nodes.length) {
548
- const s = C.parseOptionsFromSlot(this.optionsController.nodes);
549
- s.length && (this.options = [...s], this._options = [...s], this._optionsFromSlot = !0, this._lastSlotGeneration = this.optionsController.generation);
550
- }
551
- }
552
- willUpdate(t) {
553
- if (this._optionsFromSlot && this.optionsController) {
554
- const e = this.optionsController.generation;
555
- if (e !== this._lastSlotGeneration) {
556
- this._lastSlotGeneration = e;
557
- const s = C.parseOptionsFromSlot(this.optionsController.nodes), i = this._options.filter((l) => l.userAdded);
558
- this.options = [...i, ...s];
559
- }
560
- }
561
- super.willUpdate(t);
562
- }
563
- disconnectedCallback() {
564
- super.disconnectedCallback(), document == null || document.body.removeEventListener("click", this.handleBodyClick);
565
- }
566
- firstUpdated(t) {
567
- this.defaultValue !== null && !this.value && (this.value = this.defaultValue), super.firstUpdated(t);
568
- }
569
- updated(t) {
570
- t.has("isOpen") && (this._isOptionsOpen = this.isOpen);
571
- const e = t.has("value"), s = t.has("_value");
572
- if (e && this._internalValueSync)
573
- this._internalValueSync = !1, s && this.syncValueAndDispatch(t.get("_value"));
574
- else if (e) {
575
- const l = [...this._value], o = this.parseValue();
576
- o.join(",") !== this._value.join(",") && (this._value = o), this.updateMaxReached(), this.syncValueAndDispatch(l);
577
- } else s && this.syncValueAndDispatch(t.get("_value"));
578
- if (t.has("defaultOptions") && this.defaultOptions.length) {
579
- const l = (Array.isArray(this.options) ? this.options : []).filter((o) => o.userAdded) || [];
580
- this.options = [...l, ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options = Array.isArray(this.options) ? [...this.options] : [];
581
- }
582
- if (t.has("options")) {
583
- const l = t.get("options") || this._options || [], o = V.mergeWithUserAdded(this.options, l);
584
- this._options = o, o.length > this.options.length && (this.options = o);
585
- const u = V.syncOptionsWithValues(this._options, this._value);
586
- if (this._options = u.options, u.newValues.length > this._value.length) {
587
- const _ = [...this._value];
588
- this._value = u.newValues, this.syncValueAndDispatch(_);
589
- }
590
- }
591
- if (t.has("_search") && this.dispatchEvent(
592
- new CustomEvent("search", {
593
- detail: this._search,
594
- bubbles: !1
595
- })
596
- ), !this._isOptionsOpen && !this.multiple && this._hasTextInput && this.inputRef.value && this.inputRef.value.type !== "hidden") {
597
- const l = this._value[0] ? $(this._value[0], this.options, this.displayValueAs) : "";
598
- this.inputRef.value.value !== l && (this.inputRef.value.value = l);
599
- }
600
- super.updated(t);
601
- }
602
- /**
603
- * Override form reset to properly restore combobox state.
604
- * The base class deselects all options and sets value/defaultValue, but
605
- * combobox needs to re-sync _options with the restored values and clean up
606
- * user-added options and UI state.
607
- */
608
- formResetCallback() {
609
- this.touched = !1;
610
- const t = this.defaultValue || (this.multiple, "");
611
- this.value = t, this._value = this.parseValue(), this._options = this._options.filter((e) => !e.userAdded).map((e) => ({ ...e, selected: this._value.includes(e.value) })), this.options = this.options.filter((e) => !e.userAdded).map((e) => ({ ...e, selected: this._value.includes(e.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();
612
- }
613
- attributeChangedCallback(t, e, s) {
614
- if (t === "options") {
615
- this._options = Array.isArray(this.options) ? [...this.options] : [];
616
- const i = V.syncOptionsWithValues(this._options, this._value);
617
- this._options = i.options, i.newValues.length > this._value.length && (this._value = i.newValues), this._search = "";
618
- }
619
- super.attributeChangedCallback(t, e, s);
620
- }
621
- // Render methods
622
- render() {
623
- return d`
624
- <pkt-input-wrapper
625
- .label=${this.label}
626
- .helptext=${this.helptext}
627
- .helptextDropdown=${r(this.helptextDropdown)}
628
- .helptextDropdownButton=${r(this.helptextDropdownButton)}
629
- ?fullwidth=${this.fullwidth}
630
- ?hasError=${this.hasError}
631
- ?inline=${this.inline}
632
- ?disabled=${this.disabled}
633
- .errorMessage=${this.errorMessage}
634
- ?optionalTag=${this.optionalTag}
635
- .optionalText=${this.optionalText}
636
- ?requiredTag=${this.requiredTag}
637
- .requiredText=${this.requiredText}
638
- .tagText=${this.tagText}
639
- useWrapper=${this.useWrapper}
640
- .forId=${this._hasTextInput ? this.id + "-input" : this.id + "-combobox"}
641
- ?hasFieldset=${!this._hasTextInput}
642
- class="pkt-combobox__wrapper"
643
- @labelClick=${this.handleInputClick}
644
- >
645
- <div class="pkt-contents" slot="helptext">${E(this, "helptext")}</div>
646
- <div class="pkt-combobox" @focusout=${this.handleFocusOut}>
647
- <div
648
- class=${w({
649
- "pkt-combobox__input": !0,
650
- "pkt-combobox__input--fullwidth": this.fullwidth,
651
- "pkt-combobox__input--open": this._isOptionsOpen,
652
- "pkt-combobox__input--error": this.hasError,
653
- "pkt-combobox__input--disabled": this.disabled
654
- })}
655
- id=${r(this._hasTextInput ? void 0 : `${this.id}-combobox`)}
656
- role=${r(this._hasTextInput ? void 0 : "combobox")}
657
- aria-expanded=${r(
658
- this._hasTextInput ? void 0 : this._isOptionsOpen ? "true" : "false"
659
- )}
660
- aria-controls=${r(this._hasTextInput ? void 0 : `${this.id}-listbox`)}
661
- aria-haspopup=${r(this._hasTextInput ? void 0 : "listbox")}
662
- aria-labelledby=${r(
663
- this._hasTextInput ? void 0 : `${this.id}-combobox-label`
664
- )}
665
- aria-activedescendant=${r(
666
- !this._hasTextInput && this._value[0] && c(this.options, this._value[0]) ? `${this.id}-listbox-${R(this._options, this._value[0])}` : void 0
667
- )}
668
- aria-description=${r(this._selectionDescription || void 0)}
669
- tabindex=${this._hasTextInput || this.disabled ? "-1" : "0"}
670
- @click=${this.handleInputClick}
671
- @keydown=${this._hasTextInput ? b : this.handleSelectOnlyKeydown}
672
- ${O(this.triggerRef)}
673
- >
674
- ${!this._hasTextInput && this.placeholder && (!this._value.length || this.multiple && this.tagPlacement == "outside") && !this._inputFocus ? d`<span class="pkt-combobox__placeholder" @click=${this.handlePlaceholderClick}
675
- >${this.placeholder}</span
676
- >` : this.tagPlacement !== "outside" ? this.renderSingleOrMultipleValues() : b}
677
- ${this.renderInputField()}
678
- <pkt-icon
679
- class=${w({
680
- "pkt-combobox__arrow-icon": !0,
681
- "pkt-combobox__arrow-icon--open": this._isOptionsOpen
682
- })}
683
- name="chevron-thin-down"
684
- aria-hidden="true"
685
- ></pkt-icon>
686
- </div>
687
-
688
- <pkt-listbox
689
- id="${this.id}-listbox"
690
- .options=${this._options}
691
- .isOpen=${this._isOptionsOpen}
692
- .searchPlaceholder=${this.searchPlaceholder}
693
- .label="Liste: ${this.label || ""}"
694
- ?include-search=${this.includeSearch}
695
- ?is-multi-select=${this.multiple}
696
- ?allow-user-input=${this.allowUserInput && !this._maxIsReached}
697
- ?max-is-reached=${this._maxIsReached}
698
- .customUserInput=${r(this._addValueText)}
699
- .userMessage=${this._userInfoMessage}
700
- @search=${this.handleSearch}
701
- @option-toggle=${this.handleOptionToggled}
702
- @select-all=${this.addAllOptions}
703
- @close-options=${() => this._isOptionsOpen = !1}
704
- @tab-close=${() => this.closeAndProcessInput()}
705
- .searchValue=${this._search || null}
706
- .maxLength=${this.maxlength || 0}
707
- ${O(this.listboxRef)}
708
- ></pkt-listbox>
709
- </div>
710
-
711
- ${this.tagPlacement === "outside" && this.multiple ? d`<div class="pkt-combobox__tags-outside">
712
- ${this.renderSingleOrMultipleValues()}
713
- </div>` : b}
714
- </pkt-input-wrapper>
715
- `;
716
- }
717
- renderInputField() {
718
- return this.typeahead || this.allowUserInput ? d`
719
- <div class="pkt-combobox__input-div combobox__input">
720
- <input
721
- type="text"
722
- id="${this.id}-input"
723
- name=${(this.name || this.id) + "-input"}
724
- placeholder=${r(
725
- !this._value.length || this.multiple && this.tagPlacement === "outside" ? this.placeholder : void 0
726
- )}
727
- @input=${this.handleInput}
728
- @change=${(t) => {
729
- t.stopPropagation(), t.stopImmediatePropagation();
730
- }}
731
- @keydown=${this.handleInputKeydown}
732
- @focus=${this.handleFocus}
733
- @blur=${this.handleBlur}
734
- autocomplete="off"
735
- role="combobox"
736
- aria-expanded=${this._isOptionsOpen ? "true" : "false"}
737
- aria-label=${r(this.label)}
738
- aria-autocomplete=${this.typeahead ? "both" : this.allowUserInput ? "list" : "none"}
739
- aria-controls="${this.id}-listbox"
740
- aria-activedescendant=${r(
741
- this._value[0] && c(this.options, this._value[0]) ? `${this.id}-listbox-${R(this._options, this._value[0])}` : void 0
742
- )}
743
- aria-description=${r(this._selectionDescription || void 0)}
744
- ${O(this.inputRef)}
745
- />
746
- </div>
747
- ` : d`
748
- <input
749
- type="hidden"
750
- id="${this.id}-input"
751
- name=${(this.name || this.id) + "-input"}
752
- .value=${this._value.join(",")}
753
- ${O(this.inputRef)}
754
- />
755
- `;
756
- }
757
- renderSingleOrMultipleValues() {
758
- if (!this.multiple && this._hasTextInput) return b;
759
- const t = !this.multiple, e = this.renderValueTag(c(this.options, this._value[0])), s = this.tagPlacement === "outside", i = d`
760
- <ul role="list" class="pkt-combobox__tag-list">
761
- ${D(
762
- this._value,
763
- (l) => l,
764
- (l, o) => {
765
- const u = c(this.options, l), _ = u == null ? void 0 : u.tagSkinColor;
766
- return d`
767
- <li
768
- role="listitem"
769
- @click=${s ? b : (v) => v.stopPropagation()}
770
- @mousedown=${s ? b : (v) => v.preventDefault()}
771
- >
772
- <pkt-tag
773
- skin=${_ || "blue-dark"}
774
- ?closeTag=${!this.disabled}
775
- .buttonTabindex=${s ? void 0 : -1}
776
- @close=${() => this.handleTagRemove(l)}
777
- @keydown=${s ? b : (v) => this.handleTagKeydown(v, o)}
778
- >
779
- ${this.renderValueTag(u)}
780
- </pkt-tag>
781
- </li>
782
- `;
783
- }
784
- )}
785
- </ul>
786
- `;
787
- return t ? e : i;
788
- }
789
- renderValueTag(t) {
790
- if (!t) return "";
791
- switch (this.displayValueAs) {
792
- case "prefixAndValue":
793
- return d`<span class="pkt-combobox__value" data-focusfix=${this.id}
794
- >${t.prefix || ""} ${t.value}</span
795
- >`;
796
- case "value":
797
- return d`<span class="pkt-combobox__value" data-focusfix=${this.id}
798
- >${t.value}</span
799
- >`;
800
- case "label":
801
- default:
802
- return d`<span class="pkt-combobox__value" data-focusfix=${this.id}
803
- >${t.label || t.value}</span
804
- >`;
805
- }
806
- }
807
- }
808
- try {
809
- M("pkt-combobox")(Q);
810
- } catch {
811
- console.warn("Forsøker å definere <pkt-combobox>, men den er allerede definert");
812
- }
813
- export {
814
- Q as P
815
- };