@oslokommune/punkt-elements 14.5.4 → 15.0.0

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 (123) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/dist/{accordionitem-DB3tAjIZ.js → accordionitem-BbeS44TD.js} +1 -1
  3. package/dist/{accordionitem-DHYmPA-o.cjs → accordionitem-DUWhTUEI.cjs} +1 -1
  4. package/dist/{alert-DVCenNTM.cjs → alert-B9flMht5.cjs} +1 -1
  5. package/dist/{alert-Cc5FtxHN.js → alert-BpFxQviu.js} +2 -2
  6. package/dist/{button-Ju4zPhVx.cjs → button-BgCKV0zW.cjs} +1 -1
  7. package/dist/{button-DrTXtc-n.js → button-CKgpX5QA.js} +1 -1
  8. package/dist/{calendar-CTx8PD1L.js → calendar-BMarIeVp.js} +332 -325
  9. package/dist/calendar-C6xgAJ7Z.cjs +90 -0
  10. package/dist/{card-DvHL7pNu.cjs → card-DI3KodEc.cjs} +1 -1
  11. package/dist/{card-CTtmPB2n.js → card-h8ekgJRr.js} +2 -2
  12. package/dist/{checkbox-B-0FOdwi.cjs → checkbox-B2t7wfxe.cjs} +1 -1
  13. package/dist/{checkbox-CkAwPK_E.js → checkbox-BJ9pz3kV.js} +1 -1
  14. package/dist/{combobox-DNPfpTjW.js → combobox-BjAvk8Y-.js} +5 -5
  15. package/dist/{combobox-DvL3SKz2.cjs → combobox-HNN7GTzh.cjs} +1 -1
  16. package/dist/{consent-DJW7YEat.cjs → consent-C37tuFwZ.cjs} +1 -1
  17. package/dist/{consent-OdhmtIK-.js → consent-DAk2BJ7I.js} +1 -1
  18. package/dist/datepicker-2bneToiA.cjs +275 -0
  19. package/dist/datepicker-DvcH2QD9.js +1160 -0
  20. package/dist/{helptext-7fyVJK2C.cjs → helptext-BG1P_9j0.cjs} +1 -1
  21. package/dist/{helptext-CfR0SYe9.js → helptext-Cm6FLBVf.js} +1 -1
  22. package/dist/index.d.ts +10 -42
  23. package/dist/input-element-BBv4xjPb.cjs +1 -0
  24. package/dist/{input-element-DVZhYDJ_.js → input-element-CbjYtVou.js} +143 -147
  25. package/dist/{input-wrapper-DVUh5rxv.js → input-wrapper-Bwmva-69.js} +3 -3
  26. package/dist/{input-wrapper-Bta4FZe3.cjs → input-wrapper-CJqmwe3I.cjs} +1 -1
  27. package/dist/{link-40XAFlYS.js → link-BKnT-97D.js} +1 -1
  28. package/dist/{link-CBQ7uKqb.cjs → link-DRPFqqEn.cjs} +1 -1
  29. package/dist/{linkcard-D8hxLedl.cjs → linkcard-02fxYQ2g.cjs} +1 -1
  30. package/dist/{linkcard-Opb42K2k.js → linkcard-C2UENcqo.js} +1 -1
  31. package/dist/{loader-Bv1R6-AA.js → loader-BW-AWQiE.js} +1 -1
  32. package/dist/{loader-Dh_5sihO.cjs → loader-Cj4kUNRE.cjs} +1 -1
  33. package/dist/{messagebox-B9MCodIz.cjs → messagebox-CK0sSRep.cjs} +1 -1
  34. package/dist/{messagebox-DEXCTOrz.js → messagebox-DB8tEXrV.js} +1 -1
  35. package/dist/{modal-Bw61rVrQ.cjs → modal-BzVQSQy2.cjs} +1 -1
  36. package/dist/{modal-B4adxB6X.js → modal-ClYfWW2a.js} +1 -1
  37. package/dist/pkt-accordion.cjs +1 -1
  38. package/dist/pkt-accordion.js +2 -2
  39. package/dist/pkt-alert.cjs +1 -1
  40. package/dist/pkt-alert.js +1 -1
  41. package/dist/pkt-button.cjs +1 -1
  42. package/dist/pkt-button.js +1 -1
  43. package/dist/pkt-calendar.cjs +1 -1
  44. package/dist/pkt-calendar.js +1 -1
  45. package/dist/pkt-card.cjs +1 -1
  46. package/dist/pkt-card.js +1 -1
  47. package/dist/pkt-checkbox.cjs +1 -1
  48. package/dist/pkt-checkbox.js +1 -1
  49. package/dist/pkt-combobox.cjs +1 -1
  50. package/dist/pkt-combobox.js +1 -1
  51. package/dist/pkt-consent.cjs +1 -1
  52. package/dist/pkt-consent.js +1 -1
  53. package/dist/pkt-datepicker.cjs +1 -1
  54. package/dist/pkt-datepicker.js +2 -2
  55. package/dist/pkt-header.cjs +1 -1
  56. package/dist/pkt-header.js +4 -4
  57. package/dist/pkt-helptext.cjs +1 -1
  58. package/dist/pkt-helptext.js +1 -1
  59. package/dist/pkt-index.cjs +1 -1
  60. package/dist/pkt-index.js +22 -22
  61. package/dist/pkt-input-wrapper.cjs +1 -1
  62. package/dist/pkt-input-wrapper.js +1 -1
  63. package/dist/pkt-link.cjs +1 -1
  64. package/dist/pkt-link.js +1 -1
  65. package/dist/pkt-linkcard.cjs +1 -1
  66. package/dist/pkt-linkcard.js +1 -1
  67. package/dist/pkt-loader.cjs +1 -1
  68. package/dist/pkt-loader.js +1 -1
  69. package/dist/pkt-messagebox.cjs +1 -1
  70. package/dist/pkt-messagebox.js +1 -1
  71. package/dist/pkt-modal.cjs +1 -1
  72. package/dist/pkt-modal.js +1 -1
  73. package/dist/{pkt-options-controller-zn5cmMvL.js → pkt-options-controller-BcGywCmf.js} +1 -1
  74. package/dist/{pkt-options-controller-DjBCEHU4.cjs → pkt-options-controller-BnTmkl3g.cjs} +1 -1
  75. package/dist/pkt-radiobutton.cjs +1 -1
  76. package/dist/pkt-radiobutton.js +1 -1
  77. package/dist/pkt-select.cjs +1 -1
  78. package/dist/pkt-select.js +1 -1
  79. package/dist/pkt-slot-controller-D4nKlom5.cjs +1 -0
  80. package/dist/{pkt-slot-controller-BPGj-LC5.js → pkt-slot-controller-D7CrjM52.js} +27 -25
  81. package/dist/pkt-tabs.cjs +1 -1
  82. package/dist/pkt-tabs.js +2 -2
  83. package/dist/pkt-tag.cjs +1 -1
  84. package/dist/pkt-tag.js +1 -1
  85. package/dist/pkt-textarea.cjs +1 -1
  86. package/dist/pkt-textarea.js +1 -1
  87. package/dist/pkt-textinput.cjs +1 -1
  88. package/dist/pkt-textinput.js +1 -1
  89. package/dist/{radiobutton-oA20HijB.js → radiobutton-CvKKNFMd.js} +1 -1
  90. package/dist/{radiobutton-iHuLnuAn.cjs → radiobutton-DWoYQn8H.cjs} +1 -1
  91. package/dist/{select--wvwpJ0_.cjs → select-BQUp88lY.cjs} +1 -1
  92. package/dist/{select-DfsNb_Yi.js → select-CFkxir_l.js} +4 -4
  93. package/dist/{tabitem-CypTmORF.js → tabitem-C8-tZyc_.js} +1 -1
  94. package/dist/{tabitem-CtltSqDK.cjs → tabitem-DaYfUaxw.cjs} +1 -1
  95. package/dist/{tag-Cw3OQqLW.js → tag-DIJMJhyp.js} +1 -1
  96. package/dist/{tag-P9lfQZbM.cjs → tag-h0vD2Na0.cjs} +1 -1
  97. package/dist/{textarea-CM_bj81t.js → textarea-CMuiBUee.js} +3 -3
  98. package/dist/{textarea-DcEKhXia.cjs → textarea-DcCOfNlr.cjs} +1 -1
  99. package/dist/{textinput-AVll6Nh7.js → textinput-D30TCADP.js} +3 -3
  100. package/dist/{textinput-BzuYzKZ6.cjs → textinput-DR3aaHTH.cjs} +1 -1
  101. package/package.json +4 -4
  102. package/src/components/calendar/calendar.core.test.ts +1 -1
  103. package/src/components/calendar/calendar.selection.test.ts +1 -1
  104. package/src/components/calendar/calendar.ts +32 -22
  105. package/src/components/datepicker/datepicker-popup.test.ts +1 -1
  106. package/src/components/datepicker/datepicker-popup.ts +73 -30
  107. package/src/components/datepicker/datepicker-range.ts +5 -1
  108. package/src/components/datepicker/datepicker-types.ts +4 -54
  109. package/src/components/datepicker/datepicker-utils.ts +38 -517
  110. package/src/components/datepicker/datepicker.core.test.ts +12 -10
  111. package/src/components/datepicker/datepicker.selection.test.ts +8 -6
  112. package/src/components/datepicker/datepicker.ts +26 -7
  113. package/src/components/icon/icon.test.ts +8 -8
  114. package/dist/calendar-5Obd0ZT3.cjs +0 -90
  115. package/dist/datepicker-CTCaZuZU.cjs +0 -271
  116. package/dist/datepicker-t0W9fA1e.js +0 -1444
  117. package/dist/input-element-RBQVA8i0.cjs +0 -1
  118. package/dist/pkt-slot-controller-BzddBp7z.cjs +0 -1
  119. package/src/components/calendar/helpers/calendar-grid.ts +0 -93
  120. package/src/components/calendar/helpers/date-validation.ts +0 -86
  121. package/src/components/calendar/helpers/index.ts +0 -49
  122. package/src/components/calendar/helpers/keyboard-navigation.ts +0 -54
  123. package/src/components/calendar/helpers/selection-manager.ts +0 -184
@@ -0,0 +1,1160 @@
1
+ import { P as L, E as D, x as h, n as r, t as x } from "./element-BXsf_NlG.js";
2
+ import { r as z } from "./state-DgnkjP0q.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 P, d as Y, p as Z, e as G } from "./calendar-BMarIeVp.js";
4
+ import { P as ee } from "./input-element-CbjYtVou.js";
5
+ import { e as f, n as v } from "./ref-BxiKhrfa.js";
6
+ import "./icon-DBZvMard.js";
7
+ import "./input-wrapper-Bwmva-69.js";
8
+ import { e as $ } from "./class-map-Dt2jXOlF.js";
9
+ import { c as te } from "./repeat-B55jMEsG.js";
10
+ import "./tag-DIJMJhyp.js";
11
+ import { u as se, s as ie } from "./utils-DznhwRXm.js";
12
+ import { o as g } from "./if-defined-CxHgig4I.js";
13
+ import { P as ae } from "./pkt-slot-controller-D7CrjM52.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
+ }, I = {
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 = f(), this.calendarRef = f(), 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 I.addToSelected == "function")
210
+ return I.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 m extends L {
312
+ constructor() {
313
+ super(...arguments), this.inputType = "date", this.id = "", this.readonly = !1, this.disabled = !1, this.inputClasses = {}, this.inputRef = f(), this.btnRef = f();
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
+ ], m.prototype, "inputType");
398
+ y([
399
+ r({ type: String })
400
+ ], m.prototype, "id");
401
+ y([
402
+ r({ type: String })
403
+ ], m.prototype, "min");
404
+ y([
405
+ r({ type: String })
406
+ ], m.prototype, "max");
407
+ y([
408
+ r({ type: String })
409
+ ], m.prototype, "placeholder");
410
+ y([
411
+ r({ type: Boolean })
412
+ ], m.prototype, "readonly");
413
+ y([
414
+ r({ type: Boolean })
415
+ ], m.prototype, "disabled");
416
+ y([
417
+ r({ type: Object })
418
+ ], m.prototype, "inputClasses");
419
+ y([
420
+ r({ type: Object })
421
+ ], m.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 m {
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=${g(this.min)}
449
+ max=${g(this.max)}
450
+ placeholder=${g(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 m {
513
+ constructor() {
514
+ super(...arguments), this.value = [], this.label = "", this.showRangeLabels = !1, this.strings = ne, this.inputRefTo = f();
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=${g(this.min)}
532
+ max=${g(this.max)}
533
+ placeholder=${g(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=${g(this.min)}
596
+ max=${g(this.max)}
597
+ placeholder=${g(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 m {
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=${g(this.min)}
692
+ max=${g(this.max)}
693
+ placeholder=${g(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, Pe = Object.getOwnPropertyDescriptor, p = (e, t, s, n) => {
745
+ for (var i = n > 1 ? void 0 : n ? Pe(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
+ /**
751
+ * Housekeeping / lifecycle methods
752
+ */
753
+ constructor() {
754
+ super(), this._valueProperty = "", this._valueProcessing = !1, this.datepickerPopupRef = f(), 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 = f(), this.popupRef = f(), this.helptextSlot = f(), this.singleInputRef = f(), this.rangeInputRef = f(), this.multipleInputRef = f(), this.addToSelected = (e) => {
755
+ const t = this.datepickerPopupRef.value;
756
+ return t && typeof t.addToSelected == "function" ? t.addToSelected(e, this.min, this.max) : I.addToSelected(e, this.calRef, this.min, this.max);
757
+ }, this.slotController = new ae(this, this.helptextSlot);
758
+ }
759
+ get value() {
760
+ return this._valueProperty;
761
+ }
762
+ set value(e) {
763
+ const t = this._valueProperty;
764
+ this._valueProperty = Array.isArray(e) ? e.join(",") : e || "", this.valueChanged(this._valueProperty, t), this.requestUpdate("value", t);
765
+ }
766
+ /**
767
+ * Computed properties
768
+ */
769
+ get inputType() {
770
+ return be.getInputType();
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 = P(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 = P(s || "")), e === "excludeweekdays" && typeof this.excludeweekdays == "string" && (this.excludeweekdays = P(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 = P(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" ${v(this.helptextSlot)} name="helptext" slot="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
1049
+ class="pkt-datepicker__inputs ${this.range && this.showRangeLabels ? "pkt-input__range-inputs" : ""}"
1050
+ >
1051
+ ${this.range ? this.renderRangeInput() : this.multiple ? this.renderMultipleInput() : this.renderInput()}
1052
+ </div>
1053
+ </pkt-input-wrapper>
1054
+ ${this.renderCalendar()}
1055
+ `;
1056
+ }
1057
+ /**
1058
+ * Handlers
1059
+ */
1060
+ handleCalendarPosition() {
1061
+ const e = this.multiple && !!this.maxlength;
1062
+ I.handleCalendarPosition(this.popupRef, this.inputRef, e);
1063
+ }
1064
+ async showCalendar() {
1065
+ var t;
1066
+ const e = this.datepickerPopupRef.value;
1067
+ if (this.calendarOpen = !0, e && typeof e.show == "function") {
1068
+ e.show(), b() && e.focusOnCurrentDate();
1069
+ return;
1070
+ }
1071
+ await ie(20), this.handleCalendarPosition(), b() && ((t = this.calRef.value) == null || t.focusOnCurrentDate());
1072
+ }
1073
+ hideCalendar() {
1074
+ const e = this.datepickerPopupRef.value;
1075
+ if (this.calendarOpen = !1, e && typeof e.hide == "function") return e.hide();
1076
+ }
1077
+ async toggleCalendar(e) {
1078
+ e.preventDefault();
1079
+ const t = this.datepickerPopupRef.value;
1080
+ if (t && typeof t.toggle == "function") {
1081
+ const s = !!t.open;
1082
+ t.toggle(), this.calendarOpen = !s;
1083
+ return;
1084
+ }
1085
+ this.calendarOpen ? this.hideCalendar() : this.showCalendar();
1086
+ }
1087
+ clearInputValue() {
1088
+ this._value = [], this.value = "", this.internals.setFormValue(this.value), this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), this.dispatchEvent(
1089
+ new CustomEvent("value-change", {
1090
+ detail: this._value,
1091
+ bubbles: !0,
1092
+ composed: !0
1093
+ })
1094
+ );
1095
+ }
1096
+ };
1097
+ p([
1098
+ r({ type: String, reflect: !0 })
1099
+ ], u.prototype, "value", 1);
1100
+ p([
1101
+ r({ type: String, reflect: !0 })
1102
+ ], u.prototype, "label", 2);
1103
+ p([
1104
+ r({ type: String })
1105
+ ], u.prototype, "dateformat", 2);
1106
+ p([
1107
+ r({ type: Boolean, reflect: !0 })
1108
+ ], u.prototype, "multiple", 2);
1109
+ p([
1110
+ r({ type: Number, reflect: !0 })
1111
+ ], u.prototype, "maxlength", 2);
1112
+ p([
1113
+ r({ type: Boolean, reflect: !0 })
1114
+ ], u.prototype, "range", 2);
1115
+ p([
1116
+ r({ type: Boolean, attribute: "show-range-labels" })
1117
+ ], u.prototype, "showRangeLabels", 2);
1118
+ p([
1119
+ r({ type: String, reflect: !0 })
1120
+ ], u.prototype, "min", 2);
1121
+ p([
1122
+ r({ type: String, reflect: !0 })
1123
+ ], u.prototype, "max", 2);
1124
+ p([
1125
+ r({ type: Boolean })
1126
+ ], u.prototype, "weeknumbers", 2);
1127
+ p([
1128
+ r({ type: Boolean, reflect: !0 })
1129
+ ], u.prototype, "withcontrols", 2);
1130
+ p([
1131
+ r({ converter: G.csvToArray })
1132
+ ], u.prototype, "excludedates", 2);
1133
+ p([
1134
+ r({ converter: G.csvToArray })
1135
+ ], u.prototype, "excludeweekdays", 2);
1136
+ p([
1137
+ r({ type: String })
1138
+ ], u.prototype, "currentmonth", 2);
1139
+ p([
1140
+ r({ type: String })
1141
+ ], u.prototype, "today", 2);
1142
+ p([
1143
+ r({ type: Boolean, reflect: !0, attribute: "calendar-open" })
1144
+ ], u.prototype, "calendarOpen", 2);
1145
+ p([
1146
+ r({ type: String })
1147
+ ], u.prototype, "timezone", 2);
1148
+ p([
1149
+ z()
1150
+ ], u.prototype, "inputClasses", 2);
1151
+ u = p([
1152
+ x("pkt-datepicker")
1153
+ ], u);
1154
+ export {
1155
+ w as P,
1156
+ u as a,
1157
+ B as b,
1158
+ C as c,
1159
+ R as d
1160
+ };