tyrell-components 1.0.0-RC16 → 1.0.0-RC18
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/README.md +1 -1
- package/css/tyrell-colors-static.css +1 -316
- package/css/tyrell-theme.css +1 -1471
- package/css/tyrell.css +1 -1385
- package/dist/tyrell-colors-static.css +1 -1
- package/dist/tyrell-theme.css +1 -1
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +28 -15
- package/lib/base/ty-component.js +81 -38
- package/lib/components/button.d.ts +14 -0
- package/lib/components/button.js +55 -7
- package/lib/components/calendar-month.d.ts +7 -1
- package/lib/components/calendar-month.js +35 -28
- package/lib/components/calendar-navigation.js +19 -6
- package/lib/components/calendar.d.ts +27 -3
- package/lib/components/calendar.js +107 -63
- package/lib/components/checkbox.d.ts +8 -1
- package/lib/components/checkbox.js +27 -6
- package/lib/components/copy.d.ts +2 -0
- package/lib/components/copy.js +15 -31
- package/lib/components/date-picker.d.ts +53 -18
- package/lib/components/date-picker.js +217 -146
- package/lib/components/file-upload.d.ts +4 -1
- package/lib/components/file-upload.js +23 -5
- package/lib/components/input.d.ts +73 -3
- package/lib/components/input.js +158 -22
- package/lib/components/modal.d.ts +2 -0
- package/lib/components/modal.js +97 -17
- package/lib/components/option.d.ts +19 -0
- package/lib/components/option.js +45 -31
- package/lib/components/popup.js +115 -15
- package/lib/components/radio.d.ts +10 -1
- package/lib/components/radio.js +22 -29
- package/lib/components/resize-observer.js +2 -0
- package/lib/components/scroll-container.js +2 -0
- package/lib/components/select.d.ts +150 -190
- package/lib/components/select.js +501 -796
- package/lib/components/selected-tags.d.ts +14 -4
- package/lib/components/selected-tags.js +35 -8
- package/lib/components/switch.d.ts +9 -1
- package/lib/components/switch.js +27 -6
- package/lib/components/tabs.js +1 -1
- package/lib/components/tag.d.ts +0 -9
- package/lib/components/tag.js +0 -11
- package/lib/components/textarea.d.ts +47 -2
- package/lib/components/textarea.js +81 -17
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/styles/button.js +21 -19
- package/lib/styles/calendar-month.js +1 -1
- package/lib/styles/calendar.js +3 -0
- package/lib/styles/checkbox.js +11 -5
- package/lib/styles/date-picker.js +16 -4
- package/lib/styles/file-upload.d.ts +1 -1
- package/lib/styles/file-upload.js +3 -3
- package/lib/styles/icon.d.ts +1 -1
- package/lib/styles/icon.js +2 -2
- package/lib/styles/input.js +6 -10
- package/lib/styles/option.d.ts +1 -1
- package/lib/styles/option.js +6 -7
- package/lib/styles/popup.d.ts +1 -1
- package/lib/styles/popup.js +2 -0
- package/lib/styles/radio.js +12 -6
- package/lib/styles/select-base.js +22 -60
- package/lib/styles/select.d.ts +1 -1
- package/lib/styles/select.js +13 -2
- package/lib/styles/switch.js +10 -5
- package/lib/styles/tag.js +3 -5
- package/lib/styles/textarea.d.ts +1 -1
- package/lib/styles/textarea.js +7 -0
- package/lib/types/common.d.ts +3 -3
- package/lib/utils/calendar-utils.d.ts +49 -0
- package/lib/utils/calendar-utils.js +63 -6
- package/lib/utils/property-manager.d.ts +6 -5
- package/lib/utils/property-manager.js +14 -15
- package/lib/utils/scroll-lock.d.ts +10 -4
- package/lib/utils/scroll-lock.js +102 -2
- package/lib/utils/upgrade-properties.d.ts +21 -0
- package/lib/utils/upgrade-properties.js +47 -0
- package/lib/utils/validity.d.ts +98 -2
- package/lib/utils/validity.js +244 -8
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +8 -6
- package/lib/base/ty-component.d.ts.map +0 -1
- package/lib/base/ty-component.js.map +0 -1
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js.map +0 -1
- package/lib/components/calendar-month.d.ts.map +0 -1
- package/lib/components/calendar-month.js.map +0 -1
- package/lib/components/calendar-navigation.d.ts.map +0 -1
- package/lib/components/calendar-navigation.js.map +0 -1
- package/lib/components/calendar.d.ts.map +0 -1
- package/lib/components/calendar.js.map +0 -1
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js.map +0 -1
- package/lib/components/copy.d.ts.map +0 -1
- package/lib/components/copy.js.map +0 -1
- package/lib/components/date-picker.d.ts.map +0 -1
- package/lib/components/date-picker.js.map +0 -1
- package/lib/components/dropdown.d.ts +0 -403
- package/lib/components/dropdown.d.ts.map +0 -1
- package/lib/components/dropdown.js +0 -1315
- package/lib/components/dropdown.js.map +0 -1
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js.map +0 -1
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js.map +0 -1
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js.map +0 -1
- package/lib/components/multiselect.d.ts +0 -389
- package/lib/components/multiselect.d.ts.map +0 -1
- package/lib/components/multiselect.js +0 -1301
- package/lib/components/multiselect.js.map +0 -1
- package/lib/components/option.d.ts.map +0 -1
- package/lib/components/option.js.map +0 -1
- package/lib/components/popup.d.ts.map +0 -1
- package/lib/components/popup.js.map +0 -1
- package/lib/components/resize-observer.d.ts.map +0 -1
- package/lib/components/resize-observer.js.map +0 -1
- package/lib/components/scroll-container.d.ts.map +0 -1
- package/lib/components/scroll-container.js.map +0 -1
- package/lib/components/step.d.ts.map +0 -1
- package/lib/components/step.js.map +0 -1
- package/lib/components/tab.d.ts.map +0 -1
- package/lib/components/tab.js.map +0 -1
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js.map +0 -1
- package/lib/components/tag.d.ts.map +0 -1
- package/lib/components/tag.js.map +0 -1
- package/lib/components/textarea.d.ts.map +0 -1
- package/lib/components/textarea.js.map +0 -1
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js.map +0 -1
- package/lib/components/wizard.d.ts.map +0 -1
- package/lib/components/wizard.js.map +0 -1
- package/lib/icons/fontawesome/brands.d.ts.map +0 -1
- package/lib/icons/fontawesome/brands.js.map +0 -1
- package/lib/icons/fontawesome/regular.d.ts.map +0 -1
- package/lib/icons/fontawesome/regular.js.map +0 -1
- package/lib/icons/fontawesome/solid.d.ts.map +0 -1
- package/lib/icons/fontawesome/solid.js.map +0 -1
- package/lib/icons/heroicons/micro.d.ts.map +0 -1
- package/lib/icons/heroicons/micro.js.map +0 -1
- package/lib/icons/heroicons/mini.d.ts.map +0 -1
- package/lib/icons/heroicons/mini.js.map +0 -1
- package/lib/icons/heroicons/outline.d.ts.map +0 -1
- package/lib/icons/heroicons/outline.js.map +0 -1
- package/lib/icons/heroicons/solid.d.ts.map +0 -1
- package/lib/icons/heroicons/solid.js.map +0 -1
- package/lib/icons/lucide.d.ts.map +0 -1
- package/lib/icons/lucide.js.map +0 -1
- package/lib/icons/material/filled.d.ts.map +0 -1
- package/lib/icons/material/filled.js.map +0 -1
- package/lib/icons/material/outlined.d.ts.map +0 -1
- package/lib/icons/material/outlined.js.map +0 -1
- package/lib/icons/material/round.d.ts.map +0 -1
- package/lib/icons/material/round.js.map +0 -1
- package/lib/icons/material/sharp.d.ts.map +0 -1
- package/lib/icons/material/sharp.js.map +0 -1
- package/lib/icons/material/two-tone.d.ts.map +0 -1
- package/lib/icons/material/two-tone.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/styles/button.d.ts.map +0 -1
- package/lib/styles/button.js.map +0 -1
- package/lib/styles/calendar-month.d.ts.map +0 -1
- package/lib/styles/calendar-month.js.map +0 -1
- package/lib/styles/calendar-navigation.d.ts.map +0 -1
- package/lib/styles/calendar-navigation.js.map +0 -1
- package/lib/styles/calendar.d.ts.map +0 -1
- package/lib/styles/calendar.js.map +0 -1
- package/lib/styles/copy.d.ts.map +0 -1
- package/lib/styles/copy.js.map +0 -1
- package/lib/styles/date-picker.d.ts.map +0 -1
- package/lib/styles/date-picker.js.map +0 -1
- package/lib/styles/dropdown.d.ts +0 -12
- package/lib/styles/dropdown.d.ts.map +0 -1
- package/lib/styles/dropdown.js +0 -725
- package/lib/styles/dropdown.js.map +0 -1
- package/lib/styles/icon.d.ts.map +0 -1
- package/lib/styles/icon.js.map +0 -1
- package/lib/styles/input.d.ts.map +0 -1
- package/lib/styles/input.js.map +0 -1
- package/lib/styles/modal.d.ts.map +0 -1
- package/lib/styles/modal.js.map +0 -1
- package/lib/styles/multiselect.d.ts +0 -6
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -568
- package/lib/styles/multiselect.js.map +0 -1
- package/lib/styles/option.d.ts.map +0 -1
- package/lib/styles/option.js.map +0 -1
- package/lib/styles/popup.d.ts.map +0 -1
- package/lib/styles/popup.js.map +0 -1
- package/lib/styles/resize-observer.d.ts.map +0 -1
- package/lib/styles/resize-observer.js.map +0 -1
- package/lib/styles/scroll-container.d.ts.map +0 -1
- package/lib/styles/scroll-container.js.map +0 -1
- package/lib/styles/step.d.ts.map +0 -1
- package/lib/styles/step.js.map +0 -1
- package/lib/styles/tab.d.ts.map +0 -1
- package/lib/styles/tab.js.map +0 -1
- package/lib/styles/tabs.d.ts.map +0 -1
- package/lib/styles/tabs.js.map +0 -1
- package/lib/styles/tag.d.ts.map +0 -1
- package/lib/styles/tag.js.map +0 -1
- package/lib/styles/textarea.d.ts.map +0 -1
- package/lib/styles/textarea.js.map +0 -1
- package/lib/styles/tooltip.d.ts.map +0 -1
- package/lib/styles/tooltip.js.map +0 -1
- package/lib/styles/wizard.d.ts.map +0 -1
- package/lib/styles/wizard.js.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/common.js.map +0 -1
- package/lib/utils/calendar-utils.d.ts.map +0 -1
- package/lib/utils/calendar-utils.js.map +0 -1
- package/lib/utils/icon-registry.d.ts.map +0 -1
- package/lib/utils/icon-registry.js.map +0 -1
- package/lib/utils/locale.d.ts.map +0 -1
- package/lib/utils/locale.js.map +0 -1
- package/lib/utils/number-format.d.ts.map +0 -1
- package/lib/utils/number-format.js.map +0 -1
- package/lib/utils/parse-boolean.d.ts +0 -39
- package/lib/utils/parse-boolean.d.ts.map +0 -1
- package/lib/utils/parse-boolean.js +0 -23
- package/lib/utils/parse-boolean.js.map +0 -1
- package/lib/utils/positioning.d.ts.map +0 -1
- package/lib/utils/positioning.js.map +0 -1
- package/lib/utils/property-capture.d.ts.map +0 -1
- package/lib/utils/property-capture.js.map +0 -1
- package/lib/utils/property-manager.d.ts.map +0 -1
- package/lib/utils/property-manager.js.map +0 -1
- package/lib/utils/resize-observer.d.ts.map +0 -1
- package/lib/utils/resize-observer.js.map +0 -1
- package/lib/utils/scroll-lock.d.ts.map +0 -1
- package/lib/utils/scroll-lock.js.map +0 -1
- package/lib/utils/styles.d.ts.map +0 -1
- package/lib/utils/styles.js.map +0 -1
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js.map +0 -1
|
@@ -7,6 +7,8 @@ import { getEffectiveLocale, observeLocaleChanges } from '../utils/locale.js';
|
|
|
7
7
|
import { isMobileTouch } from '../utils/mobile.js';
|
|
8
8
|
import { TyComponent } from '../base/ty-component.js';
|
|
9
9
|
import { DEFAULT_SIZE } from '../types/common.js';
|
|
10
|
+
import { nativeMessage } from '../utils/validity.js';
|
|
11
|
+
import { parseDateTime, toISODay, wallClockDate } from '../utils/calendar-utils.js';
|
|
10
12
|
const CALENDAR_ICON_SVG = `<svg stroke='currentColor' fill='none' stroke-width='2' viewBox='0 0 24 24' width='16' height='16' xmlns='http://www.w3.org/2000/svg'><rect x='3' y='4' width='18' height='18' rx='2' ry='2'></rect><line x1='16' y1='2' x2='16' y2='6'></line><line x1='8' y1='2' x2='8' y2='6'></line><line x1='3' y1='10' x2='21' y2='10'></line></svg>`;
|
|
11
13
|
const CLEAR_ICON_SVG = `<svg stroke='currentColor' fill='none' stroke-width='2' viewBox='0 0 24 24' width='14' height='14' xmlns='http://www.w3.org/2000/svg'><line x1='18' y1='6' x2='6' y2='18'></line><line x1='6' y1='6' x2='18' y2='18'></line></svg>`;
|
|
12
14
|
const SCHEDULE_ICON_SVG = `<svg stroke='currentColor' fill='none' stroke-width='2' viewBox='0 0 24 24' width='16' height='16' xmlns='http://www.w3.org/2000/svg'><circle cx='12' cy='12' r='10'></circle><polyline points='12,6 12,12 16,14'></polyline></svg>`;
|
|
@@ -20,48 +22,28 @@ elementIds.set(element, id);
|
|
|
20
22
|
}
|
|
21
23
|
return id;
|
|
22
24
|
}
|
|
23
|
-
function parseValue(value, withTime) {
|
|
24
|
-
if (!value)
|
|
25
|
-
return null;
|
|
26
|
-
let dateObj = null;
|
|
27
|
-
if (typeof value === 'string') {
|
|
28
|
-
if (/^\d{4}-\d{2}-\d{2}$/.test(value)) {
|
|
29
|
-
const [yearStr, monthStr, dayStr] = value.split('-');
|
|
30
|
-
const year = parseInt(yearStr, 10);
|
|
31
|
-
const month = parseInt(monthStr, 10) - 1;
|
|
32
|
-
const day = parseInt(dayStr, 10);
|
|
33
|
-
dateObj = new Date(year, month, day, 0, 0, 0, 0);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
dateObj = new Date(value);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
else if (typeof value === 'number') {
|
|
40
|
-
dateObj = new Date(value);
|
|
41
|
-
}
|
|
42
|
-
if (!dateObj || isNaN(dateObj.getTime())) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
const components = {
|
|
46
|
-
year: dateObj.getFullYear(),
|
|
47
|
-
month: dateObj.getMonth() + 1,
|
|
48
|
-
day: dateObj.getDate(),
|
|
49
|
-
hour: withTime ? dateObj.getHours() : 0,
|
|
50
|
-
minute: withTime ? dateObj.getMinutes() : 0,
|
|
51
|
-
};
|
|
52
|
-
return components;
|
|
53
|
-
}
|
|
54
25
|
function componentsToDateObject(components) {
|
|
55
|
-
const { year, month, day, hour, minute } = components;
|
|
26
|
+
const { year, month, day, hour, minute, second } = components;
|
|
56
27
|
if (!year || !month || !day)
|
|
57
28
|
return null;
|
|
58
|
-
|
|
29
|
+
const date = new Date(2000, 0, 1, 12);
|
|
30
|
+
date.setFullYear(year, month - 1, day);
|
|
31
|
+
date.setHours(hour || 0, minute || 0, second || 0, 0);
|
|
32
|
+
return date;
|
|
33
|
+
}
|
|
34
|
+
function effectiveComponents(components, withTime) {
|
|
35
|
+
return withTime ? components : { ...components, hour: 0, minute: 0, second: 0, epoch: undefined };
|
|
59
36
|
}
|
|
60
|
-
function componentsToOutputValue(components) {
|
|
37
|
+
function componentsToOutputValue(components, withTime, native) {
|
|
61
38
|
if (!components.year || !components.month || !components.day) {
|
|
62
39
|
return null;
|
|
63
40
|
}
|
|
64
|
-
const
|
|
41
|
+
const c = effectiveComponents(components, withTime);
|
|
42
|
+
if (native)
|
|
43
|
+
return componentsToLocalValue(c, withTime);
|
|
44
|
+
if (c.epoch !== undefined)
|
|
45
|
+
return new Date(c.epoch).toISOString();
|
|
46
|
+
const dateObj = componentsToDateObject(c);
|
|
65
47
|
return dateObj ? dateObj.toISOString() : null;
|
|
66
48
|
}
|
|
67
49
|
function componentsToLocalValue(components, withTime) {
|
|
@@ -74,27 +56,34 @@ const day = components.day.toString().padStart(2, '0');
|
|
|
74
56
|
if (withTime) {
|
|
75
57
|
const hour = (components.hour || 0).toString().padStart(2, '0');
|
|
76
58
|
const minute = (components.minute || 0).toString().padStart(2, '0');
|
|
77
|
-
|
|
59
|
+
const second = components.second ? `:${components.second.toString().padStart(2, '0')}` : '';
|
|
60
|
+
return `${year}-${month}-${day}T${hour}:${minute}${second}`;
|
|
78
61
|
}
|
|
79
62
|
else {
|
|
80
63
|
return `${year}-${month}-${day}`;
|
|
81
64
|
}
|
|
82
65
|
}
|
|
83
|
-
function
|
|
66
|
+
function displayDate(components, native) {
|
|
67
|
+
return native
|
|
68
|
+
? { date: wallClockDate(components), timeZone: 'UTC' }
|
|
69
|
+
: { date: componentsToDateObject(components) };
|
|
70
|
+
}
|
|
71
|
+
function formatDisplayValue(components, formatType, locale, withTime, native) {
|
|
84
72
|
if (!components.year || !components.month || !components.day) {
|
|
85
73
|
return null;
|
|
86
74
|
}
|
|
87
|
-
const
|
|
88
|
-
if (!
|
|
75
|
+
const { date, timeZone } = displayDate(components, native);
|
|
76
|
+
if (!date)
|
|
89
77
|
return null;
|
|
90
78
|
const options = {
|
|
91
79
|
dateStyle: formatType || 'long',
|
|
80
|
+
timeZone,
|
|
92
81
|
};
|
|
93
82
|
if (withTime) {
|
|
94
83
|
options.timeStyle = 'short';
|
|
95
84
|
}
|
|
96
85
|
const formatter = new Intl.DateTimeFormat(locale, options);
|
|
97
|
-
return formatter.format(
|
|
86
|
+
return formatter.format(date);
|
|
98
87
|
}
|
|
99
88
|
class TimeFields {
|
|
100
89
|
constructor(hourEl, minuteEl, onChange, hour = 0, minute = 0) {
|
|
@@ -213,14 +202,19 @@ withTime: false,
|
|
|
213
202
|
open: false,
|
|
214
203
|
};
|
|
215
204
|
this._closeTimestamp = 0;
|
|
205
|
+
this._initialized = false;
|
|
206
|
+
this._syncing = false;
|
|
216
207
|
this._customFlavorSheet = null;
|
|
217
208
|
const shadow = this.shadowRoot;
|
|
218
209
|
ensureStyles(shadow, { css: datePickerStyles, id: 'ty-date-picker' });
|
|
219
210
|
}
|
|
220
211
|
onConnect() {
|
|
212
|
+
if (this._initialized)
|
|
213
|
+
this._state.open = false;
|
|
214
|
+
else
|
|
221
215
|
this.initializeState();
|
|
222
216
|
this.render();
|
|
223
|
-
this.
|
|
217
|
+
this.updateFormValue();
|
|
224
218
|
this._localeObserver = observeLocaleChanges(this, () => {
|
|
225
219
|
this.render();
|
|
226
220
|
});
|
|
@@ -253,74 +247,68 @@ break;
|
|
|
253
247
|
case 'noClear':
|
|
254
248
|
case 'format':
|
|
255
249
|
case 'locale':
|
|
250
|
+
case 'error':
|
|
256
251
|
break;
|
|
257
252
|
case 'value': {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const hasDate = this._state.year !== undefined ||
|
|
261
|
-
this._state.month !== undefined ||
|
|
262
|
-
this._state.day !== undefined;
|
|
263
|
-
if (hasDate) {
|
|
253
|
+
if (!this._initialized || this._syncing)
|
|
254
|
+
break;
|
|
264
255
|
this._state = {
|
|
265
256
|
withTime: this._state.withTime,
|
|
266
257
|
open: this._state.open,
|
|
258
|
+
...parseDateTime(newValue),
|
|
267
259
|
};
|
|
268
|
-
}
|
|
269
260
|
this.syncFormValue();
|
|
270
261
|
break;
|
|
271
262
|
}
|
|
272
|
-
const currentComponents = {
|
|
273
|
-
year: this._state.year,
|
|
274
|
-
month: this._state.month,
|
|
275
|
-
day: this._state.day,
|
|
276
|
-
hour: this._state.hour,
|
|
277
|
-
minute: this._state.minute,
|
|
278
|
-
};
|
|
279
|
-
const changed = newComponents?.year !== currentComponents.year ||
|
|
280
|
-
newComponents?.month !== currentComponents.month ||
|
|
281
|
-
newComponents?.day !== currentComponents.day ||
|
|
282
|
-
newComponents?.hour !== currentComponents.hour ||
|
|
283
|
-
newComponents?.minute !== currentComponents.minute;
|
|
284
|
-
if (changed) {
|
|
285
|
-
this._state = {
|
|
286
|
-
...this._state,
|
|
287
|
-
...newComponents,
|
|
288
|
-
};
|
|
289
|
-
this.syncFormValue();
|
|
290
|
-
}
|
|
291
|
-
break;
|
|
292
|
-
}
|
|
293
263
|
case 'with-time': {
|
|
264
|
+
if (!this._initialized)
|
|
265
|
+
break;
|
|
294
266
|
const newWithTime = newValue;
|
|
295
|
-
|
|
296
|
-
if (newWithTime !== oldWithTime) {
|
|
267
|
+
if (newWithTime !== this._state.withTime) {
|
|
297
268
|
this._state.withTime = newWithTime;
|
|
298
|
-
const hasDate = this._state.year !== undefined &&
|
|
299
|
-
this._state.month !== undefined &&
|
|
300
|
-
this._state.day !== undefined;
|
|
301
|
-
if (hasDate) {
|
|
302
269
|
this.syncFormValue();
|
|
303
|
-
|
|
270
|
+
this.updateValidity();
|
|
304
271
|
}
|
|
305
272
|
break;
|
|
306
273
|
}
|
|
274
|
+
case 'native':
|
|
275
|
+
if (this._initialized)
|
|
276
|
+
this.syncFormValue();
|
|
277
|
+
break;
|
|
307
278
|
}
|
|
308
279
|
}
|
|
309
280
|
}
|
|
310
281
|
getFormValue() {
|
|
311
|
-
return
|
|
282
|
+
return this.outputValue(this.getComponents());
|
|
283
|
+
}
|
|
284
|
+
outputValue(components) {
|
|
285
|
+
return componentsToOutputValue(components, this._state.withTime, !!this.getProperty('native'));
|
|
312
286
|
}
|
|
313
287
|
updateFormValue() {
|
|
314
|
-
|
|
288
|
+
this._internals.setFormValue(this.getFormValue() ?? '');
|
|
315
289
|
this.updateValidity();
|
|
316
290
|
}
|
|
291
|
+
focusTarget() {
|
|
292
|
+
return this.shadowRoot?.querySelector('.native-date-input')
|
|
293
|
+
?? this.shadowRoot?.querySelector('.date-picker-stub')
|
|
294
|
+
?? null;
|
|
295
|
+
}
|
|
296
|
+
focus(options) {
|
|
297
|
+
if (this.getProperty('disabled'))
|
|
298
|
+
return;
|
|
299
|
+
const target = this.focusTarget();
|
|
300
|
+
if (target)
|
|
301
|
+
target.focus(options);
|
|
302
|
+
else
|
|
303
|
+
super.focus(options);
|
|
304
|
+
}
|
|
317
305
|
updateValidity() {
|
|
318
306
|
if (this.getProperty('disabled') || !this.getProperty('required') || this.getFormValue()) {
|
|
319
307
|
this.applyValidity({});
|
|
320
308
|
return;
|
|
321
309
|
}
|
|
322
|
-
const
|
|
323
|
-
this.applyValidity({ valueMissing: true }, '
|
|
310
|
+
const type = this._state.withTime ? 'datetime-local' : 'date';
|
|
311
|
+
this.applyValidity({ valueMissing: true }, nativeMessage('input', { type, required: true }), this.focusTarget() ?? undefined);
|
|
324
312
|
}
|
|
325
313
|
getComponents() {
|
|
326
314
|
return {
|
|
@@ -329,6 +317,8 @@ month: this._state.month,
|
|
|
329
317
|
day: this._state.day,
|
|
330
318
|
hour: this._state.hour,
|
|
331
319
|
minute: this._state.minute,
|
|
320
|
+
second: this._state.second,
|
|
321
|
+
epoch: this._state.epoch,
|
|
332
322
|
};
|
|
333
323
|
}
|
|
334
324
|
hasDate() {
|
|
@@ -338,25 +328,15 @@ getFormattedValue(components) {
|
|
|
338
328
|
const c = components || this.getComponents();
|
|
339
329
|
if (!c.year || !c.month || !c.day)
|
|
340
330
|
return null;
|
|
341
|
-
return formatDisplayValue(c, this.getProperty('format') || 'long', getEffectiveLocale(this, this.getProperty('locale')), this._state.withTime);
|
|
331
|
+
return formatDisplayValue(c, this.getProperty('format') || 'long', getEffectiveLocale(this, this.getProperty('locale')), this._state.withTime, !!this.getProperty('native'));
|
|
342
332
|
}
|
|
343
333
|
initializeState() {
|
|
344
|
-
const valueAttr = this.getProperty('value');
|
|
345
|
-
const withTime = this.getProperty('with-time');
|
|
346
|
-
const components = parseValue(valueAttr, withTime);
|
|
347
|
-
if (components === null) {
|
|
348
334
|
this._state = {
|
|
349
|
-
|
|
335
|
+
...parseDateTime(this.getProperty('value')),
|
|
336
|
+
withTime: this.getProperty('with-time'),
|
|
350
337
|
open: false,
|
|
351
338
|
};
|
|
352
|
-
|
|
353
|
-
else {
|
|
354
|
-
this._state = {
|
|
355
|
-
...components,
|
|
356
|
-
withTime,
|
|
357
|
-
open: false,
|
|
358
|
-
};
|
|
359
|
-
}
|
|
339
|
+
this._initialized = true;
|
|
360
340
|
this.syncFormValue();
|
|
361
341
|
}
|
|
362
342
|
updateState(updates, forceSync = false) {
|
|
@@ -367,24 +347,26 @@ this.syncFormValue();
|
|
|
367
347
|
}
|
|
368
348
|
}
|
|
369
349
|
syncFormValue() {
|
|
370
|
-
const
|
|
350
|
+
const formValue = this.getFormValue();
|
|
371
351
|
const currentValue = this.getProperty('value');
|
|
372
|
-
if (
|
|
373
|
-
|
|
374
|
-
|
|
352
|
+
if (formValue !== currentValue) {
|
|
353
|
+
this._syncing = true;
|
|
354
|
+
try {
|
|
355
|
+
this.setProperty('value', formValue || null);
|
|
375
356
|
}
|
|
376
|
-
|
|
377
|
-
this.
|
|
357
|
+
finally {
|
|
358
|
+
this._syncing = false;
|
|
378
359
|
}
|
|
379
360
|
}
|
|
380
361
|
}
|
|
381
362
|
handleTimeInputChange(hour, minute) {
|
|
382
363
|
if (!this.hasDate())
|
|
383
364
|
return;
|
|
384
|
-
const components = { ...this.getComponents(), hour, minute };
|
|
365
|
+
const components = { ...this.getComponents(), hour, minute, second: 0, epoch: undefined };
|
|
385
366
|
this.updateState(components, true);
|
|
386
367
|
this.emitChangeEvent(components, 'time-change');
|
|
387
368
|
this.updateTimeSummary();
|
|
369
|
+
this.revealValidity();
|
|
388
370
|
}
|
|
389
371
|
updateTimeSummary(summary = this.shadowRoot?.querySelector('.time-summary')) {
|
|
390
372
|
if (!summary)
|
|
@@ -398,19 +380,22 @@ iso.textContent = '';
|
|
|
398
380
|
return;
|
|
399
381
|
}
|
|
400
382
|
const locale = getEffectiveLocale(this, this.getProperty('locale')) || undefined;
|
|
401
|
-
const date
|
|
402
|
-
const day = new Intl.DateTimeFormat(locale, { weekday: 'short', month: 'short', day: 'numeric' }).format(date);
|
|
403
|
-
const time = new Intl.DateTimeFormat(locale, { hour: '2-digit', minute: '2-digit', hourCycle: 'h23' }).format(date);
|
|
383
|
+
const { date, timeZone } = displayDate(c, !!this.getProperty('native'));
|
|
384
|
+
const day = new Intl.DateTimeFormat(locale, { weekday: 'short', month: 'short', day: 'numeric', timeZone }).format(date);
|
|
385
|
+
const time = new Intl.DateTimeFormat(locale, { hour: '2-digit', minute: '2-digit', hourCycle: 'h23', timeZone }).format(date);
|
|
404
386
|
text.textContent = `${day} · ${time}`;
|
|
405
387
|
iso.textContent = componentsToLocalValue(c, true) ?? '';
|
|
406
388
|
}
|
|
407
389
|
emitChangeEvent(components, source) {
|
|
408
|
-
const
|
|
390
|
+
const value = components ? this.outputValue(components) : null;
|
|
409
391
|
const localValue = components ? componentsToLocalValue(components, this._state.withTime) : null;
|
|
410
|
-
const
|
|
392
|
+
const effective = components && effectiveComponents(components, this._state.withTime);
|
|
393
|
+
const milliseconds = effective
|
|
394
|
+
? effective.epoch ?? componentsToDateObject(effective)?.getTime() ?? null
|
|
395
|
+
: null;
|
|
411
396
|
const formatted = components ? this.getFormattedValue(components) : null;
|
|
412
397
|
const detail = {
|
|
413
|
-
value
|
|
398
|
+
value,
|
|
414
399
|
localValue,
|
|
415
400
|
milliseconds,
|
|
416
401
|
formatted,
|
|
@@ -451,16 +436,26 @@ get max() { return this.getProperty('max'); }
|
|
|
451
436
|
set max(v) { this.setProperty('max', v ?? ''); }
|
|
452
437
|
get withTime() { return this.getProperty('with-time'); }
|
|
453
438
|
set withTime(v) { this.setProperty('with-time', v); }
|
|
439
|
+
get native() { return this.getProperty('native'); }
|
|
440
|
+
set native(v) { this.setProperty('native', v); }
|
|
441
|
+
get error() { return this.getProperty('error'); }
|
|
442
|
+
set error(v) { this.setProperty('error', v); }
|
|
454
443
|
get value() {
|
|
444
|
+
if (this._initialized)
|
|
455
445
|
return this.getProperty('value') || null;
|
|
446
|
+
const parsed = parseDateTime(this.getProperty('value'));
|
|
447
|
+
return parsed && componentsToOutputValue(parsed, !!this.getProperty('with-time'), !!this.getProperty('native'));
|
|
456
448
|
}
|
|
457
449
|
set value(val) {
|
|
458
450
|
if (val === null || val === undefined || val === '') {
|
|
459
451
|
this.setProperty('value', null);
|
|
460
452
|
}
|
|
453
|
+
else if (typeof val === 'string') {
|
|
454
|
+
this.setProperty('value', val);
|
|
455
|
+
}
|
|
461
456
|
else {
|
|
462
|
-
const
|
|
463
|
-
this.setProperty('value',
|
|
457
|
+
const date = new Date(val);
|
|
458
|
+
this.setProperty('value', isNaN(date.getTime()) ? null : date.toISOString());
|
|
464
459
|
}
|
|
465
460
|
}
|
|
466
461
|
clear() {
|
|
@@ -472,6 +467,8 @@ if (this.getProperty('disabled'))
|
|
|
472
467
|
classes.push('disabled');
|
|
473
468
|
if (this.getProperty('required'))
|
|
474
469
|
classes.push('required');
|
|
470
|
+
if (this.getProperty('error'))
|
|
471
|
+
classes.push('error');
|
|
475
472
|
if (this._state.open)
|
|
476
473
|
classes.push('open');
|
|
477
474
|
return classes.join(' ');
|
|
@@ -494,7 +491,7 @@ stub.setAttribute('aria-labelledby', `date-picker-label-${getElementHash(this)}`
|
|
|
494
491
|
}
|
|
495
492
|
stub.addEventListener('keydown', (e) => {
|
|
496
493
|
const ke = e;
|
|
497
|
-
if (this._state.open)
|
|
494
|
+
if (this._state.open || e.target !== stub)
|
|
498
495
|
return;
|
|
499
496
|
if (ke.key === 'Enter' || ke.key === ' ') {
|
|
500
497
|
ke.preventDefault();
|
|
@@ -590,7 +587,7 @@ const contentWrapper = document.createElement('div');
|
|
|
590
587
|
contentWrapper.className = 'calendar-content';
|
|
591
588
|
const calendar = document.createElement('ty-calendar');
|
|
592
589
|
if (this._state.year && this._state.month && this._state.day) {
|
|
593
|
-
calendar.setAttribute('year', this._state.year.
|
|
590
|
+
calendar.setAttribute('year', String(this._state.year).padStart(4, '0'));
|
|
594
591
|
calendar.setAttribute('month', this._state.month.toString());
|
|
595
592
|
calendar.setAttribute('day', this._state.day.toString());
|
|
596
593
|
}
|
|
@@ -604,8 +601,8 @@ if (min)
|
|
|
604
601
|
calendar.setAttribute('min', min);
|
|
605
602
|
if (max)
|
|
606
603
|
calendar.setAttribute('max', max);
|
|
607
|
-
const flavor = this.
|
|
608
|
-
if (flavor
|
|
604
|
+
const flavor = this.calendarFlavor();
|
|
605
|
+
if (flavor)
|
|
609
606
|
calendar.setAttribute('flavor', flavor);
|
|
610
607
|
calendar.addEventListener('change', (e) => this.handleCalendarChange(e));
|
|
611
608
|
contentWrapper.appendChild(calendar);
|
|
@@ -613,11 +610,18 @@ if (this._state.withTime) {
|
|
|
613
610
|
contentWrapper.appendChild(this.renderTimeSection());
|
|
614
611
|
}
|
|
615
612
|
dialog.appendChild(contentWrapper);
|
|
616
|
-
|
|
617
|
-
this.
|
|
618
|
-
|
|
613
|
+
new MutationObserver(() => {
|
|
614
|
+
if (this._state.open && !dialog.open && dialog.isConnected && this.isConnected)
|
|
615
|
+
this.closeDropdown();
|
|
616
|
+
}).observe(dialog, { attributes: true, attributeFilter: ['open'] });
|
|
619
617
|
return dialog;
|
|
620
618
|
}
|
|
619
|
+
calendarFlavor() {
|
|
620
|
+
if (this.getProperty('error'))
|
|
621
|
+
return 'danger';
|
|
622
|
+
const flavor = this.getProperty('flavor');
|
|
623
|
+
return flavor && flavor !== 'default' ? flavor : null;
|
|
624
|
+
}
|
|
621
625
|
renderNativeInput() {
|
|
622
626
|
const wrapper = document.createElement('div');
|
|
623
627
|
wrapper.className = 'dropdown-wrapper';
|
|
@@ -629,21 +633,8 @@ stub.setAttribute('disabled', 'true');
|
|
|
629
633
|
}
|
|
630
634
|
const input = document.createElement('input');
|
|
631
635
|
input.className = 'native-date-input';
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
input.disabled = true;
|
|
635
|
-
if (this.getProperty('required'))
|
|
636
|
-
input.required = true;
|
|
637
|
-
const minBound = this.getProperty('min');
|
|
638
|
-
const maxBound = this.getProperty('max');
|
|
639
|
-
if (minBound)
|
|
640
|
-
input.min = this._state.withTime ? `${minBound}T00:00` : minBound;
|
|
641
|
-
if (maxBound)
|
|
642
|
-
input.max = this._state.withTime ? `${maxBound}T23:59` : maxBound;
|
|
643
|
-
const localValue = componentsToLocalValue(this.getComponents(), this._state.withTime);
|
|
644
|
-
if (localValue) {
|
|
645
|
-
input.value = localValue;
|
|
646
|
-
}
|
|
636
|
+
this.syncNativeInput(input);
|
|
637
|
+
const localValue = input.value;
|
|
647
638
|
const placeholder = this.getProperty('placeholder') || 'Select date...';
|
|
648
639
|
const formattedValue = this.getFormattedValue();
|
|
649
640
|
const placeholderEl = document.createElement('span');
|
|
@@ -652,13 +643,17 @@ placeholderEl.textContent = formattedValue || placeholder;
|
|
|
652
643
|
input.addEventListener('change', () => {
|
|
653
644
|
if (!input.value) {
|
|
654
645
|
this.clearValue();
|
|
655
|
-
return;
|
|
656
646
|
}
|
|
657
|
-
|
|
647
|
+
else {
|
|
648
|
+
const parsed = parseDateTime(input.value);
|
|
658
649
|
if (parsed) {
|
|
659
|
-
this.
|
|
660
|
-
|
|
650
|
+
const { hour, minute, second } = this._state.withTime ? parsed : this._state;
|
|
651
|
+
const components = { ...parsed, hour, minute, second, epoch: undefined };
|
|
652
|
+
this.updateState(components, true);
|
|
653
|
+
this.emitChangeEvent(components, 'selection');
|
|
661
654
|
}
|
|
655
|
+
}
|
|
656
|
+
this.revealValidity();
|
|
662
657
|
});
|
|
663
658
|
const startSlot = document.createElement('slot');
|
|
664
659
|
startSlot.name = 'start';
|
|
@@ -684,6 +679,23 @@ stub.appendChild(iconContainer);
|
|
|
684
679
|
wrapper.appendChild(stub);
|
|
685
680
|
return wrapper;
|
|
686
681
|
}
|
|
682
|
+
syncNativeInput(input) {
|
|
683
|
+
const withTime = this._state.withTime;
|
|
684
|
+
input.type = withTime ? 'datetime-local' : 'date';
|
|
685
|
+
input.disabled = !!this.getProperty('disabled');
|
|
686
|
+
input.required = !!this.getProperty('required');
|
|
687
|
+
const min = toISODay(this.getProperty('min'));
|
|
688
|
+
const max = toISODay(this.getProperty('max'));
|
|
689
|
+
if (min)
|
|
690
|
+
input.min = withTime ? `${min}T00:00` : min;
|
|
691
|
+
else
|
|
692
|
+
input.removeAttribute('min');
|
|
693
|
+
if (max)
|
|
694
|
+
input.max = withTime ? `${max}T23:59` : max;
|
|
695
|
+
else
|
|
696
|
+
input.removeAttribute('max');
|
|
697
|
+
input.value = componentsToLocalValue(this.getComponents(), withTime) ?? '';
|
|
698
|
+
}
|
|
687
699
|
calculateCalendarPosition() {
|
|
688
700
|
if (!this.shadowRoot)
|
|
689
701
|
return;
|
|
@@ -750,6 +762,8 @@ this.shadowRoot.innerHTML = '';
|
|
|
750
762
|
const container = this.renderContainer();
|
|
751
763
|
container.appendChild(this.renderNativeInput());
|
|
752
764
|
this.shadowRoot.appendChild(container);
|
|
765
|
+
this.syncErrorLine();
|
|
766
|
+
this.updateValidity();
|
|
753
767
|
return;
|
|
754
768
|
}
|
|
755
769
|
const existingDialog = this.shadowRoot.querySelector('.calendar-dialog');
|
|
@@ -759,6 +773,7 @@ this.updateDisplay();
|
|
|
759
773
|
this.calculateCalendarPosition();
|
|
760
774
|
return;
|
|
761
775
|
}
|
|
776
|
+
const hadFocus = !!this.shadowRoot.activeElement;
|
|
762
777
|
this.shadowRoot.innerHTML = '';
|
|
763
778
|
const container = this.renderContainer();
|
|
764
779
|
const wrapper = document.createElement('div');
|
|
@@ -767,7 +782,33 @@ wrapper.appendChild(this.renderStub());
|
|
|
767
782
|
wrapper.appendChild(this.renderCalendarDropdown());
|
|
768
783
|
container.appendChild(wrapper);
|
|
769
784
|
this.shadowRoot.appendChild(container);
|
|
785
|
+
this.syncErrorLine();
|
|
770
786
|
this.setupEventListeners();
|
|
787
|
+
this.updateValidity();
|
|
788
|
+
if (hadFocus)
|
|
789
|
+
this.focus({ preventScroll: true });
|
|
790
|
+
}
|
|
791
|
+
syncErrorLine() {
|
|
792
|
+
const container = this.shadowRoot?.querySelector('.dropdown-container');
|
|
793
|
+
if (!container)
|
|
794
|
+
return;
|
|
795
|
+
const error = this.getProperty('error');
|
|
796
|
+
const errorId = `date-picker-error-${getElementHash(this)}`;
|
|
797
|
+
let line = container.querySelector(':scope > .error-message');
|
|
798
|
+
if (error) {
|
|
799
|
+
if (!line) {
|
|
800
|
+
line = document.createElement('div');
|
|
801
|
+
line.className = 'error-message';
|
|
802
|
+
line.id = errorId;
|
|
803
|
+
container.appendChild(line);
|
|
804
|
+
}
|
|
805
|
+
line.textContent = error;
|
|
806
|
+
this.focusTarget()?.setAttribute('aria-describedby', errorId);
|
|
807
|
+
}
|
|
808
|
+
else {
|
|
809
|
+
line?.remove();
|
|
810
|
+
this.focusTarget()?.removeAttribute('aria-describedby');
|
|
811
|
+
}
|
|
771
812
|
}
|
|
772
813
|
updateDisplay() {
|
|
773
814
|
if (!this.shadowRoot)
|
|
@@ -786,23 +827,26 @@ const clearButton = this.shadowRoot.querySelector('.stub-clear');
|
|
|
786
827
|
if (clearButton) {
|
|
787
828
|
clearButton.style.display = (clearable && hasValue && !isDisabled) ? '' : 'none';
|
|
788
829
|
}
|
|
830
|
+
const stub = this.shadowRoot.querySelector('.date-picker-stub');
|
|
831
|
+
if (stub)
|
|
832
|
+
stub.className = this.buildStubClasses();
|
|
833
|
+
this.syncErrorLine();
|
|
789
834
|
if (isMobileTouch()) {
|
|
790
835
|
const nativeInput = this.shadowRoot.querySelector('.native-date-input');
|
|
791
|
-
if (nativeInput)
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
}
|
|
836
|
+
if (nativeInput)
|
|
837
|
+
this.syncNativeInput(nativeInput);
|
|
838
|
+
stub?.toggleAttribute('disabled', !!isDisabled);
|
|
795
839
|
return;
|
|
796
840
|
}
|
|
797
841
|
const calendar = this.shadowRoot.querySelector('ty-calendar');
|
|
798
842
|
if (calendar && hasValue) {
|
|
799
|
-
calendar.setAttribute('year', this._state.year.
|
|
843
|
+
calendar.setAttribute('year', String(this._state.year).padStart(4, '0'));
|
|
800
844
|
calendar.setAttribute('month', this._state.month.toString());
|
|
801
845
|
calendar.setAttribute('day', this._state.day.toString());
|
|
802
846
|
}
|
|
803
847
|
if (calendar) {
|
|
804
|
-
const flavor = this.
|
|
805
|
-
if (flavor
|
|
848
|
+
const flavor = this.calendarFlavor();
|
|
849
|
+
if (flavor)
|
|
806
850
|
calendar.setAttribute('flavor', flavor);
|
|
807
851
|
else
|
|
808
852
|
calendar.removeAttribute('flavor');
|
|
@@ -844,7 +888,7 @@ event.preventDefault();
|
|
|
844
888
|
const dialog = this.shadowRoot?.querySelector('.calendar-dialog');
|
|
845
889
|
if (this._state.open && (!dialog || !dialog.open)) {
|
|
846
890
|
this.updateState({ open: false }, true);
|
|
847
|
-
unlockScroll(`date-picker-${this
|
|
891
|
+
unlockScroll(`date-picker-${getElementHash(this)}`);
|
|
848
892
|
}
|
|
849
893
|
const disabled = this.getProperty('disabled');
|
|
850
894
|
if (!disabled && Date.now() - this._closeTimestamp > 300) {
|
|
@@ -858,6 +902,8 @@ month: undefined,
|
|
|
858
902
|
day: undefined,
|
|
859
903
|
hour: undefined,
|
|
860
904
|
minute: undefined,
|
|
905
|
+
second: undefined,
|
|
906
|
+
epoch: undefined,
|
|
861
907
|
}, true);
|
|
862
908
|
this.value = null;
|
|
863
909
|
this.emitChangeEvent(null, 'clear');
|
|
@@ -867,6 +913,11 @@ handleClearClick(event) {
|
|
|
867
913
|
event.preventDefault();
|
|
868
914
|
event.stopPropagation();
|
|
869
915
|
this.clearValue();
|
|
916
|
+
const active = document.activeElement;
|
|
917
|
+
if (this.matches(':focus-within') || !active || active === document.body) {
|
|
918
|
+
this.shadowRoot?.querySelector('.native-date-input')?.focus({ preventScroll: true });
|
|
919
|
+
}
|
|
920
|
+
this.revealValidity();
|
|
870
921
|
}
|
|
871
922
|
handleCalendarChange(event) {
|
|
872
923
|
event.preventDefault();
|
|
@@ -882,9 +933,12 @@ month: dayContext.month,
|
|
|
882
933
|
day: dayContext.dayInMonth,
|
|
883
934
|
hour: this._state.hour,
|
|
884
935
|
minute: this._state.minute,
|
|
936
|
+
second: this._state.second,
|
|
937
|
+
epoch: undefined,
|
|
885
938
|
};
|
|
886
939
|
this.updateState(newComponents, true);
|
|
887
940
|
this.emitChangeEvent(newComponents, 'selection');
|
|
941
|
+
this.revealValidity();
|
|
888
942
|
if (!this._state.withTime) {
|
|
889
943
|
this.closeDropdown();
|
|
890
944
|
}
|
|
@@ -938,9 +992,15 @@ this.render();
|
|
|
938
992
|
requestAnimationFrame(() => {
|
|
939
993
|
if (!this.shadowRoot)
|
|
940
994
|
return;
|
|
995
|
+
if (!this._state.open || !this.isConnected)
|
|
996
|
+
return;
|
|
997
|
+
if (this.shadowRoot.querySelector('.date-picker-stub')?.checkVisibility() === false) {
|
|
998
|
+
this.closeDropdown();
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
941
1001
|
const dialog = this.shadowRoot.querySelector('.calendar-dialog');
|
|
942
1002
|
if (dialog) {
|
|
943
|
-
const pickerId = `date-picker-${this
|
|
1003
|
+
const pickerId = `date-picker-${getElementHash(this)}`;
|
|
944
1004
|
lockScroll(pickerId);
|
|
945
1005
|
dialog.showModal();
|
|
946
1006
|
this.calculateCalendarPosition();
|
|
@@ -959,7 +1019,7 @@ closeDropdown() {
|
|
|
959
1019
|
if (!this._state.open)
|
|
960
1020
|
return;
|
|
961
1021
|
this._closeTimestamp = Date.now();
|
|
962
|
-
const pickerId = `date-picker-${this
|
|
1022
|
+
const pickerId = `date-picker-${getElementHash(this)}`;
|
|
963
1023
|
this.updateState({ open: false }, true);
|
|
964
1024
|
unlockScroll(pickerId);
|
|
965
1025
|
if (this.shadowRoot) {
|
|
@@ -974,6 +1034,7 @@ stubEl.setAttribute('aria-expanded', 'false');
|
|
|
974
1034
|
}
|
|
975
1035
|
this.dispatchEvent(new CustomEvent('close'));
|
|
976
1036
|
this.render();
|
|
1037
|
+
this.focus();
|
|
977
1038
|
}
|
|
978
1039
|
cleanup() {
|
|
979
1040
|
if (this._clickListener) {
|
|
@@ -989,7 +1050,7 @@ dialog.removeEventListener('click', this._dialogClickListener);
|
|
|
989
1050
|
}
|
|
990
1051
|
}
|
|
991
1052
|
if (this._state.open) {
|
|
992
|
-
const pickerId = `date-picker-${this
|
|
1053
|
+
const pickerId = `date-picker-${getElementHash(this)}`;
|
|
993
1054
|
unlockScroll(pickerId);
|
|
994
1055
|
}
|
|
995
1056
|
this._clickListener = undefined;
|
|
@@ -1062,6 +1123,11 @@ type: 'boolean',
|
|
|
1062
1123
|
visual: true,
|
|
1063
1124
|
default: false
|
|
1064
1125
|
},
|
|
1126
|
+
error: {
|
|
1127
|
+
type: 'string',
|
|
1128
|
+
visual: true,
|
|
1129
|
+
default: ''
|
|
1130
|
+
},
|
|
1065
1131
|
format: {
|
|
1066
1132
|
type: 'string',
|
|
1067
1133
|
visual: true,
|
|
@@ -1092,6 +1158,11 @@ default: null
|
|
|
1092
1158
|
type: 'boolean',
|
|
1093
1159
|
visual: true,
|
|
1094
1160
|
default: false
|
|
1161
|
+
},
|
|
1162
|
+
native: {
|
|
1163
|
+
type: 'boolean',
|
|
1164
|
+
visual: true,
|
|
1165
|
+
default: false
|
|
1095
1166
|
}
|
|
1096
1167
|
};
|
|
1097
1168
|
TyDatePicker.formAssociated = true;
|