@oslokommune/punkt-elements 12.3.11 → 12.3.14

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 (40) hide show
  1. package/dist/{class-map-D5yOTE4V.cjs → class-map-BQ5k1q3A.cjs} +1 -1
  2. package/dist/{class-map-CQf6i-xX.js → class-map-CL_lSLwn.js} +1 -1
  3. package/dist/{index-BGPEwMZQ.cjs → index-BFqUD8HI.cjs} +1 -1
  4. package/dist/{index-cmcwixge.cjs → index-BUZITHLd.cjs} +6 -6
  5. package/dist/index-Bc9mksHI.cjs +90 -0
  6. package/dist/{index-erLPjF21.js → index-DQ5xnGw6.js} +134 -129
  7. package/dist/{index-BtB1fCeq.js → index-exzYRW0z.js} +1 -1
  8. package/dist/{index-DFB6cAPd.js → index-m5WP1NKD.js} +3 -3
  9. package/dist/index.d.ts +6 -4
  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 +4 -4
  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 +14 -14
  19. package/dist/pkt-datepicker.js +59 -53
  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 +1 -1
  33. package/dist/pkt-tag.js +4 -4
  34. package/dist/{ref-CRbDaFY5.cjs → ref-BdbjJbqo.cjs} +1 -1
  35. package/dist/{ref-ClWSy3zg.js → ref-bNNrgsqL.js} +1 -1
  36. package/package.json +2 -2
  37. package/src/components/calendar/index.ts +51 -46
  38. package/src/components/datepicker/index.ts +25 -11
  39. package/src/components/element/index.ts +3 -3
  40. package/dist/index-Bfdr5FsZ.cjs +0 -90
@@ -1,8 +1,8 @@
1
- import { r as O, P as _, k as f, D as w, n as c } from "./index-DFB6cAPd.js";
2
- import { a as b } from "./converters-DNCwIFwr.js";
3
- import { t as A } from "./directive-DA0-wdk7.js";
4
- import { R as I } from "./class-map-CQf6i-xX.js";
5
- import "./index-BtB1fCeq.js";
1
+ import { r as b, P as $, k as f, D as w, n as c } from "./index-m5WP1NKD.js";
2
+ import { a as S } from "./converters-DNCwIFwr.js";
3
+ import { t as _ } from "./directive-DA0-wdk7.js";
4
+ import { R as A } from "./class-map-CL_lSLwn.js";
5
+ import "./index-exzYRW0z.js";
6
6
  function k(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);
@@ -10,50 +10,50 @@ function k(e) {
10
10
  function M(e, t) {
11
11
  return e instanceof Date ? new e.constructor(t) : new Date(t);
12
12
  }
13
- const T = 6048e5, U = 864e5;
14
- let E = {};
15
- function $() {
16
- return E;
13
+ const I = 6048e5, U = 864e5;
14
+ let T = {};
15
+ function O() {
16
+ return T;
17
17
  }
18
18
  function v(e, t) {
19
19
  var p, h, u, d;
20
- const s = $(), 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, a = k(e), l = a.getDay(), i = (l < n ? 7 : 0) + l - n;
21
- return a.setDate(a.getDate() - i), a.setHours(0, 0, 0, 0), a;
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;
21
+ return i.setDate(i.getDate() - a), i.setHours(0, 0, 0, 0), i;
22
22
  }
23
- function S(e, t) {
23
+ function x(e, t) {
24
24
  const s = k(e.start), n = k(e.end);
25
- let a = +s > +n;
26
- const l = a ? +s : +n, i = a ? n : s;
27
- i.setHours(0, 0, 0, 0);
25
+ let i = +s > +n;
26
+ const o = i ? +s : +n, a = i ? n : s;
27
+ a.setHours(0, 0, 0, 0);
28
28
  let p = 1;
29
29
  const h = [];
30
- for (; +i <= l; )
31
- h.push(k(i)), i.setDate(i.getDate() + p), i.setHours(0, 0, 0, 0);
32
- return a ? h.reverse() : h;
30
+ for (; +a <= o; )
31
+ h.push(k(a)), a.setDate(a.getDate() + p), a.setHours(0, 0, 0, 0);
32
+ return i ? h.reverse() : h;
33
33
  }
34
34
  function C(e, t) {
35
35
  var d, y, m, D;
36
- const s = k(e), n = s.getFullYear(), a = $(), l = (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 ?? ((D = (m = a.locale) == null ? void 0 : m.options) == null ? void 0 : D.firstWeekContainsDate) ?? 1, i = M(e, 0);
37
- i.setFullYear(n + 1, 0, l), i.setHours(0, 0, 0, 0);
38
- const p = v(i, t), h = M(e, 0);
39
- h.setFullYear(n, 0, l), h.setHours(0, 0, 0, 0);
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);
37
+ a.setFullYear(n + 1, 0, o), a.setHours(0, 0, 0, 0);
38
+ const p = v(a, t), h = M(e, 0);
39
+ h.setFullYear(n, 0, o), h.setHours(0, 0, 0, 0);
40
40
  const u = v(h, t);
41
41
  return s.getTime() >= p.getTime() ? n + 1 : s.getTime() >= u.getTime() ? n : n - 1;
42
42
  }
43
- function R(e, t) {
43
+ function E(e, t) {
44
44
  var p, h, u, d;
45
- const s = $(), 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, a = C(e, t), l = M(e, 0);
46
- return l.setFullYear(a, 0, n), l.setHours(0, 0, 0, 0), v(l, t);
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);
47
47
  }
48
- function x(e, t) {
49
- const s = k(e), n = +v(s, t) - +R(s, t);
50
- return Math.round(n / T) + 1;
48
+ function R(e, t) {
49
+ const s = k(e), n = +v(s, t) - +E(s, t);
50
+ return Math.round(n / I) + 1;
51
51
  }
52
52
  function H(e) {
53
53
  let s = k(e).getDay();
54
54
  return s === 0 && (s = 7), s;
55
55
  }
56
- const N = "pkt-calendar", P = {
56
+ const N = "pkt-calendar", W = {
57
57
  id: {
58
58
  type: "string",
59
59
  name: "ID",
@@ -130,62 +130,64 @@ const N = "pkt-calendar", P = {
130
130
  default: !1,
131
131
  description: "Allow date range selection"
132
132
  }
133
- }, W = {
133
+ }, P = {
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: P,
141
- events: W
140
+ props: W,
141
+ events: P
142
142
  };
143
- var Y = Object.defineProperty, F = Object.getOwnPropertyDescriptor, o = (e, t, s, n) => {
144
- for (var a = n > 1 ? void 0 : n ? F(t, s) : t, l = e.length - 1, i; l >= 0; l--)
145
- (i = e[l]) && (a = (n ? i(t, s, a) : i(a)) || a);
146
- return n && a && Y(t, s, a), a;
143
+ var Y = Object.defineProperty, F = Object.getOwnPropertyDescriptor, l = (e, t, s, n) => {
144
+ for (var i = n > 1 ? void 0 : n ? F(t, s) : t, o = e.length - 1, a; o >= 0; o--)
145
+ (a = e[o]) && (i = (n ? a(t, s, i) : a(i)) || i);
146
+ return n && i && Y(t, s, i), i;
147
147
  };
148
- let r = class extends _ {
148
+ let r = class extends $ {
149
149
  /**
150
150
  * If we are initializing props, slots and events from specs, we should do it in the constructor
151
151
  */
152
152
  constructor() {
153
- 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.selected = [], this.earliest = g.props.earliest.default, this.latest = g.props.latest.default, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = /* @__PURE__ */ 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 = [];
153
+ 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.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;
154
154
  }
155
155
  /**
156
156
  * Runs on mount, used to set up various values and whatever you need to run
157
157
  */
158
158
  connectedCallback() {
159
- const e = this.currentmonth;
160
- this.year = e.getFullYear(), this.month = e.getMonth(), this.week = x(new Date(this.year, this.month, 1, 12)), this.selected && this.selected.length && this.selected.forEach((t) => {
161
- this._selected.push(new Date(t));
162
- }), super.connectedCallback();
159
+ super.connectedCallback();
163
160
  }
164
161
  disconnectedCallback() {
165
162
  this.removeEventListener("keydown", this.handleKeydown), super.disconnectedCallback();
166
163
  }
167
164
  attributeChangedCallback(e, t, s) {
168
- e === "currentmonth" && s && (this.currentmonth = new Date(s), this.year = this.currentmonth.getFullYear(), this.month = this.currentmonth.getMonth(), this.week = x(new Date(this.year, this.month, 1, 12))), e === "selected" && s && (this._selected = [], this.selected.forEach((n) => {
169
- this._selected.push(new Date(n));
170
- })), super.attributeChangedCallback(e, t, s);
165
+ e === "selected" && s && this.convertSelected(), super.attributeChangedCallback(e, t, s);
171
166
  }
172
167
  updated(e) {
173
- if (e.has("selected") && this.selected.length === 2) {
174
- const t = S({
168
+ e.has("selected") && this.convertSelected(), super.updated(e);
169
+ }
170
+ convertSelected() {
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) {
172
+ const e = x({
175
173
  start: new Date(this.selected[0]),
176
174
  end: new Date(this.selected[1])
177
175
  });
178
- if (this.inRange = {}, Array.isArray(t) && t.length) {
179
- const s = {};
180
- for (let n = 0; n < t.length; n++)
181
- s[this.formatISODate(t[n])] = this.isInRange(t[n]);
182
- this.inRange = s;
176
+ if (this.inRange = {}, Array.isArray(e) && e.length) {
177
+ const t = {};
178
+ for (let s = 0; s < e.length; s++)
179
+ t[this.formatISODate(e[s])] = this.isInRange(e[s]);
180
+ this.inRange = t;
183
181
  }
184
182
  }
185
- super.updated(e);
183
+ this.setCurrentMonth();
186
184
  }
187
- firstUpdated(e) {
188
- this.addEventListener("keydown", this.handleKeydown);
185
+ setCurrentMonth() {
186
+ if (this.currentmonth === null && !this.currentmonthtouched) {
187
+ this.currentmonthtouched = !0;
188
+ return;
189
+ }
190
+ this.selected.length && this.selected[0] !== "" ? this.currentmonth = new Date(this.selected[this.selected.length - 1]) : this.currentmonth === null && (this.currentmonth = /* @__PURE__ */ new Date()), this.year = this.currentmonth.getFullYear(), this.month = this.currentmonth.getMonth();
189
191
  }
190
192
  handleKeydown(e) {
191
193
  switch (e.key) {
@@ -208,15 +210,15 @@ let r = class extends _ {
208
210
  const s = new Date(this.focusedDate);
209
211
  let n = new Date(s.setDate(s.getDate() + t));
210
212
  if (n) {
211
- let a = this.querySelector(`div[data-date="${this.formatISODate(n)}"]`);
212
- if (a instanceof HTMLDivElement) {
213
- if (a.dataset.disabled) {
214
- let l = new Date(s.setDate(s.getDate() + t)), i = this.querySelector(`div[data-date="${this.formatISODate(l)}"]`);
215
- for (; i && i instanceof HTMLDivElement && i.dataset.disabled; )
216
- l = new Date(l.setDate(l.getDate() + t)), i = this.querySelector(`div[data-date="${this.formatISODate(l)}"]`);
217
- a = i;
213
+ let i = this.querySelector(`div[data-date="${this.formatISODate(n)}"]`);
214
+ if (i instanceof HTMLDivElement) {
215
+ if (i.dataset.disabled) {
216
+ let o = new Date(s.setDate(s.getDate() + t)), a = this.querySelector(`div[data-date="${this.formatISODate(o)}"]`);
217
+ for (; a && a instanceof HTMLDivElement && a.dataset.disabled; )
218
+ o = new Date(o.setDate(o.getDate() + t)), a = this.querySelector(`div[data-date="${this.formatISODate(o)}"]`);
219
+ i = a;
218
220
  }
219
- a instanceof HTMLDivElement && !a.dataset.disabled && a.focus();
221
+ i instanceof HTMLDivElement && !i.dataset.disabled && i.focus();
220
222
  }
221
223
  }
222
224
  }
@@ -302,7 +304,7 @@ let r = class extends _ {
302
304
  @change=${(t) => {
303
305
  this.changeMonth(t.target.value, this.month);
304
306
  }}
305
- value="${this.year}"
307
+ .value=${this.year}
306
308
  />
307
309
  </div> `
308
310
  ) : e.push(
@@ -312,29 +314,29 @@ let r = class extends _ {
312
314
  ), e;
313
315
  }
314
316
  renderDayView(e, t, s) {
315
- const n = new Date(this.year, this.month, e, 12), a = this.formatISODate(n), l = 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, h = this.focusedDate ? this.focusedDate === a ? "0" : "-1" : e === 1 ? "0" : "-1";
316
- this.selectableDates.push({ currentDateISO: a, isDisabled: p });
317
+ 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";
318
+ this.selectableDates.push({ currentDateISO: i, isDisabled: p });
317
319
  const u = {
318
- "pkt-cal-today": l,
319
- "pkt-cal-selected": i,
320
- "pkt-cal-in-range": this.inRange[a],
320
+ "pkt-cal-today": o,
321
+ "pkt-cal-selected": a,
322
+ "pkt-cal-in-range": this.inRange[i],
321
323
  "pkt-cal-excluded": this.isExcluded(s, n),
322
- "pkt-cal-in-range-first": this.range && (this.selected.length === 2 || this.rangeHovered !== null) && a === this.selected[0],
323
- "pkt-cal-in-range-last": this.range && this.selected.length === 2 && a === this.selected[1],
324
- "pkt-cal-range-hover": this.rangeHovered !== null && a === this.formatISODate(this.rangeHovered)
324
+ "pkt-cal-in-range-first": this.range && (this.selected.length === 2 || this.rangeHovered !== null) && i === this.selected[0],
325
+ "pkt-cal-in-range-last": this.range && this.selected.length === 2 && i === this.selected[1],
326
+ "pkt-cal-range-hover": this.rangeHovered !== null && i === this.formatISODate(this.rangeHovered)
325
327
  };
326
- return f`<td class=${I(u)}>
328
+ return f`<td class=${A(u)}>
327
329
  <div
328
- ?aria-selected=${i}
330
+ ?aria-selected=${a}
329
331
  role="gridcell"
330
332
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
331
333
  @mouseover=${() => this.range && !this.isExcluded(s, n) && this.handleRangeHover(n)}
332
334
  @focus=${() => {
333
- this.range && !this.isExcluded(s, n) && this.handleRangeHover(n), this.focusedDate = a;
335
+ this.range && !this.isExcluded(s, n) && this.handleRangeHover(n), this.focusedDate = i;
334
336
  }}
335
337
  tabindex=${h}
336
338
  data-disabled=${p ? "disabled" : w}
337
- data-date=${a}
339
+ data-date=${i}
338
340
  @keydown=${(d) => {
339
341
  (d.key === "Enter" || d.key === " ") && (d.preventDefault(), this.handleDateSelect(n));
340
342
  }}
@@ -347,16 +349,16 @@ let r = class extends _ {
347
349
  </td>`;
348
350
  }
349
351
  renderCalendarBody() {
350
- 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, a = s.getDate(), l = Math.ceil((a + n) / 7), p = new Date(this.year, this.month, 0, 12).getDate();
352
+ 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();
351
353
  let h = 1;
352
- this.week = x(new Date(this.year, this.month, 1, 12));
354
+ this.week = R(new Date(this.year, this.month, 1, 12));
353
355
  const u = [];
354
- for (let d = 0; d < l; d++) {
356
+ for (let d = 0; d < o; d++) {
355
357
  const y = [];
356
358
  this.weeknumbers && y.push(f`<td class="pkt-cal-week">${this.week}</td>`), this.week++;
357
359
  for (let m = 1; m < 8; m++)
358
360
  if (d === 0 && m < n + 1) {
359
- const D = p - (n - m - 1);
361
+ const D = p - (n - m);
360
362
  y.push(
361
363
  f`<td class="pkt-cal-other">
362
364
  <div
@@ -367,13 +369,13 @@ let r = class extends _ {
367
369
  </div>
368
370
  </td>`
369
371
  );
370
- } else h > a ? (y.push(
372
+ } else h > i ? (y.push(
371
373
  f`<td class="pkt-cal-other">
372
374
  <div
373
375
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
374
376
  data-disabled="disabled"
375
377
  >
376
- <span class="pkt-btn__text pkt-txt-14-light">${h - a}</span>
378
+ <span class="pkt-btn__text pkt-txt-14-light">${h - i}</span>
377
379
  </div>
378
380
  </td>`
379
381
  ), h++) : (y.push(this.renderDayView(h, e, m)), h++);
@@ -408,7 +410,7 @@ let r = class extends _ {
408
410
  this.changeMonth(t, e);
409
411
  }
410
412
  changeMonth(e, t) {
411
- this.year = e, this.month = t, this.selectableDates = [], this.requestUpdate("currentmonth");
413
+ this.year = e, this.month = t, this.selectableDates = [], this.requestUpdate();
412
414
  }
413
415
  isInRange(e) {
414
416
  if (this.range && this.selected.length === 2) {
@@ -420,14 +422,14 @@ let r = class extends _ {
420
422
  isRangeAllowed(e) {
421
423
  let t = !0;
422
424
  if (this._selected.length === 1) {
423
- const s = S({
425
+ const s = x({
424
426
  start: this._selected[0],
425
427
  end: e
426
428
  });
427
429
  if (Array.isArray(s) && s.length)
428
430
  for (let n = 0; n < s.length; n++)
429
- this.excludedates.forEach((a) => {
430
- a > this._selected[0] && a < e && (t = !1);
431
+ this.excludedates.forEach((i) => {
432
+ i > this._selected[0] && i < e && (t = !1);
431
433
  }), this.excludeweekdays.includes(H(s[n]).toString()) && (t = !1);
432
434
  }
433
435
  return t;
@@ -457,7 +459,7 @@ let r = class extends _ {
457
459
  handleRangeHover(e) {
458
460
  if (this.range && this._selected.length === 1 && this.isRangeAllowed(e) && this._selected[0] < e) {
459
461
  this.rangeHovered = e, this.inRange = {};
460
- const t = S({
462
+ const t = x({
461
463
  start: this._selected[0],
462
464
  end: e
463
465
  });
@@ -504,87 +506,90 @@ let r = class extends _ {
504
506
  );
505
507
  }
506
508
  };
507
- o([
508
- c({ type: Boolean, reflect: !0 })
509
+ l([
510
+ c({ type: Boolean })
509
511
  ], r.prototype, "multiple", 2);
510
- o([
512
+ l([
511
513
  c({ type: Number })
512
514
  ], r.prototype, "maxMultiple", 2);
513
- o([
514
- c({ type: Boolean, reflect: !0 })
515
+ l([
516
+ c({ type: Boolean })
515
517
  ], r.prototype, "range", 2);
516
- o([
517
- c({ type: Boolean, reflect: !0 })
518
+ l([
519
+ c({ type: Boolean })
518
520
  ], r.prototype, "weeknumbers", 2);
519
- o([
520
- c({ type: Boolean, reflect: !0 })
521
+ l([
522
+ c({ type: Boolean })
521
523
  ], r.prototype, "withcontrols", 2);
522
- o([
523
- c({ converter: b.csvToArray })
524
+ l([
525
+ c({ converter: S.csvToArray })
524
526
  ], r.prototype, "selected", 2);
525
- o([
526
- c({ type: String, reflect: !0 })
527
+ l([
528
+ c({ type: String })
527
529
  ], r.prototype, "earliest", 2);
528
- o([
529
- c({ type: String, reflect: !0 })
530
+ l([
531
+ c({ type: String })
530
532
  ], r.prototype, "latest", 2);
531
- o([
532
- c({ converter: b.stringsToDate })
533
+ l([
534
+ c({ converter: S.stringsToDate })
533
535
  ], r.prototype, "excludedates", 2);
534
- o([
535
- c({ converter: b.csvToArray })
536
+ l([
537
+ c({ converter: S.csvToArray })
536
538
  ], r.prototype, "excludeweekdays", 2);
537
- o([
538
- c({ converter: b.stringToDate })
539
+ l([
540
+ c({ converter: S.stringToDate })
539
541
  ], r.prototype, "currentmonth", 2);
540
- o([
542
+ l([
541
543
  c({ type: Array })
542
544
  ], r.prototype, "dayStrings", 2);
543
- o([
545
+ l([
544
546
  c({ type: Array })
545
547
  ], r.prototype, "monthStrings", 2);
546
- o([
548
+ l([
547
549
  c({ type: String })
548
550
  ], r.prototype, "weekString", 2);
549
- o([
551
+ l([
550
552
  c({ type: String })
551
553
  ], r.prototype, "prevMonthString", 2);
552
- o([
554
+ l([
553
555
  c({ type: String })
554
556
  ], r.prototype, "nextMonthString", 2);
555
- o([
557
+ l([
556
558
  c({ type: Array })
557
559
  ], r.prototype, "_selected", 2);
558
- o([
560
+ l([
559
561
  c({ type: Number })
560
562
  ], r.prototype, "year", 2);
561
- o([
563
+ l([
562
564
  c({ type: Number })
563
565
  ], r.prototype, "month", 2);
564
- o([
566
+ l([
565
567
  c({ type: Number })
566
568
  ], r.prototype, "week", 2);
567
- o([
569
+ l([
568
570
  c({ type: Date })
569
571
  ], r.prototype, "rangeHovered", 2);
570
- o([
571
- O()
572
+ l([
573
+ b()
572
574
  ], r.prototype, "inRange", 2);
573
- o([
574
- O()
575
+ l([
576
+ b()
575
577
  ], r.prototype, "focusedDate", 2);
576
- o([
577
- O()
578
+ l([
579
+ b()
578
580
  ], r.prototype, "selectableDates", 2);
579
- r = o([
580
- A("pkt-calendar")
581
+ l([
582
+ b()
583
+ ], r.prototype, "currentmonthtouched", 2);
584
+ r = l([
585
+ _("pkt-calendar")
581
586
  ], r);
582
587
  export {
583
588
  r as P,
584
- T as a,
585
- x as b,
589
+ I as a,
590
+ R as b,
586
591
  M as c,
587
- $ as d,
592
+ O as d,
588
593
  C as g,
589
594
  U as m,
590
595
  v as s,
@@ -1,4 +1,4 @@
1
- import { D as w, R as g, P as y, k as P, n as a } from "./index-DFB6cAPd.js";
1
+ import { D as w, R as g, P as y, k as P, n as a } from "./index-m5WP1NKD.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
@@ -762,15 +762,15 @@ class m extends vt {
762
762
  }
763
763
  // When user enters the input, we need to push that event out to the form
764
764
  onFocus() {
765
- this.dispatchEvent(new Event("focus"));
765
+ this.dispatchEvent(new FocusEvent("focus"));
766
766
  }
767
767
  // And also when the user leaves the input...
768
768
  onBlur() {
769
- this.dispatchEvent(new Event("blur"));
769
+ this.dispatchEvent(new FocusEvent("blur"));
770
770
  }
771
771
  // Trigger this when user types in the input
772
772
  onInput() {
773
- this.dispatchEvent(new Event("input"));
773
+ this.dispatchEvent(new InputEvent("input"));
774
774
  }
775
775
  // Trigger this when you want to set the value of the input out to the form
776
776
  onChange(t) {
package/dist/index.d.ts CHANGED
@@ -30,12 +30,12 @@ export declare class PktCalendar extends PktElement {
30
30
  range: boolean;
31
31
  weeknumbers: boolean;
32
32
  withcontrols: boolean;
33
- selected: string[];
33
+ selected: string | string[];
34
34
  earliest: string | null;
35
35
  latest: string | null;
36
36
  excludedates: Date[];
37
37
  excludeweekdays: string[];
38
- currentmonth: Date;
38
+ currentmonth: Date | null;
39
39
  /**
40
40
  * If we are initializing props, slots and events from specs, we should do it in the constructor
41
41
  */
@@ -59,6 +59,7 @@ export declare class PktCalendar extends PktElement {
59
59
  private inRange;
60
60
  private focusedDate;
61
61
  private selectableDates;
62
+ private currentmonthtouched;
62
63
  /**
63
64
  * Runs on mount, used to set up various values and whatever you need to run
64
65
  */
@@ -66,7 +67,8 @@ export declare class PktCalendar extends PktElement {
66
67
  disconnectedCallback(): void;
67
68
  attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
68
69
  updated(changedProperties: PropertyValues): void;
69
- protected firstUpdated(_changedProperties: PropertyValues): void;
70
+ convertSelected(): void;
71
+ setCurrentMonth(): void;
70
72
  handleKeydown(e: KeyboardEvent): void;
71
73
  handleArrowKey(e: KeyboardEvent, direction: number): void;
72
74
  /**
@@ -176,7 +178,7 @@ export declare class PktDatepicker extends PktInputElement {
176
178
  fullwidth: boolean;
177
179
  excludedates: string[];
178
180
  excludeweekdays: string[];
179
- currentmonth: string;
181
+ currentmonth: string | null;
180
182
  calendarOpen: boolean;
181
183
  /**
182
184
  * Housekeeping / lifecycle methods
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-cmcwixge.cjs"),p=require("./ref-CRbDaFY5.cjs"),c=require("./class-map-D5yOTE4V.cjs"),k=require("./directive-19_ixLKS.cjs");require("./index-BGPEwMZQ.cjs");var h=Object.defineProperty,u=Object.getOwnPropertyDescriptor,e=(s,r,o,i)=>{for(var l=i>1?void 0:i?u(r,o):r,a=s.length-1,n;a>=0;a--)(n=s[a])&&(l=(i?n(r,o,l):n(l))||l);return i&&l&&h(r,o,l),l};exports.PktAlert=class extends t.PktElement{constructor(){super(),this.defaultSlot=p.ii(),this.closable=!1,this.compact=!1,this.title="",this.skin="info",this.isDisplayed=!0,this.ariaLive="polite",this.closeAlert=!1,this.date="",this.slotController=new p.PktSlotController(this,this.defaultSlot)}handleClose(){this.isDisplayed=!1,this.onClose&&this.onClose()}render(){const r={"pkt-alert":!0,"pkt-alert--compact":this.compact,[`pkt-alert--${this.skin}`]:this.skin,"pkt-alert--closable":this.closable};return this.isDisplayed?t.ke`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BUZITHLd.cjs"),p=require("./ref-BdbjJbqo.cjs"),c=require("./class-map-BQ5k1q3A.cjs"),k=require("./directive-19_ixLKS.cjs");require("./index-BFqUD8HI.cjs");var h=Object.defineProperty,u=Object.getOwnPropertyDescriptor,e=(s,r,o,i)=>{for(var l=i>1?void 0:i?u(r,o):r,a=s.length-1,n;a>=0;a--)(n=s[a])&&(l=(i?n(r,o,l):n(l))||l);return i&&l&&h(r,o,l),l};exports.PktAlert=class extends t.PktElement{constructor(){super(),this.defaultSlot=p.ii(),this.closable=!1,this.compact=!1,this.title="",this.skin="info",this.isDisplayed=!0,this.ariaLive="polite",this.closeAlert=!1,this.date="",this.slotController=new p.PktSlotController(this,this.defaultSlot)}handleClose(){this.isDisplayed=!1,this.onClose&&this.onClose()}render(){const r={"pkt-alert":!0,"pkt-alert--compact":this.compact,[`pkt-alert--${this.skin}`]:this.skin,"pkt-alert--closable":this.closable};return this.isDisplayed?t.ke`
2
2
  <div class=${c.Rt(r)} aria-live=${this.ariaLive}>
3
3
  <pkt-icon
4
4
  class="pkt-alert__icon"
package/dist/pkt-alert.js CHANGED
@@ -1,8 +1,8 @@
1
- import { P as f, D as a, k as p, n as i } from "./index-DFB6cAPd.js";
2
- import { i as d, P as k, K as u } from "./ref-ClWSy3zg.js";
3
- import { R as y } from "./class-map-CQf6i-xX.js";
1
+ import { P as f, D as a, k as p, n as i } from "./index-m5WP1NKD.js";
2
+ import { i as d, P as k, K as u } from "./ref-bNNrgsqL.js";
3
+ import { R as y } from "./class-map-CL_lSLwn.js";
4
4
  import { t as v } from "./directive-DA0-wdk7.js";
5
- import "./index-BtB1fCeq.js";
5
+ import "./index-exzYRW0z.js";
6
6
  var m = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, e = (l, r, n, o) => {
7
7
  for (var s = o > 1 ? void 0 : o ? _(r, n) : r, c = l.length - 1, h; c >= 0; c--)
8
8
  (h = l[c]) && (s = (o ? h(r, n, s) : h(s)) || s);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-cmcwixge.cjs");require("./converters-DhM11VlY.cjs");require("./directive-19_ixLKS.cjs");require("./class-map-D5yOTE4V.cjs");const e=require("./index-Bfdr5FsZ.cjs");require("./index-BGPEwMZQ.cjs");Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>e.PktCalendar});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./index-BUZITHLd.cjs");require("./converters-DhM11VlY.cjs");require("./directive-19_ixLKS.cjs");require("./class-map-BQ5k1q3A.cjs");const e=require("./index-Bc9mksHI.cjs");require("./index-BFqUD8HI.cjs");Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>e.PktCalendar});
@@ -1,9 +1,9 @@
1
- import "./index-DFB6cAPd.js";
1
+ import "./index-m5WP1NKD.js";
2
2
  import "./converters-DNCwIFwr.js";
3
3
  import "./directive-DA0-wdk7.js";
4
- import "./class-map-CQf6i-xX.js";
5
- import { P as e } from "./index-erLPjF21.js";
6
- import "./index-BtB1fCeq.js";
4
+ import "./class-map-CL_lSLwn.js";
5
+ import { P as e } from "./index-DQ5xnGw6.js";
6
+ import "./index-exzYRW0z.js";
7
7
  export {
8
8
  e as PktCalendar
9
9
  };
package/dist/pkt-card.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-cmcwixge.cjs"),d=require("./ref-CRbDaFY5.cjs"),c=require("./class-map-D5yOTE4V.cjs"),g=require("./directive-19_ixLKS.cjs");require("./index-BGPEwMZQ.cjs");require("./pkt-tag.cjs");const k="pkt-card",u=!0,h={heading:{type:"string",name:"Heading",description:"Tittel på kortet"},subheading:{type:"string",name:"Subheading",description:"Undertittel på kortet"},tags:{type:"IPktTag[]",description:"Liste av tags på kortet. Tar inn en array med IPktTag-objekter med følgende stringproperties: skin, iconName, ariaLabel, text",name:"Tags",items:{type:"object",properties:{skin:{type:["blue","green","red","yellow"],description:"Farge på tag"},iconName:{type:"string",description:"Id på ikonet du ønsker å bruke til tag"},ariaLabel:{type:"string",description:"Tekst for aria-label"},text:{type:"string",description:"Tekst på tag"}},required:["text"]}},skin:{type:["outlined","gray","blue","beige","green"],name:"Skin",description:"Farge på kortet",default:"outlined"},direction:{type:["landscape","portrait"],name:"Direction",description:"Retningen innholdet skal ligge i forhold til kortet",default:"portrait"},Image:{type:"object",image:"Image",description:"Bilde på kortet. Tar inn et objekt av typen {src: string, alt: string}. src er stien til bildet, og alt er tekst for aria-label.",items:{type:"object",properties:{src:{type:"string",description:"Bilde på kortet"},alt:{type:"string",description:"Tekst for aria-label"}},required:["src","alt"]}}},m={default:{description:"Innholdet i kortet"}},l={name:k,"css-class":"pkt-card",isElement:u,props:h,slots:m};var y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,r=(n,i,s,a)=>{for(var e=a>1?void 0:a?b(i,s):i,o=n.length-1,p;o>=0;o--)(p=n[o])&&(e=(a?p(i,s,e):p(e))||e);return a&&e&&y(i,s,e),e};exports.PktCard=class extends t.PktElement{constructor(){super(),this.defaultSlot=d.ii(),this.skin=l.props.skin.default,this.direction=l.props.direction.default,this.image={src:"",alt:""},this.heading="",this.subheading="",this.tags=[],this.slotController=new d.PktSlotController(this,this.defaultSlot)}connectedCallback(){super.connectedCallback()}render(){const i={"pkt-card":!0,[`pkt-card--${this.skin}`]:this.skin,[`pkt-card--${this.direction}`]:this.direction};return t.ke`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-BUZITHLd.cjs"),d=require("./ref-BdbjJbqo.cjs"),c=require("./class-map-BQ5k1q3A.cjs"),g=require("./directive-19_ixLKS.cjs");require("./index-BFqUD8HI.cjs");require("./pkt-tag.cjs");const k="pkt-card",u=!0,h={heading:{type:"string",name:"Heading",description:"Tittel på kortet"},subheading:{type:"string",name:"Subheading",description:"Undertittel på kortet"},tags:{type:"IPktTag[]",description:"Liste av tags på kortet. Tar inn en array med IPktTag-objekter med følgende stringproperties: skin, iconName, ariaLabel, text",name:"Tags",items:{type:"object",properties:{skin:{type:["blue","green","red","yellow"],description:"Farge på tag"},iconName:{type:"string",description:"Id på ikonet du ønsker å bruke til tag"},ariaLabel:{type:"string",description:"Tekst for aria-label"},text:{type:"string",description:"Tekst på tag"}},required:["text"]}},skin:{type:["outlined","gray","blue","beige","green"],name:"Skin",description:"Farge på kortet",default:"outlined"},direction:{type:["landscape","portrait"],name:"Direction",description:"Retningen innholdet skal ligge i forhold til kortet",default:"portrait"},Image:{type:"object",image:"Image",description:"Bilde på kortet. Tar inn et objekt av typen {src: string, alt: string}. src er stien til bildet, og alt er tekst for aria-label.",items:{type:"object",properties:{src:{type:"string",description:"Bilde på kortet"},alt:{type:"string",description:"Tekst for aria-label"}},required:["src","alt"]}}},m={default:{description:"Innholdet i kortet"}},l={name:k,"css-class":"pkt-card",isElement:u,props:h,slots:m};var y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,r=(n,i,s,a)=>{for(var e=a>1?void 0:a?b(i,s):i,o=n.length-1,p;o>=0;o--)(p=n[o])&&(e=(a?p(i,s,e):p(e))||e);return a&&e&&y(i,s,e),e};exports.PktCard=class extends t.PktElement{constructor(){super(),this.defaultSlot=d.ii(),this.skin=l.props.skin.default,this.direction=l.props.direction.default,this.image={src:"",alt:""},this.heading="",this.subheading="",this.tags=[],this.slotController=new d.PktSlotController(this,this.defaultSlot)}connectedCallback(){super.connectedCallback()}render(){const i={"pkt-card":!0,[`pkt-card--${this.skin}`]:this.skin,[`pkt-card--${this.direction}`]:this.direction};return t.ke`
2
2
  <div class=${c.Rt(i)}>
3
3
  ${this.image.src&&t.ke`
4
4
  <div class="pkt-card__image">
package/dist/pkt-card.js CHANGED
@@ -1,8 +1,8 @@
1
- import { P as g, k as r, D as k, n as a } from "./index-DFB6cAPd.js";
2
- import { i as h, P as m, K as u } from "./ref-ClWSy3zg.js";
3
- import { R as y } from "./class-map-CQf6i-xX.js";
1
+ import { P as g, k as r, D as k, n as a } from "./index-m5WP1NKD.js";
2
+ import { i as h, P as m, K as u } from "./ref-bNNrgsqL.js";
3
+ import { R as y } from "./class-map-CL_lSLwn.js";
4
4
  import { t as f } from "./directive-DA0-wdk7.js";
5
- import "./index-BtB1fCeq.js";
5
+ import "./index-exzYRW0z.js";
6
6
  import "./pkt-tag.js";
7
7
  const b = "pkt-card", v = !0, $ = {
8
8
  heading: {
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-cmcwixge.cjs"),h=require("./directive-19_ixLKS.cjs"),r=require("./ref-CRbDaFY5.cjs"),d=require("./class-map-D5yOTE4V.cjs"),c=require("./converters-DhM11VlY.cjs");var u=Object.defineProperty,m=Object.getOwnPropertyDescriptor,o=(l,t,s,i)=>{for(var n=i>1?void 0:i?m(t,s):t,a=l.length-1,p;a>=0;a--)(p=l[a])&&(n=(i?p(t,s,n):p(n))||n);return i&&n&&u(t,s,n),n};exports.PktComponent=class extends e.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=r.ii(),this.namedSlot=r.ii(),this.slotController=new r.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(t=>{this._list.push(t.toUpperCase())}),super.connectedCallback()}render(){const t={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return e.ke`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BUZITHLd.cjs"),h=require("./directive-19_ixLKS.cjs"),r=require("./ref-BdbjJbqo.cjs"),d=require("./class-map-BQ5k1q3A.cjs"),c=require("./converters-DhM11VlY.cjs");var u=Object.defineProperty,m=Object.getOwnPropertyDescriptor,o=(l,t,s,i)=>{for(var n=i>1?void 0:i?m(t,s):t,a=l.length-1,p;a>=0;a--)(p=l[a])&&(n=(i?p(t,s,n):p(n))||n);return i&&n&&u(t,s,n),n};exports.PktComponent=class extends e.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=r.ii(),this.namedSlot=r.ii(),this.slotController=new r.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(t=>{this._list.push(t.toUpperCase())}),super.connectedCallback()}render(){const t={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return e.ke`
2
2
  <div class="${d.Rt(t)}">
3
3
  <h1 class="pkt-txt-28">${this.string}</h1>
4
4
 
@@ -1,7 +1,7 @@
1
- import { P as m, k as h, t as u, n } from "./index-DFB6cAPd.js";
1
+ import { P as m, k as h, t as u, n } from "./index-m5WP1NKD.js";
2
2
  import { t as f } from "./directive-DA0-wdk7.js";
3
- import { i as d, P as v, K as c } from "./ref-ClWSy3zg.js";
4
- import { R as g } from "./class-map-CQf6i-xX.js";
3
+ import { i as d, P as v, K as c } from "./ref-bNNrgsqL.js";
4
+ import { R as g } from "./class-map-CL_lSLwn.js";
5
5
  import { c as k } from "./converters-DNCwIFwr.js";
6
6
  var S = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, i = (t, e, l, o) => {
7
7
  for (var s = o > 1 ? void 0 : o ? $(e, l) : e, a = t.length - 1, p; a >= 0; a--)