@haiilo/catalyst 10.4.0 → 10.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/catalyst/catalyst.css +2 -2
- package/dist/catalyst/catalyst.esm.js +1 -1
- package/dist/catalyst/catalyst.esm.js.map +1 -1
- package/dist/catalyst/index.esm.js +1 -1
- package/dist/catalyst/index.esm.js.map +1 -1
- package/dist/catalyst/p-2c8ac8cf.js +2 -0
- package/dist/catalyst/p-2c8ac8cf.js.map +1 -0
- package/dist/catalyst/p-b2ec6eb3.entry.js +10 -0
- package/dist/catalyst/p-b2ec6eb3.entry.js.map +1 -0
- package/dist/catalyst/scss/_variables.scss +0 -1
- package/dist/catalyst/scss/core/_form.scss +2 -2
- package/dist/cjs/{cat-alert_28.cjs.entry.js → cat-alert_29.cjs.entry.js} +387 -218
- package/dist/cjs/cat-alert_29.cjs.entry.js.map +1 -0
- package/dist/cjs/catalyst.cjs.js +1 -1
- package/dist/cjs/index.cjs.js +4 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{of-45281229.js → of-f2844da8.js} +12 -4
- package/dist/cjs/of-f2844da8.js.map +1 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/cat-button/cat-button.css +12 -2
- package/dist/collection/components/cat-checkbox/cat-checkbox.css +2 -1
- package/dist/collection/components/cat-date/cat-date.css +2 -96
- package/dist/collection/components/cat-date/cat-date.js +77 -245
- package/dist/collection/components/cat-date/cat-date.js.map +1 -1
- package/dist/collection/components/cat-date/cat-date.spec.js +2 -1
- package/dist/collection/components/cat-date/cat-date.spec.js.map +1 -1
- package/dist/collection/components/cat-date-inline/cat-date-inline.css +166 -0
- package/dist/collection/components/cat-date-inline/cat-date-inline.e2e.js +11 -0
- package/dist/collection/components/cat-date-inline/cat-date-inline.e2e.js.map +1 -0
- package/dist/collection/components/cat-date-inline/cat-date-inline.js +505 -0
- package/dist/collection/components/cat-date-inline/cat-date-inline.js.map +1 -0
- package/dist/collection/components/cat-date-inline/cat-date-inline.spec.js +16 -0
- package/dist/collection/components/cat-date-inline/cat-date-inline.spec.js.map +1 -0
- package/dist/collection/components/{cat-date → cat-date-inline}/cat-date-locale.js +22 -1
- package/dist/collection/components/cat-date-inline/cat-date-locale.js.map +1 -0
- package/dist/collection/components/cat-date-inline/cat-date-math.js.map +1 -0
- package/dist/collection/components/cat-datepicker/cat-datepicker.js +2 -2
- package/dist/collection/components/cat-datepicker-inline/cat-datepicker-inline.js +2 -2
- package/dist/collection/components/cat-dropdown/cat-dropdown.js +29 -2
- package/dist/collection/components/cat-dropdown/cat-dropdown.js.map +1 -1
- package/dist/collection/components/cat-form-group/cat-form-group.js +4 -1
- package/dist/collection/components/cat-form-group/cat-form-group.js.map +1 -1
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js +6 -0
- package/dist/collection/components/cat-i18n/cat-i18n-registry.js.map +1 -1
- package/dist/collection/components/cat-icon/cat-icon-registry.js +4 -2
- package/dist/collection/components/cat-icon/cat-icon-registry.js.map +1 -1
- package/dist/collection/components/cat-icon/cat-icon.js +1 -1
- package/dist/collection/components/cat-input/cat-input.js +4 -4
- package/dist/collection/components/cat-notification/cat-notification.js +3 -0
- package/dist/collection/components/cat-notification/cat-notification.js.map +1 -1
- package/dist/collection/components/cat-pagination/cat-pagination.js +2 -2
- package/dist/collection/components/cat-radio/cat-radio.css +1 -1
- package/dist/collection/components/cat-radio/cat-radio.js +1 -1
- package/dist/collection/components/cat-radio-group/cat-radio-group.js +1 -1
- package/dist/collection/components/cat-scrollable/cat-scrollable.js +3 -3
- package/dist/collection/components/cat-select/cat-select.js +5 -5
- package/dist/collection/components/cat-select-demo/cat-select-demo.js +1 -1
- package/dist/collection/components/cat-skeleton/cat-skeleton.js +1 -1
- package/dist/collection/components/cat-spinner/cat-spinner.js +2 -2
- package/dist/collection/components/cat-tab/cat-tab.js +1 -1
- package/dist/collection/components/cat-tabs/cat-tabs.js +1 -1
- package/dist/collection/components/cat-textarea/cat-textarea.js +3 -3
- package/dist/collection/components/cat-time/cat-time-locale.js +3 -0
- package/dist/collection/components/cat-time/cat-time-locale.js.map +1 -1
- package/dist/collection/components/cat-time/cat-time.js +39 -8
- package/dist/collection/components/cat-time/cat-time.js.map +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.css +1 -1
- package/dist/collection/components/cat-toggle/cat-toggle.js +1 -1
- package/dist/collection/components/cat-tooltip/cat-tooltip.js +7 -2
- package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
- package/dist/collection/scss/_variables.scss +0 -1
- package/dist/collection/scss/core/_form.scss +2 -2
- package/dist/components/cat-button2.js +1 -1
- package/dist/components/cat-button2.js.map +1 -1
- package/dist/components/cat-checkbox2.js +1 -1
- package/dist/components/cat-checkbox2.js.map +1 -1
- package/dist/components/cat-date-inline.d.ts +11 -0
- package/dist/components/cat-date-inline.js +8 -0
- package/dist/components/cat-date-inline.js.map +1 -0
- package/dist/components/cat-date-inline2.js +386 -0
- package/dist/components/cat-date-inline2.js.map +1 -0
- package/dist/components/cat-date.js +83 -283
- package/dist/components/cat-date.js.map +1 -1
- package/dist/components/cat-datepicker-inline.js +2 -2
- package/dist/components/cat-datepicker.js +2 -2
- package/dist/components/cat-dropdown2.js +8 -2
- package/dist/components/cat-dropdown2.js.map +1 -1
- package/dist/components/cat-form-group.js +1 -1
- package/dist/components/cat-form-group.js.map +1 -1
- package/dist/components/cat-i18n-registry.js +6 -0
- package/dist/components/cat-i18n-registry.js.map +1 -1
- package/dist/components/cat-icon-registry.js +4 -2
- package/dist/components/cat-icon-registry.js.map +1 -1
- package/dist/components/cat-icon2.js +1 -1
- package/dist/components/cat-input2.js +4 -4
- package/dist/components/cat-pagination.js +2 -2
- package/dist/components/cat-radio-group.js +1 -1
- package/dist/components/cat-radio.js +2 -2
- package/dist/components/cat-radio.js.map +1 -1
- package/dist/components/cat-scrollable2.js +8 -6
- package/dist/components/cat-scrollable2.js.map +1 -1
- package/dist/components/cat-select-demo.js +3 -3
- package/dist/components/cat-select-demo.js.map +1 -1
- package/dist/components/cat-select2.js.map +1 -1
- package/dist/components/cat-skeleton2.js +1 -1
- package/dist/components/cat-spinner2.js +2 -2
- package/dist/components/cat-tab.js +1 -1
- package/dist/components/cat-tabs.js +1 -1
- package/dist/components/cat-textarea.js +3 -3
- package/dist/components/cat-time.js +37 -8
- package/dist/components/cat-time.js.map +1 -1
- package/dist/components/cat-toggle.js +2 -2
- package/dist/components/cat-toggle.js.map +1 -1
- package/dist/components/cat-tooltip.js +2 -2
- package/dist/components/cat-tooltip.js.map +1 -1
- package/dist/components/floating-ui.dom.esm.js +38 -30
- package/dist/components/floating-ui.dom.esm.js.map +1 -1
- package/dist/components/from.js +1 -1
- package/dist/components/from.js.map +1 -1
- package/dist/components/index.js +3 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/of.js.map +1 -1
- package/dist/esm/{cat-alert_28.entry.js → cat-alert_29.entry.js} +387 -219
- package/dist/esm/cat-alert_29.entry.js.map +1 -0
- package/dist/esm/catalyst.js +1 -1
- package/dist/esm/index.js +5 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{of-19888f3b.js → of-53334b95.js} +12 -4
- package/dist/esm/of-53334b95.js.map +1 -0
- package/dist/types/components/cat-date/cat-date.d.ts +11 -31
- package/dist/types/components/cat-date-inline/cat-date-inline.d.ts +81 -0
- package/dist/types/components/{cat-date → cat-date-inline}/cat-date-locale.d.ts +5 -0
- package/dist/types/components/cat-dropdown/cat-dropdown.d.ts +9 -0
- package/dist/types/components/cat-form-group/cat-form-group.d.ts +3 -0
- package/dist/types/components/cat-i18n/cat-i18n-registry.d.ts +6 -0
- package/dist/types/components/cat-icon/cat-icon-registry.d.ts +1 -0
- package/dist/types/components/cat-notification/cat-notification.d.ts +3 -0
- package/dist/types/components/cat-time/cat-time-locale.d.ts +1 -0
- package/dist/types/components/cat-time/cat-time.d.ts +6 -1
- package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +5 -0
- package/dist/types/components.d.ts +209 -5
- package/package.json +2 -2
- package/dist/catalyst/p-81800b65.js +0 -2
- package/dist/catalyst/p-81800b65.js.map +0 -1
- package/dist/catalyst/p-8a1d505d.entry.js +0 -10
- package/dist/catalyst/p-8a1d505d.entry.js.map +0 -1
- package/dist/cjs/cat-alert_28.cjs.entry.js.map +0 -1
- package/dist/cjs/of-45281229.js.map +0 -1
- package/dist/collection/components/cat-date/cat-date-locale.js.map +0 -1
- package/dist/collection/components/cat-date/cat-date-math.js.map +0 -1
- package/dist/esm/cat-alert_28.entry.js.map +0 -1
- package/dist/esm/of-19888f3b.js.map +0 -1
- /package/dist/collection/components/{cat-date → cat-date-inline}/cat-date-math.js +0 -0
- /package/dist/types/components/{cat-date → cat-date-inline}/cat-date-math.d.ts +0 -0
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
|
+
import { getLocale } from "../cat-date-inline/cat-date-locale";
|
|
3
|
+
import { clampDate } from "../cat-date-inline/cat-date-math";
|
|
2
4
|
import { catI18nRegistry as i18n } from "../cat-i18n/cat-i18n-registry";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A date input component to select a date from a calendar in a dropdown.
|
|
7
|
+
*/
|
|
5
8
|
export class CatDate {
|
|
6
9
|
constructor() {
|
|
7
10
|
this.language = i18n.getLocale();
|
|
8
11
|
this.locale = getLocale(this.language);
|
|
9
|
-
this.isOpen = false;
|
|
10
|
-
// additonally store the focus date to ensure correct focus after potential re-render
|
|
11
|
-
this.focusDate = null;
|
|
12
12
|
this.hasSlottedLabel = false;
|
|
13
13
|
this.hasSlottedHint = false;
|
|
14
|
-
this.viewDate = this.now;
|
|
15
|
-
this.selectionDate = null;
|
|
16
14
|
this.requiredMarker = 'optional';
|
|
17
15
|
this.horizontal = false;
|
|
18
16
|
this.autoComplete = undefined;
|
|
@@ -38,29 +36,24 @@ export class CatDate {
|
|
|
38
36
|
this.nativeAttributes = undefined;
|
|
39
37
|
this.placement = 'bottom-end';
|
|
40
38
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
get minDate() {
|
|
46
|
-
const [y, m, d] = this.min?.split('-').map(Number) || [];
|
|
47
|
-
return this.min ? new Date(y, m - 1, d) : null;
|
|
48
|
-
}
|
|
49
|
-
get now() {
|
|
50
|
-
const date = new Date();
|
|
51
|
-
return new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
|
39
|
+
onMinChanged(min, oldMin) {
|
|
40
|
+
if (min !== oldMin) {
|
|
41
|
+
this.reclamp('min', min);
|
|
42
|
+
}
|
|
52
43
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return all ? new Date(Number(year), Number(month) - 1, Number(day)) : null;
|
|
44
|
+
onMaxChanged(max, oldMax) {
|
|
45
|
+
if (max !== oldMax) {
|
|
46
|
+
this.reclamp('max', max);
|
|
47
|
+
}
|
|
58
48
|
}
|
|
59
|
-
|
|
49
|
+
get inputValue() {
|
|
60
50
|
const [match, year, month, day] = this.value?.match(/^(\d{4})-(\d{2})-(\d{2})/) ?? [];
|
|
61
51
|
if (match) {
|
|
62
|
-
|
|
52
|
+
const date = new Date(Number(year), Number(month) - 1, Number(day));
|
|
53
|
+
const format = new Intl.DateTimeFormat(this.language, { year: 'numeric', month: '2-digit', day: '2-digit' });
|
|
54
|
+
return format.format(date);
|
|
63
55
|
}
|
|
56
|
+
return '';
|
|
64
57
|
}
|
|
65
58
|
componentWillRender() {
|
|
66
59
|
this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
|
|
@@ -77,66 +70,6 @@ export class CatDate {
|
|
|
77
70
|
datePattern: [p1, p2, p3]
|
|
78
71
|
});
|
|
79
72
|
}
|
|
80
|
-
componentDidRender() {
|
|
81
|
-
if (this.focusDate) {
|
|
82
|
-
this.hostElement.shadowRoot
|
|
83
|
-
?.querySelector(`[data-date="${this.toLocalISO(this.focusDate)}"]`)
|
|
84
|
-
?.doFocus();
|
|
85
|
-
this.focusDate = null;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
onOpen() {
|
|
89
|
-
this.isOpen = true;
|
|
90
|
-
this.setAriaLive('');
|
|
91
|
-
const viewDate = this.selectionDate
|
|
92
|
-
? new Date(this.selectionDate.getFullYear(), this.selectionDate.getMonth(), 1)
|
|
93
|
-
: this.now;
|
|
94
|
-
this.viewDate = clampDate(this.minDate, viewDate, this.maxDate);
|
|
95
|
-
}
|
|
96
|
-
onClose() {
|
|
97
|
-
this.isOpen = false;
|
|
98
|
-
}
|
|
99
|
-
onKeyDown(e) {
|
|
100
|
-
if (!this.isOpen || !['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(e.key)) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const focused = this.focusedDate;
|
|
104
|
-
if (!focused) {
|
|
105
|
-
e.preventDefault();
|
|
106
|
-
this.focus(this.selectionDate || this.now);
|
|
107
|
-
}
|
|
108
|
-
else if (e.key === 'ArrowLeft') {
|
|
109
|
-
e.preventDefault();
|
|
110
|
-
this.focus(e.shiftKey ? addMonth(focused, -1) : addDays(focused, -1));
|
|
111
|
-
}
|
|
112
|
-
else if (e.key === 'ArrowRight') {
|
|
113
|
-
e.preventDefault();
|
|
114
|
-
this.focus(e.shiftKey ? addMonth(focused, 1) : addDays(focused, 1));
|
|
115
|
-
}
|
|
116
|
-
else if (e.key === 'ArrowUp') {
|
|
117
|
-
e.preventDefault();
|
|
118
|
-
this.focus(addDays(focused, -7));
|
|
119
|
-
}
|
|
120
|
-
else if (e.key === 'ArrowDown') {
|
|
121
|
-
e.preventDefault();
|
|
122
|
-
this.focus(addDays(focused, 7));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Select a date in the picker.
|
|
127
|
-
*
|
|
128
|
-
* @param date The date to select.
|
|
129
|
-
*/
|
|
130
|
-
async select(date) {
|
|
131
|
-
const oldValue = this.value;
|
|
132
|
-
const newDate = clampDate(this.minDate, new Date(date.getFullYear(), date.getMonth(), date.getDate()), this.maxDate);
|
|
133
|
-
this.focus(newDate);
|
|
134
|
-
this.selectionDate = newDate;
|
|
135
|
-
this.value = newDate.toISOString();
|
|
136
|
-
if (oldValue !== this.value) {
|
|
137
|
-
this.catChange.emit(this.value);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
73
|
/**
|
|
141
74
|
* Programmatically move focus to the input. Use this method instead of
|
|
142
75
|
* `input.focus()`.
|
|
@@ -161,28 +94,54 @@ export class CatDate {
|
|
|
161
94
|
this.input?.clear();
|
|
162
95
|
}
|
|
163
96
|
render() {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
97
|
+
return (h(Host, { key: 'd588c96f031fc8ab9518d13dfaac730a0d424caa' }, h("cat-input", { key: 'f49f0682e2f2fe3dfcd89477bda91fe46ed44dfa', class: "cat-date-input", ref: el => (this.input = el), requiredMarker: this.requiredMarker, horizontal: this.horizontal, autoComplete: this.autoComplete, clearable: this.clearable, disabled: this.disabled, hint: this.hint, icon: this.icon, iconRight: this.iconRight, identifier: this.identifier, labelHidden: this.labelHidden, name: this.name, placeholder: this.placeholder, textPrefix: this.textPrefix, textSuffix: this.textSuffix, readonly: this.readonly, required: this.required, errors: this.errors, errorUpdate: this.errorUpdate, nativeAttributes: this.nativeAttributes, value: this.inputValue, onCatFocus: e => {
|
|
98
|
+
e.stopPropagation();
|
|
99
|
+
this.catFocus.emit(e.detail);
|
|
100
|
+
}, onCatBlur: e => {
|
|
101
|
+
e.stopPropagation();
|
|
102
|
+
this.onInputBlur(e.detail);
|
|
103
|
+
} }, h("span", { key: '68ef0708d25128b9a52d60c5b1a7b34e0ffb2ef1', slot: "label" }, this.label, h("span", { key: 'ac017335567a4e0059631e7535455d52f61f2e43', class: "label-aria" }, " (", this.locale.formatStr, ")")), h("cat-dropdown", { key: '16a6e95f6e4f6a9b0ddd7716f0b713c8fac3fdff', slot: "addon", placement: this.placement, arrowNavigation: "none", noResize: true, onCatOpen: () => this.dateInline?.resetView() }, h("cat-button", { key: 'cf7f2aaa2c5775b23f3e8826e9b0e722c4ce8be6', slot: "trigger", icon: "$cat:datepicker-calendar", iconOnly: true, class: "cat-date-toggle", disabled: this.disabled, a11yLabel: this.getTriggerA11yLabel() }), h("div", { key: 'f90eef976a3102855801df5ffeee770d45e7eaba', slot: "content" }, h("cat-date-inline", { key: '853b3adee0ea8f9c9b2a1276a10fcaa299044b42', ref: el => (this.dateInline = el), min: this.min, max: this.max, value: this.value, noClear: true, onCatChange: this.onDateChange.bind(this) }))))));
|
|
104
|
+
}
|
|
105
|
+
getTriggerA11yLabel() {
|
|
106
|
+
const date = this.locale.fromLocalISO(this.value);
|
|
107
|
+
return date ? `${this.locale.change}, ${this.locale.toLocalStr(date)}` : this.locale.choose;
|
|
108
|
+
}
|
|
109
|
+
onInputBlur(e) {
|
|
110
|
+
if (!this.input) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const oldValue = this.value;
|
|
114
|
+
const dateParsed = this.parse(this.input.value ?? '');
|
|
115
|
+
const dateMin = this.locale.fromLocalISO(this.min);
|
|
116
|
+
const dateMax = this.locale.fromLocalISO(this.max);
|
|
117
|
+
const date = dateParsed ? clampDate(dateMin, dateParsed, dateMax) : null;
|
|
118
|
+
this.value = date ? this.locale.toLocalISO(date) : undefined;
|
|
119
|
+
if (oldValue !== this.value) {
|
|
120
|
+
if (date) {
|
|
121
|
+
this.dateInline?.select(date);
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
this.dateInline?.clear();
|
|
125
|
+
}
|
|
126
|
+
this.catChange.emit(this.value);
|
|
127
|
+
}
|
|
128
|
+
this.input.value = this.inputValue;
|
|
129
|
+
this.catBlur.emit(e);
|
|
130
|
+
}
|
|
131
|
+
onDateChange(e) {
|
|
132
|
+
e.stopPropagation();
|
|
133
|
+
const oldValue = this.value;
|
|
134
|
+
const date = e.detail ? new Date(e.detail) : null;
|
|
135
|
+
this.value = date ? this.locale.toLocalISO(date) : undefined;
|
|
136
|
+
if (oldValue !== this.value) {
|
|
137
|
+
this.catChange.emit(this.value);
|
|
138
|
+
}
|
|
180
139
|
}
|
|
181
140
|
parse(value) {
|
|
182
141
|
const [, p1, d1, p2, p3] = /(\w+)([^\w]+)(\w+)[^\w]+(\w+)/.exec(this.locale.formatStr) || [];
|
|
183
142
|
const formatParts = [p1, p2, p3];
|
|
184
143
|
const parts = value.split(d1).map(s => Number(s || 'x'));
|
|
185
|
-
let year = parts[formatParts.indexOf('YYYY') || formatParts.indexOf('YY')] || this.now.getFullYear();
|
|
144
|
+
let year = parts[formatParts.indexOf('YYYY') || formatParts.indexOf('YY')] || this.locale.now().getFullYear();
|
|
186
145
|
const month = parts[formatParts.indexOf('MM')];
|
|
187
146
|
const day = parts[formatParts.indexOf('DD')];
|
|
188
147
|
if (!Number.isInteger(month) || !Number.isInteger(day)) {
|
|
@@ -193,104 +152,19 @@ export class CatDate {
|
|
|
193
152
|
}
|
|
194
153
|
return new Date(year, month - 1, day);
|
|
195
154
|
}
|
|
196
|
-
|
|
197
|
-
this.focusDate = clampDate(this.minDate, date, this.maxDate);
|
|
198
|
-
this.viewDate = new Date(this.focusDate.getFullYear(), this.focusDate.getMonth());
|
|
199
|
-
this.hostElement.shadowRoot
|
|
200
|
-
?.querySelector(`[data-date="${this.toLocalISO(this.focusDate)}"]`)
|
|
201
|
-
?.doFocus();
|
|
202
|
-
}
|
|
203
|
-
navigate(direction, period) {
|
|
204
|
-
this.viewDate = new Date(direction === 'prev'
|
|
205
|
-
? period === 'year'
|
|
206
|
-
? this.viewDate.setFullYear(this.viewDate.getFullYear() - 1)
|
|
207
|
-
: this.viewDate.setMonth(this.viewDate.getMonth() - 1)
|
|
208
|
-
: period === 'year'
|
|
209
|
-
? this.viewDate.setFullYear(this.viewDate.getFullYear() + 1)
|
|
210
|
-
: this.viewDate.setMonth(this.viewDate.getMonth() + 1));
|
|
211
|
-
// announce the new month and year
|
|
212
|
-
this.setAriaLive(this.getHeadline());
|
|
213
|
-
}
|
|
214
|
-
setAriaLive(text) {
|
|
215
|
-
const node = this.hostElement.shadowRoot?.querySelector('.cursor-aria');
|
|
216
|
-
if (node) {
|
|
217
|
-
node.innerHTML = text;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
onInputBlur(e) {
|
|
221
|
-
if (!this.input) {
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
155
|
+
reclamp(mode, limit) {
|
|
224
156
|
const oldValue = this.value;
|
|
225
|
-
const
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
this.catChange.emit(this.value);
|
|
230
|
-
}
|
|
231
|
-
this.input.value = this.getInputValue();
|
|
232
|
-
this.catBlur.emit(e);
|
|
233
|
-
}
|
|
234
|
-
dateGrid(year, month) {
|
|
235
|
-
const firstDayOfWeek = new Date(year, month, 1).getDay();
|
|
236
|
-
const daysInMonth = new Date(year, month + 1, 0).getDate();
|
|
237
|
-
const days = [...Array(daysInMonth).keys()];
|
|
238
|
-
const daysBefore = [...Array(firstDayOfWeek).keys()].map(day => new Date(year, month, day - firstDayOfWeek).getDate());
|
|
239
|
-
const daysAfter = [...Array(42 - days.length - daysBefore.length).keys()];
|
|
240
|
-
return [
|
|
241
|
-
...daysBefore.map(day => new Date(year, month - 1, day + 1)),
|
|
242
|
-
...days.map(day => new Date(year, month, day + 1)),
|
|
243
|
-
...daysAfter.map(day => new Date(year, month + 1, day + 1))
|
|
244
|
-
];
|
|
245
|
-
}
|
|
246
|
-
getHeadline() {
|
|
247
|
-
return `${this.locale.months.long[this.viewDate.getMonth()]} ${this.viewDate.getFullYear()}`;
|
|
248
|
-
}
|
|
249
|
-
getInputValue() {
|
|
250
|
-
const format = new Intl.DateTimeFormat(this.language, { year: 'numeric', month: '2-digit', day: '2-digit' });
|
|
251
|
-
return this.selectionDate ? format.format(this.selectionDate) : '';
|
|
252
|
-
}
|
|
253
|
-
getA11yLabelDay(date) {
|
|
254
|
-
const format = new Intl.DateTimeFormat(this.language, {
|
|
255
|
-
year: 'numeric',
|
|
256
|
-
month: 'long',
|
|
257
|
-
day: 'numeric',
|
|
258
|
-
weekday: 'long'
|
|
259
|
-
});
|
|
260
|
-
return format.format(date);
|
|
261
|
-
}
|
|
262
|
-
getWeekNumber(date, iso8601 = true) {
|
|
263
|
-
const currentDate = new Date(date.getTime());
|
|
264
|
-
const dayNum = iso8601 ? currentDate.getDay() || 7 : currentDate.getDay();
|
|
265
|
-
currentDate.setDate(currentDate.getDate() + 4 - dayNum);
|
|
266
|
-
const yearStart = new Date(currentDate.getFullYear(), 0, 1);
|
|
267
|
-
return Math.ceil(((+currentDate - +yearStart) / 86400000 + 1) / 7);
|
|
268
|
-
}
|
|
269
|
-
canFocus(date) {
|
|
270
|
-
const now = this.now;
|
|
271
|
-
const focused = this.focusedDate;
|
|
272
|
-
if (focused && isSameMonth(focused, this.viewDate)) {
|
|
273
|
-
return isSameMonth(focused, date) && isSameDay(focused, date);
|
|
274
|
-
}
|
|
275
|
-
else if (this.selectionDate && isSameMonth(this.selectionDate, this.viewDate)) {
|
|
276
|
-
return isSameMonth(this.selectionDate, date) && isSameDay(this.selectionDate, date);
|
|
157
|
+
const oldDate = this.locale.fromLocalISO(oldValue);
|
|
158
|
+
const limitDate = this.locale.fromLocalISO(limit);
|
|
159
|
+
if (!oldDate || !limitDate) {
|
|
160
|
+
return;
|
|
277
161
|
}
|
|
278
|
-
|
|
279
|
-
|
|
162
|
+
const newDate = clampDate(mode === 'min' ? limitDate : null, oldDate, mode === 'max' ? limitDate : null);
|
|
163
|
+
const newValue = this.locale.toLocalISO(newDate);
|
|
164
|
+
if (oldValue !== newValue) {
|
|
165
|
+
this.value = newValue;
|
|
166
|
+
this.catChange.emit(newValue);
|
|
280
167
|
}
|
|
281
|
-
const minDay = isSameMonth(date, this.minDate) ? this.minDate?.getDate() ?? 1 : 1;
|
|
282
|
-
return isSameMonth(this.viewDate, date) && date.getDate() === minDay;
|
|
283
|
-
}
|
|
284
|
-
canClick(date) {
|
|
285
|
-
const min = this.minDate;
|
|
286
|
-
const max = this.maxDate;
|
|
287
|
-
return (!min || min <= date) && (!max || max >= date);
|
|
288
|
-
}
|
|
289
|
-
toLocalISO(date) {
|
|
290
|
-
const year = date.getFullYear();
|
|
291
|
-
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
|
292
|
-
const day = date.getDate().toString().padStart(2, '0');
|
|
293
|
-
return `${year}-${month}-${day}`;
|
|
294
168
|
}
|
|
295
169
|
static get is() { return "cat-date"; }
|
|
296
170
|
static get encapsulation() { return "shadow"; }
|
|
@@ -740,9 +614,7 @@ export class CatDate {
|
|
|
740
614
|
static get states() {
|
|
741
615
|
return {
|
|
742
616
|
"hasSlottedLabel": {},
|
|
743
|
-
"hasSlottedHint": {}
|
|
744
|
-
"viewDate": {},
|
|
745
|
-
"selectionDate": {}
|
|
617
|
+
"hasSlottedHint": {}
|
|
746
618
|
};
|
|
747
619
|
}
|
|
748
620
|
static get events() {
|
|
@@ -805,34 +677,6 @@ export class CatDate {
|
|
|
805
677
|
}
|
|
806
678
|
static get methods() {
|
|
807
679
|
return {
|
|
808
|
-
"select": {
|
|
809
|
-
"complexType": {
|
|
810
|
-
"signature": "(date: Date) => Promise<void>",
|
|
811
|
-
"parameters": [{
|
|
812
|
-
"name": "date",
|
|
813
|
-
"type": "Date",
|
|
814
|
-
"docs": "The date to select."
|
|
815
|
-
}],
|
|
816
|
-
"references": {
|
|
817
|
-
"Promise": {
|
|
818
|
-
"location": "global",
|
|
819
|
-
"id": "global::Promise"
|
|
820
|
-
},
|
|
821
|
-
"Date": {
|
|
822
|
-
"location": "global",
|
|
823
|
-
"id": "global::Date"
|
|
824
|
-
}
|
|
825
|
-
},
|
|
826
|
-
"return": "Promise<void>"
|
|
827
|
-
},
|
|
828
|
-
"docs": {
|
|
829
|
-
"text": "Select a date in the picker.",
|
|
830
|
-
"tags": [{
|
|
831
|
-
"name": "param",
|
|
832
|
-
"text": "date The date to select."
|
|
833
|
-
}]
|
|
834
|
-
}
|
|
835
|
-
},
|
|
836
680
|
"doFocus": {
|
|
837
681
|
"complexType": {
|
|
838
682
|
"signature": "(options?: FocusOptions) => Promise<void>",
|
|
@@ -898,25 +742,13 @@ export class CatDate {
|
|
|
898
742
|
};
|
|
899
743
|
}
|
|
900
744
|
static get elementRef() { return "hostElement"; }
|
|
901
|
-
static get
|
|
745
|
+
static get watchers() {
|
|
902
746
|
return [{
|
|
903
|
-
"
|
|
904
|
-
"
|
|
905
|
-
"target": undefined,
|
|
906
|
-
"capture": false,
|
|
907
|
-
"passive": false
|
|
908
|
-
}, {
|
|
909
|
-
"name": "catClose",
|
|
910
|
-
"method": "onClose",
|
|
911
|
-
"target": undefined,
|
|
912
|
-
"capture": false,
|
|
913
|
-
"passive": false
|
|
747
|
+
"propName": "min",
|
|
748
|
+
"methodName": "onMinChanged"
|
|
914
749
|
}, {
|
|
915
|
-
"
|
|
916
|
-
"
|
|
917
|
-
"target": undefined,
|
|
918
|
-
"capture": false,
|
|
919
|
-
"passive": false
|
|
750
|
+
"propName": "max",
|
|
751
|
+
"methodName": "onMaxChanged"
|
|
920
752
|
}];
|
|
921
753
|
}
|
|
922
754
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-date.js","sourceRoot":"","sources":["../../../src/components/cat-date/cat-date.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,KAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Placement } from '@floating-ui/dom';\nimport { Component, Element, Event, EventEmitter, Host, Listen, Method, Prop, State, h } from '@stencil/core';\nimport { ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\nimport { getLocale } from './cat-date-locale';\nimport { addDays, addMonth, clampDate, isSameDay, isSameMonth, isSameYear } from './cat-date-math';\n\n@Component({\n tag: 'cat-date',\n styleUrl: 'cat-date.scss',\n shadow: true\n})\nexport class CatDate {\n private readonly language = i18n.getLocale();\n private readonly locale = getLocale(this.language);\n private input?: HTMLCatInputElement;\n private isOpen = false;\n // additonally store the focus date to ensure correct focus after potential re-render\n private focusDate: Date | null = null;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\n\n @State() viewDate: Date = this.now;\n\n @State() selectionDate: Date | null = null;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker?: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() max?: string;\n\n get maxDate() {\n const [y, m, d] = this.max?.split('-').map(Number) || [];\n return this.max ? new Date(y, m - 1, d) : null;\n }\n\n /**\n * A minimum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() min?: string;\n\n get minDate() {\n const [y, m, d] = this.min?.split('-').map(Number) || [];\n return this.min ? new Date(y, m - 1, d) : null;\n }\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The value of the control, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors on change with the given delay in milliseconds.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * The placement of the dropdown.\n */\n @Prop() placement: Placement = 'bottom-end';\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n private get now() {\n const date = new Date();\n return new Date(date.getFullYear(), date.getMonth(), date.getDate());\n }\n\n private get focusedDate() {\n const [all, year, month, day] =\n this.hostElement.shadowRoot\n ?.querySelector<HTMLCatButtonElement>(`[data-date]:focus`)\n ?.dataset.date?.match(/^(\\d{4})-(\\d{2})-(\\d{2})/) ?? [];\n return all ? new Date(Number(year), Number(month) - 1, Number(day)) : null;\n }\n\n componentWillLoad() {\n const [match, year, month, day] = this.value?.match(/^(\\d{4})-(\\d{2})-(\\d{2})/) ?? [];\n if (match) {\n this.select(new Date(Number(year), Number(month) - 1, Number(day)));\n }\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n }\n\n componentDidLoad() {\n const format = this.locale.formatStr.replace('YYYY', 'Y').replace('YY', 'y').replace('MM', 'm').replace('DD', 'd');\n const [, p1, d1, p2, p3] = /(\\w+)([^\\w]+)(\\w+)[^\\w]+(\\w+)/.exec(format) || [];\n this.input?.mask({\n date: true,\n dateMin: this.min,\n dateMax: this.max,\n delimiter: d1,\n datePattern: [p1, p2, p3]\n });\n }\n\n componentDidRender() {\n if (this.focusDate) {\n this.hostElement.shadowRoot\n ?.querySelector<HTMLCatButtonElement>(`[data-date=\"${this.toLocalISO(this.focusDate)}\"]`)\n ?.doFocus();\n this.focusDate = null;\n }\n }\n\n @Listen('catOpen')\n onOpen() {\n this.isOpen = true;\n this.setAriaLive('');\n const viewDate = this.selectionDate\n ? new Date(this.selectionDate.getFullYear(), this.selectionDate.getMonth(), 1)\n : this.now;\n this.viewDate = clampDate(this.minDate, viewDate, this.maxDate);\n }\n\n @Listen('catClose')\n onClose() {\n this.isOpen = false;\n }\n\n @Listen('keydown')\n onKeyDown(e: KeyboardEvent) {\n if (!this.isOpen || !['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'].includes(e.key)) {\n return;\n }\n const focused = this.focusedDate;\n if (!focused) {\n e.preventDefault();\n this.focus(this.selectionDate || this.now);\n } else if (e.key === 'ArrowLeft') {\n e.preventDefault();\n this.focus(e.shiftKey ? addMonth(focused, -1) : addDays(focused, -1));\n } else if (e.key === 'ArrowRight') {\n e.preventDefault();\n this.focus(e.shiftKey ? addMonth(focused, 1) : addDays(focused, 1));\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n this.focus(addDays(focused, -7));\n } else if (e.key === 'ArrowDown') {\n e.preventDefault();\n this.focus(addDays(focused, 7));\n }\n }\n\n /**\n * Select a date in the picker.\n *\n * @param date The date to select.\n */\n @Method()\n async select(date: Date): Promise<void> {\n const oldValue = this.value;\n const newDate = clampDate(\n this.minDate,\n new Date(date.getFullYear(), date.getMonth(), date.getDate()),\n this.maxDate\n );\n this.focus(newDate);\n this.selectionDate = newDate;\n this.value = newDate.toISOString();\n if (oldValue !== this.value) {\n this.catChange.emit(this.value);\n }\n }\n\n /**\n * Programmatically move focus to the input. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input?.doFocus(options);\n }\n\n /**\n * Programmatically remove focus from the input. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input?.doBlur();\n }\n\n /**\n * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.input?.clear();\n }\n\n render() {\n const dateGrid = this.dateGrid(this.viewDate.getFullYear(), this.viewDate.getMonth());\n return (\n <Host>\n <cat-input\n class=\"cat-date-input\"\n ref={el => (this.input = el as HTMLCatInputElement)}\n requiredMarker={this.requiredMarker}\n horizontal={this.horizontal}\n autoComplete={this.autoComplete}\n clearable={this.clearable}\n disabled={this.disabled}\n hint={this.hint}\n icon={this.icon}\n iconRight={this.iconRight}\n identifier={this.identifier}\n labelHidden={this.labelHidden}\n name={this.name}\n placeholder={this.placeholder}\n textPrefix={this.textPrefix}\n textSuffix={this.textSuffix}\n readonly={this.readonly}\n required={this.required}\n errors={this.errors}\n errorUpdate={this.errorUpdate}\n nativeAttributes={this.nativeAttributes}\n value={this.getInputValue()}\n onCatFocus={e => this.catFocus.emit(e.detail)}\n onCatBlur={e => this.onInputBlur(e.detail)}\n >\n <span slot=\"label\">\n {this.label}\n <span class=\"label-aria\"> ({this.locale.formatStr})</span>\n </span>\n <cat-dropdown slot=\"addon\" placement={this.placement} arrowNavigation=\"none\" noResize>\n <cat-button\n slot=\"trigger\"\n icon=\"$cat:datepicker-calendar\"\n iconOnly\n class=\"cat-date-toggle\"\n disabled={this.disabled}\n a11yLabel={\n this.selectionDate\n ? `${this.locale.change}, ${this.getA11yLabelDay(this.selectionDate)}`\n : this.locale.choose\n }\n ></cat-button>\n <div class=\"picker\" slot=\"content\">\n <div class=\"picker-head\">\n <cat-button\n icon=\"$cat:datepicker-year-prev\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.prevYear}\n disabled={isSameYear(this.viewDate, this.minDate)}\n onClick={() => this.navigate('prev', 'year')}\n data-dropdown-no-close\n ></cat-button>\n <cat-button\n icon=\"$cat:datepicker-month-prev\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.prevMonth}\n disabled={isSameMonth(this.viewDate, this.minDate)}\n onClick={() => this.navigate('prev', 'month')}\n data-dropdown-no-close\n ></cat-button>\n <h3>{this.getHeadline()}</h3>\n <cat-button\n icon=\"$cat:datepicker-month-next\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.nextMonth}\n disabled={isSameMonth(this.viewDate, this.maxDate)}\n onClick={() => this.navigate('next', 'month')}\n data-dropdown-no-close\n ></cat-button>\n <cat-button\n icon=\"$cat:datepicker-year-next\"\n iconOnly\n size=\"xs\"\n variant=\"text\"\n a11y-label={this.locale.nextYear}\n disabled={isSameYear(this.viewDate, this.maxDate)}\n onClick={() => this.navigate('next', 'year')}\n data-dropdown-no-close\n ></cat-button>\n </div>\n <div class=\"picker-grid\" onFocusin={() => this.setAriaLive(this.locale.arrowKeys)}>\n <div class=\"picker-grid-head\">\n {Array.from(Array(7), (_, i) => (\n <abbr title={this.locale.days.long[i]}>{this.locale.days.short[i]}</abbr>\n ))}\n </div>\n <div class=\"picker-grid-weeks\">\n {dateGrid\n .filter((_, i) => i % 7 === 0)\n .map(day => (\n <div>{this.getWeekNumber(day)}</div>\n ))}\n </div>\n <div class=\"picker-grid-days\">\n {dateGrid.map(day => (\n <cat-button\n class={{\n 'cat-date-item': true,\n 'date-other': !isSameMonth(this.viewDate, day),\n 'date-today': isSameDay(this.now, day),\n 'date-selected': isSameDay(this.selectionDate, day),\n 'date-focusable': this.canFocus(day),\n 'date-disabled': !this.canClick(day)\n }}\n nativeAttributes={!this.canFocus(day) ? { tabindex: '-1' } : {}}\n variant={\n isSameDay(this.selectionDate, day) ? 'filled' : isSameDay(this.now, day) ? 'outlined' : 'text'\n }\n a11yLabel={this.getA11yLabelDay(day)}\n active={isSameDay(this.selectionDate, day)}\n color={isSameDay(this.selectionDate, day) || isSameDay(this.now, day) ? 'primary' : 'secondary'}\n disabled={!this.canClick(day)}\n onClick={() => this.select(day)}\n data-date={this.toLocalISO(day)}\n >\n {day.getDate()}\n </cat-button>\n ))}\n </div>\n </div>\n <div class=\"picker-foot\">\n {this.canClick(this.now) && (\n <cat-button size=\"s\" data-dropdown-no-close onClick={() => this.select(this.now)}>\n {this.locale.today}\n </cat-button>\n )}\n <p\n class={{\n 'cursor-help': true,\n 'cursor-right': this.canClick(this.now)\n }}\n >\n {this.locale.arrowKeys}\n </p>\n <p class=\"cursor-aria\" aria-live=\"polite\"></p>\n </div>\n </div>\n </cat-dropdown>\n </cat-input>\n </Host>\n );\n }\n\n private parse(value: string) {\n const [, p1, d1, p2, p3] = /(\\w+)([^\\w]+)(\\w+)[^\\w]+(\\w+)/.exec(this.locale.formatStr) || [];\n const formatParts = [p1, p2, p3];\n const parts = value.split(d1).map(s => Number(s || 'x'));\n let year = parts[formatParts.indexOf('YYYY') || formatParts.indexOf('YY')] || this.now.getFullYear();\n const month = parts[formatParts.indexOf('MM')];\n const day = parts[formatParts.indexOf('DD')];\n if (!Number.isInteger(month) || !Number.isInteger(day)) {\n return null;\n } else if (year < 100) {\n year += year < 50 ? 2000 : 1900;\n }\n return new Date(year, month - 1, day);\n }\n\n private focus(date: Date) {\n this.focusDate = clampDate(this.minDate, date, this.maxDate);\n this.viewDate = new Date(this.focusDate.getFullYear(), this.focusDate.getMonth());\n this.hostElement.shadowRoot\n ?.querySelector<HTMLCatButtonElement>(`[data-date=\"${this.toLocalISO(this.focusDate)}\"]`)\n ?.doFocus();\n }\n\n private navigate(direction: 'prev' | 'next', period: 'year' | 'month') {\n this.viewDate = new Date(\n direction === 'prev'\n ? period === 'year'\n ? this.viewDate.setFullYear(this.viewDate.getFullYear() - 1)\n : this.viewDate.setMonth(this.viewDate.getMonth() - 1)\n : period === 'year'\n ? this.viewDate.setFullYear(this.viewDate.getFullYear() + 1)\n : this.viewDate.setMonth(this.viewDate.getMonth() + 1)\n );\n // announce the new month and year\n this.setAriaLive(this.getHeadline());\n }\n\n private setAriaLive(text: string) {\n const node = this.hostElement.shadowRoot?.querySelector('.cursor-aria');\n if (node) {\n node.innerHTML = text;\n }\n }\n\n private onInputBlur(e: FocusEvent) {\n if (!this.input) {\n return;\n }\n const oldValue = this.value;\n const value = this.parse(this.input.value ?? '');\n this.selectionDate = value ? clampDate(this.minDate, value, this.maxDate) : value;\n this.value = this.selectionDate?.toISOString();\n if (oldValue !== this.value) {\n this.catChange.emit(this.value);\n }\n this.input.value = this.getInputValue();\n this.catBlur.emit(e);\n }\n\n private dateGrid(year: number, month: number) {\n const firstDayOfWeek = new Date(year, month, 1).getDay();\n const daysInMonth = new Date(year, month + 1, 0).getDate();\n const days = [...Array(daysInMonth).keys()];\n const daysBefore = [...Array(firstDayOfWeek).keys()].map(day =>\n new Date(year, month, day - firstDayOfWeek).getDate()\n );\n const daysAfter = [...Array(42 - days.length - daysBefore.length).keys()];\n return [\n ...daysBefore.map(day => new Date(year, month - 1, day + 1)),\n ...days.map(day => new Date(year, month, day + 1)),\n ...daysAfter.map(day => new Date(year, month + 1, day + 1))\n ];\n }\n\n private getHeadline() {\n return `${this.locale.months.long[this.viewDate.getMonth()]} ${this.viewDate.getFullYear()}`;\n }\n\n private getInputValue() {\n const format = new Intl.DateTimeFormat(this.language, { year: 'numeric', month: '2-digit', day: '2-digit' });\n return this.selectionDate ? format.format(this.selectionDate) : '';\n }\n\n private getA11yLabelDay(date: Date) {\n const format = new Intl.DateTimeFormat(this.language, {\n year: 'numeric',\n month: 'long',\n day: 'numeric',\n weekday: 'long'\n });\n return format.format(date);\n }\n\n private getWeekNumber(date: Date, iso8601 = true) {\n const currentDate = new Date(date.getTime());\n const dayNum = iso8601 ? currentDate.getDay() || 7 : currentDate.getDay();\n currentDate.setDate(currentDate.getDate() + 4 - dayNum);\n const yearStart = new Date(currentDate.getFullYear(), 0, 1);\n return Math.ceil(((+currentDate - +yearStart) / 86400000 + 1) / 7);\n }\n\n private canFocus(date: Date): boolean {\n const now = this.now;\n const focused = this.focusedDate;\n if (focused && isSameMonth(focused, this.viewDate)) {\n return isSameMonth(focused, date) && isSameDay(focused, date);\n } else if (this.selectionDate && isSameMonth(this.selectionDate, this.viewDate)) {\n return isSameMonth(this.selectionDate, date) && isSameDay(this.selectionDate, date);\n } else if (isSameMonth(this.viewDate, now) && (!this.minDate || this.minDate <= now)) {\n return isSameMonth(this.viewDate, date) && isSameDay(now, date);\n }\n const minDay = isSameMonth(date, this.minDate) ? this.minDate?.getDate() ?? 1 : 1;\n return isSameMonth(this.viewDate, date) && date.getDate() === minDay;\n }\n\n private canClick(date: Date) {\n const min = this.minDate;\n const max = this.maxDate;\n return (!min || min <= date) && (!max || max >= date);\n }\n\n private toLocalISO(date: Date) {\n const year = date.getFullYear();\n const month = (date.getMonth() + 1).toString().padStart(2, '0');\n const day = date.getDate().toString().padStart(2, '0');\n return `${year}-${month}-${day}`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cat-date.js","sourceRoot":"","sources":["../../../src/components/cat-date/cat-date.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAC7G,OAAO,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D,OAAO,EAAE,eAAe,IAAI,IAAI,EAAE,MAAM,+BAA+B,CAAC;AAExE;;GAEG;AAMH,MAAM,OAAO,OAAO;;QACD,aAAQ,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAC5B,WAAM,GAAG,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Placement } from '@floating-ui/dom';\nimport { Component, Element, Event, EventEmitter, Host, Method, Prop, State, Watch, h } from '@stencil/core';\nimport { getLocale } from '../cat-date-inline/cat-date-locale';\nimport { clampDate } from '../cat-date-inline/cat-date-math';\nimport { ErrorMap } from '../cat-form-hint/cat-form-hint';\nimport { catI18nRegistry as i18n } from '../cat-i18n/cat-i18n-registry';\n\n/**\n * A date input component to select a date from a calendar in a dropdown.\n */\n@Component({\n tag: 'cat-date',\n styleUrl: 'cat-date.scss',\n shadow: true\n})\nexport class CatDate {\n private readonly language = i18n.getLocale();\n private readonly locale = getLocale(this.language);\n private input?: HTMLCatInputElement;\n private dateInline?: HTMLCatDateInlineElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n @State() hasSlottedHint = false;\n\n /**\n * Whether the label need a marker to shown if the input is required or optional.\n */\n @Prop() requiredMarker?: 'none' | 'required' | 'optional' | 'none!' | 'optional!' | 'required!' = 'optional';\n\n /**\n * Whether the label is on top or left.\n */\n @Prop() horizontal = false;\n\n /**\n * Hint for form autofill feature.\n */\n @Prop() autoComplete?: string;\n\n /**\n * Whether the input should show a clear button.\n */\n @Prop() clearable = false;\n\n /**\n * Whether the input is disabled.\n */\n @Prop() disabled = false;\n\n /**\n * Optional hint text(s) to be displayed with the input.\n */\n @Prop() hint?: string | string[];\n\n /**\n * The name of an icon to be displayed in the input.\n */\n @Prop() icon?: string;\n\n /**\n * Display the icon on the right.\n */\n @Prop() iconRight = false;\n\n /**\n * A unique identifier for the input.\n */\n @Prop() identifier?: string;\n\n /**\n * The label for the input.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * A maximum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() max?: string;\n\n /**\n * A minimum value for the date, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop() min?: string;\n\n /**\n * The name of the form control. Submitted with the form as part of a name/value pair.\n */\n @Prop() name?: string;\n\n /**\n * The placeholder text to display within the input.\n */\n @Prop() placeholder?: string;\n\n /**\n * A textual prefix to be displayed in the input.\n */\n @Prop() textPrefix?: string;\n\n /**\n * A textual suffix to be displayed in the input.\n */\n @Prop() textSuffix?: string;\n\n /**\n * The value is not editable.\n */\n @Prop() readonly = false;\n\n /**\n * A value is required or must be check for the form to be submittable.\n */\n @Prop() required = false;\n\n /**\n * The value of the control, given in local ISO 8601 date format YYYY-MM-DD.\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * The validation errors for this input. Will render a hint under the input\n * with the translated error message(s) `error.${key}`. If an object is\n * passed, the keys will be used as error keys and the values translation\n * parameters.\n * If the value is `true`, the input will be marked as invalid without any\n * hints under the input.\n */\n @Prop() errors?: boolean | string[] | ErrorMap;\n\n /**\n * Fine-grained control over when the errors are shown. Can be `false` to\n * never show errors, `true` to show errors on blur, or a number to show\n * errors on change with the given delay in milliseconds.\n */\n @Prop() errorUpdate: boolean | number = 0;\n\n /**\n * Attributes that will be added to the native HTML input element.\n */\n @Prop() nativeAttributes?: { [key: string]: string };\n\n /**\n * The placement of the dropdown.\n */\n @Prop() placement: Placement = 'bottom-end';\n\n @Watch('min')\n onMinChanged(min?: string, oldMin?: string) {\n if (min !== oldMin) {\n this.reclamp('min', min);\n }\n }\n\n @Watch('max')\n onMaxChanged(max?: string, oldMax?: string) {\n if (max !== oldMax) {\n this.reclamp('max', max);\n }\n }\n\n /**\n * Emitted when the value is changed.\n */\n @Event() catChange!: EventEmitter<string>;\n\n /**\n * Emitted when the input received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the input loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n private get inputValue() {\n const [match, year, month, day] = this.value?.match(/^(\\d{4})-(\\d{2})-(\\d{2})/) ?? [];\n if (match) {\n const date = new Date(Number(year), Number(month) - 1, Number(day));\n const format = new Intl.DateTimeFormat(this.language, { year: 'numeric', month: '2-digit', day: '2-digit' });\n return format.format(date);\n }\n return '';\n }\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n this.hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n }\n\n componentDidLoad() {\n const format = this.locale.formatStr.replace('YYYY', 'Y').replace('YY', 'y').replace('MM', 'm').replace('DD', 'd');\n const [, p1, d1, p2, p3] = /(\\w+)([^\\w]+)(\\w+)[^\\w]+(\\w+)/.exec(format) || [];\n this.input?.mask({\n date: true,\n dateMin: this.min,\n dateMax: this.max,\n delimiter: d1,\n datePattern: [p1, p2, p3]\n });\n }\n\n /**\n * Programmatically move focus to the input. Use this method instead of\n * `input.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async doFocus(options?: FocusOptions): Promise<void> {\n this.input?.doFocus(options);\n }\n\n /**\n * Programmatically remove focus from the input. Use this method instead of\n * `input.blur()`.\n */\n @Method()\n async doBlur(): Promise<void> {\n this.input?.doBlur();\n }\n\n /**\n * Clear the input.\n */\n @Method()\n async clear(): Promise<void> {\n this.input?.clear();\n }\n\n render() {\n return (\n <Host>\n <cat-input\n class=\"cat-date-input\"\n ref={el => (this.input = el as HTMLCatInputElement)}\n requiredMarker={this.requiredMarker}\n horizontal={this.horizontal}\n autoComplete={this.autoComplete}\n clearable={this.clearable}\n disabled={this.disabled}\n hint={this.hint}\n icon={this.icon}\n iconRight={this.iconRight}\n identifier={this.identifier}\n labelHidden={this.labelHidden}\n name={this.name}\n placeholder={this.placeholder}\n textPrefix={this.textPrefix}\n textSuffix={this.textSuffix}\n readonly={this.readonly}\n required={this.required}\n errors={this.errors}\n errorUpdate={this.errorUpdate}\n nativeAttributes={this.nativeAttributes}\n value={this.inputValue}\n onCatFocus={e => {\n e.stopPropagation();\n this.catFocus.emit(e.detail);\n }}\n onCatBlur={e => {\n e.stopPropagation();\n this.onInputBlur(e.detail);\n }}\n >\n <span slot=\"label\">\n {this.label}\n <span class=\"label-aria\"> ({this.locale.formatStr})</span>\n </span>\n <cat-dropdown\n slot=\"addon\"\n placement={this.placement}\n arrowNavigation=\"none\"\n noResize\n onCatOpen={() => this.dateInline?.resetView()}\n >\n <cat-button\n slot=\"trigger\"\n icon=\"$cat:datepicker-calendar\"\n iconOnly\n class=\"cat-date-toggle\"\n disabled={this.disabled}\n a11yLabel={this.getTriggerA11yLabel()}\n ></cat-button>\n <div slot=\"content\">\n <cat-date-inline\n ref={el => (this.dateInline = el as HTMLCatDateInlineElement)}\n min={this.min}\n max={this.max}\n value={this.value}\n noClear\n onCatChange={this.onDateChange.bind(this)}\n ></cat-date-inline>\n </div>\n </cat-dropdown>\n </cat-input>\n </Host>\n );\n }\n\n private getTriggerA11yLabel() {\n const date = this.locale.fromLocalISO(this.value);\n return date ? `${this.locale.change}, ${this.locale.toLocalStr(date)}` : this.locale.choose;\n }\n\n private onInputBlur(e: FocusEvent) {\n if (!this.input) {\n return;\n }\n const oldValue = this.value;\n const dateParsed = this.parse(this.input.value ?? '');\n const dateMin = this.locale.fromLocalISO(this.min);\n const dateMax = this.locale.fromLocalISO(this.max);\n const date = dateParsed ? clampDate(dateMin, dateParsed, dateMax) : null;\n this.value = date ? this.locale.toLocalISO(date) : undefined;\n if (oldValue !== this.value) {\n if (date) {\n this.dateInline?.select(date);\n } else {\n this.dateInline?.clear();\n }\n this.catChange.emit(this.value);\n }\n this.input.value = this.inputValue;\n this.catBlur.emit(e);\n }\n\n private onDateChange(e: CustomEvent<string>) {\n e.stopPropagation();\n const oldValue = this.value;\n const date = e.detail ? new Date(e.detail) : null;\n this.value = date ? this.locale.toLocalISO(date) : undefined;\n if (oldValue !== this.value) {\n this.catChange.emit(this.value);\n }\n }\n\n private parse(value: string) {\n const [, p1, d1, p2, p3] = /(\\w+)([^\\w]+)(\\w+)[^\\w]+(\\w+)/.exec(this.locale.formatStr) || [];\n const formatParts = [p1, p2, p3];\n const parts = value.split(d1).map(s => Number(s || 'x'));\n let year = parts[formatParts.indexOf('YYYY') || formatParts.indexOf('YY')] || this.locale.now().getFullYear();\n const month = parts[formatParts.indexOf('MM')];\n const day = parts[formatParts.indexOf('DD')];\n if (!Number.isInteger(month) || !Number.isInteger(day)) {\n return null;\n } else if (year < 100) {\n year += year < 50 ? 2000 : 1900;\n }\n return new Date(year, month - 1, day);\n }\n\n private reclamp(mode: 'min' | 'max', limit: string | undefined) {\n const oldValue = this.value;\n const oldDate = this.locale.fromLocalISO(oldValue);\n const limitDate = this.locale.fromLocalISO(limit);\n if (!oldDate || !limitDate) {\n return;\n }\n const newDate = clampDate(mode === 'min' ? limitDate : null, oldDate, mode === 'max' ? limitDate : null);\n const newValue = this.locale.toLocalISO(newDate);\n if (oldValue !== newValue) {\n this.value = newValue;\n this.catChange.emit(newValue);\n }\n }\n}\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
jest.mock('../cat-i18n/cat-i18n-registry');
|
|
2
2
|
import { newSpecPage } from "@stencil/core/testing";
|
|
3
|
+
import { CatDateInline } from "../cat-date-inline/cat-date-inline";
|
|
3
4
|
import { CatInput } from "../cat-input/cat-input";
|
|
4
5
|
import { CatDate } from "./cat-date";
|
|
5
6
|
describe('cat-date', () => {
|
|
6
7
|
it('renders', async () => {
|
|
7
8
|
const page = await newSpecPage({
|
|
8
|
-
components: [CatDate, CatInput],
|
|
9
|
+
components: [CatDate, CatInput, CatDateInline],
|
|
9
10
|
html: `<cat-date></cat-date>`
|
|
10
11
|
});
|
|
11
12
|
expect(page.root).toEqualLightHtml(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cat-date.spec.js","sourceRoot":"","sources":["../../../src/components/cat-date/cat-date.spec.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,OAAO,EAAE,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"cat-date.spec.js","sourceRoot":"","sources":["../../../src/components/cat-date/cat-date.spec.tsx"],"names":[],"mappings":"AAAA,IAAI,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QACvB,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC;YAC7B,UAAU,EAAE,CAAC,OAAO,EAAE,QAAQ,EAAE,aAAa,CAAC;YAC9C,IAAI,EAAE,uBAAuB;SAC9B,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,gBAAgB,CAAC;;KAElC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["jest.mock('../cat-i18n/cat-i18n-registry');\n\nimport { newSpecPage } from '@stencil/core/testing';\nimport { CatDateInline } from '../cat-date-inline/cat-date-inline';\nimport { CatInput } from '../cat-input/cat-input';\nimport { CatDate } from './cat-date';\n\ndescribe('cat-date', () => {\n it('renders', async () => {\n const page = await newSpecPage({\n components: [CatDate, CatInput, CatDateInline],\n html: `<cat-date></cat-date>`\n });\n expect(page.root).toEqualLightHtml(`\n <cat-date></cat-date>\n `);\n });\n});\n"]}
|