q2-tecton-elements 1.52.0 → 1.52.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/click-elsewhere_2.cjs.entry.js +2 -13
- package/dist/cjs/click-elsewhere_2.cjs.entry.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/q2-action-group.cjs.entry.js +38 -14
- package/dist/cjs/q2-action-group.cjs.entry.js.map +1 -1
- package/dist/cjs/q2-calendar.cjs.entry.js +18 -15
- package/dist/cjs/q2-calendar.cjs.entry.js.map +1 -1
- package/dist/cjs/q2-dropdown.cjs.entry.js +3 -5
- package/dist/cjs/q2-dropdown.cjs.entry.js.map +1 -1
- package/dist/cjs/q2-pill.cjs.entry.js +1 -1
- package/dist/cjs/q2-pill.cjs.entry.js.map +1 -1
- package/dist/cjs/q2-select.cjs.entry.js +3 -4
- package/dist/cjs/q2-select.cjs.entry.js.map +1 -1
- package/dist/cjs/q2-tag.cjs.entry.js +1 -2
- package/dist/cjs/q2-tag.cjs.entry.js.map +1 -1
- package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
- package/dist/collection/components/q2-action-group/q2-action-group.js +41 -14
- package/dist/collection/components/q2-action-group/q2-action-group.js.map +1 -1
- package/dist/collection/components/q2-action-group/test/q2-action-group.spec.js +97 -65
- package/dist/collection/components/q2-action-group/test/q2-action-group.spec.js.map +1 -1
- package/dist/collection/components/q2-calendar/q2-calendar.js +22 -17
- package/dist/collection/components/q2-calendar/q2-calendar.js.map +1 -1
- package/dist/collection/components/q2-calendar/test/q2-calendar-test.e2e.js +0 -27
- package/dist/collection/components/q2-calendar/test/q2-calendar-test.e2e.js.map +1 -1
- package/dist/collection/components/q2-dropdown/q2-dropdown.js +11 -12
- package/dist/collection/components/q2-dropdown/q2-dropdown.js.map +1 -1
- package/dist/collection/components/q2-dropdown/test/q2-dropdown-test.e2e.js +24 -88
- package/dist/collection/components/q2-dropdown/test/q2-dropdown-test.e2e.js.map +1 -1
- package/dist/collection/components/q2-pill/q2-pill.js +5 -2
- package/dist/collection/components/q2-pill/q2-pill.js.map +1 -1
- package/dist/collection/components/q2-pill/test/q2-pill-test.e2e.js +0 -49
- package/dist/collection/components/q2-pill/test/q2-pill-test.e2e.js.map +1 -1
- package/dist/collection/components/q2-popover/q2-popover.js +3 -16
- package/dist/collection/components/q2-popover/q2-popover.js.map +1 -1
- package/dist/collection/components/q2-select/q2-select.js +3 -5
- package/dist/collection/components/q2-select/q2-select.js.map +1 -1
- package/dist/collection/components/q2-select/test/q2-select-test.e2e.js.map +1 -1
- package/dist/collection/components/q2-tag/q2-tag.js +5 -4
- package/dist/collection/components/q2-tag/q2-tag.js.map +1 -1
- package/dist/collection/components/q2-tag/test/q2-tag-test.e2e.js +0 -49
- package/dist/collection/components/q2-tag/test/q2-tag-test.e2e.js.map +1 -1
- package/dist/components/q2-action-group.js +40 -14
- package/dist/components/q2-action-group.js.map +1 -1
- package/dist/components/q2-calendar.js +18 -16
- package/dist/components/q2-calendar.js.map +1 -1
- package/dist/components/q2-dropdown.js +3 -6
- package/dist/components/q2-dropdown.js.map +1 -1
- package/dist/components/q2-pill.js +1 -1
- package/dist/components/q2-pill.js.map +1 -1
- package/dist/components/q2-popover2.js +3 -15
- package/dist/components/q2-popover2.js.map +1 -1
- package/dist/components/q2-select2.js +3 -5
- package/dist/components/q2-select2.js.map +1 -1
- package/dist/components/q2-tag.js +1 -3
- package/dist/components/q2-tag.js.map +1 -1
- package/dist/esm/click-elsewhere_2.entry.js +2 -13
- package/dist/esm/click-elsewhere_2.entry.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/q2-action-group.entry.js +38 -14
- package/dist/esm/q2-action-group.entry.js.map +1 -1
- package/dist/esm/q2-calendar.entry.js +18 -15
- package/dist/esm/q2-calendar.entry.js.map +1 -1
- package/dist/esm/q2-dropdown.entry.js +3 -5
- package/dist/esm/q2-dropdown.entry.js.map +1 -1
- package/dist/esm/q2-pill.entry.js +1 -1
- package/dist/esm/q2-pill.entry.js.map +1 -1
- package/dist/esm/q2-select.entry.js +3 -4
- package/dist/esm/q2-select.entry.js.map +1 -1
- package/dist/esm/q2-tag.entry.js +1 -2
- package/dist/esm/q2-tag.entry.js.map +1 -1
- package/dist/esm/q2-tecton-elements.js +1 -1
- package/dist/q2-tecton-elements/click-elsewhere_2.entry.js +21 -33
- package/dist/q2-tecton-elements/click-elsewhere_2.entry.js.map +1 -1
- package/dist/q2-tecton-elements/q2-action-group.entry.js +58 -32
- package/dist/q2-tecton-elements/q2-action-group.entry.js.map +1 -1
- package/dist/q2-tecton-elements/q2-calendar.entry.js +259 -256
- package/dist/q2-tecton-elements/q2-calendar.entry.js.map +1 -1
- package/dist/q2-tecton-elements/q2-dropdown.entry.js +17 -21
- package/dist/q2-tecton-elements/q2-dropdown.entry.js.map +1 -1
- package/dist/q2-tecton-elements/q2-pill.entry.js +13 -13
- package/dist/q2-tecton-elements/q2-pill.entry.js.map +1 -1
- package/dist/q2-tecton-elements/q2-select.entry.js +6 -7
- package/dist/q2-tecton-elements/q2-select.entry.js.map +1 -1
- package/dist/q2-tecton-elements/q2-tag.entry.js +12 -13
- package/dist/q2-tecton-elements/q2-tag.entry.js.map +1 -1
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js.map +1 -1
- package/dist/types/components/q2-action-group/q2-action-group.d.ts +4 -0
- package/dist/types/components/q2-calendar/q2-calendar.d.ts +10 -5
- package/dist/types/components/q2-dropdown/q2-dropdown.d.ts +11 -4
- package/dist/types/components/q2-pill/q2-pill.d.ts +5 -1
- package/dist/types/components/q2-popover/q2-popover.d.ts +0 -1
- package/dist/types/components/q2-select/q2-select.d.ts +1 -1
- package/dist/types/components/q2-tag/q2-tag.d.ts +6 -2
- package/dist/types/components.d.ts +10 -0
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as e, c as t, h as
|
|
1
|
+
import { r as e, c as t, h as i, g as a } from "./index-7a5365e2.js";
|
|
2
2
|
|
|
3
3
|
import { d as n } from "./index-3184c760.js";
|
|
4
4
|
|
|
@@ -17,7 +17,7 @@ let h;
|
|
|
17
17
|
function formatDateShort(e) {
|
|
18
18
|
const t = new Date(e);
|
|
19
19
|
if (!n.isValid(t)) return;
|
|
20
|
-
const
|
|
20
|
+
const i = t.toISOString();
|
|
21
21
|
if (!h) {
|
|
22
22
|
h = new Intl.DateTimeFormat("en-US", {
|
|
23
23
|
month: "2-digit",
|
|
@@ -26,7 +26,7 @@ function formatDateShort(e) {
|
|
|
26
26
|
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
|
-
return h.format(new Date(
|
|
29
|
+
return h.format(new Date(i));
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
let u;
|
|
@@ -73,44 +73,44 @@ function stringToDate(e) {
|
|
|
73
73
|
} else if (!e || !n.isValid(new Date(e))) {
|
|
74
74
|
return undefined;
|
|
75
75
|
}
|
|
76
|
-
let
|
|
77
|
-
const
|
|
76
|
+
let i;
|
|
77
|
+
const a = e.split(/[\/\-]/).map((e => e.padStart(2, "0")));
|
|
78
78
|
const s = t && e.length >= 24 && e[10] === "T";
|
|
79
|
-
const r =
|
|
80
|
-
const o =
|
|
79
|
+
const r = a.length === 3;
|
|
80
|
+
const o = a.length < 3;
|
|
81
81
|
if (s) {
|
|
82
82
|
e = e.split("T")[0];
|
|
83
|
-
|
|
83
|
+
i = new Date(e);
|
|
84
84
|
} else if (r) {
|
|
85
|
-
const t = e.includes("/") &&
|
|
85
|
+
const t = e.includes("/") && a[2].length === 4;
|
|
86
86
|
// Reorder mm/dd/yyyy dates for ISO formatting
|
|
87
87
|
// [mm, dd, yyyy] -> [yyyy, mm, dd]
|
|
88
|
-
if (t)
|
|
89
|
-
|
|
88
|
+
if (t) a.unshift(a.pop());
|
|
89
|
+
i = new Date(Date.UTC(parseInt(a[0]), parseInt(a[1]) - 1, parseInt(a[2])));
|
|
90
90
|
} else if (o) {
|
|
91
91
|
const e = new Date;
|
|
92
92
|
let t;
|
|
93
93
|
let n;
|
|
94
94
|
let s;
|
|
95
|
-
switch (
|
|
95
|
+
switch (a.length) {
|
|
96
96
|
case 1:
|
|
97
97
|
t = e.getFullYear();
|
|
98
|
-
n =
|
|
98
|
+
n = a[0];
|
|
99
99
|
s = "01";
|
|
100
100
|
break;
|
|
101
101
|
|
|
102
102
|
case 2:
|
|
103
103
|
t = e.getFullYear();
|
|
104
|
-
n =
|
|
105
|
-
s =
|
|
104
|
+
n = a[0];
|
|
105
|
+
s = a[1];
|
|
106
106
|
break;
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
i = new Date(`${t}-${n}-${s}`);
|
|
109
109
|
}
|
|
110
|
-
if (!n.isValid(
|
|
110
|
+
if (!n.isValid(i)) return undefined;
|
|
111
111
|
// result = setHours(result, 0);
|
|
112
|
-
|
|
113
|
-
return n.isValid(
|
|
112
|
+
i = removeTimezoneOffset(i);
|
|
113
|
+
return n.isValid(i) ? i : undefined;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
function removeTimezoneOffset(e) {
|
|
@@ -133,8 +133,8 @@ function setupMonthYear(e = new Date) {
|
|
|
133
133
|
};
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
-
function validateInput(e = "", t = [],
|
|
137
|
-
|
|
136
|
+
function validateInput(e = "", t = [], i = [], // white list
|
|
137
|
+
a = [], // black list
|
|
138
138
|
r, o, d = "mm/dd/yyyy", l) {
|
|
139
139
|
let c = true;
|
|
140
140
|
let h = false;
|
|
@@ -164,8 +164,8 @@ r, o, d = "mm/dd/yyyy", l) {
|
|
|
164
164
|
h = t.includes(v.getDay());
|
|
165
165
|
const l = formatDateISO(v);
|
|
166
166
|
if (h) {
|
|
167
|
-
const e =
|
|
168
|
-
const t =
|
|
167
|
+
const e = i.length && !i.includes(l);
|
|
168
|
+
const t = a.length && a.includes(l);
|
|
169
169
|
const n = r && r > l;
|
|
170
170
|
const s = o && o < l;
|
|
171
171
|
if (e || t || n || s) {
|
|
@@ -194,32 +194,32 @@ r, o, d = "mm/dd/yyyy", l) {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
function buildInputDate(e, t) {
|
|
197
|
-
const
|
|
197
|
+
const i = new Date;
|
|
198
198
|
// eslint-disable-next-line prefer-const
|
|
199
|
-
let [
|
|
200
|
-
if (
|
|
199
|
+
let [a, n, s] = e.split("/");
|
|
200
|
+
if (a === "0") a = "01";
|
|
201
201
|
if (n === "0") n = "01";
|
|
202
202
|
if (e.length === 10) {
|
|
203
203
|
return new Date(e);
|
|
204
|
-
} else if (
|
|
204
|
+
} else if (a && n && Number(n) > 0) {
|
|
205
205
|
const e = Number(n) < 10 ? `0${Number(n)}` : n;
|
|
206
|
-
const
|
|
207
|
-
return new Date(`${
|
|
208
|
-
} else if (
|
|
209
|
-
return new Date(`${
|
|
206
|
+
const i = !s || s.length < 4 ? assumeYear(a, n, t) : s;
|
|
207
|
+
return new Date(`${a}/${e}/${i}`);
|
|
208
|
+
} else if (a) {
|
|
209
|
+
return new Date(`${a}/01/${i.getFullYear()}`);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
function assumeYear(e, t,
|
|
214
|
-
const
|
|
213
|
+
function assumeYear(e, t, i) {
|
|
214
|
+
const a = `${e}/${t}`;
|
|
215
215
|
const n = new Date;
|
|
216
216
|
const s = n.getMonth() < 9 ? `0${n.getMonth() + 1}` : `${n.getMonth() + 1}`;
|
|
217
217
|
const r = n.getDate() < 10 ? `0${n.getDate()}` : `${n.getDate()}`;
|
|
218
218
|
const o = `${s}/${r}/${n.getFullYear()}`;
|
|
219
219
|
let d = n.getFullYear();
|
|
220
|
-
if (
|
|
220
|
+
if (i === "future" && o.slice(0, 5) > a) {
|
|
221
221
|
d = n.getFullYear() + 1;
|
|
222
|
-
} else if (
|
|
222
|
+
} else if (i === "past" && o.slice(0, 5) < a) {
|
|
223
223
|
d = n.getFullYear() - 1;
|
|
224
224
|
}
|
|
225
225
|
return d.toString();
|
|
@@ -261,18 +261,18 @@ function getMonths() {
|
|
|
261
261
|
}
|
|
262
262
|
|
|
263
263
|
function generateDatesFromMonthYear(e, t) {
|
|
264
|
-
const
|
|
265
|
-
return [ ...Array(
|
|
266
|
-
|
|
267
|
-
return
|
|
264
|
+
const i = n.getDaysInMonth(new Date(t, e));
|
|
265
|
+
return [ ...Array(i).keys() ].reduce(((i, a) => {
|
|
266
|
+
i.push(new Date(t, e, a + 1));
|
|
267
|
+
return i;
|
|
268
268
|
}), []);
|
|
269
269
|
}
|
|
270
270
|
|
|
271
271
|
function getValidDaysOfWeek(e = 127) {
|
|
272
272
|
/* tslint:disable:no-bitwise */
|
|
273
273
|
const t = e & 1;
|
|
274
|
-
const
|
|
275
|
-
const
|
|
274
|
+
const i = e & 2;
|
|
275
|
+
const a = e & 4;
|
|
276
276
|
const n = e & 8;
|
|
277
277
|
const s = e & 16;
|
|
278
278
|
const r = e & 32;
|
|
@@ -280,8 +280,8 @@ function getValidDaysOfWeek(e = 127) {
|
|
|
280
280
|
/* tslint:enable:no-bitwise */ const d = [];
|
|
281
281
|
if (e <= 0) return d;
|
|
282
282
|
if (t) d.push(0);
|
|
283
|
-
if (
|
|
284
|
-
if (
|
|
283
|
+
if (i) d.push(1);
|
|
284
|
+
if (a) d.push(2);
|
|
285
285
|
if (n) d.push(3);
|
|
286
286
|
if (s) d.push(4);
|
|
287
287
|
if (r) d.push(5);
|
|
@@ -301,22 +301,22 @@ function validateAgainstWhitelist(e, t) {
|
|
|
301
301
|
return e.some((e => n.isSameDay(e, t)));
|
|
302
302
|
}
|
|
303
303
|
|
|
304
|
-
function buildDates(e, t,
|
|
304
|
+
function buildDates(e, t, i, a, n, s, r) {
|
|
305
305
|
const o = [ baseValidation.bind(null, s, new Date) ];
|
|
306
306
|
if (t === null || t === void 0 ? void 0 : t.length) {
|
|
307
307
|
o.push(validateAgainstWhitelist.bind(null, t));
|
|
308
308
|
} else {
|
|
309
309
|
o.push(validateAgainstChecksum.bind(null, e));
|
|
310
310
|
}
|
|
311
|
-
o.push(validateAgainstBlacklist.bind(null,
|
|
312
|
-
return generateDateList(
|
|
311
|
+
o.push(validateAgainstBlacklist.bind(null, i));
|
|
312
|
+
return generateDateList(a, n, s, o, r);
|
|
313
313
|
}
|
|
314
314
|
|
|
315
|
-
function generateDateList({monthIndex: e, selectedYear: t},
|
|
315
|
+
function generateDateList({monthIndex: e, selectedYear: t}, i, a, s, r) {
|
|
316
316
|
const o = !n.isValid(new Date(r));
|
|
317
317
|
const d = generateDatesFromMonthYear(e, t).map(((e, t) => {
|
|
318
318
|
const n = s.some((t => !t(e)));
|
|
319
|
-
const r = getDayState(e,
|
|
319
|
+
const r = getDayState(e, a, i);
|
|
320
320
|
const d = generateClassesForCalDay(Object.assign(Object.assign({}, r), {
|
|
321
321
|
isInvalid: n,
|
|
322
322
|
isIncompleteDate: o
|
|
@@ -335,33 +335,33 @@ function generateDateList({monthIndex: e, selectedYear: t}, a, i, s, r) {
|
|
|
335
335
|
return [ ...l, ...d, ...c ];
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
-
function baseValidation(e, t,
|
|
339
|
-
const
|
|
340
|
-
const s = n.isBefore(e === null || e === void 0 ? void 0 : e.endDate,
|
|
341
|
-
const r = n.isSameDay(t,
|
|
342
|
-
return !(
|
|
338
|
+
function baseValidation(e, t, i) {
|
|
339
|
+
const a = n.isAfter(e === null || e === void 0 ? void 0 : e.startDate, i);
|
|
340
|
+
const s = n.isBefore(e === null || e === void 0 ? void 0 : e.endDate, i);
|
|
341
|
+
const r = n.isSameDay(t, i) && n.isAfter(t, e === null || e === void 0 ? void 0 : e.cutOffTime);
|
|
342
|
+
return !(a || r || s);
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
function getDayState(e, t,
|
|
346
|
-
if (!
|
|
347
|
-
const
|
|
345
|
+
function getDayState(e, t, i) {
|
|
346
|
+
if (!i) i = new Date;
|
|
347
|
+
const a = i && n.isSameDay(i, e);
|
|
348
348
|
const s = n.isSameDay(e, new Date);
|
|
349
349
|
const r = n.isSameDay(e, t === null || t === void 0 ? void 0 : t.startDate);
|
|
350
350
|
const o = n.isSameDay(e, t === null || t === void 0 ? void 0 : t.endDate);
|
|
351
351
|
return {
|
|
352
|
-
isSelected:
|
|
352
|
+
isSelected: a,
|
|
353
353
|
isToday: s,
|
|
354
354
|
isStartDate: r,
|
|
355
355
|
isEndDate: o
|
|
356
356
|
};
|
|
357
357
|
}
|
|
358
358
|
|
|
359
|
-
function generateClassesForCalDay({isInvalid: e, isSelected: t, isEndDate:
|
|
359
|
+
function generateClassesForCalDay({isInvalid: e, isSelected: t, isEndDate: i, isStartDate: a, isToday: n, isIncompleteDate: s}) {
|
|
360
360
|
const r = [];
|
|
361
361
|
if (!e) r.push("is-valid");
|
|
362
362
|
if (t) r.push("is-selected");
|
|
363
|
-
if (
|
|
364
|
-
if (
|
|
363
|
+
if (i) r.push("is-end-date");
|
|
364
|
+
if (a) r.push("is-start-date");
|
|
365
365
|
if (n) r.push("is-today");
|
|
366
366
|
if (t && e && !s) r.push("is-unavailable");
|
|
367
367
|
return r.join(" ");
|
|
@@ -399,8 +399,8 @@ const p = "*{box-sizing:border-box}*:active{outline:none}*:focus{outline:none;bo
|
|
|
399
399
|
const m = p;
|
|
400
400
|
|
|
401
401
|
const y = class {
|
|
402
|
-
constructor(
|
|
403
|
-
e(this,
|
|
402
|
+
constructor(i) {
|
|
403
|
+
e(this, i);
|
|
404
404
|
this.change = t(this, "change", 7);
|
|
405
405
|
this.error = t(this, "error", 7);
|
|
406
406
|
this.success = t(this, "success", 7);
|
|
@@ -440,9 +440,9 @@ const y = class {
|
|
|
440
440
|
}
|
|
441
441
|
};
|
|
442
442
|
this.onDateKeydown = e => {
|
|
443
|
-
const {monthIndex: t, selectedYear:
|
|
444
|
-
const
|
|
445
|
-
const s = this.generateDateFromDay(
|
|
443
|
+
const {monthIndex: t, selectedYear: i} = this.selectedMonthYear;
|
|
444
|
+
const a = parseInt(e.target.dataset.day);
|
|
445
|
+
const s = this.generateDateFromDay(a);
|
|
446
446
|
switch (e.key) {
|
|
447
447
|
case "ArrowUp":
|
|
448
448
|
e.preventDefault();
|
|
@@ -466,12 +466,12 @@ const y = class {
|
|
|
466
466
|
|
|
467
467
|
case "PageUp":
|
|
468
468
|
e.preventDefault();
|
|
469
|
-
if (e.shiftKey) this.goToMonthYear(t,
|
|
469
|
+
if (e.shiftKey) this.goToMonthYear(t, i - 1); else this.goToMonthYear(t - 1, i);
|
|
470
470
|
break;
|
|
471
471
|
|
|
472
472
|
case "PageDown":
|
|
473
473
|
e.preventDefault();
|
|
474
|
-
if (e.shiftKey) this.goToMonthYear(t,
|
|
474
|
+
if (e.shiftKey) this.goToMonthYear(t, i + 1); else this.goToMonthYear(t + 1, i);
|
|
475
475
|
break;
|
|
476
476
|
|
|
477
477
|
case "Home":
|
|
@@ -510,34 +510,34 @@ const y = class {
|
|
|
510
510
|
this.onDateSelection = e => {
|
|
511
511
|
const t = e.target.closest("td:not([aria-hidden])");
|
|
512
512
|
if (!t) return;
|
|
513
|
-
const
|
|
514
|
-
this.selectDate(
|
|
513
|
+
const i = removeTimezoneOffset(new Date(t.dataset.date));
|
|
514
|
+
this.selectDate(i);
|
|
515
515
|
this.closeCalendar();
|
|
516
516
|
};
|
|
517
517
|
this.onHeaderControlKeydown = e => {
|
|
518
518
|
var t;
|
|
519
|
-
const
|
|
520
|
-
const
|
|
521
|
-
if (e.key === "Tab" && !
|
|
519
|
+
const i = this.generateDateFromDay(1);
|
|
520
|
+
const a = (t = this.calendarBody) === null || t === void 0 ? void 0 : t.querySelector('[aria-selected="true"]');
|
|
521
|
+
if (e.key === "Tab" && !a) {
|
|
522
522
|
e.preventDefault();
|
|
523
|
-
this.activateDay(
|
|
523
|
+
this.activateDay(i);
|
|
524
524
|
}
|
|
525
525
|
};
|
|
526
526
|
this.onInputBlur = () => {
|
|
527
527
|
if (!this.isTypeable) return;
|
|
528
528
|
const e = getValidDaysOfWeek(this.daysOfWeekChecksum);
|
|
529
529
|
const {typedValue: t} = this;
|
|
530
|
-
const {isValid:
|
|
531
|
-
if (!t && (
|
|
530
|
+
const {isValid: i, inputDate: a, isAvailable: s} = validateInput(this.typedValue, e, this.validDates, this.invalidDates, this.startDate, this.endDate, this.defaultFormatString, this.assume);
|
|
531
|
+
if (!t && (a === null || a === void 0 ? void 0 : a.toString()) === "Invalid Date") {
|
|
532
532
|
// initial/clear state
|
|
533
533
|
this.setHints({
|
|
534
534
|
isValid: true,
|
|
535
535
|
message: this.defaultHintMessage,
|
|
536
536
|
messageType: "info"
|
|
537
537
|
});
|
|
538
|
-
} else if (
|
|
539
|
-
|
|
540
|
-
this.setCompleteInput(
|
|
538
|
+
} else if (i || t && t.length > 4 && // at least mm/dd provided
|
|
539
|
+
a && n.isValid(a) && s) {
|
|
540
|
+
this.setCompleteInput(a);
|
|
541
541
|
} else if (this.value) {
|
|
542
542
|
this.valueOnBlur = this.value;
|
|
543
543
|
this.value = null;
|
|
@@ -605,19 +605,19 @@ const y = class {
|
|
|
605
605
|
// handle missing zero in month and date
|
|
606
606
|
this.typedValue = handleMissingZeros(this.typedValue);
|
|
607
607
|
const {typedValue: t} = this;
|
|
608
|
-
const
|
|
609
|
-
const {isValid:
|
|
608
|
+
const i = getValidDaysOfWeek(this.daysOfWeekChecksum);
|
|
609
|
+
const {isValid: a, message: s, messageType: r, inputDate: o, isAvailable: d, calendarPosition: l} = validateInput(t, i, this.validDates, this.invalidDates, this.startDate, this.endDate, this.defaultFormatString, this.assume);
|
|
610
610
|
if (l) {
|
|
611
|
-
const [e, t,
|
|
612
|
-
const
|
|
613
|
-
if (n.isValid(
|
|
614
|
-
this.selectedMonthYear = setupMonthYear(
|
|
611
|
+
const [e, t, i] = l;
|
|
612
|
+
const a = new Date(i, e - 1, t);
|
|
613
|
+
if (n.isValid(a)) {
|
|
614
|
+
this.selectedMonthYear = setupMonthYear(a);
|
|
615
615
|
this.dateList = this.buildDateList(this.selectedMonthYear);
|
|
616
616
|
this.validateDate();
|
|
617
617
|
}
|
|
618
618
|
}
|
|
619
619
|
if (e.key === "Enter") {
|
|
620
|
-
if (
|
|
620
|
+
if (a || t && t.length > 4 && // at least mm/dd provided
|
|
621
621
|
o && n.isValid(o) && d) {
|
|
622
622
|
this.setCompleteInput(o);
|
|
623
623
|
} else if (this.value) {
|
|
@@ -635,7 +635,7 @@ const y = class {
|
|
|
635
635
|
}
|
|
636
636
|
} else {
|
|
637
637
|
this.setHints({
|
|
638
|
-
isValid:
|
|
638
|
+
isValid: a,
|
|
639
639
|
message: s,
|
|
640
640
|
messageType: r
|
|
641
641
|
});
|
|
@@ -677,7 +677,6 @@ const y = class {
|
|
|
677
677
|
this.openCalendar();
|
|
678
678
|
}
|
|
679
679
|
};
|
|
680
|
-
this.controlElement = undefined;
|
|
681
680
|
this.dateList = undefined;
|
|
682
681
|
this.hintMessage = this.defaultHintMessage;
|
|
683
682
|
this.hintMessageType = "info";
|
|
@@ -813,14 +812,14 @@ const y = class {
|
|
|
813
812
|
* @testOnly
|
|
814
813
|
*/ async setValue(e) {
|
|
815
814
|
var t;
|
|
816
|
-
const
|
|
817
|
-
if (!n.isValid(
|
|
815
|
+
const i = typeof e === "string" ? stringToDate(e) : e;
|
|
816
|
+
if (!n.isValid(i)) return;
|
|
818
817
|
await this.openPopover();
|
|
819
818
|
await l();
|
|
820
|
-
this.goToMonthYear(
|
|
819
|
+
this.goToMonthYear(i.getMonth(), i.getFullYear());
|
|
821
820
|
await l();
|
|
822
|
-
const
|
|
823
|
-
|
|
821
|
+
const a = (t = this.calendarTable) === null || t === void 0 ? void 0 : t.querySelector(`td[data-date="${formatDateISO(i)}"]`);
|
|
822
|
+
a === null || a === void 0 ? void 0 : a.click();
|
|
824
823
|
}
|
|
825
824
|
/**
|
|
826
825
|
* Emulates focusing the `<input>`, entering the provided value, and emitting an `input` event.
|
|
@@ -835,13 +834,13 @@ const y = class {
|
|
|
835
834
|
*/ async typeValue(e) {
|
|
836
835
|
if (!this.typeable) return;
|
|
837
836
|
const t = typeof e === "string" ? stringToDate(e) : e;
|
|
838
|
-
const
|
|
837
|
+
const i = formatDateShort(t);
|
|
839
838
|
if (!n.isValid(t)) return;
|
|
840
|
-
const {innerInputField:
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
839
|
+
const {innerInputField: a, controlElement: s} = this;
|
|
840
|
+
a.focus();
|
|
841
|
+
a.dispatchEvent(new FocusEvent("focus"));
|
|
842
|
+
a.value = i;
|
|
843
|
+
a.dispatchEvent(new InputEvent("input"));
|
|
845
844
|
s.dispatchEvent(new KeyboardEvent("keyup"));
|
|
846
845
|
}
|
|
847
846
|
// #endregion
|
|
@@ -891,19 +890,19 @@ const y = class {
|
|
|
891
890
|
return;
|
|
892
891
|
}
|
|
893
892
|
const t = e && typeof e !== "string" && "toDate" in e;
|
|
894
|
-
const
|
|
895
|
-
const
|
|
893
|
+
const i = t ? e.toDate() : stringToDate(e);
|
|
894
|
+
const a = formatDateShort(i);
|
|
896
895
|
if (this.isTypeable) {
|
|
897
|
-
this.typedValue =
|
|
896
|
+
this.typedValue = a;
|
|
898
897
|
} else {
|
|
899
|
-
this.controlElement.value =
|
|
900
|
-
this.selectedMonthYear = setupMonthYear(
|
|
898
|
+
this.controlElement.value = a;
|
|
899
|
+
this.selectedMonthYear = setupMonthYear(i);
|
|
901
900
|
this.dateList = this.buildDateList(this.selectedMonthYear);
|
|
902
901
|
this.validateDate();
|
|
903
902
|
}
|
|
904
903
|
// reset hint when value is cleared
|
|
905
904
|
if (this.invalid) return;
|
|
906
|
-
if (
|
|
905
|
+
if (a) {
|
|
907
906
|
this.setHints({
|
|
908
907
|
isValid: true,
|
|
909
908
|
message: null,
|
|
@@ -936,12 +935,12 @@ const y = class {
|
|
|
936
935
|
return this.placeholder && s(this.placeholder) || "";
|
|
937
936
|
}
|
|
938
937
|
get currentWeeks() {
|
|
939
|
-
const e = this.dateList.reduce(((e, t,
|
|
940
|
-
const
|
|
941
|
-
if (!e[
|
|
942
|
-
e[
|
|
938
|
+
const e = this.dateList.reduce(((e, t, i) => {
|
|
939
|
+
const a = Math.floor(i / 7);
|
|
940
|
+
if (!e[a]) {
|
|
941
|
+
e[a] = [];
|
|
943
942
|
}
|
|
944
|
-
e[
|
|
943
|
+
e[a].push(t);
|
|
945
944
|
return e;
|
|
946
945
|
}), []);
|
|
947
946
|
return e;
|
|
@@ -963,8 +962,8 @@ const y = class {
|
|
|
963
962
|
const t = e && typeof e !== "string" && "toDate" in e;
|
|
964
963
|
if (t) return e.toDate();
|
|
965
964
|
// stringified moment value assigned in html template e.g.) handlebar
|
|
966
|
-
const
|
|
967
|
-
if (
|
|
965
|
+
const i = typeof e === "string" && e.split(" ").length === 6 && /GMT-\d{4}/g.test(e);
|
|
966
|
+
if (i) {
|
|
968
967
|
e = formatDateISO(e);
|
|
969
968
|
}
|
|
970
969
|
return stringToDate(e);
|
|
@@ -974,23 +973,23 @@ const y = class {
|
|
|
974
973
|
return this.typeable ? s("tecton.element.calendar.hint.format") + ": " + this.defaultFormatString : s("tecton.element.calendar.hint.select");
|
|
975
974
|
}
|
|
976
975
|
get errorList() {
|
|
977
|
-
const {errors: e, internalError: t, invalid:
|
|
978
|
-
let
|
|
976
|
+
const {errors: e, internalError: t, invalid: i} = this;
|
|
977
|
+
let a = [];
|
|
979
978
|
if (t) {
|
|
980
|
-
|
|
979
|
+
a = [ t ];
|
|
981
980
|
}
|
|
982
981
|
if (Array.isArray(e) && e.length) {
|
|
983
|
-
|
|
984
|
-
} else if (!t &&
|
|
982
|
+
a = e.filter((e => !!e)).map((e => s(e))).concat(a);
|
|
983
|
+
} else if (!t && i) {
|
|
985
984
|
return [ "tecton.element.calendar.invalid" ];
|
|
986
985
|
}
|
|
987
|
-
return
|
|
986
|
+
return a;
|
|
988
987
|
}
|
|
989
988
|
get formattedValue() {
|
|
990
|
-
const {typedValue: e, dateValue: t, displayFormat:
|
|
991
|
-
if (
|
|
989
|
+
const {typedValue: e, dateValue: t, displayFormat: i, isTypeable: a} = this;
|
|
990
|
+
if (a) return e;
|
|
992
991
|
if (t === undefined) return "";
|
|
993
|
-
if (
|
|
992
|
+
if (i) return n.format(t, convertMomentFormat(i));
|
|
994
993
|
return new Intl.DateTimeFormat("en-US", {
|
|
995
994
|
year: "numeric",
|
|
996
995
|
month: "2-digit",
|
|
@@ -999,11 +998,15 @@ const y = class {
|
|
|
999
998
|
}).format(t);
|
|
1000
999
|
}
|
|
1001
1000
|
get hintList() {
|
|
1002
|
-
const {hints: e, hintMessageType: t, hintMessage:
|
|
1001
|
+
const {hints: e, hintMessageType: t, hintMessage: i} = this;
|
|
1003
1002
|
if (Array.isArray(e) && e.length) return e.filter((e => !!e)).map((e => s(e)));
|
|
1004
|
-
if (t === "info" &&
|
|
1003
|
+
if (t === "info" && i) return [ i ];
|
|
1005
1004
|
return [];
|
|
1006
1005
|
}
|
|
1006
|
+
get innerInputContainer() {
|
|
1007
|
+
var e, t;
|
|
1008
|
+
return (t = (e = this.controlElement) === null || e === void 0 ? void 0 : e.shadowRoot) === null || t === void 0 ? void 0 : t.querySelector(".input-container");
|
|
1009
|
+
}
|
|
1007
1010
|
get innerInputField() {
|
|
1008
1011
|
var e, t;
|
|
1009
1012
|
return (t = (e = this.controlElement) === null || e === void 0 ? void 0 : e.shadowRoot) === null || t === void 0 ? void 0 : t.querySelector(".input-field");
|
|
@@ -1028,30 +1031,30 @@ const y = class {
|
|
|
1028
1031
|
}
|
|
1029
1032
|
buildDateList(e) {
|
|
1030
1033
|
const t = stringArrayToDate(this.invalidDates);
|
|
1031
|
-
const
|
|
1032
|
-
const
|
|
1033
|
-
return buildDates(
|
|
1034
|
+
const i = getValidDaysOfWeek(this.daysOfWeekChecksum);
|
|
1035
|
+
const a = stringArrayToDate(this.validDates);
|
|
1036
|
+
return buildDates(i, a, t, e, this.dateValue, this.dateValidators, this.typedValue);
|
|
1034
1037
|
}
|
|
1035
1038
|
calendarDays() {
|
|
1036
|
-
return
|
|
1039
|
+
return i("table", {
|
|
1037
1040
|
role: "grid",
|
|
1038
1041
|
"aria-labelledby": "table-label",
|
|
1039
1042
|
ref: e => this.calendarTable = e
|
|
1040
|
-
},
|
|
1043
|
+
}, i("thead", null, i("tr", null, [ ...Array(7).keys() ].map((e => i("th", {
|
|
1041
1044
|
scope: "col",
|
|
1042
1045
|
"aria-label": this.dayStrings[e]
|
|
1043
|
-
}, this.dayAbbrStrings[e]))))),
|
|
1046
|
+
}, this.dayAbbrStrings[e]))))), i("tbody", {
|
|
1044
1047
|
onClick: this.onDateSelection,
|
|
1045
1048
|
onKeyDown: this.onDateKeydown,
|
|
1046
1049
|
ref: e => this.calendarBody = e,
|
|
1047
1050
|
"test-id": "calendarTableBody"
|
|
1048
|
-
}, this.currentWeeks.map((e =>
|
|
1051
|
+
}, this.currentWeeks.map((e => i("tr", null, e.map((e => {
|
|
1049
1052
|
var t;
|
|
1050
|
-
let
|
|
1051
|
-
if (e.isToday)
|
|
1052
|
-
|
|
1053
|
-
if (e.isSelected)
|
|
1054
|
-
return
|
|
1053
|
+
let a = "";
|
|
1054
|
+
if (e.isToday) a = `${s("tecton.element.calendar.today")}, `;
|
|
1055
|
+
a += formatDateFull(e.date);
|
|
1056
|
+
if (e.isSelected) a += ` (${s("tecton.element.calendar.selected")})`;
|
|
1057
|
+
return i("td", {
|
|
1055
1058
|
class: e.classList,
|
|
1056
1059
|
"aria-hidden": e.isEmpty ? "true" : undefined,
|
|
1057
1060
|
tabindex: e.isSelected ? 0 : -1,
|
|
@@ -1060,148 +1063,55 @@ const y = class {
|
|
|
1060
1063
|
"aria-disabled": e.isValid ? undefined : "true",
|
|
1061
1064
|
"data-day": e.integer || undefined,
|
|
1062
1065
|
"data-date": e.date ? formatDateISO(e.date) : undefined
|
|
1063
|
-
}, (e === null || e === void 0 ? void 0 : e.isToday) &&
|
|
1066
|
+
}, (e === null || e === void 0 ? void 0 : e.isToday) && i("div", {
|
|
1064
1067
|
class: "today-decorator",
|
|
1065
1068
|
"aria-hidden": "true"
|
|
1066
|
-
}, s("tecton.element.calendar.today")),
|
|
1067
|
-
"aria-label":
|
|
1069
|
+
}, s("tecton.element.calendar.today")), i("div", {
|
|
1070
|
+
"aria-label": a
|
|
1068
1071
|
}, (t = e === null || e === void 0 ? void 0 : e.integer) !== null && t !== void 0 ? t : ""));
|
|
1069
1072
|
})))))));
|
|
1070
1073
|
}
|
|
1071
|
-
checkActiveCellForBlankness() {
|
|
1072
|
-
const e = this.hostElement.shadowRoot.activeElement;
|
|
1073
|
-
if (!e || e.tagName !== "TD" || !e.hasAttribute("aria-hidden")) return;
|
|
1074
|
-
const {calendarBody: t} = this;
|
|
1075
|
-
const a = Array.from(t.querySelectorAll("td"));
|
|
1076
|
-
const i = Array.from(a).indexOf(e);
|
|
1077
|
-
const n = i < 15 ? 1 : a.filter((e => !e.hasAttribute("aria-hidden"))).length;
|
|
1078
|
-
this.focusDay(this.generateDateFromDay(n));
|
|
1079
|
-
}
|
|
1080
|
-
async focusDay(e) {
|
|
1081
|
-
var t;
|
|
1082
|
-
if (!e) return;
|
|
1083
|
-
await l();
|
|
1084
|
-
(t = this.calendarBody.querySelector(`td[data-day="${e.getDate()}"]`)) === null || t === void 0 ? void 0 : t.focus();
|
|
1085
|
-
}
|
|
1086
|
-
focusInput() {
|
|
1087
|
-
var e;
|
|
1088
|
-
(e = this.controlElement) === null || e === void 0 ? void 0 : e.focus();
|
|
1089
|
-
}
|
|
1090
|
-
generateDateFromDay(e) {
|
|
1091
|
-
const {monthIndex: t, selectedYear: a} = this.selectedMonthYear;
|
|
1092
|
-
return new Date(a, t, e);
|
|
1093
|
-
}
|
|
1094
|
-
setCompleteInput(e) {
|
|
1095
|
-
const t = formatDateShort(e);
|
|
1096
|
-
this.change.emit({
|
|
1097
|
-
value: formatDateISO(e)
|
|
1098
|
-
});
|
|
1099
|
-
this.typedValue = t;
|
|
1100
|
-
this.internalError = null;
|
|
1101
|
-
this.setHints({
|
|
1102
|
-
isValid: true,
|
|
1103
|
-
message: null,
|
|
1104
|
-
messageType: null
|
|
1105
|
-
});
|
|
1106
|
-
}
|
|
1107
|
-
setHints({isValid: e, message: t, messageType: a}) {
|
|
1108
|
-
var i;
|
|
1109
|
-
if (t === this.hintMessage) return (i = this.hintMessageElement) === null || i === void 0 ? void 0 : i.present();
|
|
1110
|
-
this.invalid = !e;
|
|
1111
|
-
this.hintMessage = t;
|
|
1112
|
-
this.hintMessageType = a;
|
|
1113
|
-
if (a === "error" && t) {
|
|
1114
|
-
this.internalError = t;
|
|
1115
|
-
this.error.emit({
|
|
1116
|
-
errors: [ {
|
|
1117
|
-
message: t,
|
|
1118
|
-
errorCode: "generalInvalid"
|
|
1119
|
-
} ]
|
|
1120
|
-
});
|
|
1121
|
-
}
|
|
1122
|
-
}
|
|
1123
|
-
validateDate() {
|
|
1124
|
-
var e, t, a;
|
|
1125
|
-
try {
|
|
1126
|
-
if (!!this.value) {
|
|
1127
|
-
const {dateValue: i} = this;
|
|
1128
|
-
const n = (e = i === null || i === void 0 ? void 0 : i.getMonth()) !== null && e !== void 0 ? e : undefined;
|
|
1129
|
-
const s = (t = i === null || i === void 0 ? void 0 : i.getFullYear()) !== null && t !== void 0 ? t : undefined;
|
|
1130
|
-
const {monthIndex: r, selectedYear: o} = this.selectedMonthYear;
|
|
1131
|
-
const d = n === r && s === o;
|
|
1132
|
-
let l = [];
|
|
1133
|
-
if (!i) {
|
|
1134
|
-
l = [];
|
|
1135
|
-
} else if (d) {
|
|
1136
|
-
l = this.dateList;
|
|
1137
|
-
} else {
|
|
1138
|
-
l = this.buildDateList({
|
|
1139
|
-
monthIndex: n,
|
|
1140
|
-
selectedYear: s
|
|
1141
|
-
});
|
|
1142
|
-
}
|
|
1143
|
-
const c = (a = i === null || i === void 0 ? void 0 : i.getDate()) !== null && a !== void 0 ? a : undefined;
|
|
1144
|
-
const h = c ? !l.find((({integer: e}) => e === c)).isValid : true;
|
|
1145
|
-
if (h) {
|
|
1146
|
-
this.error.emit({
|
|
1147
|
-
errors: [ {
|
|
1148
|
-
message: `Value passed is invalid: The date ${this.value} is not valid`,
|
|
1149
|
-
errorCode: "generalInvalid"
|
|
1150
|
-
} ]
|
|
1151
|
-
});
|
|
1152
|
-
} else {
|
|
1153
|
-
this.success.emit({
|
|
1154
|
-
value: formatDateISO(i)
|
|
1155
|
-
});
|
|
1156
|
-
}
|
|
1157
|
-
}
|
|
1158
|
-
} catch (e) {
|
|
1159
|
-
console.warn("Invalid moment value ", this.dateValue);
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
// #endregion
|
|
1163
|
-
// #region Render Methods
|
|
1164
1074
|
renderCalendarPopover() {
|
|
1165
1075
|
const {monthIndex: e, selectedYear: t} = this.selectedMonthYear;
|
|
1166
|
-
return
|
|
1076
|
+
return i("div", {
|
|
1167
1077
|
class: "calendar-field-popup",
|
|
1168
1078
|
onKeyUp: this.onPopupKeyup
|
|
1169
|
-
}, this.calendarLabel &&
|
|
1079
|
+
}, this.calendarLabel && i("p", {
|
|
1170
1080
|
class: "calendar-label"
|
|
1171
|
-
}, s(this.calendarLabel)),
|
|
1081
|
+
}, s(this.calendarLabel)), i("div", {
|
|
1172
1082
|
class: "cal-month-heading"
|
|
1173
|
-
},
|
|
1083
|
+
}, i("q2-btn", {
|
|
1174
1084
|
label: s("tecton.element.calendar.previousMonth"),
|
|
1175
1085
|
"hide-label": true,
|
|
1176
1086
|
ref: e => this.btnPrevMonth = e,
|
|
1177
1087
|
class: "cal-nav-btn prev-month",
|
|
1178
1088
|
"test-id": "previousMonthButton",
|
|
1179
1089
|
onClick: () => this.goToMonthYear(e - 1, t)
|
|
1180
|
-
},
|
|
1090
|
+
}, i("q2-icon", {
|
|
1181
1091
|
type: "chevron-left"
|
|
1182
|
-
})),
|
|
1092
|
+
})), i("span", {
|
|
1183
1093
|
class: "cal-month-text"
|
|
1184
|
-
}, this.monthStrings[e]),
|
|
1094
|
+
}, this.monthStrings[e]), i("q2-btn", {
|
|
1185
1095
|
label: s("tecton.element.calendar.nextMonth"),
|
|
1186
1096
|
"hide-label": true,
|
|
1187
1097
|
class: "cal-nav-btn next-month",
|
|
1188
1098
|
ref: e => this.btnNextMonth = e,
|
|
1189
1099
|
"test-id": "nextMonthButton",
|
|
1190
1100
|
onClick: () => this.goToMonthYear(e + 1, t)
|
|
1191
|
-
},
|
|
1101
|
+
}, i("q2-icon", {
|
|
1192
1102
|
type: "chevron-right"
|
|
1193
|
-
})),
|
|
1103
|
+
})), i("q2-btn", {
|
|
1194
1104
|
label: s("tecton.element.calendar.previousYear"),
|
|
1195
1105
|
"hide-label": true,
|
|
1196
1106
|
class: "cal-nav-btn prev-year",
|
|
1197
1107
|
ref: e => this.btnPrevYear = e,
|
|
1198
1108
|
"test-id": "previousYearButton",
|
|
1199
1109
|
onClick: () => this.goToMonthYear(e, t - 1)
|
|
1200
|
-
},
|
|
1110
|
+
}, i("q2-icon", {
|
|
1201
1111
|
type: "chevron-left"
|
|
1202
|
-
})),
|
|
1112
|
+
})), i("span", {
|
|
1203
1113
|
class: "cal-year-text"
|
|
1204
|
-
}, this.selectedMonthYear.selectedYear),
|
|
1114
|
+
}, this.selectedMonthYear.selectedYear), i("q2-btn", {
|
|
1205
1115
|
label: s("tecton.element.calendar.nextYear"),
|
|
1206
1116
|
"hide-label": true,
|
|
1207
1117
|
class: "cal-nav-btn next-year",
|
|
@@ -1209,22 +1119,45 @@ const y = class {
|
|
|
1209
1119
|
"test-id": "nextYearButton",
|
|
1210
1120
|
onClick: () => this.goToMonthYear(e, t + 1),
|
|
1211
1121
|
onKeyDown: this.onHeaderControlKeydown
|
|
1212
|
-
},
|
|
1122
|
+
}, i("q2-icon", {
|
|
1213
1123
|
type: "chevron-right"
|
|
1214
|
-
}))),
|
|
1124
|
+
}))), i("div", {
|
|
1215
1125
|
class: "sr",
|
|
1216
1126
|
"aria-live": "polite",
|
|
1217
1127
|
id: "table-label"
|
|
1218
|
-
}, `${this.monthStrings[e]} ${t}`), this.calendarDays(), this.disclaimer &&
|
|
1128
|
+
}, `${this.monthStrings[e]} ${t}`), this.calendarDays(), this.disclaimer && i("div", {
|
|
1219
1129
|
class: "calendar-disclaimer"
|
|
1220
|
-
}, s(this.disclaimer)),
|
|
1130
|
+
}, s(this.disclaimer)), i("q2-btn", {
|
|
1221
1131
|
class: "sr refocus-popup",
|
|
1222
1132
|
onFocus: this.onRefocus
|
|
1223
1133
|
}));
|
|
1224
1134
|
}
|
|
1135
|
+
checkActiveCellForBlankness() {
|
|
1136
|
+
const e = this.hostElement.shadowRoot.activeElement;
|
|
1137
|
+
if (!e || e.tagName !== "TD" || !e.hasAttribute("aria-hidden")) return;
|
|
1138
|
+
const {calendarBody: t} = this;
|
|
1139
|
+
const i = Array.from(t.querySelectorAll("td"));
|
|
1140
|
+
const a = Array.from(i).indexOf(e);
|
|
1141
|
+
const n = a < 15 ? 1 : i.filter((e => !e.hasAttribute("aria-hidden"))).length;
|
|
1142
|
+
this.focusDay(this.generateDateFromDay(n));
|
|
1143
|
+
}
|
|
1144
|
+
async focusDay(e) {
|
|
1145
|
+
var t;
|
|
1146
|
+
if (!e) return;
|
|
1147
|
+
await l();
|
|
1148
|
+
(t = this.calendarBody.querySelector(`td[data-day="${e.getDate()}"]`)) === null || t === void 0 ? void 0 : t.focus();
|
|
1149
|
+
}
|
|
1150
|
+
focusInput() {
|
|
1151
|
+
var e;
|
|
1152
|
+
(e = this.controlElement) === null || e === void 0 ? void 0 : e.focus();
|
|
1153
|
+
}
|
|
1154
|
+
generateDateFromDay(e) {
|
|
1155
|
+
const {monthIndex: t, selectedYear: i} = this.selectedMonthYear;
|
|
1156
|
+
return new Date(i, t, e);
|
|
1157
|
+
}
|
|
1225
1158
|
renderHintField() {
|
|
1226
1159
|
if (!this.hintMessage) return;
|
|
1227
|
-
return
|
|
1160
|
+
return i("q2-message", {
|
|
1228
1161
|
class: "calendar-hint sr",
|
|
1229
1162
|
ref: e => this.hintMessageElement = e,
|
|
1230
1163
|
type: this.hintMessageType
|
|
@@ -1232,7 +1165,7 @@ const y = class {
|
|
|
1232
1165
|
}
|
|
1233
1166
|
renderInputField() {
|
|
1234
1167
|
const {isTypeable: e} = this;
|
|
1235
|
-
return
|
|
1168
|
+
return i("q2-input", {
|
|
1236
1169
|
ref: e => this.controlElement = e,
|
|
1237
1170
|
class: "calendar-input-field",
|
|
1238
1171
|
value: this.formattedValue,
|
|
@@ -1260,26 +1193,96 @@ const y = class {
|
|
|
1260
1193
|
"test-id": "inputAndCalendarToggle",
|
|
1261
1194
|
_role: "combobox",
|
|
1262
1195
|
_preventEntry: !e
|
|
1263
|
-
}, e &&
|
|
1196
|
+
}, e && i("q2-btn", {
|
|
1264
1197
|
ref: e => this.btnCalendarToggle = e,
|
|
1265
1198
|
slot: "input-right",
|
|
1266
1199
|
onClick: this.onInputClick,
|
|
1267
1200
|
"test-id": "calendarToggle",
|
|
1268
1201
|
label: "tecton.element.calendar.toggleAriaLabel",
|
|
1269
1202
|
"hide-label": true
|
|
1270
|
-
},
|
|
1203
|
+
}, i("q2-icon", {
|
|
1271
1204
|
type: "calendar"
|
|
1272
1205
|
})));
|
|
1273
1206
|
}
|
|
1207
|
+
setCompleteInput(e) {
|
|
1208
|
+
const t = formatDateShort(e);
|
|
1209
|
+
this.change.emit({
|
|
1210
|
+
value: formatDateISO(e)
|
|
1211
|
+
});
|
|
1212
|
+
this.typedValue = t;
|
|
1213
|
+
this.internalError = null;
|
|
1214
|
+
this.setHints({
|
|
1215
|
+
isValid: true,
|
|
1216
|
+
message: null,
|
|
1217
|
+
messageType: null
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
setHints({isValid: e, message: t, messageType: i}) {
|
|
1221
|
+
var a;
|
|
1222
|
+
if (t === this.hintMessage) return (a = this.hintMessageElement) === null || a === void 0 ? void 0 : a.present();
|
|
1223
|
+
this.invalid = !e;
|
|
1224
|
+
this.hintMessage = t;
|
|
1225
|
+
this.hintMessageType = i;
|
|
1226
|
+
if (i === "error" && t) {
|
|
1227
|
+
this.internalError = t;
|
|
1228
|
+
this.error.emit({
|
|
1229
|
+
errors: [ {
|
|
1230
|
+
message: t,
|
|
1231
|
+
errorCode: "generalInvalid"
|
|
1232
|
+
} ]
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
validateDate() {
|
|
1237
|
+
var e, t, i;
|
|
1238
|
+
try {
|
|
1239
|
+
if (!!this.value) {
|
|
1240
|
+
const {dateValue: a} = this;
|
|
1241
|
+
const n = (e = a === null || a === void 0 ? void 0 : a.getMonth()) !== null && e !== void 0 ? e : undefined;
|
|
1242
|
+
const s = (t = a === null || a === void 0 ? void 0 : a.getFullYear()) !== null && t !== void 0 ? t : undefined;
|
|
1243
|
+
const {monthIndex: r, selectedYear: o} = this.selectedMonthYear;
|
|
1244
|
+
const d = n === r && s === o;
|
|
1245
|
+
let l = [];
|
|
1246
|
+
if (!a) {
|
|
1247
|
+
l = [];
|
|
1248
|
+
} else if (d) {
|
|
1249
|
+
l = this.dateList;
|
|
1250
|
+
} else {
|
|
1251
|
+
l = this.buildDateList({
|
|
1252
|
+
monthIndex: n,
|
|
1253
|
+
selectedYear: s
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
const c = (i = a === null || a === void 0 ? void 0 : a.getDate()) !== null && i !== void 0 ? i : undefined;
|
|
1257
|
+
const h = c ? !l.find((({integer: e}) => e === c)).isValid : true;
|
|
1258
|
+
if (h) {
|
|
1259
|
+
this.error.emit({
|
|
1260
|
+
errors: [ {
|
|
1261
|
+
message: `Value passed is invalid: The date ${this.value} is not valid`,
|
|
1262
|
+
errorCode: "generalInvalid"
|
|
1263
|
+
} ]
|
|
1264
|
+
});
|
|
1265
|
+
} else {
|
|
1266
|
+
this.success.emit({
|
|
1267
|
+
value: formatDateISO(a)
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
}
|
|
1271
|
+
} catch (e) {
|
|
1272
|
+
console.warn("Invalid moment value ", this.dateValue);
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
// #endregion
|
|
1276
|
+
// #region Render Methods
|
|
1274
1277
|
render() {
|
|
1275
|
-
return
|
|
1276
|
-
key: "
|
|
1278
|
+
return i("click-elsewhere", {
|
|
1279
|
+
key: "76bda9101bf99ae49ab8f04be2d5743dc6b110a8",
|
|
1277
1280
|
class: this.open ? "dropdown-open" : undefined,
|
|
1278
1281
|
onChange: this.onClickElsewhere
|
|
1279
|
-
}, this.renderInputField(),
|
|
1280
|
-
key: "
|
|
1282
|
+
}, this.renderInputField(), i("q2-popover", {
|
|
1283
|
+
key: "4e556602957d99a9e48127e647923f3e5719e950",
|
|
1281
1284
|
ref: e => this.popoverElement = e,
|
|
1282
|
-
controlElement: this.
|
|
1285
|
+
controlElement: this.innerInputContainer,
|
|
1283
1286
|
open: this.open,
|
|
1284
1287
|
direction: this.popoverDirection,
|
|
1285
1288
|
minHeight: this.popoverMinHeight,
|
|
@@ -1289,7 +1292,7 @@ const y = class {
|
|
|
1289
1292
|
}, this.renderHintField(), this.renderCalendarPopover()));
|
|
1290
1293
|
}
|
|
1291
1294
|
get hostElement() {
|
|
1292
|
-
return
|
|
1295
|
+
return a(this);
|
|
1293
1296
|
}
|
|
1294
1297
|
static get watchers() {
|
|
1295
1298
|
return {
|