@oslokommune/punkt-elements 16.14.0 → 16.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/dist/calendar-Ch1dgnBo.js +656 -0
  3. package/dist/calendar-DkjXla0I.cjs +90 -0
  4. package/dist/{card-CQYxrtL0.cjs → card-C3POnP3O.cjs} +1 -1
  5. package/dist/{card-Bir3-pl2.js → card-CEDbo1t7.js} +2 -2
  6. package/dist/{checkbox-Cspxcvt_.js → checkbox-Bjp43NxA.js} +1 -1
  7. package/dist/{checkbox-BARDb9iV.cjs → checkbox-nTbihMxW.cjs} +1 -1
  8. package/dist/{combobox-CstFVsy1.cjs → combobox-C4Q6kQEs.cjs} +1 -1
  9. package/dist/{combobox-DtYloYZq.js → combobox-CL9BLuxt.js} +6 -6
  10. package/dist/components/fileupload/fileupload-base.d.ts +116 -0
  11. package/dist/components/fileupload/fileupload-operations.d.ts +4 -0
  12. package/dist/components/fileupload/fileupload-renderers.d.ts +28 -0
  13. package/dist/components/fileupload/fileupload-types.d.ts +70 -0
  14. package/dist/components/fileupload/fileupload.d.ts +25 -0
  15. package/dist/components/fileupload/fileupload.test.d.ts +0 -0
  16. package/dist/components/fileupload/index.d.ts +4 -0
  17. package/dist/components/index.d.ts +2 -0
  18. package/dist/converters-Bffq_YDm.cjs +1 -0
  19. package/dist/converters-jauYkvNh.js +1378 -0
  20. package/dist/{datepicker-gO2EuaBX.js → datepicker-BUK1Qanw.js} +22 -21
  21. package/dist/{datepicker-DfSdjIjl.cjs → datepicker-DYd3JCs_.cjs} +10 -10
  22. package/dist/docs/components/fileupload.d.ts +27 -0
  23. package/dist/fileupload-BRqioKSY.cjs +396 -0
  24. package/dist/fileupload-Bnl303X0.js +1372 -0
  25. package/dist/fileupload.d.ts +1 -0
  26. package/dist/{header-DpU4HYdj.cjs → header-Dps8o-ZY.cjs} +1 -1
  27. package/dist/{header-BHrgTCxj.js → header-T5O6sfCN.js} +3 -3
  28. package/dist/{helptext-CCBKKLus.js → helptext-C5rG4VkA.js} +2 -2
  29. package/dist/{helptext-D-3QfZv5.cjs → helptext-DQgStO4D.cjs} +1 -1
  30. package/dist/{input-element-Bw1s6NlF.js → input-element-CjebcQd1.js} +3 -3
  31. package/dist/{input-element-B1yxcfz4.cjs → input-element-FGcr5hGd.cjs} +1 -1
  32. package/dist/{input-wrapper-CzS4rUrK.cjs → input-wrapper-B_XFi211.cjs} +1 -1
  33. package/dist/{input-wrapper-XuUnGN_U.js → input-wrapper-DBpMVSxt.js} +4 -4
  34. package/dist/{listbox-DuBgTFvH.js → listbox-0NHJvNjz.js} +2 -2
  35. package/dist/{listbox-DCA2JoPV.cjs → listbox-CcThiNBY.cjs} +1 -1
  36. package/dist/{modal-CBEWrAi2.cjs → modal-B6591sWa.cjs} +1 -1
  37. package/dist/{modal-pPp8nia6.js → modal-DyIC3uhs.js} +1 -1
  38. package/dist/pkt-calendar.cjs +1 -1
  39. package/dist/pkt-calendar.js +1 -1
  40. package/dist/pkt-card.cjs +1 -1
  41. package/dist/pkt-card.js +1 -1
  42. package/dist/pkt-checkbox.cjs +1 -1
  43. package/dist/pkt-checkbox.js +1 -1
  44. package/dist/pkt-combobox.cjs +1 -1
  45. package/dist/pkt-combobox.js +1 -1
  46. package/dist/pkt-consent.cjs +1 -1
  47. package/dist/pkt-consent.js +1 -1
  48. package/dist/pkt-datepicker.cjs +1 -1
  49. package/dist/pkt-datepicker.js +1 -1
  50. package/dist/pkt-fileupload.cjs +1 -0
  51. package/dist/pkt-fileupload.js +2 -0
  52. package/dist/pkt-header.cjs +1 -1
  53. package/dist/pkt-header.js +1 -1
  54. package/dist/pkt-heading.cjs +1 -1
  55. package/dist/pkt-heading.js +1 -1
  56. package/dist/pkt-helptext.cjs +1 -1
  57. package/dist/pkt-helptext.js +1 -1
  58. package/dist/pkt-index.cjs +1 -1
  59. package/dist/pkt-index.js +25 -24
  60. package/dist/pkt-input-wrapper.cjs +1 -1
  61. package/dist/pkt-input-wrapper.js +1 -1
  62. package/dist/pkt-link.cjs +1 -1
  63. package/dist/pkt-link.js +1 -1
  64. package/dist/pkt-linkcard.cjs +1 -1
  65. package/dist/pkt-linkcard.js +1 -1
  66. package/dist/pkt-listbox.cjs +1 -1
  67. package/dist/pkt-listbox.js +1 -1
  68. package/dist/pkt-loader.cjs +1 -1
  69. package/dist/pkt-loader.js +1 -1
  70. package/dist/pkt-messagebox.cjs +1 -1
  71. package/dist/pkt-messagebox.js +1 -1
  72. package/dist/pkt-modal.cjs +1 -1
  73. package/dist/pkt-modal.js +1 -1
  74. package/dist/pkt-progressbar.cjs +1 -1
  75. package/dist/pkt-progressbar.js +1 -1
  76. package/dist/pkt-radiobutton.cjs +1 -1
  77. package/dist/pkt-radiobutton.js +1 -1
  78. package/dist/pkt-select.cjs +1 -1
  79. package/dist/pkt-select.js +1 -1
  80. package/dist/pkt-tabs.cjs +1 -1
  81. package/dist/pkt-tabs.js +1 -1
  82. package/dist/pkt-tag.cjs +1 -1
  83. package/dist/pkt-tag.js +1 -1
  84. package/dist/pkt-textarea.cjs +1 -1
  85. package/dist/pkt-textarea.js +1 -1
  86. package/dist/pkt-textinput.cjs +1 -1
  87. package/dist/pkt-textinput.js +1 -1
  88. package/dist/pkt-timepicker.cjs +1 -1
  89. package/dist/pkt-timepicker.js +1 -1
  90. package/dist/{progressbar-CdXtmOBb.cjs → progressbar-CrwpnIkv.cjs} +1 -1
  91. package/dist/{progressbar-Dy9AiYQz.js → progressbar-uC-0W6o4.js} +1 -1
  92. package/dist/{radiobutton-V_KPbup_.js → radiobutton-B-8-wWFf.js} +1 -1
  93. package/dist/{radiobutton-GOnpUbCW.cjs → radiobutton-DvXr7tDk.cjs} +1 -1
  94. package/dist/{select-Cwzq_O8S.cjs → select-B75wzvyz.cjs} +1 -1
  95. package/dist/{select-Bo-w84pI.js → select-D9B8Ighz.js} +3 -3
  96. package/dist/shared-types/fileupload.d.ts +73 -0
  97. package/dist/shared-types/index.d.ts +2 -0
  98. package/dist/shared-utils/fileupload/announcements.d.ts +11 -0
  99. package/dist/shared-utils/fileupload/filename.d.ts +13 -0
  100. package/dist/shared-utils/fileupload/focus-trap.d.ts +12 -0
  101. package/dist/shared-utils/fileupload/formats.d.ts +30 -0
  102. package/dist/shared-utils/fileupload/index.d.ts +15 -0
  103. package/dist/shared-utils/fileupload/navigation.d.ts +5 -0
  104. package/dist/shared-utils/fileupload/size.d.ts +12 -0
  105. package/dist/shared-utils/fileupload/transfers.d.ts +17 -0
  106. package/dist/shared-utils/fileupload/truncate.d.ts +13 -0
  107. package/dist/shared-utils/fileupload/validation.d.ts +24 -0
  108. package/dist/tests/component-registry.d.ts +2 -0
  109. package/dist/{textarea-DYInBFHP.js → textarea-CIWXMaAD.js} +2 -2
  110. package/dist/{textarea-CbqiuSE8.cjs → textarea-CjqprL6Y.cjs} +1 -1
  111. package/dist/{textinput-Bp-UeGOq.cjs → textinput-B0VWmVIF.cjs} +1 -1
  112. package/dist/{textinput-DO9RldRk.js → textinput-CxzAxM8E.js} +2 -2
  113. package/dist/{timepicker-BpBcPB-r.cjs → timepicker-Cv9juQeB.cjs} +1 -1
  114. package/dist/{timepicker-D_XpQJXa.js → timepicker-DXrpg5C7.js} +2 -2
  115. package/package.json +2 -2
  116. package/src/components/fileupload/fileupload-base.ts +557 -0
  117. package/src/components/fileupload/fileupload-operations.ts +213 -0
  118. package/src/components/fileupload/fileupload-renderers.ts +769 -0
  119. package/src/components/fileupload/fileupload-types.ts +88 -0
  120. package/src/components/fileupload/fileupload.test.ts +949 -0
  121. package/src/components/fileupload/fileupload.ts +469 -0
  122. package/src/components/fileupload/index.ts +34 -0
  123. package/src/components/index.ts +16 -0
  124. package/dist/calendar-BzEtOJla.js +0 -2031
  125. package/dist/calendar-E5jJLt8D.cjs +0 -90
  126. /package/dist/{booleanish-jJLlnr6-.cjs → booleanish-B5EFqFpJ.cjs} +0 -0
  127. /package/dist/{booleanish-BmcOU-43.js → booleanish-CRaKZ75t.js} +0 -0
  128. /package/dist/{consent-DeB_5sWH.js → consent-f_IGyHss.js} +0 -0
  129. /package/dist/{consent-hwu7pp3S.cjs → consent-zh2npq2K.cjs} +0 -0
  130. /package/dist/{dialog-polyfill.esm-1hPr0gl9.js → dialog-polyfill.esm-BmVHGRTX.js} +0 -0
  131. /package/dist/{dialog-polyfill.esm-D3Oinvk0.cjs → dialog-polyfill.esm-CXDsb3l-.cjs} +0 -0
  132. /package/dist/{heading-DiQLPxdf.js → heading-BxvE80bb.js} +0 -0
  133. /package/dist/{heading-BgSWIRii.cjs → heading-DRJTS27k.cjs} +0 -0
  134. /package/dist/{input-wrapper-Dwd-_sKm.cjs → input-wrapper-CYCCx8MP.cjs} +0 -0
  135. /package/dist/{input-wrapper-CDyHTR1V.js → input-wrapper-kw2y6Jp_.js} +0 -0
  136. /package/dist/{link-CyTCpI0k.cjs → link-B8zYc5WK.cjs} +0 -0
  137. /package/dist/{link-CKAFMz9j.js → link-CjJcwcxR.js} +0 -0
  138. /package/dist/{linkcard-BE4-FewK.cjs → linkcard-C4x-NJMi.cjs} +0 -0
  139. /package/dist/{linkcard-B0KOGaGj.js → linkcard-Ddh5R_L-.js} +0 -0
  140. /package/dist/{loader-CX2rsC01.cjs → loader-CGQXAuyM.cjs} +0 -0
  141. /package/dist/{loader-6kFZUErT.js → loader-DeizpX45.js} +0 -0
  142. /package/dist/{messagebox-Din9X53b.cjs → messagebox-Ccu29rDv.cjs} +0 -0
  143. /package/dist/{messagebox-Cwlg5sOr.js → messagebox-DqoPqo4K.js} +0 -0
  144. /package/dist/{pkt-options-controller-CXUGx134.cjs → pkt-options-controller-BPBb_O2K.cjs} +0 -0
  145. /package/dist/{pkt-options-controller-CRrI6WMk.js → pkt-options-controller-DbLrdRwH.js} +0 -0
  146. /package/dist/{repeat-Cepr3469.js → repeat-DV1O43YU.js} +0 -0
  147. /package/dist/{repeat-CqcDYBxr.cjs → repeat-DaDFvx86.cjs} +0 -0
  148. /package/dist/{tabs-Rc9N9HWa.js → tabs-4eWA7CsK.js} +0 -0
  149. /package/dist/{tabs-BfurI6C3.cjs → tabs-RnDtIFv3.cjs} +0 -0
  150. /package/dist/{tag-DLthw5b4.cjs → tag-DWtajZk6.cjs} +0 -0
  151. /package/dist/{tag-VwykmuQR.js → tag-hl59gziI.js} +0 -0
  152. /package/dist/{utils-CUqCKGvp.js → utils-BOOZ0ppt.js} +0 -0
  153. /package/dist/{utils-CjAbIttF.cjs → utils-CM67Oudc.cjs} +0 -0
package/CHANGELOG.md CHANGED
@@ -5,6 +5,23 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [16.15.0](https://github.com/oslokommune/punkt/compare/16.14.0...16.15.0) (2026-05-11)
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+ Ingen
12
+
13
+ ### Features
14
+ Ingen
15
+
16
+ ### Bug Fixes
17
+ Ingen
18
+
19
+ ### Chores
20
+ Ingen
21
+
22
+ ---
23
+
24
+
8
25
  ## [16.14.0](https://github.com/oslokommune/punkt/compare/16.13.3...16.14.0) (2026-05-08)
9
26
 
10
27
  ### ⚠ BREAKING CHANGES
@@ -263,7 +280,6 @@ Ingen
263
280
 
264
281
  ---
265
282
 
266
-
267
283
  ## [16.3.0](https://github.com/oslokommune/punkt/compare/16.2.0...16.3.0) (2026-03-24)
268
284
 
269
285
  ### ⚠ BREAKING CHANGES
@@ -0,0 +1,656 @@
1
+ import { c as e, d as t, l as n, o as r, r as i, s as a, t as o } from "./element-cZ85T_aa.js";
2
+ import { t as s } from "./class-map-C8HuhNzZ.js";
3
+ import "./icon-Co72KtgF.js";
4
+ import { _ as c, a as l, b as u, d, f, g as p, l as m, m as h, o as g, p as _, t as v, v as y, y as b } from "./converters-jauYkvNh.js";
5
+ //#region ../../node_modules/date-fns/addDays.js
6
+ function x(e, t, n) {
7
+ let r = b(e, n?.in);
8
+ return isNaN(t) ? u(n?.in || e, NaN) : (t && r.setDate(r.getDate() + t), r);
9
+ }
10
+ //#endregion
11
+ //#region ../../node_modules/date-fns/_lib/normalizeInterval.js
12
+ function S(e, t) {
13
+ let [n, r] = y(e, t.start, t.end);
14
+ return {
15
+ start: n,
16
+ end: r
17
+ };
18
+ }
19
+ //#endregion
20
+ //#region ../../node_modules/date-fns/eachDayOfInterval.js
21
+ function C(e, t) {
22
+ let { start: n, end: r } = S(t?.in, e), i = +n > +r, a = i ? +n : +r, o = i ? r : n;
23
+ o.setHours(0, 0, 0, 0);
24
+ let s = t?.step ?? 1;
25
+ if (!s) return [];
26
+ s < 0 && (s = -s, i = !i);
27
+ let c = [];
28
+ for (; +o <= a;) c.push(u(n, o)), o.setDate(o.getDate() + s), o.setHours(0, 0, 0, 0);
29
+ return i ? c.reverse() : c;
30
+ }
31
+ //#endregion
32
+ //#region ../../node_modules/date-fns/getISODay.js
33
+ function w(e, t) {
34
+ let n = b(e, t?.in).getDay();
35
+ return n === 0 ? 7 : n;
36
+ }
37
+ var T = {
38
+ name: "pkt-calendar",
39
+ react: "PktCalendar",
40
+ "css-class": "pkt-calendar",
41
+ isElement: !0,
42
+ isPureReact: !0,
43
+ props: {
44
+ id: {
45
+ type: "string",
46
+ name: "ID",
47
+ description: "Unik identifikasjon for kalenderen"
48
+ },
49
+ currentmonth: {
50
+ type: "date",
51
+ name: "Gjeldende måned",
52
+ converter: "stringToDate",
53
+ description: "Måneden som vises i kalenderen"
54
+ },
55
+ selected: {
56
+ type: "array",
57
+ name: "Valgte datoer",
58
+ converter: "csvToArray",
59
+ reflect: !0,
60
+ items: { type: "date" },
61
+ description: "Liste over valgte datoer"
62
+ },
63
+ excludeweekdays: {
64
+ type: "array",
65
+ name: "Utelat ukedager",
66
+ converter: "csvToArray",
67
+ items: { type: "string" },
68
+ description: "Liste over ukedager (1-7) som skal ekskluderes"
69
+ },
70
+ excludedates: {
71
+ type: "array",
72
+ name: "Utelat datoer",
73
+ converter: "stringsToDate",
74
+ items: { type: "date" },
75
+ description: "Liste over spesifikke datoer som skal ekskluderes"
76
+ },
77
+ earliest: {
78
+ type: "date",
79
+ name: "Tidligst tillatte dato",
80
+ converter: "stringToDate",
81
+ default: null,
82
+ description: "Tidligste dato som kan velges"
83
+ },
84
+ latest: {
85
+ type: "date",
86
+ name: "Senest tillatte dato",
87
+ converter: "stringToDate",
88
+ default: null,
89
+ description: "Seneste dato som kan velges"
90
+ },
91
+ weeknumbers: {
92
+ type: "boolean",
93
+ name: "Vis ukenummer",
94
+ reflect: !0,
95
+ default: !1,
96
+ description: "Vis ukenummer i kalenderen"
97
+ },
98
+ withcontrols: {
99
+ type: "boolean",
100
+ name: "Med velgere for måned/år",
101
+ reflect: !0,
102
+ default: !1,
103
+ description: "Vis navigasjonskontroller for måned og år"
104
+ },
105
+ multiple: {
106
+ type: "boolean",
107
+ name: "Flervalg",
108
+ reflect: !0,
109
+ default: !1,
110
+ description: "Tillat valg av flere datoer"
111
+ },
112
+ maxMultiple: {
113
+ attribute: "max-multiple",
114
+ type: "number",
115
+ name: "Maks antall i flervalg",
116
+ default: 4,
117
+ description: "Maksimalt antall datoer som kan velges"
118
+ },
119
+ today: {
120
+ type: "string",
121
+ name: "Dagens dato (overstyring)",
122
+ description: "ISO-datostreng som overstyrer dagens dato. Nyttig for snapshot-tester."
123
+ },
124
+ range: {
125
+ type: "boolean",
126
+ name: "Datotidsrom (fra og til)",
127
+ reflect: !0,
128
+ default: !1,
129
+ description: "Tillat valg av datotidsrom"
130
+ },
131
+ dayStrings: {
132
+ attribute: "day-strings",
133
+ type: "array",
134
+ name: "Korte dagsnavn",
135
+ items: { type: "string" },
136
+ description: "Korte dagsnavn for kalenderoverskriften"
137
+ },
138
+ dayStringsLong: {
139
+ attribute: "day-strings-long",
140
+ type: "array",
141
+ name: "Fulle dagsnavn",
142
+ items: { type: "string" },
143
+ description: "Fulle dagsnavn for tilgjengelighetsetiketter"
144
+ },
145
+ monthStrings: {
146
+ attribute: "month-strings",
147
+ type: "array",
148
+ name: "Månedsnavn",
149
+ items: { type: "string" },
150
+ description: "Månedsnavn for kalendernavigasjonen"
151
+ },
152
+ weekString: {
153
+ attribute: "week-string",
154
+ type: "string",
155
+ name: "Ukenummer-etikett",
156
+ description: "Etikett for ukenummerkolonnen"
157
+ },
158
+ prevMonthString: {
159
+ attribute: "prev-month-string",
160
+ type: "string",
161
+ name: "Forrige måned-etikett",
162
+ description: "Tilgjengelighetsetikett for forrige måned-knappen"
163
+ },
164
+ nextMonthString: {
165
+ attribute: "next-month-string",
166
+ type: "string",
167
+ name: "Neste måned-etikett",
168
+ description: "Tilgjengelighetsetikett for neste måned-knappen"
169
+ }
170
+ },
171
+ events: {
172
+ "date-selected": { description: "Returnerer en liste med valgte datoer i ISO-format" },
173
+ close: { description: "Utløses når kalenderen ber om å lukkes (Escape-tast eller fokus forlater)" }
174
+ }
175
+ };
176
+ //#endregion
177
+ //#region ../../shared-utils/calendar/date-validation.ts
178
+ function E(e, t) {
179
+ let n = (t.excludedates ?? []).map((e) => typeof e == "string" ? e : l(e));
180
+ return !m(e, t.earliest, t.latest, n, t.excludeweekdays ?? []);
181
+ }
182
+ function D(e, t, n, r) {
183
+ return !!(E(e, n) || !t && r.multiple && r.maxMultiple > 0 && r.selectedCount >= r.maxMultiple);
184
+ }
185
+ function O(e, t, n) {
186
+ let r = _(e, t, 0);
187
+ return !(n && d(n) > r);
188
+ }
189
+ function k(e, t, n) {
190
+ let r = _(t === 11 ? e + 1 : e, t === 11 ? 0 : t + 1, 1);
191
+ return !(n && d(n) < r);
192
+ }
193
+ function A(e, t) {
194
+ let n = _(e, t, 1), r = _(e, t + 1, 0), i = (n.getDay() + 6) % 7, a = r.getDate();
195
+ return {
196
+ firstDayOfMonth: n,
197
+ lastDayOfMonth: r,
198
+ startingDay: i,
199
+ numDays: a,
200
+ numRows: Math.ceil((a + i) / 7),
201
+ numDaysPrevMonth: _(e, t, 0).getDate(),
202
+ initialWeek: c(n)
203
+ };
204
+ }
205
+ function j(e, t, n, r) {
206
+ let { startingDay: i, numDays: a } = r;
207
+ return e === 0 && t < i ? "prev-month" : n > a ? "next-month" : "current-month";
208
+ }
209
+ function M(e, t, n, r) {
210
+ let { startingDay: i, numDaysPrevMonth: a, numDays: o } = r;
211
+ return e === "prev-month" ? a - (i - t - 1) : e === "next-month" ? n - o : n;
212
+ }
213
+ //#endregion
214
+ //#region ../../shared-utils/calendar/selection-manager.ts
215
+ function N(e) {
216
+ return typeof e == "string" && (e = e.split(",")), e.length === 1 && e[0] === "" ? [] : e.map((e) => h(e));
217
+ }
218
+ function P(e, t) {
219
+ let n = C({
220
+ start: e,
221
+ end: t
222
+ }), r = {};
223
+ if (Array.isArray(n) && n.length) for (let i = 0; i < n.length; i++) {
224
+ let a = n[i], o = a > e && a < t;
225
+ r[l(a)] = o;
226
+ }
227
+ return r;
228
+ }
229
+ function F(e, t, n, r) {
230
+ if (t.length !== 1) return !0;
231
+ let i = C({
232
+ start: t[0],
233
+ end: e
234
+ });
235
+ if (!Array.isArray(i) || !i.length) return !0;
236
+ for (let a = 0; a < i.length; a++) {
237
+ for (let r of n ?? []) if (r > t[0] && r < e) return !1;
238
+ if ((r ?? []).includes(w(i[a]).toString())) return !1;
239
+ }
240
+ return !0;
241
+ }
242
+ function I(e, t) {
243
+ let n = l(e);
244
+ return t.includes(n) ? t : [...t, n];
245
+ }
246
+ function L(e, t) {
247
+ let n = l(e), r = t.indexOf(n);
248
+ if (r === -1) return t;
249
+ if (t.length === 1) return [];
250
+ let i = [...t];
251
+ return i.splice(r, 1), i;
252
+ }
253
+ function R(e, t, n) {
254
+ let r = l(e);
255
+ return t.includes(r) ? L(e, t) : n > 0 && t.length >= n ? t : I(e, t);
256
+ }
257
+ function z(e, t, n) {
258
+ let r = l(e), i = N(t);
259
+ return t.includes(r) ? t.indexOf(r) === 0 ? [] : L(e, t) : t.length > 1 || t.length === 1 && (!F(e, i, n.excludedates, n.excludeweekdays) || i[0] > e) ? [r] : I(e, t);
260
+ }
261
+ //#endregion
262
+ //#region ../../shared-utils/calendar/keyboard-navigation.ts
263
+ var B = {
264
+ ArrowLeft: -1,
265
+ ArrowRight: 1,
266
+ ArrowUp: -7,
267
+ ArrowDown: 7
268
+ };
269
+ function V(e) {
270
+ let t = e.nodeName;
271
+ return t === "INPUT" || t === "SELECT" || t === "BUTTON" && !e.dataset?.date;
272
+ }
273
+ function H(e, t, n) {
274
+ let r = x(e, t);
275
+ if (!r) return null;
276
+ let i = n(`button[data-date="${l(r)}"]`);
277
+ for (; i instanceof HTMLButtonElement && i.dataset.disabled;) if (r = x(r, t), i = n(`button[data-date="${l(r)}"]`), !i) return null;
278
+ return r;
279
+ }
280
+ function U(e) {
281
+ return B[e] ?? null;
282
+ }
283
+ //#endregion
284
+ //#region src/components/calendar/calendar.ts
285
+ var W = class extends o {
286
+ constructor(...e) {
287
+ super(...e), this.selected = [], this.multiple = T.props.multiple.default, this.maxMultiple = T.props.maxMultiple.default, this.range = T.props.range.default, this.earliest = T.props.earliest.default, this.latest = T.props.latest.default, this.excludedates = [], this.excludeweekdays = [], this.weeknumbers = T.props.weeknumbers.default, this.withcontrols = T.props.withcontrols.default, this.currentmonth = null, this.today = null, this.dayStrings = this.strings.dates.daysShort, this.dayStringsLong = this.strings.dates.days, 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.inRange = {}, this.rangeHovered = null, this.year = 0, this.month = 0, this.week = 0, this.currentmonthtouched = !1, this.focusedDate = null, this.selectableDates = [], this.tabIndexSet = 0;
288
+ }
289
+ get todayDate() {
290
+ return this.today ? h(this.today) : p();
291
+ }
292
+ firstUpdated(e) {
293
+ this.addEventListener("keydown", this.handleKeydown);
294
+ }
295
+ disconnectedCallback() {
296
+ this.removeEventListener("keydown", this.handleKeydown), super.disconnectedCallback();
297
+ }
298
+ updated(e) {
299
+ super.updated(e), e.has("selected") && this.convertSelected();
300
+ }
301
+ convertSelected() {
302
+ typeof this.selected == "string" && (this.selected = this.selected.split(",")), this.selected.length === 1 && this.selected[0] === "" && (this.selected = []), this._selected = N(this.selected), this.range && this.selected.length === 2 && (this.inRange = P(this._selected[0], this._selected[1])), this.setCurrentMonth();
303
+ }
304
+ setCurrentMonth() {
305
+ if (this.currentmonth === null && !this.currentmonthtouched && (this.currentmonthtouched = !0), this.selected.length && this.selected[0] !== "") {
306
+ let e = h(this.selected[this.selected.length - 1]);
307
+ this.currentmonth = isNaN(e.getTime()) ? f(this.todayDate) : e;
308
+ } else this.currentmonth === null && (this.currentmonth = f(this.todayDate));
309
+ (!this.currentmonth || isNaN(this.currentmonth.getTime())) && (this.currentmonth = f(this.todayDate)), this.year = this.currentmonth.getFullYear(), this.month = this.currentmonth.getMonth();
310
+ }
311
+ handleKeydown(e) {
312
+ let t = U(e.key);
313
+ t !== null && this.handleArrowKey(e, t);
314
+ }
315
+ handleArrowKey(e, t) {
316
+ let n = e.target;
317
+ if (V(n)) return;
318
+ if (e.preventDefault(), !this.focusedDate) {
319
+ this.focusOnCurrentDate();
320
+ return;
321
+ }
322
+ let r = H(this.focusedDate ? d(this.focusedDate) : _(this.year, this.month, 1), t, this.querySelector.bind(this));
323
+ if (r) {
324
+ let e = this.querySelector(`button[data-date="${l(r)}"]`);
325
+ e instanceof HTMLButtonElement && !e.dataset.disabled && (this.focusedDate = l(r), e.focus());
326
+ }
327
+ }
328
+ render() {
329
+ return t`
330
+ <div
331
+ class="pkt-calendar ${this.weeknumbers ? "pkt-cal-weeknumbers" : ""}"
332
+ @focusout=${this.closeEvent}
333
+ @keydown=${(e) => {
334
+ e.key === "Escape" && (e.preventDefault(), this.close());
335
+ }}
336
+ >
337
+ <nav class="pkt-cal-month-nav">
338
+ ${this.renderMonthNavButton("prev")}
339
+ ${this.renderMonthNav()}
340
+ ${this.renderMonthNavButton("next")}
341
+ </nav>
342
+ <table
343
+ class="pkt-cal-days pkt-txt-12-medium pkt-calendar__body"
344
+ role="grid"
345
+ ?aria-multiselectable=${this.range || this.multiple}
346
+ >
347
+ <thead>
348
+ ${this.renderDayNames()}
349
+ </thead>
350
+ <tbody>
351
+ ${this.renderCalendarBody()}
352
+ </tbody>
353
+ </table>
354
+ </div>
355
+ `;
356
+ }
357
+ renderMonthNavButton(e) {
358
+ let r = e === "prev", i = r ? this.isPrevMonthAllowed() : this.isNextMonthAllowed(), a = r ? this.prevMonthString : this.nextMonthString, o = r ? "chevron-thin-left" : "chevron-thin-right", s = r ? "pkt-calendar__prev-month" : "pkt-calendar__next-month", c = r ? () => this.prevMonth() : () => this.nextMonth();
359
+ return t`<div>
360
+ <button
361
+ type="button"
362
+ aria-label="${a}"
363
+ @click=${() => i && c()}
364
+ @keydown=${(e) => {
365
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), i && c());
366
+ }}
367
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only ${s} ${i ? "" : "pkt-invisible"}"
368
+ .data-disabled=${i ? n : "disabled"}
369
+ ?aria-disabled=${!i}
370
+ tabindex=${i ? "0" : "-1"}
371
+ >
372
+ <pkt-icon class="pkt-btn__icon" name="${o}"></pkt-icon>
373
+ <span class="pkt-btn__text">${a}</span>
374
+ </button>
375
+ </div>`;
376
+ }
377
+ renderDayNames() {
378
+ let e = [];
379
+ this.weeknumbers && e.push(t`<th><div class="pkt-calendar__week-number">${this.weekString}</div></th>`);
380
+ for (let n = 0; n < this.dayStrings.length; n++) e.push(t`<th>
381
+ <div class="pkt-calendar__day-name" aria-label="${this.dayStringsLong[n]}">
382
+ ${this.dayStrings[n]}
383
+ </div>
384
+ </th>`);
385
+ return t`<tr class="pkt-cal-week-row">${e}</tr>`;
386
+ }
387
+ renderMonthNav() {
388
+ return this.withcontrols ? t`<div class="pkt-cal-month-picker">
389
+ <label for="${this.id}-monthnav" class="pkt-hide">${this.strings.dates.month}</label>
390
+ <select
391
+ aria-label="${this.strings.dates.month}"
392
+ class="pkt-input pkt-input-compact"
393
+ id="${this.id}-monthnav"
394
+ @change=${(e) => {
395
+ e.stopImmediatePropagation();
396
+ let t = e.target;
397
+ this.changeMonth(this.year, parseInt(t.value));
398
+ }}
399
+ >
400
+ ${this.monthStrings.map((e, n) => t`<option value=${n} ?selected=${this.month === n}>${e}</option>`)}
401
+ </select>
402
+ <label for="${this.id}-yearnav" class="pkt-hide">${this.strings.dates.year}</label>
403
+ <input
404
+ aria-label="${this.strings.dates.year}"
405
+ class="pkt-input pkt-cal-input-year pkt-input-compact"
406
+ id="${this.id}-yearnav"
407
+ type="number"
408
+ size="4"
409
+ placeholder="0000"
410
+ @change=${(e) => {
411
+ e.stopImmediatePropagation();
412
+ let t = e.target;
413
+ this.changeMonth(parseInt(t.value), this.month);
414
+ }}
415
+ .value=${this.year}
416
+ />
417
+ </div>` : t`<div class="pkt-txt-16-medium pkt-calendar__month-title" aria-live="polite">
418
+ ${this.monthStrings[this.month]} ${this.year}
419
+ </div>`;
420
+ }
421
+ getDayViewData(e, t) {
422
+ let n = _(this.year, this.month, e), r = l(n), i = r === l(t), a = this.selected.includes(r), o = this.isDayDisabled(n, a), s = this.calculateTabIndex(r, o, e);
423
+ return {
424
+ currentDate: n,
425
+ currentDateISO: r,
426
+ isToday: i,
427
+ isSelected: a,
428
+ isDisabled: o,
429
+ ariaLabel: g(n),
430
+ tabindex: s
431
+ };
432
+ }
433
+ getDateConstraints() {
434
+ return {
435
+ earliest: this.earliest,
436
+ latest: this.latest,
437
+ excludedates: this.excludedates,
438
+ excludeweekdays: this.excludeweekdays
439
+ };
440
+ }
441
+ isDayDisabled(e, t) {
442
+ return D(e, t, this.getDateConstraints(), {
443
+ multiple: this.multiple,
444
+ maxMultiple: this.maxMultiple,
445
+ selectedCount: this.selected.length
446
+ });
447
+ }
448
+ calculateTabIndex(e, t, n) {
449
+ return this.focusedDate ? this.focusedDate === e && !t ? "0" : "-1" : !t && this.tabIndexSet === 0 ? (this.tabIndexSet = n, "0") : this.tabIndexSet === n ? "0" : "-1";
450
+ }
451
+ getDayCellClasses(e) {
452
+ let { currentDateISO: t, isToday: n, isSelected: r } = e, i = this.range && (this.selected.length === 2 || this.rangeHovered !== null) && t === this.selected[0], a = this.range && this.selected.length === 2 && t === this.selected[1];
453
+ return {
454
+ "pkt-cal-today": n,
455
+ "pkt-cal-selected": r,
456
+ "pkt-cal-in-range": this.inRange[t],
457
+ "pkt-cal-excluded": this.isExcluded(e.currentDate),
458
+ "pkt-cal-in-range-first": i,
459
+ "pkt-cal-in-range-last": a,
460
+ "pkt-cal-range-hover": this.rangeHovered !== null && t === l(this.rangeHovered)
461
+ };
462
+ }
463
+ getDayButtonClasses(e) {
464
+ let { currentDateISO: t, isToday: n, isSelected: r, isDisabled: i } = e, a = this.range && (this.selected.length === 2 || this.rangeHovered !== null) && t === this.selected[0], o = this.range && this.selected.length === 2 && t === this.selected[1];
465
+ return {
466
+ "pkt-calendar__date": !0,
467
+ "pkt-calendar__date--today": n,
468
+ "pkt-calendar__date--selected": r,
469
+ "pkt-calendar__date--disabled": i,
470
+ "pkt-calendar__date--in-range": this.inRange[t],
471
+ "pkt-calendar__date--in-range-hover": this.rangeHovered !== null && t === l(this.rangeHovered),
472
+ "pkt-calendar__date--range-start": a,
473
+ "pkt-calendar__date--range-end": o
474
+ };
475
+ }
476
+ handleDayFocus(e, t) {
477
+ this.range && !this.isExcluded(e) && this.handleRangeHover(e), this.focusedDate = t;
478
+ }
479
+ renderDayView(e, r) {
480
+ let i = this.getDayViewData(e, r), { currentDate: a, currentDateISO: o, isSelected: c, isDisabled: l, ariaLabel: u, tabindex: d } = i;
481
+ this.selectableDates.push({
482
+ currentDateISO: o,
483
+ isDisabled: l,
484
+ tabindex: d
485
+ });
486
+ let f = this.getDayCellClasses(i), p = this.getDayButtonClasses(i);
487
+ return t`<td class=${s(f)}>
488
+ <button
489
+ type="button"
490
+ aria-pressed=${c ? "true" : "false"}
491
+ ?disabled=${l}
492
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only ${s(p)}"
493
+ @mouseover=${() => this.range && !this.isExcluded(a) && this.handleRangeHover(a)}
494
+ @focus=${() => this.handleDayFocus(a, o)}
495
+ aria-label="${u}"
496
+ tabindex=${d}
497
+ data-disabled=${l ? "disabled" : n}
498
+ data-date=${o}
499
+ @keydown=${(e) => {
500
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.handleDateSelect(a));
501
+ }}
502
+ @click=${(e) => {
503
+ l || (e.preventDefault(), this.handleDateSelect(a));
504
+ }}
505
+ >
506
+ <span class="pkt-btn__text pkt-txt-14-light">${e}</span>
507
+ </button>
508
+ </td>`;
509
+ }
510
+ renderEmptyDayCell(e) {
511
+ return t`<td class="pkt-cal-other">
512
+ <div
513
+ class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--label-only"
514
+ data-disabled="disabled"
515
+ >
516
+ <span class="pkt-btn__text pkt-txt-14-light">${e}</span>
517
+ </div>
518
+ </td>`;
519
+ }
520
+ renderWeekRow(e) {
521
+ return t`<tr class="pkt-cal-week-row" role="row">${e}</tr>`;
522
+ }
523
+ renderCalendarBody() {
524
+ let e = this.todayDate, n = A(this.year, this.month);
525
+ this.selectableDates = [], this.tabIndexSet = 0;
526
+ let r = 1;
527
+ this.week = n.initialWeek;
528
+ let i = [];
529
+ for (let a = 0; a < n.numRows; a++) {
530
+ let o = [];
531
+ this.weeknumbers && o.push(t`<td class="pkt-cal-week">${this.week}</td>`), this.week++;
532
+ for (let t = 0; t < 7; t++) {
533
+ let i = j(a, t, r, n);
534
+ if (i === "current-month") o.push(this.renderDayView(r, e)), r++;
535
+ else {
536
+ let e = M(i, t, r, n);
537
+ o.push(this.renderEmptyDayCell(e)), i === "next-month" && r++;
538
+ }
539
+ }
540
+ i.push(this.renderWeekRow(o));
541
+ }
542
+ return i;
543
+ }
544
+ isExcluded(e) {
545
+ return E(e, this.getDateConstraints());
546
+ }
547
+ isPrevMonthAllowed() {
548
+ return O(this.year, this.month, this.earliest);
549
+ }
550
+ prevMonth() {
551
+ let e = this.month === 0 ? 11 : this.month - 1, t = this.month === 0 ? this.year - 1 : this.year;
552
+ this.changeMonth(t, e);
553
+ }
554
+ isNextMonthAllowed() {
555
+ return k(this.year, this.month, this.latest);
556
+ }
557
+ nextMonth() {
558
+ let e = this.month === 11 ? 0 : this.month + 1, t = this.month === 11 ? this.year + 1 : this.year;
559
+ this.changeMonth(t, e);
560
+ }
561
+ changeMonth(e, t) {
562
+ this.year = typeof e == "string" ? parseInt(e) : e, this.month = typeof t == "string" ? parseInt(t) : t, this.currentmonth = f(new Date(this.year, this.month, 1)), this.tabIndexSet = 0, this.focusedDate = null, this.selectableDates = [];
563
+ }
564
+ emptySelected() {
565
+ this.selected = [], this._selected = [], this.inRange = {};
566
+ }
567
+ normalizeSelected() {
568
+ return typeof this.selected == "string" ? this.selected.split(",") : this.selected;
569
+ }
570
+ addToSelected(e) {
571
+ this.selected = I(e, this.normalizeSelected()), this._selected = N(this.selected), this.range && this.selected.length === 2 && (this.convertSelected(), this.close());
572
+ }
573
+ removeFromSelected(e) {
574
+ this.selected = L(e, this.normalizeSelected()), this._selected = N(this.selected);
575
+ }
576
+ toggleSelected(e) {
577
+ this.selected = R(e, this.normalizeSelected(), this.maxMultiple), this._selected = N(this.selected);
578
+ }
579
+ isRangeAllowed(e) {
580
+ return F(e, this._selected, this.excludedates, this.excludeweekdays);
581
+ }
582
+ handleRangeSelect(e) {
583
+ return this.selected = z(e, this.normalizeSelected(), {
584
+ excludedates: this.excludedates,
585
+ excludeweekdays: this.excludeweekdays
586
+ }), this._selected = N(this.selected), this.selected.length === 2 ? (this.convertSelected(), this.close()) : this.selected.length === 1 && (this.inRange = {}), Promise.resolve();
587
+ }
588
+ handleRangeHover(e) {
589
+ if (!this.range || this._selected.length !== 1 || !this.isRangeAllowed(e) || this._selected[0] >= e) {
590
+ this.rangeHovered = null;
591
+ return;
592
+ }
593
+ this.rangeHovered = e, this.inRange = P(this._selected[0], e);
594
+ }
595
+ handleDateSelect(e) {
596
+ return e ? (this.range ? this.handleRangeSelect(e) : this.multiple ? this.toggleSelected(e) : (this.selected.includes(l(e)) ? this.emptySelected() : (this.emptySelected(), this.addToSelected(e)), this.close()), this.dispatchEvent(new CustomEvent("date-selected", {
597
+ detail: this.selected,
598
+ bubbles: !0,
599
+ composed: !0
600
+ })), Promise.resolve()) : Promise.resolve();
601
+ }
602
+ focusOnCurrentDate() {
603
+ let e = l(f(this.todayDate)), t = this.querySelector(`button[data-date="${e}"]`);
604
+ if (t instanceof HTMLButtonElement) {
605
+ this.focusedDate = e, t.focus();
606
+ return;
607
+ }
608
+ let n = this.selectableDates.find((e) => !e.isDisabled);
609
+ if (n) {
610
+ let e = this.querySelector(`button[data-date="${n.currentDateISO}"]`);
611
+ e instanceof HTMLButtonElement && (this.focusedDate = n.currentDateISO, e.focus());
612
+ }
613
+ }
614
+ closeEvent(e) {
615
+ !this.contains(e.relatedTarget) && !e.target.classList.contains("pkt-invisible") && this.close();
616
+ }
617
+ close() {
618
+ this.dispatchEvent(new CustomEvent("close", {
619
+ detail: !0,
620
+ bubbles: !0,
621
+ composed: !0
622
+ }));
623
+ }
624
+ };
625
+ i([a({ converter: v.csvToArray })], W.prototype, "selected", void 0), i([a({ type: Boolean })], W.prototype, "multiple", void 0), i([a({
626
+ type: Number,
627
+ attribute: "max-multiple"
628
+ })], W.prototype, "maxMultiple", void 0), i([a({ type: Boolean })], W.prototype, "range", void 0), i([a({ type: String })], W.prototype, "earliest", void 0), i([a({ type: String })], W.prototype, "latest", void 0), i([a({ converter: v.stringsToDate })], W.prototype, "excludedates", void 0), i([a({ converter: v.csvToArray })], W.prototype, "excludeweekdays", void 0), i([a({ type: Boolean })], W.prototype, "weeknumbers", void 0), i([a({ type: Boolean })], W.prototype, "withcontrols", void 0), i([a({ converter: v.stringToDate })], W.prototype, "currentmonth", void 0), i([a({ type: String })], W.prototype, "today", void 0), i([a({
629
+ type: Array,
630
+ attribute: "day-strings"
631
+ })], W.prototype, "dayStrings", void 0), i([a({
632
+ type: Array,
633
+ attribute: "day-strings-long"
634
+ })], W.prototype, "dayStringsLong", void 0), i([a({
635
+ type: Array,
636
+ attribute: "month-strings"
637
+ })], W.prototype, "monthStrings", void 0), i([a({
638
+ type: String,
639
+ attribute: "week-string"
640
+ })], W.prototype, "weekString", void 0), i([a({
641
+ type: String,
642
+ attribute: "prev-month-string"
643
+ })], W.prototype, "prevMonthString", void 0), i([a({
644
+ type: String,
645
+ attribute: "next-month-string"
646
+ })], W.prototype, "nextMonthString", void 0), i([a({ type: Array })], W.prototype, "_selected", void 0), i([r()], W.prototype, "inRange", void 0), i([a({ type: Date })], W.prototype, "rangeHovered", void 0), i([a({ type: Number })], W.prototype, "year", void 0), i([a({ type: Number })], W.prototype, "month", void 0), i([a({ type: Number })], W.prototype, "week", void 0), i([r()], W.prototype, "currentmonthtouched", void 0), i([r()], W.prototype, "focusedDate", void 0);
647
+ try {
648
+ e("pkt-calendar")(W);
649
+ } catch {
650
+ console.warn("Forsøker å definere <pkt-calendar>, men den er allerede definert");
651
+ }
652
+ //#endregion
653
+ //#region src/components/calendar/index.ts
654
+ var G = W;
655
+ //#endregion
656
+ export { W as n, G as t };