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