q2-tecton-elements 1.27.1 → 1.28.1
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 +258 -0
- package/dist/cjs/{index-ffd19146.js → index-7a73e106.js} +12 -52
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/q2-action-sheet.cjs.entry.js +1 -1
- package/dist/cjs/q2-avatar.cjs.entry.js +1 -1
- package/dist/cjs/q2-badge_2.cjs.entry.js +1 -1
- package/dist/cjs/q2-btn_2.cjs.entry.js +1 -1
- package/dist/cjs/q2-calendar.cjs.entry.js +128 -83
- package/dist/cjs/q2-card.cjs.entry.js +1 -1
- package/dist/cjs/q2-carousel-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-carousel.cjs.entry.js +1 -1
- package/dist/cjs/q2-chart-area.cjs.entry.js +1 -1
- package/dist/cjs/q2-chart-bar.cjs.entry.js +1 -1
- package/dist/cjs/q2-chart-donut.cjs.entry.js +1 -1
- package/dist/cjs/q2-checkbox-group.cjs.entry.js +1 -1
- package/dist/cjs/q2-checkbox.cjs.entry.js +1 -1
- package/dist/cjs/q2-dropdown-item.cjs.entry.js +1 -1
- package/dist/cjs/q2-dropdown.cjs.entry.js +44 -45
- package/dist/cjs/q2-editable-field.cjs.entry.js +1 -1
- package/dist/cjs/q2-icon.cjs.entry.js +1 -1
- package/dist/cjs/q2-loc.cjs.entry.js +1 -1
- package/dist/cjs/q2-message.cjs.entry.js +1 -1
- package/dist/cjs/q2-month-picker.cjs.entry.js +1 -1
- package/dist/cjs/q2-optgroup_2.cjs.entry.js +1 -1
- package/dist/cjs/{q2-option-list_2.cjs.entry.js → q2-option-list.cjs.entry.js} +3 -167
- package/dist/cjs/q2-pagination.cjs.entry.js +1 -1
- package/dist/cjs/q2-pill.cjs.entry.js +1 -1
- package/dist/cjs/q2-radio-group.cjs.entry.js +1 -1
- package/dist/cjs/q2-radio.cjs.entry.js +1 -1
- package/dist/cjs/q2-section.cjs.entry.js +1 -1
- package/dist/cjs/q2-select.cjs.entry.js +11 -6
- package/dist/cjs/q2-stepper-pane.cjs.entry.js +1 -1
- package/dist/cjs/q2-stepper-vertical.cjs.entry.js +1 -1
- package/dist/cjs/q2-stepper.cjs.entry.js +1 -1
- package/dist/cjs/q2-tab-container.cjs.entry.js +1 -1
- package/dist/cjs/q2-tag.cjs.entry.js +1 -1
- package/dist/cjs/q2-tecton-elements.cjs.js +1 -1
- package/dist/cjs/q2-textarea.cjs.entry.js +1 -1
- package/dist/cjs/q2-tooltip.cjs.entry.js +1 -1
- package/dist/collection/components/q2-avatar/styles.css +3 -7
- package/dist/collection/components/q2-calendar/helpers.js +37 -11
- package/dist/collection/components/q2-calendar/index.js +174 -91
- package/dist/collection/components/q2-calendar/styles.css +5 -68
- package/dist/collection/components/q2-dropdown/index.js +123 -66
- package/dist/collection/components/q2-dropdown/styles.css +3 -89
- package/dist/collection/components/q2-select/index.js +10 -5
- package/dist/collection/utils/index.js +11 -51
- package/dist/components/index11.js +1 -1
- package/dist/components/index15.js +12 -52
- package/dist/components/index3.js +1 -1
- package/dist/components/index7.js +1 -1
- package/dist/components/index8.js +1 -1
- package/dist/components/q2-calendar.js +154 -101
- package/dist/components/q2-card.js +1 -1
- package/dist/components/q2-carousel.js +1 -1
- package/dist/components/q2-checkbox-group.js +1 -1
- package/dist/components/q2-checkbox.js +1 -1
- package/dist/components/q2-dropdown.js +66 -59
- package/dist/components/q2-radio-group.js +1 -1
- package/dist/components/q2-radio.js +1 -1
- package/dist/components/q2-select.js +11 -6
- package/dist/components/q2-stepper-pane.js +1 -1
- package/dist/components/q2-stepper-vertical.js +1 -1
- package/dist/components/q2-stepper.js +1 -1
- package/dist/components/q2-tab-container.js +1 -1
- package/dist/components/q2-textarea.js +1 -1
- package/dist/docs.json +144 -4
- package/dist/esm/click-elsewhere_2.entry.js +253 -0
- package/dist/esm/{index-a0cc60e3.js → index-576f618c.js} +12 -52
- package/dist/esm/loader.js +1 -1
- package/dist/esm/q2-action-sheet.entry.js +1 -1
- package/dist/esm/q2-avatar.entry.js +1 -1
- package/dist/esm/q2-badge_2.entry.js +1 -1
- package/dist/esm/q2-btn_2.entry.js +1 -1
- package/dist/esm/q2-calendar.entry.js +128 -83
- package/dist/esm/q2-card.entry.js +1 -1
- package/dist/esm/q2-carousel-pane.entry.js +1 -1
- package/dist/esm/q2-carousel.entry.js +1 -1
- package/dist/esm/q2-chart-area.entry.js +1 -1
- package/dist/esm/q2-chart-bar.entry.js +1 -1
- package/dist/esm/q2-chart-donut.entry.js +1 -1
- package/dist/esm/q2-checkbox-group.entry.js +1 -1
- package/dist/esm/q2-checkbox.entry.js +1 -1
- package/dist/esm/q2-dropdown-item.entry.js +1 -1
- package/dist/esm/q2-dropdown.entry.js +44 -45
- package/dist/esm/q2-editable-field.entry.js +1 -1
- package/dist/esm/q2-icon.entry.js +1 -1
- package/dist/esm/q2-loc.entry.js +1 -1
- package/dist/esm/q2-message.entry.js +1 -1
- package/dist/esm/q2-month-picker.entry.js +1 -1
- package/dist/esm/q2-optgroup_2.entry.js +1 -1
- package/dist/esm/{q2-option-list_2.entry.js → q2-option-list.entry.js} +4 -167
- package/dist/esm/q2-pagination.entry.js +1 -1
- package/dist/esm/q2-pill.entry.js +1 -1
- package/dist/esm/q2-radio-group.entry.js +1 -1
- package/dist/esm/q2-radio.entry.js +1 -1
- package/dist/esm/q2-section.entry.js +1 -1
- package/dist/esm/q2-select.entry.js +11 -6
- package/dist/esm/q2-stepper-pane.entry.js +1 -1
- package/dist/esm/q2-stepper-vertical.entry.js +1 -1
- package/dist/esm/q2-stepper.entry.js +1 -1
- package/dist/esm/q2-tab-container.entry.js +1 -1
- package/dist/esm/q2-tag.entry.js +1 -1
- package/dist/esm/q2-tecton-elements.js +1 -1
- package/dist/esm/q2-textarea.entry.js +1 -1
- package/dist/esm/q2-tooltip.entry.js +1 -1
- package/dist/q2-tecton-elements/p-0b7003c4.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-0b8943da.entry.js → p-0d92ab4a.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-138db98d.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-a298cbfb.entry.js → p-1b9e07b4.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-bafb5e70.entry.js → p-1e57a843.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-ac6dd5b1.entry.js → p-2423b9a9.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-396fd275.entry.js → p-2bb447c3.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-85e780b2.entry.js → p-3422207a.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-edcf49fd.entry.js → p-39989362.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-3dca7465.entry.js → p-3aad6a45.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-ef657f8f.entry.js → p-4d2b7f2e.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-869e899c.entry.js → p-4ffde81a.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-d06d752f.entry.js → p-55bdd480.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-590adc15.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-949fa312.entry.js → p-5cd51157.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-5e14a790.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-12e65423.entry.js → p-6524d5f3.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-521c9085.entry.js → p-68908be9.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-9367dc29.entry.js → p-6975e5e4.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-6bb3789b.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-5a670d93.entry.js → p-6db208c7.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-78b7ea4e.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-2b8a8981.entry.js → p-7a702d92.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-fb768d19.entry.js → p-7e1a14ea.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-921ea070.js +1 -0
- package/dist/q2-tecton-elements/{p-04b9a7ee.entry.js → p-a63e64f0.entry.js} +1 -1
- package/dist/q2-tecton-elements/p-b9bbfaf7.entry.js +1 -0
- package/dist/q2-tecton-elements/{p-d69cb7d1.entry.js → p-bbd2c530.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-05bdc0aa.entry.js → p-c19e143e.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-256e5161.entry.js → p-c8525f80.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-fcad1609.entry.js → p-c93341d5.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-8545c3cb.entry.js → p-d6824ce5.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-f3e4bb52.entry.js → p-ddfb393a.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-9292bd80.entry.js → p-df3fb1e7.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-fe3625ad.entry.js → p-ed77f0c2.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-25ea01d3.entry.js → p-ed91f837.entry.js} +1 -1
- package/dist/q2-tecton-elements/{p-1d28c600.entry.js → p-fa0e471c.entry.js} +1 -1
- package/dist/q2-tecton-elements/q2-tecton-elements.esm.js +1 -1
- package/dist/test/helpers.js +1 -1
- package/dist/types/components/q2-calendar/helpers.d.ts +1 -0
- package/dist/types/components/q2-calendar/index.d.ts +22 -12
- package/dist/types/components/q2-dropdown/index.d.ts +12 -8
- package/dist/types/components.d.ts +24 -0
- package/dist/types/utils/index.d.ts +4 -9
- package/dist/types/workspace/workspace/{tecton-production_release_1.27.x → tecton-production_release_1.28.x}/packages/q2-tecton-elements/.stencil/test/helpers.d.ts +1 -1
- package/package.json +3 -3
- package/dist/cjs/click-elsewhere.cjs.entry.js +0 -93
- package/dist/esm/click-elsewhere.entry.js +0 -89
- package/dist/q2-tecton-elements/p-2453cd92.js +0 -1
- package/dist/q2-tecton-elements/p-31b655b6.entry.js +0 -1
- package/dist/q2-tecton-elements/p-72374b8e.entry.js +0 -1
- package/dist/q2-tecton-elements/p-8e652d59.entry.js +0 -1
- package/dist/q2-tecton-elements/p-aae8b9fc.entry.js +0 -1
- package/dist/q2-tecton-elements/p-be0d3bfe.entry.js +0 -1
- package/dist/q2-tecton-elements/p-c1d33fd2.entry.js +0 -1
- package/dist/q2-tecton-elements/p-ee1f3114.entry.js +0 -1
|
@@ -1,44 +1,37 @@
|
|
|
1
1
|
import { h, } from '@stencil/core';
|
|
2
2
|
import { addDays, isSameDay, format, isValid as isValidDate } from 'date-fns';
|
|
3
|
-
import { stringToDate, setupMonthYear, getMonths, getDays, getDaysOfWeek, stringArrayToDate, convertMomentFormat, validateInput, handleMissingZeros, formatDateISO, formatDateLong, formatDateShort, removeTimezoneOffset, reorderDateString, } from './helpers';
|
|
3
|
+
import { stringToDate, setupMonthYear, getMonths, getDays, getDaysOfWeek, stringArrayToDate, convertMomentFormat, validateInput, handleMissingZeros, formatDateISO, formatDateLong, formatDateShort, removeTimezoneOffset, reorderDateString, formatDateFull, } from './helpers';
|
|
4
4
|
import { buildDates, getValidDaysOfWeek } from './validation';
|
|
5
|
-
import { handleAriaLabel, loc,
|
|
5
|
+
import { handleAriaLabel, loc, overrideFocus, isEventFromElement, isMobile, handleRenamedProp, waitForNextPaint, } from 'src/utils';
|
|
6
6
|
export class Q2Calendar {
|
|
7
7
|
constructor() {
|
|
8
8
|
this.formatModifier = 'M/D/YYYY'; // To allow missing leading zero, 4/3/2021 => converts into 04/03/2021
|
|
9
9
|
this.defaultFormatString = 'mm/dd/yyyy';
|
|
10
|
-
this.defaultHintMessage = loc('tecton.element.calendar.hint.format') + ': ' + this.defaultFormatString;
|
|
11
10
|
this.scheduledAfterRender = [];
|
|
12
11
|
this.dayAbbrStrings = getDays();
|
|
13
12
|
this.dayStrings = getDaysOfWeek();
|
|
14
13
|
this.monthStrings = getMonths();
|
|
15
14
|
this.closeCalendar = () => {
|
|
16
|
-
if (this.
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
15
|
+
if (!this.open)
|
|
16
|
+
return;
|
|
17
|
+
this.open = false;
|
|
18
|
+
this.focusInput();
|
|
21
19
|
};
|
|
22
20
|
this.openCalendar = () => {
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.scheduledAfterRender.push(this.resizeIframe);
|
|
29
|
-
}
|
|
21
|
+
if (this.readonly || this.open)
|
|
22
|
+
return;
|
|
23
|
+
this.selectedMonthYear = setupMonthYear(this.dateValue);
|
|
24
|
+
this.dateList = this.buildDateList(this.selectedMonthYear);
|
|
25
|
+
this.open = true;
|
|
30
26
|
};
|
|
31
27
|
this.toggleCalendar = () => {
|
|
32
28
|
if (this.readonly)
|
|
33
29
|
return;
|
|
34
|
-
this.
|
|
35
|
-
|
|
36
|
-
if (this.dropdownOpen) {
|
|
37
|
-
this.selectedMonthYear = setupMonthYear(this.dateValue);
|
|
38
|
-
this.dateList = this.buildDateList(this.selectedMonthYear);
|
|
30
|
+
if (this.open) {
|
|
31
|
+
this.closeCalendar();
|
|
39
32
|
}
|
|
40
33
|
else {
|
|
41
|
-
this.
|
|
34
|
+
this.openCalendar();
|
|
42
35
|
}
|
|
43
36
|
};
|
|
44
37
|
this.onClickElsewhere = (event) => {
|
|
@@ -71,10 +64,11 @@ export class Q2Calendar {
|
|
|
71
64
|
if (this.disabled) {
|
|
72
65
|
return;
|
|
73
66
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
switch (event.key) {
|
|
68
|
+
case 'Escape':
|
|
69
|
+
this.onInputBlur();
|
|
70
|
+
this.closeCalendar();
|
|
71
|
+
break;
|
|
78
72
|
}
|
|
79
73
|
if (!this.isTypeable)
|
|
80
74
|
return;
|
|
@@ -148,10 +142,8 @@ export class Q2Calendar {
|
|
|
148
142
|
}
|
|
149
143
|
};
|
|
150
144
|
this.onInputClick = () => {
|
|
151
|
-
if (this.disabled)
|
|
145
|
+
if (this.disabled)
|
|
152
146
|
return;
|
|
153
|
-
}
|
|
154
|
-
setPopProperties(this);
|
|
155
147
|
this.toggleCalendar();
|
|
156
148
|
};
|
|
157
149
|
this.onRefocus = () => {
|
|
@@ -188,13 +180,6 @@ export class Q2Calendar {
|
|
|
188
180
|
return;
|
|
189
181
|
const clickedDate = removeTimezoneOffset(new Date(dateCell.dataset.date));
|
|
190
182
|
this.selectDate(clickedDate);
|
|
191
|
-
if (this.isTypeable) {
|
|
192
|
-
this.setHints({
|
|
193
|
-
isValid: true,
|
|
194
|
-
message: `${loc('tecton.element.calendar.hint.selection')}: ${formatDateLong(clickedDate)}`,
|
|
195
|
-
messageType: 'success',
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
183
|
this.closeCalendar();
|
|
199
184
|
};
|
|
200
185
|
this.onDateKeydown = (event) => {
|
|
@@ -269,6 +254,7 @@ export class Q2Calendar {
|
|
|
269
254
|
this.disabled = undefined;
|
|
270
255
|
this.readonly = undefined;
|
|
271
256
|
this.invalid = undefined;
|
|
257
|
+
this.open = undefined;
|
|
272
258
|
this.typeable = undefined;
|
|
273
259
|
this.clearable = undefined;
|
|
274
260
|
this.placeholder = undefined;
|
|
@@ -280,24 +266,22 @@ export class Q2Calendar {
|
|
|
280
266
|
this.endDate = undefined;
|
|
281
267
|
this.cutoffTime = undefined;
|
|
282
268
|
this.daysOfWeekChecksum = undefined;
|
|
283
|
-
this.popDirection = undefined;
|
|
284
269
|
this.assume = 'current';
|
|
285
270
|
this.errors = undefined;
|
|
286
271
|
this.invalidDates = undefined;
|
|
287
272
|
this.validDates = undefined;
|
|
273
|
+
this.popoverDirection = undefined;
|
|
274
|
+
this.popoverMinHeight = 355;
|
|
275
|
+
this.popDirection = undefined;
|
|
288
276
|
this.onsuccess = undefined;
|
|
289
277
|
this.buttonLabel = undefined;
|
|
290
278
|
this.ariaLabel = undefined;
|
|
291
|
-
this.dropdownOpen = false;
|
|
292
279
|
this.keyboardSelection = false;
|
|
293
280
|
this.typedValue = '';
|
|
294
281
|
this.dateList = undefined;
|
|
295
282
|
this.hintMessage = this.defaultHintMessage;
|
|
296
283
|
this.hintMessageType = 'info';
|
|
297
284
|
}
|
|
298
|
-
resizeIframe() {
|
|
299
|
-
return window.TectonElements && window.TectonElements.resizeIframe && window.TectonElements.resizeIframe();
|
|
300
|
-
}
|
|
301
285
|
connectedCallback() {
|
|
302
286
|
this.selectedMonthYear = setupMonthYear(this.dateValue);
|
|
303
287
|
this.dateList = this.buildDateList(this.selectedMonthYear);
|
|
@@ -307,6 +291,7 @@ export class Q2Calendar {
|
|
|
307
291
|
this.validateDate();
|
|
308
292
|
}
|
|
309
293
|
componentWillLoad() {
|
|
294
|
+
this.popDirectionHandler();
|
|
310
295
|
handleAriaLabel(this);
|
|
311
296
|
}
|
|
312
297
|
componentDidRender() {
|
|
@@ -318,6 +303,20 @@ export class Q2Calendar {
|
|
|
318
303
|
componentDidLoad() {
|
|
319
304
|
overrideFocus(this.hostElement);
|
|
320
305
|
}
|
|
306
|
+
get selectedDate() {
|
|
307
|
+
var _a;
|
|
308
|
+
const selectedCell = (_a = this.calendarBody) === null || _a === void 0 ? void 0 : _a.querySelector('[aria-selected="true"]');
|
|
309
|
+
return selectedCell ? removeTimezoneOffset(new Date(selectedCell.dataset.date)) : null;
|
|
310
|
+
}
|
|
311
|
+
get innerInputField() {
|
|
312
|
+
var _a, _b;
|
|
313
|
+
return (_b = (_a = this.controlElement) === null || _a === void 0 ? void 0 : _a.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('.input-field');
|
|
314
|
+
}
|
|
315
|
+
get defaultHintMessage() {
|
|
316
|
+
return this.typeable
|
|
317
|
+
? loc('tecton.element.calendar.hint.format') + ': ' + this.defaultFormatString
|
|
318
|
+
: loc('tecton.element.calendar.hint.select');
|
|
319
|
+
}
|
|
321
320
|
get canClear() {
|
|
322
321
|
if (this.isTypeable) {
|
|
323
322
|
return this.clearable && !!this.typedValue;
|
|
@@ -425,36 +424,52 @@ export class Q2Calendar {
|
|
|
425
424
|
delegateFocus(event) {
|
|
426
425
|
if (!isEventFromElement(event, this.hostElement))
|
|
427
426
|
return;
|
|
428
|
-
this.
|
|
427
|
+
this.controlElement.shadowRoot.querySelector('.input-field').focus();
|
|
429
428
|
}
|
|
430
429
|
handleClear() {
|
|
431
430
|
this.value = null;
|
|
432
431
|
this.typedValue = '';
|
|
433
|
-
|
|
432
|
+
}
|
|
433
|
+
popoverStateHandler({ detail: { open } }) {
|
|
434
|
+
if (this.open !== open)
|
|
435
|
+
this.open = open;
|
|
434
436
|
}
|
|
435
437
|
//////// Observers //////////
|
|
438
|
+
popDirectionHandler() {
|
|
439
|
+
handleRenamedProp(this, 'popDirection', 'popoverDirection');
|
|
440
|
+
}
|
|
436
441
|
ariaLabelObserver() {
|
|
437
442
|
handleAriaLabel(this);
|
|
438
443
|
}
|
|
444
|
+
typeableChanged() {
|
|
445
|
+
this.valueObserver(this.value);
|
|
446
|
+
}
|
|
439
447
|
valueObserver(newValue) {
|
|
440
448
|
const isMoment = newValue && typeof newValue !== 'string' && 'toDate' in newValue;
|
|
449
|
+
const newDate = isMoment ? newValue.toDate() : stringToDate(newValue);
|
|
450
|
+
const shortFormattedValue = formatDateShort(newDate);
|
|
441
451
|
if (this.isTypeable) {
|
|
442
|
-
|
|
443
|
-
? formatDateShort(newValue.toDate())
|
|
444
|
-
: newValue;
|
|
445
|
-
this.typedValue = newValueAsString;
|
|
446
|
-
// reset hint when value is cleared
|
|
447
|
-
if (!newValueAsString && !this.invalid) {
|
|
448
|
-
this.setHints({ isValid: true, message: this.defaultHintMessage, messageType: 'info' });
|
|
449
|
-
}
|
|
452
|
+
this.typedValue = shortFormattedValue;
|
|
450
453
|
}
|
|
451
454
|
else {
|
|
452
|
-
|
|
453
|
-
this.
|
|
454
|
-
this.selectedMonthYear = setupMonthYear(dateValue);
|
|
455
|
+
this.controlElement.value = shortFormattedValue;
|
|
456
|
+
this.selectedMonthYear = setupMonthYear(newDate);
|
|
455
457
|
this.dateList = this.buildDateList(this.selectedMonthYear);
|
|
456
458
|
this.validateDate();
|
|
457
459
|
}
|
|
460
|
+
// reset hint when value is cleared
|
|
461
|
+
if (this.invalid)
|
|
462
|
+
return;
|
|
463
|
+
if (shortFormattedValue) {
|
|
464
|
+
this.setHints({
|
|
465
|
+
isValid: true,
|
|
466
|
+
message: `${loc('tecton.element.calendar.hint.selection')}: ${formatDateLong(newDate)}`,
|
|
467
|
+
messageType: 'success',
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
this.setHints({ isValid: true, message: this.defaultHintMessage, messageType: 'info' });
|
|
472
|
+
}
|
|
458
473
|
}
|
|
459
474
|
daysOfWeekChecksumObserver() {
|
|
460
475
|
this.dateList = this.buildDateList(this.selectedMonthYear);
|
|
@@ -534,7 +549,7 @@ export class Q2Calendar {
|
|
|
534
549
|
}
|
|
535
550
|
focusInput() {
|
|
536
551
|
var _a;
|
|
537
|
-
(_a = this.
|
|
552
|
+
(_a = this.controlElement) === null || _a === void 0 ? void 0 : _a.focus();
|
|
538
553
|
}
|
|
539
554
|
checkActiveCellForBlankness() {
|
|
540
555
|
const activeElement = this.hostElement.shadowRoot.activeElement;
|
|
@@ -554,51 +569,53 @@ export class Q2Calendar {
|
|
|
554
569
|
this.goToMonthYear(date.getMonth(), date.getFullYear());
|
|
555
570
|
this.scheduledAfterRender.push(() => this.focusDay(date));
|
|
556
571
|
}
|
|
557
|
-
focusDay(date) {
|
|
572
|
+
async focusDay(date) {
|
|
558
573
|
var _a;
|
|
574
|
+
if (!date)
|
|
575
|
+
return;
|
|
576
|
+
await waitForNextPaint();
|
|
559
577
|
(_a = this.calendarBody.querySelector(`td[data-day="${date.getDate()}"]`)) === null || _a === void 0 ? void 0 : _a.focus();
|
|
560
578
|
}
|
|
561
579
|
render() {
|
|
562
|
-
return (h("click-elsewhere", { class:
|
|
580
|
+
return (h("click-elsewhere", { class: this.open ? 'dropdown-open' : undefined, onChange: this.onClickElsewhere }, this.inputField(), h("q2-popover", { ref: el => (this.popoverElement = el), controlElement: this.innerInputField, open: this.open, direction: this.popoverDirection, "aria-label": loc('tecton.element.calendar.dialogLabel'), minHeight: this.popoverMinHeight, block: true }, this.hintField(), this.calendarPopover())));
|
|
563
581
|
}
|
|
564
582
|
hintField() {
|
|
565
|
-
|
|
583
|
+
const messageClasses = ['calendar-hint'];
|
|
584
|
+
if (!this.isTypeable)
|
|
585
|
+
messageClasses.push('sr');
|
|
586
|
+
return (h("q2-message", { ref: el => (this.hintMessageElement = el), type: this.hintMessageType, class: messageClasses.join(' ') }, this.hintMessage));
|
|
566
587
|
}
|
|
567
588
|
setHints({ isValid, message, messageType }) {
|
|
589
|
+
if (message === this.hintMessage)
|
|
590
|
+
return this.hintMessageElement.present();
|
|
568
591
|
this.invalid = !isValid;
|
|
569
592
|
this.hintMessage = message;
|
|
570
593
|
this.hintMessageType = messageType;
|
|
571
|
-
if (!this.invalid) {
|
|
572
|
-
this.errors = [];
|
|
573
|
-
}
|
|
574
594
|
}
|
|
575
595
|
setCompleteInput(inputDate) {
|
|
576
596
|
const formattedDate = formatDateShort(inputDate);
|
|
577
597
|
this.change.emit({ value: formatDateISO(inputDate) });
|
|
578
598
|
this.typedValue = formattedDate;
|
|
579
|
-
this.setHints({
|
|
580
|
-
isValid: true,
|
|
581
|
-
message: `${loc('tecton.element.calendar.hint.selection')}: ${formatDateLong(inputDate)}`,
|
|
582
|
-
messageType: 'success',
|
|
583
|
-
});
|
|
584
599
|
}
|
|
585
|
-
|
|
586
|
-
return (h("q2-input", { ref: el => (this.
|
|
600
|
+
inputField() {
|
|
601
|
+
return (h("q2-input", { ref: el => (this.controlElement = el), class: "calendar-input-field", value: this.formattedValue, label: loc(this.label), hideLabel: this.hideLabel, disabled: !!this.disabled, readonly: !!this.readonly, clearable: this.canClear, placeholder: this.computedPlaceholder, optional: !!this.optional, ariaExpanded: `${!!this.open}`, errors: (this.localizedErrors.length > 0 && this.localizedErrors) ||
|
|
587
602
|
(this.invalid && ['tecton.element.calendar.invalid']) ||
|
|
588
603
|
[], onClick: this.onInputClick, onChange: this.onInputChange, onInput: this.onInputInput, onKeyDown: this.onInputKeydown, onKeyUp: this.onInputKeyup, onBlur: this.onInputBlur, "icon-right": "calendar", "format-modifier": this.isTypeable ? this.formatModifier : '', pseudo: !this.isTypeable, type: "date", "hide-messages": true, "test-id": "inputAndCalendarToggle" }));
|
|
589
604
|
}
|
|
590
|
-
|
|
605
|
+
calendarPopover() {
|
|
591
606
|
const { monthIndex, selectedYear } = this.selectedMonthYear;
|
|
592
607
|
return (h("div", { class: "calendar-field-popup", onKeyUp: this.onPopupKeyup }, this.calendarLabel && h("p", { class: "calendar-label" }, loc(this.calendarLabel)), h("div", { class: "cal-month-heading" }, h("q2-btn", { label: loc('tecton.element.calendar.previousMonth'), "hide-label": true, ref: elm => (this.btnPrevMonth = elm), class: "cal-nav-btn prev-month", "test-id": "previousMonthButton", onClick: () => this.goToMonthYear(monthIndex - 1, selectedYear) }, h("q2-icon", { type: "chevron-left" })), h("span", { class: "cal-month-text" }, this.monthStrings[monthIndex]), h("q2-btn", { label: loc('tecton.element.calendar.nextMonth'), "hide-label": true, class: "cal-nav-btn next-month", ref: elm => (this.btnNextMonth = elm), "test-id": "nextMonthButton", onClick: () => this.goToMonthYear(monthIndex + 1, selectedYear) }, h("q2-icon", { type: "chevron-right" })), h("q2-btn", { label: loc('tecton.element.calendar.previousYear'), "hide-label": true, class: "cal-nav-btn prev-year", ref: elm => (this.btnPrevYear = elm), "test-id": "previousYearButton", onClick: () => this.goToMonthYear(monthIndex, selectedYear - 1) }, h("q2-icon", { type: "chevron-left" })), h("span", { class: "cal-year-text" }, this.selectedMonthYear.selectedYear), h("q2-btn", { label: loc('tecton.element.calendar.nextYear'), "hide-label": true, class: "cal-nav-btn next-year", ref: elm => (this.btnNextYear = elm), "test-id": "nextYearButton", onClick: () => this.goToMonthYear(monthIndex, selectedYear + 1) }, h("q2-icon", { type: "chevron-right" }))), h("div", { class: "sr", "aria-live": "polite", id: "table-label" }, `${this.monthStrings[monthIndex]} ${selectedYear}`), this.calendarDays(), this.disclaimer && h("div", { class: "calendar-disclaimer" }, loc(this.disclaimer)), h("q2-btn", { class: "sr refocus-popup", onFocus: this.onRefocus })));
|
|
593
608
|
}
|
|
594
609
|
calendarDays() {
|
|
595
|
-
|
|
596
|
-
return (h("table", { role: "grid", "aria-labelledby": "table-label" }, h("thead", null, h("tr", null, [...Array(7).keys()].map(index => (h("th", { scope: "col", abbr: this.dayStrings[index] }, this.dayAbbrStrings[index]))))), h("tbody", { onClick: this.onDateSelection, onKeyDown: this.onDateKeydown, ref: elm => (this.calendarBody = elm), "test-id": "calendarTableBody" }, this.currentWeeks.map(week => (h("tr", null, week.map(day => {
|
|
610
|
+
return (h("table", { role: "grid", "aria-labelledby": "table-label" }, h("thead", null, h("tr", null, [...Array(7).keys()].map(index => (h("th", { scope: "col", "aria-label": this.dayStrings[index] }, this.dayAbbrStrings[index]))))), h("tbody", { onClick: this.onDateSelection, onKeyDown: this.onDateKeydown, ref: elm => (this.calendarBody = elm), "test-id": "calendarTableBody" }, this.currentWeeks.map(week => (h("tr", null, week.map(day => {
|
|
597
611
|
var _a;
|
|
598
|
-
let ariaLabel =
|
|
612
|
+
let ariaLabel = '';
|
|
613
|
+
if (day.isToday)
|
|
614
|
+
ariaLabel = `${loc('tecton.element.calendar.today')}, `;
|
|
615
|
+
ariaLabel += formatDateFull(day.date);
|
|
599
616
|
if (day.isSelected)
|
|
600
617
|
ariaLabel += ` (${loc('tecton.element.calendar.selected')})`;
|
|
601
|
-
return (h("td", { class: day.classList, "aria-hidden": day.isEmpty ? 'true' : undefined, tabindex: day.isSelected ? 0 : -1, role: day.isSelected ? 'gridcell' : undefined, "aria-selected": day.isSelected ? 'true' : undefined, "aria-disabled": day.isValid ? undefined : 'true', "data-day": day.integer || undefined, "data-date": day.date ? formatDateISO(day.date) : undefined }, (day === null || day === void 0 ? void 0 : day.isToday) && (h("div", { class: "today-decorator" }, loc('tecton.element.calendar.today'))), h("div", { "aria-label": ariaLabel }, (_a = day === null || day === void 0 ? void 0 : day.integer) !== null && _a !== void 0 ? _a : '')));
|
|
618
|
+
return (h("td", { class: day.classList, "aria-hidden": day.isEmpty ? 'true' : undefined, tabindex: day.isSelected ? 0 : -1, role: day.isSelected ? 'gridcell' : undefined, "aria-selected": day.isSelected ? 'true' : undefined, "aria-disabled": day.isValid ? undefined : 'true', "data-day": day.integer || undefined, "data-date": day.date ? formatDateISO(day.date) : undefined }, (day === null || day === void 0 ? void 0 : day.isToday) && (h("div", { class: "today-decorator", "aria-hidden": "true" }, loc('tecton.element.calendar.today'))), h("div", { "aria-label": ariaLabel }, (_a = day === null || day === void 0 ? void 0 : day.integer) !== null && _a !== void 0 ? _a : '')));
|
|
602
619
|
})))))));
|
|
603
620
|
}
|
|
604
621
|
static get is() { return "q2-calendar"; }
|
|
@@ -738,6 +755,23 @@ export class Q2Calendar {
|
|
|
738
755
|
"attribute": "invalid",
|
|
739
756
|
"reflect": true
|
|
740
757
|
},
|
|
758
|
+
"open": {
|
|
759
|
+
"type": "boolean",
|
|
760
|
+
"mutable": true,
|
|
761
|
+
"complexType": {
|
|
762
|
+
"original": "boolean",
|
|
763
|
+
"resolved": "boolean",
|
|
764
|
+
"references": {}
|
|
765
|
+
},
|
|
766
|
+
"required": false,
|
|
767
|
+
"optional": false,
|
|
768
|
+
"docs": {
|
|
769
|
+
"tags": [],
|
|
770
|
+
"text": ""
|
|
771
|
+
},
|
|
772
|
+
"attribute": "open",
|
|
773
|
+
"reflect": true
|
|
774
|
+
},
|
|
741
775
|
"typeable": {
|
|
742
776
|
"type": "boolean",
|
|
743
777
|
"mutable": false,
|
|
@@ -925,23 +959,6 @@ export class Q2Calendar {
|
|
|
925
959
|
"attribute": "days-of-week-checksum",
|
|
926
960
|
"reflect": true
|
|
927
961
|
},
|
|
928
|
-
"popDirection": {
|
|
929
|
-
"type": "string",
|
|
930
|
-
"mutable": false,
|
|
931
|
-
"complexType": {
|
|
932
|
-
"original": "'up' | 'down'",
|
|
933
|
-
"resolved": "\"down\" | \"up\"",
|
|
934
|
-
"references": {}
|
|
935
|
-
},
|
|
936
|
-
"required": false,
|
|
937
|
-
"optional": false,
|
|
938
|
-
"docs": {
|
|
939
|
-
"tags": [],
|
|
940
|
-
"text": ""
|
|
941
|
-
},
|
|
942
|
-
"attribute": "pop-direction",
|
|
943
|
-
"reflect": true
|
|
944
|
-
},
|
|
945
962
|
"assume": {
|
|
946
963
|
"type": "string",
|
|
947
964
|
"mutable": false,
|
|
@@ -1005,6 +1022,61 @@ export class Q2Calendar {
|
|
|
1005
1022
|
"text": ""
|
|
1006
1023
|
}
|
|
1007
1024
|
},
|
|
1025
|
+
"popoverDirection": {
|
|
1026
|
+
"type": "string",
|
|
1027
|
+
"mutable": true,
|
|
1028
|
+
"complexType": {
|
|
1029
|
+
"original": "'up' | 'down'",
|
|
1030
|
+
"resolved": "\"down\" | \"up\"",
|
|
1031
|
+
"references": {}
|
|
1032
|
+
},
|
|
1033
|
+
"required": false,
|
|
1034
|
+
"optional": false,
|
|
1035
|
+
"docs": {
|
|
1036
|
+
"tags": [],
|
|
1037
|
+
"text": ""
|
|
1038
|
+
},
|
|
1039
|
+
"attribute": "popover-direction",
|
|
1040
|
+
"reflect": false
|
|
1041
|
+
},
|
|
1042
|
+
"popoverMinHeight": {
|
|
1043
|
+
"type": "number",
|
|
1044
|
+
"mutable": false,
|
|
1045
|
+
"complexType": {
|
|
1046
|
+
"original": "number",
|
|
1047
|
+
"resolved": "number",
|
|
1048
|
+
"references": {}
|
|
1049
|
+
},
|
|
1050
|
+
"required": false,
|
|
1051
|
+
"optional": false,
|
|
1052
|
+
"docs": {
|
|
1053
|
+
"tags": [],
|
|
1054
|
+
"text": ""
|
|
1055
|
+
},
|
|
1056
|
+
"attribute": "popover-min-height",
|
|
1057
|
+
"reflect": false,
|
|
1058
|
+
"defaultValue": "355"
|
|
1059
|
+
},
|
|
1060
|
+
"popDirection": {
|
|
1061
|
+
"type": "string",
|
|
1062
|
+
"mutable": false,
|
|
1063
|
+
"complexType": {
|
|
1064
|
+
"original": "'up' | 'down'",
|
|
1065
|
+
"resolved": "\"down\" | \"up\"",
|
|
1066
|
+
"references": {}
|
|
1067
|
+
},
|
|
1068
|
+
"required": false,
|
|
1069
|
+
"optional": false,
|
|
1070
|
+
"docs": {
|
|
1071
|
+
"tags": [{
|
|
1072
|
+
"name": "deprecated",
|
|
1073
|
+
"text": undefined
|
|
1074
|
+
}],
|
|
1075
|
+
"text": ""
|
|
1076
|
+
},
|
|
1077
|
+
"attribute": "pop-direction",
|
|
1078
|
+
"reflect": true
|
|
1079
|
+
},
|
|
1008
1080
|
"onsuccess": {
|
|
1009
1081
|
"type": "unknown",
|
|
1010
1082
|
"mutable": false,
|
|
@@ -1049,7 +1121,7 @@ export class Q2Calendar {
|
|
|
1049
1121
|
},
|
|
1050
1122
|
"ariaLabel": {
|
|
1051
1123
|
"type": "string",
|
|
1052
|
-
"mutable":
|
|
1124
|
+
"mutable": true,
|
|
1053
1125
|
"complexType": {
|
|
1054
1126
|
"original": "string",
|
|
1055
1127
|
"resolved": "string",
|
|
@@ -1071,7 +1143,6 @@ export class Q2Calendar {
|
|
|
1071
1143
|
}
|
|
1072
1144
|
static get states() {
|
|
1073
1145
|
return {
|
|
1074
|
-
"dropdownOpen": {},
|
|
1075
1146
|
"keyboardSelection": {},
|
|
1076
1147
|
"typedValue": {},
|
|
1077
1148
|
"dateList": {},
|
|
@@ -1130,8 +1201,14 @@ export class Q2Calendar {
|
|
|
1130
1201
|
static get elementRef() { return "hostElement"; }
|
|
1131
1202
|
static get watchers() {
|
|
1132
1203
|
return [{
|
|
1204
|
+
"propName": "popDirection",
|
|
1205
|
+
"methodName": "popDirectionHandler"
|
|
1206
|
+
}, {
|
|
1133
1207
|
"propName": "ariaLabel",
|
|
1134
1208
|
"methodName": "ariaLabelObserver"
|
|
1209
|
+
}, {
|
|
1210
|
+
"propName": "typeable",
|
|
1211
|
+
"methodName": "typeableChanged"
|
|
1135
1212
|
}, {
|
|
1136
1213
|
"propName": "value",
|
|
1137
1214
|
"methodName": "valueObserver"
|
|
@@ -1186,6 +1263,12 @@ export class Q2Calendar {
|
|
|
1186
1263
|
"target": undefined,
|
|
1187
1264
|
"capture": false,
|
|
1188
1265
|
"passive": false
|
|
1266
|
+
}, {
|
|
1267
|
+
"name": "popoverStateChanged",
|
|
1268
|
+
"method": "popoverStateHandler",
|
|
1269
|
+
"target": undefined,
|
|
1270
|
+
"capture": false,
|
|
1271
|
+
"passive": false
|
|
1189
1272
|
}];
|
|
1190
1273
|
}
|
|
1191
1274
|
}
|
|
@@ -65,65 +65,6 @@ button {
|
|
|
65
65
|
visibility: hidden;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
.q2-element-dropdown {
|
|
69
|
-
display: none;
|
|
70
|
-
position: absolute;
|
|
71
|
-
background-color: var(--app-white, #ffffff);
|
|
72
|
-
color: var(--t-text, #4d4d4d);
|
|
73
|
-
left: 0;
|
|
74
|
-
width: 100%;
|
|
75
|
-
z-index: 100;
|
|
76
|
-
margin-top: 1px;
|
|
77
|
-
box-shadow: var(--app-shadow-1, 0 2px 4px rgba(0, 0, 0, 0.3));
|
|
78
|
-
height: 0;
|
|
79
|
-
overflow: hidden;
|
|
80
|
-
opacity: 0;
|
|
81
|
-
visibility: hidden;
|
|
82
|
-
transition: opacity var(--app-tween-1, 0.2s ease);
|
|
83
|
-
border-radius: var(--tct-dropdown-border-radius, --t-dropdown-border-radius, 0);
|
|
84
|
-
--comp-scrollbar-size: var(--tct-scrollbar-size, var(--t-scrollbar-size, var(--app-scale-1x, 5px)));
|
|
85
|
-
--comp-scrollbar-border-radius: var(--tct-scrollbar-border-radius, var(--t-scrollbar-border-radius, var(--app-border-radius-1, 3px)));
|
|
86
|
-
--comp-scrollbar-color: var(--tct-scrollbar-color, var(--t-scrollbar-color, var(--t-a11y-gray-color, #747474)));
|
|
87
|
-
scrollbar-width: thin;
|
|
88
|
-
scrollbar-color: var(--comp-scrollbar-color) transparent;
|
|
89
|
-
}
|
|
90
|
-
.q2-element-dropdown::-webkit-scrollbar {
|
|
91
|
-
width: var(--comp-scrollbar-size);
|
|
92
|
-
height: var(--comp-scrollbar-size);
|
|
93
|
-
margin: 5px;
|
|
94
|
-
}
|
|
95
|
-
.q2-element-dropdown::-webkit-scrollbar-thumb {
|
|
96
|
-
background: var(--comp-scrollbar-color);
|
|
97
|
-
border-radius: var(--comp-scrollbar-border-radius);
|
|
98
|
-
}
|
|
99
|
-
.q2-element-dropdown::-webkit-scrollbar-track {
|
|
100
|
-
background: transparent;
|
|
101
|
-
border-radius: var(--comp-scrollbar-border-radius);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.q2-element-dropdown.sizable {
|
|
105
|
-
display: block;
|
|
106
|
-
height: auto;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.dropdown-open .q2-element-dropdown {
|
|
110
|
-
display: block;
|
|
111
|
-
height: auto;
|
|
112
|
-
overflow: auto;
|
|
113
|
-
opacity: 1;
|
|
114
|
-
visibility: visible;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
:host([alignment=right]) .q2-element-dropdown {
|
|
118
|
-
left: auto;
|
|
119
|
-
right: 0;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
:host([block]) q2-btn,
|
|
123
|
-
:host([block]) {
|
|
124
|
-
display: block;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
68
|
:host {
|
|
128
69
|
display: block;
|
|
129
70
|
}
|
|
@@ -132,7 +73,7 @@ button {
|
|
|
132
73
|
display: none;
|
|
133
74
|
}
|
|
134
75
|
|
|
135
|
-
|
|
76
|
+
click-elsewhere {
|
|
136
77
|
position: relative;
|
|
137
78
|
display: block;
|
|
138
79
|
}
|
|
@@ -142,14 +83,8 @@ q2-input {
|
|
|
142
83
|
cursor: pointer;
|
|
143
84
|
}
|
|
144
85
|
|
|
145
|
-
.
|
|
146
|
-
|
|
147
|
-
min-width: 308px;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
.q2-element-dropdown.dropup {
|
|
151
|
-
bottom: var(--comp-input-min-height, 44px);
|
|
152
|
-
margin-bottom: 0px;
|
|
86
|
+
.calendar-field-popup {
|
|
87
|
+
padding: var(--tct-calendar-popover-padding, var(--t-calendar-popover-padding, var(--app-scale-1x, 5px)));
|
|
153
88
|
}
|
|
154
89
|
|
|
155
90
|
.calendar-label {
|
|
@@ -172,6 +107,7 @@ q2-input {
|
|
|
172
107
|
align-items: center;
|
|
173
108
|
font-size: var(--tct-calendar-month-font-size, var(--t-calendar-month-font-size, 16px));
|
|
174
109
|
font-weight: var(--tct-calendar-month-font-weight, var(--t-calendar-month-font-weight, 600));
|
|
110
|
+
text-align: center;
|
|
175
111
|
}
|
|
176
112
|
|
|
177
113
|
.cal-month-text {
|
|
@@ -187,6 +123,7 @@ q2-input {
|
|
|
187
123
|
table {
|
|
188
124
|
width: 100%;
|
|
189
125
|
margin-bottom: 2px;
|
|
126
|
+
text-align: center;
|
|
190
127
|
}
|
|
191
128
|
|
|
192
129
|
th {
|