@oslokommune/punkt-elements 12.5.0 → 12.5.1

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.
@@ -1,9 +1,9 @@
1
- import { r as b, P as $, x as f, E as w, n as c } from "./index-CsTujnXs.js";
1
+ import { r as k, P as $, x as y, E as v, n as c } from "./index-CsTujnXs.js";
2
2
  import { a as S } from "./converters-DNCwIFwr.js";
3
- import { t as _ } from "./directive-Cxhakbpr.js";
4
- import { e as A } from "./class-map-DunDFQn7.js";
3
+ import { t as A } from "./directive-Cxhakbpr.js";
4
+ import { e as _ } from "./class-map-DunDFQn7.js";
5
5
  import "./index-CyqOyy_9.js";
6
- function k(e) {
6
+ function D(e) {
7
7
  const t = Object.prototype.toString.call(e);
8
8
  return e instanceof Date || typeof e == "object" && t === "[object Date]" ? new e.constructor(+e) : typeof e == "number" || t === "[object Number]" || typeof e == "string" || t === "[object String]" ? new Date(e) : /* @__PURE__ */ new Date(NaN);
9
9
  }
@@ -15,45 +15,45 @@ let T = {};
15
15
  function O() {
16
16
  return T;
17
17
  }
18
- function v(e, t) {
19
- var p, h, u, d;
20
- const s = O(), n = (t == null ? void 0 : t.weekStartsOn) ?? ((h = (p = t == null ? void 0 : t.locale) == null ? void 0 : p.options) == null ? void 0 : h.weekStartsOn) ?? s.weekStartsOn ?? ((d = (u = s.locale) == null ? void 0 : u.options) == null ? void 0 : d.weekStartsOn) ?? 0, i = k(e), o = i.getDay(), a = (o < n ? 7 : 0) + o - n;
18
+ function b(e, t) {
19
+ var d, h, f, u;
20
+ const s = O(), n = (t == null ? void 0 : t.weekStartsOn) ?? ((h = (d = t == null ? void 0 : t.locale) == null ? void 0 : d.options) == null ? void 0 : h.weekStartsOn) ?? s.weekStartsOn ?? ((u = (f = s.locale) == null ? void 0 : f.options) == null ? void 0 : u.weekStartsOn) ?? 0, i = D(e), o = i.getDay(), a = (o < n ? 7 : 0) + o - n;
21
21
  return i.setDate(i.getDate() - a), i.setHours(0, 0, 0, 0), i;
22
22
  }
23
23
  function x(e, t) {
24
- const s = k(e.start), n = k(e.end);
24
+ const s = D(e.start), n = D(e.end);
25
25
  let i = +s > +n;
26
26
  const o = i ? +s : +n, a = i ? n : s;
27
27
  a.setHours(0, 0, 0, 0);
28
- let p = 1;
28
+ let d = 1;
29
29
  const h = [];
30
30
  for (; +a <= o; )
31
- h.push(k(a)), a.setDate(a.getDate() + p), a.setHours(0, 0, 0, 0);
31
+ h.push(D(a)), a.setDate(a.getDate() + d), a.setHours(0, 0, 0, 0);
32
32
  return i ? h.reverse() : h;
33
33
  }
34
34
  function C(e, t) {
35
- var d, y, m, D;
36
- const s = k(e), n = s.getFullYear(), i = O(), o = (t == null ? void 0 : t.firstWeekContainsDate) ?? ((y = (d = t == null ? void 0 : t.locale) == null ? void 0 : d.options) == null ? void 0 : y.firstWeekContainsDate) ?? i.firstWeekContainsDate ?? ((D = (m = i.locale) == null ? void 0 : m.options) == null ? void 0 : D.firstWeekContainsDate) ?? 1, a = M(e, 0);
35
+ var u, p, m, w;
36
+ const s = D(e), n = s.getFullYear(), i = O(), o = (t == null ? void 0 : t.firstWeekContainsDate) ?? ((p = (u = t == null ? void 0 : t.locale) == null ? void 0 : u.options) == null ? void 0 : p.firstWeekContainsDate) ?? i.firstWeekContainsDate ?? ((w = (m = i.locale) == null ? void 0 : m.options) == null ? void 0 : w.firstWeekContainsDate) ?? 1, a = M(e, 0);
37
37
  a.setFullYear(n + 1, 0, o), a.setHours(0, 0, 0, 0);
38
- const p = v(a, t), h = M(e, 0);
38
+ const d = b(a, t), h = M(e, 0);
39
39
  h.setFullYear(n, 0, o), h.setHours(0, 0, 0, 0);
40
- const u = v(h, t);
41
- return s.getTime() >= p.getTime() ? n + 1 : s.getTime() >= u.getTime() ? n : n - 1;
40
+ const f = b(h, t);
41
+ return s.getTime() >= d.getTime() ? n + 1 : s.getTime() >= f.getTime() ? n : n - 1;
42
42
  }
43
43
  function E(e, t) {
44
- var p, h, u, d;
45
- const s = O(), n = (t == null ? void 0 : t.firstWeekContainsDate) ?? ((h = (p = t == null ? void 0 : t.locale) == null ? void 0 : p.options) == null ? void 0 : h.firstWeekContainsDate) ?? s.firstWeekContainsDate ?? ((d = (u = s.locale) == null ? void 0 : u.options) == null ? void 0 : d.firstWeekContainsDate) ?? 1, i = C(e, t), o = M(e, 0);
46
- return o.setFullYear(i, 0, n), o.setHours(0, 0, 0, 0), v(o, t);
44
+ var d, h, f, u;
45
+ const s = O(), n = (t == null ? void 0 : t.firstWeekContainsDate) ?? ((h = (d = t == null ? void 0 : t.locale) == null ? void 0 : d.options) == null ? void 0 : h.firstWeekContainsDate) ?? s.firstWeekContainsDate ?? ((u = (f = s.locale) == null ? void 0 : f.options) == null ? void 0 : u.firstWeekContainsDate) ?? 1, i = C(e, t), o = M(e, 0);
46
+ return o.setFullYear(i, 0, n), o.setHours(0, 0, 0, 0), b(o, t);
47
47
  }
48
48
  function H(e, t) {
49
- const s = k(e), n = +v(s, t) - +E(s, t);
49
+ const s = D(e), n = +b(s, t) - +E(s, t);
50
50
  return Math.round(n / I) + 1;
51
51
  }
52
52
  function R(e) {
53
- let s = k(e).getDay();
53
+ let s = D(e).getDay();
54
54
  return s === 0 && (s = 7), s;
55
55
  }
56
- const N = "pkt-calendar", W = {
56
+ const N = "pkt-calendar", P = {
57
57
  id: {
58
58
  type: "string",
59
59
  name: "ID",
@@ -130,15 +130,15 @@ const N = "pkt-calendar", W = {
130
130
  default: !1,
131
131
  description: "Allow date range selection"
132
132
  }
133
- }, P = {
133
+ }, W = {
134
134
  "date-selected": {
135
135
  description: "Returns ISO formatted date string"
136
136
  }
137
137
  }, g = {
138
138
  name: N,
139
139
  "css-class": "pkt-calendar",
140
- props: W,
141
- events: P
140
+ props: P,
141
+ events: W
142
142
  };
143
143
  var Y = Object.defineProperty, F = Object.getOwnPropertyDescriptor, l = (e, t, s, n) => {
144
144
  for (var i = n > 1 ? void 0 : n ? F(t, s) : t, o = e.length - 1, a; o >= 0; o--)
@@ -147,7 +147,7 @@ var Y = Object.defineProperty, F = Object.getOwnPropertyDescriptor, l = (e, t, s
147
147
  };
148
148
  let r = class extends $ {
149
149
  constructor() {
150
- super(...arguments), this.multiple = g.props.multiple.default, this.maxMultiple = g.props.maxMultiple.default, this.range = g.props.range.default, this.weeknumbers = g.props.weeknumbers.default, this.withcontrols = g.props.withcontrols.default, this.selected = [], this.earliest = g.props.earliest.default, this.latest = g.props.latest.default, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = null, this.dayStrings = this.strings.dates.daysShort, this.monthStrings = this.strings.dates.months, this.weekString = this.strings.dates.week, this.prevMonthString = this.strings.dates.prevMonth, this.nextMonthString = this.strings.dates.nextMonth, this._selected = [], this.year = 0, this.month = 0, this.week = 0, this.rangeHovered = null, this.inRange = {}, this.focusedDate = null, this.selectableDates = [], this.currentmonthtouched = !1;
150
+ super(...arguments), this.multiple = g.props.multiple.default, this.maxMultiple = g.props.maxMultiple.default, this.range = g.props.range.default, this.weeknumbers = g.props.weeknumbers.default, this.withcontrols = g.props.withcontrols.default, this.selected = [], this.earliest = g.props.earliest.default, this.latest = g.props.latest.default, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = null, this.dayStrings = this.strings.dates.daysShort, this.monthStrings = this.strings.dates.months, this.weekString = this.strings.dates.week, this.prevMonthString = this.strings.dates.prevMonth, this.nextMonthString = this.strings.dates.nextMonth, this._selected = [], this.year = 0, this.month = 0, this.week = 0, this.rangeHovered = null, this.inRange = {}, this.focusedDate = null, this.selectableDates = [], this.currentmonthtouched = !1, this.tabIndexSet = 0;
151
151
  }
152
152
  /**
153
153
  * Runs on mount, used to set up various values and whatever you need to run
@@ -164,6 +164,9 @@ let r = class extends $ {
164
164
  updated(e) {
165
165
  e.has("selected") && this.convertSelected(), super.updated(e);
166
166
  }
167
+ firstUpdated(e) {
168
+ this.addEventListener("keydown", this.handleKeydown);
169
+ }
167
170
  convertSelected() {
168
171
  if (typeof this.selected == "string" && (this.selected = this.selected.split(",")), this.selected.length === 1 && this.selected[0] === "" && (this.selected = []), this._selected = this.selected.map((e) => new Date(e)), this.range && this.selected.length === 2) {
169
172
  const e = x({
@@ -203,8 +206,8 @@ let r = class extends $ {
203
206
  }
204
207
  }
205
208
  handleArrowKey(e, t) {
206
- if (e.preventDefault(), !this.focusedDate) return;
207
- const s = new Date(this.focusedDate);
209
+ e.preventDefault(), this.focusedDate || this.focusOnCurrentDate();
210
+ const s = this.focusedDate ? new Date(this.focusedDate) : new Date(this.year, this.month, 1);
208
211
  let n = new Date(s.setDate(s.getDate() + t));
209
212
  if (n) {
210
213
  let i = this.querySelector(`div[data-date="${this.formatISODate(n)}"]`);
@@ -215,7 +218,7 @@ let r = class extends $ {
215
218
  o = new Date(o.setDate(o.getDate() + t)), a = this.querySelector(`div[data-date="${this.formatISODate(o)}"]`);
216
219
  i = a;
217
220
  }
218
- i instanceof HTMLDivElement && !i.dataset.disabled && i.focus();
221
+ i instanceof HTMLDivElement && !i.dataset.disabled && (this.focusedDate = this.formatISODate(n), i.focus());
219
222
  }
220
223
  }
221
224
  }
@@ -223,41 +226,45 @@ let r = class extends $ {
223
226
  * Component functionality and render
224
227
  */
225
228
  render() {
226
- return f`
229
+ return y`
227
230
  <div
228
- class="pkt-calendar ${this.weeknumbers ? "pkt-cal-weeknumbers" : w}"
231
+ class="pkt-calendar ${this.weeknumbers ? "pkt-cal-weeknumbers" : v}"
229
232
  @focusout=${this.closeEvent}
230
233
  @keydown=${(e) => {
231
234
  e.key === "Escape" && (e.preventDefault(), this.close());
232
235
  }}
233
236
  >
234
237
  <nav class="pkt-cal-month-nav">
235
- <div
236
- @click=${this.isPrevMonthAllowed() && this.prevMonth}
237
- @keydown=${(e) => {
238
+ <div>
239
+ <div
240
+ @click=${this.isPrevMonthAllowed() && this.prevMonth}
241
+ @keydown=${(e) => {
238
242
  (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.isNextMonthAllowed() && this.prevMonth());
239
243
  }}
240
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
241
- .data-disabled=${this.isPrevMonthAllowed() ? w : "disabled"}
242
- ?aria-disabled=${!this.isPrevMonthAllowed()}
243
- tabindex="0"
244
- >
245
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
246
- <span class="pkt-btn__text">${this.prevMonthString}</span>
244
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isPrevMonthAllowed() ? "" : "pkt-hide"}"
245
+ .data-disabled=${this.isPrevMonthAllowed() ? v : "disabled"}
246
+ ?aria-disabled=${!this.isPrevMonthAllowed()}
247
+ tabindex=${this.isPrevMonthAllowed() ? "0" : "-1"}
248
+ >
249
+ <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
250
+ <span class="pkt-btn__text">${this.prevMonthString}</span>
251
+ </div>
247
252
  </div>
248
253
  ${this.renderMonthNav()}
249
- <div
250
- @click=${this.isNextMonthAllowed() && this.nextMonth}
251
- @keydown=${(e) => {
254
+ <div>
255
+ <div
256
+ @click=${this.isNextMonthAllowed() && this.nextMonth}
257
+ @keydown=${(e) => {
252
258
  (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.isNextMonthAllowed() && this.nextMonth());
253
259
  }}
254
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
255
- .data-disabled=${this.isNextMonthAllowed() ? w : "disabled"}
256
- ?aria-disabled=${!this.isNextMonthAllowed()}
257
- tabindex="0"
258
- >
259
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
260
- <span class="pkt-btn__text">${this.nextMonthString}</span>
260
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isNextMonthAllowed() ? "" : "pkt-hide"}"
261
+ .data-disabled=${this.isNextMonthAllowed() ? v : "disabled"}
262
+ ?aria-disabled=${!this.isNextMonthAllowed()}
263
+ tabindex=${this.isNextMonthAllowed() ? "0" : "-1"}
264
+ >
265
+ <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
266
+ <span class="pkt-btn__text">${this.nextMonthString}</span>
267
+ </div>
261
268
  </div>
262
269
  </nav>
263
270
  <table
@@ -272,17 +279,17 @@ let r = class extends $ {
272
279
  }
273
280
  renderDayNames() {
274
281
  const e = [];
275
- this.weeknumbers && e.push(f`<td><div>${this.weekString}<div></td>`);
282
+ this.weeknumbers && e.push(y`<td><div>${this.weekString}<div></td>`);
276
283
  for (let t = 0; t < this.dayStrings.length; t++)
277
- e.push(f`<td><div>${this.dayStrings[t]}</div></td>`);
278
- return f`<tr class="pkt-cal-week-row" role="presentation">
284
+ e.push(y`<td><div>${this.dayStrings[t]}</div></td>`);
285
+ return y`<tr class="pkt-cal-week-row" role="presentation">
279
286
  ${e}
280
287
  </tr>`;
281
288
  }
282
289
  renderMonthNav() {
283
290
  let e = [];
284
291
  return this.withcontrols ? e.push(
285
- f`<div class="pkt-cal-month-picker">
292
+ y`<div class="pkt-cal-month-picker">
286
293
  <select
287
294
  class="pkt-input pkt-input-compact"
288
295
  @change=${(t) => {
@@ -290,7 +297,7 @@ let r = class extends $ {
290
297
  }}
291
298
  >
292
299
  ${this.monthStrings.map(
293
- (t, s) => f`<option value=${s} ?selected=${this.month === s}>${t}</option>`
300
+ (t, s) => y`<option value=${s} ?selected=${this.month === s}>${t}</option>`
294
301
  )}
295
302
  </select>
296
303
  <input
@@ -305,15 +312,16 @@ let r = class extends $ {
305
312
  />
306
313
  </div> `
307
314
  ) : e.push(
308
- f`<div class="pkt-txt-16-medium" aria-live="polite">
315
+ y`<div class="pkt-txt-16-medium" aria-live="polite">
309
316
  ${this.monthStrings[this.month]} ${this.year}
310
317
  </div>`
311
318
  ), e;
312
319
  }
313
320
  renderDayView(e, t, s) {
314
- const n = new Date(this.year, this.month, e, 12), i = this.formatISODate(n), o = i === this.formatISODate(t), a = this.selected.includes(i), p = this.isExcluded(s, n) || !a && this.multiple && this.maxMultiple > 0 && this.selected.length >= this.maxMultiple, h = this.focusedDate ? this.focusedDate === i ? "0" : "-1" : e === 1 ? "0" : "-1";
315
- this.selectableDates.push({ currentDateISO: i, isDisabled: p });
316
- const u = {
321
+ var u;
322
+ const n = new Date(this.year, this.month, e, 12), i = this.formatISODate(n), o = i === this.formatISODate(t), a = this.selected.includes(i), d = this.isExcluded(s, n) || !a && this.multiple && this.maxMultiple > 0 && this.selected.length >= this.maxMultiple, h = this.focusedDate ? this.focusedDate === i && !d ? "0" : "-1" : !d && this.tabIndexSet === 0 || this.tabIndexSet === e ? "0" : "-1";
323
+ h === "0" && (this.tabIndexSet = e), this.selectableDates.push({ currentDateISO: i, isDisabled: d, tabindex: h });
324
+ const f = {
317
325
  "pkt-cal-today": o,
318
326
  "pkt-cal-selected": a,
319
327
  "pkt-cal-in-range": this.inRange[i],
@@ -322,7 +330,7 @@ let r = class extends $ {
322
330
  "pkt-cal-in-range-last": this.range && this.selected.length === 2 && i === this.selected[1],
323
331
  "pkt-cal-range-hover": this.rangeHovered !== null && i === this.formatISODate(this.rangeHovered)
324
332
  };
325
- return f`<td class=${A(u)}>
333
+ return y`<td class=${_(f)}>
326
334
  <div
327
335
  ?aria-selected=${a}
328
336
  role="gridcell"
@@ -331,14 +339,14 @@ let r = class extends $ {
331
339
  @focus=${() => {
332
340
  this.range && !this.isExcluded(s, n) && this.handleRangeHover(n), this.focusedDate = i;
333
341
  }}
334
- tabindex=${h}
335
- data-disabled=${p ? "disabled" : w}
342
+ tabindex=${(u = this.selectableDates.find((p) => p.currentDateISO === i)) == null ? void 0 : u.tabindex}
343
+ data-disabled=${d ? "disabled" : v}
336
344
  data-date=${i}
337
- @keydown=${(d) => {
338
- (d.key === "Enter" || d.key === " ") && (d.preventDefault(), this.handleDateSelect(n));
345
+ @keydown=${(p) => {
346
+ (p.key === "Enter" || p.key === " ") && (p.preventDefault(), this.handleDateSelect(n));
339
347
  }}
340
- @click=${(d) => {
341
- p || (d.preventDefault(), this.handleDateSelect(n));
348
+ @click=${(p) => {
349
+ d || (p.preventDefault(), this.handleDateSelect(n));
342
350
  }}
343
351
  >
344
352
  <span class="pkt-btn__text pkt-txt-14-light">${e}</span>
@@ -346,28 +354,28 @@ let r = class extends $ {
346
354
  </td>`;
347
355
  }
348
356
  renderCalendarBody() {
349
- const e = /* @__PURE__ */ new Date(), t = new Date(this.year, this.month, 1, 12), s = new Date(this.year, this.month + 1, 0, 12), n = (t.getDay() + 6) % 7, i = s.getDate(), o = Math.ceil((i + n) / 7), p = new Date(this.year, this.month, 0, 12).getDate();
357
+ const e = /* @__PURE__ */ new Date(), t = new Date(this.year, this.month, 1, 12), s = new Date(this.year, this.month + 1, 0, 12), n = (t.getDay() + 6) % 7, i = s.getDate(), o = Math.ceil((i + n) / 7), d = new Date(this.year, this.month, 0, 12).getDate();
350
358
  let h = 1;
351
359
  this.week = H(new Date(this.year, this.month, 1, 12));
352
- const u = [];
353
- for (let d = 0; d < o; d++) {
354
- const y = [];
355
- this.weeknumbers && y.push(f`<td class="pkt-cal-week">${this.week}</td>`), this.week++;
360
+ const f = [];
361
+ for (let u = 0; u < o; u++) {
362
+ const p = [];
363
+ this.weeknumbers && p.push(y`<td class="pkt-cal-week">${this.week}</td>`), this.week++;
356
364
  for (let m = 1; m < 8; m++)
357
- if (d === 0 && m < n + 1) {
358
- const D = p - (n - m);
359
- y.push(
360
- f`<td class="pkt-cal-other">
365
+ if (u === 0 && m < n + 1) {
366
+ const w = d - (n - m);
367
+ p.push(
368
+ y`<td class="pkt-cal-other">
361
369
  <div
362
370
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
363
371
  data-disabled="disabled"
364
372
  >
365
- <span class="pkt-btn__text pkt-txt-14-light">${D}</span>
373
+ <span class="pkt-btn__text pkt-txt-14-light">${w}</span>
366
374
  </div>
367
375
  </td>`
368
376
  );
369
- } else h > i ? (y.push(
370
- f`<td class="pkt-cal-other">
377
+ } else h > i ? (p.push(
378
+ y`<td class="pkt-cal-other">
371
379
  <div
372
380
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
373
381
  data-disabled="disabled"
@@ -375,14 +383,14 @@ let r = class extends $ {
375
383
  <span class="pkt-btn__text pkt-txt-14-light">${h - i}</span>
376
384
  </div>
377
385
  </td>`
378
- ), h++) : (y.push(this.renderDayView(h, e, m)), h++);
379
- u.push(
380
- f`<tr class="pkt-cal-week-row" role="row">
381
- ${y}
386
+ ), h++) : (p.push(this.renderDayView(h, e, m)), h++);
387
+ f.push(
388
+ y`<tr class="pkt-cal-week-row" role="row">
389
+ ${p}
382
390
  </tr>`
383
391
  );
384
392
  }
385
- return u;
393
+ return f;
386
394
  }
387
395
  isExcluded(e, t) {
388
396
  return this.excludeweekdays.includes(e.toString()) || this.earliest && t < new Date(this.earliest) || this.latest && t > new Date(this.latest) ? !0 : this.excludedates.some((s) => typeof s == "string" ? s === this.formatISODate(t) : s.toDateString() === t.toDateString());
@@ -407,7 +415,7 @@ let r = class extends $ {
407
415
  this.changeMonth(t, e);
408
416
  }
409
417
  changeMonth(e, t) {
410
- this.year = e, this.month = t, this.selectableDates = [], this.requestUpdate();
418
+ this.year = e, this.month = t, this.tabIndexSet = 0, this.focusedDate = null, this.selectableDates = [], this.requestUpdate();
411
419
  }
412
420
  isInRange(e) {
413
421
  if (this.range && this.selected.length === 2) {
@@ -479,14 +487,14 @@ let r = class extends $ {
479
487
  focusOnCurrentDate() {
480
488
  const e = this.formatISODate(/* @__PURE__ */ new Date()), t = this.querySelector(`div[data-date="${e}"]`);
481
489
  if (t instanceof HTMLDivElement)
482
- t.focus();
490
+ this.focusedDate = e, t.focus();
483
491
  else {
484
492
  const s = this.selectableDates.find((n) => !n.isDisabled);
485
493
  if (s) {
486
494
  const n = this.querySelector(
487
495
  `div[data-date="${s.currentDateISO}"]`
488
496
  );
489
- n instanceof HTMLDivElement && n.focus();
497
+ n instanceof HTMLDivElement && (this.focusedDate = s.currentDateISO, n.focus());
490
498
  }
491
499
  }
492
500
  }
@@ -567,19 +575,22 @@ l([
567
575
  c({ type: Date })
568
576
  ], r.prototype, "rangeHovered", 2);
569
577
  l([
570
- b()
578
+ k()
571
579
  ], r.prototype, "inRange", 2);
572
580
  l([
573
- b()
581
+ k()
574
582
  ], r.prototype, "focusedDate", 2);
575
583
  l([
576
- b()
584
+ k()
577
585
  ], r.prototype, "selectableDates", 2);
578
586
  l([
579
- b()
587
+ k()
580
588
  ], r.prototype, "currentmonthtouched", 2);
589
+ l([
590
+ k()
591
+ ], r.prototype, "tabIndexSet", 2);
581
592
  r = l([
582
- _("pkt-calendar")
593
+ A("pkt-calendar")
583
594
  ], r);
584
595
  export {
585
596
  r as P,
@@ -589,6 +600,6 @@ export {
589
600
  O as d,
590
601
  C as g,
591
602
  U as m,
592
- v as s,
593
- k as t
603
+ b as s,
604
+ D as t
594
605
  };
@@ -0,0 +1,94 @@
1
+ "use strict";const a=require("./index-DSyh6tUw.cjs"),v=require("./converters-DhM11VlY.cjs"),C=require("./directive-DtixNHDT.cjs"),$=require("./class-map-Ch54kkX5.cjs");require("./index-Bpc07w_P.cjs");function k(r){const e=Object.prototype.toString.call(r);return r instanceof Date||typeof r=="object"&&e==="[object Date]"?new r.constructor(+r):typeof r=="number"||e==="[object Number]"||typeof r=="string"||e==="[object String]"?new Date(r):new Date(NaN)}function D(r,e){return r instanceof Date?new r.constructor(e):new Date(e)}const S=6048e5,P=864e5;let A={};function w(){return A}function m(r,e){var c,h,d,p;const t=w(),s=(e==null?void 0:e.weekStartsOn)??((h=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:h.weekStartsOn)??t.weekStartsOn??((p=(d=t.locale)==null?void 0:d.options)==null?void 0:p.weekStartsOn)??0,n=k(r),i=n.getDay(),l=(i<s?7:0)+i-s;return n.setDate(n.getDate()-l),n.setHours(0,0,0,0),n}function b(r,e){const t=k(r.start),s=k(r.end);let n=+t>+s;const i=n?+t:+s,l=n?s:t;l.setHours(0,0,0,0);let c=1;const h=[];for(;+l<=i;)h.push(k(l)),l.setDate(l.getDate()+c),l.setHours(0,0,0,0);return n?h.reverse():h}function x(r,e){var p,f,u,y;const t=k(r),s=t.getFullYear(),n=w(),i=(e==null?void 0:e.firstWeekContainsDate)??((f=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:f.firstWeekContainsDate)??n.firstWeekContainsDate??((y=(u=n.locale)==null?void 0:u.options)==null?void 0:y.firstWeekContainsDate)??1,l=D(r,0);l.setFullYear(s+1,0,i),l.setHours(0,0,0,0);const c=m(l,e),h=D(r,0);h.setFullYear(s,0,i),h.setHours(0,0,0,0);const d=m(h,e);return t.getTime()>=c.getTime()?s+1:t.getTime()>=d.getTime()?s:s-1}function I(r,e){var c,h,d,p;const t=w(),s=(e==null?void 0:e.firstWeekContainsDate)??((h=(c=e==null?void 0:e.locale)==null?void 0:c.options)==null?void 0:h.firstWeekContainsDate)??t.firstWeekContainsDate??((p=(d=t.locale)==null?void 0:d.options)==null?void 0:p.firstWeekContainsDate)??1,n=x(r,e),i=D(r,0);return i.setFullYear(n,0,s),i.setHours(0,0,0,0),m(i,e)}function M(r,e){const t=k(r),s=+m(t,e)-+I(t,e);return Math.round(s/S)+1}function _(r){let t=k(r).getDay();return t===0&&(t=7),t}const E="pkt-calendar",T={id:{type:"string",name:"ID",description:"Unique identifier for the calendar"},currentmonth:{type:"date",converter:"stringToDate",description:"The current month to display"},selected:{type:"array",converter:"csvToArray",reflect:!0,items:{type:"date"},description:"Array of selected dates"},excludeweekdays:{type:"array",converter:"csvToArray",items:{type:"string"},description:"Array of weekdays (1-7) to exclude"},excludedates:{type:"array",converter:"stringsToDate",items:{type:"date"},description:"Array of specific dates to exclude"},earliest:{type:"date",converter:"stringToDate",default:null,description:"Earliest selectable date"},latest:{type:"date",converter:"stringToDate",default:null,description:"Latest selectable date"},weeknumbers:{type:"boolean",reflect:!0,default:!1,description:"Show week numbers in calendar"},withcontrols:{type:"boolean",reflect:!0,default:!1,description:"Show month and year navigation controls"},multiple:{type:"boolean",reflect:!0,default:!1,description:"Allow multiple date selection"},maxMultiple:{type:"number",default:4,description:"Maximum number of dates that can be selected"},range:{type:"boolean",reflect:!0,default:!1,description:"Allow date range selection"}},H={"date-selected":{description:"Returns ISO formatted date string"}},g={name:E,"css-class":"pkt-calendar",props:T,events:H};var R=Object.defineProperty,W=Object.getOwnPropertyDescriptor,o=(r,e,t,s)=>{for(var n=s>1?void 0:s?W(e,t):e,i=r.length-1,l;i>=0;i--)(l=r[i])&&(n=(s?l(e,t,n):l(n))||n);return s&&n&&R(e,t,n),n};exports.PktCalendar=class extends a.PktElement{constructor(){super(...arguments),this.multiple=g.props.multiple.default,this.maxMultiple=g.props.maxMultiple.default,this.range=g.props.range.default,this.weeknumbers=g.props.weeknumbers.default,this.withcontrols=g.props.withcontrols.default,this.selected=[],this.earliest=g.props.earliest.default,this.latest=g.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.dayStrings=this.strings.dates.daysShort,this.monthStrings=this.strings.dates.months,this.weekString=this.strings.dates.week,this.prevMonthString=this.strings.dates.prevMonth,this.nextMonthString=this.strings.dates.nextMonth,this._selected=[],this.year=0,this.month=0,this.week=0,this.rangeHovered=null,this.inRange={},this.focusedDate=null,this.selectableDates=[],this.currentmonthtouched=!1,this.tabIndexSet=0}connectedCallback(){super.connectedCallback()}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}attributeChangedCallback(e,t,s){e==="selected"&&s&&this.convertSelected(),super.attributeChangedCallback(e,t,s)}updated(e){e.has("selected")&&this.convertSelected(),super.updated(e)}firstUpdated(e){this.addEventListener("keydown",this.handleKeydown)}convertSelected(){if(typeof this.selected=="string"&&(this.selected=this.selected.split(",")),this.selected.length===1&&this.selected[0]===""&&(this.selected=[]),this._selected=this.selected.map(e=>new Date(e)),this.range&&this.selected.length===2){const e=b({start:new Date(this.selected[0]),end:new Date(this.selected[1])});if(this.inRange={},Array.isArray(e)&&e.length){const t={};for(let s=0;s<e.length;s++)t[this.formatISODate(e[s])]=this.isInRange(e[s]);this.inRange=t}}this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched){this.currentmonthtouched=!0;return}this.selected.length&&this.selected[0]!==""?this.currentmonth=new Date(this.selected[this.selected.length-1]):this.currentmonth===null&&(this.currentmonth=new Date),this.year=this.currentmonth.getFullYear(),this.month=this.currentmonth.getMonth()}handleKeydown(e){switch(e.key){case"ArrowLeft":this.handleArrowKey(e,-1);break;case"ArrowRight":this.handleArrowKey(e,1);break;case"ArrowUp":this.handleArrowKey(e,-7);break;case"ArrowDown":this.handleArrowKey(e,7);break}}handleArrowKey(e,t){e.preventDefault(),this.focusedDate||this.focusOnCurrentDate();const s=this.focusedDate?new Date(this.focusedDate):new Date(this.year,this.month,1);let n=new Date(s.setDate(s.getDate()+t));if(n){let i=this.querySelector(`div[data-date="${this.formatISODate(n)}"]`);if(i instanceof HTMLDivElement){if(i.dataset.disabled){let l=new Date(s.setDate(s.getDate()+t)),c=this.querySelector(`div[data-date="${this.formatISODate(l)}"]`);for(;c&&c instanceof HTMLDivElement&&c.dataset.disabled;)l=new Date(l.setDate(l.getDate()+t)),c=this.querySelector(`div[data-date="${this.formatISODate(l)}"]`);i=c}i instanceof HTMLDivElement&&!i.dataset.disabled&&(this.focusedDate=this.formatISODate(n),i.focus())}}}render(){return a.x`
2
+ <div
3
+ class="pkt-calendar ${this.weeknumbers?"pkt-cal-weeknumbers":a.E}"
4
+ @focusout=${this.closeEvent}
5
+ @keydown=${e=>{e.key==="Escape"&&(e.preventDefault(),this.close())}}
6
+ >
7
+ <nav class="pkt-cal-month-nav">
8
+ <div>
9
+ <div
10
+ @click=${this.isPrevMonthAllowed()&&this.prevMonth}
11
+ @keydown=${e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.isNextMonthAllowed()&&this.prevMonth())}}
12
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isPrevMonthAllowed()?"":"pkt-hide"}"
13
+ .data-disabled=${this.isPrevMonthAllowed()?a.E:"disabled"}
14
+ ?aria-disabled=${!this.isPrevMonthAllowed()}
15
+ tabindex=${this.isPrevMonthAllowed()?"0":"-1"}
16
+ >
17
+ <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
18
+ <span class="pkt-btn__text">${this.prevMonthString}</span>
19
+ </div>
20
+ </div>
21
+ ${this.renderMonthNav()}
22
+ <div>
23
+ <div
24
+ @click=${this.isNextMonthAllowed()&&this.nextMonth}
25
+ @keydown=${e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.isNextMonthAllowed()&&this.nextMonth())}}
26
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isNextMonthAllowed()?"":"pkt-hide"}"
27
+ .data-disabled=${this.isNextMonthAllowed()?a.E:"disabled"}
28
+ ?aria-disabled=${!this.isNextMonthAllowed()}
29
+ tabindex=${this.isNextMonthAllowed()?"0":"-1"}
30
+ >
31
+ <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
32
+ <span class="pkt-btn__text">${this.nextMonthString}</span>
33
+ </div>
34
+ </div>
35
+ </nav>
36
+ <table
37
+ class="pkt-cal-days pkt-txt-12-medium"
38
+ role="grid"
39
+ ?aria-multiselectable=${this.range||this.multiple}
40
+ >
41
+ ${this.renderDayNames()} ${this.renderCalendarBody()}
42
+ </table>
43
+ </div>
44
+ `}renderDayNames(){const e=[];this.weeknumbers&&e.push(a.x`<td><div>${this.weekString}<div></td>`);for(let t=0;t<this.dayStrings.length;t++)e.push(a.x`<td><div>${this.dayStrings[t]}</div></td>`);return a.x`<tr class="pkt-cal-week-row" role="presentation">
45
+ ${e}
46
+ </tr>`}renderMonthNav(){let e=[];return this.withcontrols?e.push(a.x`<div class="pkt-cal-month-picker">
47
+ <select
48
+ class="pkt-input pkt-input-compact"
49
+ @change=${t=>{this.changeMonth(this.year,t.target.value)}}
50
+ >
51
+ ${this.monthStrings.map((t,s)=>a.x`<option value=${s} ?selected=${this.month===s}>${t}</option>`)}
52
+ </select>
53
+ <input
54
+ class="pkt-input pkt-cal-input-year pkt-input-compact"
55
+ type="number"
56
+ size="4"
57
+ placeholder="0000"
58
+ @change=${t=>{this.changeMonth(t.target.value,this.month)}}
59
+ .value=${this.year}
60
+ />
61
+ </div> `):e.push(a.x`<div class="pkt-txt-16-medium" aria-live="polite">
62
+ ${this.monthStrings[this.month]} ${this.year}
63
+ </div>`),e}renderDayView(e,t,s){var f;const n=new Date(this.year,this.month,e,12),i=this.formatISODate(n),l=i===this.formatISODate(t),c=this.selected.includes(i),h=this.isExcluded(s,n)||!c&&this.multiple&&this.maxMultiple>0&&this.selected.length>=this.maxMultiple,d=this.focusedDate?this.focusedDate===i&&!h?"0":"-1":!h&&this.tabIndexSet===0||this.tabIndexSet===e?"0":"-1";d==="0"&&(this.tabIndexSet=e),this.selectableDates.push({currentDateISO:i,isDisabled:h,tabindex:d});const p={"pkt-cal-today":l,"pkt-cal-selected":c,"pkt-cal-in-range":this.inRange[i],"pkt-cal-excluded":this.isExcluded(s,n),"pkt-cal-in-range-first":this.range&&(this.selected.length===2||this.rangeHovered!==null)&&i===this.selected[0],"pkt-cal-in-range-last":this.range&&this.selected.length===2&&i===this.selected[1],"pkt-cal-range-hover":this.rangeHovered!==null&&i===this.formatISODate(this.rangeHovered)};return a.x`<td class=${$.e(p)}>
64
+ <div
65
+ ?aria-selected=${c}
66
+ role="gridcell"
67
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
68
+ @mouseover=${()=>this.range&&!this.isExcluded(s,n)&&this.handleRangeHover(n)}
69
+ @focus=${()=>{this.range&&!this.isExcluded(s,n)&&this.handleRangeHover(n),this.focusedDate=i}}
70
+ tabindex=${(f=this.selectableDates.find(u=>u.currentDateISO===i))==null?void 0:f.tabindex}
71
+ data-disabled=${h?"disabled":a.E}
72
+ data-date=${i}
73
+ @keydown=${u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.handleDateSelect(n))}}
74
+ @click=${u=>{h||(u.preventDefault(),this.handleDateSelect(n))}}
75
+ >
76
+ <span class="pkt-btn__text pkt-txt-14-light">${e}</span>
77
+ </div>
78
+ </td>`}renderCalendarBody(){const e=new Date,t=new Date(this.year,this.month,1,12),s=new Date(this.year,this.month+1,0,12),n=(t.getDay()+6)%7,i=s.getDate(),l=Math.ceil((i+n)/7),h=new Date(this.year,this.month,0,12).getDate();let d=1;this.week=M(new Date(this.year,this.month,1,12));const p=[];for(let f=0;f<l;f++){const u=[];this.weeknumbers&&u.push(a.x`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let y=1;y<8;y++)if(f===0&&y<n+1){const O=h-(n-y);u.push(a.x`<td class="pkt-cal-other">
79
+ <div
80
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
81
+ data-disabled="disabled"
82
+ >
83
+ <span class="pkt-btn__text pkt-txt-14-light">${O}</span>
84
+ </div>
85
+ </td>`)}else d>i?(u.push(a.x`<td class="pkt-cal-other">
86
+ <div
87
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
88
+ data-disabled="disabled"
89
+ >
90
+ <span class="pkt-btn__text pkt-txt-14-light">${d-i}</span>
91
+ </div>
92
+ </td>`),d++):(u.push(this.renderDayView(d,e,y)),d++);p.push(a.x`<tr class="pkt-cal-week-row" role="row">
93
+ ${u}
94
+ </tr>`)}return p}isExcluded(e,t){return this.excludeweekdays.includes(e.toString())||this.earliest&&t<new Date(this.earliest)||this.latest&&t>new Date(this.latest)?!0:this.excludedates.some(s=>typeof s=="string"?s===this.formatISODate(t):s.toDateString()===t.toDateString())}formatISODate(e){return e.toISOString().split("T")[0]}isPrevMonthAllowed(){const e=new Date(this.year,this.month,0,12);return!(this.earliest&&new Date(this.earliest)>e)}prevMonth(){const e=this.month===0?11:this.month-1,t=this.month===0?this.year-1:this.year;this.changeMonth(t,e)}isNextMonthAllowed(){const e=new Date(this.year,this.month===11?0:this.month+1,1,12);return!(this.latest&&new Date(this.latest)<e)}nextMonth(){const e=this.month===11?0:this.month+1,t=this.month===11?this.year+1:this.year;this.changeMonth(t,e)}changeMonth(e,t){this.year=e,this.month=t,this.tabIndexSet=0,this.focusedDate=null,this.selectableDates=[],this.requestUpdate()}isInRange(e){if(this.range&&this.selected.length===2){if(e>new Date(this.selected[0])&&e<new Date(this.selected[1]))return!0}else if(this.range&&this.selected.length===1&&this.rangeHovered&&e>new Date(this.selected[0])&&e<this.rangeHovered)return!0;return!1}isRangeAllowed(e){let t=!0;if(this._selected.length===1){const s=b({start:this._selected[0],end:e});if(Array.isArray(s)&&s.length)for(let n=0;n<s.length;n++)this.excludedates.forEach(i=>{i>this._selected[0]&&i<e&&(t=!1)}),this.excludeweekdays.includes(_(s[n]).toString())&&(t=!1)}return t}emptySelected(){this.selected=[],this._selected=[],this.inRange={}}addToSelected(e){this.selected.includes(this.formatISODate(e))||(this.selected=[...this.selected,this.formatISODate(e)],this._selected=[...this._selected,e],this.range&&this.selected.length===2&&this.close())}removeFromSelected(e){if(this.selected.length===1)this.emptySelected();else{const t=this.selected.indexOf(this.formatISODate(e)),s=[...this.selected],n=[...this._selected];s.splice(t,1),n.splice(t,1),this.selected=s,this._selected=n}}toggleSelected(e){const t=this.formatISODate(e);this.selected.includes(t)?this.removeFromSelected(e):this.maxMultiple&&this.selected.length>=this.maxMultiple||this.addToSelected(e)}handleRangeSelect(e){const t=this.formatISODate(e);return this.selected.includes(t)?this.selected.indexOf(t)===0?this.emptySelected():this.removeFromSelected(e):this.selected.length>1?(this.emptySelected(),this.addToSelected(e)):(this.selected.length===1&&!this.isRangeAllowed(e)&&this.emptySelected(),this.selected.length===1&&this._selected[0]>e&&this.emptySelected(),this.addToSelected(e)),Promise.resolve()}handleRangeHover(e){if(this.range&&this._selected.length===1&&this.isRangeAllowed(e)&&this._selected[0]<e){this.rangeHovered=e,this.inRange={};const t=b({start:this._selected[0],end:e});if(Array.isArray(t)&&t.length)for(let s=0;s<t.length;s++)this.inRange[this.formatISODate(t[s])]=this.isInRange(t[s])}else this.rangeHovered=null}handleDateSelect(e){if(e)return this.range?this.handleRangeSelect(e):this.multiple?this.toggleSelected(e):(this.selected.includes(this.formatISODate(e))?this.emptySelected():(this.emptySelected(),this.addToSelected(e)),this.close()),this.dispatchEvent(new CustomEvent("date-selected",{detail:this.selected,bubbles:!0,composed:!0})),Promise.resolve()}focusOnCurrentDate(){const e=this.formatISODate(new Date),t=this.querySelector(`div[data-date="${e}"]`);if(t instanceof HTMLDivElement)this.focusedDate=e,t.focus();else{const s=this.selectableDates.find(n=>!n.isDisabled);if(s){const n=this.querySelector(`div[data-date="${s.currentDateISO}"]`);n instanceof HTMLDivElement&&(this.focusedDate=s.currentDateISO,n.focus())}}}closeEvent(e){this.contains(e.relatedTarget)||this.close()}close(){this.dispatchEvent(new CustomEvent("close",{detail:!0,bubbles:!0,composed:!0}))}};o([a.n({type:Boolean})],exports.PktCalendar.prototype,"multiple",2);o([a.n({type:Number})],exports.PktCalendar.prototype,"maxMultiple",2);o([a.n({type:Boolean})],exports.PktCalendar.prototype,"range",2);o([a.n({type:Boolean})],exports.PktCalendar.prototype,"weeknumbers",2);o([a.n({type:Boolean})],exports.PktCalendar.prototype,"withcontrols",2);o([a.n({converter:v.converters.csvToArray})],exports.PktCalendar.prototype,"selected",2);o([a.n({type:String})],exports.PktCalendar.prototype,"earliest",2);o([a.n({type:String})],exports.PktCalendar.prototype,"latest",2);o([a.n({converter:v.converters.stringsToDate})],exports.PktCalendar.prototype,"excludedates",2);o([a.n({converter:v.converters.csvToArray})],exports.PktCalendar.prototype,"excludeweekdays",2);o([a.n({converter:v.converters.stringToDate})],exports.PktCalendar.prototype,"currentmonth",2);o([a.n({type:Array})],exports.PktCalendar.prototype,"dayStrings",2);o([a.n({type:Array})],exports.PktCalendar.prototype,"monthStrings",2);o([a.n({type:String})],exports.PktCalendar.prototype,"weekString",2);o([a.n({type:String})],exports.PktCalendar.prototype,"prevMonthString",2);o([a.n({type:String})],exports.PktCalendar.prototype,"nextMonthString",2);o([a.n({type:Array})],exports.PktCalendar.prototype,"_selected",2);o([a.n({type:Number})],exports.PktCalendar.prototype,"year",2);o([a.n({type:Number})],exports.PktCalendar.prototype,"month",2);o([a.n({type:Number})],exports.PktCalendar.prototype,"week",2);o([a.n({type:Date})],exports.PktCalendar.prototype,"rangeHovered",2);o([a.r()],exports.PktCalendar.prototype,"inRange",2);o([a.r()],exports.PktCalendar.prototype,"focusedDate",2);o([a.r()],exports.PktCalendar.prototype,"selectableDates",2);o([a.r()],exports.PktCalendar.prototype,"currentmonthtouched",2);o([a.r()],exports.PktCalendar.prototype,"tabIndexSet",2);exports.PktCalendar=o([C.t("pkt-calendar")],exports.PktCalendar);exports.constructFrom=D;exports.getDefaultOptions=w;exports.getWeek=M;exports.getWeekYear=x;exports.millisecondsInDay=P;exports.millisecondsInWeek=S;exports.startOfWeek=m;exports.toDate=k;
package/dist/index.d.ts CHANGED
@@ -56,6 +56,7 @@ export declare class PktCalendar extends PktElement {
56
56
  private focusedDate;
57
57
  private selectableDates;
58
58
  private currentmonthtouched;
59
+ private tabIndexSet;
59
60
  /**
60
61
  * Runs on mount, used to set up various values and whatever you need to run
61
62
  */
@@ -63,6 +64,7 @@ export declare class PktCalendar extends PktElement {
63
64
  disconnectedCallback(): void;
64
65
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
65
66
  updated(changedProperties: PropertyValues): void;
67
+ protected firstUpdated(_changedProperties: PropertyValues): void;
66
68
  convertSelected(): void;
67
69
  setCurrentMonth(): void;
68
70
  handleKeydown(e: KeyboardEvent): void;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-DSyh6tUw.cjs");require("./converters-DhM11VlY.cjs");require("./directive-DtixNHDT.cjs");require("./class-map-Ch54kkX5.cjs");const e=require("./index-BR7VtlYg.cjs");require("./index-Bpc07w_P.cjs");Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>e.PktCalendar});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-DSyh6tUw.cjs");require("./converters-DhM11VlY.cjs");require("./directive-DtixNHDT.cjs");require("./class-map-Ch54kkX5.cjs");const e=require("./index-BNOnscrA.cjs");require("./index-Bpc07w_P.cjs");Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>e.PktCalendar});
@@ -2,7 +2,7 @@ import "./index-CsTujnXs.js";
2
2
  import "./converters-DNCwIFwr.js";
3
3
  import "./directive-Cxhakbpr.js";
4
4
  import "./class-map-DunDFQn7.js";
5
- import { P as e } from "./index-dgAzBeRk.js";
5
+ import { P as e } from "./index-BI6-RUqp.js";
6
6
  import "./index-CyqOyy_9.js";
7
7
  export {
8
8
  e as PktCalendar
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-DSyh6tUw.cjs"),S=require("./directive-DtixNHDT.cjs"),o=require("./ref-C3InMDfU.cjs"),O=require("./class-map-Ch54kkX5.cjs"),j=require("./converters-DhM11VlY.cjs"),g=require("./index-BR7VtlYg.cjs");require("./pkt-input-wrapper.cjs");require("./index-Bpc07w_P.cjs");require("./pkt-tag.cjs");function C(n){return g.startOfWeek(n,{weekStartsOn:1})}function V(n){const e=g.toDate(n),t=e.getFullYear(),a=g.constructFrom(n,0);a.setFullYear(t+1,0,4),a.setHours(0,0,0,0);const r=C(a),i=g.constructFrom(n,0);i.setFullYear(t,0,4),i.setHours(0,0,0,0);const s=C(i);return e.getTime()>=r.getTime()?t+1:e.getTime()>=s.getTime()?t:t-1}function _(n){const e=g.toDate(n);return e.setHours(0,0,0,0),e}function q(n){const e=g.toDate(n),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+n-+t}function A(n,e){const t=_(n),a=_(e),r=+t-q(t),i=+a-q(a);return Math.round((r-i)/g.millisecondsInDay)}function L(n){const e=V(n),t=g.constructFrom(n,0);return t.setFullYear(e,0,4),t.setHours(0,0,0,0),C(t)}function Q(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function X(n){if(!Q(n)&&typeof n!="number")return!1;const e=g.toDate(n);return!isNaN(Number(e))}function G(n){const e=g.toDate(n),t=g.constructFrom(n,0);return t.setFullYear(e.getFullYear(),0,1),t.setHours(0,0,0,0),t}const U={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},J=(n,e,t)=>{let a;const r=U[n];return typeof r=="string"?a=r:e===1?a=r.one:a=r.other.replace("{{count}}",e.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+a:a+" ago":a};function R(n){return(e={})=>{const t=e.width?String(e.width):n.defaultWidth;return n.formats[t]||n.formats[n.defaultWidth]}}const K={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},z={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Z={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ee={date:R({formats:K,defaultWidth:"full"}),time:R({formats:z,defaultWidth:"full"}),dateTime:R({formats:Z,defaultWidth:"full"})},te={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ne=(n,e,t,a)=>te[n];function $(n){return(e,t)=>{const a=t!=null&&t.context?String(t.context):"standalone";let r;if(a==="formatting"&&n.formattingValues){const s=n.defaultFormattingWidth||n.defaultWidth,h=t!=null&&t.width?String(t.width):s;r=n.formattingValues[h]||n.formattingValues[s]}else{const s=n.defaultWidth,h=t!=null&&t.width?String(t.width):n.defaultWidth;r=n.values[h]||n.values[s]}const i=n.argumentCallback?n.argumentCallback(e):e;return r[i]}}const ae={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},re={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ie={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},se={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},oe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},ue={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},le=(n,e)=>{const t=Number(n),a=t%100;if(a>20||a<10)switch(a%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},de={ordinalNumber:le,era:$({values:ae,defaultWidth:"wide"}),quarter:$({values:re,defaultWidth:"wide",argumentCallback:n=>n-1}),month:$({values:ie,defaultWidth:"wide"}),day:$({values:se,defaultWidth:"wide"}),dayPeriod:$({values:oe,defaultWidth:"wide",formattingValues:ue,defaultFormattingWidth:"wide"})};function T(n){return(e,t={})=>{const a=t.width,r=a&&n.matchPatterns[a]||n.matchPatterns[n.defaultMatchWidth],i=e.match(r);if(!i)return null;const s=i[0],h=a&&n.parsePatterns[a]||n.parsePatterns[n.defaultParseWidth],v=Array.isArray(h)?he(h,c=>c.test(s)):ce(h,c=>c.test(s));let w;w=n.valueCallback?n.valueCallback(v):v,w=t.valueCallback?t.valueCallback(w):w;const x=e.slice(s.length);return{value:w,rest:x}}}function ce(n,e){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&e(n[t]))return t}function he(n,e){for(let t=0;t<n.length;t++)if(e(n[t]))return t}function fe(n){return(e,t={})=>{const a=e.match(n.matchPattern);if(!a)return null;const r=a[0],i=e.match(n.parsePattern);if(!i)return null;let s=n.valueCallback?n.valueCallback(i[0]):i[0];s=t.valueCallback?t.valueCallback(s):s;const h=e.slice(r.length);return{value:s,rest:h}}}const me=/^(\d+)(th|st|nd|rd)?/i,pe=/\d+/i,ge={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ye={any:[/^b/i,/^(a|c)/i]},ve={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},we={any:[/1/i,/2/i,/3/i,/4/i]},ke={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},be={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},xe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Pe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},De={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Me={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Oe={ordinalNumber:fe({matchPattern:me,parsePattern:pe,valueCallback:n=>parseInt(n,10)}),era:T({matchPatterns:ge,defaultMatchWidth:"wide",parsePatterns:ye,defaultParseWidth:"any"}),quarter:T({matchPatterns:ve,defaultMatchWidth:"wide",parsePatterns:we,defaultParseWidth:"any",valueCallback:n=>n+1}),month:T({matchPatterns:ke,defaultMatchWidth:"wide",parsePatterns:be,defaultParseWidth:"any"}),day:T({matchPatterns:xe,defaultMatchWidth:"wide",parsePatterns:Pe,defaultParseWidth:"any"}),dayPeriod:T({matchPatterns:De,defaultMatchWidth:"any",parsePatterns:Me,defaultParseWidth:"any"})},$e={code:"en-US",formatDistance:J,formatLong:ee,formatRelative:ne,localize:de,match:Oe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Te(n){const e=g.toDate(n);return A(e,G(e))+1}function Se(n){const e=g.toDate(n),t=+C(e)-+L(e);return Math.round(t/g.millisecondsInWeek)+1}function u(n,e){const t=n<0?"-":"",a=Math.abs(n).toString().padStart(e,"0");return t+a}const b={y(n,e){const t=n.getFullYear(),a=t>0?t:1-t;return u(e==="yy"?a%100:a,e.length)},M(n,e){const t=n.getMonth();return e==="M"?String(t+1):u(t+1,2)},d(n,e){return u(n.getDate(),e.length)},a(n,e){const t=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];case"aaaa":default:return t==="am"?"a.m.":"p.m."}},h(n,e){return u(n.getHours()%12||12,e.length)},H(n,e){return u(n.getHours(),e.length)},m(n,e){return u(n.getMinutes(),e.length)},s(n,e){return u(n.getSeconds(),e.length)},S(n,e){const t=e.length,a=n.getMilliseconds(),r=Math.trunc(a*Math.pow(10,t-3));return u(r,e.length)}},M={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},F={G:function(n,e,t){const a=n.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return t.era(a,{width:"abbreviated"});case"GGGGG":return t.era(a,{width:"narrow"});case"GGGG":default:return t.era(a,{width:"wide"})}},y:function(n,e,t){if(e==="yo"){const a=n.getFullYear(),r=a>0?a:1-a;return t.ordinalNumber(r,{unit:"year"})}return b.y(n,e)},Y:function(n,e,t,a){const r=g.getWeekYear(n,a),i=r>0?r:1-r;if(e==="YY"){const s=i%100;return u(s,2)}return e==="Yo"?t.ordinalNumber(i,{unit:"year"}):u(i,e.length)},R:function(n,e){const t=V(n);return u(t,e.length)},u:function(n,e){const t=n.getFullYear();return u(t,e.length)},Q:function(n,e,t){const a=Math.ceil((n.getMonth()+1)/3);switch(e){case"Q":return String(a);case"QQ":return u(a,2);case"Qo":return t.ordinalNumber(a,{unit:"quarter"});case"QQQ":return t.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return t.quarter(a,{width:"wide",context:"formatting"})}},q:function(n,e,t){const a=Math.ceil((n.getMonth()+1)/3);switch(e){case"q":return String(a);case"qq":return u(a,2);case"qo":return t.ordinalNumber(a,{unit:"quarter"});case"qqq":return t.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return t.quarter(a,{width:"wide",context:"standalone"})}},M:function(n,e,t){const a=n.getMonth();switch(e){case"M":case"MM":return b.M(n,e);case"Mo":return t.ordinalNumber(a+1,{unit:"month"});case"MMM":return t.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return t.month(a,{width:"wide",context:"formatting"})}},L:function(n,e,t){const a=n.getMonth();switch(e){case"L":return String(a+1);case"LL":return u(a+1,2);case"Lo":return t.ordinalNumber(a+1,{unit:"month"});case"LLL":return t.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return t.month(a,{width:"wide",context:"standalone"})}},w:function(n,e,t,a){const r=g.getWeek(n,a);return e==="wo"?t.ordinalNumber(r,{unit:"week"}):u(r,e.length)},I:function(n,e,t){const a=Se(n);return e==="Io"?t.ordinalNumber(a,{unit:"week"}):u(a,e.length)},d:function(n,e,t){return e==="do"?t.ordinalNumber(n.getDate(),{unit:"date"}):b.d(n,e)},D:function(n,e,t){const a=Te(n);return e==="Do"?t.ordinalNumber(a,{unit:"dayOfYear"}):u(a,e.length)},E:function(n,e,t){const a=n.getDay();switch(e){case"E":case"EE":case"EEE":return t.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(a,{width:"short",context:"formatting"});case"EEEE":default:return t.day(a,{width:"wide",context:"formatting"})}},e:function(n,e,t,a){const r=n.getDay(),i=(r-a.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return u(i,2);case"eo":return t.ordinalNumber(i,{unit:"day"});case"eee":return t.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(r,{width:"short",context:"formatting"});case"eeee":default:return t.day(r,{width:"wide",context:"formatting"})}},c:function(n,e,t,a){const r=n.getDay(),i=(r-a.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return u(i,e.length);case"co":return t.ordinalNumber(i,{unit:"day"});case"ccc":return t.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(r,{width:"narrow",context:"standalone"});case"cccccc":return t.day(r,{width:"short",context:"standalone"});case"cccc":default:return t.day(r,{width:"wide",context:"standalone"})}},i:function(n,e,t){const a=n.getDay(),r=a===0?7:a;switch(e){case"i":return String(r);case"ii":return u(r,e.length);case"io":return t.ordinalNumber(r,{unit:"day"});case"iii":return t.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(a,{width:"short",context:"formatting"});case"iiii":default:return t.day(a,{width:"wide",context:"formatting"})}},a:function(n,e,t){const r=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaa":default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(n,e,t){const a=n.getHours();let r;switch(a===12?r=M.noon:a===0?r=M.midnight:r=a/12>=1?"pm":"am",e){case"b":case"bb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbb":default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(n,e,t){const a=n.getHours();let r;switch(a>=17?r=M.evening:a>=12?r=M.afternoon:a>=4?r=M.morning:r=M.night,e){case"B":case"BB":case"BBB":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBB":default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(n,e,t){if(e==="ho"){let a=n.getHours()%12;return a===0&&(a=12),t.ordinalNumber(a,{unit:"hour"})}return b.h(n,e)},H:function(n,e,t){return e==="Ho"?t.ordinalNumber(n.getHours(),{unit:"hour"}):b.H(n,e)},K:function(n,e,t){const a=n.getHours()%12;return e==="Ko"?t.ordinalNumber(a,{unit:"hour"}):u(a,e.length)},k:function(n,e,t){let a=n.getHours();return a===0&&(a=24),e==="ko"?t.ordinalNumber(a,{unit:"hour"}):u(a,e.length)},m:function(n,e,t){return e==="mo"?t.ordinalNumber(n.getMinutes(),{unit:"minute"}):b.m(n,e)},s:function(n,e,t){return e==="so"?t.ordinalNumber(n.getSeconds(),{unit:"second"}):b.s(n,e)},S:function(n,e){return b.S(n,e)},X:function(n,e,t){const a=n.getTimezoneOffset();if(a===0)return"Z";switch(e){case"X":return Y(a);case"XXXX":case"XX":return D(a);case"XXXXX":case"XXX":default:return D(a,":")}},x:function(n,e,t){const a=n.getTimezoneOffset();switch(e){case"x":return Y(a);case"xxxx":case"xx":return D(a);case"xxxxx":case"xxx":default:return D(a,":")}},O:function(n,e,t){const a=n.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+I(a,":");case"OOOO":default:return"GMT"+D(a,":")}},z:function(n,e,t){const a=n.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+I(a,":");case"zzzz":default:return"GMT"+D(a,":")}},t:function(n,e,t){const a=Math.trunc(n.getTime()/1e3);return u(a,e.length)},T:function(n,e,t){const a=n.getTime();return u(a,e.length)}};function I(n,e=""){const t=n>0?"-":"+",a=Math.abs(n),r=Math.trunc(a/60),i=a%60;return i===0?t+String(r):t+String(r)+e+u(i,2)}function Y(n,e){return n%60===0?(n>0?"-":"+")+u(Math.abs(n)/60,2):D(n,e)}function D(n,e=""){const t=n>0?"-":"+",a=Math.abs(n),r=u(Math.trunc(a/60),2),i=u(a%60,2);return t+r+e+i}const N=(n,e)=>{switch(n){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},H=(n,e)=>{switch(n){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},Ce=(n,e)=>{const t=n.match(/(P+)(p+)?/)||[],a=t[1],r=t[2];if(!r)return N(n,e);let i;switch(a){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;case"PPPP":default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",N(a,e)).replace("{{time}}",H(r,e))},Re={p:H,P:Ce},Ee=/^D+$/,We=/^Y+$/,_e=["D","DD","YY","YYYY"];function qe(n){return Ee.test(n)}function Fe(n){return We.test(n)}function Ie(n,e,t){const a=Ye(n,e,t);if(console.warn(a),_e.includes(n))throw new RangeError(a)}function Ye(n,e,t){const a=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${e}\`) for formatting ${a} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Ne=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Be=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,je=/^'([^]*?)'?$/,Ve=/''/g,He=/[a-zA-Z]/;function Ae(n,e,t){var x,c,p,m;const a=g.getDefaultOptions(),r=a.locale??$e,i=a.firstWeekContainsDate??((c=(x=a.locale)==null?void 0:x.options)==null?void 0:c.firstWeekContainsDate)??1,s=a.weekStartsOn??((m=(p=a.locale)==null?void 0:p.options)==null?void 0:m.weekStartsOn)??0,h=g.toDate(n);if(!X(h))throw new RangeError("Invalid time value");let v=e.match(Be).map(d=>{const f=d[0];if(f==="p"||f==="P"){const P=Re[f];return P(d,r.formatLong)}return d}).join("").match(Ne).map(d=>{if(d==="''")return{isToken:!1,value:"'"};const f=d[0];if(f==="'")return{isToken:!1,value:Le(d)};if(F[f])return{isToken:!0,value:d};if(f.match(He))throw new RangeError("Format string contains an unescaped latin alphabet character `"+f+"`");return{isToken:!1,value:d}});r.localize.preprocessor&&(v=r.localize.preprocessor(h,v));const w={firstWeekContainsDate:i,weekStartsOn:s,locale:r};return v.map(d=>{if(!d.isToken)return d.value;const f=d.value;(Fe(f)||qe(f))&&Ie(f,e,String(n));const P=F[f[0]];return P(h,f,r.localize,w)}).join("")}function Le(n){const e=n.match(je);return e?e[1].replace(Ve,"'"):n}/**
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./index-DSyh6tUw.cjs"),S=require("./directive-DtixNHDT.cjs"),o=require("./ref-C3InMDfU.cjs"),O=require("./class-map-Ch54kkX5.cjs"),V=require("./converters-DhM11VlY.cjs"),g=require("./index-BNOnscrA.cjs");require("./pkt-input-wrapper.cjs");require("./index-Bpc07w_P.cjs");require("./pkt-tag.cjs");function C(n){return g.startOfWeek(n,{weekStartsOn:1})}function j(n){const e=g.toDate(n),t=e.getFullYear(),a=g.constructFrom(n,0);a.setFullYear(t+1,0,4),a.setHours(0,0,0,0);const r=C(a),i=g.constructFrom(n,0);i.setFullYear(t,0,4),i.setHours(0,0,0,0);const s=C(i);return e.getTime()>=r.getTime()?t+1:e.getTime()>=s.getTime()?t:t-1}function _(n){const e=g.toDate(n);return e.setHours(0,0,0,0),e}function q(n){const e=g.toDate(n),t=new Date(Date.UTC(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()));return t.setUTCFullYear(e.getFullYear()),+n-+t}function A(n,e){const t=_(n),a=_(e),r=+t-q(t),i=+a-q(a);return Math.round((r-i)/g.millisecondsInDay)}function L(n){const e=j(n),t=g.constructFrom(n,0);return t.setFullYear(e,0,4),t.setHours(0,0,0,0),C(t)}function Q(n){return n instanceof Date||typeof n=="object"&&Object.prototype.toString.call(n)==="[object Date]"}function X(n){if(!Q(n)&&typeof n!="number")return!1;const e=g.toDate(n);return!isNaN(Number(e))}function G(n){const e=g.toDate(n),t=g.constructFrom(n,0);return t.setFullYear(e.getFullYear(),0,1),t.setHours(0,0,0,0),t}const U={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},J=(n,e,t)=>{let a;const r=U[n];return typeof r=="string"?a=r:e===1?a=r.one:a=r.other.replace("{{count}}",e.toString()),t!=null&&t.addSuffix?t.comparison&&t.comparison>0?"in "+a:a+" ago":a};function R(n){return(e={})=>{const t=e.width?String(e.width):n.defaultWidth;return n.formats[t]||n.formats[n.defaultWidth]}}const K={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},z={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},Z={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},ee={date:R({formats:K,defaultWidth:"full"}),time:R({formats:z,defaultWidth:"full"}),dateTime:R({formats:Z,defaultWidth:"full"})},te={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},ne=(n,e,t,a)=>te[n];function $(n){return(e,t)=>{const a=t!=null&&t.context?String(t.context):"standalone";let r;if(a==="formatting"&&n.formattingValues){const s=n.defaultFormattingWidth||n.defaultWidth,h=t!=null&&t.width?String(t.width):s;r=n.formattingValues[h]||n.formattingValues[s]}else{const s=n.defaultWidth,h=t!=null&&t.width?String(t.width):n.defaultWidth;r=n.values[h]||n.values[s]}const i=n.argumentCallback?n.argumentCallback(e):e;return r[i]}}const ae={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},re={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},ie={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},se={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},oe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},ue={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},le=(n,e)=>{const t=Number(n),a=t%100;if(a>20||a<10)switch(a%10){case 1:return t+"st";case 2:return t+"nd";case 3:return t+"rd"}return t+"th"},de={ordinalNumber:le,era:$({values:ae,defaultWidth:"wide"}),quarter:$({values:re,defaultWidth:"wide",argumentCallback:n=>n-1}),month:$({values:ie,defaultWidth:"wide"}),day:$({values:se,defaultWidth:"wide"}),dayPeriod:$({values:oe,defaultWidth:"wide",formattingValues:ue,defaultFormattingWidth:"wide"})};function T(n){return(e,t={})=>{const a=t.width,r=a&&n.matchPatterns[a]||n.matchPatterns[n.defaultMatchWidth],i=e.match(r);if(!i)return null;const s=i[0],h=a&&n.parsePatterns[a]||n.parsePatterns[n.defaultParseWidth],v=Array.isArray(h)?he(h,c=>c.test(s)):ce(h,c=>c.test(s));let w;w=n.valueCallback?n.valueCallback(v):v,w=t.valueCallback?t.valueCallback(w):w;const x=e.slice(s.length);return{value:w,rest:x}}}function ce(n,e){for(const t in n)if(Object.prototype.hasOwnProperty.call(n,t)&&e(n[t]))return t}function he(n,e){for(let t=0;t<n.length;t++)if(e(n[t]))return t}function fe(n){return(e,t={})=>{const a=e.match(n.matchPattern);if(!a)return null;const r=a[0],i=e.match(n.parsePattern);if(!i)return null;let s=n.valueCallback?n.valueCallback(i[0]):i[0];s=t.valueCallback?t.valueCallback(s):s;const h=e.slice(r.length);return{value:s,rest:h}}}const me=/^(\d+)(th|st|nd|rd)?/i,pe=/\d+/i,ge={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},ye={any:[/^b/i,/^(a|c)/i]},ve={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},we={any:[/1/i,/2/i,/3/i,/4/i]},ke={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},be={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},xe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},Pe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},De={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},Me={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},Oe={ordinalNumber:fe({matchPattern:me,parsePattern:pe,valueCallback:n=>parseInt(n,10)}),era:T({matchPatterns:ge,defaultMatchWidth:"wide",parsePatterns:ye,defaultParseWidth:"any"}),quarter:T({matchPatterns:ve,defaultMatchWidth:"wide",parsePatterns:we,defaultParseWidth:"any",valueCallback:n=>n+1}),month:T({matchPatterns:ke,defaultMatchWidth:"wide",parsePatterns:be,defaultParseWidth:"any"}),day:T({matchPatterns:xe,defaultMatchWidth:"wide",parsePatterns:Pe,defaultParseWidth:"any"}),dayPeriod:T({matchPatterns:De,defaultMatchWidth:"any",parsePatterns:Me,defaultParseWidth:"any"})},$e={code:"en-US",formatDistance:J,formatLong:ee,formatRelative:ne,localize:de,match:Oe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function Te(n){const e=g.toDate(n);return A(e,G(e))+1}function Se(n){const e=g.toDate(n),t=+C(e)-+L(e);return Math.round(t/g.millisecondsInWeek)+1}function u(n,e){const t=n<0?"-":"",a=Math.abs(n).toString().padStart(e,"0");return t+a}const b={y(n,e){const t=n.getFullYear(),a=t>0?t:1-t;return u(e==="yy"?a%100:a,e.length)},M(n,e){const t=n.getMonth();return e==="M"?String(t+1):u(t+1,2)},d(n,e){return u(n.getDate(),e.length)},a(n,e){const t=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.toUpperCase();case"aaa":return t;case"aaaaa":return t[0];case"aaaa":default:return t==="am"?"a.m.":"p.m."}},h(n,e){return u(n.getHours()%12||12,e.length)},H(n,e){return u(n.getHours(),e.length)},m(n,e){return u(n.getMinutes(),e.length)},s(n,e){return u(n.getSeconds(),e.length)},S(n,e){const t=e.length,a=n.getMilliseconds(),r=Math.trunc(a*Math.pow(10,t-3));return u(r,e.length)}},M={am:"am",pm:"pm",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},F={G:function(n,e,t){const a=n.getFullYear()>0?1:0;switch(e){case"G":case"GG":case"GGG":return t.era(a,{width:"abbreviated"});case"GGGGG":return t.era(a,{width:"narrow"});case"GGGG":default:return t.era(a,{width:"wide"})}},y:function(n,e,t){if(e==="yo"){const a=n.getFullYear(),r=a>0?a:1-a;return t.ordinalNumber(r,{unit:"year"})}return b.y(n,e)},Y:function(n,e,t,a){const r=g.getWeekYear(n,a),i=r>0?r:1-r;if(e==="YY"){const s=i%100;return u(s,2)}return e==="Yo"?t.ordinalNumber(i,{unit:"year"}):u(i,e.length)},R:function(n,e){const t=j(n);return u(t,e.length)},u:function(n,e){const t=n.getFullYear();return u(t,e.length)},Q:function(n,e,t){const a=Math.ceil((n.getMonth()+1)/3);switch(e){case"Q":return String(a);case"QQ":return u(a,2);case"Qo":return t.ordinalNumber(a,{unit:"quarter"});case"QQQ":return t.quarter(a,{width:"abbreviated",context:"formatting"});case"QQQQQ":return t.quarter(a,{width:"narrow",context:"formatting"});case"QQQQ":default:return t.quarter(a,{width:"wide",context:"formatting"})}},q:function(n,e,t){const a=Math.ceil((n.getMonth()+1)/3);switch(e){case"q":return String(a);case"qq":return u(a,2);case"qo":return t.ordinalNumber(a,{unit:"quarter"});case"qqq":return t.quarter(a,{width:"abbreviated",context:"standalone"});case"qqqqq":return t.quarter(a,{width:"narrow",context:"standalone"});case"qqqq":default:return t.quarter(a,{width:"wide",context:"standalone"})}},M:function(n,e,t){const a=n.getMonth();switch(e){case"M":case"MM":return b.M(n,e);case"Mo":return t.ordinalNumber(a+1,{unit:"month"});case"MMM":return t.month(a,{width:"abbreviated",context:"formatting"});case"MMMMM":return t.month(a,{width:"narrow",context:"formatting"});case"MMMM":default:return t.month(a,{width:"wide",context:"formatting"})}},L:function(n,e,t){const a=n.getMonth();switch(e){case"L":return String(a+1);case"LL":return u(a+1,2);case"Lo":return t.ordinalNumber(a+1,{unit:"month"});case"LLL":return t.month(a,{width:"abbreviated",context:"standalone"});case"LLLLL":return t.month(a,{width:"narrow",context:"standalone"});case"LLLL":default:return t.month(a,{width:"wide",context:"standalone"})}},w:function(n,e,t,a){const r=g.getWeek(n,a);return e==="wo"?t.ordinalNumber(r,{unit:"week"}):u(r,e.length)},I:function(n,e,t){const a=Se(n);return e==="Io"?t.ordinalNumber(a,{unit:"week"}):u(a,e.length)},d:function(n,e,t){return e==="do"?t.ordinalNumber(n.getDate(),{unit:"date"}):b.d(n,e)},D:function(n,e,t){const a=Te(n);return e==="Do"?t.ordinalNumber(a,{unit:"dayOfYear"}):u(a,e.length)},E:function(n,e,t){const a=n.getDay();switch(e){case"E":case"EE":case"EEE":return t.day(a,{width:"abbreviated",context:"formatting"});case"EEEEE":return t.day(a,{width:"narrow",context:"formatting"});case"EEEEEE":return t.day(a,{width:"short",context:"formatting"});case"EEEE":default:return t.day(a,{width:"wide",context:"formatting"})}},e:function(n,e,t,a){const r=n.getDay(),i=(r-a.weekStartsOn+8)%7||7;switch(e){case"e":return String(i);case"ee":return u(i,2);case"eo":return t.ordinalNumber(i,{unit:"day"});case"eee":return t.day(r,{width:"abbreviated",context:"formatting"});case"eeeee":return t.day(r,{width:"narrow",context:"formatting"});case"eeeeee":return t.day(r,{width:"short",context:"formatting"});case"eeee":default:return t.day(r,{width:"wide",context:"formatting"})}},c:function(n,e,t,a){const r=n.getDay(),i=(r-a.weekStartsOn+8)%7||7;switch(e){case"c":return String(i);case"cc":return u(i,e.length);case"co":return t.ordinalNumber(i,{unit:"day"});case"ccc":return t.day(r,{width:"abbreviated",context:"standalone"});case"ccccc":return t.day(r,{width:"narrow",context:"standalone"});case"cccccc":return t.day(r,{width:"short",context:"standalone"});case"cccc":default:return t.day(r,{width:"wide",context:"standalone"})}},i:function(n,e,t){const a=n.getDay(),r=a===0?7:a;switch(e){case"i":return String(r);case"ii":return u(r,e.length);case"io":return t.ordinalNumber(r,{unit:"day"});case"iii":return t.day(a,{width:"abbreviated",context:"formatting"});case"iiiii":return t.day(a,{width:"narrow",context:"formatting"});case"iiiiii":return t.day(a,{width:"short",context:"formatting"});case"iiii":default:return t.day(a,{width:"wide",context:"formatting"})}},a:function(n,e,t){const r=n.getHours()/12>=1?"pm":"am";switch(e){case"a":case"aa":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"aaa":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return t.dayPeriod(r,{width:"narrow",context:"formatting"});case"aaaa":default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},b:function(n,e,t){const a=n.getHours();let r;switch(a===12?r=M.noon:a===0?r=M.midnight:r=a/12>=1?"pm":"am",e){case"b":case"bb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"bbb":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return t.dayPeriod(r,{width:"narrow",context:"formatting"});case"bbbb":default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},B:function(n,e,t){const a=n.getHours();let r;switch(a>=17?r=M.evening:a>=12?r=M.afternoon:a>=4?r=M.morning:r=M.night,e){case"B":case"BB":case"BBB":return t.dayPeriod(r,{width:"abbreviated",context:"formatting"});case"BBBBB":return t.dayPeriod(r,{width:"narrow",context:"formatting"});case"BBBB":default:return t.dayPeriod(r,{width:"wide",context:"formatting"})}},h:function(n,e,t){if(e==="ho"){let a=n.getHours()%12;return a===0&&(a=12),t.ordinalNumber(a,{unit:"hour"})}return b.h(n,e)},H:function(n,e,t){return e==="Ho"?t.ordinalNumber(n.getHours(),{unit:"hour"}):b.H(n,e)},K:function(n,e,t){const a=n.getHours()%12;return e==="Ko"?t.ordinalNumber(a,{unit:"hour"}):u(a,e.length)},k:function(n,e,t){let a=n.getHours();return a===0&&(a=24),e==="ko"?t.ordinalNumber(a,{unit:"hour"}):u(a,e.length)},m:function(n,e,t){return e==="mo"?t.ordinalNumber(n.getMinutes(),{unit:"minute"}):b.m(n,e)},s:function(n,e,t){return e==="so"?t.ordinalNumber(n.getSeconds(),{unit:"second"}):b.s(n,e)},S:function(n,e){return b.S(n,e)},X:function(n,e,t){const a=n.getTimezoneOffset();if(a===0)return"Z";switch(e){case"X":return Y(a);case"XXXX":case"XX":return D(a);case"XXXXX":case"XXX":default:return D(a,":")}},x:function(n,e,t){const a=n.getTimezoneOffset();switch(e){case"x":return Y(a);case"xxxx":case"xx":return D(a);case"xxxxx":case"xxx":default:return D(a,":")}},O:function(n,e,t){const a=n.getTimezoneOffset();switch(e){case"O":case"OO":case"OOO":return"GMT"+I(a,":");case"OOOO":default:return"GMT"+D(a,":")}},z:function(n,e,t){const a=n.getTimezoneOffset();switch(e){case"z":case"zz":case"zzz":return"GMT"+I(a,":");case"zzzz":default:return"GMT"+D(a,":")}},t:function(n,e,t){const a=Math.trunc(n.getTime()/1e3);return u(a,e.length)},T:function(n,e,t){const a=n.getTime();return u(a,e.length)}};function I(n,e=""){const t=n>0?"-":"+",a=Math.abs(n),r=Math.trunc(a/60),i=a%60;return i===0?t+String(r):t+String(r)+e+u(i,2)}function Y(n,e){return n%60===0?(n>0?"-":"+")+u(Math.abs(n)/60,2):D(n,e)}function D(n,e=""){const t=n>0?"-":"+",a=Math.abs(n),r=u(Math.trunc(a/60),2),i=u(a%60,2);return t+r+e+i}const N=(n,e)=>{switch(n){case"P":return e.date({width:"short"});case"PP":return e.date({width:"medium"});case"PPP":return e.date({width:"long"});case"PPPP":default:return e.date({width:"full"})}},H=(n,e)=>{switch(n){case"p":return e.time({width:"short"});case"pp":return e.time({width:"medium"});case"ppp":return e.time({width:"long"});case"pppp":default:return e.time({width:"full"})}},Ce=(n,e)=>{const t=n.match(/(P+)(p+)?/)||[],a=t[1],r=t[2];if(!r)return N(n,e);let i;switch(a){case"P":i=e.dateTime({width:"short"});break;case"PP":i=e.dateTime({width:"medium"});break;case"PPP":i=e.dateTime({width:"long"});break;case"PPPP":default:i=e.dateTime({width:"full"});break}return i.replace("{{date}}",N(a,e)).replace("{{time}}",H(r,e))},Re={p:H,P:Ce},Ee=/^D+$/,We=/^Y+$/,_e=["D","DD","YY","YYYY"];function qe(n){return Ee.test(n)}function Fe(n){return We.test(n)}function Ie(n,e,t){const a=Ye(n,e,t);if(console.warn(a),_e.includes(n))throw new RangeError(a)}function Ye(n,e,t){const a=n[0]==="Y"?"years":"days of the month";return`Use \`${n.toLowerCase()}\` instead of \`${n}\` (in \`${e}\`) for formatting ${a} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const Ne=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,Be=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,Ve=/^'([^]*?)'?$/,je=/''/g,He=/[a-zA-Z]/;function Ae(n,e,t){var x,c,p,m;const a=g.getDefaultOptions(),r=a.locale??$e,i=a.firstWeekContainsDate??((c=(x=a.locale)==null?void 0:x.options)==null?void 0:c.firstWeekContainsDate)??1,s=a.weekStartsOn??((m=(p=a.locale)==null?void 0:p.options)==null?void 0:m.weekStartsOn)??0,h=g.toDate(n);if(!X(h))throw new RangeError("Invalid time value");let v=e.match(Be).map(d=>{const f=d[0];if(f==="p"||f==="P"){const P=Re[f];return P(d,r.formatLong)}return d}).join("").match(Ne).map(d=>{if(d==="''")return{isToken:!1,value:"'"};const f=d[0];if(f==="'")return{isToken:!1,value:Le(d)};if(F[f])return{isToken:!0,value:d};if(f.match(He))throw new RangeError("Format string contains an unescaped latin alphabet character `"+f+"`");return{isToken:!1,value:d}});r.localize.preprocessor&&(v=r.localize.preprocessor(h,v));const w={firstWeekContainsDate:i,weekStartsOn:s,locale:r};return v.map(d=>{if(!d.isToken)return d.value;const f=d.value;(Fe(f)||qe(f))&&Ie(f,e,String(n));const P=F[f[0]];return P(h,f,r.localize,w)}).join("")}function Le(n){const e=n.match(Ve);return e?e[1].replace(je,"'"):n}/**
2
2
  * @license
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
@@ -33,7 +33,7 @@
33
33
  @keydown=${e=>{var t;(e.key===","||e.key==="Enter")&&((t=this.inputRef.value)==null||t.blur())}}
34
34
  @input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
35
35
  @focus=${()=>{this.onFocus(),this.isMobileSafari&&this.showCalendar()}}
36
- @blur=${e=>{var t,a;if(e.target.value){this.manageValidity(e.target);const r=this.fromISOToDate(e.target.value);r&&this._value[0]!==e.target.value&&this._value[1]&&((a=(t=this.calRef)==null?void 0:t.value)==null||a.handleDateSelect(r))}else this._value[0]&&this.clearInputValue()}}
36
+ @blur=${e=>{var t,a;if(e.target.value){this.manageValidity(e.target);const r=this.fromISOToDate(e.target.value);r&&this._value[0]!==e.target.value&&this._value[1]&&(this.clearInputValue(),(a=(t=this.calRef)==null?void 0:t.value)==null||a.handleDateSelect(r))}else this._value[0]&&this.clearInputValue()}}
37
37
  @change=${e=>{e.stopImmediatePropagation()}}
38
38
  ${o.n(this.inputRef)}
39
39
  />
@@ -141,4 +141,4 @@
141
141
  </div>
142
142
  </pkt-input-wrapper>
143
143
  ${this.renderCalendar()}
144
- `}handleCalendarPosition(){var e;if(this.popupRef.value&&this.inputRef.value){const t=this.multiple&&!!this.maxlength,a=((e=this.inputRef.value.parentElement)==null?void 0:e.getBoundingClientRect())||this.inputRef.value.getBoundingClientRect(),r=t?a.height+30:a.height,i=this.popupRef.value.getBoundingClientRect().height;let s=t?"calc(100% - 30px)":"100%";a&&a.top+i>window.innerHeight&&a.top-i>0&&(s=`calc(100% - ${r}px - ${i}px)`),this.popupRef.value.style.top=s}}handleFocusOut(e){this.contains(e.target)||(this.onBlur(),this.hideCalendar())}async showCalendar(){var e;this.calendarOpen=!0,await E(20),this.handleCalendarPosition(),this.isMobileSafari&&((e=this.calRef.value)==null||e.focusOnCurrentDate())}hideCalendar(){this.calendarOpen=!1}async toggleCalendar(e){var t;e.preventDefault(),this.calendarOpen?this.hideCalendar():this.showCalendar(),await E(20),this.isMobileSafari&&((t=this.calRef.value)==null||t.focusOnCurrentDate())}};y([l.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"value",2);y([l.n({type:Array,reflect:!1})],exports.PktDatepicker.prototype,"_value",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"label",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"helptext",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"helptextDropdown",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"helptextDropdownButton",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"dateformat",2);y([l.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"multiple",2);y([l.n({type:Number})],exports.PktDatepicker.prototype,"maxlength",2);y([l.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"range",2);y([l.n({type:Boolean})],exports.PktDatepicker.prototype,"weeknumbers",2);y([l.n({type:Boolean})],exports.PktDatepicker.prototype,"withcontrols",2);y([l.n({type:Boolean})],exports.PktDatepicker.prototype,"fullwidth",2);y([l.n({converter:j.converters.csvToArray})],exports.PktDatepicker.prototype,"excludedates",2);y([l.n({converter:j.converters.csvToArray})],exports.PktDatepicker.prototype,"excludeweekdays",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"currentmonth",2);y([l.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"calendarOpen",2);exports.PktDatepicker=y([S.t("pkt-datepicker")],exports.PktDatepicker);
144
+ `}handleCalendarPosition(){var e;if(this.popupRef.value&&this.inputRef.value){const t=this.multiple&&!!this.maxlength,a=((e=this.inputRef.value.parentElement)==null?void 0:e.getBoundingClientRect())||this.inputRef.value.getBoundingClientRect(),r=t?a.height+30:a.height,i=this.popupRef.value.getBoundingClientRect().height;let s=t?"calc(100% - 30px)":"100%";a&&a.top+i>window.innerHeight&&a.top-i>0&&(s=`calc(100% - ${r}px - ${i}px)`),this.popupRef.value.style.top=s}}handleFocusOut(e){this.contains(e.target)||(this.onBlur(),this.hideCalendar())}async showCalendar(){var e;this.calendarOpen=!0,await E(20),this.handleCalendarPosition(),this.isMobileSafari&&((e=this.calRef.value)==null||e.focusOnCurrentDate())}hideCalendar(){this.calendarOpen=!1}async toggleCalendar(e){var t;e.preventDefault(),this.calendarOpen?this.hideCalendar():this.showCalendar(),await E(20),this.isMobileSafari&&((t=this.calRef.value)==null||t.focusOnCurrentDate())}};y([l.n({type:String,reflect:!0})],exports.PktDatepicker.prototype,"value",2);y([l.n({type:Array,reflect:!1})],exports.PktDatepicker.prototype,"_value",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"label",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"helptext",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"helptextDropdown",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"helptextDropdownButton",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"dateformat",2);y([l.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"multiple",2);y([l.n({type:Number})],exports.PktDatepicker.prototype,"maxlength",2);y([l.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"range",2);y([l.n({type:Boolean})],exports.PktDatepicker.prototype,"weeknumbers",2);y([l.n({type:Boolean})],exports.PktDatepicker.prototype,"withcontrols",2);y([l.n({type:Boolean})],exports.PktDatepicker.prototype,"fullwidth",2);y([l.n({converter:V.converters.csvToArray})],exports.PktDatepicker.prototype,"excludedates",2);y([l.n({converter:V.converters.csvToArray})],exports.PktDatepicker.prototype,"excludeweekdays",2);y([l.n({type:String})],exports.PktDatepicker.prototype,"currentmonth",2);y([l.n({type:Boolean,reflect:!0})],exports.PktDatepicker.prototype,"calendarOpen",2);exports.PktDatepicker=y([S.t("pkt-datepicker")],exports.PktDatepicker);
@@ -3,7 +3,7 @@ import { e as Z, i as tt, a as et, t as nt } from "./directive-Cxhakbpr.js";
3
3
  import { p as at, v as O, r as S, M as Y, m as rt, e as C, n as P } from "./ref-By_W8A-f.js";
4
4
  import { e as R } from "./class-map-DunDFQn7.js";
5
5
  import { a as G } from "./converters-DNCwIFwr.js";
6
- import { s as it, t as k, c as _, m as st, a as ot, g as ut, b as lt, d as dt } from "./index-dgAzBeRk.js";
6
+ import { s as it, t as k, c as _, m as st, a as ot, g as ut, b as lt, d as dt } from "./index-BI6-RUqp.js";
7
7
  import "./pkt-input-wrapper.js";
8
8
  import "./index-CyqOyy_9.js";
9
9
  import "./pkt-tag.js";
@@ -1535,7 +1535,7 @@ let f = class extends z {
1535
1535
  if (t.target.value) {
1536
1536
  this.manageValidity(t.target);
1537
1537
  const a = this.fromISOToDate(t.target.value);
1538
- a && this._value[0] !== t.target.value && this._value[1] && ((n = (e = this.calRef) == null ? void 0 : e.value) == null || n.handleDateSelect(a));
1538
+ a && this._value[0] !== t.target.value && this._value[1] && (this.clearInputValue(), (n = (e = this.calRef) == null ? void 0 : e.value) == null || n.handleDateSelect(a));
1539
1539
  } else this._value[0] && this.clearInputValue();
1540
1540
  }}
1541
1541
  @change=${(t) => {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BR7VtlYg.cjs"),t=require("./pkt-card.cjs"),r=require("./pkt-component-template.cjs"),n=require("./pkt-datepicker.cjs"),o=require("./index-Bpc07w_P.cjs"),a=require("./pkt-input-wrapper.cjs"),u=require("./pkt-link.cjs"),c=require("./pkt-messagebox.cjs"),i=require("./pkt-tag.cjs");Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>e.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>t.PktCard});Object.defineProperty(exports,"PktComponent",{enumerable:!0,get:()=>r.PktComponent});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>n.PktDatepicker});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>o.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>a.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>u.PktLink});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>c.PktMessagebox});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>i.PktTag});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BNOnscrA.cjs"),t=require("./pkt-card.cjs"),r=require("./pkt-component-template.cjs"),n=require("./pkt-datepicker.cjs"),o=require("./index-Bpc07w_P.cjs"),a=require("./pkt-input-wrapper.cjs"),u=require("./pkt-link.cjs"),c=require("./pkt-messagebox.cjs"),i=require("./pkt-tag.cjs");Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>e.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>t.PktCard});Object.defineProperty(exports,"PktComponent",{enumerable:!0,get:()=>r.PktComponent});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>n.PktDatepicker});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>o.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>a.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>u.PktLink});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>c.PktMessagebox});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>i.PktTag});
package/dist/pkt-index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { P as t } from "./index-dgAzBeRk.js";
1
+ import { P as t } from "./index-BI6-RUqp.js";
2
2
  import { PktCard as p } from "./pkt-card.js";
3
3
  import { PktComponent as P } from "./pkt-component-template.js";
4
4
  import { PktDatepicker as x } from "./pkt-datepicker.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "12.5.0",
3
+ "version": "12.5.1",
4
4
  "description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo Origo",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "devDependencies": {
30
30
  "@oslokommune/punkt-assets": "^12.4.0",
31
- "@oslokommune/punkt-css": "^12.5.0",
31
+ "@oslokommune/punkt-css": "^12.5.1",
32
32
  "sass": "^1.78.0",
33
33
  "typescript": "^5.6.2",
34
34
  "vite": "^5.4.4",
@@ -55,5 +55,5 @@
55
55
  "url": "https://github.com/oslokommune/punkt/issues"
56
56
  },
57
57
  "license": "MIT",
58
- "gitHead": "1342b6cc802b3fef7caa218bc76051777e8dbe57"
58
+ "gitHead": "ed053c5c5fc351fd296129b6945f17196cab3646"
59
59
  }
@@ -70,8 +70,13 @@ export class PktCalendar extends PktElement {
70
70
 
71
71
  @state() private inRange: DatesInRange = {}
72
72
  @state() private focusedDate: string | null = null
73
- @state() private selectableDates: { currentDateISO: string; isDisabled: boolean }[] = []
73
+ @state() private selectableDates: {
74
+ currentDateISO: string
75
+ isDisabled: boolean
76
+ tabindex: string
77
+ }[] = []
74
78
  @state() private currentmonthtouched: boolean = false
79
+ @state() private tabIndexSet: number = 0
75
80
  /**
76
81
  * Runs on mount, used to set up various values and whatever you need to run
77
82
  */
@@ -98,6 +103,10 @@ export class PktCalendar extends PktElement {
98
103
  super.updated(changedProperties)
99
104
  }
100
105
 
106
+ protected firstUpdated(_changedProperties: PropertyValues): void {
107
+ this.addEventListener('keydown', this.handleKeydown)
108
+ }
109
+
101
110
  convertSelected() {
102
111
  if (typeof this.selected === 'string') {
103
112
  this.selected = this.selected.split(',')
@@ -159,8 +168,10 @@ export class PktCalendar extends PktElement {
159
168
 
160
169
  handleArrowKey(e: KeyboardEvent, direction: number) {
161
170
  e.preventDefault()
162
- if (!this.focusedDate) return
163
- const date = new Date(this.focusedDate)
171
+ if (!this.focusedDate) {
172
+ this.focusOnCurrentDate()
173
+ }
174
+ const date = this.focusedDate ? new Date(this.focusedDate) : new Date(this.year, this.month, 1)
164
175
  let newDate = new Date(date.setDate(date.getDate() + direction))
165
176
  if (newDate) {
166
177
  let el = this.querySelector(`div[data-date="${this.formatISODate(newDate)}"]`)
@@ -179,6 +190,7 @@ export class PktCalendar extends PktElement {
179
190
  el = nextElement
180
191
  }
181
192
  if (el instanceof HTMLDivElement && !el.dataset.disabled) {
193
+ this.focusedDate = this.formatISODate(newDate)
182
194
  el.focus()
183
195
  }
184
196
  }
@@ -200,38 +212,46 @@ export class PktCalendar extends PktElement {
200
212
  }}
201
213
  >
202
214
  <nav class="pkt-cal-month-nav">
203
- <div
204
- @click=${this.isPrevMonthAllowed() && this.prevMonth}
205
- @keydown=${(e: KeyboardEvent) => {
206
- if (e.key === 'Enter' || e.key === ' ') {
207
- e.preventDefault()
208
- this.isNextMonthAllowed() && this.prevMonth()
209
- }
210
- }}
211
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
212
- .data-disabled=${!this.isPrevMonthAllowed() ? 'disabled' : nothing}
213
- ?aria-disabled=${!this.isPrevMonthAllowed()}
214
- tabindex="0"
215
- >
216
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
217
- <span class="pkt-btn__text">${this.prevMonthString}</span>
215
+ <div>
216
+ <div
217
+ @click=${this.isPrevMonthAllowed() && this.prevMonth}
218
+ @keydown=${(e: KeyboardEvent) => {
219
+ if (e.key === 'Enter' || e.key === ' ') {
220
+ e.preventDefault()
221
+ this.isNextMonthAllowed() && this.prevMonth()
222
+ }
223
+ }}
224
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isPrevMonthAllowed()
225
+ ? ''
226
+ : 'pkt-hide'}"
227
+ .data-disabled=${!this.isPrevMonthAllowed() ? 'disabled' : nothing}
228
+ ?aria-disabled=${!this.isPrevMonthAllowed()}
229
+ tabindex=${this.isPrevMonthAllowed() ? '0' : '-1'}
230
+ >
231
+ <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
232
+ <span class="pkt-btn__text">${this.prevMonthString}</span>
233
+ </div>
218
234
  </div>
219
235
  ${this.renderMonthNav()}
220
- <div
221
- @click=${this.isNextMonthAllowed() && this.nextMonth}
222
- @keydown=${(e: KeyboardEvent) => {
223
- if (e.key === 'Enter' || e.key === ' ') {
224
- e.preventDefault()
225
- this.isNextMonthAllowed() && this.nextMonth()
226
- }
227
- }}
228
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
229
- .data-disabled=${!this.isNextMonthAllowed() ? 'disabled' : nothing}
230
- ?aria-disabled=${!this.isNextMonthAllowed()}
231
- tabindex="0"
232
- >
233
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
234
- <span class="pkt-btn__text">${this.nextMonthString}</span>
236
+ <div>
237
+ <div
238
+ @click=${this.isNextMonthAllowed() && this.nextMonth}
239
+ @keydown=${(e: KeyboardEvent) => {
240
+ if (e.key === 'Enter' || e.key === ' ') {
241
+ e.preventDefault()
242
+ this.isNextMonthAllowed() && this.nextMonth()
243
+ }
244
+ }}
245
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${this.isNextMonthAllowed()
246
+ ? ''
247
+ : 'pkt-hide'}"
248
+ .data-disabled=${!this.isNextMonthAllowed() ? 'disabled' : nothing}
249
+ ?aria-disabled=${!this.isNextMonthAllowed()}
250
+ tabindex=${this.isNextMonthAllowed() ? '0' : '-1'}
251
+ >
252
+ <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
253
+ <span class="pkt-btn__text">${this.nextMonthString}</span>
254
+ </div>
235
255
  </div>
236
256
  </nav>
237
257
  <table
@@ -308,14 +328,20 @@ export class PktCalendar extends PktElement {
308
328
  this.maxMultiple > 0 &&
309
329
  this.selected.length >= this.maxMultiple)
310
330
  const tabindex = this.focusedDate
311
- ? this.focusedDate === currentDateISO
331
+ ? this.focusedDate === currentDateISO && !isDisabled
312
332
  ? '0'
313
333
  : '-1'
314
- : dayCounter === 1
334
+ : !isDisabled && this.tabIndexSet === 0
315
335
  ? '0'
316
- : '-1'
336
+ : this.tabIndexSet === dayCounter
337
+ ? '0'
338
+ : '-1'
317
339
 
318
- this.selectableDates.push({ currentDateISO, isDisabled })
340
+ if (tabindex === '0') {
341
+ this.tabIndexSet = dayCounter
342
+ }
343
+
344
+ this.selectableDates.push({ currentDateISO, isDisabled, tabindex })
319
345
 
320
346
  const classes = {
321
347
  'pkt-cal-today': isToday,
@@ -342,7 +368,7 @@ export class PktCalendar extends PktElement {
342
368
  this.range && !this.isExcluded(j, currentDate) && this.handleRangeHover(currentDate)
343
369
  this.focusedDate = currentDateISO
344
370
  }}
345
- tabindex=${tabindex}
371
+ tabindex=${this.selectableDates.find((x) => x.currentDateISO === currentDateISO)?.tabindex}
346
372
  data-disabled=${isDisabled ? 'disabled' : nothing}
347
373
  data-date=${currentDateISO}
348
374
  @keydown=${(e: KeyboardEvent) => {
@@ -469,7 +495,10 @@ export class PktCalendar extends PktElement {
469
495
  private changeMonth(year: number, month: number) {
470
496
  this.year = year
471
497
  this.month = month
498
+ this.tabIndexSet = 0
499
+ this.focusedDate = null
472
500
  this.selectableDates = []
501
+
473
502
  this.requestUpdate()
474
503
  }
475
504
 
@@ -623,6 +652,7 @@ export class PktCalendar extends PktElement {
623
652
  const currentDateISO = this.formatISODate(new Date())
624
653
  const el = this.querySelector(`div[data-date="${currentDateISO}"]`)
625
654
  if (el instanceof HTMLDivElement) {
655
+ this.focusedDate = currentDateISO
626
656
  el.focus()
627
657
  } else {
628
658
  const firstSelectable = this.selectableDates.find((x) => !x.isDisabled)
@@ -631,6 +661,7 @@ export class PktCalendar extends PktElement {
631
661
  `div[data-date="${firstSelectable.currentDateISO}"]`,
632
662
  )
633
663
  if (firstSelectableEl instanceof HTMLDivElement) {
664
+ this.focusedDate = firstSelectable.currentDateISO
634
665
  firstSelectableEl.focus()
635
666
  }
636
667
  }
@@ -310,6 +310,7 @@ export class PktDatepicker extends PktInputElement {
310
310
  const date = this.fromISOToDate((e.target as HTMLInputElement).value)
311
311
  if (date) {
312
312
  if (this._value[0] !== (e.target as HTMLInputElement).value && this._value[1]) {
313
+ this.clearInputValue()
313
314
  this.calRef?.value?.handleDateSelect(date)
314
315
  }
315
316
  }
@@ -1,90 +0,0 @@
1
- "use strict";const a=require("./index-DSyh6tUw.cjs"),v=require("./converters-DhM11VlY.cjs"),O=require("./directive-DtixNHDT.cjs"),$=require("./class-map-Ch54kkX5.cjs");require("./index-Bpc07w_P.cjs");function k(i){const e=Object.prototype.toString.call(i);return i instanceof Date||typeof i=="object"&&e==="[object Date]"?new i.constructor(+i):typeof i=="number"||e==="[object Number]"||typeof i=="string"||e==="[object String]"?new Date(i):new Date(NaN)}function D(i,e){return i instanceof Date?new i.constructor(e):new Date(e)}const S=6048e5,P=864e5;let _={};function w(){return _}function m(i,e){var h,c,d,u;const t=w(),s=(e==null?void 0:e.weekStartsOn)??((c=(h=e==null?void 0:e.locale)==null?void 0:h.options)==null?void 0:c.weekStartsOn)??t.weekStartsOn??((u=(d=t.locale)==null?void 0:d.options)==null?void 0:u.weekStartsOn)??0,n=k(i),r=n.getDay(),l=(r<s?7:0)+r-s;return n.setDate(n.getDate()-l),n.setHours(0,0,0,0),n}function b(i,e){const t=k(i.start),s=k(i.end);let n=+t>+s;const r=n?+t:+s,l=n?s:t;l.setHours(0,0,0,0);let h=1;const c=[];for(;+l<=r;)c.push(k(l)),l.setDate(l.getDate()+h),l.setHours(0,0,0,0);return n?c.reverse():c}function x(i,e){var u,p,f,y;const t=k(i),s=t.getFullYear(),n=w(),r=(e==null?void 0:e.firstWeekContainsDate)??((p=(u=e==null?void 0:e.locale)==null?void 0:u.options)==null?void 0:p.firstWeekContainsDate)??n.firstWeekContainsDate??((y=(f=n.locale)==null?void 0:f.options)==null?void 0:y.firstWeekContainsDate)??1,l=D(i,0);l.setFullYear(s+1,0,r),l.setHours(0,0,0,0);const h=m(l,e),c=D(i,0);c.setFullYear(s,0,r),c.setHours(0,0,0,0);const d=m(c,e);return t.getTime()>=h.getTime()?s+1:t.getTime()>=d.getTime()?s:s-1}function A(i,e){var h,c,d,u;const t=w(),s=(e==null?void 0:e.firstWeekContainsDate)??((c=(h=e==null?void 0:e.locale)==null?void 0:h.options)==null?void 0:c.firstWeekContainsDate)??t.firstWeekContainsDate??((u=(d=t.locale)==null?void 0:d.options)==null?void 0:u.firstWeekContainsDate)??1,n=x(i,e),r=D(i,0);return r.setFullYear(n,0,s),r.setHours(0,0,0,0),m(r,e)}function M(i,e){const t=k(i),s=+m(t,e)-+A(t,e);return Math.round(s/S)+1}function I(i){let t=k(i).getDay();return t===0&&(t=7),t}const T="pkt-calendar",E={id:{type:"string",name:"ID",description:"Unique identifier for the calendar"},currentmonth:{type:"date",converter:"stringToDate",description:"The current month to display"},selected:{type:"array",converter:"csvToArray",reflect:!0,items:{type:"date"},description:"Array of selected dates"},excludeweekdays:{type:"array",converter:"csvToArray",items:{type:"string"},description:"Array of weekdays (1-7) to exclude"},excludedates:{type:"array",converter:"stringsToDate",items:{type:"date"},description:"Array of specific dates to exclude"},earliest:{type:"date",converter:"stringToDate",default:null,description:"Earliest selectable date"},latest:{type:"date",converter:"stringToDate",default:null,description:"Latest selectable date"},weeknumbers:{type:"boolean",reflect:!0,default:!1,description:"Show week numbers in calendar"},withcontrols:{type:"boolean",reflect:!0,default:!1,description:"Show month and year navigation controls"},multiple:{type:"boolean",reflect:!0,default:!1,description:"Allow multiple date selection"},maxMultiple:{type:"number",default:4,description:"Maximum number of dates that can be selected"},range:{type:"boolean",reflect:!0,default:!1,description:"Allow date range selection"}},H={"date-selected":{description:"Returns ISO formatted date string"}},g={name:T,"css-class":"pkt-calendar",props:E,events:H};var R=Object.defineProperty,W=Object.getOwnPropertyDescriptor,o=(i,e,t,s)=>{for(var n=s>1?void 0:s?W(e,t):e,r=i.length-1,l;r>=0;r--)(l=i[r])&&(n=(s?l(e,t,n):l(n))||n);return s&&n&&R(e,t,n),n};exports.PktCalendar=class extends a.PktElement{constructor(){super(...arguments),this.multiple=g.props.multiple.default,this.maxMultiple=g.props.maxMultiple.default,this.range=g.props.range.default,this.weeknumbers=g.props.weeknumbers.default,this.withcontrols=g.props.withcontrols.default,this.selected=[],this.earliest=g.props.earliest.default,this.latest=g.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.dayStrings=this.strings.dates.daysShort,this.monthStrings=this.strings.dates.months,this.weekString=this.strings.dates.week,this.prevMonthString=this.strings.dates.prevMonth,this.nextMonthString=this.strings.dates.nextMonth,this._selected=[],this.year=0,this.month=0,this.week=0,this.rangeHovered=null,this.inRange={},this.focusedDate=null,this.selectableDates=[],this.currentmonthtouched=!1}connectedCallback(){super.connectedCallback()}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}attributeChangedCallback(e,t,s){e==="selected"&&s&&this.convertSelected(),super.attributeChangedCallback(e,t,s)}updated(e){e.has("selected")&&this.convertSelected(),super.updated(e)}convertSelected(){if(typeof this.selected=="string"&&(this.selected=this.selected.split(",")),this.selected.length===1&&this.selected[0]===""&&(this.selected=[]),this._selected=this.selected.map(e=>new Date(e)),this.range&&this.selected.length===2){const e=b({start:new Date(this.selected[0]),end:new Date(this.selected[1])});if(this.inRange={},Array.isArray(e)&&e.length){const t={};for(let s=0;s<e.length;s++)t[this.formatISODate(e[s])]=this.isInRange(e[s]);this.inRange=t}}this.setCurrentMonth()}setCurrentMonth(){if(this.currentmonth===null&&!this.currentmonthtouched){this.currentmonthtouched=!0;return}this.selected.length&&this.selected[0]!==""?this.currentmonth=new Date(this.selected[this.selected.length-1]):this.currentmonth===null&&(this.currentmonth=new Date),this.year=this.currentmonth.getFullYear(),this.month=this.currentmonth.getMonth()}handleKeydown(e){switch(e.key){case"ArrowLeft":this.handleArrowKey(e,-1);break;case"ArrowRight":this.handleArrowKey(e,1);break;case"ArrowUp":this.handleArrowKey(e,-7);break;case"ArrowDown":this.handleArrowKey(e,7);break}}handleArrowKey(e,t){if(e.preventDefault(),!this.focusedDate)return;const s=new Date(this.focusedDate);let n=new Date(s.setDate(s.getDate()+t));if(n){let r=this.querySelector(`div[data-date="${this.formatISODate(n)}"]`);if(r instanceof HTMLDivElement){if(r.dataset.disabled){let l=new Date(s.setDate(s.getDate()+t)),h=this.querySelector(`div[data-date="${this.formatISODate(l)}"]`);for(;h&&h instanceof HTMLDivElement&&h.dataset.disabled;)l=new Date(l.setDate(l.getDate()+t)),h=this.querySelector(`div[data-date="${this.formatISODate(l)}"]`);r=h}r instanceof HTMLDivElement&&!r.dataset.disabled&&r.focus()}}}render(){return a.x`
2
- <div
3
- class="pkt-calendar ${this.weeknumbers?"pkt-cal-weeknumbers":a.E}"
4
- @focusout=${this.closeEvent}
5
- @keydown=${e=>{e.key==="Escape"&&(e.preventDefault(),this.close())}}
6
- >
7
- <nav class="pkt-cal-month-nav">
8
- <div
9
- @click=${this.isPrevMonthAllowed()&&this.prevMonth}
10
- @keydown=${e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.isNextMonthAllowed()&&this.prevMonth())}}
11
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
12
- .data-disabled=${this.isPrevMonthAllowed()?a.E:"disabled"}
13
- ?aria-disabled=${!this.isPrevMonthAllowed()}
14
- tabindex="0"
15
- >
16
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-left"></pkt-icon>
17
- <span class="pkt-btn__text">${this.prevMonthString}</span>
18
- </div>
19
- ${this.renderMonthNav()}
20
- <div
21
- @click=${this.isNextMonthAllowed()&&this.nextMonth}
22
- @keydown=${e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.isNextMonthAllowed()&&this.nextMonth())}}
23
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
24
- .data-disabled=${this.isNextMonthAllowed()?a.E:"disabled"}
25
- ?aria-disabled=${!this.isNextMonthAllowed()}
26
- tabindex="0"
27
- >
28
- <pkt-icon class="pkt-btn__icon" name="chevron-thin-right"></pkt-icon>
29
- <span class="pkt-btn__text">${this.nextMonthString}</span>
30
- </div>
31
- </nav>
32
- <table
33
- class="pkt-cal-days pkt-txt-12-medium"
34
- role="grid"
35
- ?aria-multiselectable=${this.range||this.multiple}
36
- >
37
- ${this.renderDayNames()} ${this.renderCalendarBody()}
38
- </table>
39
- </div>
40
- `}renderDayNames(){const e=[];this.weeknumbers&&e.push(a.x`<td><div>${this.weekString}<div></td>`);for(let t=0;t<this.dayStrings.length;t++)e.push(a.x`<td><div>${this.dayStrings[t]}</div></td>`);return a.x`<tr class="pkt-cal-week-row" role="presentation">
41
- ${e}
42
- </tr>`}renderMonthNav(){let e=[];return this.withcontrols?e.push(a.x`<div class="pkt-cal-month-picker">
43
- <select
44
- class="pkt-input pkt-input-compact"
45
- @change=${t=>{this.changeMonth(this.year,t.target.value)}}
46
- >
47
- ${this.monthStrings.map((t,s)=>a.x`<option value=${s} ?selected=${this.month===s}>${t}</option>`)}
48
- </select>
49
- <input
50
- class="pkt-input pkt-cal-input-year pkt-input-compact"
51
- type="number"
52
- size="4"
53
- placeholder="0000"
54
- @change=${t=>{this.changeMonth(t.target.value,this.month)}}
55
- .value=${this.year}
56
- />
57
- </div> `):e.push(a.x`<div class="pkt-txt-16-medium" aria-live="polite">
58
- ${this.monthStrings[this.month]} ${this.year}
59
- </div>`),e}renderDayView(e,t,s){const n=new Date(this.year,this.month,e,12),r=this.formatISODate(n),l=r===this.formatISODate(t),h=this.selected.includes(r),c=this.isExcluded(s,n)||!h&&this.multiple&&this.maxMultiple>0&&this.selected.length>=this.maxMultiple,d=this.focusedDate?this.focusedDate===r?"0":"-1":e===1?"0":"-1";this.selectableDates.push({currentDateISO:r,isDisabled:c});const u={"pkt-cal-today":l,"pkt-cal-selected":h,"pkt-cal-in-range":this.inRange[r],"pkt-cal-excluded":this.isExcluded(s,n),"pkt-cal-in-range-first":this.range&&(this.selected.length===2||this.rangeHovered!==null)&&r===this.selected[0],"pkt-cal-in-range-last":this.range&&this.selected.length===2&&r===this.selected[1],"pkt-cal-range-hover":this.rangeHovered!==null&&r===this.formatISODate(this.rangeHovered)};return a.x`<td class=${$.e(u)}>
60
- <div
61
- ?aria-selected=${h}
62
- role="gridcell"
63
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
64
- @mouseover=${()=>this.range&&!this.isExcluded(s,n)&&this.handleRangeHover(n)}
65
- @focus=${()=>{this.range&&!this.isExcluded(s,n)&&this.handleRangeHover(n),this.focusedDate=r}}
66
- tabindex=${d}
67
- data-disabled=${c?"disabled":a.E}
68
- data-date=${r}
69
- @keydown=${p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),this.handleDateSelect(n))}}
70
- @click=${p=>{c||(p.preventDefault(),this.handleDateSelect(n))}}
71
- >
72
- <span class="pkt-btn__text pkt-txt-14-light">${e}</span>
73
- </div>
74
- </td>`}renderCalendarBody(){const e=new Date,t=new Date(this.year,this.month,1,12),s=new Date(this.year,this.month+1,0,12),n=(t.getDay()+6)%7,r=s.getDate(),l=Math.ceil((r+n)/7),c=new Date(this.year,this.month,0,12).getDate();let d=1;this.week=M(new Date(this.year,this.month,1,12));const u=[];for(let p=0;p<l;p++){const f=[];this.weeknumbers&&f.push(a.x`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let y=1;y<8;y++)if(p===0&&y<n+1){const C=c-(n-y);f.push(a.x`<td class="pkt-cal-other">
75
- <div
76
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
77
- data-disabled="disabled"
78
- >
79
- <span class="pkt-btn__text pkt-txt-14-light">${C}</span>
80
- </div>
81
- </td>`)}else d>r?(f.push(a.x`<td class="pkt-cal-other">
82
- <div
83
- class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
84
- data-disabled="disabled"
85
- >
86
- <span class="pkt-btn__text pkt-txt-14-light">${d-r}</span>
87
- </div>
88
- </td>`),d++):(f.push(this.renderDayView(d,e,y)),d++);u.push(a.x`<tr class="pkt-cal-week-row" role="row">
89
- ${f}
90
- </tr>`)}return u}isExcluded(e,t){return this.excludeweekdays.includes(e.toString())||this.earliest&&t<new Date(this.earliest)||this.latest&&t>new Date(this.latest)?!0:this.excludedates.some(s=>typeof s=="string"?s===this.formatISODate(t):s.toDateString()===t.toDateString())}formatISODate(e){return e.toISOString().split("T")[0]}isPrevMonthAllowed(){const e=new Date(this.year,this.month,0,12);return!(this.earliest&&new Date(this.earliest)>e)}prevMonth(){const e=this.month===0?11:this.month-1,t=this.month===0?this.year-1:this.year;this.changeMonth(t,e)}isNextMonthAllowed(){const e=new Date(this.year,this.month===11?0:this.month+1,1,12);return!(this.latest&&new Date(this.latest)<e)}nextMonth(){const e=this.month===11?0:this.month+1,t=this.month===11?this.year+1:this.year;this.changeMonth(t,e)}changeMonth(e,t){this.year=e,this.month=t,this.selectableDates=[],this.requestUpdate()}isInRange(e){if(this.range&&this.selected.length===2){if(e>new Date(this.selected[0])&&e<new Date(this.selected[1]))return!0}else if(this.range&&this.selected.length===1&&this.rangeHovered&&e>new Date(this.selected[0])&&e<this.rangeHovered)return!0;return!1}isRangeAllowed(e){let t=!0;if(this._selected.length===1){const s=b({start:this._selected[0],end:e});if(Array.isArray(s)&&s.length)for(let n=0;n<s.length;n++)this.excludedates.forEach(r=>{r>this._selected[0]&&r<e&&(t=!1)}),this.excludeweekdays.includes(I(s[n]).toString())&&(t=!1)}return t}emptySelected(){this.selected=[],this._selected=[],this.inRange={}}addToSelected(e){this.selected.includes(this.formatISODate(e))||(this.selected=[...this.selected,this.formatISODate(e)],this._selected=[...this._selected,e],this.range&&this.selected.length===2&&this.close())}removeFromSelected(e){if(this.selected.length===1)this.emptySelected();else{const t=this.selected.indexOf(this.formatISODate(e)),s=[...this.selected],n=[...this._selected];s.splice(t,1),n.splice(t,1),this.selected=s,this._selected=n}}toggleSelected(e){const t=this.formatISODate(e);this.selected.includes(t)?this.removeFromSelected(e):this.maxMultiple&&this.selected.length>=this.maxMultiple||this.addToSelected(e)}handleRangeSelect(e){const t=this.formatISODate(e);return this.selected.includes(t)?this.selected.indexOf(t)===0?this.emptySelected():this.removeFromSelected(e):this.selected.length>1?(this.emptySelected(),this.addToSelected(e)):(this.selected.length===1&&!this.isRangeAllowed(e)&&this.emptySelected(),this.selected.length===1&&this._selected[0]>e&&this.emptySelected(),this.addToSelected(e)),Promise.resolve()}handleRangeHover(e){if(this.range&&this._selected.length===1&&this.isRangeAllowed(e)&&this._selected[0]<e){this.rangeHovered=e,this.inRange={};const t=b({start:this._selected[0],end:e});if(Array.isArray(t)&&t.length)for(let s=0;s<t.length;s++)this.inRange[this.formatISODate(t[s])]=this.isInRange(t[s])}else this.rangeHovered=null}handleDateSelect(e){if(e)return this.range?this.handleRangeSelect(e):this.multiple?this.toggleSelected(e):(this.selected.includes(this.formatISODate(e))?this.emptySelected():(this.emptySelected(),this.addToSelected(e)),this.close()),this.dispatchEvent(new CustomEvent("date-selected",{detail:this.selected,bubbles:!0,composed:!0})),Promise.resolve()}focusOnCurrentDate(){const e=this.formatISODate(new Date),t=this.querySelector(`div[data-date="${e}"]`);if(t instanceof HTMLDivElement)t.focus();else{const s=this.selectableDates.find(n=>!n.isDisabled);if(s){const n=this.querySelector(`div[data-date="${s.currentDateISO}"]`);n instanceof HTMLDivElement&&n.focus()}}}closeEvent(e){this.contains(e.relatedTarget)||this.close()}close(){this.dispatchEvent(new CustomEvent("close",{detail:!0,bubbles:!0,composed:!0}))}};o([a.n({type:Boolean})],exports.PktCalendar.prototype,"multiple",2);o([a.n({type:Number})],exports.PktCalendar.prototype,"maxMultiple",2);o([a.n({type:Boolean})],exports.PktCalendar.prototype,"range",2);o([a.n({type:Boolean})],exports.PktCalendar.prototype,"weeknumbers",2);o([a.n({type:Boolean})],exports.PktCalendar.prototype,"withcontrols",2);o([a.n({converter:v.converters.csvToArray})],exports.PktCalendar.prototype,"selected",2);o([a.n({type:String})],exports.PktCalendar.prototype,"earliest",2);o([a.n({type:String})],exports.PktCalendar.prototype,"latest",2);o([a.n({converter:v.converters.stringsToDate})],exports.PktCalendar.prototype,"excludedates",2);o([a.n({converter:v.converters.csvToArray})],exports.PktCalendar.prototype,"excludeweekdays",2);o([a.n({converter:v.converters.stringToDate})],exports.PktCalendar.prototype,"currentmonth",2);o([a.n({type:Array})],exports.PktCalendar.prototype,"dayStrings",2);o([a.n({type:Array})],exports.PktCalendar.prototype,"monthStrings",2);o([a.n({type:String})],exports.PktCalendar.prototype,"weekString",2);o([a.n({type:String})],exports.PktCalendar.prototype,"prevMonthString",2);o([a.n({type:String})],exports.PktCalendar.prototype,"nextMonthString",2);o([a.n({type:Array})],exports.PktCalendar.prototype,"_selected",2);o([a.n({type:Number})],exports.PktCalendar.prototype,"year",2);o([a.n({type:Number})],exports.PktCalendar.prototype,"month",2);o([a.n({type:Number})],exports.PktCalendar.prototype,"week",2);o([a.n({type:Date})],exports.PktCalendar.prototype,"rangeHovered",2);o([a.r()],exports.PktCalendar.prototype,"inRange",2);o([a.r()],exports.PktCalendar.prototype,"focusedDate",2);o([a.r()],exports.PktCalendar.prototype,"selectableDates",2);o([a.r()],exports.PktCalendar.prototype,"currentmonthtouched",2);exports.PktCalendar=o([O.t("pkt-calendar")],exports.PktCalendar);exports.constructFrom=D;exports.getDefaultOptions=w;exports.getWeek=M;exports.getWeekYear=x;exports.millisecondsInDay=P;exports.millisecondsInWeek=S;exports.startOfWeek=m;exports.toDate=k;