@oslokommune/punkt-elements 14.0.2 → 14.0.3

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 (30) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/calendar-BtShW7ER.cjs +90 -0
  3. package/dist/{calendar-Bz27nuTP.js → calendar-yxjSI4wd.js} +766 -682
  4. package/dist/datepicker-D0q75U1Z.js +1463 -0
  5. package/dist/datepicker-DDV382Uu.cjs +271 -0
  6. package/dist/index.d.ts +118 -83
  7. package/dist/pkt-calendar.cjs +1 -1
  8. package/dist/pkt-calendar.js +1 -1
  9. package/dist/pkt-datepicker.cjs +1 -1
  10. package/dist/pkt-datepicker.js +2 -2
  11. package/dist/pkt-index.cjs +1 -1
  12. package/dist/pkt-index.js +3 -3
  13. package/package.json +2 -2
  14. package/src/components/calendar/calendar.ts +372 -414
  15. package/src/components/calendar/helpers/calendar-grid.ts +93 -0
  16. package/src/components/calendar/helpers/date-validation.ts +86 -0
  17. package/src/components/calendar/helpers/index.ts +49 -0
  18. package/src/components/calendar/helpers/keyboard-navigation.ts +54 -0
  19. package/src/components/calendar/helpers/selection-manager.ts +184 -0
  20. package/src/components/datepicker/datepicker-base.ts +151 -0
  21. package/src/components/datepicker/datepicker-multiple.ts +7 -114
  22. package/src/components/datepicker/datepicker-range.ts +21 -141
  23. package/src/components/datepicker/datepicker-single.ts +7 -115
  24. package/src/components/datepicker/datepicker-types.ts +56 -0
  25. package/src/components/datepicker/datepicker-utils.test.ts +730 -0
  26. package/src/components/datepicker/datepicker-utils.ts +338 -9
  27. package/src/components/datepicker/datepicker.ts +25 -1
  28. package/dist/calendar-Dz1Cnzx5.cjs +0 -115
  29. package/dist/datepicker-CnCOXI2x.cjs +0 -289
  30. package/dist/datepicker-DsqM01iU.js +0 -1355
@@ -1,1355 +0,0 @@
1
- import { P as I, E as A, x as d, n as a, a as R } from "./element-CRDRygXu.js";
2
- import { r as q } from "./state-DS_kr2Fy.js";
3
- import { s as U, f as N, n as j, a as W, i as H, b as L, v as O, d as G, e as J, p as Q, g as z } from "./calendar-Bz27nuTP.js";
4
- import { P as X } from "./input-element-B0VPRK_E.js";
5
- import { e as u, n as c } from "./ref-Xa5dbh--.js";
6
- import "./icon-1dy7UZcu.js";
7
- import "./input-wrapper-CnYj-xNE.js";
8
- import { e as k } from "./class-map-wy7PUk0P.js";
9
- import { c as Y } from "./repeat-CJ79egkN.js";
10
- import "./tag-BpCdJuei.js";
11
- import { u as Z, s as tt } from "./utils-DznhwRXm.js";
12
- import { o as C } from "./if-defined-BWZGb3bh.js";
13
- import { P as et } from "./pkt-slot-controller-BPGj-LC5.js";
14
- var st = Object.defineProperty, it = Object.getOwnPropertyDescriptor, P = (t, e, s, n) => {
15
- for (var i = n > 1 ? void 0 : n ? it(e, s) : e, l = t.length - 1, r; l >= 0; l--)
16
- (r = t[l]) && (i = (n ? r(e, s, i) : r(i)) || i);
17
- return n && i && st(e, s, i), i;
18
- };
19
- let T = class extends I {
20
- constructor() {
21
- super(...arguments), this.dates = [], this.dateformat = "dd.MM.yyyy", this.className = "pkt-datepicker__tags", this.idBase = Z();
22
- }
23
- render() {
24
- return this.classes = {
25
- "pkt-date-tags": !0,
26
- [this.className]: !0
27
- }, d`
28
- <div class=${k(this.classes)} aria-live="polite">
29
- ${Array.isArray(this.dates) && this.dates[0] ? Y(
30
- U((this.dates ?? []).filter(Boolean)),
31
- (t) => t,
32
- (t) => {
33
- var e;
34
- return d` <pkt-tag
35
- id=${this.idBase + t + "-tag"}
36
- closeTag
37
- @close=${() => {
38
- this.dispatchEvent(new CustomEvent("date-tag-removed", { detail: t }));
39
- }}
40
- .ariaLabel=${`${(e = this.strings) == null ? void 0 : e.calendar.deleteDate} ${N(t, this.dateformat)}`}
41
- >
42
- <time datetime=${t}>${N(t, this.dateformat)}</time>
43
- </pkt-tag>`;
44
- }
45
- ) : A}
46
- </div>
47
- `;
48
- }
49
- };
50
- P([
51
- a({ type: Array })
52
- ], T.prototype, "dates", 2);
53
- P([
54
- a({ type: String })
55
- ], T.prototype, "dateformat", 2);
56
- P([
57
- a({ type: String, attribute: "class" })
58
- ], T.prototype, "className", 2);
59
- P([
60
- a({ type: String, attribute: "id-base" })
61
- ], T.prototype, "idBase", 2);
62
- T = P([
63
- R("pkt-date-tags")
64
- ], T);
65
- const at = { dateformat: { default: "dd.MM.yyyy" }, weeknumbers: { default: !1 }, withcontrols: { default: !1 }, multiple: { default: !1 }, range: { default: !1 } }, _ = {
66
- props: at
67
- }, E = () => {
68
- const t = navigator.userAgent;
69
- return !!(/iP(hone|od|ad)/.test(t) || /Macintosh/.test(t) && "ontouchend" in document);
70
- }, B = {
71
- /**
72
- * Ensures name attribute ends with [] for multiple/range inputs
73
- */
74
- normalizeNameForMultiple(t, e, s) {
75
- return t ? (e || s) && !t.endsWith("[]") ? t + "[]" : t : null;
76
- },
77
- /**
78
- * Validates that a range has valid order (start <= end)
79
- */
80
- validateRangeOrder(t) {
81
- return !t || t.length !== 2 ? !0 : H(t[0], t[1]);
82
- },
83
- /**
84
- * Sorts date strings chronologically
85
- */
86
- sortDates(t) {
87
- return U(t);
88
- },
89
- /**
90
- * Filters dates to only include selectable ones based on constraints
91
- */
92
- filterSelectableDates(t, e, s, n, i) {
93
- return W(t, e, s, n, i);
94
- }
95
- }, nt = {
96
- /**
97
- * Determines the appropriate input type based on device
98
- * Mobile Safari does not play well with type="date" amd custom datepickers
99
- */
100
- getInputType() {
101
- return E() ? "text" : "date";
102
- }
103
- }, D = {
104
- /**
105
- * Submits the form that contains the given element
106
- */
107
- submitForm(t) {
108
- var s;
109
- const e = (s = t.internals) == null ? void 0 : s.form;
110
- e && e.requestSubmit();
111
- },
112
- /**
113
- * Submits form if available, otherwise executes fallback action
114
- */
115
- submitFormOrFallback(t, e) {
116
- const s = t == null ? void 0 : t.form;
117
- s ? s.requestSubmit() : e();
118
- },
119
- /**
120
- * Validates a date input and sets validity state
121
- */
122
- validateDateInput(t, e, s, n, i) {
123
- var r, h, V, K;
124
- const l = t.value;
125
- l && (s && s > l ? e.setValidity(
126
- { rangeUnderflow: !0 },
127
- ((h = (r = i == null ? void 0 : i.forms) == null ? void 0 : r.messages) == null ? void 0 : h.rangeUnderflow) || "Value is below minimum",
128
- t
129
- ) : n && n < l && e.setValidity(
130
- { rangeOverflow: !0 },
131
- ((K = (V = i == null ? void 0 : i.forms) == null ? void 0 : V.messages) == null ? void 0 : K.rangeOverflow) || "Value is above maximum",
132
- t
133
- ));
134
- }
135
- }, F = {
136
- /**
137
- * Adds a date to selected dates if it's valid
138
- */
139
- addToSelected(t, e, s, n) {
140
- const i = t.target;
141
- if (!i.value) return;
142
- const l = s ? j(s) : null, r = n ? j(n) : null, h = j(i.value.split(",")[0]);
143
- h && !isNaN(h.getTime()) && (!l || h >= l) && (!r || h <= r) && e.value && e.value.handleDateSelect(h), i.value = "";
144
- },
145
- /**
146
- * Handles calendar positioning based on viewport and input position
147
- */
148
- handleCalendarPosition(t, e, s = !1) {
149
- var h;
150
- if (!t.value || !e.value) return;
151
- const n = ((h = e.value.parentElement) == null ? void 0 : h.getBoundingClientRect()) || e.value.getBoundingClientRect(), i = s ? n.height + 30 : n.height, l = t.value.getBoundingClientRect().height;
152
- let r = s ? "calc(100% - 30px)" : "100%";
153
- n && n.top + l > window.innerHeight && n.top - l > 0 && (r = `calc(100% - ${i}px - ${l}px)`), t.value.style.top = r;
154
- }
155
- }, S = {
156
- /**
157
- * Generates input classes for datepicker
158
- */
159
- getInputClasses(t, e, s, n, i, l) {
160
- return {
161
- "pkt-input": !0,
162
- "pkt-datepicker__input": !0,
163
- "pkt-input--fullwidth": t,
164
- "pkt-datepicker--hasrangelabels": e,
165
- "pkt-datepicker--multiple": s,
166
- "pkt-datepicker--range": n,
167
- "ios-readonly-hack": i === !1 && l === "text"
168
- };
169
- },
170
- /**
171
- * Generates button classes for datepicker
172
- */
173
- getButtonClasses() {
174
- return {
175
- "pkt-input-icon": !0,
176
- "pkt-btn": !0,
177
- "pkt-btn--icon-only": !0,
178
- "pkt-btn--tertiary": !0,
179
- "pkt-datepicker__calendar-button": !0
180
- };
181
- },
182
- /**
183
- * Generates range label classes
184
- */
185
- getRangeLabelClasses(t) {
186
- return {
187
- "pkt-input-prefix": t,
188
- "pkt-hide": !t
189
- };
190
- }
191
- }, M = {
192
- /**
193
- * Handles date selection from calendar events
194
- */
195
- processDateSelection(t, e, s) {
196
- return !e && !s ? t[0] || "" : Array.isArray(t) ? t.join(",") : t;
197
- },
198
- /**
199
- * Updates input values after calendar selection
200
- */
201
- updateInputValues(t, e, s, n, i, l) {
202
- t.value && (n && (e != null && e.value) ? (t.value.value = s[0] ?? "", e.value.value = s[1] ?? "", l(t.value), l(e.value)) : i || (t.value.value = s.length ? s[0] : "", l(t.value)));
203
- },
204
- /**
205
- * Processes blur events for range inputs
206
- */
207
- processRangeBlur(t, e, s, n, i) {
208
- var r;
209
- const l = t.target;
210
- if (l.value) {
211
- i(l);
212
- const h = L(l.value);
213
- h && e[0] !== l.value && e[1] && (n(), (r = s == null ? void 0 : s.value) == null || r.handleDateSelect(h));
214
- } else e[0] && n();
215
- }
216
- }, x = {
217
- /**
218
- * Handles common keyboard interactions for datepicker inputs
219
- */
220
- handleInputKeydown(t, e, s, n, i, l) {
221
- const { key: r } = t;
222
- r === "," && (t.preventDefault(), l ? l(t) : i && i()), (r === "Space" || r === " ") && (t.preventDefault(), e(t)), r === "Enter" && (t.preventDefault(), s ? s() : n ? n() : i && i());
223
- },
224
- /**
225
- * Handles keyboard interactions for calendar button
226
- */
227
- handleButtonKeydown(t, e) {
228
- const { key: s } = t;
229
- (s === "Enter" || s === " " || s === "Space") && (t.preventDefault(), e(t));
230
- }
231
- };
232
- var lt = Object.defineProperty, rt = Object.getOwnPropertyDescriptor, v = (t, e, s, n) => {
233
- for (var i = n > 1 ? void 0 : n ? rt(e, s) : e, l = t.length - 1, r; l >= 0; l--)
234
- (r = t[l]) && (i = (n ? r(e, s, i) : r(i)) || i);
235
- return n && i && lt(e, s, i), i;
236
- };
237
- let g = class extends I {
238
- constructor() {
239
- 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.popupRef = u(), this.calendarRef = u(), this.handleDocumentClick = (t) => {
240
- if (!this.open) return;
241
- const e = t.composedPath(), s = this.parentElement, n = this.popupRef.value;
242
- !e.includes(this) && !e.includes(n) && !(s && e.includes(s)) && (this.hide(), this.dispatchEvent(new CustomEvent("close", { bubbles: !0, composed: !0 })));
243
- }, this.handleDocumentKeydown = (t) => {
244
- this.open && t.key === "Escape" && (this.hide(), this.dispatchEvent(new CustomEvent("close", { bubbles: !0, composed: !0 })));
245
- };
246
- }
247
- firstUpdated() {
248
- this.calRef = this.calendarRef, document.addEventListener("keydown", this.handleDocumentKeydown), document.addEventListener("click", this.handleDocumentClick);
249
- }
250
- disconnectedCallback() {
251
- super.disconnectedCallback(), document.removeEventListener("click", this.handleDocumentClick), document.removeEventListener("keydown", this.handleDocumentKeydown);
252
- }
253
- show() {
254
- var t;
255
- this.open = !0, (t = this.calendarRef.value) == null || t.focus();
256
- }
257
- hide() {
258
- this.open = !1;
259
- }
260
- toggle() {
261
- this.open ? this.hide() : this.show();
262
- }
263
- contains(t) {
264
- var e;
265
- return !!t && !!((e = this.popupRef.value) != null && e.contains(t));
266
- }
267
- focusOnCurrentDate() {
268
- const t = this.calendarRef.value;
269
- t && typeof t.focusOnCurrentDate == "function" && t.focusOnCurrentDate();
270
- }
271
- addToSelected(t, e, s) {
272
- if (typeof F.addToSelected == "function")
273
- return F.addToSelected(t, this.calendarRef, e, s);
274
- }
275
- handleDateSelect(t) {
276
- const e = this.calendarRef.value;
277
- if (e && typeof e.handleDateSelect == "function") return e.handleDateSelect(t);
278
- }
279
- render() {
280
- const t = { "pkt-calendar-popup": !0, show: this.open, hide: !this.open };
281
- return d`
282
- <div
283
- class="${k(t)}"
284
- ${c(this.popupRef)}
285
- id="date-popup"
286
- ?hidden=${!this.open}
287
- aria-hidden="${!this.open}"
288
- >
289
- <pkt-calendar
290
- ${c(this.calendarRef)}
291
- ?multiple=${this.multiple}
292
- ?range=${this.range}
293
- ?weeknumbers=${this.weeknumbers}
294
- ?withcontrols=${this.withcontrols}
295
- .maxMultiple=${this.maxMultiple}
296
- .selected=${this.selected}
297
- .earliest=${this.earliest}
298
- .latest=${this.latest}
299
- .excludedates=${this.excludedates}
300
- .excludeweekdays=${this.excludeweekdays}
301
- .currentmonth=${this.currentmonth}
302
- @date-selected=${(e) => {
303
- this.selected = e.detail, this.dispatchEvent(
304
- new CustomEvent("date-selected", { detail: e.detail, bubbles: !0, composed: !0 })
305
- );
306
- }}
307
- @close=${() => {
308
- this.hide(), this.dispatchEvent(new CustomEvent("close", { bubbles: !0, composed: !0 }));
309
- }}
310
- ></pkt-calendar>
311
- </div>
312
- `;
313
- }
314
- };
315
- v([
316
- a({ type: Boolean, reflect: !0 })
317
- ], g.prototype, "open", 2);
318
- v([
319
- a({ type: Boolean })
320
- ], g.prototype, "multiple", 2);
321
- v([
322
- a({ type: Boolean })
323
- ], g.prototype, "range", 2);
324
- v([
325
- a({ type: Boolean })
326
- ], g.prototype, "weeknumbers", 2);
327
- v([
328
- a({ type: Boolean })
329
- ], g.prototype, "withcontrols", 2);
330
- v([
331
- a({ type: Number })
332
- ], g.prototype, "maxMultiple", 2);
333
- v([
334
- a({ type: Array })
335
- ], g.prototype, "selected", 2);
336
- v([
337
- a({ type: String })
338
- ], g.prototype, "earliest", 2);
339
- v([
340
- a({ type: String })
341
- ], g.prototype, "latest", 2);
342
- v([
343
- a({ type: Array })
344
- ], g.prototype, "excludedates", 2);
345
- v([
346
- a({ type: Array })
347
- ], g.prototype, "excludeweekdays", 2);
348
- v([
349
- a({ type: String })
350
- ], g.prototype, "currentmonth", 2);
351
- g = v([
352
- R("pkt-datepicker-popup")
353
- ], g);
354
- var pt = Object.defineProperty, ot = Object.getOwnPropertyDescriptor, w = (t, e, s, n) => {
355
- for (var i = n > 1 ? void 0 : n ? ot(e, s) : e, l = t.length - 1, r; l >= 0; l--)
356
- (r = t[l]) && (i = (n ? r(e, s, i) : r(i)) || i);
357
- return n && i && pt(e, s, i), i;
358
- };
359
- let y = class extends I {
360
- constructor() {
361
- super(...arguments), this.value = "", this.inputType = "date", this.id = "", this.readonly = !1, this.disabled = !1, this.inputClasses = {}, this.strings = { calendar: { buttonAltText: "Åpne kalender" } }, this.inputRef = u(), this.btnRef = u();
362
- }
363
- get inputElement() {
364
- return this.inputRef.value;
365
- }
366
- get buttonElement() {
367
- return this.btnRef.value;
368
- }
369
- get isInputReadonly() {
370
- return this.readonly || this.inputType === "text";
371
- }
372
- dispatchToggleCalendar(t) {
373
- this.readonly || this.dispatchEvent(
374
- new CustomEvent("toggle-calendar", {
375
- detail: t,
376
- bubbles: !0,
377
- composed: !0
378
- })
379
- );
380
- }
381
- dispatchInput(t) {
382
- this.dispatchEvent(
383
- new CustomEvent("input-change", {
384
- detail: t,
385
- bubbles: !0,
386
- composed: !0
387
- })
388
- );
389
- }
390
- dispatchFocus() {
391
- this.dispatchEvent(
392
- new CustomEvent("input-focus", {
393
- bubbles: !0,
394
- composed: !0
395
- })
396
- );
397
- }
398
- dispatchBlur(t) {
399
- this.dispatchEvent(
400
- new CustomEvent("input-blur", {
401
- detail: t,
402
- bubbles: !0,
403
- composed: !0
404
- })
405
- );
406
- }
407
- dispatchChange(t) {
408
- this.dispatchEvent(
409
- new CustomEvent("input-changed", {
410
- detail: t,
411
- bubbles: !0,
412
- composed: !0
413
- })
414
- );
415
- }
416
- dispatchManageValidity(t) {
417
- this.dispatchEvent(
418
- new CustomEvent("manage-validity", {
419
- detail: t,
420
- bubbles: !0,
421
- composed: !0
422
- })
423
- );
424
- }
425
- createRenderRoot() {
426
- return this;
427
- }
428
- render() {
429
- return d`
430
- <div class="pkt-input__container">
431
- <input
432
- class="${k(this.inputClasses)}"
433
- .type=${this.inputType}
434
- id="${this.id}-input"
435
- .value=${this.value}
436
- min=${C(this.min)}
437
- max=${C(this.max)}
438
- placeholder=${C(this.placeholder)}
439
- ?readonly=${this.isInputReadonly}
440
- aria-describedby="${this.id}-helptext"
441
- @click=${(t) => {
442
- t.preventDefault(), this.dispatchToggleCalendar(t);
443
- }}
444
- @touchend=${(t) => {
445
- t.preventDefault(), this.dispatchToggleCalendar(t);
446
- }}
447
- ?disabled=${this.disabled}
448
- @keydown=${(t) => x.handleInputKeydown(
449
- t,
450
- (e) => this.dispatchToggleCalendar(e),
451
- () => D.submitFormOrFallback(this.internals, () => {
452
- var e;
453
- return (e = this.inputRef.value) == null ? void 0 : e.blur();
454
- }),
455
- void 0,
456
- () => {
457
- var e;
458
- return (e = this.inputRef.value) == null ? void 0 : e.blur();
459
- }
460
- )}
461
- @input=${(t) => {
462
- this.dispatchInput(t), t.stopImmediatePropagation();
463
- }}
464
- @focus=${() => {
465
- this.dispatchFocus(), E() && this.dispatchToggleCalendar(new Event("focus"));
466
- }}
467
- @blur=${(t) => {
468
- this.dispatchBlur(t), this.dispatchManageValidity(t.target), this.dispatchEvent(
469
- new CustomEvent("value-change", {
470
- detail: t.target.value,
471
- bubbles: !0,
472
- composed: !0
473
- })
474
- );
475
- }}
476
- @change=${(t) => {
477
- this.dispatchChange(t), t.stopImmediatePropagation();
478
- }}
479
- ${c(this.inputRef)}
480
- />
481
- <button
482
- class="${k(S.getButtonClasses())}"
483
- type="button"
484
- @click=${(t) => this.dispatchToggleCalendar(t)}
485
- @keydown=${(t) => x.handleButtonKeydown(t, (e) => this.dispatchToggleCalendar(e))}
486
- ?disabled=${this.disabled}
487
- ${c(this.btnRef)}
488
- >
489
- <pkt-icon name="calendar"></pkt-icon>
490
- <span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
491
- </button>
492
- </div>
493
- `;
494
- }
495
- };
496
- w([
497
- a({ type: String })
498
- ], y.prototype, "value", 2);
499
- w([
500
- a({ type: String })
501
- ], y.prototype, "inputType", 2);
502
- w([
503
- a({ type: String })
504
- ], y.prototype, "id", 2);
505
- w([
506
- a({ type: String })
507
- ], y.prototype, "min", 2);
508
- w([
509
- a({ type: String })
510
- ], y.prototype, "max", 2);
511
- w([
512
- a({ type: String })
513
- ], y.prototype, "placeholder", 2);
514
- w([
515
- a({ type: Boolean })
516
- ], y.prototype, "readonly", 2);
517
- w([
518
- a({ type: Boolean })
519
- ], y.prototype, "disabled", 2);
520
- w([
521
- a({ type: Object })
522
- ], y.prototype, "inputClasses", 2);
523
- w([
524
- a({ type: Object })
525
- ], y.prototype, "internals", 2);
526
- w([
527
- a({ type: Object })
528
- ], y.prototype, "strings", 2);
529
- y = w([
530
- R("pkt-datepicker-single")
531
- ], y);
532
- var ut = Object.defineProperty, ht = Object.getOwnPropertyDescriptor, b = (t, e, s, n) => {
533
- for (var i = n > 1 ? void 0 : n ? ht(e, s) : e, l = t.length - 1, r; l >= 0; l--)
534
- (r = t[l]) && (i = (n ? r(e, s, i) : r(i)) || i);
535
- return n && i && ut(e, s, i), i;
536
- };
537
- let m = class extends I {
538
- constructor() {
539
- super(...arguments), this.value = [], this.inputType = "date", this.id = "", this.readonly = !1, this.disabled = !1, this.showRangeLabels = !1, this.inputClasses = {}, this.strings = { generic: { from: "Fra", to: "Til" } }, this.inputRef = u(), this.inputRefTo = u(), this.btnRef = u();
540
- }
541
- get inputElement() {
542
- return this.inputRef.value;
543
- }
544
- get inputElementTo() {
545
- return this.inputRefTo.value;
546
- }
547
- get buttonElement() {
548
- return this.btnRef.value;
549
- }
550
- get isInputReadonly() {
551
- return this.readonly || this.inputType === "text";
552
- }
553
- dispatchToggleCalendar(t) {
554
- this.readonly || this.dispatchEvent(
555
- new CustomEvent("toggle-calendar", {
556
- detail: t,
557
- bubbles: !0,
558
- composed: !0
559
- })
560
- );
561
- }
562
- dispatchInput(t) {
563
- this.dispatchEvent(
564
- new CustomEvent("input-change", {
565
- detail: t,
566
- bubbles: !0,
567
- composed: !0
568
- })
569
- );
570
- }
571
- dispatchFocus() {
572
- this.dispatchEvent(
573
- new CustomEvent("input-focus", {
574
- bubbles: !0,
575
- composed: !0
576
- })
577
- );
578
- }
579
- dispatchBlur(t) {
580
- this.dispatchEvent(
581
- new CustomEvent("input-blur", {
582
- detail: t,
583
- bubbles: !0,
584
- composed: !0
585
- })
586
- );
587
- }
588
- dispatchChange(t) {
589
- this.dispatchEvent(
590
- new CustomEvent("input-changed", {
591
- detail: t,
592
- bubbles: !0,
593
- composed: !0
594
- })
595
- );
596
- }
597
- dispatchManageValidity(t) {
598
- this.dispatchEvent(
599
- new CustomEvent("manage-validity", {
600
- detail: t,
601
- bubbles: !0,
602
- composed: !0
603
- })
604
- );
605
- }
606
- createRenderRoot() {
607
- return this;
608
- }
609
- render() {
610
- const t = S.getRangeLabelClasses(this.showRangeLabels);
611
- return d`
612
- <div class="pkt-input__container">
613
- ${this.showRangeLabels ? d` <div class="pkt-input-prefix">${this.strings.generic.from}</div> ` : A}
614
- <input
615
- class=${k(this.inputClasses)}
616
- .type=${this.inputType}
617
- id="${this.id}-input"
618
- .value=${this.value[0] ?? ""}
619
- min=${C(this.min)}
620
- max=${C(this.max)}
621
- placeholder=${C(this.placeholder)}
622
- ?readonly=${this.isInputReadonly}
623
- ?disabled=${this.disabled}
624
- @click=${(e) => {
625
- e.preventDefault(), this.dispatchToggleCalendar(e);
626
- }}
627
- @touchend=${(e) => {
628
- e.preventDefault(), this.dispatchToggleCalendar(e);
629
- }}
630
- @keydown=${(e) => x.handleInputKeydown(
631
- e,
632
- (s) => this.dispatchToggleCalendar(s),
633
- () => D.submitFormOrFallback(
634
- this.internals,
635
- () => {
636
- var s;
637
- return (s = this.inputRefTo.value) == null ? void 0 : s.focus();
638
- }
639
- ),
640
- () => {
641
- var s;
642
- return (s = this.inputRefTo.value) == null ? void 0 : s.focus();
643
- },
644
- () => {
645
- var s;
646
- return (s = this.inputRef.value) == null ? void 0 : s.blur();
647
- }
648
- )}
649
- @input=${(e) => {
650
- this.dispatchInput(e), e.stopImmediatePropagation();
651
- }}
652
- @focus=${() => {
653
- this.dispatchFocus(), E() && this.dispatchToggleCalendar(new Event("focus"));
654
- }}
655
- @blur=${(e) => {
656
- this.dispatchEvent(
657
- new CustomEvent("range-blur", {
658
- detail: {
659
- event: e,
660
- values: this.value,
661
- inputType: "from"
662
- },
663
- bubbles: !0,
664
- composed: !0
665
- })
666
- );
667
- }}
668
- @change=${(e) => {
669
- e.stopImmediatePropagation();
670
- }}
671
- ${c(this.inputRef)}
672
- />
673
- <div class="${k(t)}" id="${this.id}-to-label">
674
- ${this.strings.generic.to}
675
- </div>
676
- ${this.showRangeLabels ? A : d` <div class="pkt-input-separator">–</div> `}
677
- <input
678
- class=${k(this.inputClasses)}
679
- .type=${this.inputType}
680
- id="${this.id}-to"
681
- aria-labelledby="${this.id}-to-label"
682
- .value=${this.value[1] ?? ""}
683
- min=${C(this.min)}
684
- max=${C(this.max)}
685
- placeholder=${C(this.placeholder)}
686
- ?readonly=${this.isInputReadonly}
687
- ?disabled=${this.disabled}
688
- @click=${(e) => {
689
- e.preventDefault(), this.dispatchToggleCalendar(e);
690
- }}
691
- @touchend=${(e) => {
692
- e.preventDefault(), this.dispatchToggleCalendar(e);
693
- }}
694
- @keydown=${(e) => x.handleInputKeydown(
695
- e,
696
- (s) => this.dispatchToggleCalendar(s),
697
- () => D.submitFormOrFallback(this.internals, () => {
698
- var s;
699
- return (s = this.inputRefTo.value) == null ? void 0 : s.blur();
700
- }),
701
- void 0,
702
- () => {
703
- var s;
704
- return (s = this.inputRefTo.value) == null ? void 0 : s.blur();
705
- }
706
- )}
707
- @input=${(e) => {
708
- this.dispatchInput(e), e.stopImmediatePropagation();
709
- }}
710
- @focus=${() => {
711
- this.dispatchFocus(), E() && this.dispatchToggleCalendar(new Event("focus"));
712
- }}
713
- @blur=${(e) => {
714
- this.dispatchBlur(e), e.target.value && (this.dispatchManageValidity(e.target), this.dispatchEvent(
715
- new CustomEvent("validate-date-input", {
716
- detail: e.target,
717
- bubbles: !0,
718
- composed: !0
719
- })
720
- ), this.dispatchEvent(
721
- new CustomEvent("handle-date-select", {
722
- detail: e.target.value,
723
- bubbles: !0,
724
- composed: !0
725
- })
726
- ));
727
- }}
728
- @change=${(e) => {
729
- this.dispatchChange(e), e.stopImmediatePropagation();
730
- }}
731
- ${c(this.inputRefTo)}
732
- />
733
- <button
734
- class="${k(S.getButtonClasses())}"
735
- type="button"
736
- @click=${(e) => this.dispatchToggleCalendar(e)}
737
- @keydown=${(e) => x.handleButtonKeydown(e, (s) => this.dispatchToggleCalendar(s))}
738
- ?disabled=${this.disabled}
739
- ${c(this.btnRef)}
740
- >
741
- <pkt-icon name="calendar"></pkt-icon>
742
- <span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
743
- </button>
744
- </div>
745
- `;
746
- }
747
- };
748
- b([
749
- a({ type: Array })
750
- ], m.prototype, "value", 2);
751
- b([
752
- a({ type: String })
753
- ], m.prototype, "inputType", 2);
754
- b([
755
- a({ type: String })
756
- ], m.prototype, "id", 2);
757
- b([
758
- a({ type: String })
759
- ], m.prototype, "min", 2);
760
- b([
761
- a({ type: String })
762
- ], m.prototype, "max", 2);
763
- b([
764
- a({ type: String })
765
- ], m.prototype, "placeholder", 2);
766
- b([
767
- a({ type: Boolean })
768
- ], m.prototype, "readonly", 2);
769
- b([
770
- a({ type: Boolean })
771
- ], m.prototype, "disabled", 2);
772
- b([
773
- a({ type: Boolean })
774
- ], m.prototype, "showRangeLabels", 2);
775
- b([
776
- a({ type: Object })
777
- ], m.prototype, "inputClasses", 2);
778
- b([
779
- a({ type: Object })
780
- ], m.prototype, "internals", 2);
781
- b([
782
- a({ type: Object })
783
- ], m.prototype, "strings", 2);
784
- m = b([
785
- R("pkt-datepicker-range")
786
- ], m);
787
- var dt = Object.defineProperty, ct = Object.getOwnPropertyDescriptor, $ = (t, e, s, n) => {
788
- for (var i = n > 1 ? void 0 : n ? ct(e, s) : e, l = t.length - 1, r; l >= 0; l--)
789
- (r = t[l]) && (i = (n ? r(e, s, i) : r(i)) || i);
790
- return n && i && dt(e, s, i), i;
791
- };
792
- let f = class extends I {
793
- constructor() {
794
- super(...arguments), this.value = [], this.inputType = "date", this.id = "", this.readonly = !1, this.disabled = !1, this.inputClasses = {}, this.strings = { calendar: { buttonAltText: "Åpne kalender" } }, this.inputRef = u(), this.btnRef = u();
795
- }
796
- get inputElement() {
797
- return this.inputRef.value;
798
- }
799
- get buttonElement() {
800
- return this.btnRef.value;
801
- }
802
- get isInputReadonly() {
803
- return this.readonly || this.inputType === "text";
804
- }
805
- get isInputDisabled() {
806
- return this.disabled || this.maxlength !== void 0 && this.maxlength !== null && this.value.length >= this.maxlength;
807
- }
808
- dispatchToggleCalendar(t) {
809
- this.readonly || this.dispatchEvent(
810
- new CustomEvent("toggle-calendar", {
811
- detail: t,
812
- bubbles: !0,
813
- composed: !0
814
- })
815
- );
816
- }
817
- dispatchInput(t) {
818
- this.dispatchEvent(
819
- new CustomEvent("input-change", {
820
- detail: t,
821
- bubbles: !0,
822
- composed: !0
823
- })
824
- );
825
- }
826
- dispatchFocus() {
827
- this.dispatchEvent(
828
- new CustomEvent("input-focus", {
829
- bubbles: !0,
830
- composed: !0
831
- })
832
- );
833
- }
834
- dispatchBlur(t) {
835
- this.dispatchEvent(
836
- new CustomEvent("input-blur", {
837
- detail: t,
838
- bubbles: !0,
839
- composed: !0
840
- })
841
- );
842
- }
843
- dispatchChange(t) {
844
- this.dispatchEvent(
845
- new CustomEvent("input-changed", {
846
- detail: t,
847
- bubbles: !0,
848
- composed: !0
849
- })
850
- );
851
- }
852
- dispatchAddToSelected(t) {
853
- this.dispatchEvent(
854
- new CustomEvent("add-to-selected", {
855
- detail: t,
856
- bubbles: !0,
857
- composed: !0
858
- })
859
- );
860
- }
861
- createRenderRoot() {
862
- return this;
863
- }
864
- render() {
865
- return d`
866
- <div class="pkt-input__container">
867
- <input
868
- class=${k(this.inputClasses)}
869
- .type=${this.inputType}
870
- id="${this.id}-input"
871
- min=${C(this.min)}
872
- max=${C(this.max)}
873
- placeholder=${C(this.placeholder)}
874
- ?readonly=${this.isInputReadonly}
875
- ?disabled=${this.isInputDisabled}
876
- @click=${(t) => {
877
- t.preventDefault(), this.dispatchToggleCalendar(t);
878
- }}
879
- @touchend=${(t) => {
880
- t.preventDefault(), this.dispatchToggleCalendar(t);
881
- }}
882
- @blur=${(t) => {
883
- this.dispatchBlur(t), this.dispatchAddToSelected(t);
884
- }}
885
- @input=${(t) => {
886
- this.dispatchInput(t), t.stopImmediatePropagation();
887
- }}
888
- @focus=${() => {
889
- this.dispatchFocus(), E() && this.dispatchToggleCalendar(new Event("focus"));
890
- }}
891
- @keydown=${(t) => x.handleInputKeydown(
892
- t,
893
- (e) => this.dispatchToggleCalendar(e),
894
- () => D.submitFormOrFallback(this.internals, () => {
895
- var e;
896
- return (e = this.inputRef.value) == null ? void 0 : e.blur();
897
- }),
898
- void 0,
899
- void 0,
900
- (e) => this.dispatchAddToSelected(e)
901
- )}
902
- @change=${(t) => {
903
- this.dispatchChange(t), t.stopImmediatePropagation();
904
- }}
905
- ${c(this.inputRef)}
906
- />
907
- <button
908
- class="${k(S.getButtonClasses())}"
909
- type="button"
910
- @click=${(t) => this.dispatchToggleCalendar(t)}
911
- @keydown=${(t) => x.handleButtonKeydown(t, (e) => this.dispatchToggleCalendar(e))}
912
- ?disabled=${this.disabled}
913
- ${c(this.btnRef)}
914
- >
915
- <pkt-icon name="calendar"></pkt-icon>
916
- <span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
917
- </button>
918
- </div>
919
- `;
920
- }
921
- };
922
- $([
923
- a({ type: Array })
924
- ], f.prototype, "value", 2);
925
- $([
926
- a({ type: String })
927
- ], f.prototype, "inputType", 2);
928
- $([
929
- a({ type: String })
930
- ], f.prototype, "id", 2);
931
- $([
932
- a({ type: String })
933
- ], f.prototype, "min", 2);
934
- $([
935
- a({ type: String })
936
- ], f.prototype, "max", 2);
937
- $([
938
- a({ type: String })
939
- ], f.prototype, "placeholder", 2);
940
- $([
941
- a({ type: Boolean })
942
- ], f.prototype, "readonly", 2);
943
- $([
944
- a({ type: Boolean })
945
- ], f.prototype, "disabled", 2);
946
- $([
947
- a({ type: Number })
948
- ], f.prototype, "maxlength", 2);
949
- $([
950
- a({ type: Object })
951
- ], f.prototype, "inputClasses", 2);
952
- $([
953
- a({ type: Object })
954
- ], f.prototype, "internals", 2);
955
- $([
956
- a({ type: Object })
957
- ], f.prototype, "strings", 2);
958
- f = $([
959
- R("pkt-datepicker-multiple")
960
- ], f);
961
- var gt = Object.defineProperty, mt = Object.getOwnPropertyDescriptor, o = (t, e, s, n) => {
962
- for (var i = n > 1 ? void 0 : n ? mt(e, s) : e, l = t.length - 1, r; l >= 0; l--)
963
- (r = t[l]) && (i = (n ? r(e, s, i) : r(i)) || i);
964
- return n && i && gt(e, s, i), i;
965
- };
966
- let p = class extends X {
967
- /**
968
- * Housekeeping / lifecycle methods
969
- */
970
- constructor() {
971
- super(), this._valueProperty = "", this.datepickerPopupRef = u(), 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.calendarOpen = !1, this.timezone = "Europe/Oslo", this.inputClasses = {}, this.calRef = u(), this.popupRef = u(), this.helptextSlot = u(), this.singleInputRef = u(), this.rangeInputRef = u(), this.multipleInputRef = u(), this.addToSelected = (t) => {
972
- const e = this.datepickerPopupRef.value;
973
- return e && typeof e.addToSelected == "function" ? e.addToSelected(t, this.min, this.max) : F.addToSelected(t, this.calRef, this.min, this.max);
974
- }, this.slotController = new et(this, this.helptextSlot);
975
- }
976
- get value() {
977
- return this._valueProperty;
978
- }
979
- set value(t) {
980
- const e = this._valueProperty;
981
- this._valueProperty = Array.isArray(t) ? t.join(",") : t || "", this.valueChanged(this._valueProperty, e), this.requestUpdate("value", e);
982
- }
983
- /**
984
- * Computed properties
985
- */
986
- get inputType() {
987
- return nt.getInputType();
988
- }
989
- connectedCallback() {
990
- super.connectedCallback(), this.timezone && this.timezone !== window.pktTz && (window.pktTz = this.timezone), this.name = B.normalizeNameForMultiple(this.name, this.multiple, this.range) || this.name;
991
- }
992
- disconnectedCallback() {
993
- super.disconnectedCallback();
994
- }
995
- onInput() {
996
- this.dispatchEvent(new Event("input", { bubbles: !0 }));
997
- }
998
- valueChanged(t, e) {
999
- if (t === e) return;
1000
- const s = O(t), n = this.multiple && s.length > 1 ? B.filterSelectableDates(
1001
- s,
1002
- this.min,
1003
- this.max,
1004
- this.excludedates,
1005
- this.excludeweekdays
1006
- ) : s;
1007
- if (this.range && !B.validateRangeOrder(n)) {
1008
- this._value = [], this._valueProperty = "", super.valueChanged("", e);
1009
- return;
1010
- }
1011
- this._value = n;
1012
- const i = G(n);
1013
- this._valueProperty !== i && (this._valueProperty = i), super.valueChanged(i, e);
1014
- }
1015
- attributeChangedCallback(t, e, s) {
1016
- t === "value" && this.value !== e && this.valueChanged(s, e), t === "excludedates" && typeof this.excludedates == "string" && (this.excludedates = O(s || "")), t === "excludeweekdays" && typeof this.excludeweekdays == "string" && (this.excludeweekdays = O(s || "")), super.attributeChangedCallback(t, e, s);
1017
- }
1018
- updated(t) {
1019
- if (t.has("value")) {
1020
- const e = Array.isArray(this.value) ? this.value.join(",") : this.value, s = t.get("value"), n = Array.isArray(s) ? s.join(",") : s;
1021
- this.valueChanged(e, n);
1022
- }
1023
- (t.has("multiple") || t.has("range")) && (this.name = B.normalizeNameForMultiple(this.name, this.multiple, this.range) || this.name), t.has("multiple") && (this.multiple && !Array.isArray(this._value) ? this._value = O(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(t);
1024
- }
1025
- /**
1026
- * Element references
1027
- */
1028
- // Override the inputRef and inputRefTo for compatibility
1029
- get inputRef() {
1030
- return { value: this.currentInputElement };
1031
- }
1032
- get inputRefTo() {
1033
- return { value: this.currentInputElementTo };
1034
- }
1035
- // Getters for backward compatibility with input refs
1036
- get currentInputElement() {
1037
- var t, e, s;
1038
- return this.multiple ? (t = this.multipleInputRef.value) == null ? void 0 : t.inputElement : this.range ? (e = this.rangeInputRef.value) == null ? void 0 : e.inputElement : (s = this.singleInputRef.value) == null ? void 0 : s.inputElement;
1039
- }
1040
- get currentInputElementTo() {
1041
- var t;
1042
- if (this.range)
1043
- return (t = this.rangeInputRef.value) == null ? void 0 : t.inputElementTo;
1044
- }
1045
- get currentButtonElement() {
1046
- var t, e, s;
1047
- return this.multiple ? (t = this.multipleInputRef.value) == null ? void 0 : t.buttonElement : this.range ? (e = this.rangeInputRef.value) == null ? void 0 : e.buttonElement : (s = this.singleInputRef.value) == null ? void 0 : s.buttonElement;
1048
- }
1049
- // Override btnRef for compatibility
1050
- get btnRef() {
1051
- return { value: this.currentButtonElement };
1052
- }
1053
- /**
1054
- * Rendering
1055
- */
1056
- renderInput() {
1057
- return d`
1058
- <pkt-datepicker-single
1059
- .value=${this._value[0] ?? ""}
1060
- .inputType=${this.inputType}
1061
- .id=${this.id}
1062
- .min=${this.min}
1063
- .max=${this.max}
1064
- .placeholder=${this.placeholder}
1065
- .readonly=${this.readonly}
1066
- .disabled=${this.disabled}
1067
- .inputClasses=${this.inputClasses}
1068
- .internals=${this.internals}
1069
- .strings=${this.strings}
1070
- @toggle-calendar=${(t) => this.toggleCalendar(t.detail)}
1071
- @input-change=${() => this.onInput()}
1072
- @input-focus=${() => this.onFocus()}
1073
- @input-blur=${(t) => {
1074
- var e;
1075
- (e = this.calRef.value) != null && e.contains(t.detail.relatedTarget) || this.onBlur();
1076
- }}
1077
- @manage-validity=${(t) => this.manageValidity(t.detail)}
1078
- @value-change=${(t) => {
1079
- this.value = t.detail;
1080
- }}
1081
- @input-changed=${() => {
1082
- this.touched = !0;
1083
- }}
1084
- ${c(this.singleInputRef)}
1085
- ></pkt-datepicker-single>
1086
- `;
1087
- }
1088
- renderRangeInput() {
1089
- return d`
1090
- <pkt-datepicker-range
1091
- .value=${this._value}
1092
- .inputType=${this.inputType}
1093
- .id=${this.id}
1094
- .min=${this.min}
1095
- .max=${this.max}
1096
- .placeholder=${this.placeholder}
1097
- .readonly=${this.readonly}
1098
- .disabled=${this.disabled}
1099
- .showRangeLabels=${this.showRangeLabels}
1100
- .inputClasses=${this.inputClasses}
1101
- .internals=${this.internals}
1102
- .strings=${this.strings}
1103
- @toggle-calendar=${(t) => this.toggleCalendar(t.detail)}
1104
- @input-change=${() => this.onInput()}
1105
- @input-focus=${() => this.onFocus()}
1106
- @input-blur=${(t) => {
1107
- var e;
1108
- (e = this.calRef.value) != null && e.contains(t.detail.relatedTarget) || this.onBlur();
1109
- }}
1110
- @range-blur=${(t) => {
1111
- M.processRangeBlur(
1112
- t.detail.event,
1113
- t.detail.values,
1114
- this.calRef,
1115
- () => this.clearInputValue(),
1116
- (e) => this.manageValidity(e)
1117
- );
1118
- }}
1119
- @manage-validity=${(t) => this.manageValidity(t.detail)}
1120
- @validate-date-input=${(t) => {
1121
- D.validateDateInput(t.detail, this.internals, this.min, this.max, this.strings);
1122
- }}
1123
- @handle-date-select=${(t) => {
1124
- var s, n;
1125
- const e = L(t.detail);
1126
- e && this._value[1] !== J(e) && ((n = (s = this.calRef) == null ? void 0 : s.value) == null || n.handleDateSelect(e));
1127
- }}
1128
- @input-changed=${() => {
1129
- this.touched = !0;
1130
- }}
1131
- ${c(this.rangeInputRef)}
1132
- ></pkt-datepicker-range>
1133
- `;
1134
- }
1135
- renderMultipleInput() {
1136
- return d`
1137
- <pkt-datepicker-multiple
1138
- .value=${this._value}
1139
- .inputType=${this.inputType}
1140
- .id=${this.id}
1141
- .min=${this.min}
1142
- .max=${this.max}
1143
- .placeholder=${this.placeholder}
1144
- .readonly=${this.readonly}
1145
- .disabled=${this.disabled}
1146
- .maxlength=${this.maxlength}
1147
- .inputClasses=${this.inputClasses}
1148
- .internals=${this.internals}
1149
- .strings=${this.strings}
1150
- @toggle-calendar=${(t) => this.toggleCalendar(t.detail)}
1151
- @input-change=${() => this.onInput()}
1152
- @input-focus=${() => this.onFocus()}
1153
- @input-blur=${(t) => {
1154
- var e;
1155
- (e = this.calRef.value) != null && e.contains(t.detail.relatedTarget) || this.onBlur();
1156
- }}
1157
- @add-to-selected=${(t) => this.addToSelected(t.detail)}
1158
- @input-changed=${() => {
1159
- this.touched = !0;
1160
- }}
1161
- ${c(this.multipleInputRef)}
1162
- ></pkt-datepicker-multiple>
1163
- `;
1164
- }
1165
- renderCalendar() {
1166
- return d`
1167
- <pkt-datepicker-popup
1168
- class="pkt-contents"
1169
- ?open=${this.calendarOpen}
1170
- ?multiple=${this.multiple}
1171
- ?range=${this.range}
1172
- ?weeknumbers=${this.weeknumbers}
1173
- ?withcontrols=${this.withcontrols}
1174
- .maxMultiple=${this.maxlength}
1175
- .selected=${this._value}
1176
- .earliest=${this.min}
1177
- .latest=${this.max}
1178
- .excludedates=${Array.isArray(this.excludedates) ? this.excludedates : this.excludedates.split(",")}
1179
- .excludeweekdays=${this.excludeweekdays}
1180
- .currentmonth=${this.currentmonth ? Q(this.currentmonth) : null}
1181
- @date-selected=${(t) => {
1182
- this.value = M.processDateSelection(t.detail, this.multiple, this.range), this._value = t.detail, M.updateInputValues(
1183
- this.inputRef,
1184
- this.inputRefTo,
1185
- this._value,
1186
- this.range,
1187
- this.multiple,
1188
- (e) => this.manageValidity(e)
1189
- );
1190
- }}
1191
- @close=${() => {
1192
- this.onBlur(), this.hideCalendar();
1193
- }}
1194
- ${c(this.datepickerPopupRef)}
1195
- ></pkt-datepicker-popup>
1196
- `;
1197
- }
1198
- render() {
1199
- return this.inputClasses = S.getInputClasses(
1200
- this.fullwidth,
1201
- this.showRangeLabels,
1202
- this.multiple,
1203
- this.range,
1204
- this.readonly,
1205
- this.inputType
1206
- ), d`
1207
- <pkt-input-wrapper
1208
- label="${this.label}"
1209
- forId="${this.id}-input"
1210
- ?counter=${this.multiple && !!this.maxlength}
1211
- .counterCurrent=${this.value ? this._value.length : 0}
1212
- .counterMaxLength=${this.maxlength}
1213
- ?disabled=${this.disabled}
1214
- ?hasError=${this.hasError}
1215
- ?hasFieldset=${this.hasFieldset}
1216
- ?inline=${this.inline}
1217
- ?required=${this.required}
1218
- ?optionalTag=${this.optionalTag}
1219
- ?requiredTag=${this.requiredTag}
1220
- useWrapper=${this.useWrapper}
1221
- .optionalText=${this.optionalText}
1222
- .requiredText=${this.requiredText}
1223
- .tagText=${this.tagText}
1224
- .errorMessage=${this.errorMessage}
1225
- .helptext=${this.helptext}
1226
- .helptextDropdown=${this.helptextDropdown}
1227
- .helptextDropdownButton=${this.helptextDropdownButton}
1228
- .ariaDescribedBy=${this.ariaDescribedBy}
1229
- class="pkt-datepicker"
1230
- >
1231
- <div class="pkt-contents" ${c(this.helptextSlot)} name="helptext" slot="helptext"></div>
1232
- ${this.multiple ? d`<pkt-date-tags
1233
- .dates=${this._value}
1234
- dateformat=${this.dateformat}
1235
- strings=${this.strings}
1236
- id-base=${this.id}
1237
- @date-tag-removed=${(t) => {
1238
- var n;
1239
- const e = this.datepickerPopupRef.value, s = L(t.detail);
1240
- e && s && typeof e.handleDateSelect == "function" ? e.handleDateSelect(s) : (n = this.calRef.value) == null || n.handleDateSelect(s);
1241
- }}
1242
- ></pkt-date-tags>` : A}
1243
- <div
1244
- class="pkt-datepicker__inputs ${this.range && this.showRangeLabels ? "pkt-input__range-inputs" : ""}"
1245
- >
1246
- ${this.range ? this.renderRangeInput() : this.multiple ? this.renderMultipleInput() : this.renderInput()}
1247
- </div>
1248
- </pkt-input-wrapper>
1249
- ${this.renderCalendar()}
1250
- `;
1251
- }
1252
- /**
1253
- * Handlers
1254
- */
1255
- handleCalendarPosition() {
1256
- const t = this.multiple && !!this.maxlength;
1257
- F.handleCalendarPosition(this.popupRef, this.inputRef, t);
1258
- }
1259
- async showCalendar() {
1260
- var e;
1261
- const t = this.datepickerPopupRef.value;
1262
- if (this.calendarOpen = !0, t && typeof t.show == "function") {
1263
- t.show(), E() && t.focusOnCurrentDate();
1264
- return;
1265
- }
1266
- await tt(20), this.handleCalendarPosition(), E() && ((e = this.calRef.value) == null || e.focusOnCurrentDate());
1267
- }
1268
- hideCalendar() {
1269
- const t = this.datepickerPopupRef.value;
1270
- if (this.calendarOpen = !1, t && typeof t.hide == "function") return t.hide();
1271
- }
1272
- async toggleCalendar(t) {
1273
- t.preventDefault();
1274
- const e = this.datepickerPopupRef.value;
1275
- if (e && typeof e.toggle == "function") {
1276
- const s = !!e.open;
1277
- e.toggle(), this.calendarOpen = !s;
1278
- return;
1279
- }
1280
- this.calendarOpen ? this.hideCalendar() : this.showCalendar();
1281
- }
1282
- clearInputValue() {
1283
- this._value = [], this.value = "", this.internals.setFormValue(this.value), this.dispatchEvent(new Event("change", { bubbles: !0, composed: !0 })), this.dispatchEvent(
1284
- new CustomEvent("value-change", {
1285
- detail: this._value,
1286
- bubbles: !0,
1287
- composed: !0
1288
- })
1289
- );
1290
- }
1291
- };
1292
- o([
1293
- a({ type: String, reflect: !0 })
1294
- ], p.prototype, "value", 1);
1295
- o([
1296
- a({ type: Array })
1297
- ], p.prototype, "_value", 2);
1298
- o([
1299
- a({ type: String, reflect: !0 })
1300
- ], p.prototype, "label", 2);
1301
- o([
1302
- a({ type: String })
1303
- ], p.prototype, "dateformat", 2);
1304
- o([
1305
- a({ type: Boolean, reflect: !0 })
1306
- ], p.prototype, "multiple", 2);
1307
- o([
1308
- a({ type: Number, reflect: !0 })
1309
- ], p.prototype, "maxlength", 2);
1310
- o([
1311
- a({ type: Boolean, reflect: !0 })
1312
- ], p.prototype, "range", 2);
1313
- o([
1314
- a({ type: Boolean })
1315
- ], p.prototype, "showRangeLabels", 2);
1316
- o([
1317
- a({ type: String, reflect: !0 })
1318
- ], p.prototype, "min", 2);
1319
- o([
1320
- a({ type: String, reflect: !0 })
1321
- ], p.prototype, "max", 2);
1322
- o([
1323
- a({ type: Boolean })
1324
- ], p.prototype, "weeknumbers", 2);
1325
- o([
1326
- a({ type: Boolean, reflect: !0 })
1327
- ], p.prototype, "withcontrols", 2);
1328
- o([
1329
- a({ converter: z.csvToArray })
1330
- ], p.prototype, "excludedates", 2);
1331
- o([
1332
- a({ converter: z.csvToArray })
1333
- ], p.prototype, "excludeweekdays", 2);
1334
- o([
1335
- a({ type: String })
1336
- ], p.prototype, "currentmonth", 2);
1337
- o([
1338
- a({ type: Boolean, reflect: !0 })
1339
- ], p.prototype, "calendarOpen", 2);
1340
- o([
1341
- a({ type: String })
1342
- ], p.prototype, "timezone", 2);
1343
- o([
1344
- q()
1345
- ], p.prototype, "inputClasses", 2);
1346
- p = o([
1347
- R("pkt-datepicker")
1348
- ], p);
1349
- export {
1350
- T as P,
1351
- p as a,
1352
- y as b,
1353
- m as c,
1354
- f as d
1355
- };