@oslokommune/punkt-elements 13.6.6 → 13.6.8
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.
- package/CHANGELOG.md +34 -0
- package/dist/{calendar-ChphTIhk.js → calendar-CodWwTHM.js} +503 -471
- package/dist/calendar-DH-fCGyW.cjs +115 -0
- package/dist/{combobox-C_pTRtsQ.js → combobox-DxNotM0u.js} +2 -2
- package/dist/{combobox-CNH-j9Za.cjs → combobox-cK_746ek.cjs} +2 -2
- package/dist/datepicker-BEMo4X9s.js +770 -0
- package/dist/datepicker-n49TAIAt.cjs +169 -0
- package/dist/index.d.ts +7 -1
- package/dist/{listbox-BBO1d5Jd.cjs → listbox-L-iOSF7M.cjs} +2 -2
- package/dist/{listbox-DJ7b3Wmc.js → listbox-n4wjlLqD.js} +10 -10
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +4 -4
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +1 -1
- package/package.json +2 -2
- package/src/components/calendar/calendar.ts +26 -28
- package/src/components/combobox/combobox.ts +1 -1
- package/src/components/datepicker/date-tags.ts +2 -1
- package/src/components/datepicker/datepicker-utils.ts +475 -0
- package/src/components/datepicker/datepicker.selection.test.ts +62 -1
- package/src/components/datepicker/datepicker.ts +157 -271
- package/src/components/listbox/listbox.ts +1 -1
- package/dist/calendar-CL9O0tLP.cjs +0 -115
- package/dist/datepicker-CV73pLqD.cjs +0 -169
- package/dist/datepicker-Ca552mbJ.js +0 -531
|
@@ -1,531 +0,0 @@
|
|
|
1
|
-
import { e as f } from "./class-map-Dw6Wrxwi.js";
|
|
2
|
-
import { o } from "./if-defined-D3lgJqT7.js";
|
|
3
|
-
import { P as _, E as y, x as p, n as r, a as w } from "./element-DJZPsA_J.js";
|
|
4
|
-
import { r as R } from "./state-CPQXJ4Ct.js";
|
|
5
|
-
import { f as k, n as $, a as b, b as S, p as T, d as C } from "./calendar-ChphTIhk.js";
|
|
6
|
-
import { P as D } from "./input-element-DQOVrqUZ.js";
|
|
7
|
-
import { e as m, n as d } from "./ref-BCGCor-j.js";
|
|
8
|
-
import "./icon-B1-mkmwB.js";
|
|
9
|
-
import "./input-wrapper-D_JdEqcO.js";
|
|
10
|
-
import { c as P } from "./repeat-B6qPUgAq.js";
|
|
11
|
-
import "./tag-NZ5oeGfw.js";
|
|
12
|
-
import { u as B } from "./stringutils-DJjRa8dG.js";
|
|
13
|
-
import { P as I } from "./pkt-slot-controller-BPGj-LC5.js";
|
|
14
|
-
var O = Object.defineProperty, A = Object.getOwnPropertyDescriptor, v = (t, e, i, a) => {
|
|
15
|
-
for (var s = a > 1 ? void 0 : a ? A(e, i) : e, h = t.length - 1, u; h >= 0; h--)
|
|
16
|
-
(u = t[h]) && (s = (a ? u(e, i, s) : u(s)) || s);
|
|
17
|
-
return a && s && O(e, i, s), s;
|
|
18
|
-
};
|
|
19
|
-
let g = class extends _ {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(...arguments), this.dates = [], this.dateformat = "dd.MM.yyyy", this.className = "pkt-datepicker__tags", this.idBase = B();
|
|
22
|
-
}
|
|
23
|
-
render() {
|
|
24
|
-
return this.classes = {
|
|
25
|
-
"pkt-date-tags": !0,
|
|
26
|
-
[this.className]: !0
|
|
27
|
-
}, p`
|
|
28
|
-
<div class=${f(this.classes)} aria-live="polite">
|
|
29
|
-
${Array.isArray(this.dates) && this.dates[0] ? P(
|
|
30
|
-
(this.dates ?? []).filter(Boolean).sort(),
|
|
31
|
-
(t) => t,
|
|
32
|
-
(t) => {
|
|
33
|
-
var e;
|
|
34
|
-
return p` <pkt-tag
|
|
35
|
-
id=${this.idBase + t + "-tag"}
|
|
36
|
-
closeTag
|
|
37
|
-
@close=${() => {
|
|
38
|
-
this.dispatchEvent(new CustomEvent("date-tag-removed", { detail: t }));
|
|
39
|
-
}}
|
|
40
|
-
.ariaLabel=${`${(e = this.strings) == null ? void 0 : e.calendar.deleteDate} ${k(t, this.dateformat)}`}
|
|
41
|
-
>
|
|
42
|
-
<time datetime=${t}>${k(t, this.dateformat)}</time>
|
|
43
|
-
</pkt-tag>`;
|
|
44
|
-
}
|
|
45
|
-
) : y}
|
|
46
|
-
</div>
|
|
47
|
-
`;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
v([
|
|
51
|
-
r({ type: Array })
|
|
52
|
-
], g.prototype, "dates", 2);
|
|
53
|
-
v([
|
|
54
|
-
r({ type: String })
|
|
55
|
-
], g.prototype, "dateformat", 2);
|
|
56
|
-
v([
|
|
57
|
-
r({ type: String, attribute: "class" })
|
|
58
|
-
], g.prototype, "className", 2);
|
|
59
|
-
v([
|
|
60
|
-
r({ type: String, attribute: "id-base" })
|
|
61
|
-
], g.prototype, "idBase", 2);
|
|
62
|
-
g = v([
|
|
63
|
-
w("pkt-date-tags")
|
|
64
|
-
], g);
|
|
65
|
-
const E = {
|
|
66
|
-
dateformat: {
|
|
67
|
-
default: "dd.MM.yyyy"
|
|
68
|
-
},
|
|
69
|
-
min: {
|
|
70
|
-
default: null
|
|
71
|
-
},
|
|
72
|
-
max: {
|
|
73
|
-
default: null
|
|
74
|
-
},
|
|
75
|
-
weeknumbers: {
|
|
76
|
-
default: !1
|
|
77
|
-
},
|
|
78
|
-
withcontrols: {
|
|
79
|
-
default: !1
|
|
80
|
-
},
|
|
81
|
-
multiple: {
|
|
82
|
-
default: !1
|
|
83
|
-
},
|
|
84
|
-
range: {
|
|
85
|
-
default: !1
|
|
86
|
-
}
|
|
87
|
-
}, c = {
|
|
88
|
-
props: E
|
|
89
|
-
};
|
|
90
|
-
var L = Object.defineProperty, M = Object.getOwnPropertyDescriptor, n = (t, e, i, a) => {
|
|
91
|
-
for (var s = a > 1 ? void 0 : a ? M(e, i) : e, h = t.length - 1, u; h >= 0; h--)
|
|
92
|
-
(u = t[h]) && (s = (a ? u(e, i, s) : u(s)) || s);
|
|
93
|
-
return a && s && L(e, i, s), s;
|
|
94
|
-
};
|
|
95
|
-
const x = (t) => new Promise((e) => setTimeout(e, t));
|
|
96
|
-
let l = class extends D {
|
|
97
|
-
/**
|
|
98
|
-
* Housekeeping / lifecycle methods
|
|
99
|
-
*/
|
|
100
|
-
constructor() {
|
|
101
|
-
super(), this._valueProperty = "", this._value = [], this.label = "Datovelger", this.dateformat = c.props.dateformat.default, this.multiple = c.props.multiple.default, this.maxlength = null, this.range = c.props.range.default, this.showRangeLabels = !1, this.min = null, this.max = null, this.weeknumbers = c.props.weeknumbers.default, this.withcontrols = c.props.withcontrols.default, this.excludedates = [], this.excludeweekdays = [], this.currentmonth = null, this.calendarOpen = !1, this.timezone = "Europe/Oslo", this.inputClasses = {}, this.buttonClasses = {}, this.inputRef = m(), this.inputRefTo = m(), this.btnRef = m(), this.calRef = m(), this.popupRef = m(), this.helptextSlot = m(), this.addToSelected = (t) => {
|
|
102
|
-
const e = t.target;
|
|
103
|
-
if (!e.value) return;
|
|
104
|
-
const i = this.min ? $(this.min) : null, a = this.max ? $(this.max) : null, s = $(e.value.split(",")[0]);
|
|
105
|
-
s && !isNaN(s.getTime()) && (!i || s >= i) && (!a || s <= a) && this.calRef.value && this.calRef.value.handleDateSelect(s), e.value = "";
|
|
106
|
-
}, this.slotController = new I(this, this.helptextSlot);
|
|
107
|
-
}
|
|
108
|
-
get value() {
|
|
109
|
-
return this._valueProperty;
|
|
110
|
-
}
|
|
111
|
-
set value(t) {
|
|
112
|
-
const e = this._valueProperty;
|
|
113
|
-
this._valueProperty = Array.isArray(t) ? t.join(",") : t || "", this.valueChanged(this._valueProperty, e), this.requestUpdate("value", e);
|
|
114
|
-
}
|
|
115
|
-
async connectedCallback() {
|
|
116
|
-
super.connectedCallback();
|
|
117
|
-
const t = navigator.userAgent, e = /iP(hone|od|ad)/.test(t);
|
|
118
|
-
this.inputType = e ? "text" : "date", document && document.body.addEventListener("click", (i) => {
|
|
119
|
-
var a, s;
|
|
120
|
-
(a = this.inputRef) != null && a.value && ((s = this.btnRef) != null && s.value) && !this.inputRef.value.contains(i.target) && !(this.inputRefTo.value && this.inputRefTo.value.contains(i.target)) && !this.btnRef.value.contains(i.target) && !i.target.closest(".pkt-calendar-popup") && this.calendarOpen && (this.onBlur(), this.hideCalendar());
|
|
121
|
-
}), document && document.body.addEventListener("keydown", (i) => {
|
|
122
|
-
i.key === "Escape" && this.calendarOpen && this.hideCalendar();
|
|
123
|
-
}), this.value && (this._value = Array.isArray(this.value) ? this.value.filter(Boolean) : this.value.split(",").filter(Boolean)), this.min = this.min || c.props.min.default, this.max = this.max || c.props.max.default, typeof this.excludedates == "string" && (this.excludedates = this.excludedates.split(",")), typeof this.excludeweekdays == "string" && (this.excludeweekdays = this.excludeweekdays.split(",")), (this.multiple || this.range) && this.name && !this.name.endsWith("[]") && (this.name = this.name + "[]"), this.calendarOpen && (await x(20), this.handleCalendarPosition());
|
|
124
|
-
}
|
|
125
|
-
disconnectedCallback() {
|
|
126
|
-
super.disconnectedCallback(), document && document.body.removeEventListener("click", (t) => {
|
|
127
|
-
var e, i;
|
|
128
|
-
(e = this.inputRef) != null && e.value && ((i = this.btnRef) != null && i.value) && !this.inputRef.value.contains(t.target) && !this.btnRef.value.contains(t.target) && this.hideCalendar();
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
onInput() {
|
|
132
|
-
this.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
133
|
-
}
|
|
134
|
-
valueChanged(t, e) {
|
|
135
|
-
if (t === e) return;
|
|
136
|
-
let i = [];
|
|
137
|
-
t && (typeof t == "string" ? i = t.split(",").filter(Boolean) : i = String(t).split(",").filter(Boolean)), this._value = i;
|
|
138
|
-
const a = i.join(",");
|
|
139
|
-
this._valueProperty !== a && (this._valueProperty = a), super.valueChanged(a, e);
|
|
140
|
-
}
|
|
141
|
-
attributeChangedCallback(t, e, i) {
|
|
142
|
-
t === "value" && this.value !== e && this.valueChanged(i, e), t === "excludedates" && typeof this.excludedates == "string" && (this.excludedates = (i == null ? void 0 : i.split(",")) ?? []), t === "excludeweekdays" && typeof this.excludeweekdays == "string" && (this.excludeweekdays = (i == null ? void 0 : i.split(",")) ?? []), super.attributeChangedCallback(t, e, i);
|
|
143
|
-
}
|
|
144
|
-
updated(t) {
|
|
145
|
-
if (t.has("value")) {
|
|
146
|
-
const e = Array.isArray(this.value) ? this.value.join(",") : this.value, i = t.get("value"), a = Array.isArray(i) ? i.join(",") : i;
|
|
147
|
-
this.valueChanged(e, a);
|
|
148
|
-
}
|
|
149
|
-
t.has("multiple") && (this.multiple && !Array.isArray(this._value) ? this._value = typeof this.value == "string" ? this.value ? this.value.split(",").filter(Boolean) : [] : [] : !this.multiple && Array.isArray(this._value) && (this._value = this._value.filter(Boolean)), !this.multiple && !this.range && Array.isArray(this._value) && (this._value = [this._value[0] ?? ""])), super.updated(t);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Rendering
|
|
153
|
-
*/
|
|
154
|
-
renderInput() {
|
|
155
|
-
return p`
|
|
156
|
-
<input
|
|
157
|
-
class="${f(this.inputClasses)}"
|
|
158
|
-
.type=${this.inputType}
|
|
159
|
-
id="${this.id}-input"
|
|
160
|
-
.value=${this._value[0] ?? ""}
|
|
161
|
-
min=${o(this.min)}
|
|
162
|
-
max=${o(this.max)}
|
|
163
|
-
placeholder=${o(this.placeholder)}
|
|
164
|
-
?readonly=${this.readonly}
|
|
165
|
-
aria-describedby="${this.id}-helptext"
|
|
166
|
-
@click=${(t) => {
|
|
167
|
-
t.preventDefault(), this.showCalendar();
|
|
168
|
-
}}
|
|
169
|
-
?disabled=${this.disabled}
|
|
170
|
-
@keydown=${(t) => {
|
|
171
|
-
var e, i;
|
|
172
|
-
if (t.key === "," && ((e = this.inputRef.value) == null || e.blur()), (t.key === "Space" || t.key === " ") && (t.preventDefault(), this.toggleCalendar(t)), t.key === "Enter") {
|
|
173
|
-
const a = this.internals.form;
|
|
174
|
-
a ? a.requestSubmit() : (i = this.inputRef.value) == null || i.blur();
|
|
175
|
-
}
|
|
176
|
-
}}
|
|
177
|
-
@input=${(t) => {
|
|
178
|
-
this.onInput(), t.stopImmediatePropagation();
|
|
179
|
-
}}
|
|
180
|
-
@focus=${() => {
|
|
181
|
-
this.onFocus(), this.isMobileSafari && this.showCalendar();
|
|
182
|
-
}}
|
|
183
|
-
@blur=${(t) => {
|
|
184
|
-
var e;
|
|
185
|
-
(e = this.calRef.value) != null && e.contains(t.relatedTarget) || this.onBlur(), this.manageValidity(t.target), this.value = t.target.value;
|
|
186
|
-
}}
|
|
187
|
-
@change=${(t) => {
|
|
188
|
-
this.touched = !0, t.stopImmediatePropagation();
|
|
189
|
-
}}
|
|
190
|
-
${d(this.inputRef)}
|
|
191
|
-
/>
|
|
192
|
-
`;
|
|
193
|
-
}
|
|
194
|
-
renderRangeInput() {
|
|
195
|
-
const t = {
|
|
196
|
-
"pkt-input-prefix": this.showRangeLabels,
|
|
197
|
-
"pkt-hide": !this.showRangeLabels
|
|
198
|
-
};
|
|
199
|
-
return p`
|
|
200
|
-
${this.showRangeLabels ? p` <div class="pkt-input-prefix">${this.strings.generic.from}</div> ` : y}
|
|
201
|
-
<input
|
|
202
|
-
class=${f(this.inputClasses)}
|
|
203
|
-
.type=${this.inputType}
|
|
204
|
-
id="${this.id}-input"
|
|
205
|
-
.value=${this._value[0] ?? ""}
|
|
206
|
-
min=${o(this.min)}
|
|
207
|
-
max=${o(this.max)}
|
|
208
|
-
placeholder=${o(this.placeholder)}
|
|
209
|
-
?readonly=${this.readonly}
|
|
210
|
-
?disabled=${this.disabled}
|
|
211
|
-
@click=${(e) => {
|
|
212
|
-
e.preventDefault(), this.showCalendar();
|
|
213
|
-
}}
|
|
214
|
-
@keydown=${(e) => {
|
|
215
|
-
var i, a;
|
|
216
|
-
if (e.key === "," && ((i = this.inputRef.value) == null || i.blur()), (e.key === "Space" || e.key === " ") && (e.preventDefault(), this.toggleCalendar(e)), e.key === "Enter") {
|
|
217
|
-
const s = this.internals.form;
|
|
218
|
-
s ? s.requestSubmit() : (a = this.inputRefTo.value) == null || a.focus();
|
|
219
|
-
}
|
|
220
|
-
}}
|
|
221
|
-
@input=${(e) => {
|
|
222
|
-
this.onInput(), e.stopImmediatePropagation();
|
|
223
|
-
}}
|
|
224
|
-
@focus=${() => {
|
|
225
|
-
this.onFocus(), this.isMobileSafari && this.showCalendar();
|
|
226
|
-
}}
|
|
227
|
-
@blur=${(e) => {
|
|
228
|
-
var i, a;
|
|
229
|
-
if (e.target.value) {
|
|
230
|
-
this.manageValidity(e.target);
|
|
231
|
-
const s = b(e.target.value);
|
|
232
|
-
s && this._value[0] !== e.target.value && this._value[1] && (this.clearInputValue(), (a = (i = this.calRef) == null ? void 0 : i.value) == null || a.handleDateSelect(s));
|
|
233
|
-
} else this._value[0] && this.clearInputValue();
|
|
234
|
-
}}
|
|
235
|
-
@change=${(e) => {
|
|
236
|
-
e.stopImmediatePropagation();
|
|
237
|
-
}}
|
|
238
|
-
${d(this.inputRef)}
|
|
239
|
-
/>
|
|
240
|
-
<div class="${f(t)}" id="${this.id}-to-label">
|
|
241
|
-
${this.strings.generic.to}
|
|
242
|
-
</div>
|
|
243
|
-
${this.showRangeLabels ? y : p` <div class="pkt-input-separator">–</div> `}
|
|
244
|
-
<input
|
|
245
|
-
class=${f(this.inputClasses)}
|
|
246
|
-
.type=${this.inputType}
|
|
247
|
-
id="${this.id}-to"
|
|
248
|
-
aria-labelledby="${this.id}-to-label"
|
|
249
|
-
.value=${this._value[1] ?? ""}
|
|
250
|
-
min=${o(this.min)}
|
|
251
|
-
max=${o(this.max)}
|
|
252
|
-
placeholder=${o(this.placeholder)}
|
|
253
|
-
?readonly=${this.readonly}
|
|
254
|
-
?disabled=${this.disabled}
|
|
255
|
-
@click=${(e) => {
|
|
256
|
-
e.preventDefault(), this.showCalendar();
|
|
257
|
-
}}
|
|
258
|
-
@keydown=${(e) => {
|
|
259
|
-
var i, a;
|
|
260
|
-
if (e.key === "," && ((i = this.inputRefTo.value) == null || i.blur()), (e.key === "Space" || e.key === " ") && (e.preventDefault(), this.toggleCalendar(e)), e.key === "Enter") {
|
|
261
|
-
const s = this.internals.form;
|
|
262
|
-
s ? s.requestSubmit() : (a = this.inputRefTo.value) == null || a.blur();
|
|
263
|
-
}
|
|
264
|
-
}}
|
|
265
|
-
@input=${(e) => {
|
|
266
|
-
this.onInput(), e.stopImmediatePropagation();
|
|
267
|
-
}}
|
|
268
|
-
@focus=${() => {
|
|
269
|
-
this.onFocus(), this.isMobileSafari && this.showCalendar();
|
|
270
|
-
}}
|
|
271
|
-
@blur=${(e) => {
|
|
272
|
-
var i, a, s;
|
|
273
|
-
if ((i = this.calRef.value) != null && i.contains(e.relatedTarget) || this.onBlur(), e.target.value) {
|
|
274
|
-
this.manageValidity(e.target);
|
|
275
|
-
const h = e.target.value;
|
|
276
|
-
this.min && this.min > h ? this.internals.setValidity(
|
|
277
|
-
{ rangeUnderflow: !0 },
|
|
278
|
-
this.strings.forms.messages.rangeUnderflow,
|
|
279
|
-
e.target
|
|
280
|
-
) : this.max && this.max < h && this.internals.setValidity(
|
|
281
|
-
{ rangeOverflow: !0 },
|
|
282
|
-
this.strings.forms.messages.rangeOverflow,
|
|
283
|
-
e.target
|
|
284
|
-
);
|
|
285
|
-
const u = b(e.target.value);
|
|
286
|
-
u && this._value[1] !== S(u) && ((s = (a = this.calRef) == null ? void 0 : a.value) == null || s.handleDateSelect(u));
|
|
287
|
-
}
|
|
288
|
-
}}
|
|
289
|
-
@change=${(e) => {
|
|
290
|
-
this.touched = !0, e.stopImmediatePropagation();
|
|
291
|
-
}}
|
|
292
|
-
${d(this.inputRefTo)}
|
|
293
|
-
/>
|
|
294
|
-
`;
|
|
295
|
-
}
|
|
296
|
-
renderMultipleInput() {
|
|
297
|
-
return p`
|
|
298
|
-
<input
|
|
299
|
-
class=${f(this.inputClasses)}
|
|
300
|
-
.type=${this.inputType}
|
|
301
|
-
id="${this.id}-input"
|
|
302
|
-
min=${o(this.min)}
|
|
303
|
-
max=${o(this.max)}
|
|
304
|
-
placeholder=${o(this.placeholder)}
|
|
305
|
-
?readonly=${this.readonly}
|
|
306
|
-
?disabled=${this.disabled || this.maxlength && this._value.length >= this.maxlength}
|
|
307
|
-
@click=${(t) => {
|
|
308
|
-
t.preventDefault(), this.showCalendar();
|
|
309
|
-
}}
|
|
310
|
-
@blur=${(t) => {
|
|
311
|
-
var e;
|
|
312
|
-
(e = this.calRef.value) != null && e.contains(t.relatedTarget) || this.onBlur(), this.addToSelected(t);
|
|
313
|
-
}}
|
|
314
|
-
@input=${(t) => {
|
|
315
|
-
this.onInput(), t.stopImmediatePropagation();
|
|
316
|
-
}}
|
|
317
|
-
@focus=${() => {
|
|
318
|
-
this.onFocus(), this.isMobileSafari && this.showCalendar();
|
|
319
|
-
}}
|
|
320
|
-
@keydown=${(t) => {
|
|
321
|
-
var e;
|
|
322
|
-
if (t.key === "," && (t.preventDefault(), this.addToSelected(t)), (t.key === "Space" || t.key === " ") && (t.preventDefault(), this.toggleCalendar(t)), t.key === "Enter") {
|
|
323
|
-
const i = this.internals.form;
|
|
324
|
-
i ? i.requestSubmit() : (e = this.inputRef.value) == null || e.blur();
|
|
325
|
-
}
|
|
326
|
-
}}
|
|
327
|
-
@change=${(t) => {
|
|
328
|
-
this.touched = !0, t.stopImmediatePropagation();
|
|
329
|
-
}}
|
|
330
|
-
${d(this.inputRef)}
|
|
331
|
-
/>
|
|
332
|
-
`;
|
|
333
|
-
}
|
|
334
|
-
renderCalendar() {
|
|
335
|
-
return p`<div
|
|
336
|
-
class="pkt-calendar-popup pkt-${this.calendarOpen ? "show" : "hide"}"
|
|
337
|
-
@focusout=${(t) => {
|
|
338
|
-
this.calendarOpen && this.handleFocusOut(t);
|
|
339
|
-
}}
|
|
340
|
-
id="${this.id}-popup"
|
|
341
|
-
${d(this.popupRef)}
|
|
342
|
-
>
|
|
343
|
-
<pkt-calendar
|
|
344
|
-
id="${this.id}-calendar"
|
|
345
|
-
?multiple=${this.multiple}
|
|
346
|
-
?range=${this.range}
|
|
347
|
-
?weeknumbers=${this.weeknumbers}
|
|
348
|
-
?withcontrols=${this.withcontrols}
|
|
349
|
-
.maxMultiple=${this.maxlength}
|
|
350
|
-
.selected=${this._value}
|
|
351
|
-
.earliest=${this.min}
|
|
352
|
-
.latest=${this.max}
|
|
353
|
-
.excludedates=${Array.isArray(this.excludedates) ? this.excludedates : this.excludedates.split(",")}
|
|
354
|
-
.excludeweekdays=${this.excludeweekdays}
|
|
355
|
-
.currentmonth=${this.currentmonth ? T(this.currentmonth) : null}
|
|
356
|
-
@date-selected=${(t) => {
|
|
357
|
-
this.value = !this.multiple && !this.range ? t.detail[0] : Array.isArray(t.detail) ? t.detail.join(",") : t.detail, this._value = t.detail, this.inputRef.value && (this.range && this.inputRefTo.value ? (this.inputRef.value.value = this._value[0] ?? "", this.inputRefTo.value.value = this._value[1] ?? "", this.manageValidity(this.inputRef.value), this.manageValidity(this.inputRefTo.value)) : this.multiple || (this.inputRef.value.value = this._value.length ? this._value[0] : "", this.manageValidity(this.inputRef.value)));
|
|
358
|
-
}}
|
|
359
|
-
@close=${() => {
|
|
360
|
-
this.onBlur(), this.hideCalendar();
|
|
361
|
-
}}
|
|
362
|
-
${d(this.calRef)}
|
|
363
|
-
></pkt-calendar>
|
|
364
|
-
</div>`;
|
|
365
|
-
}
|
|
366
|
-
render() {
|
|
367
|
-
return this.inputClasses = {
|
|
368
|
-
"pkt-input": !0,
|
|
369
|
-
"pkt-datepicker__input": !0,
|
|
370
|
-
"pkt-input--fullwidth": this.fullwidth,
|
|
371
|
-
"pkt-datepicker--hasrangelabels": this.showRangeLabels,
|
|
372
|
-
"pkt-datepicker--multiple": this.multiple,
|
|
373
|
-
"pkt-datepicker--range": this.range
|
|
374
|
-
}, this.buttonClasses = {
|
|
375
|
-
"pkt-input-icon": !0,
|
|
376
|
-
"pkt-btn": !0,
|
|
377
|
-
"pkt-btn--icon-only": !0,
|
|
378
|
-
"pkt-btn--tertiary": !0,
|
|
379
|
-
"pkt-datepicker__calendar-button": !0
|
|
380
|
-
}, p`
|
|
381
|
-
<pkt-input-wrapper
|
|
382
|
-
label="${this.label}"
|
|
383
|
-
forId="${this.id}-input"
|
|
384
|
-
?counter=${this.multiple && !!this.maxlength}
|
|
385
|
-
.counterCurrent=${this.value ? this._value.length : 0}
|
|
386
|
-
.counterMaxLength=${this.maxlength}
|
|
387
|
-
?disabled=${this.disabled}
|
|
388
|
-
?hasError=${this.hasError}
|
|
389
|
-
?hasFieldset=${this.hasFieldset}
|
|
390
|
-
?inline=${this.inline}
|
|
391
|
-
?required=${this.required}
|
|
392
|
-
?optionalTag=${this.optionalTag}
|
|
393
|
-
?requiredTag=${this.requiredTag}
|
|
394
|
-
?useWrapper=${this.useWrapper}
|
|
395
|
-
.optionalText=${this.optionalText}
|
|
396
|
-
.requiredText=${this.requiredText}
|
|
397
|
-
.tagText=${this.tagText}
|
|
398
|
-
.errorMessage=${this.errorMessage}
|
|
399
|
-
.helptext=${this.helptext}
|
|
400
|
-
.helptextDropdown=${this.helptextDropdown}
|
|
401
|
-
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
402
|
-
.ariaDescribedBy=${this.ariaDescribedBy}
|
|
403
|
-
class="pkt-datepicker"
|
|
404
|
-
>
|
|
405
|
-
<div class="pkt-contents" ${d(this.helptextSlot)} name="helptext" slot="helptext"></div>
|
|
406
|
-
${this.multiple ? p`<pkt-date-tags
|
|
407
|
-
.dates=${this._value}
|
|
408
|
-
dateformat=${this.dateformat}
|
|
409
|
-
strings=${this.strings}
|
|
410
|
-
id-base=${this.id}
|
|
411
|
-
@date-tag-removed=${(t) => {
|
|
412
|
-
var e;
|
|
413
|
-
(e = this.calRef.value) == null || e.handleDateSelect(b(t.detail));
|
|
414
|
-
}}
|
|
415
|
-
></pkt-date-tags>` : y}
|
|
416
|
-
<div
|
|
417
|
-
class="pkt-datepicker__inputs ${this.range && this.showRangeLabels ? "pkt-input__range-inputs" : ""}"
|
|
418
|
-
>
|
|
419
|
-
<div class="pkt-input__container">
|
|
420
|
-
${this.range ? this.renderRangeInput() : this.multiple ? this.renderMultipleInput() : this.renderInput()}
|
|
421
|
-
<button
|
|
422
|
-
class="${f(this.buttonClasses)}"
|
|
423
|
-
type="button"
|
|
424
|
-
@click=${this.toggleCalendar}
|
|
425
|
-
@keydown=${(t) => {
|
|
426
|
-
(t.key === "Enter" || t.key === " " || t.key === "Space") && (t.preventDefault(), this.toggleCalendar(t));
|
|
427
|
-
}}
|
|
428
|
-
?disabled=${this.disabled}
|
|
429
|
-
${d(this.btnRef)}
|
|
430
|
-
>
|
|
431
|
-
<pkt-icon name="calendar"></pkt-icon>
|
|
432
|
-
<span class="pkt-btn__text">${this.strings.calendar.buttonAltText}</span>
|
|
433
|
-
</button>
|
|
434
|
-
</div>
|
|
435
|
-
</div>
|
|
436
|
-
</pkt-input-wrapper>
|
|
437
|
-
${this.renderCalendar()}
|
|
438
|
-
`;
|
|
439
|
-
}
|
|
440
|
-
/**
|
|
441
|
-
* Handlers
|
|
442
|
-
*/
|
|
443
|
-
handleCalendarPosition() {
|
|
444
|
-
var t;
|
|
445
|
-
if (this.popupRef.value && this.inputRef.value) {
|
|
446
|
-
const e = this.multiple && !!this.maxlength, i = ((t = this.inputRef.value.parentElement) == null ? void 0 : t.getBoundingClientRect()) || this.inputRef.value.getBoundingClientRect(), a = e ? i.height + 30 : i.height, s = this.popupRef.value.getBoundingClientRect().height;
|
|
447
|
-
let h = e ? "calc(100% - 30px)" : "100%";
|
|
448
|
-
i && i.top + s > window.innerHeight && i.top - s > 0 && (h = `calc(100% - ${a}px - ${s}px)`), this.popupRef.value.style.top = h;
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
handleFocusOut(t) {
|
|
452
|
-
this.contains(t.target) || (this.onBlur(), this.hideCalendar());
|
|
453
|
-
}
|
|
454
|
-
async showCalendar() {
|
|
455
|
-
var t;
|
|
456
|
-
this.calendarOpen = !0, await x(20), this.handleCalendarPosition(), this.isMobileSafari && ((t = this.calRef.value) == null || t.focusOnCurrentDate());
|
|
457
|
-
}
|
|
458
|
-
hideCalendar() {
|
|
459
|
-
this.calendarOpen = !1;
|
|
460
|
-
}
|
|
461
|
-
async toggleCalendar(t) {
|
|
462
|
-
t.preventDefault(), this.calendarOpen ? this.hideCalendar() : this.showCalendar();
|
|
463
|
-
}
|
|
464
|
-
clearInputValue() {
|
|
465
|
-
this._value = [], this.value = "";
|
|
466
|
-
}
|
|
467
|
-
};
|
|
468
|
-
n([
|
|
469
|
-
r({ type: String, reflect: !0 })
|
|
470
|
-
], l.prototype, "value", 1);
|
|
471
|
-
n([
|
|
472
|
-
r({ type: Array })
|
|
473
|
-
], l.prototype, "_value", 2);
|
|
474
|
-
n([
|
|
475
|
-
r({ type: String, reflect: !0 })
|
|
476
|
-
], l.prototype, "label", 2);
|
|
477
|
-
n([
|
|
478
|
-
r({ type: String })
|
|
479
|
-
], l.prototype, "dateformat", 2);
|
|
480
|
-
n([
|
|
481
|
-
r({ type: Boolean, reflect: !0 })
|
|
482
|
-
], l.prototype, "multiple", 2);
|
|
483
|
-
n([
|
|
484
|
-
r({ type: Number, reflect: !0 })
|
|
485
|
-
], l.prototype, "maxlength", 2);
|
|
486
|
-
n([
|
|
487
|
-
r({ type: Boolean, reflect: !0 })
|
|
488
|
-
], l.prototype, "range", 2);
|
|
489
|
-
n([
|
|
490
|
-
r({ type: Boolean })
|
|
491
|
-
], l.prototype, "showRangeLabels", 2);
|
|
492
|
-
n([
|
|
493
|
-
r({ type: String, reflect: !0 })
|
|
494
|
-
], l.prototype, "min", 2);
|
|
495
|
-
n([
|
|
496
|
-
r({ type: String, reflect: !0 })
|
|
497
|
-
], l.prototype, "max", 2);
|
|
498
|
-
n([
|
|
499
|
-
r({ type: Boolean })
|
|
500
|
-
], l.prototype, "weeknumbers", 2);
|
|
501
|
-
n([
|
|
502
|
-
r({ type: Boolean, reflect: !0 })
|
|
503
|
-
], l.prototype, "withcontrols", 2);
|
|
504
|
-
n([
|
|
505
|
-
r({ converter: C.csvToArray })
|
|
506
|
-
], l.prototype, "excludedates", 2);
|
|
507
|
-
n([
|
|
508
|
-
r({ converter: C.csvToArray })
|
|
509
|
-
], l.prototype, "excludeweekdays", 2);
|
|
510
|
-
n([
|
|
511
|
-
r({ type: String })
|
|
512
|
-
], l.prototype, "currentmonth", 2);
|
|
513
|
-
n([
|
|
514
|
-
r({ type: Boolean, reflect: !0 })
|
|
515
|
-
], l.prototype, "calendarOpen", 2);
|
|
516
|
-
n([
|
|
517
|
-
r({ type: String })
|
|
518
|
-
], l.prototype, "timezone", 2);
|
|
519
|
-
n([
|
|
520
|
-
R()
|
|
521
|
-
], l.prototype, "inputClasses", 2);
|
|
522
|
-
n([
|
|
523
|
-
R()
|
|
524
|
-
], l.prototype, "buttonClasses", 2);
|
|
525
|
-
l = n([
|
|
526
|
-
w("pkt-datepicker")
|
|
527
|
-
], l);
|
|
528
|
-
export {
|
|
529
|
-
g as P,
|
|
530
|
-
l as a
|
|
531
|
-
};
|