igniteui-webcomponents 6.4.0 → 6.5.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/CHANGELOG.md +62 -0
- package/components/calendar/base.d.ts +7 -3
- package/components/calendar/base.js +10 -14
- package/components/calendar/base.js.map +1 -1
- package/components/calendar/calendar.d.ts +48 -46
- package/components/calendar/calendar.js +259 -242
- package/components/calendar/calendar.js.map +1 -1
- package/components/calendar/days-view/days-view.d.ts +49 -27
- package/components/calendar/days-view/days-view.js +169 -160
- package/components/calendar/days-view/days-view.js.map +1 -1
- package/components/calendar/helpers.js +40 -28
- package/components/calendar/helpers.js.map +1 -1
- package/components/calendar/model.d.ts +9 -3
- package/components/calendar/model.js +29 -19
- package/components/calendar/model.js.map +1 -1
- package/components/calendar/months-view/months-view.d.ts +6 -7
- package/components/calendar/months-view/months-view.js +24 -27
- package/components/calendar/months-view/months-view.js.map +1 -1
- package/components/calendar/years-view/years-view.d.ts +6 -5
- package/components/calendar/years-view/years-view.js +11 -14
- package/components/calendar/years-view/years-view.js.map +1 -1
- package/components/checkbox/checkbox-base.d.ts +1 -1
- package/components/chip/themes/dark/chip.fluent.css.js +1 -1
- package/components/chip/themes/dark/chip.fluent.css.js.map +1 -1
- package/components/chip/themes/dark/chip.indigo.css.js +1 -1
- package/components/chip/themes/dark/chip.indigo.css.js.map +1 -1
- package/components/chip/themes/light/chip.fluent.css.js +1 -1
- package/components/chip/themes/light/chip.fluent.css.js.map +1 -1
- package/components/chip/themes/light/chip.indigo.css.js +1 -1
- package/components/chip/themes/light/chip.indigo.css.js.map +1 -1
- package/components/chip/themes/light/chip.shared.css.js +1 -1
- package/components/chip/themes/light/chip.shared.css.js.map +1 -1
- package/components/chip/themes/shared/chip.indigo.css.js +1 -1
- package/components/chip/themes/shared/chip.indigo.css.js.map +1 -1
- package/components/common/definitions/defineAllComponents.js +2 -0
- package/components/common/definitions/defineAllComponents.js.map +1 -1
- package/components/date-range-picker/date-range-picker.js +1 -1
- package/components/date-range-picker/date-range-picker.js.map +1 -1
- package/components/date-time-input/date-time-input.d.ts +4 -1
- package/components/date-time-input/date-time-input.js +17 -6
- package/components/date-time-input/date-time-input.js.map +1 -1
- package/components/file-input/file-input.d.ts +15 -13
- package/components/file-input/file-input.js +49 -47
- package/components/file-input/file-input.js.map +1 -1
- package/components/input/input-base.d.ts +31 -34
- package/components/input/input-base.js +58 -83
- package/components/input/input-base.js.map +1 -1
- package/components/input/input.d.ts +18 -7
- package/components/input/input.js +34 -19
- package/components/input/input.js.map +1 -1
- package/components/mask-input/mask-input-base.d.ts +10 -4
- package/components/mask-input/mask-input-base.js +18 -14
- package/components/mask-input/mask-input-base.js.map +1 -1
- package/components/mask-input/mask-input.d.ts +9 -3
- package/components/mask-input/mask-input.js +26 -6
- package/components/mask-input/mask-input.js.map +1 -1
- package/components/mask-input/validators.js +1 -1
- package/components/mask-input/validators.js.map +1 -1
- package/components/theme-provider/theme-provider.d.ts +65 -0
- package/components/theme-provider/theme-provider.js +58 -0
- package/components/theme-provider/theme-provider.js.map +1 -0
- package/components/tile-manager/tile.js +6 -3
- package/components/tile-manager/tile.js.map +1 -1
- package/custom-elements.json +2136 -1596
- package/extras/chat-markdown-renderer.d.ts +72 -4
- package/extras/chat-markdown-renderer.js +19 -7
- package/extras/chat-markdown-renderer.js.map +1 -1
- package/igniteui-webcomponents.html-data.json +1 -1
- package/index.d.ts +3 -0
- package/index.js +2 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/themes/dark/bootstrap.css +1 -1
- package/themes/dark/fluent.css +1 -1
- package/themes/dark/indigo.css +1 -1
- package/themes/dark/material.css +1 -1
- package/themes/light/bootstrap.css +1 -1
- package/themes/light/fluent.css +1 -1
- package/themes/light/indigo.css +1 -1
- package/themes/light/material.css +1 -1
- package/theming/context.d.ts +36 -0
- package/theming/context.js +3 -0
- package/theming/context.js.map +1 -0
- package/theming/theming-controller.d.ts +7 -1
- package/theming/theming-controller.js +48 -12
- package/theming/theming-controller.js.map +1 -1
- package/theming/utils.d.ts +10 -0
- package/theming/utils.js +8 -42
- package/theming/utils.js.map +1 -1
- package/web-types.json +1 -1
|
@@ -40,158 +40,229 @@ export default class IgcCalendarComponent extends EventEmitterMixin(IgcCalendarB
|
|
|
40
40
|
get _isYearView() {
|
|
41
41
|
return this.activeView === 'years';
|
|
42
42
|
}
|
|
43
|
-
get
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (this._isDayView) {
|
|
54
|
-
return this.resourceStrings.nextMonth;
|
|
55
|
-
}
|
|
56
|
-
if (this._isMonthView) {
|
|
57
|
-
return this.resourceStrings.nextYear;
|
|
43
|
+
get _previousButtonLabel() {
|
|
44
|
+
switch (this.activeView) {
|
|
45
|
+
case 'days':
|
|
46
|
+
return this.resourceStrings.previousMonth;
|
|
47
|
+
case 'months':
|
|
48
|
+
return this.resourceStrings.previousYear;
|
|
49
|
+
case 'years':
|
|
50
|
+
return formatString(this.resourceStrings.previousYears, YEARS_PER_PAGE);
|
|
51
|
+
default:
|
|
52
|
+
return '';
|
|
58
53
|
}
|
|
59
|
-
return formatString(this.resourceStrings.nextYears, YEARS_PER_PAGE);
|
|
60
54
|
}
|
|
61
|
-
get
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (this._isMonthView) {
|
|
72
|
-
return this.monthsView.focusActiveDate(options);
|
|
73
|
-
}
|
|
74
|
-
if (this._isYearView) {
|
|
75
|
-
return this.yearsView.focusActiveDate(options);
|
|
55
|
+
get _nextButtonLabel() {
|
|
56
|
+
switch (this.activeView) {
|
|
57
|
+
case 'days':
|
|
58
|
+
return this.resourceStrings.nextMonth;
|
|
59
|
+
case 'months':
|
|
60
|
+
return this.resourceStrings.nextYear;
|
|
61
|
+
case 'years':
|
|
62
|
+
return formatString(this.resourceStrings.nextYears, YEARS_PER_PAGE);
|
|
63
|
+
default:
|
|
64
|
+
return '';
|
|
76
65
|
}
|
|
77
66
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
67
|
+
constructor() {
|
|
68
|
+
super();
|
|
69
|
+
this._contentRef = createRef();
|
|
70
|
+
this._activeDaysViewIndex = 0;
|
|
71
|
+
this.hideOutsideDays = false;
|
|
72
|
+
this.hideHeader = false;
|
|
73
|
+
this.headerOrientation = 'horizontal';
|
|
74
|
+
this.orientation = 'horizontal';
|
|
75
|
+
this.visibleMonths = 1;
|
|
76
|
+
this.activeView = 'days';
|
|
77
|
+
this.formatOptions = { month: 'long', weekday: 'narrow' };
|
|
78
|
+
addThemingController(this, all);
|
|
79
|
+
addKeybindings(this, {
|
|
80
|
+
skip: this._shouldSkipKeyboardEvent,
|
|
81
|
+
ref: this._contentRef,
|
|
82
|
+
bindingDefaults: { triggers: ['keydownRepeat'] },
|
|
83
|
+
})
|
|
84
|
+
.set(arrowLeft, this._handleArrowKey.bind(this, 'day', -1))
|
|
85
|
+
.set(arrowRight, this._handleArrowKey.bind(this, 'day', 1))
|
|
86
|
+
.set(arrowUp, this._handleArrowKey.bind(this, 'week', -1))
|
|
87
|
+
.set(arrowDown, this._handleArrowKey.bind(this, 'week', 1))
|
|
88
|
+
.set([shiftKey, pageUpKey], this._handleShiftPageKeys.bind(this, -1))
|
|
89
|
+
.set([shiftKey, pageDownKey], this._handleShiftPageKeys.bind(this, 1))
|
|
90
|
+
.set(pageUpKey, this._handlePageKeys.bind(this, -1))
|
|
91
|
+
.set(pageDownKey, this._handlePageKeys.bind(this, 1))
|
|
92
|
+
.set(homeKey, this._handleHomeKey)
|
|
93
|
+
.set(endKey, this._handleEndKey);
|
|
94
|
+
}
|
|
95
|
+
_shouldSkipKeyboardEvent(_, event) {
|
|
96
|
+
return !findElementFromEventPath(`${IgcDaysViewComponent.tagName}, ${IgcMonthsViewComponent.tagName}, ${IgcYearsViewComponent.tagName}`, event);
|
|
94
97
|
}
|
|
95
|
-
|
|
98
|
+
_handleArrowKey(period, delta) {
|
|
96
99
|
if (this._isDayView) {
|
|
97
|
-
const date = this.
|
|
98
|
-
this.
|
|
100
|
+
const date = this._getNextEnabledDate(this._activeDate.add(period, delta), delta);
|
|
101
|
+
this._updateViewIndex(date, delta);
|
|
99
102
|
this._activeDate = date;
|
|
100
103
|
}
|
|
101
104
|
else {
|
|
102
105
|
const monthOrYear = this._isMonthView ? 'month' : 'year';
|
|
103
106
|
const monthOrYearDelta = (this._isMonthView ? MONTHS_PER_ROW : YEARS_PER_ROW) * delta;
|
|
104
|
-
this._activeDate = this.
|
|
107
|
+
this._activeDate = this._getNextEnabledDate(this._activeDate.add(monthOrYear, period === 'week' ? monthOrYearDelta : delta), delta);
|
|
105
108
|
}
|
|
106
109
|
this[focusActiveDate]();
|
|
107
110
|
}
|
|
108
|
-
|
|
111
|
+
_handlePageKeys(delta) {
|
|
109
112
|
const unit = this._isDayView ? 'month' : 'year';
|
|
110
113
|
const increment = (this._isYearView ? YEARS_PER_PAGE : 1) * delta;
|
|
111
|
-
this._activeDate = this.
|
|
114
|
+
this._activeDate = this._getNextEnabledDate(this._activeDate.add(unit, increment), increment);
|
|
112
115
|
this[focusActiveDate]();
|
|
113
116
|
}
|
|
114
|
-
|
|
117
|
+
_handleShiftPageKeys(delta) {
|
|
115
118
|
if (this._isDayView) {
|
|
116
|
-
this._activeDate = this.
|
|
119
|
+
this._activeDate = this._getNextEnabledDate(this._activeDate.add('year', delta), delta);
|
|
117
120
|
this[focusActiveDate]();
|
|
118
121
|
}
|
|
119
122
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
_handleHomeKey() {
|
|
124
|
+
switch (this.activeView) {
|
|
125
|
+
case 'days': {
|
|
126
|
+
const firstView = CalendarDay.from(this._daysViews.item(0).activeDate);
|
|
127
|
+
this._activeDate = this._getNextEnabledDate(firstView.set({ date: 1 }), 1);
|
|
128
|
+
this._activeDaysViewIndex = 0;
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
case 'months':
|
|
132
|
+
this._activeDate = this._getNextEnabledDate(this._activeDate.set({ month: 0 }), 1);
|
|
133
|
+
break;
|
|
134
|
+
case 'years':
|
|
135
|
+
this._activeDate = this._getNextEnabledDate(this._activeDate.set({
|
|
136
|
+
year: getYearRange(this._activeDate, YEARS_PER_PAGE).start,
|
|
137
|
+
}), 1);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
this[focusActiveDate]();
|
|
141
|
+
}
|
|
142
|
+
_handleEndKey() {
|
|
143
|
+
switch (this.activeView) {
|
|
144
|
+
case 'days': {
|
|
145
|
+
const index = this._daysViews.length - 1;
|
|
146
|
+
const lastView = CalendarDay.from(this._daysViews.item(index).activeDate);
|
|
147
|
+
this._activeDate = this._getNextEnabledDate(lastView.set({ month: lastView.month + 1, date: 0 }), -1);
|
|
148
|
+
this._activeDaysViewIndex = index;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
case 'months':
|
|
152
|
+
this._activeDate = this._getNextEnabledDate(this._activeDate.set({ month: 11 }), -1);
|
|
153
|
+
break;
|
|
154
|
+
case 'years':
|
|
155
|
+
this._activeDate = this._getNextEnabledDate(this._activeDate.set({
|
|
156
|
+
year: getYearRange(this._activeDate, YEARS_PER_PAGE).end,
|
|
157
|
+
}), -1);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
this[focusActiveDate]();
|
|
161
|
+
}
|
|
162
|
+
_handleMonthChange(event) {
|
|
163
|
+
event.stopPropagation();
|
|
164
|
+
this.activeDate = event.detail;
|
|
165
|
+
this.activeView = 'days';
|
|
166
|
+
this[focusActiveDate]();
|
|
167
|
+
}
|
|
168
|
+
_handleYearChange(event) {
|
|
169
|
+
event.stopPropagation();
|
|
170
|
+
this.activeDate = event.detail;
|
|
171
|
+
this.activeView = 'months';
|
|
172
|
+
this[focusActiveDate]();
|
|
173
|
+
}
|
|
174
|
+
_handleValueChange(event) {
|
|
175
|
+
event.stopPropagation();
|
|
176
|
+
const view = event.target;
|
|
177
|
+
if (this._isSingle) {
|
|
178
|
+
this.value = view.value;
|
|
125
179
|
}
|
|
126
|
-
|
|
127
|
-
this.
|
|
180
|
+
else {
|
|
181
|
+
this.values = view.values;
|
|
128
182
|
}
|
|
129
|
-
|
|
130
|
-
this.
|
|
131
|
-
|
|
132
|
-
|
|
183
|
+
this.emitEvent('igcChange', {
|
|
184
|
+
detail: this._isSingle ? this.value : this.values,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
_handleActiveDateChange(event) {
|
|
188
|
+
const view = event.target;
|
|
189
|
+
const views = Array.from(this._daysViews);
|
|
190
|
+
this._activeDaysViewIndex = views.indexOf(view);
|
|
191
|
+
this.activeDate = event.detail;
|
|
192
|
+
if (!areSameMonth(this.activeDate, view.activeDate)) {
|
|
193
|
+
this[focusActiveDate]();
|
|
133
194
|
}
|
|
195
|
+
}
|
|
196
|
+
_handleRangePreviewChange(event) {
|
|
197
|
+
this._rangePreviewDate = event.detail
|
|
198
|
+
? CalendarDay.from(event.detail)
|
|
199
|
+
: undefined;
|
|
200
|
+
}
|
|
201
|
+
_setActiveDaysView(viewIndex) {
|
|
202
|
+
const view = this._daysViews.item(viewIndex);
|
|
203
|
+
this.activeDate = view.activeDate;
|
|
204
|
+
this._activeDaysViewIndex = viewIndex;
|
|
205
|
+
}
|
|
206
|
+
_navigate(delta) {
|
|
207
|
+
const unit = this._isDayView ? 'month' : 'year';
|
|
208
|
+
const increment = (this._isYearView ? YEARS_PER_PAGE : 1) * delta;
|
|
209
|
+
this._activeDate = this._activeDate.add(unit, increment);
|
|
210
|
+
}
|
|
211
|
+
_navigatePrevious() {
|
|
212
|
+
this._navigate(-1);
|
|
213
|
+
}
|
|
214
|
+
_navigateNext() {
|
|
215
|
+
this._navigate(1);
|
|
216
|
+
}
|
|
217
|
+
_navigateToMonthView(viewIndex) {
|
|
218
|
+
this._setActiveDaysView(viewIndex);
|
|
219
|
+
this.activeView = 'months';
|
|
134
220
|
this[focusActiveDate]();
|
|
135
221
|
}
|
|
136
|
-
|
|
222
|
+
_navigateToYearView(viewIndex) {
|
|
137
223
|
if (this._isDayView) {
|
|
138
|
-
|
|
139
|
-
const last = CalendarDay.from(this.daysViews.item(index).activeDate);
|
|
140
|
-
this._activeDate = this.getSubsequentActiveDate(last.set({ month: last.month + 1, date: 0 }), -1);
|
|
141
|
-
this.activeDaysViewIndex = index;
|
|
224
|
+
this._setActiveDaysView(viewIndex);
|
|
142
225
|
}
|
|
143
|
-
|
|
144
|
-
|
|
226
|
+
this.activeView = 'years';
|
|
227
|
+
this[focusActiveDate]();
|
|
228
|
+
}
|
|
229
|
+
async [focusActiveDate](options) {
|
|
230
|
+
await this.updateComplete;
|
|
231
|
+
switch (this.activeView) {
|
|
232
|
+
case 'days':
|
|
233
|
+
return this._daysViews
|
|
234
|
+
.item(this._activeDaysViewIndex)
|
|
235
|
+
.focusActiveDate(options);
|
|
236
|
+
case 'months':
|
|
237
|
+
return this._monthsView.focusActiveDate(options);
|
|
238
|
+
case 'years':
|
|
239
|
+
return this._yearsView.focusActiveDate(options);
|
|
145
240
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
241
|
+
}
|
|
242
|
+
_updateViewIndex(date, delta) {
|
|
243
|
+
if (this.visibleMonths === 1) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const index = this._activeDaysViewIndex;
|
|
247
|
+
const view = CalendarDay.from(this._daysViews.item(index).activeDate);
|
|
248
|
+
if (date.month !== view.month) {
|
|
249
|
+
this._activeDaysViewIndex = clamp(index + delta, 0, this.visibleMonths - 1);
|
|
150
250
|
}
|
|
151
|
-
this[focusActiveDate]();
|
|
152
251
|
}
|
|
153
|
-
|
|
154
|
-
|
|
252
|
+
_getActiveDates() {
|
|
253
|
+
const current = this._activeDaysViewIndex;
|
|
254
|
+
const length = Math.max(this.visibleMonths, 1);
|
|
255
|
+
return Array.from({ length }, (_, i) => this._activeDate.add('month', i - current));
|
|
155
256
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
this.activeView = 'days';
|
|
166
|
-
this.formatOptions = { month: 'long', weekday: 'narrow' };
|
|
167
|
-
this._monthLabelOptions = { month: 'long' };
|
|
168
|
-
this._weekdayOptions = { weekday: 'short' };
|
|
169
|
-
this._monthDayOptions = {
|
|
170
|
-
month: 'short',
|
|
171
|
-
day: 'numeric',
|
|
172
|
-
};
|
|
173
|
-
this._yearLabelOptions = {
|
|
174
|
-
month: 'long',
|
|
175
|
-
year: 'numeric',
|
|
176
|
-
};
|
|
177
|
-
addThemingController(this, all);
|
|
178
|
-
addKeybindings(this, {
|
|
179
|
-
skip: this.isNotFromCalendarView,
|
|
180
|
-
ref: this.contentRef,
|
|
181
|
-
bindingDefaults: { preventDefault: true, triggers: ['keydownRepeat'] },
|
|
182
|
-
})
|
|
183
|
-
.set(arrowLeft, this.handleArrowKey.bind(this, 'day', -1))
|
|
184
|
-
.set(arrowRight, this.handleArrowKey.bind(this, 'day', 1))
|
|
185
|
-
.set(arrowUp, this.handleArrowKey.bind(this, 'week', -1))
|
|
186
|
-
.set(arrowDown, this.handleArrowKey.bind(this, 'week', 1))
|
|
187
|
-
.set([shiftKey, pageUpKey], this.onShiftPageKeys.bind(this, -1))
|
|
188
|
-
.set([shiftKey, pageDownKey], this.onShiftPageKeys.bind(this, 1))
|
|
189
|
-
.set(pageUpKey, this.onPageKeys.bind(this, -1))
|
|
190
|
-
.set(pageDownKey, this.onPageKeys.bind(this, 1))
|
|
191
|
-
.set(homeKey, this.onHomeKey)
|
|
192
|
-
.set(endKey, this.onEndKey);
|
|
193
|
-
}
|
|
194
|
-
renderNavigationButtons() {
|
|
257
|
+
_getNextEnabledDate(start, delta) {
|
|
258
|
+
const disabled = this._disabledDates;
|
|
259
|
+
let beginning = start.clone();
|
|
260
|
+
while (isDateInRanges(beginning, disabled)) {
|
|
261
|
+
beginning = beginning.add('day', delta);
|
|
262
|
+
}
|
|
263
|
+
return beginning;
|
|
264
|
+
}
|
|
265
|
+
_renderNavigationButtons() {
|
|
195
266
|
const parts = {
|
|
196
267
|
'navigation-button': true,
|
|
197
268
|
vertical: this.orientation === 'vertical',
|
|
@@ -200,8 +271,8 @@ export default class IgcCalendarComponent extends EventEmitterMixin(IgcCalendarB
|
|
|
200
271
|
<div part="navigation-buttons">
|
|
201
272
|
<button
|
|
202
273
|
part=${partMap(parts)}
|
|
203
|
-
aria-label=${this.
|
|
204
|
-
@click=${this.
|
|
274
|
+
aria-label=${this._previousButtonLabel}
|
|
275
|
+
@click=${this._navigatePrevious}
|
|
205
276
|
>
|
|
206
277
|
<igc-icon
|
|
207
278
|
aria-hidden="true"
|
|
@@ -212,8 +283,8 @@ export default class IgcCalendarComponent extends EventEmitterMixin(IgcCalendarB
|
|
|
212
283
|
|
|
213
284
|
<button
|
|
214
285
|
part=${partMap(parts)}
|
|
215
|
-
aria-label=${this.
|
|
216
|
-
@click=${this.
|
|
286
|
+
aria-label=${this._nextButtonLabel}
|
|
287
|
+
@click=${this._navigateNext}
|
|
217
288
|
>
|
|
218
289
|
<igc-icon
|
|
219
290
|
aria-hidden="true"
|
|
@@ -224,61 +295,69 @@ export default class IgcCalendarComponent extends EventEmitterMixin(IgcCalendarB
|
|
|
224
295
|
</div>
|
|
225
296
|
`;
|
|
226
297
|
}
|
|
227
|
-
|
|
228
|
-
const
|
|
229
|
-
const
|
|
298
|
+
_renderMonthButtonNavigation(active, viewIndex) {
|
|
299
|
+
const formatter = getDateFormatter();
|
|
300
|
+
const label = formatter.formatDateTime(active.native, this.locale, {
|
|
301
|
+
month: 'long',
|
|
302
|
+
});
|
|
303
|
+
const value = formatter.formatDateTime(active.native, this.locale, {
|
|
304
|
+
month: this.formatOptions.month,
|
|
305
|
+
});
|
|
230
306
|
const ariaLabel = `${label}, ${this.resourceStrings.selectMonth}`;
|
|
231
307
|
return html `
|
|
232
308
|
<button
|
|
233
309
|
part="months-navigation"
|
|
234
310
|
aria-label=${ariaLabel}
|
|
235
|
-
@click=${() => this.
|
|
311
|
+
@click=${() => this._navigateToMonthView(viewIndex)}
|
|
236
312
|
>
|
|
237
313
|
${value}
|
|
238
314
|
</button>
|
|
239
315
|
`;
|
|
240
316
|
}
|
|
241
|
-
|
|
242
|
-
const
|
|
317
|
+
_renderYearButtonNavigation(active, viewIndex) {
|
|
318
|
+
const { format } = getDateFormatter().getIntlFormatter(this.locale, {
|
|
319
|
+
month: 'long',
|
|
320
|
+
year: 'numeric',
|
|
321
|
+
});
|
|
243
322
|
const ariaLabel = `${active.year}, ${this.resourceStrings.selectYear}`;
|
|
244
|
-
const ariaSkip = this._isDayView ?
|
|
323
|
+
const ariaSkip = this._isDayView ? format(active.native) : active.year;
|
|
245
324
|
return html `
|
|
246
325
|
<span class="aria-off-screen" aria-live="polite">${ariaSkip}</span>
|
|
247
326
|
<button
|
|
248
327
|
part="years-navigation"
|
|
249
328
|
aria-label=${ariaLabel}
|
|
250
|
-
@click=${() => this.
|
|
329
|
+
@click=${() => this._navigateToYearView(viewIndex)}
|
|
251
330
|
>
|
|
252
331
|
${active.year}
|
|
253
332
|
</button>
|
|
254
333
|
`;
|
|
255
334
|
}
|
|
256
|
-
|
|
335
|
+
_renderYearRangeNavigation(active) {
|
|
257
336
|
const { start, end } = getYearRange(active, YEARS_PER_PAGE);
|
|
258
337
|
return html `
|
|
259
338
|
<span part="years-range" aria-live="polite"> ${start} - ${end} </span>
|
|
260
339
|
`;
|
|
261
340
|
}
|
|
262
|
-
|
|
341
|
+
_renderNavigation(date, showButtons = true, viewIndex = 0) {
|
|
263
342
|
const activeDate = date ?? this._activeDate;
|
|
264
343
|
return html `
|
|
265
344
|
<div part="navigation">
|
|
266
345
|
<div part="picker-dates">
|
|
267
346
|
${this._isDayView
|
|
268
|
-
? this.
|
|
347
|
+
? this._renderMonthButtonNavigation(activeDate, viewIndex)
|
|
269
348
|
: nothing}
|
|
270
349
|
${this._isDayView || this._isMonthView
|
|
271
|
-
? this.
|
|
350
|
+
? this._renderYearButtonNavigation(activeDate, viewIndex)
|
|
272
351
|
: nothing}
|
|
273
352
|
${this._isYearView
|
|
274
|
-
? this.
|
|
353
|
+
? this._renderYearRangeNavigation(activeDate)
|
|
275
354
|
: nothing}
|
|
276
355
|
</div>
|
|
277
|
-
${showButtons ? this.
|
|
356
|
+
${showButtons ? this._renderNavigationButtons() : nothing}
|
|
278
357
|
</div>
|
|
279
358
|
`;
|
|
280
359
|
}
|
|
281
|
-
|
|
360
|
+
_renderHeader() {
|
|
282
361
|
if (this.hideHeader || this._isMultiple) {
|
|
283
362
|
return nothing;
|
|
284
363
|
}
|
|
@@ -290,24 +369,33 @@ export default class IgcCalendarComponent extends EventEmitterMixin(IgcCalendarB
|
|
|
290
369
|
<h5 part="header-title">
|
|
291
370
|
<slot name="title">${title}</slot>
|
|
292
371
|
</h5>
|
|
293
|
-
<h2 part="header-date">${this.
|
|
372
|
+
<h2 part="header-date">${this._renderHeaderDate()}</h2>
|
|
294
373
|
</div>
|
|
295
374
|
`;
|
|
296
375
|
}
|
|
297
|
-
|
|
376
|
+
_renderHeaderDateSingle() {
|
|
298
377
|
const date = this.value ?? CalendarDay.today.native;
|
|
299
|
-
const
|
|
300
|
-
const
|
|
378
|
+
const formatter = getDateFormatter();
|
|
379
|
+
const weekday = formatter.formatDateTime(date, this.locale, {
|
|
380
|
+
weekday: 'short',
|
|
381
|
+
});
|
|
382
|
+
const monthDay = formatter.formatDateTime(date, this.locale, {
|
|
383
|
+
month: 'short',
|
|
384
|
+
day: 'numeric',
|
|
385
|
+
});
|
|
301
386
|
const separator = this.headerOrientation === 'vertical' ? html `<br />` : ' ';
|
|
302
387
|
const formatted = html `${weekday},${separator}${monthDay}`;
|
|
303
388
|
return html `<slot name="header-date">${formatted}</slot>`;
|
|
304
389
|
}
|
|
305
|
-
|
|
390
|
+
_renderHeaderDateRange() {
|
|
306
391
|
const values = this.values;
|
|
307
|
-
const
|
|
392
|
+
const { format } = getDateFormatter().getIntlFormatter(this.locale, {
|
|
393
|
+
month: 'short',
|
|
394
|
+
day: 'numeric',
|
|
395
|
+
});
|
|
308
396
|
const { startDate, endDate } = this.resourceStrings;
|
|
309
|
-
const start = this._hasValues ?
|
|
310
|
-
const end = this._hasValues && values.length > 1 ?
|
|
397
|
+
const start = this._hasValues ? format(first(values)) : startDate;
|
|
398
|
+
const end = this._hasValues && values.length > 1 ? format(last(values)) : endDate;
|
|
311
399
|
return html `
|
|
312
400
|
<slot name="header-date">
|
|
313
401
|
<span>${start}</span>
|
|
@@ -316,27 +404,27 @@ export default class IgcCalendarComponent extends EventEmitterMixin(IgcCalendarB
|
|
|
316
404
|
</slot>
|
|
317
405
|
`;
|
|
318
406
|
}
|
|
319
|
-
|
|
407
|
+
_renderHeaderDate() {
|
|
320
408
|
return this._isSingle
|
|
321
|
-
? this.
|
|
322
|
-
: this.
|
|
409
|
+
? this._renderHeaderDateSingle()
|
|
410
|
+
: this._renderHeaderDateRange();
|
|
323
411
|
}
|
|
324
|
-
|
|
325
|
-
const activeDates = this.
|
|
412
|
+
_renderDaysView() {
|
|
413
|
+
const activeDates = this._getActiveDates();
|
|
326
414
|
const horizontal = this.orientation === 'horizontal';
|
|
327
415
|
const length = activeDates.length - 1;
|
|
328
416
|
const format = this.formatOptions
|
|
329
417
|
.weekday;
|
|
330
418
|
return html `${activeDates.map((date, idx) => html `
|
|
331
419
|
<div part="days-view-container">
|
|
332
|
-
${this.
|
|
420
|
+
${this._renderNavigation(date, horizontal ? idx === length : idx === 0, idx)}
|
|
333
421
|
<igc-days-view
|
|
334
|
-
@igcChange=${this.
|
|
335
|
-
@igcActiveDateChange=${this.
|
|
336
|
-
@igcRangePreviewDateChange=${this.
|
|
422
|
+
@igcChange=${this._handleValueChange}
|
|
423
|
+
@igcActiveDateChange=${this._handleActiveDateChange}
|
|
424
|
+
@igcRangePreviewDateChange=${this._handleRangePreviewChange}
|
|
337
425
|
part="days-view"
|
|
338
426
|
exportparts="days-row, label, date-inner, week-number-inner, week-number, date, first, last, selected, inactive, hidden, current, content-vertical, weekend, range, special, disabled, single, preview"
|
|
339
|
-
.active=${this.
|
|
427
|
+
.active=${this._activeDaysViewIndex === idx}
|
|
340
428
|
.activeDate=${date.native}
|
|
341
429
|
.disabledDates=${this.disabledDates}
|
|
342
430
|
.hideLeadingDays=${this.hideOutsideDays || idx !== 0}
|
|
@@ -355,28 +443,28 @@ export default class IgcCalendarComponent extends EventEmitterMixin(IgcCalendarB
|
|
|
355
443
|
</div>
|
|
356
444
|
`)}`;
|
|
357
445
|
}
|
|
358
|
-
|
|
446
|
+
_renderMonthView() {
|
|
359
447
|
const format = this.formatOptions
|
|
360
448
|
.month;
|
|
361
449
|
return html `
|
|
362
|
-
${this.
|
|
450
|
+
${this._renderNavigation()}
|
|
363
451
|
<igc-months-view
|
|
364
452
|
part="months-view"
|
|
365
453
|
exportparts="month, selected, month-inner, current"
|
|
366
|
-
@igcChange=${this.
|
|
454
|
+
@igcChange=${this._handleMonthChange}
|
|
367
455
|
.value=${this.activeDate}
|
|
368
456
|
.locale=${this.locale}
|
|
369
457
|
.monthFormat=${format}
|
|
370
458
|
></igc-months-view>
|
|
371
459
|
`;
|
|
372
460
|
}
|
|
373
|
-
|
|
461
|
+
_renderYearView() {
|
|
374
462
|
return html `
|
|
375
|
-
${this.
|
|
463
|
+
${this._renderNavigation()}
|
|
376
464
|
<igc-years-view
|
|
377
465
|
part="years-view"
|
|
378
466
|
exportparts="year, selected, year-inner, current"
|
|
379
|
-
@igcChange=${this.
|
|
467
|
+
@igcChange=${this._handleYearChange}
|
|
380
468
|
.value=${this.activeDate}
|
|
381
469
|
.yearsPerPage=${YEARS_PER_PAGE}
|
|
382
470
|
></igc-years-view>
|
|
@@ -388,100 +476,29 @@ export default class IgcCalendarComponent extends EventEmitterMixin(IgcCalendarB
|
|
|
388
476
|
'content-vertical': this._isDayView && this.orientation === 'vertical',
|
|
389
477
|
};
|
|
390
478
|
return html `
|
|
391
|
-
${this.
|
|
392
|
-
<div ${ref(this.
|
|
479
|
+
${this._renderHeader()}
|
|
480
|
+
<div ${ref(this._contentRef)} part=${partMap(parts)}>
|
|
393
481
|
${choose(this.activeView, [
|
|
394
|
-
['days', () => this.
|
|
395
|
-
['months', () => this.
|
|
396
|
-
['years', () => this.
|
|
482
|
+
['days', () => this._renderDaysView()],
|
|
483
|
+
['months', () => this._renderMonthView()],
|
|
484
|
+
['years', () => this._renderYearView()],
|
|
397
485
|
])}
|
|
398
486
|
</div>
|
|
399
487
|
`;
|
|
400
488
|
}
|
|
401
|
-
changeMonth(event) {
|
|
402
|
-
event.stopPropagation();
|
|
403
|
-
this.activeDate = event.detail;
|
|
404
|
-
this.activeView = 'days';
|
|
405
|
-
this[focusActiveDate]();
|
|
406
|
-
}
|
|
407
|
-
changeYear(event) {
|
|
408
|
-
event.stopPropagation();
|
|
409
|
-
this.activeDate = event.detail;
|
|
410
|
-
this.activeView = 'months';
|
|
411
|
-
this[focusActiveDate]();
|
|
412
|
-
}
|
|
413
|
-
changeValue(event) {
|
|
414
|
-
event.stopPropagation();
|
|
415
|
-
const view = event.target;
|
|
416
|
-
if (this._isSingle) {
|
|
417
|
-
this.value = view.value;
|
|
418
|
-
}
|
|
419
|
-
else {
|
|
420
|
-
this.values = view.values;
|
|
421
|
-
}
|
|
422
|
-
this.emitEvent('igcChange', {
|
|
423
|
-
detail: this._isSingle ? this.value : this.values,
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
activeDateChanged(event) {
|
|
427
|
-
const view = event.target;
|
|
428
|
-
const views = Array.from(this.daysViews);
|
|
429
|
-
this.activeDaysViewIndex = views.indexOf(view);
|
|
430
|
-
this.activeDate = event.detail;
|
|
431
|
-
if (!areSameMonth(this.activeDate, view.activeDate)) {
|
|
432
|
-
this[focusActiveDate]();
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
rangePreviewDateChanged(event) {
|
|
436
|
-
this._rangePreviewDate = event.detail
|
|
437
|
-
? CalendarDay.from(event.detail)
|
|
438
|
-
: undefined;
|
|
439
|
-
}
|
|
440
|
-
getActiveDates() {
|
|
441
|
-
const current = this.activeDaysViewIndex;
|
|
442
|
-
const length = Math.max(this.visibleMonths, 1);
|
|
443
|
-
return Array.from({ length }, (_, i) => this._activeDate.add('month', i - current));
|
|
444
|
-
}
|
|
445
|
-
activateDaysView(index) {
|
|
446
|
-
const view = this.daysViews.item(index);
|
|
447
|
-
this.activeDate = view.activeDate;
|
|
448
|
-
this.activeDaysViewIndex = index;
|
|
449
|
-
}
|
|
450
|
-
navigatePrevious() {
|
|
451
|
-
const unit = this._isDayView ? 'month' : 'year';
|
|
452
|
-
const delta = this._isYearView ? YEARS_PER_PAGE : 1;
|
|
453
|
-
this._activeDate = this._activeDate.add(unit, -delta);
|
|
454
|
-
}
|
|
455
|
-
navigateNext() {
|
|
456
|
-
const unit = this._isDayView ? 'month' : 'year';
|
|
457
|
-
const delta = this._isYearView ? YEARS_PER_PAGE : 1;
|
|
458
|
-
this._activeDate = this._activeDate.add(unit, delta);
|
|
459
|
-
}
|
|
460
|
-
switchToMonths(viewIndex) {
|
|
461
|
-
this.activateDaysView(viewIndex);
|
|
462
|
-
this.activeView = 'months';
|
|
463
|
-
this[focusActiveDate]();
|
|
464
|
-
}
|
|
465
|
-
switchToYears(viewIndex) {
|
|
466
|
-
if (this._isDayView) {
|
|
467
|
-
this.activateDaysView(viewIndex);
|
|
468
|
-
}
|
|
469
|
-
this.activeView = 'years';
|
|
470
|
-
this[focusActiveDate]();
|
|
471
|
-
}
|
|
472
489
|
}
|
|
473
490
|
__decorate([
|
|
474
491
|
state()
|
|
475
|
-
], IgcCalendarComponent.prototype, "
|
|
492
|
+
], IgcCalendarComponent.prototype, "_activeDaysViewIndex", void 0);
|
|
476
493
|
__decorate([
|
|
477
494
|
queryAll(IgcDaysViewComponent.tagName)
|
|
478
|
-
], IgcCalendarComponent.prototype, "
|
|
495
|
+
], IgcCalendarComponent.prototype, "_daysViews", void 0);
|
|
479
496
|
__decorate([
|
|
480
497
|
query(IgcMonthsViewComponent.tagName)
|
|
481
|
-
], IgcCalendarComponent.prototype, "
|
|
498
|
+
], IgcCalendarComponent.prototype, "_monthsView", void 0);
|
|
482
499
|
__decorate([
|
|
483
500
|
query(IgcYearsViewComponent.tagName)
|
|
484
|
-
], IgcCalendarComponent.prototype, "
|
|
501
|
+
], IgcCalendarComponent.prototype, "_yearsView", void 0);
|
|
485
502
|
__decorate([
|
|
486
503
|
property({ type: Boolean, attribute: 'hide-outside-days', reflect: true })
|
|
487
504
|
], IgcCalendarComponent.prototype, "hideOutsideDays", void 0);
|