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.
Files changed (90) hide show
  1. package/CHANGELOG.md +62 -0
  2. package/components/calendar/base.d.ts +7 -3
  3. package/components/calendar/base.js +10 -14
  4. package/components/calendar/base.js.map +1 -1
  5. package/components/calendar/calendar.d.ts +48 -46
  6. package/components/calendar/calendar.js +259 -242
  7. package/components/calendar/calendar.js.map +1 -1
  8. package/components/calendar/days-view/days-view.d.ts +49 -27
  9. package/components/calendar/days-view/days-view.js +169 -160
  10. package/components/calendar/days-view/days-view.js.map +1 -1
  11. package/components/calendar/helpers.js +40 -28
  12. package/components/calendar/helpers.js.map +1 -1
  13. package/components/calendar/model.d.ts +9 -3
  14. package/components/calendar/model.js +29 -19
  15. package/components/calendar/model.js.map +1 -1
  16. package/components/calendar/months-view/months-view.d.ts +6 -7
  17. package/components/calendar/months-view/months-view.js +24 -27
  18. package/components/calendar/months-view/months-view.js.map +1 -1
  19. package/components/calendar/years-view/years-view.d.ts +6 -5
  20. package/components/calendar/years-view/years-view.js +11 -14
  21. package/components/calendar/years-view/years-view.js.map +1 -1
  22. package/components/checkbox/checkbox-base.d.ts +1 -1
  23. package/components/chip/themes/dark/chip.fluent.css.js +1 -1
  24. package/components/chip/themes/dark/chip.fluent.css.js.map +1 -1
  25. package/components/chip/themes/dark/chip.indigo.css.js +1 -1
  26. package/components/chip/themes/dark/chip.indigo.css.js.map +1 -1
  27. package/components/chip/themes/light/chip.fluent.css.js +1 -1
  28. package/components/chip/themes/light/chip.fluent.css.js.map +1 -1
  29. package/components/chip/themes/light/chip.indigo.css.js +1 -1
  30. package/components/chip/themes/light/chip.indigo.css.js.map +1 -1
  31. package/components/chip/themes/light/chip.shared.css.js +1 -1
  32. package/components/chip/themes/light/chip.shared.css.js.map +1 -1
  33. package/components/chip/themes/shared/chip.indigo.css.js +1 -1
  34. package/components/chip/themes/shared/chip.indigo.css.js.map +1 -1
  35. package/components/common/definitions/defineAllComponents.js +2 -0
  36. package/components/common/definitions/defineAllComponents.js.map +1 -1
  37. package/components/date-range-picker/date-range-picker.js +1 -1
  38. package/components/date-range-picker/date-range-picker.js.map +1 -1
  39. package/components/date-time-input/date-time-input.d.ts +4 -1
  40. package/components/date-time-input/date-time-input.js +17 -6
  41. package/components/date-time-input/date-time-input.js.map +1 -1
  42. package/components/file-input/file-input.d.ts +15 -13
  43. package/components/file-input/file-input.js +49 -47
  44. package/components/file-input/file-input.js.map +1 -1
  45. package/components/input/input-base.d.ts +31 -34
  46. package/components/input/input-base.js +58 -83
  47. package/components/input/input-base.js.map +1 -1
  48. package/components/input/input.d.ts +18 -7
  49. package/components/input/input.js +34 -19
  50. package/components/input/input.js.map +1 -1
  51. package/components/mask-input/mask-input-base.d.ts +10 -4
  52. package/components/mask-input/mask-input-base.js +18 -14
  53. package/components/mask-input/mask-input-base.js.map +1 -1
  54. package/components/mask-input/mask-input.d.ts +9 -3
  55. package/components/mask-input/mask-input.js +26 -6
  56. package/components/mask-input/mask-input.js.map +1 -1
  57. package/components/mask-input/validators.js +1 -1
  58. package/components/mask-input/validators.js.map +1 -1
  59. package/components/theme-provider/theme-provider.d.ts +65 -0
  60. package/components/theme-provider/theme-provider.js +58 -0
  61. package/components/theme-provider/theme-provider.js.map +1 -0
  62. package/components/tile-manager/tile.js +6 -3
  63. package/components/tile-manager/tile.js.map +1 -1
  64. package/custom-elements.json +2136 -1596
  65. package/extras/chat-markdown-renderer.d.ts +72 -4
  66. package/extras/chat-markdown-renderer.js +19 -7
  67. package/extras/chat-markdown-renderer.js.map +1 -1
  68. package/igniteui-webcomponents.html-data.json +1 -1
  69. package/index.d.ts +3 -0
  70. package/index.js +2 -0
  71. package/index.js.map +1 -1
  72. package/package.json +1 -1
  73. package/themes/dark/bootstrap.css +1 -1
  74. package/themes/dark/fluent.css +1 -1
  75. package/themes/dark/indigo.css +1 -1
  76. package/themes/dark/material.css +1 -1
  77. package/themes/light/bootstrap.css +1 -1
  78. package/themes/light/fluent.css +1 -1
  79. package/themes/light/indigo.css +1 -1
  80. package/themes/light/material.css +1 -1
  81. package/theming/context.d.ts +36 -0
  82. package/theming/context.js +3 -0
  83. package/theming/context.js.map +1 -0
  84. package/theming/theming-controller.d.ts +7 -1
  85. package/theming/theming-controller.js +48 -12
  86. package/theming/theming-controller.js.map +1 -1
  87. package/theming/utils.d.ts +10 -0
  88. package/theming/utils.js +8 -42
  89. package/theming/utils.js.map +1 -1
  90. 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 previousButtonLabel() {
44
- if (this._isDayView) {
45
- return this.resourceStrings.previousMonth;
46
- }
47
- if (this._isMonthView) {
48
- return this.resourceStrings.previousYear;
49
- }
50
- return formatString(this.resourceStrings.previousYears, YEARS_PER_PAGE);
51
- }
52
- get nextButtonLabel() {
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 _monthOptions() {
62
- return { month: this.formatOptions.month };
63
- }
64
- async [focusActiveDate](options) {
65
- await this.updateComplete;
66
- if (this._isDayView) {
67
- return this.daysViews
68
- .item(this.activeDaysViewIndex)
69
- .focusActiveDate(options);
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
- updateViewIndex(date, delta) {
79
- if (this.visibleMonths === 1)
80
- return;
81
- const index = this.activeDaysViewIndex;
82
- const view = CalendarDay.from(this.daysViews.item(index).activeDate);
83
- if (date.month !== view.month) {
84
- this.activeDaysViewIndex = clamp(index + delta, 0, this.visibleMonths - 1);
85
- }
86
- }
87
- getSubsequentActiveDate(start, delta) {
88
- const disabled = this._disabledDates;
89
- let beginning = start.clone();
90
- while (isDateInRanges(beginning, disabled)) {
91
- beginning = beginning.add('day', delta);
92
- }
93
- return beginning;
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
- handleArrowKey(period, delta) {
98
+ _handleArrowKey(period, delta) {
96
99
  if (this._isDayView) {
97
- const date = this.getSubsequentActiveDate(this._activeDate.add(period, delta), delta);
98
- this.updateViewIndex(date, delta);
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.getSubsequentActiveDate(this._activeDate.add(monthOrYear, period === 'week' ? monthOrYearDelta : delta), delta);
107
+ this._activeDate = this._getNextEnabledDate(this._activeDate.add(monthOrYear, period === 'week' ? monthOrYearDelta : delta), delta);
105
108
  }
106
109
  this[focusActiveDate]();
107
110
  }
108
- onPageKeys(delta) {
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.getSubsequentActiveDate(this._activeDate.add(unit, increment), increment);
114
+ this._activeDate = this._getNextEnabledDate(this._activeDate.add(unit, increment), increment);
112
115
  this[focusActiveDate]();
113
116
  }
114
- onShiftPageKeys(delta) {
117
+ _handleShiftPageKeys(delta) {
115
118
  if (this._isDayView) {
116
- this._activeDate = this.getSubsequentActiveDate(this._activeDate.add('year', delta), delta);
119
+ this._activeDate = this._getNextEnabledDate(this._activeDate.add('year', delta), delta);
117
120
  this[focusActiveDate]();
118
121
  }
119
122
  }
120
- onHomeKey() {
121
- if (this._isDayView) {
122
- const first = CalendarDay.from(this.daysViews.item(0).activeDate);
123
- this._activeDate = this.getSubsequentActiveDate(first.set({ date: 1 }), 1);
124
- this.activeDaysViewIndex = 0;
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
- if (this._isMonthView) {
127
- this._activeDate = this.getSubsequentActiveDate(this._activeDate.set({ month: 0 }), 1);
180
+ else {
181
+ this.values = view.values;
128
182
  }
129
- if (this._isYearView) {
130
- this._activeDate = this.getSubsequentActiveDate(this._activeDate.set({
131
- year: getYearRange(this._activeDate, YEARS_PER_PAGE).start,
132
- }), 1);
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
- onEndKey() {
222
+ _navigateToYearView(viewIndex) {
137
223
  if (this._isDayView) {
138
- const index = this.daysViews.length - 1;
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
- if (this._isMonthView) {
144
- this._activeDate = this.getSubsequentActiveDate(this._activeDate.set({ month: 11 }), -1);
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
- if (this._isYearView) {
147
- this._activeDate = this.getSubsequentActiveDate(this._activeDate.set({
148
- year: getYearRange(this._activeDate, YEARS_PER_PAGE).end,
149
- }), -1);
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
- isNotFromCalendarView(_, event) {
154
- return !findElementFromEventPath(`${IgcDaysViewComponent.tagName}, ${IgcMonthsViewComponent.tagName}, ${IgcYearsViewComponent.tagName}`, event);
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
- constructor() {
157
- super();
158
- this.contentRef = createRef();
159
- this.activeDaysViewIndex = 0;
160
- this.hideOutsideDays = false;
161
- this.hideHeader = false;
162
- this.headerOrientation = 'horizontal';
163
- this.orientation = 'horizontal';
164
- this.visibleMonths = 1;
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.previousButtonLabel}
204
- @click=${this.navigatePrevious}
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.nextButtonLabel}
216
- @click=${this.navigateNext}
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
- renderMonthButtonNavigation(active, viewIndex) {
228
- const label = getDateFormatter().formatDateTime(active.native, this.locale, this._monthLabelOptions);
229
- const value = getDateFormatter().formatDateTime(active.native, this.locale, this._monthOptions);
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.switchToMonths(viewIndex)}
311
+ @click=${() => this._navigateToMonthView(viewIndex)}
236
312
  >
237
313
  ${value}
238
314
  </button>
239
315
  `;
240
316
  }
241
- renderYearButtonNavigation(active, viewIndex) {
242
- const fmt = getDateFormatter().getIntlFormatter(this.locale, this._yearLabelOptions).format;
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 ? fmt(active.native) : active.year;
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.switchToYears(viewIndex)}
329
+ @click=${() => this._navigateToYearView(viewIndex)}
251
330
  >
252
331
  ${active.year}
253
332
  </button>
254
333
  `;
255
334
  }
256
- renderYearRangeNavigation(active) {
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
- renderNavigation(date, showButtons = true, viewIndex = 0) {
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.renderMonthButtonNavigation(activeDate, viewIndex)
347
+ ? this._renderMonthButtonNavigation(activeDate, viewIndex)
269
348
  : nothing}
270
349
  ${this._isDayView || this._isMonthView
271
- ? this.renderYearButtonNavigation(activeDate, viewIndex)
350
+ ? this._renderYearButtonNavigation(activeDate, viewIndex)
272
351
  : nothing}
273
352
  ${this._isYearView
274
- ? this.renderYearRangeNavigation(activeDate)
353
+ ? this._renderYearRangeNavigation(activeDate)
275
354
  : nothing}
276
355
  </div>
277
- ${showButtons ? this.renderNavigationButtons() : nothing}
356
+ ${showButtons ? this._renderNavigationButtons() : nothing}
278
357
  </div>
279
358
  `;
280
359
  }
281
- renderHeader() {
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.renderHeaderDate()}</h2>
372
+ <h2 part="header-date">${this._renderHeaderDate()}</h2>
294
373
  </div>
295
374
  `;
296
375
  }
297
- renderHeaderDateSingle() {
376
+ _renderHeaderDateSingle() {
298
377
  const date = this.value ?? CalendarDay.today.native;
299
- const weekday = getDateFormatter().formatDateTime(date, this.locale, this._weekdayOptions);
300
- const monthDay = getDateFormatter().formatDateTime(date, this.locale, this._monthDayOptions);
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
- renderHeaderDateRange() {
390
+ _renderHeaderDateRange() {
306
391
  const values = this.values;
307
- const fmt = getDateFormatter().getIntlFormatter(this.locale, this._monthDayOptions).format;
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 ? fmt(first(values)) : startDate;
310
- const end = this._hasValues && values.length > 1 ? fmt(last(values)) : endDate;
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
- renderHeaderDate() {
407
+ _renderHeaderDate() {
320
408
  return this._isSingle
321
- ? this.renderHeaderDateSingle()
322
- : this.renderHeaderDateRange();
409
+ ? this._renderHeaderDateSingle()
410
+ : this._renderHeaderDateRange();
323
411
  }
324
- renderDaysView() {
325
- const activeDates = this.getActiveDates();
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.renderNavigation(date, horizontal ? idx === length : idx === 0, idx)}
420
+ ${this._renderNavigation(date, horizontal ? idx === length : idx === 0, idx)}
333
421
  <igc-days-view
334
- @igcChange=${this.changeValue}
335
- @igcActiveDateChange=${this.activeDateChanged}
336
- @igcRangePreviewDateChange=${this.rangePreviewDateChanged}
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.activeDaysViewIndex === idx}
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
- renderMonthView() {
446
+ _renderMonthView() {
359
447
  const format = this.formatOptions
360
448
  .month;
361
449
  return html `
362
- ${this.renderNavigation()}
450
+ ${this._renderNavigation()}
363
451
  <igc-months-view
364
452
  part="months-view"
365
453
  exportparts="month, selected, month-inner, current"
366
- @igcChange=${this.changeMonth}
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
- renderYearView() {
461
+ _renderYearView() {
374
462
  return html `
375
- ${this.renderNavigation()}
463
+ ${this._renderNavigation()}
376
464
  <igc-years-view
377
465
  part="years-view"
378
466
  exportparts="year, selected, year-inner, current"
379
- @igcChange=${this.changeYear}
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.renderHeader()}
392
- <div ${ref(this.contentRef)} part=${partMap(parts)}>
479
+ ${this._renderHeader()}
480
+ <div ${ref(this._contentRef)} part=${partMap(parts)}>
393
481
  ${choose(this.activeView, [
394
- ['days', () => this.renderDaysView()],
395
- ['months', () => this.renderMonthView()],
396
- ['years', () => this.renderYearView()],
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, "activeDaysViewIndex", void 0);
492
+ ], IgcCalendarComponent.prototype, "_activeDaysViewIndex", void 0);
476
493
  __decorate([
477
494
  queryAll(IgcDaysViewComponent.tagName)
478
- ], IgcCalendarComponent.prototype, "daysViews", void 0);
495
+ ], IgcCalendarComponent.prototype, "_daysViews", void 0);
479
496
  __decorate([
480
497
  query(IgcMonthsViewComponent.tagName)
481
- ], IgcCalendarComponent.prototype, "monthsView", void 0);
498
+ ], IgcCalendarComponent.prototype, "_monthsView", void 0);
482
499
  __decorate([
483
500
  query(IgcYearsViewComponent.tagName)
484
- ], IgcCalendarComponent.prototype, "yearsView", void 0);
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);