@oslokommune/punkt-elements 16.7.1 → 16.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (286) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/dist/accordion-BB1JrONI.cjs +34 -0
  3. package/dist/accordion-nNH87Y60.js +130 -0
  4. package/dist/alert-BEEnTiCb.cjs +33 -0
  5. package/dist/alert-ePJuDtmm.js +171 -0
  6. package/dist/async-directive-B9P1Qa0k.cjs +1 -0
  7. package/dist/async-directive-CaQiqjyV.js +55 -0
  8. package/dist/backlink-Ba03LlbB.cjs +13 -0
  9. package/dist/backlink-CiwXrQYD.js +38 -0
  10. package/dist/booleanish-BmcOU-43.js +11 -0
  11. package/dist/booleanish-jJLlnr6-.cjs +1 -0
  12. package/dist/breadcrumbs-CD1zib3s.cjs +43 -0
  13. package/dist/breadcrumbs-CpuVqWhF.js +76 -0
  14. package/dist/button-BIpd1xJh.js +95 -0
  15. package/dist/button-D-TOBaJB.cjs +27 -0
  16. package/dist/calendar-BzEtOJla.js +2031 -0
  17. package/dist/calendar-E5jJLt8D.cjs +90 -0
  18. package/dist/card-BYJu1MYm.js +339 -0
  19. package/dist/card-CUFhMVim.cjs +87 -0
  20. package/dist/checkbox-BARDb9iV.cjs +31 -0
  21. package/dist/checkbox-Cspxcvt_.js +111 -0
  22. package/dist/class-map-C8HuhNzZ.js +27 -0
  23. package/dist/class-map-CJ-msbHs.cjs +1 -0
  24. package/dist/classutils-DEL164Ur.js +7 -0
  25. package/dist/classutils-z8YsPlOf.cjs +1 -0
  26. package/dist/combobox-BcdLZRDU.js +984 -0
  27. package/dist/combobox-CGbFTWq_.cjs +135 -0
  28. package/dist/consent-DeB_5sWH.js +197 -0
  29. package/dist/consent-hwu7pp3S.cjs +11 -0
  30. package/dist/datepicker-DpmlsnH_.cjs +273 -0
  31. package/dist/datepicker-OVd8pmnZ.js +1125 -0
  32. package/dist/dialog-polyfill.esm-1hPr0gl9.js +280 -0
  33. package/dist/dialog-polyfill.esm-D3Oinvk0.cjs +1 -0
  34. package/dist/directive-3THFsVew.js +28 -0
  35. package/dist/directive-CJ2giQBZ.cjs +1 -0
  36. package/dist/directive-helpers-D1QSxY17.cjs +1 -0
  37. package/dist/directive-helpers-Dkv2gKgs.js +25 -0
  38. package/dist/element-DjtxO-1r.cjs +2 -0
  39. package/dist/element-cZ85T_aa.js +693 -0
  40. package/dist/element-with-slot-4J2o3SeU.js +166 -0
  41. package/dist/element-with-slot-CWoTGA1B.cjs +1 -0
  42. package/dist/header-DWgPgGfS.cjs +304 -0
  43. package/dist/header-a6ztVNp3.js +782 -0
  44. package/dist/heading-BgSWIRii.cjs +1 -0
  45. package/dist/heading-DiQLPxdf.js +73 -0
  46. package/dist/helptext-CCBKKLus.js +65 -0
  47. package/dist/helptext-D-3QfZv5.cjs +24 -0
  48. package/dist/icon-Co72KtgF.js +86 -0
  49. package/dist/icon-Dr8sfT2X.cjs +1 -0
  50. package/dist/if-defined-Cjj8qN-Z.js +5 -0
  51. package/dist/if-defined-XKOD_t_V.cjs +1 -0
  52. package/dist/index.d.ts +1 -2
  53. package/dist/input-element-B1yxcfz4.cjs +1 -0
  54. package/dist/input-element-Bw1s6NlF.js +643 -0
  55. package/dist/input-wrapper-BRuVELpK.cjs +54 -0
  56. package/dist/input-wrapper-CDyHTR1V.js +164 -0
  57. package/dist/input-wrapper-Dwd-_sKm.cjs +1 -0
  58. package/dist/input-wrapper-YfTmpSSY.js +117 -0
  59. package/dist/link-CKAFMz9j.js +89 -0
  60. package/dist/link-CyTCpI0k.cjs +7 -0
  61. package/dist/linkcard-B0KOGaGj.js +55 -0
  62. package/dist/linkcard-BE4-FewK.cjs +13 -0
  63. package/dist/listbox-DCA2JoPV.cjs +106 -0
  64. package/dist/listbox-DuBgTFvH.js +397 -0
  65. package/dist/loader-6kFZUErT.js +66 -0
  66. package/dist/loader-CX2rsC01.cjs +16 -0
  67. package/dist/messagebox-Cwlg5sOr.js +110 -0
  68. package/dist/messagebox-Din9X53b.cjs +13 -0
  69. package/dist/modal-C_wtsh9m.js +209 -0
  70. package/dist/modal-DS_wUOIv.cjs +36 -0
  71. package/dist/pkt-accordion.cjs +1 -1
  72. package/dist/pkt-accordion.js +2 -7
  73. package/dist/pkt-alert.cjs +1 -1
  74. package/dist/pkt-alert.js +2 -6
  75. package/dist/pkt-backlink.cjs +1 -1
  76. package/dist/pkt-backlink.js +2 -6
  77. package/dist/pkt-breadcrumbs.cjs +1 -43
  78. package/dist/pkt-breadcrumbs.js +2 -79
  79. package/dist/pkt-button.cjs +1 -1
  80. package/dist/pkt-button.js +2 -6
  81. package/dist/pkt-calendar.cjs +1 -1
  82. package/dist/pkt-calendar.js +2 -6
  83. package/dist/pkt-card.cjs +1 -1
  84. package/dist/pkt-card.js +2 -6
  85. package/dist/pkt-checkbox.cjs +1 -1
  86. package/dist/pkt-checkbox.js +2 -6
  87. package/dist/pkt-combobox.cjs +1 -1
  88. package/dist/pkt-combobox.js +2 -6
  89. package/dist/pkt-consent.cjs +1 -1
  90. package/dist/pkt-consent.js +2 -6
  91. package/dist/pkt-datepicker.cjs +1 -1
  92. package/dist/pkt-datepicker.js +5 -10
  93. package/dist/pkt-header.cjs +1 -304
  94. package/dist/pkt-header.js +2 -855
  95. package/dist/pkt-heading.cjs +1 -1
  96. package/dist/pkt-heading.js +2 -6
  97. package/dist/pkt-helptext.cjs +1 -1
  98. package/dist/pkt-helptext.js +2 -6
  99. package/dist/pkt-icon.cjs +1 -1
  100. package/dist/pkt-icon.js +2 -6
  101. package/dist/pkt-index.cjs +1 -1
  102. package/dist/pkt-index.js +30 -66
  103. package/dist/pkt-input-wrapper.cjs +1 -1
  104. package/dist/pkt-input-wrapper.js +2 -6
  105. package/dist/pkt-link.cjs +1 -1
  106. package/dist/pkt-link.js +2 -6
  107. package/dist/pkt-linkcard.cjs +1 -1
  108. package/dist/pkt-linkcard.js +2 -6
  109. package/dist/pkt-listbox.cjs +1 -1
  110. package/dist/pkt-listbox.js +2 -6
  111. package/dist/pkt-loader.cjs +1 -1
  112. package/dist/pkt-loader.js +2 -6
  113. package/dist/pkt-messagebox.cjs +1 -1
  114. package/dist/pkt-messagebox.js +2 -6
  115. package/dist/pkt-modal.cjs +1 -1
  116. package/dist/pkt-modal.js +2 -6
  117. package/dist/pkt-options-controller-CRrI6WMk.js +43 -0
  118. package/dist/pkt-options-controller-CXUGx134.cjs +1 -0
  119. package/dist/pkt-progressbar.cjs +1 -1
  120. package/dist/pkt-progressbar.js +2 -6
  121. package/dist/pkt-radiobutton.cjs +1 -1
  122. package/dist/pkt-radiobutton.js +2 -6
  123. package/dist/pkt-select.cjs +1 -1
  124. package/dist/pkt-select.js +2 -6
  125. package/dist/pkt-tabs.cjs +1 -1
  126. package/dist/pkt-tabs.js +2 -7
  127. package/dist/pkt-tag.cjs +1 -1
  128. package/dist/pkt-tag.js +2 -6
  129. package/dist/pkt-textarea.cjs +1 -1
  130. package/dist/pkt-textarea.js +2 -6
  131. package/dist/pkt-textinput.cjs +1 -1
  132. package/dist/pkt-textinput.js +2 -6
  133. package/dist/pkt-timepicker.cjs +1 -191
  134. package/dist/pkt-timepicker.js +2 -558
  135. package/dist/progressbar-CdXtmOBb.cjs +17 -0
  136. package/dist/progressbar-Dy9AiYQz.js +113 -0
  137. package/dist/radiobutton-GOnpUbCW.cjs +31 -0
  138. package/dist/radiobutton-V_KPbup_.js +84 -0
  139. package/dist/ref-BaJ0mBT_.cjs +1 -0
  140. package/dist/ref-RS8Uv6uC.js +30 -0
  141. package/dist/repeat-Cepr3469.js +57 -0
  142. package/dist/repeat-CqcDYBxr.cjs +1 -0
  143. package/dist/select-BSAFd8Wa.js +164 -0
  144. package/dist/select-C2i8sOk5.cjs +49 -0
  145. package/dist/tabs-D8nL9rWx.cjs +37 -0
  146. package/dist/tabs-Y7utmJi9.js +318 -0
  147. package/dist/tag-DLthw5b4.cjs +27 -0
  148. package/dist/tag-VwykmuQR.js +179 -0
  149. package/dist/textarea-D7aGOyDf.cjs +46 -0
  150. package/dist/textarea-DYOBhJrN.js +115 -0
  151. package/dist/textinput-BUgntXnM.js +124 -0
  152. package/dist/textinput-DFh8_9cx.cjs +70 -0
  153. package/dist/timepicker-BIfE7KKJ.cjs +191 -0
  154. package/dist/timepicker-DaSwn1FA.js +503 -0
  155. package/dist/utils-CUqCKGvp.js +7 -0
  156. package/dist/utils-CjAbIttF.cjs +1 -0
  157. package/package.json +6 -6
  158. package/src/components/accordion/accordion.ts +6 -1
  159. package/src/components/accordion/accordionitem.ts +6 -1
  160. package/src/components/alert/alert.test.ts +1 -1
  161. package/src/components/alert/alert.ts +12 -7
  162. package/src/components/backlink/backlink.ts +6 -1
  163. package/src/components/breadcrumbs/breadcrumbs.ts +6 -1
  164. package/src/components/button/button.ts +6 -1
  165. package/src/components/calendar/calendar.ts +6 -1
  166. package/src/components/card/card.ts +6 -1
  167. package/src/components/checkbox/checkbox.ts +6 -1
  168. package/src/components/combobox/combobox.ts +6 -1
  169. package/src/components/consent/consent.ts +6 -1
  170. package/src/components/datepicker/date-tags.ts +6 -1
  171. package/src/components/datepicker/datepicker-multiple.ts +6 -1
  172. package/src/components/datepicker/datepicker-popup.ts +6 -1
  173. package/src/components/datepicker/datepicker-range.ts +6 -1
  174. package/src/components/datepicker/datepicker-single.ts +6 -1
  175. package/src/components/datepicker/datepicker-utils.test.ts +16 -23
  176. package/src/components/datepicker/datepicker.ts +6 -1
  177. package/src/components/header/header-service.ts +6 -1
  178. package/src/components/header/header-user-menu.ts +6 -1
  179. package/src/components/header/header.ts +6 -1
  180. package/src/components/heading/heading.ts +6 -1
  181. package/src/components/helptext/helptext.ts +6 -1
  182. package/src/components/icon/icon.ts +6 -1
  183. package/src/components/input-wrapper/input-wrapper.ts +6 -1
  184. package/src/components/link/link.ts +6 -1
  185. package/src/components/linkcard/linkcard.ts +6 -1
  186. package/src/components/listbox/listbox.ts +6 -1
  187. package/src/components/loader/loader.ts +6 -1
  188. package/src/components/messagebox/messagebox.ts +6 -1
  189. package/src/components/modal/modal.ts +6 -1
  190. package/src/components/progressbar/progressbar.ts +6 -1
  191. package/src/components/radiobutton/radiobutton.ts +6 -1
  192. package/src/components/select/select.ts +6 -1
  193. package/src/components/tabs/tabitem.ts +6 -1
  194. package/src/components/tabs/tabs.ts +6 -1
  195. package/src/components/tag/tag.ts +6 -1
  196. package/src/components/textarea/textarea.ts +6 -1
  197. package/src/components/textinput/textinput.ts +6 -1
  198. package/src/components/timepicker/timepicker.ts +6 -1
  199. package/dist/accordionitem-D1Agl1bB.cjs +0 -34
  200. package/dist/accordionitem-ZlaXvjt5.js +0 -138
  201. package/dist/alert-BuAXrnKl.js +0 -115
  202. package/dist/alert-DFkFNTxh.cjs +0 -33
  203. package/dist/async-directive-CMzWMlZ5.js +0 -65
  204. package/dist/async-directive-DoMuclel.cjs +0 -5
  205. package/dist/backlink-EiAXUUZP.cjs +0 -13
  206. package/dist/backlink-V4DAt17e.js +0 -47
  207. package/dist/booleanish-BKVonob4.cjs +0 -1
  208. package/dist/booleanish-C9R0tdXH.js +0 -11
  209. package/dist/button-DEyvt1LI.js +0 -137
  210. package/dist/button-DYv5Dg4M.cjs +0 -27
  211. package/dist/calendar-HIE9nxcc.cjs +0 -90
  212. package/dist/calendar-S63oreVW.js +0 -2138
  213. package/dist/card-CyeH6l1c.cjs +0 -87
  214. package/dist/card-DDiLfuO4.js +0 -231
  215. package/dist/checkbox-BLlwTABj.cjs +0 -31
  216. package/dist/checkbox-ejBUa5qQ.js +0 -145
  217. package/dist/class-map-CEnykyO_.js +0 -34
  218. package/dist/class-map-CsENJXf1.cjs +0 -5
  219. package/dist/classutils-BwNK82ZQ.cjs +0 -1
  220. package/dist/classutils-RQs1k6D9.js +0 -7
  221. package/dist/combobox-BmxSecfE.js +0 -818
  222. package/dist/combobox-Hb2V-fPX.cjs +0 -135
  223. package/dist/consent-iXyx5v6J.js +0 -173
  224. package/dist/consent-ruWAEVXW.cjs +0 -11
  225. package/dist/datepicker-CZl7b8Na.js +0 -1158
  226. package/dist/datepicker-D2H7U6MS.cjs +0 -273
  227. package/dist/dialog-polyfill.esm-CPKZe7AL.cjs +0 -1
  228. package/dist/dialog-polyfill.esm-CbjBMXAG.js +0 -395
  229. package/dist/directive-C7oCP5Bh.cjs +0 -5
  230. package/dist/directive-helpers-BP2WOx60.cjs +0 -5
  231. package/dist/directive-helpers-rm-28gIj.js +0 -38
  232. package/dist/directive-oAbCiebi.js +0 -27
  233. package/dist/element-CPpT3rFQ.js +0 -638
  234. package/dist/element-gR_VtSiD.cjs +0 -27
  235. package/dist/element-with-slot-Dqk6-TRR.js +0 -240
  236. package/dist/element-with-slot-ZX-up7jO.cjs +0 -1
  237. package/dist/heading-CKt7cVn7.js +0 -101
  238. package/dist/heading-Cvz8m1xL.cjs +0 -1
  239. package/dist/helptext-5Mzp65-F.cjs +0 -24
  240. package/dist/helptext-jIoWRcCF.js +0 -80
  241. package/dist/icon-BlKA8YuW.js +0 -103
  242. package/dist/icon-Bqj9oBbl.cjs +0 -9
  243. package/dist/if-defined-B0krMLad.js +0 -10
  244. package/dist/if-defined-BOW3ODSj.cjs +0 -5
  245. package/dist/input-element-8nLwuQS4.js +0 -837
  246. package/dist/input-element-DdVhUvva.cjs +0 -1
  247. package/dist/input-wrapper-B0MkQ0IZ.cjs +0 -54
  248. package/dist/input-wrapper-B2JpK016.js +0 -179
  249. package/dist/input-wrapper-CDgenrYA.js +0 -6
  250. package/dist/input-wrapper-EoSAbU-U.cjs +0 -1
  251. package/dist/link-R_lNhViF.cjs +0 -7
  252. package/dist/link-Z_GizclR.js +0 -53
  253. package/dist/linkcard-BlQvdB1a.js +0 -54
  254. package/dist/linkcard-C7HbSLlX.cjs +0 -13
  255. package/dist/listbox-BQKDZvZn.js +0 -438
  256. package/dist/listbox-CGgV9MAe.cjs +0 -106
  257. package/dist/loader-Ci3CHU8k.js +0 -93
  258. package/dist/loader-e2gs_1xz.cjs +0 -16
  259. package/dist/messagebox-Bf-XMlvW.js +0 -69
  260. package/dist/messagebox-D67w71VX.cjs +0 -13
  261. package/dist/modal-CyvEkbfQ.cjs +0 -36
  262. package/dist/modal-DzGe1g8Z.js +0 -154
  263. package/dist/pkt-options-controller-5LXbEzuk.cjs +0 -1
  264. package/dist/pkt-options-controller-B5YalfCb.js +0 -39
  265. package/dist/progressbar-By7e0lEI.js +0 -162
  266. package/dist/progressbar-DsJ2B9Vm.cjs +0 -21
  267. package/dist/radiobutton-6frNG9J_.js +0 -111
  268. package/dist/radiobutton-Bv-BZ1Hw.cjs +0 -31
  269. package/dist/ref-Bg_Swj5w.js +0 -42
  270. package/dist/ref-CL-Xk9Xm.cjs +0 -5
  271. package/dist/repeat-BD8TKgJb.js +0 -61
  272. package/dist/repeat-Cfq8CDlf.cjs +0 -5
  273. package/dist/select-CXZt1nHS.js +0 -228
  274. package/dist/select-WFhS4Vfp.cjs +0 -49
  275. package/dist/state-C_1EOo3D.js +0 -12
  276. package/dist/state-Dg-53wQ8.cjs +0 -5
  277. package/dist/tabitem-CB8wkKmv.js +0 -332
  278. package/dist/tabitem-DZpspU4Q.cjs +0 -65
  279. package/dist/tag-BuCpqaks.js +0 -115
  280. package/dist/tag-X6xdjR0N.cjs +0 -27
  281. package/dist/textarea-Bzuymclz.js +0 -131
  282. package/dist/textarea-DoeHJ7HR.cjs +0 -50
  283. package/dist/textinput-9lHjs4ce.js +0 -150
  284. package/dist/textinput-BNsLd26i.cjs +0 -70
  285. package/dist/utils-DznhwRXm.js +0 -8
  286. package/dist/utils-byXsEz1u.cjs +0 -1
@@ -1,1158 +0,0 @@
1
- import { P as L, A as D, b as h, n as r, t as x } from "./element-CPpT3rFQ.js";
2
- import { r as z } from "./state-C_1EOo3D.js";
3
- import { s as H, f as N, a as Q, i as X, n as k, b as j, c as W, v as I, d as Y, p as Z, e as G } from "./calendar-S63oreVW.js";
4
- import { P as ee } from "./input-element-8nLwuQS4.js";
5
- import { e as m, n as v } from "./ref-Bg_Swj5w.js";
6
- import "./icon-BlKA8YuW.js";
7
- import "./input-wrapper-B2JpK016.js";
8
- import { e as $ } from "./class-map-CEnykyO_.js";
9
- import { c as te } from "./repeat-BD8TKgJb.js";
10
- import "./tag-BuCpqaks.js";
11
- import { u as se, s as ie } from "./utils-DznhwRXm.js";
12
- import { o as f } from "./if-defined-B0krMLad.js";
13
- import { s as ae } from "./element-with-slot-Dqk6-TRR.js";
14
- const J = {
15
- calendar: { buttonAltText: "Åpne kalender" }
16
- }, ne = {
17
- calendar: { buttonAltText: "Åpne kalender" },
18
- generic: { from: "Fra", to: "Til" }
19
- };
20
- var le = Object.defineProperty, re = Object.getOwnPropertyDescriptor, E = (e, t, s, n) => {
21
- for (var i = n > 1 ? void 0 : n ? re(t, s) : t, a = e.length - 1, l; a >= 0; a--)
22
- (l = e[a]) && (i = (n ? l(t, s, i) : l(i)) || i);
23
- return n && i && le(t, s, i), i;
24
- };
25
- let w = class extends L {
26
- constructor() {
27
- super(...arguments), this.dates = [], this.dateformat = "dd.MM.yyyy", this.className = "pkt-datepicker__tags", this.idBase = se();
28
- }
29
- render() {
30
- return this.classes = {
31
- "pkt-date-tags": !0,
32
- [this.className]: !0
33
- }, h`
34
- <div class=${$(this.classes)} aria-live="polite">
35
- ${Array.isArray(this.dates) && this.dates[0] ? te(
36
- H((this.dates ?? []).filter(Boolean)),
37
- (e) => e,
38
- (e) => {
39
- var t;
40
- return h` <pkt-tag
41
- id=${this.idBase + e + "-tag"}
42
- closeTag
43
- @close=${() => {
44
- this.dispatchEvent(new CustomEvent("date-tag-removed", { detail: e }));
45
- }}
46
- .ariaLabel=${`${(t = this.strings) == null ? void 0 : t.calendar.deleteDate} ${N(e, this.dateformat)}`}
47
- >
48
- <time datetime=${e}>${N(e, this.dateformat)}</time>
49
- </pkt-tag>`;
50
- }
51
- ) : D}
52
- </div>
53
- `;
54
- }
55
- };
56
- E([
57
- r({ type: Array })
58
- ], w.prototype, "dates", 2);
59
- E([
60
- r({ type: String })
61
- ], w.prototype, "dateformat", 2);
62
- E([
63
- r({ type: String, attribute: "class" })
64
- ], w.prototype, "className", 2);
65
- E([
66
- r({ type: String, attribute: "id-base" })
67
- ], w.prototype, "idBase", 2);
68
- w = E([
69
- x("pkt-date-tags")
70
- ], w);
71
- const oe = { dateformat: { default: "dd.MM.yyyy" }, weeknumbers: { default: !1 }, withcontrols: { default: !1 }, multiple: { default: !1 }, range: { default: !1 } }, _ = {
72
- props: oe
73
- }, b = () => {
74
- const e = navigator.userAgent;
75
- return !!(/iP(hone|od|ad)/.test(e) || /Macintosh/.test(e) && "ontouchend" in document);
76
- }, ue = () => b() ? "text" : "date", pe = (e) => !e || e.length !== 2 ? !0 : X(e[0], e[1]), he = (e) => H(e), de = (e, t, s, n, i) => Q(e, t, s, n, i), ce = (e, t, s, n, i, a) => ({
77
- "pkt-input": !0,
78
- "pkt-datepicker__input": !0,
79
- "pkt-input--fullwidth": e,
80
- "pkt-datepicker--hasrangelabels": t,
81
- "pkt-datepicker--multiple": s,
82
- "pkt-datepicker--range": n,
83
- "ios-readonly-hack": i === !1 && a === "text"
84
- }), fe = () => ({
85
- "pkt-input-icon": !0,
86
- "pkt-btn": !0,
87
- "pkt-btn--icon-only": !0,
88
- "pkt-btn--tertiary": !0,
89
- "pkt-datepicker__calendar-button": !0
90
- }), ge = (e) => ({
91
- "pkt-input-prefix": e,
92
- "pkt-hide": !e
93
- }), me = (e, t, s) => !t && !s ? Array.isArray(e) ? e[0] || "" : e : Array.isArray(e) ? e.join(",") : e, ve = (e, t, s = !1) => {
94
- var o;
95
- if (!e || !t) return;
96
- const n = ((o = t.parentElement) == null ? void 0 : o.getBoundingClientRect()) || t.getBoundingClientRect(), i = s ? n.height + 30 : n.height, a = e.getBoundingClientRect().height;
97
- let l = s ? "calc(100% - 30px)" : "100%";
98
- n && n.top + a > window.innerHeight && n.top - a > 0 && (l = `calc(100% - ${i}px - ${a}px)`), e.style.top = l;
99
- }, ye = (e, t, s, n, i, a) => {
100
- const { key: l } = e;
101
- l === "," && (e.preventDefault(), a ? a(e) : i && i()), (l === "Space" || l === " ") && (e.preventDefault(), t(e)), l === "Enter" && (e.preventDefault(), s ? s() : n ? n() : i && i());
102
- }, $e = (e, t) => {
103
- const { key: s } = e;
104
- (s === "Enter" || s === " " || s === "Space") && (e.preventDefault(), t(e));
105
- }, q = {
106
- validateRangeOrder: pe,
107
- sortDates: he,
108
- filterSelectableDates: de
109
- }, be = {
110
- getInputType: ue
111
- }, T = {
112
- submitForm(e) {
113
- var s;
114
- const t = (s = e.internals) == null ? void 0 : s.form;
115
- t && t.requestSubmit();
116
- },
117
- submitFormOrFallback(e, t) {
118
- const s = e == null ? void 0 : e.form;
119
- s ? s.requestSubmit() : t();
120
- },
121
- validateDateInput(e, t, s, n, i) {
122
- var l, o, K, U;
123
- const a = e.value;
124
- a && (s && s > a ? t.setValidity(
125
- { rangeUnderflow: !0 },
126
- ((o = (l = i == null ? void 0 : i.forms) == null ? void 0 : l.messages) == null ? void 0 : o.rangeUnderflow) || "Value is below minimum",
127
- e
128
- ) : n && n < a && t.setValidity(
129
- { rangeOverflow: !0 },
130
- ((U = (K = i == null ? void 0 : i.forms) == null ? void 0 : K.messages) == null ? void 0 : U.rangeOverflow) || "Value is above maximum",
131
- e
132
- ));
133
- }
134
- }, P = {
135
- addToSelected(e, t, s, n) {
136
- const i = e.target;
137
- if (!i.value) return;
138
- const a = s ? k(s) : null, l = n ? k(n) : null, o = k(i.value.split(",")[0]);
139
- o && !isNaN(o.getTime()) && (!a || o >= a) && (!l || o <= l) && t.value && t.value.handleDateSelect(o), i.value = "";
140
- },
141
- handleCalendarPosition(e, t, s = !1) {
142
- ve(e.value ?? null, t.value ?? null, s);
143
- }
144
- }, V = {
145
- getInputClasses: ce,
146
- getButtonClasses: fe,
147
- getRangeLabelClasses: ge
148
- }, F = {
149
- processDateSelection: me,
150
- updateInputValues(e, t, s, n, i, a) {
151
- e.value && (n && (t != null && t.value) ? (e.value.value = s[0] ?? "", t.value.value = s[1] ?? "", a(e.value), a(t.value)) : i || (e.value.value = s.length ? s[0] : "", a(e.value)));
152
- },
153
- processRangeBlur(e, t, s, n, i) {
154
- var l;
155
- const a = e.target;
156
- if (a.value) {
157
- i(a);
158
- const o = j(a.value);
159
- o && ((l = s == null ? void 0 : s.value) == null || l.handleDateSelect(o));
160
- } else t[0] && n();
161
- }
162
- }, O = {
163
- handleInputKeydown: ye,
164
- handleButtonKeydown: $e
165
- };
166
- var ke = Object.defineProperty, we = Object.getOwnPropertyDescriptor, c = (e, t, s, n) => {
167
- for (var i = n > 1 ? void 0 : n ? we(t, s) : t, a = e.length - 1, l; a >= 0; a--)
168
- (l = e[a]) && (i = (n ? l(t, s, i) : l(i)) || i);
169
- return n && i && ke(t, s, i), i;
170
- };
171
- let d = class extends L {
172
- constructor() {
173
- super(...arguments), this.open = !1, this.multiple = !1, this.range = !1, this.weeknumbers = !1, this.withcontrols = !1, this.maxMultiple = null, this.selected = [], this.earliest = null, this.latest = null, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = null, this.today = null, this._hasBeenOpened = !1, this.popupRef = m(), this.calendarRef = m(), this.handleDocumentClick = (e) => {
174
- if (!this.open) return;
175
- const t = e.composedPath(), s = this.parentElement, n = this.popupRef.value;
176
- !t.includes(this) && !t.includes(n) && !(s && t.includes(s)) && (this.hide(), this.dispatchEvent(new CustomEvent("close", { bubbles: !0, composed: !0 })));
177
- }, this.handleDocumentKeydown = (e) => {
178
- this.open && e.key === "Escape" && (this.hide(), this.dispatchEvent(new CustomEvent("close", { bubbles: !0, composed: !0 })));
179
- };
180
- }
181
- firstUpdated() {
182
- this.calRef = this.calendarRef;
183
- }
184
- updated(e) {
185
- super.updated(e), e.has("open") && (this.open ? (this._hasBeenOpened = !0, document.addEventListener("keydown", this.handleDocumentKeydown), document.addEventListener("click", this.handleDocumentClick)) : (document.removeEventListener("click", this.handleDocumentClick), document.removeEventListener("keydown", this.handleDocumentKeydown)));
186
- }
187
- disconnectedCallback() {
188
- super.disconnectedCallback(), document.removeEventListener("click", this.handleDocumentClick), document.removeEventListener("keydown", this.handleDocumentKeydown);
189
- }
190
- show() {
191
- var e;
192
- this.open = !0, (e = this.calendarRef.value) == null || e.focus();
193
- }
194
- hide() {
195
- this.open = !1;
196
- }
197
- toggle() {
198
- this.open ? this.hide() : this.show();
199
- }
200
- contains(e) {
201
- var t;
202
- return !!e && !!((t = this.popupRef.value) != null && t.contains(e));
203
- }
204
- focusOnCurrentDate() {
205
- const e = this.calendarRef.value;
206
- e && typeof e.focusOnCurrentDate == "function" && e.focusOnCurrentDate();
207
- }
208
- addToSelected(e, t, s) {
209
- if (this.calendarRef.value && typeof P.addToSelected == "function")
210
- return P.addToSelected(e, this.calendarRef, t, s);
211
- const i = e.target;
212
- if (!i.value) return;
213
- const a = t ? k(t) : null, l = s ? k(s) : null, o = k(i.value.split(",")[0]);
214
- o && !isNaN(o.getTime()) && (!a || o >= a) && (!l || o <= l) && this.handleDateSelect(o), i.value = "";
215
- }
216
- handleDateSelect(e) {
217
- const t = this.calendarRef.value;
218
- if (t && typeof t.handleDateSelect == "function") return t.handleDateSelect(e);
219
- const s = W(e), i = this.selected.indexOf(s) >= 0 ? this.selected.filter((a) => a !== s) : [...this.selected, s];
220
- this.selected = i, this.dispatchEvent(
221
- new CustomEvent("date-selected", { detail: i, bubbles: !0, composed: !0 })
222
- );
223
- }
224
- render() {
225
- const e = { "pkt-calendar-popup": !0, show: this.open, hide: !this.open };
226
- return h`
227
- <div
228
- class="${$(e)}"
229
- ${v(this.popupRef)}
230
- id="date-popup"
231
- ?hidden=${!this.open}
232
- aria-hidden="${!this.open}"
233
- >
234
- ${this.open || this._hasBeenOpened ? h`<pkt-calendar
235
- ${v(this.calendarRef)}
236
- ?multiple=${this.multiple}
237
- ?range=${this.range}
238
- ?weeknumbers=${this.weeknumbers}
239
- ?withcontrols=${this.withcontrols}
240
- .maxMultiple=${this.maxMultiple}
241
- .selected=${this.selected}
242
- .earliest=${this.earliest}
243
- .latest=${this.latest}
244
- .excludedates=${this.excludedates}
245
- .excludeweekdays=${this.excludeweekdays}
246
- .currentmonth=${this.currentmonth}
247
- .today=${this.today}
248
- @date-selected=${(t) => {
249
- this.selected = t.detail, this.dispatchEvent(
250
- new CustomEvent("date-selected", { detail: t.detail, bubbles: !0, composed: !0 })
251
- );
252
- }}
253
- @close=${() => {
254
- this.hide(), this.dispatchEvent(new CustomEvent("close", { bubbles: !0, composed: !0 }));
255
- }}
256
- ></pkt-calendar>` : D}
257
- </div>
258
- `;
259
- }
260
- };
261
- c([
262
- r({ type: Boolean, reflect: !0 })
263
- ], d.prototype, "open", 2);
264
- c([
265
- r({ type: Boolean })
266
- ], d.prototype, "multiple", 2);
267
- c([
268
- r({ type: Boolean })
269
- ], d.prototype, "range", 2);
270
- c([
271
- r({ type: Boolean })
272
- ], d.prototype, "weeknumbers", 2);
273
- c([
274
- r({ type: Boolean })
275
- ], d.prototype, "withcontrols", 2);
276
- c([
277
- r({ type: Number })
278
- ], d.prototype, "maxMultiple", 2);
279
- c([
280
- r({ type: Array })
281
- ], d.prototype, "selected", 2);
282
- c([
283
- r({ type: String })
284
- ], d.prototype, "earliest", 2);
285
- c([
286
- r({ type: String })
287
- ], d.prototype, "latest", 2);
288
- c([
289
- r({ type: Array })
290
- ], d.prototype, "excludedates", 2);
291
- c([
292
- r({ type: Array })
293
- ], d.prototype, "excludeweekdays", 2);
294
- c([
295
- r({ type: String })
296
- ], d.prototype, "currentmonth", 2);
297
- c([
298
- r({ type: String })
299
- ], d.prototype, "today", 2);
300
- c([
301
- z()
302
- ], d.prototype, "_hasBeenOpened", 2);
303
- d = c([
304
- x("pkt-datepicker-popup")
305
- ], d);
306
- var Ce = Object.defineProperty, y = (e, t, s, n) => {
307
- for (var i = void 0, a = e.length - 1, l; a >= 0; a--)
308
- (l = e[a]) && (i = l(t, s, i) || i);
309
- return i && Ce(t, s, i), i;
310
- };
311
- class g extends L {
312
- constructor() {
313
- super(...arguments), this.inputType = "date", this.id = "", this.readonly = !1, this.disabled = !1, this.inputClasses = {}, this.inputRef = m(), this.btnRef = m();
314
- }
315
- // Shared getters
316
- get inputElement() {
317
- return this.inputRef.value;
318
- }
319
- get buttonElement() {
320
- return this.btnRef.value;
321
- }
322
- get isInputReadonly() {
323
- return this.readonly || this.inputType === "text";
324
- }
325
- // Shared event dispatchers (protected so subclasses can use them)
326
- dispatchToggleCalendar(t) {
327
- this.readonly || this.dispatchEvent(
328
- new CustomEvent("toggle-calendar", {
329
- detail: t,
330
- bubbles: !0,
331
- composed: !0
332
- })
333
- );
334
- }
335
- dispatchInput(t) {
336
- this.dispatchEvent(
337
- new CustomEvent("input-change", {
338
- detail: t,
339
- bubbles: !0,
340
- composed: !0
341
- })
342
- );
343
- }
344
- dispatchFocus() {
345
- this.dispatchEvent(
346
- new CustomEvent("input-focus", {
347
- bubbles: !0,
348
- composed: !0
349
- })
350
- );
351
- }
352
- dispatchBlur(t) {
353
- this.dispatchEvent(
354
- new CustomEvent("input-blur", {
355
- detail: t,
356
- bubbles: !0,
357
- composed: !0
358
- })
359
- );
360
- }
361
- dispatchChange(t) {
362
- this.dispatchEvent(
363
- new CustomEvent("input-changed", {
364
- detail: t,
365
- bubbles: !0,
366
- composed: !0
367
- })
368
- );
369
- }
370
- // Shared render helper for calendar button
371
- renderCalendarButton() {
372
- var t;
373
- return h`
374
- <button
375
- class="${$(V.getButtonClasses())}"
376
- type="button"
377
- @click=${(s) => this.dispatchToggleCalendar(s)}
378
- @keydown=${(s) => {
379
- const { key: n } = s;
380
- (n === "Enter" || n === " " || n === "Space") && (s.preventDefault(), this.dispatchToggleCalendar(s));
381
- }}
382
- ?disabled=${this.disabled}
383
- ${this.btnRef}
384
- >
385
- <pkt-icon name="calendar"></pkt-icon>
386
- <span class="pkt-btn__text">${((t = this.strings.calendar) == null ? void 0 : t.buttonAltText) || "Åpne kalender"}</span>
387
- </button>
388
- `;
389
- }
390
- // Shared method - no shadow DOM
391
- createRenderRoot() {
392
- return this;
393
- }
394
- }
395
- y([
396
- r({ type: String })
397
- ], g.prototype, "inputType");
398
- y([
399
- r({ type: String })
400
- ], g.prototype, "id");
401
- y([
402
- r({ type: String })
403
- ], g.prototype, "min");
404
- y([
405
- r({ type: String })
406
- ], g.prototype, "max");
407
- y([
408
- r({ type: String })
409
- ], g.prototype, "placeholder");
410
- y([
411
- r({ type: Boolean })
412
- ], g.prototype, "readonly");
413
- y([
414
- r({ type: Boolean })
415
- ], g.prototype, "disabled");
416
- y([
417
- r({ type: Object })
418
- ], g.prototype, "inputClasses");
419
- y([
420
- r({ type: Object })
421
- ], g.prototype, "internals");
422
- var xe = Object.defineProperty, _e = Object.getOwnPropertyDescriptor, M = (e, t, s, n) => {
423
- for (var i = n > 1 ? void 0 : n ? _e(t, s) : t, a = e.length - 1, l; a >= 0; a--)
424
- (l = e[a]) && (i = (n ? l(t, s, i) : l(i)) || i);
425
- return n && i && xe(t, s, i), i;
426
- };
427
- let B = class extends g {
428
- constructor() {
429
- super(...arguments), this.value = "", this.strings = J;
430
- }
431
- dispatchManageValidity(e) {
432
- this.dispatchEvent(
433
- new CustomEvent("manage-validity", {
434
- detail: e,
435
- bubbles: !0,
436
- composed: !0
437
- })
438
- );
439
- }
440
- render() {
441
- return h`
442
- <div class="pkt-input__container">
443
- <input
444
- class="${$(this.inputClasses)}"
445
- .type=${this.inputType}
446
- id="${this.id}-input"
447
- .value=${this.value}
448
- min=${f(this.min)}
449
- max=${f(this.max)}
450
- placeholder=${f(this.placeholder)}
451
- ?readonly=${this.isInputReadonly}
452
- aria-describedby="${this.id}-helptext"
453
- @click=${(e) => {
454
- e.preventDefault(), this.dispatchToggleCalendar(e);
455
- }}
456
- @touchend=${(e) => {
457
- e.preventDefault(), this.dispatchToggleCalendar(e);
458
- }}
459
- ?disabled=${this.disabled}
460
- @keydown=${(e) => O.handleInputKeydown(
461
- e,
462
- (t) => this.dispatchToggleCalendar(t),
463
- () => T.submitFormOrFallback(this.internals, () => {
464
- var t;
465
- return (t = this.inputRef.value) == null ? void 0 : t.blur();
466
- }),
467
- void 0,
468
- () => {
469
- var t;
470
- return (t = this.inputRef.value) == null ? void 0 : t.blur();
471
- }
472
- )}
473
- @input=${(e) => {
474
- this.dispatchInput(e), e.stopImmediatePropagation();
475
- }}
476
- @focus=${() => {
477
- this.dispatchFocus(), b() && this.dispatchToggleCalendar(new Event("focus"));
478
- }}
479
- @blur=${(e) => {
480
- this.dispatchBlur(e), this.dispatchManageValidity(e.target), this.dispatchEvent(
481
- new CustomEvent("value-change", {
482
- detail: e.target.value,
483
- bubbles: !0,
484
- composed: !0
485
- })
486
- );
487
- }}
488
- @change=${(e) => {
489
- this.dispatchChange(e), e.stopImmediatePropagation();
490
- }}
491
- ${v(this.inputRef)}
492
- />
493
- ${this.renderCalendarButton()}
494
- </div>
495
- `;
496
- }
497
- };
498
- M([
499
- r({ type: String })
500
- ], B.prototype, "value", 2);
501
- M([
502
- r({ type: Object })
503
- ], B.prototype, "strings", 2);
504
- B = M([
505
- x("pkt-datepicker-single")
506
- ], B);
507
- var De = Object.defineProperty, Te = Object.getOwnPropertyDescriptor, S = (e, t, s, n) => {
508
- for (var i = n > 1 ? void 0 : n ? Te(t, s) : t, a = e.length - 1, l; a >= 0; a--)
509
- (l = e[a]) && (i = (n ? l(t, s, i) : l(i)) || i);
510
- return n && i && De(t, s, i), i;
511
- };
512
- let C = class extends g {
513
- constructor() {
514
- super(...arguments), this.value = [], this.label = "", this.showRangeLabels = !1, this.strings = ne, this.inputRefTo = m();
515
- }
516
- get inputElementTo() {
517
- return this.inputRefTo.value;
518
- }
519
- render() {
520
- var t, s, n, i;
521
- const e = V.getRangeLabelClasses(this.showRangeLabels);
522
- return h`
523
- <div class="pkt-input__container">
524
- ${this.showRangeLabels ? h` <div class="pkt-input-prefix">${(t = this.strings.generic) == null ? void 0 : t.from}</div> ` : D}
525
- <input
526
- class=${$(this.inputClasses)}
527
- .type=${this.inputType}
528
- id="${this.id}-input"
529
- aria-label="${this.label} ${((s = this.strings.generic) == null ? void 0 : s.from) ?? "Fra"}"
530
- .value=${this.value[0] ?? ""}
531
- min=${f(this.min)}
532
- max=${f(this.max)}
533
- placeholder=${f(this.placeholder)}
534
- ?readonly=${this.isInputReadonly}
535
- ?disabled=${this.disabled}
536
- @click=${(a) => {
537
- a.preventDefault(), this.dispatchToggleCalendar(a);
538
- }}
539
- @touchend=${(a) => {
540
- a.preventDefault(), this.dispatchToggleCalendar(a);
541
- }}
542
- @keydown=${(a) => O.handleInputKeydown(
543
- a,
544
- (l) => this.dispatchToggleCalendar(l),
545
- () => T.submitFormOrFallback(
546
- this.internals,
547
- () => {
548
- var l;
549
- return (l = this.inputRefTo.value) == null ? void 0 : l.focus();
550
- }
551
- ),
552
- () => {
553
- var l;
554
- return (l = this.inputRefTo.value) == null ? void 0 : l.focus();
555
- },
556
- () => {
557
- var l;
558
- return (l = this.inputRef.value) == null ? void 0 : l.blur();
559
- }
560
- )}
561
- @input=${(a) => {
562
- this.dispatchInput(a), a.stopImmediatePropagation();
563
- }}
564
- @focus=${() => {
565
- this.dispatchFocus(), b() && this.dispatchToggleCalendar(new Event("focus"));
566
- }}
567
- @blur=${(a) => {
568
- this.dispatchBlur(a), this.dispatchEvent(
569
- new CustomEvent("range-blur", {
570
- detail: {
571
- event: a,
572
- values: this.value,
573
- inputType: "from"
574
- },
575
- bubbles: !0,
576
- composed: !0
577
- })
578
- );
579
- }}
580
- @change=${(a) => {
581
- this.dispatchChange(a), a.stopImmediatePropagation();
582
- }}
583
- ${v(this.inputRef)}
584
- />
585
- <div class="${$(e)}" id="${this.id}-to-label">
586
- ${(n = this.strings.generic) == null ? void 0 : n.to}
587
- </div>
588
- ${this.showRangeLabels ? D : h` <div class="pkt-input-separator">–</div> `}
589
- <input
590
- class=${$(this.inputClasses)}
591
- .type=${this.inputType}
592
- id="${this.id}-to"
593
- aria-label="${this.label} ${((i = this.strings.generic) == null ? void 0 : i.to) ?? "Til"}"
594
- .value=${this.value[1] ?? ""}
595
- min=${f(this.min)}
596
- max=${f(this.max)}
597
- placeholder=${f(this.placeholder)}
598
- ?readonly=${this.isInputReadonly}
599
- ?disabled=${this.disabled}
600
- @click=${(a) => {
601
- a.preventDefault(), this.dispatchToggleCalendar(a);
602
- }}
603
- @touchend=${(a) => {
604
- a.preventDefault(), this.dispatchToggleCalendar(a);
605
- }}
606
- @keydown=${(a) => O.handleInputKeydown(
607
- a,
608
- (l) => this.dispatchToggleCalendar(l),
609
- () => T.submitFormOrFallback(this.internals, () => {
610
- var l;
611
- return (l = this.inputRefTo.value) == null ? void 0 : l.blur();
612
- }),
613
- void 0,
614
- () => {
615
- var l;
616
- return (l = this.inputRefTo.value) == null ? void 0 : l.blur();
617
- }
618
- )}
619
- @input=${(a) => {
620
- this.dispatchInput(a), a.stopImmediatePropagation();
621
- }}
622
- @focus=${() => {
623
- this.dispatchFocus(), b() && this.dispatchToggleCalendar(new Event("focus"));
624
- }}
625
- @blur=${(a) => {
626
- this.dispatchBlur(a), this.dispatchEvent(
627
- new CustomEvent("range-blur", {
628
- detail: {
629
- event: a,
630
- values: this.value,
631
- inputType: "to"
632
- },
633
- bubbles: !0,
634
- composed: !0
635
- })
636
- );
637
- }}
638
- @change=${(a) => {
639
- this.dispatchChange(a), a.stopImmediatePropagation();
640
- }}
641
- ${v(this.inputRefTo)}
642
- />
643
- ${this.renderCalendarButton()}
644
- </div>
645
- `;
646
- }
647
- };
648
- S([
649
- r({ type: Array })
650
- ], C.prototype, "value", 2);
651
- S([
652
- r({ type: String })
653
- ], C.prototype, "label", 2);
654
- S([
655
- r({ type: Boolean })
656
- ], C.prototype, "showRangeLabels", 2);
657
- S([
658
- r({ type: Object })
659
- ], C.prototype, "strings", 2);
660
- C = S([
661
- x("pkt-datepicker-range")
662
- ], C);
663
- var Re = Object.defineProperty, Ee = Object.getOwnPropertyDescriptor, A = (e, t, s, n) => {
664
- for (var i = n > 1 ? void 0 : n ? Ee(t, s) : t, a = e.length - 1, l; a >= 0; a--)
665
- (l = e[a]) && (i = (n ? l(t, s, i) : l(i)) || i);
666
- return n && i && Re(t, s, i), i;
667
- };
668
- let R = class extends g {
669
- constructor() {
670
- super(...arguments), this.value = [], this.strings = J;
671
- }
672
- get isInputDisabled() {
673
- return this.disabled || this.maxlength !== void 0 && this.maxlength !== null && this.value.length >= this.maxlength;
674
- }
675
- dispatchAddToSelected(e) {
676
- this.dispatchEvent(
677
- new CustomEvent("add-to-selected", {
678
- detail: e,
679
- bubbles: !0,
680
- composed: !0
681
- })
682
- );
683
- }
684
- render() {
685
- return h`
686
- <div class="pkt-input__container">
687
- <input
688
- class=${$(this.inputClasses)}
689
- .type=${this.inputType}
690
- id="${this.id}-input"
691
- min=${f(this.min)}
692
- max=${f(this.max)}
693
- placeholder=${f(this.placeholder)}
694
- ?readonly=${this.isInputReadonly}
695
- ?disabled=${this.isInputDisabled}
696
- @click=${(e) => {
697
- e.preventDefault(), this.dispatchToggleCalendar(e);
698
- }}
699
- @touchend=${(e) => {
700
- e.preventDefault(), this.dispatchToggleCalendar(e);
701
- }}
702
- @blur=${(e) => {
703
- this.dispatchBlur(e), this.dispatchAddToSelected(e);
704
- }}
705
- @input=${(e) => {
706
- this.dispatchInput(e), e.stopImmediatePropagation();
707
- }}
708
- @focus=${() => {
709
- this.dispatchFocus(), b() && this.dispatchToggleCalendar(new Event("focus"));
710
- }}
711
- @keydown=${(e) => O.handleInputKeydown(
712
- e,
713
- (t) => this.dispatchToggleCalendar(t),
714
- () => T.submitFormOrFallback(this.internals, () => {
715
- var t;
716
- return (t = this.inputRef.value) == null ? void 0 : t.blur();
717
- }),
718
- void 0,
719
- void 0,
720
- (t) => this.dispatchAddToSelected(t)
721
- )}
722
- @change=${(e) => {
723
- this.dispatchChange(e), e.stopImmediatePropagation();
724
- }}
725
- ${v(this.inputRef)}
726
- />
727
- ${this.renderCalendarButton()}
728
- </div>
729
- `;
730
- }
731
- };
732
- A([
733
- r({ type: Array })
734
- ], R.prototype, "value", 2);
735
- A([
736
- r({ type: Number })
737
- ], R.prototype, "maxlength", 2);
738
- A([
739
- r({ type: Object })
740
- ], R.prototype, "strings", 2);
741
- R = A([
742
- x("pkt-datepicker-multiple")
743
- ], R);
744
- var Se = Object.defineProperty, Ie = Object.getOwnPropertyDescriptor, p = (e, t, s, n) => {
745
- for (var i = n > 1 ? void 0 : n ? Ie(t, s) : t, a = e.length - 1, l; a >= 0; a--)
746
- (l = e[a]) && (i = (n ? l(t, s, i) : l(i)) || i);
747
- return n && i && Se(t, s, i), i;
748
- };
749
- let u = class extends ee {
750
- constructor() {
751
- super(...arguments), this._valueProperty = "", this._valueProcessing = !1, this.datepickerPopupRef = m(), this._value = [], this.label = "Datovelger", this.dateformat = _.props.dateformat.default, this.multiple = _.props.multiple.default, this.maxlength = null, this.range = _.props.range.default, this.showRangeLabels = !1, this.min = null, this.max = null, this.weeknumbers = _.props.weeknumbers.default, this.withcontrols = _.props.withcontrols.default, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = null, this.today = null, this.calendarOpen = !1, this.timezone = "Europe/Oslo", this.inputClasses = {}, this.calRef = m(), this.popupRef = m(), this.singleInputRef = m(), this.rangeInputRef = m(), this.multipleInputRef = m(), this.addToSelected = (e) => {
752
- const t = this.datepickerPopupRef.value;
753
- return t && typeof t.addToSelected == "function" ? t.addToSelected(e, this.min, this.max) : P.addToSelected(e, this.calRef, this.min, this.max);
754
- };
755
- }
756
- get value() {
757
- return this._valueProperty;
758
- }
759
- set value(e) {
760
- const t = this._valueProperty;
761
- this._valueProperty = Array.isArray(e) ? e.join(",") : e || "", this.valueChanged(this._valueProperty, t), this.requestUpdate("value", t);
762
- }
763
- /**
764
- * Computed properties
765
- */
766
- get inputType() {
767
- return be.getInputType();
768
- }
769
- /**
770
- * Housekeeping / lifecycle methods
771
- */
772
- connectedCallback() {
773
- super.connectedCallback(), this.timezone && this.timezone !== window.pktTz && (window.pktTz = this.timezone);
774
- }
775
- disconnectedCallback() {
776
- super.disconnectedCallback();
777
- }
778
- onInput() {
779
- this.dispatchEvent(new Event("input", { bubbles: !0 }));
780
- }
781
- valueChanged(e, t) {
782
- if (!(this._valueProcessing || e === t)) {
783
- this._valueProcessing = !0;
784
- try {
785
- const s = I(e), n = this.multiple && s.length > 1 ? q.filterSelectableDates(
786
- s,
787
- this.min,
788
- this.max,
789
- this.excludedates,
790
- this.excludeweekdays
791
- ) : s;
792
- if (this.range && !q.validateRangeOrder(n)) {
793
- this._value = [], this._valueProperty = "", super.valueChanged("", t);
794
- return;
795
- }
796
- this._value = n;
797
- const i = Y(n);
798
- if (this._valueProperty !== i && (this._valueProperty = i), this.range && n.length < 2) return;
799
- super.valueChanged(i, t);
800
- } finally {
801
- this._valueProcessing = !1;
802
- }
803
- }
804
- }
805
- attributeChangedCallback(e, t, s) {
806
- e === "value" && this.value !== t && this.valueChanged(s, t), e === "excludedates" && typeof this.excludedates == "string" && (this.excludedates = I(s || "")), e === "excludeweekdays" && typeof this.excludeweekdays == "string" && (this.excludeweekdays = I(s || "")), super.attributeChangedCallback(e, t, s);
807
- }
808
- updated(e) {
809
- if (e.has("value") && (e.has("multiple") || e.has("range"))) {
810
- const t = Array.isArray(this.value) ? this.value.join(",") : this.value, s = e.get("value"), n = Array.isArray(s) ? s.join(",") : s;
811
- this.valueChanged(t, n);
812
- }
813
- e.has("multiple") && (this.multiple && !Array.isArray(this._value) ? this._value = I(this.value) : !this.multiple && Array.isArray(this._value) && (this._value = this._value.filter(Boolean)), !this.multiple && !this.range && Array.isArray(this._value) && (this._value = [this._value[0] ?? ""])), super.updated(e);
814
- }
815
- /**
816
- * Element references
817
- */
818
- // Override the inputRef and inputRefTo for compatibility
819
- get inputRef() {
820
- return { value: this.currentInputElement };
821
- }
822
- get inputRefTo() {
823
- return { value: this.currentInputElementTo };
824
- }
825
- // Getters for backward compatibility with input refs
826
- get currentInputElement() {
827
- var e, t, s;
828
- return this.multiple ? (e = this.multipleInputRef.value) == null ? void 0 : e.inputElement : this.range ? (t = this.rangeInputRef.value) == null ? void 0 : t.inputElement : (s = this.singleInputRef.value) == null ? void 0 : s.inputElement;
829
- }
830
- get currentInputElementTo() {
831
- var e;
832
- if (this.range)
833
- return (e = this.rangeInputRef.value) == null ? void 0 : e.inputElementTo;
834
- }
835
- get currentButtonElement() {
836
- var e, t, s;
837
- return this.multiple ? (e = this.multipleInputRef.value) == null ? void 0 : e.buttonElement : this.range ? (t = this.rangeInputRef.value) == null ? void 0 : t.buttonElement : (s = this.singleInputRef.value) == null ? void 0 : s.buttonElement;
838
- }
839
- // Override btnRef for compatibility
840
- get btnRef() {
841
- return { value: this.currentButtonElement };
842
- }
843
- /**
844
- * Rendering
845
- */
846
- renderInput() {
847
- return h`
848
- <pkt-datepicker-single
849
- .value=${this._value[0] ?? ""}
850
- .inputType=${this.inputType}
851
- .id=${this.id}
852
- .min=${this.min}
853
- .max=${this.max}
854
- .placeholder=${this.placeholder}
855
- .readonly=${this.readonly}
856
- .disabled=${this.disabled}
857
- .inputClasses=${this.inputClasses}
858
- .internals=${this.internals}
859
- .strings=${this.strings}
860
- @toggle-calendar=${(e) => this.toggleCalendar(e.detail)}
861
- @input-change=${() => this.onInput()}
862
- @input-focus=${() => this.onFocus()}
863
- @input-blur=${(e) => {
864
- var t;
865
- (t = this.calRef.value) != null && t.contains(e.detail.relatedTarget) || this.onBlur();
866
- }}
867
- @manage-validity=${(e) => this.manageValidity(e.detail)}
868
- @value-change=${(e) => {
869
- this.value = e.detail;
870
- }}
871
- @input-changed=${() => {
872
- this.touched = !0;
873
- }}
874
- ${v(this.singleInputRef)}
875
- ></pkt-datepicker-single>
876
- `;
877
- }
878
- renderRangeInput() {
879
- return h`
880
- <pkt-datepicker-range
881
- .value=${this._value}
882
- .inputType=${this.inputType}
883
- .id=${this.id}
884
- .label=${this.label}
885
- .min=${this.min}
886
- .max=${this.max}
887
- .placeholder=${this.placeholder}
888
- .readonly=${this.readonly}
889
- .disabled=${this.disabled}
890
- .showRangeLabels=${this.showRangeLabels}
891
- .inputClasses=${this.inputClasses}
892
- .internals=${this.internals}
893
- .strings=${this.strings}
894
- @toggle-calendar=${(e) => this.toggleCalendar(e.detail)}
895
- @input-change=${() => this.onInput()}
896
- @input-focus=${() => this.onFocus()}
897
- @input-blur=${(e) => {
898
- var t;
899
- (t = this.calRef.value) != null && t.contains(e.detail.relatedTarget) || this.onBlur();
900
- }}
901
- @range-blur=${(e) => {
902
- const t = this.currentInputElement, s = this.currentInputElementTo;
903
- if (t && s) {
904
- const n = t.value, i = s.value;
905
- if (n && i && n > i)
906
- s.value = "", this._value = [n], this.value = n;
907
- else {
908
- const a = [n, i].filter(Boolean);
909
- a.length > 0 && (a[0] !== this._value[0] || a[1] !== this._value[1]) && (this._value = a, this.value = a.join(","));
910
- }
911
- }
912
- F.processRangeBlur(
913
- e.detail.event,
914
- e.detail.values,
915
- this.calRef,
916
- () => this.clearInputValue(),
917
- (n) => this.manageValidity(n)
918
- );
919
- }}
920
- @manage-validity=${(e) => this.manageValidity(e.detail)}
921
- @validate-date-input=${(e) => {
922
- T.validateDateInput(e.detail, this.internals, this.min, this.max, this.strings);
923
- }}
924
- @handle-date-select=${(e) => {
925
- var s, n;
926
- const t = j(e.detail);
927
- if (t) {
928
- const i = W(t);
929
- this._value[0] !== i && this._value[1] !== i && ((n = (s = this.calRef) == null ? void 0 : s.value) == null || n.handleDateSelect(t));
930
- }
931
- }}
932
- @input-changed=${() => {
933
- this.touched = !0;
934
- }}
935
- ${v(this.rangeInputRef)}
936
- ></pkt-datepicker-range>
937
- `;
938
- }
939
- renderMultipleInput() {
940
- return h`
941
- <pkt-datepicker-multiple
942
- .value=${this._value}
943
- .inputType=${this.inputType}
944
- .id=${this.id}
945
- .min=${this.min}
946
- .max=${this.max}
947
- .placeholder=${this.placeholder}
948
- .readonly=${this.readonly}
949
- .disabled=${this.disabled}
950
- .maxlength=${this.maxlength}
951
- .inputClasses=${this.inputClasses}
952
- .internals=${this.internals}
953
- .strings=${this.strings}
954
- @toggle-calendar=${(e) => this.toggleCalendar(e.detail)}
955
- @input-change=${() => this.onInput()}
956
- @input-focus=${() => this.onFocus()}
957
- @input-blur=${(e) => {
958
- var t;
959
- (t = this.calRef.value) != null && t.contains(e.detail.relatedTarget) || this.onBlur();
960
- }}
961
- @add-to-selected=${(e) => this.addToSelected(e.detail)}
962
- @input-changed=${() => {
963
- this.touched = !0;
964
- }}
965
- ${v(this.multipleInputRef)}
966
- ></pkt-datepicker-multiple>
967
- `;
968
- }
969
- renderCalendar() {
970
- return h`
971
- <pkt-datepicker-popup
972
- class="pkt-contents"
973
- ?open=${this.calendarOpen}
974
- ?multiple=${this.multiple}
975
- ?range=${this.range}
976
- ?weeknumbers=${this.weeknumbers}
977
- ?withcontrols=${this.withcontrols}
978
- .maxMultiple=${this.maxlength}
979
- .selected=${this._value}
980
- .earliest=${this.min}
981
- .latest=${this.max}
982
- .excludedates=${Array.isArray(this.excludedates) ? this.excludedates : this.excludedates.split(",")}
983
- .excludeweekdays=${this.excludeweekdays}
984
- .currentmonth=${this.currentmonth ? Z(this.currentmonth) : null}
985
- .today=${this.today}
986
- @date-selected=${(e) => {
987
- this.value = F.processDateSelection(e.detail, this.multiple, this.range), this._value = e.detail, F.updateInputValues(
988
- this.inputRef,
989
- this.inputRefTo,
990
- this._value,
991
- this.range,
992
- this.multiple,
993
- (t) => this.manageValidity(t)
994
- );
995
- }}
996
- @close=${() => {
997
- this.onBlur(), this.hideCalendar();
998
- }}
999
- ${v(this.datepickerPopupRef)}
1000
- ></pkt-datepicker-popup>
1001
- `;
1002
- }
1003
- render() {
1004
- return this.inputClasses = V.getInputClasses(
1005
- this.fullwidth,
1006
- this.showRangeLabels,
1007
- this.multiple,
1008
- this.range,
1009
- this.readonly,
1010
- this.inputType
1011
- ), h`
1012
- <pkt-input-wrapper
1013
- label="${this.label}"
1014
- forId="${this.id}-input"
1015
- ?counter=${this.multiple && !!this.maxlength}
1016
- .counterCurrent=${this.value ? this._value.length : 0}
1017
- .counterMaxLength=${this.maxlength}
1018
- ?disabled=${this.disabled}
1019
- ?hasError=${this.hasError}
1020
- ?hasFieldset=${this.hasFieldset}
1021
- ?inline=${this.inline}
1022
- ?required=${this.required}
1023
- ?optionalTag=${this.optionalTag}
1024
- ?requiredTag=${this.requiredTag}
1025
- useWrapper=${this.useWrapper}
1026
- .optionalText=${this.optionalText}
1027
- .requiredText=${this.requiredText}
1028
- .tagText=${this.tagText}
1029
- .errorMessage=${this.errorMessage}
1030
- .helptext=${this.helptext}
1031
- .helptextDropdown=${this.helptextDropdown}
1032
- .helptextDropdownButton=${this.helptextDropdownButton}
1033
- .ariaDescribedBy=${this.ariaDescribedBy}
1034
- class="pkt-datepicker"
1035
- >
1036
- <div class="pkt-contents" slot="helptext">${ae(this, "helptext")}</div>
1037
- ${this.multiple ? h`<pkt-date-tags
1038
- .dates=${this._value}
1039
- dateformat=${this.dateformat}
1040
- strings=${this.strings}
1041
- id-base=${this.id}
1042
- @date-tag-removed=${(e) => {
1043
- var n;
1044
- const t = this.datepickerPopupRef.value, s = j(e.detail);
1045
- t && s && typeof t.handleDateSelect == "function" ? t.handleDateSelect(s) : (n = this.calRef.value) == null || n.handleDateSelect(s);
1046
- }}
1047
- ></pkt-date-tags>` : D}
1048
- <div class="pkt-datepicker__inputs ${this.range ? "pkt-input__range-inputs" : ""}">
1049
- ${this.range ? this.renderRangeInput() : this.multiple ? this.renderMultipleInput() : this.renderInput()}
1050
- </div>
1051
- </pkt-input-wrapper>
1052
- ${this.renderCalendar()}
1053
- `;
1054
- }
1055
- /**
1056
- * Handlers
1057
- */
1058
- handleCalendarPosition() {
1059
- const e = this.multiple && !!this.maxlength;
1060
- P.handleCalendarPosition(this.popupRef, this.inputRef, e);
1061
- }
1062
- async showCalendar() {
1063
- var t;
1064
- const e = this.datepickerPopupRef.value;
1065
- if (this.calendarOpen = !0, e && typeof e.show == "function") {
1066
- e.show(), b() && e.focusOnCurrentDate();
1067
- return;
1068
- }
1069
- await ie(20), this.handleCalendarPosition(), b() && ((t = this.calRef.value) == null || t.focusOnCurrentDate());
1070
- }
1071
- hideCalendar() {
1072
- const e = this.datepickerPopupRef.value;
1073
- if (this.calendarOpen = !1, e && typeof e.hide == "function") return e.hide();
1074
- }
1075
- async toggleCalendar(e) {
1076
- e.preventDefault();
1077
- const t = this.datepickerPopupRef.value;
1078
- if (t && typeof t.toggle == "function") {
1079
- const s = !!t.open;
1080
- t.toggle(), this.calendarOpen = !s;
1081
- return;
1082
- }
1083
- this.calendarOpen ? this.hideCalendar() : this.showCalendar();
1084
- }
1085
- clearInputValue() {
1086
- this._value = [], this.value = "", this.internals.setFormValue(this.value), this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), this.dispatchEvent(
1087
- new CustomEvent("value-change", {
1088
- detail: this._value,
1089
- bubbles: !0,
1090
- composed: !0
1091
- })
1092
- );
1093
- }
1094
- };
1095
- p([
1096
- r({ type: String, reflect: !0 })
1097
- ], u.prototype, "value", 1);
1098
- p([
1099
- r({ type: String, reflect: !0 })
1100
- ], u.prototype, "label", 2);
1101
- p([
1102
- r({ type: String })
1103
- ], u.prototype, "dateformat", 2);
1104
- p([
1105
- r({ type: Boolean, reflect: !0 })
1106
- ], u.prototype, "multiple", 2);
1107
- p([
1108
- r({ type: Number, reflect: !0 })
1109
- ], u.prototype, "maxlength", 2);
1110
- p([
1111
- r({ type: Boolean, reflect: !0 })
1112
- ], u.prototype, "range", 2);
1113
- p([
1114
- r({ type: Boolean, attribute: "show-range-labels" })
1115
- ], u.prototype, "showRangeLabels", 2);
1116
- p([
1117
- r({ type: String, reflect: !0 })
1118
- ], u.prototype, "min", 2);
1119
- p([
1120
- r({ type: String, reflect: !0 })
1121
- ], u.prototype, "max", 2);
1122
- p([
1123
- r({ type: Boolean })
1124
- ], u.prototype, "weeknumbers", 2);
1125
- p([
1126
- r({ type: Boolean, reflect: !0 })
1127
- ], u.prototype, "withcontrols", 2);
1128
- p([
1129
- r({ converter: G.csvToArray })
1130
- ], u.prototype, "excludedates", 2);
1131
- p([
1132
- r({ converter: G.csvToArray })
1133
- ], u.prototype, "excludeweekdays", 2);
1134
- p([
1135
- r({ type: String })
1136
- ], u.prototype, "currentmonth", 2);
1137
- p([
1138
- r({ type: String })
1139
- ], u.prototype, "today", 2);
1140
- p([
1141
- r({ type: Boolean, reflect: !0, attribute: "calendar-open" })
1142
- ], u.prototype, "calendarOpen", 2);
1143
- p([
1144
- r({ type: String })
1145
- ], u.prototype, "timezone", 2);
1146
- p([
1147
- z()
1148
- ], u.prototype, "inputClasses", 2);
1149
- u = p([
1150
- x("pkt-datepicker")
1151
- ], u);
1152
- export {
1153
- w as P,
1154
- u as a,
1155
- R as b,
1156
- C as c,
1157
- B as d
1158
- };