@clr/angular 18.0.0 → 18.1.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.
@@ -211,6 +211,27 @@ function datesAreEqual(date1, date2) {
211
211
  }
212
212
  }
213
213
 
214
+ /*
215
+ * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.
216
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
217
+ * This software is released under MIT license.
218
+ * The full license information can be found in LICENSE in the root directory of this project.
219
+ */
220
+ /**
221
+ * Index of the day of the week, matching JavaScript's Date.getDay() convention.
222
+ * Used to override the locale-derived first day of the week in the date picker.
223
+ */
224
+ var ClrWeekday;
225
+ (function (ClrWeekday) {
226
+ ClrWeekday[ClrWeekday["Sunday"] = 0] = "Sunday";
227
+ ClrWeekday[ClrWeekday["Monday"] = 1] = "Monday";
228
+ ClrWeekday[ClrWeekday["Tuesday"] = 2] = "Tuesday";
229
+ ClrWeekday[ClrWeekday["Wednesday"] = 3] = "Wednesday";
230
+ ClrWeekday[ClrWeekday["Thursday"] = 4] = "Thursday";
231
+ ClrWeekday[ClrWeekday["Friday"] = 5] = "Friday";
232
+ ClrWeekday[ClrWeekday["Saturday"] = 6] = "Saturday";
233
+ })(ClrWeekday || (ClrWeekday = {}));
234
+
214
235
  /*
215
236
  * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.
216
237
  * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
@@ -223,7 +244,7 @@ function datesAreEqual(date1, date2) {
223
244
  class LocaleHelperService {
224
245
  constructor(locale) {
225
246
  this.locale = locale;
226
- this._firstDayOfWeek = 0;
247
+ this._firstDayOfWeek = ClrWeekday.Sunday;
227
248
  this.initializeLocaleData();
228
249
  }
229
250
  get firstDayOfWeek() {
@@ -245,12 +266,26 @@ class LocaleHelperService {
245
266
  get localeDateFormat() {
246
267
  return this._localeDateFormat;
247
268
  }
269
+ /**
270
+ * Overrides the first day of the week regardless of locale.
271
+ * Accepts a `ClrWeekday` value (Sunday=0 through Saturday=6), or null to revert to locale default.
272
+ * Incorrect values will revert to default value (Sunday).
273
+ */
274
+ updateFirstDayOfWeek(day) {
275
+ if (day === null || day < ClrWeekday.Sunday || day > ClrWeekday.Saturday) {
276
+ this.initializeLocaleFirstDayOfWeek();
277
+ this.initializeLocaleDays();
278
+ return;
279
+ }
280
+ this._firstDayOfWeek = day;
281
+ this.initializeLocaleDays();
282
+ }
248
283
  /**
249
284
  * Initializes the locale data.
250
285
  */
251
286
  initializeLocaleData() {
252
287
  // Order in which these functions is called is very important.
253
- this.initializeFirstDayOfWeek();
288
+ this.initializeLocaleFirstDayOfWeek();
254
289
  this.initializeLocaleDateFormat();
255
290
  this.initializeLocaleMonthsAbbreviated();
256
291
  this.initializeLocaleMonthsWide();
@@ -265,14 +300,12 @@ class LocaleHelperService {
265
300
  const tempArr = [];
266
301
  const tempWideArr = getLocaleDayNames(this.locale, FormStyle.Standalone, TranslationWidth.Wide).slice();
267
302
  const tempNarrowArr = getLocaleDayNames(this.locale, FormStyle.Standalone, TranslationWidth.Narrow).slice();
268
- // Get first day of the week based on the locale
269
- const firstDayOfWeek = this.firstDayOfWeek;
270
303
  for (let i = 0; i < 7; i++) {
271
304
  tempArr.push({ day: tempWideArr[i], narrow: tempNarrowArr[i] });
272
305
  }
273
- // Rearrange the tempArr to start with the first day of the week based on the locale.
274
- if (firstDayOfWeek > 0) {
275
- const prevDays = tempArr.splice(0, firstDayOfWeek);
306
+ // Rearrange the tempArr to start with the first day of the week based on the locale (default or override).
307
+ if (this.firstDayOfWeek > ClrWeekday.Sunday) {
308
+ const prevDays = tempArr.splice(0, this.firstDayOfWeek);
276
309
  tempArr.push(...prevDays);
277
310
  }
278
311
  this._localeDays = tempArr;
@@ -294,7 +327,7 @@ class LocaleHelperService {
294
327
  /**
295
328
  * Initializes the first day of the week based on the locale.
296
329
  */
297
- initializeFirstDayOfWeek() {
330
+ initializeLocaleFirstDayOfWeek() {
298
331
  this._firstDayOfWeek = getLocaleFirstDayOfWeek(this.locale);
299
332
  }
300
333
  initializeLocaleDateFormat() {
@@ -2272,7 +2305,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
2272
2305
  * The full license information can be found in LICENSE in the root directory of this project.
2273
2306
  */
2274
2307
  class ClrDateContainer extends ClrAbstractContainer {
2275
- constructor(renderer, elem, popoverService, dateNavigationService, datepickerEnabledService, dateFormControlService, dateIOService, commonStrings, focusService, viewManagerService, controlClassService, layoutService, ngControlService) {
2308
+ constructor(renderer, elem, popoverService, dateNavigationService, datepickerEnabledService, dateFormControlService, dateIOService, commonStrings, focusService, viewManagerService, controlClassService, layoutService, ngControlService, localeHelperService) {
2276
2309
  super(layoutService, controlClassService, ngControlService);
2277
2310
  this.renderer = renderer;
2278
2311
  this.elem = elem;
@@ -2286,6 +2319,7 @@ class ClrDateContainer extends ClrAbstractContainer {
2286
2319
  this.controlClassService = controlClassService;
2287
2320
  this.layoutService = layoutService;
2288
2321
  this.ngControlService = ngControlService;
2322
+ this.localeHelperService = localeHelperService;
2289
2323
  this.focus = false;
2290
2324
  this.popoverType = ClrPopoverType.DROPDOWN;
2291
2325
  this.subscriptions.push(focusService.focusChange.subscribe(state => {
@@ -2300,6 +2334,14 @@ class ClrDateContainer extends ClrAbstractContainer {
2300
2334
  tagName === 'clr-date-range-container';
2301
2335
  }
2302
2336
  }
2337
+ /**
2338
+ * Overrides the locale-derived first day of the week for the calendar.
2339
+ * Accepts a `ClrWeekday` value (Sunday=0 through Saturday=6).
2340
+ * When not set, the first day of the week is determined by the Angular locale.
2341
+ */
2342
+ set firstDayOfWeek(value) {
2343
+ this.localeHelperService.updateFirstDayOfWeek(value ?? null);
2344
+ }
2303
2345
  /**
2304
2346
  * For date range picker actions buttons are shown by default
2305
2347
  */
@@ -2426,8 +2468,8 @@ class ClrDateContainer extends ClrAbstractContainer {
2426
2468
  }
2427
2469
  }
2428
2470
  }
2429
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ClrDateContainer, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1.ClrPopoverService }, { token: DateNavigationService }, { token: DatepickerEnabledService }, { token: DateFormControlService }, { token: DateIOService }, { token: i4.ClrCommonStringsService }, { token: i7.FormsFocusService }, { token: ViewManagerService }, { token: i7.ControlClassService }, { token: i7.LayoutService, optional: true }, { token: i7.NgControlService }], target: i0.ɵɵFactoryTarget.Component }); }
2430
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: ClrDateContainer, isStandalone: false, selector: "clr-date-container, clr-date-range-container", inputs: { showActionButtons: "showActionButtons", clrPosition: "clrPosition", rangeOptions: "rangeOptions", min: "min", max: "max" }, host: { properties: { "class.clr-date-container": "true", "class.clr-form-control-disabled": "isInputDateDisabled", "class.clr-form-control": "true", "class.clr-row": "addGrid()" } }, providers: [
2471
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: ClrDateContainer, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1.ClrPopoverService }, { token: DateNavigationService }, { token: DatepickerEnabledService }, { token: DateFormControlService }, { token: DateIOService }, { token: i4.ClrCommonStringsService }, { token: i7.FormsFocusService }, { token: ViewManagerService }, { token: i7.ControlClassService }, { token: i7.LayoutService, optional: true }, { token: i7.NgControlService }, { token: LocaleHelperService }], target: i0.ɵɵFactoryTarget.Component }); }
2472
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: ClrDateContainer, isStandalone: false, selector: "clr-date-container, clr-date-range-container", inputs: { firstDayOfWeek: ["clrFirstDayOfWeek", "firstDayOfWeek"], showActionButtons: "showActionButtons", clrPosition: "clrPosition", rangeOptions: "rangeOptions", min: "min", max: "max" }, host: { properties: { "class.clr-date-container": "true", "class.clr-form-control-disabled": "isInputDateDisabled", "class.clr-form-control": "true", "class.clr-row": "addGrid()" } }, providers: [
2431
2473
  ControlIdService,
2432
2474
  LocaleHelperService,
2433
2475
  ControlClassService,
@@ -2566,7 +2608,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
2566
2608
  }]
2567
2609
  }], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1.ClrPopoverService }, { type: DateNavigationService }, { type: DatepickerEnabledService }, { type: DateFormControlService }, { type: DateIOService }, { type: i4.ClrCommonStringsService }, { type: i7.FormsFocusService }, { type: ViewManagerService }, { type: i7.ControlClassService }, { type: i7.LayoutService, decorators: [{
2568
2610
  type: Optional
2569
- }] }, { type: i7.NgControlService }], propDecorators: { showActionButtons: [{
2611
+ }] }, { type: i7.NgControlService }, { type: LocaleHelperService }], propDecorators: { firstDayOfWeek: [{
2612
+ type: Input,
2613
+ args: ['clrFirstDayOfWeek']
2614
+ }], showActionButtons: [{
2570
2615
  type: Input,
2571
2616
  args: ['showActionButtons']
2572
2617
  }], clrPosition: [{
@@ -3119,6 +3164,13 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
3119
3164
  type: Optional
3120
3165
  }] }] });
3121
3166
 
3167
+ /*
3168
+ * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.
3169
+ * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
3170
+ * This software is released under MIT license.
3171
+ * The full license information can be found in LICENSE in the root directory of this project.
3172
+ */
3173
+
3122
3174
  /*
3123
3175
  * Copyright (c) 2016-2026 Broadcom. All Rights Reserved.
3124
3176
  * The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries.
@@ -3218,5 +3270,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImpor
3218
3270
  * Generated bundle index. Do not edit.
3219
3271
  */
3220
3272
 
3221
- export { CLR_DATEPICKER_DIRECTIVES, ClrCalendar, ClrDateContainer, ClrDateInput, ClrDateInputBase, ClrDateInputValidator, ClrDatepickerActions, ClrDatepickerModule, ClrDatepickerViewManager, ClrDay, ClrDaypicker, ClrEndDateInput, ClrEndDateInputValidator, ClrMonthpicker, ClrStartDateInput, ClrStartDateInputValidator, ClrYearpicker };
3273
+ export { CLR_DATEPICKER_DIRECTIVES, ClrCalendar, ClrDateContainer, ClrDateInput, ClrDateInputBase, ClrDateInputValidator, ClrDatepickerActions, ClrDatepickerModule, ClrDatepickerViewManager, ClrDay, ClrDaypicker, ClrEndDateInput, ClrEndDateInputValidator, ClrMonthpicker, ClrStartDateInput, ClrStartDateInputValidator, ClrWeekday, ClrYearpicker };
3222
3274
  //# sourceMappingURL=clr-angular-forms-datepicker.mjs.map