@oslokommune/punkt-elements 12.3.0 → 12.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/{class-map-DiT0qP3E.js → class-map-CEzmgstO.js} +1 -1
  2. package/dist/{class-map-CA8wadiN.cjs → class-map-DfznHRRW.cjs} +1 -1
  3. package/dist/{index-DSplpVWQ.cjs → index-BCVyjeWS.cjs} +1 -1
  4. package/dist/{index-CPvZ03uX.js → index-BkKs8Yam.js} +52 -53
  5. package/dist/index-BkqOsymS.cjs +90 -0
  6. package/dist/{index-BlHnvy7v.js → index-C7OaW8f8.js} +1 -1
  7. package/dist/{index-BHzxfdBK.js → index-CINnuWkG.js} +113 -97
  8. package/dist/{index-BJ_4AGO3.cjs → index-CkBUiPHx.cjs} +10 -6
  9. package/dist/index.d.ts +2 -0
  10. package/dist/pkt-alert.cjs +1 -1
  11. package/dist/pkt-alert.js +4 -4
  12. package/dist/pkt-calendar.cjs +1 -1
  13. package/dist/pkt-calendar.js +5 -6
  14. package/dist/pkt-card.cjs +1 -1
  15. package/dist/pkt-card.js +4 -4
  16. package/dist/pkt-component-template.cjs +1 -1
  17. package/dist/pkt-component-template.js +3 -3
  18. package/dist/pkt-datepicker.cjs +3 -3
  19. package/dist/pkt-datepicker.js +444 -442
  20. package/dist/pkt-element.cjs +1 -1
  21. package/dist/pkt-element.js +1 -1
  22. package/dist/pkt-icon.cjs +1 -1
  23. package/dist/pkt-icon.js +2 -2
  24. package/dist/pkt-index.cjs +1 -1
  25. package/dist/pkt-index.js +2 -2
  26. package/dist/pkt-input-wrapper.cjs +1 -1
  27. package/dist/pkt-input-wrapper.js +4 -4
  28. package/dist/pkt-link.cjs +1 -1
  29. package/dist/pkt-link.js +4 -4
  30. package/dist/pkt-messagebox.cjs +1 -1
  31. package/dist/pkt-messagebox.js +4 -4
  32. package/dist/pkt-tag.cjs +2 -2
  33. package/dist/pkt-tag.js +18 -19
  34. package/dist/{ref-Bk590hog.cjs → ref-BkUqMgQu.cjs} +1 -1
  35. package/dist/{ref-Co_S0Cgj.js → ref-Cau3ksvI.js} +1 -1
  36. package/package.json +3 -3
  37. package/src/components/datepicker/index.ts +13 -11
  38. package/src/components/element/index.ts +7 -1
  39. package/dist/index-DkGcZra2.cjs +0 -90
  40. package/dist/state-BRgFbJX9.js +0 -12
  41. package/dist/state-D2tUtTi6.cjs +0 -5
@@ -1,4 +1,4 @@
1
- import { R as a } from "./index-BHzxfdBK.js";
1
+ import { R as a } from "./index-CINnuWkG.js";
2
2
  import { e as h, i as d, a as c } from "./directive-DA0-wdk7.js";
3
3
  /**
4
4
  * @license
@@ -1,4 +1,4 @@
1
- "use strict";const a=require("./index-BJ_4AGO3.cjs"),n=require("./directive-19_ixLKS.cjs");/**
1
+ "use strict";const a=require("./index-CkBUiPHx.cjs"),n=require("./directive-19_ixLKS.cjs");/**
2
2
  * @license
3
3
  * Copyright 2018 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
@@ -1,4 +1,4 @@
1
- "use strict";const o=require("./index-BJ_4AGO3.cjs"),n=require("./directive-19_ixLKS.cjs");/**
1
+ "use strict";const o=require("./index-CkBUiPHx.cjs"),n=require("./directive-19_ixLKS.cjs");/**
2
2
  * @license
3
3
  * Copyright 2017 Google LLC
4
4
  * SPDX-License-Identifier: BSD-3-Clause
@@ -1,9 +1,8 @@
1
- import { P as _, k as f, D, n as h } from "./index-BHzxfdBK.js";
1
+ import { r as M, P as _, k as f, D, n as h } from "./index-CINnuWkG.js";
2
2
  import { a as b } from "./converters-DNCwIFwr.js";
3
3
  import { t as A } from "./directive-DA0-wdk7.js";
4
- import { r as M } from "./state-BRgFbJX9.js";
5
- import { R as I } from "./class-map-DiT0qP3E.js";
6
- import "./index-BlHnvy7v.js";
4
+ import { R as I } from "./class-map-CEzmgstO.js";
5
+ import "./index-C7OaW8f8.js";
7
6
  function k(e) {
8
7
  const t = Object.prototype.toString.call(e);
9
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);
@@ -11,32 +10,32 @@ function k(e) {
11
10
  function x(e, t) {
12
11
  return e instanceof Date ? new e.constructor(t) : new Date(t);
13
12
  }
14
- const T = 6048e5, V = 864e5;
13
+ const T = 6048e5, U = 864e5;
15
14
  let E = {};
16
15
  function O() {
17
16
  return E;
18
17
  }
19
18
  function v(e, t) {
20
19
  var p, c, u, d;
21
- const s = O(), n = (t == null ? void 0 : t.weekStartsOn) ?? ((c = (p = t == null ? void 0 : t.locale) == null ? void 0 : p.options) == null ? void 0 : c.weekStartsOn) ?? s.weekStartsOn ?? ((d = (u = s.locale) == null ? void 0 : u.options) == null ? void 0 : d.weekStartsOn) ?? 0, a = k(e), o = a.getDay(), r = (o < n ? 7 : 0) + o - n;
22
- return a.setDate(a.getDate() - r), a.setHours(0, 0, 0, 0), a;
20
+ const s = O(), n = (t == null ? void 0 : t.weekStartsOn) ?? ((c = (p = t == null ? void 0 : t.locale) == null ? void 0 : p.options) == null ? void 0 : c.weekStartsOn) ?? s.weekStartsOn ?? ((d = (u = s.locale) == null ? void 0 : u.options) == null ? void 0 : d.weekStartsOn) ?? 0, a = k(e), o = a.getDay(), i = (o < n ? 7 : 0) + o - n;
21
+ return a.setDate(a.getDate() - i), a.setHours(0, 0, 0, 0), a;
23
22
  }
24
23
  function S(e, t) {
25
24
  const s = k(e.start), n = k(e.end);
26
25
  let a = +s > +n;
27
- const o = a ? +s : +n, r = a ? n : s;
28
- r.setHours(0, 0, 0, 0);
26
+ const o = a ? +s : +n, i = a ? n : s;
27
+ i.setHours(0, 0, 0, 0);
29
28
  let p = 1;
30
29
  const c = [];
31
- for (; +r <= o; )
32
- c.push(k(r)), r.setDate(r.getDate() + p), r.setHours(0, 0, 0, 0);
30
+ for (; +i <= o; )
31
+ c.push(k(i)), i.setDate(i.getDate() + p), i.setHours(0, 0, 0, 0);
33
32
  return a ? c.reverse() : c;
34
33
  }
35
34
  function R(e, t) {
36
35
  var d, y, m, w;
37
- const s = k(e), n = s.getFullYear(), a = 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) ?? a.firstWeekContainsDate ?? ((w = (m = a.locale) == null ? void 0 : m.options) == null ? void 0 : w.firstWeekContainsDate) ?? 1, r = x(e, 0);
38
- r.setFullYear(n + 1, 0, o), r.setHours(0, 0, 0, 0);
39
- const p = v(r, t), c = x(e, 0);
36
+ const s = k(e), n = s.getFullYear(), a = 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) ?? a.firstWeekContainsDate ?? ((w = (m = a.locale) == null ? void 0 : m.options) == null ? void 0 : w.firstWeekContainsDate) ?? 1, i = x(e, 0);
37
+ i.setFullYear(n + 1, 0, o), i.setHours(0, 0, 0, 0);
38
+ const p = v(i, t), c = x(e, 0);
40
39
  c.setFullYear(n, 0, o), c.setHours(0, 0, 0, 0);
41
40
  const u = v(c, t);
42
41
  return s.getTime() >= p.getTime() ? n + 1 : s.getTime() >= u.getTime() ? n : n - 1;
@@ -142,11 +141,11 @@ const N = "pkt-calendar", P = {
142
141
  events: W
143
142
  };
144
143
  var Y = Object.defineProperty, F = Object.getOwnPropertyDescriptor, l = (e, t, s, n) => {
145
- for (var a = n > 1 ? void 0 : n ? F(t, s) : t, o = e.length - 1, r; o >= 0; o--)
146
- (r = e[o]) && (a = (n ? r(t, s, a) : r(a)) || a);
144
+ for (var a = n > 1 ? void 0 : n ? F(t, s) : t, o = e.length - 1, i; o >= 0; o--)
145
+ (i = e[o]) && (a = (n ? i(t, s, a) : i(a)) || a);
147
146
  return n && a && Y(t, s, a), a;
148
147
  };
149
- let i = class extends _ {
148
+ let r = class extends _ {
150
149
  /**
151
150
  * If we are initializing props, slots and events from specs, we should do it in the constructor
152
151
  */
@@ -207,10 +206,10 @@ let i = class extends _ {
207
206
  let a = this.querySelector(`div[data-date="${this.formatISODate(n)}"]`);
208
207
  if (a instanceof HTMLDivElement) {
209
208
  if (a.dataset.disabled) {
210
- let o = new Date(s.setDate(s.getDate() + t)), r = this.querySelector(`div[data-date="${this.formatISODate(o)}"]`);
211
- for (; r && r instanceof HTMLDivElement && r.dataset.disabled; )
212
- o = new Date(o.setDate(o.getDate() + t)), r = this.querySelector(`div[data-date="${this.formatISODate(o)}"]`);
213
- a = r;
209
+ let o = new Date(s.setDate(s.getDate() + t)), i = this.querySelector(`div[data-date="${this.formatISODate(o)}"]`);
210
+ for (; i && i instanceof HTMLDivElement && i.dataset.disabled; )
211
+ o = new Date(o.setDate(o.getDate() + t)), i = this.querySelector(`div[data-date="${this.formatISODate(o)}"]`);
212
+ a = i;
214
213
  }
215
214
  a instanceof HTMLDivElement && !a.dataset.disabled && a.focus();
216
215
  }
@@ -308,11 +307,11 @@ let i = class extends _ {
308
307
  ), e;
309
308
  }
310
309
  renderDayView(e, t, s) {
311
- const n = new Date(this.year, this.month, e, 12), a = this.formatISODate(n), o = a === this.formatISODate(t), r = this.selected.includes(a), p = this.isExcluded(s, n) || !r && this.multiple && this.maxMultiple > 0 && this.selected.length >= this.maxMultiple, c = this.focusedDate ? this.focusedDate === a ? "0" : "-1" : e === 1 ? "0" : "-1";
310
+ const n = new Date(this.year, this.month, e, 12), a = this.formatISODate(n), o = a === this.formatISODate(t), i = this.selected.includes(a), p = this.isExcluded(s, n) || !i && this.multiple && this.maxMultiple > 0 && this.selected.length >= this.maxMultiple, c = this.focusedDate ? this.focusedDate === a ? "0" : "-1" : e === 1 ? "0" : "-1";
312
311
  this.selectableDates.push({ currentDateISO: a, isDisabled: p });
313
312
  const u = {
314
313
  "pkt-cal-today": o,
315
- "pkt-cal-selected": r,
314
+ "pkt-cal-selected": i,
316
315
  "pkt-cal-in-range": this.inRange[a],
317
316
  "pkt-cal-excluded": this.isExcluded(s, n),
318
317
  "pkt-cal-in-range-first": this.range && (this.selected.length === 2 || this.rangeHovered !== null) && a === this.selected[0],
@@ -321,7 +320,7 @@ let i = class extends _ {
321
320
  };
322
321
  return f`<td class=${I(u)}>
323
322
  <div
324
- ?aria-selected=${r}
323
+ ?aria-selected=${i}
325
324
  role="gridcell"
326
325
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
327
326
  @mouseover=${() => this.range && !this.isExcluded(s, n) && this.handleRangeHover(n)}
@@ -488,90 +487,90 @@ let i = class extends _ {
488
487
  };
489
488
  l([
490
489
  h({ type: Boolean, reflect: !0 })
491
- ], i.prototype, "multiple", 2);
490
+ ], r.prototype, "multiple", 2);
492
491
  l([
493
492
  h({ type: Number })
494
- ], i.prototype, "maxMultiple", 2);
493
+ ], r.prototype, "maxMultiple", 2);
495
494
  l([
496
495
  h({ type: Boolean, reflect: !0 })
497
- ], i.prototype, "range", 2);
496
+ ], r.prototype, "range", 2);
498
497
  l([
499
498
  h({ type: Boolean, reflect: !0 })
500
- ], i.prototype, "weeknumbers", 2);
499
+ ], r.prototype, "weeknumbers", 2);
501
500
  l([
502
501
  h({ type: Boolean, reflect: !0 })
503
- ], i.prototype, "withcontrols", 2);
502
+ ], r.prototype, "withcontrols", 2);
504
503
  l([
505
504
  h({ type: Boolean, reflect: !0 })
506
- ], i.prototype, "focused", 2);
505
+ ], r.prototype, "focused", 2);
507
506
  l([
508
507
  h({ converter: b.csvToArray })
509
- ], i.prototype, "selected", 2);
508
+ ], r.prototype, "selected", 2);
510
509
  l([
511
510
  h({ type: String, reflect: !0 })
512
- ], i.prototype, "earliest", 2);
511
+ ], r.prototype, "earliest", 2);
513
512
  l([
514
513
  h({ type: String, reflect: !0 })
515
- ], i.prototype, "latest", 2);
514
+ ], r.prototype, "latest", 2);
516
515
  l([
517
516
  h({ converter: b.stringsToDate })
518
- ], i.prototype, "excludedates", 2);
517
+ ], r.prototype, "excludedates", 2);
519
518
  l([
520
519
  h({ converter: b.csvToArray })
521
- ], i.prototype, "excludeweekdays", 2);
520
+ ], r.prototype, "excludeweekdays", 2);
522
521
  l([
523
522
  h({ converter: b.stringToDate })
524
- ], i.prototype, "currentmonth", 2);
523
+ ], r.prototype, "currentmonth", 2);
525
524
  l([
526
525
  h({ type: Array })
527
- ], i.prototype, "dayStrings", 2);
526
+ ], r.prototype, "dayStrings", 2);
528
527
  l([
529
528
  h({ type: Array })
530
- ], i.prototype, "monthStrings", 2);
529
+ ], r.prototype, "monthStrings", 2);
531
530
  l([
532
531
  h({ type: String })
533
- ], i.prototype, "weekString", 2);
532
+ ], r.prototype, "weekString", 2);
534
533
  l([
535
534
  h({ type: String })
536
- ], i.prototype, "prevMonthString", 2);
535
+ ], r.prototype, "prevMonthString", 2);
537
536
  l([
538
537
  h({ type: String })
539
- ], i.prototype, "nextMonthString", 2);
538
+ ], r.prototype, "nextMonthString", 2);
540
539
  l([
541
540
  h({ type: Array })
542
- ], i.prototype, "_selected", 2);
541
+ ], r.prototype, "_selected", 2);
543
542
  l([
544
543
  h({ type: Number })
545
- ], i.prototype, "year", 2);
544
+ ], r.prototype, "year", 2);
546
545
  l([
547
546
  h({ type: Number })
548
- ], i.prototype, "month", 2);
547
+ ], r.prototype, "month", 2);
549
548
  l([
550
549
  h({ type: Number })
551
- ], i.prototype, "week", 2);
550
+ ], r.prototype, "week", 2);
552
551
  l([
553
552
  h({ type: Date })
554
- ], i.prototype, "rangeHovered", 2);
553
+ ], r.prototype, "rangeHovered", 2);
555
554
  l([
556
555
  M()
557
- ], i.prototype, "inRange", 2);
556
+ ], r.prototype, "inRange", 2);
558
557
  l([
559
558
  M()
560
- ], i.prototype, "focusedDate", 2);
559
+ ], r.prototype, "focusedDate", 2);
561
560
  l([
562
561
  M()
563
- ], i.prototype, "selectableDates", 2);
564
- i = l([
562
+ ], r.prototype, "selectableDates", 2);
563
+ r = l([
565
564
  A("pkt-calendar")
566
- ], i);
565
+ ], r);
567
566
  export {
568
- i as P,
567
+ r as P,
569
568
  T as a,
570
569
  $ as b,
571
570
  x as c,
572
571
  O as d,
573
572
  R as g,
574
- V as m,
573
+ U as m,
575
574
  v as s,
576
575
  k as t
577
576
  };
@@ -0,0 +1,90 @@
1
+ "use strict";const a=require("./index-CkBUiPHx.cjs"),w=require("./converters-DhM11VlY.cjs"),C=require("./directive-19_ixLKS.cjs"),$=require("./class-map-DfznHRRW.cjs");require("./index-BCVyjeWS.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 x=6048e5,P=864e5;let _={};function v(){return _}function m(i,e){var h,c,d,p;const t=v(),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??((p=(d=t.locale)==null?void 0:d.options)==null?void 0:p.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 M(i,e){var p,u,f,y;const t=k(i),s=t.getFullYear(),n=v(),r=(e==null?void 0:e.firstWeekContainsDate)??((u=(p=e==null?void 0:e.locale)==null?void 0:p.options)==null?void 0:u.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,p;const t=v(),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??((p=(d=t.locale)==null?void 0:d.options)==null?void 0:p.firstWeekContainsDate)??1,n=M(i,e),r=D(i,0);return r.setFullYear(n,0,s),r.setHours(0,0,0,0),m(r,e)}function S(i,e){const t=k(i),s=+m(t,e)-+A(t,e);return Math.round(s/x)+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"}},R={"date-selected":{description:"Returns ISO formatted date string"}},g={name:T,"css-class":"pkt-calendar",props:E,events:R};var W=Object.defineProperty,H=Object.getOwnPropertyDescriptor,o=(i,e,t,s)=>{for(var n=s>1?void 0:s?H(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&&W(e,t,n),n};exports.PktCalendar=class extends a.PktElement{constructor(){super(),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.focused=!1,this.selected=[],this.earliest=g.props.earliest.default,this.latest=g.props.latest.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=new Date,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=[]}connectedCallback(){const e=this.currentmonth;this.year=e.getFullYear(),this.month=e.getMonth(),this.week=S(new Date(this.year,this.month,1,12)),this.selected&&this.selected.length&&this.selected.forEach(t=>{this._selected.push(new Date(t))}),super.connectedCallback()}disconnectedCallback(){this.removeEventListener("keydown",this.handleKeydown),super.disconnectedCallback()}updated(e){if(e.has("selected")&&this.selected.length===2){const t=b({start:new Date(this.selected[0]),end:new Date(this.selected[1])});if(this.inRange={},Array.isArray(t)&&t.length){const s={};for(let n=0;n<t.length;n++)s[this.formatISODate(t[n])]=this.isInRange(t[n]);this.inRange=s}}super.updated(e)}firstUpdated(e){this.addEventListener("keydown",this.handleKeydown)}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.ke`
2
+ <div
3
+ class="pkt-calendar ${this.weeknumbers?"pkt-cal-weeknumbers":a.D}"
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.D:"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.D:"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.ke`<td><div>${this.weekString}<div></td>`);for(let t=0;t<this.dayStrings.length;t++)e.push(a.ke`<td><div>${this.dayStrings[t]}</div></td>`);return a.ke`<tr class="pkt-cal-week-row" role="presentation">
41
+ ${e}
42
+ </tr>`}renderMonthNav(){let e=[];return this.withcontrols?e.push(a.ke`<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.ke`<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.ke`<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 p={"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.ke`<td class=${$.Rt(p)}>
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.D}
68
+ data-date=${r}
69
+ @keydown=${u=>{(u.key==="Enter"||u.key===" ")&&(u.preventDefault(),this.handleDateSelect(n))}}
70
+ @click=${u=>{c||(u.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=S(new Date(this.year,this.month,1,12));const p=[];for(let u=0;u<l;u++){const f=[];this.weeknumbers&&f.push(a.ke`<td class="pkt-cal-week">${this.week}</td>`),this.week++;for(let y=1;y<8;y++)if(u===0&&y<n+1){const O=c-(n-y-1);f.push(a.ke`<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">${O}</span>
80
+ </div>
81
+ </td>`)}else d>r?(f.push(a.ke`<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++);p.push(a.ke`<tr class="pkt-cal-week-row" role="row">
89
+ ${f}
90
+ </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.selectableDates=[],this.requestUpdate("currentmonth")}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])}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()}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,reflect:!0})],exports.PktCalendar.prototype,"multiple",2);o([a.n({type:Number})],exports.PktCalendar.prototype,"maxMultiple",2);o([a.n({type:Boolean,reflect:!0})],exports.PktCalendar.prototype,"range",2);o([a.n({type:Boolean,reflect:!0})],exports.PktCalendar.prototype,"weeknumbers",2);o([a.n({type:Boolean,reflect:!0})],exports.PktCalendar.prototype,"withcontrols",2);o([a.n({type:Boolean,reflect:!0})],exports.PktCalendar.prototype,"focused",2);o([a.n({converter:w.converters.csvToArray})],exports.PktCalendar.prototype,"selected",2);o([a.n({type:String,reflect:!0})],exports.PktCalendar.prototype,"earliest",2);o([a.n({type:String,reflect:!0})],exports.PktCalendar.prototype,"latest",2);o([a.n({converter:w.converters.stringsToDate})],exports.PktCalendar.prototype,"excludedates",2);o([a.n({converter:w.converters.csvToArray})],exports.PktCalendar.prototype,"excludeweekdays",2);o([a.n({converter:w.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);exports.PktCalendar=o([C.t("pkt-calendar")],exports.PktCalendar);exports.constructFrom=D;exports.getDefaultOptions=v;exports.getWeek=S;exports.getWeekYear=M;exports.millisecondsInDay=P;exports.millisecondsInWeek=x;exports.startOfWeek=m;exports.toDate=k;
@@ -1,4 +1,4 @@
1
- import { D as w, R as g, P as y, k as P, n as a } from "./index-BHzxfdBK.js";
1
+ import { D as w, R as g, P as y, k as P, n as a } from "./index-CINnuWkG.js";
2
2
  import { i as m, a as k, e as v, t as _ } from "./directive-DA0-wdk7.js";
3
3
  /**
4
4
  * @license