@energinet/watt 1.5.8 → 1.5.10

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.
@@ -1,6 +1,6 @@
1
1
  import { getLocaleDateFormat, FormatWidth } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { inject, ElementRef, ChangeDetectorRef, LOCALE_ID, input, computed, effect, Input, ViewChild, ViewEncapsulation, Component, Injectable } from '@angular/core';
3
+ import { inject, ElementRef, ChangeDetectorRef, LOCALE_ID, input, booleanAttribute, computed, linkedSignal, effect, ViewChild, ViewEncapsulation, Component, Injectable } from '@angular/core';
4
4
  import { NgControl } from '@angular/forms';
5
5
  import * as i1 from '@angular/material/datepicker';
6
6
  import { MatDatepickerModule, MatDatepickerInput, MatDateRangePicker, MatDateRangeInput, MatStartDate, MatEndDate, MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER } from '@angular/material/datepicker';
@@ -51,8 +51,10 @@ class WattDatepickerComponent extends WattPickerBase {
51
51
  max = input();
52
52
  min = input();
53
53
  rangeMonthOnlyMode = input(false);
54
- startAt = null;
55
- label = '';
54
+ startAt = input(null);
55
+ label = input('');
56
+ dateClass = input(() => '');
57
+ canStepThroughDays = input(false, { transform: booleanAttribute });
56
58
  /**
57
59
  * @ignore
58
60
  */
@@ -87,7 +89,6 @@ class WattDatepickerComponent extends WattPickerBase {
87
89
  * @ignore
88
90
  */
89
91
  _placeholder = this.getPlaceholder(this.getInputFormat());
90
- dateClass = () => '';
91
92
  /**
92
93
  * @ignore
93
94
  */
@@ -127,6 +128,8 @@ class WattDatepickerComponent extends WattPickerBase {
127
128
  getRangePlaceholder() {
128
129
  return this.datePlaceholder + this.rangeSeparator + this.datePlaceholder;
129
130
  }
131
+ isPrevDayButtonDisabled = linkedSignal(() => this.isPrevDayBeforeOrEqualToMinDate());
132
+ isNextDayButtonDisabled = linkedSignal(() => this.isNextDayAfterOrEqualToMaxDate());
130
133
  constructor() {
131
134
  super(`watt-datepicker-${WattDatepickerComponent.nextId++}`);
132
135
  effect(() => {
@@ -175,13 +178,14 @@ class WattDatepickerComponent extends WattPickerBase {
175
178
  datepickerClosed() {
176
179
  if (this.matDatepickerInput.value) {
177
180
  this.control?.setValue(this.matDatepickerInput.value);
178
- this.actualInput.nativeElement.value =
179
- this.formatDateTimeFromModelToView(this.formatDateFromViewToModel(this.matDatepickerInput.value));
181
+ this.actualInput.nativeElement.value = this.formatDateTimeFromModelToView(this.formatDateFromViewToModel(this.matDatepickerInput.value));
180
182
  }
181
183
  else {
182
184
  this.actualInput.nativeElement.value = '';
183
185
  this.control?.setValue(null);
184
186
  }
187
+ this.isPrevDayButtonDisabled.set(this.isPrevDayBeforeOrEqualToMinDate());
188
+ this.isNextDayButtonDisabled.set(this.isNextDayAfterOrEqualToMaxDate());
185
189
  this.actualInput.nativeElement.dispatchEvent(new InputEvent('input'));
186
190
  }
187
191
  onMonthSelected(date) {
@@ -253,6 +257,54 @@ class WattDatepickerComponent extends WattPickerBase {
253
257
  this.setValueToInput(start, startInput, this.matStartDate);
254
258
  this.setValueToInput(end, endInput, this.matEndDate);
255
259
  }
260
+ /**
261
+ * @ignore
262
+ */
263
+ prevDay() {
264
+ this.changeDay(-1);
265
+ }
266
+ /**
267
+ * @ignore
268
+ */
269
+ nextDay() {
270
+ this.changeDay(1);
271
+ }
272
+ /**
273
+ * @ignore
274
+ */
275
+ changeDay(value) {
276
+ const currentDate = this.matDatepickerInput.value;
277
+ if (currentDate) {
278
+ const newDate = dayjs(currentDate).add(value, 'day').toISOString();
279
+ const newDateFormatted = this.formatDateTimeFromModelToView(newDate);
280
+ this.inputChanged(newDateFormatted);
281
+ this.datepickerClosed();
282
+ }
283
+ }
284
+ /**
285
+ * @ignore
286
+ */
287
+ isPrevDayBeforeOrEqualToMinDate() {
288
+ const min = this.min();
289
+ const selectedDate = this.matDatepickerInput?.value;
290
+ if (!min || !selectedDate)
291
+ return false;
292
+ const isBefore = dayjs(selectedDate).isBefore(min, 'day');
293
+ const isSame = dayjs(selectedDate).isSame(min, 'day');
294
+ return isSame || isBefore;
295
+ }
296
+ /**
297
+ * @ignore
298
+ */
299
+ isNextDayAfterOrEqualToMaxDate() {
300
+ const max = this.max();
301
+ const selectedDate = this.matDatepickerInput?.value;
302
+ if (!max || !selectedDate)
303
+ return false;
304
+ const isAfter = dayjs(selectedDate).isAfter(max, 'day');
305
+ const isSame = dayjs(selectedDate).isSame(max, 'day');
306
+ return isSame || isAfter;
307
+ }
256
308
  /**
257
309
  * @ignore
258
310
  */
@@ -321,10 +373,10 @@ class WattDatepickerComponent extends WattPickerBase {
321
373
  return maybeDateInDanishTimeZone;
322
374
  }
323
375
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattDatepickerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
324
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.1", type: WattDatepickerComponent, isStandalone: true, selector: "watt-datepicker", inputs: { max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, rangeMonthOnlyMode: { classPropertyName: "rangeMonthOnlyMode", publicName: "rangeMonthOnlyMode", isSignal: true, isRequired: false, transformFunction: null }, startAt: { classPropertyName: "startAt", publicName: "startAt", isSignal: false, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: false, isRequired: false, transformFunction: null }, dateClass: { classPropertyName: "dateClass", publicName: "dateClass", isSignal: false, isRequired: false, transformFunction: null } }, providers: [
376
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.1", type: WattDatepickerComponent, isStandalone: true, selector: "watt-datepicker", inputs: { max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, rangeMonthOnlyMode: { classPropertyName: "rangeMonthOnlyMode", publicName: "rangeMonthOnlyMode", isSignal: true, isRequired: false, transformFunction: null }, startAt: { classPropertyName: "startAt", publicName: "startAt", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, dateClass: { classPropertyName: "dateClass", publicName: "dateClass", isSignal: true, isRequired: false, transformFunction: null }, canStepThroughDays: { classPropertyName: "canStepThroughDays", publicName: "canStepThroughDays", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
325
377
  { provide: MatFormFieldControl, useExisting: WattDatepickerComponent },
326
378
  MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER,
327
- ], viewQueries: [{ propertyName: "matDatepickerInput", first: true, predicate: MatDatepickerInput, descendants: true }, { propertyName: "matDateRangePicker", first: true, predicate: MatDateRangePicker, descendants: true }, { propertyName: "matDateRangeInput", first: true, predicate: MatDateRangeInput, descendants: true }, { propertyName: "matStartDate", first: true, predicate: MatStartDate, descendants: true }, { propertyName: "matEndDate", first: true, predicate: MatEndDate, descendants: true }, { propertyName: "actualInput", first: true, predicate: ["actualInput"], descendants: true }, { propertyName: "input", first: true, predicate: ["dateInput"], descendants: true }, { propertyName: "startInput", first: true, predicate: ["startDateInput"], descendants: true }, { propertyName: "endInput", first: true, predicate: ["endDateInput"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<!--\n@license\nCopyright 2020 Energinet DataHub A/S\n\nLicensed under the Apache License, Version 2.0 (the \"License2\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-->\n<watt-field [control]=\"control\" [label]=\"label\">\n @if (range) {\n <mat-date-range-input\n [disabled]=\"disabled\"\n [rangePicker]=\"rangeDatepicker\"\n [min]=\"min() ?? null\"\n [max]=\"max() ?? null\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n >\n <input\n inert\n aria-label=\"start-date-input\"\n matStartDate\n #startDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n\n <input\n inert\n aria-label=\"end-date-input\"\n matEndDate\n #endDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n </mat-date-range-input>\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"rangeInputMask()\"\n [placeholder]=\"rangePlaceholder\"\n (maskApplied)=\"rangeInputChanged($event)\"\n />\n\n <watt-button\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n [attr.aria-pressed]=\"false\"\n (click)=\"rangeDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n\n <mat-date-range-picker\n [panelClass]=\"rangeMonthOnlyMode() ? 'watt-datepicker-range__panel--month-only' : ''\"\n [startView]=\"rangeMonthOnlyMode() ? 'multi-year' : 'month'\"\n [startAt]=\"startAt\"\n (monthSelected)=\"onMonthSelected($event)\"\n (closed)=\"rangePickerClosed()\"\n #rangeDatepicker\n />\n } @else {\n <input\n inert\n matInput\n tabindex=\"-1\"\n aria-label=\"date-input\"\n #dateInput\n autocomplete=\"off\"\n spellcheck=\"false\"\n [disabled]=\"disabled\"\n [min]=\"min()\"\n [max]=\"max()\"\n [matDatepicker]=\"singleDatepicker\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"inputMask()\"\n [placeholder]=\"datePlaceholder\"\n (maskApplied)=\"inputChanged($event)\"\n />\n\n <watt-button\n wattSuffix\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n (click)=\"singleDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n <mat-datepicker\n #singleDatepicker\n panelClass=\"watt-datepicker-single__panel\"\n [dateClass]=\"dateClass\"\n [startAt]=\"startAt\"\n (closed)=\"datepickerClosed()\"\n />\n }\n\n <ng-content />\n <ng-content ngProjectAs=\"watt-field-hint\" select=\"watt-field-hint\" />\n <ng-content ngProjectAs=\"watt-field-error\" select=\"watt-field-error\" />\n</watt-field>\n", styles: ["watt-datepicker{display:flex;align-items:center;width:100%}watt-datepicker watt-button[variant=icon]{margin-left:auto}watt-datepicker watt-button[variant=icon] .watt-button--icon{height:42px}watt-datepicker mat-datepicker,watt-datepicker mat-date-range-picker{display:none}watt-datepicker input.mat-date-range-input-inner,watt-datepicker input.mat-mdc-input-element,watt-datepicker .mat-date-range-input-mirror,watt-datepicker input.mask-input{font-family:Droid Sans Mono,monospace}watt-datepicker input.mat-date-range-input-inner,watt-datepicker input.mat-mdc-input-element,watt-datepicker input.mask-input{border:none;caret-color:var(--watt-color-neutral-black);letter-spacing:-.03em;-webkit-background-clip:text;-moz-background-clip:text;background-clip:text;color:transparent}watt-datepicker input.mask-input{color:#000}watt-datepicker input.mask-input{position:absolute;min-width:100%;padding:2px 1px}watt-datepicker input.mask-input:focus-visible{outline:none}watt-datepicker .mat-date-range-input-container{align-items:initial}watt-datepicker .mat-date-range-input-start-wrapper,watt-datepicker .mat-date-range-input-end-wrapper{max-width:calc(50% - var(--watt-space-s));overflow:visible;position:relative}watt-datepicker .mat-date-range-input-separator{display:flex;align-items:center}watt-datepicker .mat-date-range-input-separator-hidden,watt-datepicker .mat-date-range-input-separator{opacity:0!important}watt-datepicker .mat-date-range-input-inner::-webkit-input-placeholder{color:var(--watt-color-neutral-grey-500)!important;-webkit-text-fill-color:var(--watt-color-neutral-grey-500)}watt-datepicker watt-button .mat-button{background:transparent}.watt-datepicker-range__panel--month-only .mat-calendar-period-button{pointer-events:none}\n"], dependencies: [{ kind: "ngmodule", type: MatDatepickerModule }, { kind: "component", type: i1.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i1.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i1.MatDateRangeInput, selector: "mat-date-range-input", inputs: ["rangePicker", "required", "dateFilter", "min", "max", "disabled", "separator", "comparisonStart", "comparisonEnd"], exportAs: ["matDateRangeInput"] }, { kind: "directive", type: i1.MatStartDate, selector: "input[matStartDate]", outputs: ["dateChange", "dateInput"] }, { kind: "directive", type: i1.MatEndDate, selector: "input[matEndDate]", outputs: ["dateChange", "dateInput"] }, { kind: "component", type: i1.MatDateRangePicker, selector: "mat-date-range-picker", exportAs: ["matDateRangePicker"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: WattButtonComponent, selector: "watt-button", inputs: ["icon", "variant", "type", "formId", "disabled", "loading"] }, { kind: "component", type: WattFieldComponent, selector: "watt-field", inputs: ["control", "label", "id", "chipMode", "tooltip", "placeholder", "anchorName"] }, { kind: "ngmodule", type: MaskitoModule }, { kind: "component", type: WattPlaceholderMaskComponent, selector: "watt-placeholder-mask", inputs: ["primaryInputElement", "secondaryInputElement", "mask", "placeholder"], outputs: ["maskApplied"] }], encapsulation: i0.ViewEncapsulation.None });
379
+ ], viewQueries: [{ propertyName: "matDatepickerInput", first: true, predicate: MatDatepickerInput, descendants: true }, { propertyName: "matDateRangePicker", first: true, predicate: MatDateRangePicker, descendants: true }, { propertyName: "matDateRangeInput", first: true, predicate: MatDateRangeInput, descendants: true }, { propertyName: "matStartDate", first: true, predicate: MatStartDate, descendants: true }, { propertyName: "matEndDate", first: true, predicate: MatEndDate, descendants: true }, { propertyName: "actualInput", first: true, predicate: ["actualInput"], descendants: true }, { propertyName: "input", first: true, predicate: ["dateInput"], descendants: true }, { propertyName: "startInput", first: true, predicate: ["startDateInput"], descendants: true }, { propertyName: "endInput", first: true, predicate: ["endDateInput"], descendants: true }], usesInheritance: true, ngImport: i0, template: "<!--\n@license\nCopyright 2020 Energinet DataHub A/S\n\nLicensed under the Apache License, Version 2.0 (the \"License2\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-->\n<watt-field [control]=\"control\" [label]=\"label()\">\n @if (range) {\n <mat-date-range-input\n [disabled]=\"disabled\"\n [rangePicker]=\"rangeDatepicker\"\n [min]=\"min() ?? null\"\n [max]=\"max() ?? null\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n >\n <input\n inert\n aria-label=\"start-date-input\"\n matStartDate\n #startDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n\n <input\n inert\n aria-label=\"end-date-input\"\n matEndDate\n #endDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n </mat-date-range-input>\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"rangeInputMask()\"\n [placeholder]=\"rangePlaceholder\"\n (maskApplied)=\"rangeInputChanged($event)\"\n />\n\n <watt-button\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n [attr.aria-pressed]=\"false\"\n (click)=\"rangeDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n\n <mat-date-range-picker\n [panelClass]=\"rangeMonthOnlyMode() ? 'watt-datepicker-range__panel--month-only' : ''\"\n [startView]=\"rangeMonthOnlyMode() ? 'multi-year' : 'month'\"\n [startAt]=\"startAt()\"\n (monthSelected)=\"onMonthSelected($event)\"\n (closed)=\"rangePickerClosed()\"\n #rangeDatepicker\n />\n } @else {\n <input\n inert\n matInput\n tabindex=\"-1\"\n aria-label=\"date-input\"\n #dateInput\n autocomplete=\"off\"\n spellcheck=\"false\"\n [disabled]=\"disabled\"\n [min]=\"min()\"\n [max]=\"max()\"\n [matDatepicker]=\"singleDatepicker\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"inputMask()\"\n [placeholder]=\"datePlaceholder\"\n (maskApplied)=\"inputChanged($event)\"\n />\n\n <watt-button\n wattSuffix\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n (click)=\"singleDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n\n <mat-datepicker\n #singleDatepicker\n panelClass=\"watt-datepicker-single__panel\"\n [dateClass]=\"dateClass()\"\n [startAt]=\"startAt()\"\n (closed)=\"datepickerClosed()\"\n />\n }\n\n <ng-content />\n <ng-content ngProjectAs=\"watt-field-hint\" select=\"watt-field-hint\" />\n <ng-content ngProjectAs=\"watt-field-error\" select=\"watt-field-error\" />\n</watt-field>\n\n@if (!range && canStepThroughDays()) {\n <span\n class=\"watt-datepicker-single__step-through\"\n [class.watt-datepicker-single__has-label]=\"!!label()\"\n >\n <watt-button\n variant=\"icon\"\n icon=\"left\"\n (click)=\"prevDay()\"\n [disabled]=\"disabled || isPrevDayButtonDisabled()\"\n />\n <watt-button\n variant=\"icon\"\n icon=\"right\"\n (click)=\"nextDay()\"\n [disabled]=\"disabled || isNextDayButtonDisabled()\"\n />\n </span>\n}\n", styles: ["watt-datepicker{display:flex;align-items:center;width:100%}watt-datepicker watt-button[variant=icon]{margin-left:auto}watt-datepicker watt-button[variant=icon] .watt-button--icon{height:42px}watt-datepicker mat-datepicker,watt-datepicker mat-date-range-picker{display:none}watt-datepicker input.mat-date-range-input-inner,watt-datepicker input.mat-mdc-input-element,watt-datepicker .mat-date-range-input-mirror,watt-datepicker input.mask-input{font-family:Droid Sans Mono,monospace}watt-datepicker input.mat-date-range-input-inner,watt-datepicker input.mat-mdc-input-element,watt-datepicker input.mask-input{border:none;caret-color:var(--watt-color-neutral-black);letter-spacing:-.03em;-webkit-background-clip:text;-moz-background-clip:text;background-clip:text;color:transparent}watt-datepicker input.mask-input{color:#000}watt-datepicker input.mask-input{position:absolute;min-width:100%;padding:2px 1px}watt-datepicker input.mask-input:focus-visible{outline:none}watt-datepicker .mat-date-range-input-container{align-items:initial}watt-datepicker .mat-date-range-input-start-wrapper,watt-datepicker .mat-date-range-input-end-wrapper{max-width:calc(50% - var(--watt-space-s));overflow:visible;position:relative}watt-datepicker .mat-date-range-input-separator{display:flex;align-items:center}watt-datepicker .mat-date-range-input-separator-hidden,watt-datepicker .mat-date-range-input-separator{opacity:0!important}watt-datepicker .mat-date-range-input-inner::-webkit-input-placeholder{color:var(--watt-color-neutral-grey-500)!important;-webkit-text-fill-color:var(--watt-color-neutral-grey-500)}watt-datepicker watt-button .mat-button{background:transparent}watt-datepicker:has(.watt-datepicker-single__step-through){align-items:flex-start}watt-datepicker:has(.watt-datepicker-single__step-through) .watt-datepicker-single__step-through{display:flex;margin-top:1px}watt-datepicker:has(.watt-datepicker-single__has-label) .watt-datepicker-single__step-through{margin-top:28px}.watt-datepicker-range__panel--month-only .mat-calendar-period-button{pointer-events:none}\n"], dependencies: [{ kind: "ngmodule", type: MatDatepickerModule }, { kind: "component", type: i1.MatDatepicker, selector: "mat-datepicker", exportAs: ["matDatepicker"] }, { kind: "directive", type: i1.MatDatepickerInput, selector: "input[matDatepicker]", inputs: ["matDatepicker", "min", "max", "matDatepickerFilter"], exportAs: ["matDatepickerInput"] }, { kind: "component", type: i1.MatDateRangeInput, selector: "mat-date-range-input", inputs: ["rangePicker", "required", "dateFilter", "min", "max", "disabled", "separator", "comparisonStart", "comparisonEnd"], exportAs: ["matDateRangeInput"] }, { kind: "directive", type: i1.MatStartDate, selector: "input[matStartDate]", outputs: ["dateChange", "dateInput"] }, { kind: "directive", type: i1.MatEndDate, selector: "input[matEndDate]", outputs: ["dateChange", "dateInput"] }, { kind: "component", type: i1.MatDateRangePicker, selector: "mat-date-range-picker", exportAs: ["matDateRangePicker"] }, { kind: "ngmodule", type: MatInputModule }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly", "disabledInteractive"], exportAs: ["matInput"] }, { kind: "component", type: WattButtonComponent, selector: "watt-button", inputs: ["icon", "variant", "type", "formId", "disabled", "loading"] }, { kind: "component", type: WattFieldComponent, selector: "watt-field", inputs: ["control", "label", "id", "chipMode", "tooltip", "placeholder", "anchorName"] }, { kind: "ngmodule", type: MaskitoModule }, { kind: "component", type: WattPlaceholderMaskComponent, selector: "watt-placeholder-mask", inputs: ["primaryInputElement", "secondaryInputElement", "mask", "placeholder"], outputs: ["maskApplied"] }], encapsulation: i0.ViewEncapsulation.None });
328
380
  }
329
381
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattDatepickerComponent, decorators: [{
330
382
  type: Component,
@@ -338,12 +390,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
338
390
  WattFieldComponent,
339
391
  MaskitoModule,
340
392
  WattPlaceholderMaskComponent,
341
- ], template: "<!--\n@license\nCopyright 2020 Energinet DataHub A/S\n\nLicensed under the Apache License, Version 2.0 (the \"License2\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-->\n<watt-field [control]=\"control\" [label]=\"label\">\n @if (range) {\n <mat-date-range-input\n [disabled]=\"disabled\"\n [rangePicker]=\"rangeDatepicker\"\n [min]=\"min() ?? null\"\n [max]=\"max() ?? null\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n >\n <input\n inert\n aria-label=\"start-date-input\"\n matStartDate\n #startDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n\n <input\n inert\n aria-label=\"end-date-input\"\n matEndDate\n #endDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n </mat-date-range-input>\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"rangeInputMask()\"\n [placeholder]=\"rangePlaceholder\"\n (maskApplied)=\"rangeInputChanged($event)\"\n />\n\n <watt-button\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n [attr.aria-pressed]=\"false\"\n (click)=\"rangeDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n\n <mat-date-range-picker\n [panelClass]=\"rangeMonthOnlyMode() ? 'watt-datepicker-range__panel--month-only' : ''\"\n [startView]=\"rangeMonthOnlyMode() ? 'multi-year' : 'month'\"\n [startAt]=\"startAt\"\n (monthSelected)=\"onMonthSelected($event)\"\n (closed)=\"rangePickerClosed()\"\n #rangeDatepicker\n />\n } @else {\n <input\n inert\n matInput\n tabindex=\"-1\"\n aria-label=\"date-input\"\n #dateInput\n autocomplete=\"off\"\n spellcheck=\"false\"\n [disabled]=\"disabled\"\n [min]=\"min()\"\n [max]=\"max()\"\n [matDatepicker]=\"singleDatepicker\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"inputMask()\"\n [placeholder]=\"datePlaceholder\"\n (maskApplied)=\"inputChanged($event)\"\n />\n\n <watt-button\n wattSuffix\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n (click)=\"singleDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n <mat-datepicker\n #singleDatepicker\n panelClass=\"watt-datepicker-single__panel\"\n [dateClass]=\"dateClass\"\n [startAt]=\"startAt\"\n (closed)=\"datepickerClosed()\"\n />\n }\n\n <ng-content />\n <ng-content ngProjectAs=\"watt-field-hint\" select=\"watt-field-hint\" />\n <ng-content ngProjectAs=\"watt-field-error\" select=\"watt-field-error\" />\n</watt-field>\n", styles: ["watt-datepicker{display:flex;align-items:center;width:100%}watt-datepicker watt-button[variant=icon]{margin-left:auto}watt-datepicker watt-button[variant=icon] .watt-button--icon{height:42px}watt-datepicker mat-datepicker,watt-datepicker mat-date-range-picker{display:none}watt-datepicker input.mat-date-range-input-inner,watt-datepicker input.mat-mdc-input-element,watt-datepicker .mat-date-range-input-mirror,watt-datepicker input.mask-input{font-family:Droid Sans Mono,monospace}watt-datepicker input.mat-date-range-input-inner,watt-datepicker input.mat-mdc-input-element,watt-datepicker input.mask-input{border:none;caret-color:var(--watt-color-neutral-black);letter-spacing:-.03em;-webkit-background-clip:text;-moz-background-clip:text;background-clip:text;color:transparent}watt-datepicker input.mask-input{color:#000}watt-datepicker input.mask-input{position:absolute;min-width:100%;padding:2px 1px}watt-datepicker input.mask-input:focus-visible{outline:none}watt-datepicker .mat-date-range-input-container{align-items:initial}watt-datepicker .mat-date-range-input-start-wrapper,watt-datepicker .mat-date-range-input-end-wrapper{max-width:calc(50% - var(--watt-space-s));overflow:visible;position:relative}watt-datepicker .mat-date-range-input-separator{display:flex;align-items:center}watt-datepicker .mat-date-range-input-separator-hidden,watt-datepicker .mat-date-range-input-separator{opacity:0!important}watt-datepicker .mat-date-range-input-inner::-webkit-input-placeholder{color:var(--watt-color-neutral-grey-500)!important;-webkit-text-fill-color:var(--watt-color-neutral-grey-500)}watt-datepicker watt-button .mat-button{background:transparent}.watt-datepicker-range__panel--month-only .mat-calendar-period-button{pointer-events:none}\n"] }]
342
- }], ctorParameters: () => [], propDecorators: { startAt: [{
343
- type: Input
344
- }], label: [{
345
- type: Input
346
- }], matDatepickerInput: [{
393
+ ], template: "<!--\n@license\nCopyright 2020 Energinet DataHub A/S\n\nLicensed under the Apache License, Version 2.0 (the \"License2\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-->\n<watt-field [control]=\"control\" [label]=\"label()\">\n @if (range) {\n <mat-date-range-input\n [disabled]=\"disabled\"\n [rangePicker]=\"rangeDatepicker\"\n [min]=\"min() ?? null\"\n [max]=\"max() ?? null\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n >\n <input\n inert\n aria-label=\"start-date-input\"\n matStartDate\n #startDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n\n <input\n inert\n aria-label=\"end-date-input\"\n matEndDate\n #endDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n </mat-date-range-input>\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"rangeInputMask()\"\n [placeholder]=\"rangePlaceholder\"\n (maskApplied)=\"rangeInputChanged($event)\"\n />\n\n <watt-button\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n [attr.aria-pressed]=\"false\"\n (click)=\"rangeDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n\n <mat-date-range-picker\n [panelClass]=\"rangeMonthOnlyMode() ? 'watt-datepicker-range__panel--month-only' : ''\"\n [startView]=\"rangeMonthOnlyMode() ? 'multi-year' : 'month'\"\n [startAt]=\"startAt()\"\n (monthSelected)=\"onMonthSelected($event)\"\n (closed)=\"rangePickerClosed()\"\n #rangeDatepicker\n />\n } @else {\n <input\n inert\n matInput\n tabindex=\"-1\"\n aria-label=\"date-input\"\n #dateInput\n autocomplete=\"off\"\n spellcheck=\"false\"\n [disabled]=\"disabled\"\n [min]=\"min()\"\n [max]=\"max()\"\n [matDatepicker]=\"singleDatepicker\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"inputMask()\"\n [placeholder]=\"datePlaceholder\"\n (maskApplied)=\"inputChanged($event)\"\n />\n\n <watt-button\n wattSuffix\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n (click)=\"singleDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n\n <mat-datepicker\n #singleDatepicker\n panelClass=\"watt-datepicker-single__panel\"\n [dateClass]=\"dateClass()\"\n [startAt]=\"startAt()\"\n (closed)=\"datepickerClosed()\"\n />\n }\n\n <ng-content />\n <ng-content ngProjectAs=\"watt-field-hint\" select=\"watt-field-hint\" />\n <ng-content ngProjectAs=\"watt-field-error\" select=\"watt-field-error\" />\n</watt-field>\n\n@if (!range && canStepThroughDays()) {\n <span\n class=\"watt-datepicker-single__step-through\"\n [class.watt-datepicker-single__has-label]=\"!!label()\"\n >\n <watt-button\n variant=\"icon\"\n icon=\"left\"\n (click)=\"prevDay()\"\n [disabled]=\"disabled || isPrevDayButtonDisabled()\"\n />\n <watt-button\n variant=\"icon\"\n icon=\"right\"\n (click)=\"nextDay()\"\n [disabled]=\"disabled || isNextDayButtonDisabled()\"\n />\n </span>\n}\n", styles: ["watt-datepicker{display:flex;align-items:center;width:100%}watt-datepicker watt-button[variant=icon]{margin-left:auto}watt-datepicker watt-button[variant=icon] .watt-button--icon{height:42px}watt-datepicker mat-datepicker,watt-datepicker mat-date-range-picker{display:none}watt-datepicker input.mat-date-range-input-inner,watt-datepicker input.mat-mdc-input-element,watt-datepicker .mat-date-range-input-mirror,watt-datepicker input.mask-input{font-family:Droid Sans Mono,monospace}watt-datepicker input.mat-date-range-input-inner,watt-datepicker input.mat-mdc-input-element,watt-datepicker input.mask-input{border:none;caret-color:var(--watt-color-neutral-black);letter-spacing:-.03em;-webkit-background-clip:text;-moz-background-clip:text;background-clip:text;color:transparent}watt-datepicker input.mask-input{color:#000}watt-datepicker input.mask-input{position:absolute;min-width:100%;padding:2px 1px}watt-datepicker input.mask-input:focus-visible{outline:none}watt-datepicker .mat-date-range-input-container{align-items:initial}watt-datepicker .mat-date-range-input-start-wrapper,watt-datepicker .mat-date-range-input-end-wrapper{max-width:calc(50% - var(--watt-space-s));overflow:visible;position:relative}watt-datepicker .mat-date-range-input-separator{display:flex;align-items:center}watt-datepicker .mat-date-range-input-separator-hidden,watt-datepicker .mat-date-range-input-separator{opacity:0!important}watt-datepicker .mat-date-range-input-inner::-webkit-input-placeholder{color:var(--watt-color-neutral-grey-500)!important;-webkit-text-fill-color:var(--watt-color-neutral-grey-500)}watt-datepicker watt-button .mat-button{background:transparent}watt-datepicker:has(.watt-datepicker-single__step-through){align-items:flex-start}watt-datepicker:has(.watt-datepicker-single__step-through) .watt-datepicker-single__step-through{display:flex;margin-top:1px}watt-datepicker:has(.watt-datepicker-single__has-label) .watt-datepicker-single__step-through{margin-top:28px}.watt-datepicker-range__panel--month-only .mat-calendar-period-button{pointer-events:none}\n"] }]
394
+ }], ctorParameters: () => [], propDecorators: { matDatepickerInput: [{
347
395
  type: ViewChild,
348
396
  args: [MatDatepickerInput]
349
397
  }], matDateRangePicker: [{
@@ -370,8 +418,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
370
418
  }], endInput: [{
371
419
  type: ViewChild,
372
420
  args: ['endDateInput']
373
- }], dateClass: [{
374
- type: Input
375
421
  }] } });
376
422
 
377
423
  //#region License
@@ -1 +1 @@
1
- {"version":3,"file":"energinet-watt-picker-datepicker.mjs","sources":["../../../libs/watt/package/picker/datepicker/watt-datepicker.component.ts","../../../libs/watt/package/picker/datepicker/watt-datepicker.component.html","../../../libs/watt/package/picker/datepicker/watt-datepicker-intl.service.ts","../../../libs/watt/package/picker/datepicker/index.ts","../../../libs/watt/package/picker/datepicker/energinet-watt-picker-datepicker.ts"],"sourcesContent":["//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { FormatWidth, getLocaleDateFormat } from '@angular/common';\nimport {\n ChangeDetectorRef,\n Component,\n ElementRef,\n Input,\n LOCALE_ID,\n ViewChild,\n ViewEncapsulation,\n computed,\n inject,\n input,\n AfterViewInit,\n effect,\n} from '@angular/core';\nimport { AbstractControl, NgControl, Validator } from '@angular/forms';\nimport {\n MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER,\n MatCalendarCellClassFunction,\n MatDateRangeInput,\n MatDateRangePicker,\n MatDatepickerInput,\n MatDatepickerModule,\n MatEndDate,\n MatStartDate,\n} from '@angular/material/datepicker';\nimport { MatFormFieldControl } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { MaskitoModule } from '@maskito/angular';\nimport { maskitoDateOptionsGenerator, maskitoDateRangeOptionsGenerator } from '@maskito/kit';\nimport { WattFieldComponent } from '@energinet/watt/field';\nimport {\n WattDateRange,\n WattLocaleService,\n WattRange,\n WattSupportedLocales,\n dayjs,\n} from '@energinet/watt/core/date';\nimport { WattButtonComponent } from '@energinet/watt/button';\n\nimport {\n WattPickerBase,\n WattPickerValue,\n WattPlaceholderMaskComponent,\n} from '@energinet/watt/picker/__shared';\n\nconst dateShortFormat = 'DD-MM-YYYY';\nconst danishLocaleCode = 'da';\nexport const danishTimeZoneIdentifier = 'Europe/Copenhagen';\n\n/**\n * Usage:\n * `import { WattDatepickerComponent } from '@energinet-datahub/watt/datepicker';`\n *\n * IMPORTANT:\n * The styling is calculated based on our monospaced font.\n */\n@Component({\n selector: 'watt-datepicker',\n templateUrl: './watt-datepicker.component.html',\n styleUrls: ['./watt-datepicker.component.scss'],\n providers: [\n { provide: MatFormFieldControl, useExisting: WattDatepickerComponent },\n MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER,\n ],\n encapsulation: ViewEncapsulation.None,\n imports: [\n MatDatepickerModule,\n MatInputModule,\n WattButtonComponent,\n WattFieldComponent,\n MaskitoModule,\n WattPlaceholderMaskComponent,\n ],\n})\nexport class WattDatepickerComponent extends WattPickerBase implements Validator, AfterViewInit {\n protected override elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n protected override changeDetectionRef = inject(ChangeDetectorRef);\n protected override ngControl = inject(NgControl, { optional: true, self: true });\n private localeService = inject(WattLocaleService);\n private locale: WattSupportedLocales = inject(LOCALE_ID) as WattSupportedLocales;\n\n max = input<Date>();\n min = input<Date>();\n rangeMonthOnlyMode = input(false);\n\n @Input() startAt: Date | null = null;\n @Input() label = '';\n\n /**\n * @ignore\n */\n @ViewChild(MatDatepickerInput)\n matDatepickerInput!: MatDatepickerInput<Date | null>;\n\n @ViewChild(MatDateRangePicker)\n matDateRangePicker!: MatDateRangePicker<Date | null>;\n\n @ViewChild(MatDateRangeInput)\n matDateRangeInput!: MatDateRangeInput<Date | null>;\n\n /**\n * @ignore\n */\n @ViewChild(MatStartDate)\n matStartDate!: MatStartDate<Date | null>;\n\n /**\n * @ignore\n */\n @ViewChild(MatEndDate)\n matEndDate!: MatEndDate<Date | null>;\n\n /**\n * @ignore\n */\n @ViewChild('actualInput')\n actualInput!: ElementRef;\n\n /**\n * @ignore\n */\n @ViewChild('dateInput')\n input!: ElementRef;\n\n /**\n * @ignore\n */\n @ViewChild('startDateInput')\n startInput!: ElementRef;\n\n /**\n * @ignore\n */\n @ViewChild('endDateInput')\n endInput!: ElementRef;\n /**\n * @ignore\n */\n protected _placeholder = this.getPlaceholder(this.getInputFormat());\n\n @Input() dateClass: MatCalendarCellClassFunction<Date> = () => '';\n\n /**\n * @ignore\n */\n datePlaceholder = this.getPlaceholderByLocale(this.locale);\n /**\n * @ignore\n */\n rangeSeparator = ' - ';\n /**\n * @ignore\n */\n rangePlaceholder = this.datePlaceholder + this.rangeSeparator + this.datePlaceholder;\n /**\n * @ignore\n */\n inputMask = computed(() =>\n maskitoDateOptionsGenerator({\n mode: 'dd/mm/yyyy',\n separator: '-',\n max: this.max(),\n min: this.min(),\n })\n );\n\n /**\n * @ignore\n */\n rangeInputMask = computed(() =>\n maskitoDateRangeOptionsGenerator({\n mode: 'dd/mm/yyyy',\n dateSeparator: '-',\n max: this.max(),\n min: this.min(),\n })\n );\n /**\n * @ignore\n */\n getPlaceholderByLocale(locale: WattSupportedLocales): string {\n return locale === 'da' ? 'dd-mm-åååå' : 'dd-mm-yyyy';\n }\n getRangePlaceholder(): string {\n return this.datePlaceholder + this.rangeSeparator + this.datePlaceholder;\n }\n constructor() {\n super(`watt-datepicker-${WattDatepickerComponent.nextId++}`);\n\n effect(() => {\n const locale = this.localeService.locale();\n this.datePlaceholder = this.getPlaceholderByLocale(locale);\n this.rangePlaceholder = this.getRangePlaceholder();\n });\n\n effect(() => {\n this.rangeMonthOnlyMode();\n this.ngControl?.control?.updateValueAndValidity();\n });\n }\n\n override ngAfterViewInit() {\n super.ngAfterViewInit();\n this.ngControl?.control?.addValidators(this.validate.bind(this));\n }\n\n validate({ value }: AbstractControl<WattRange<string>>) {\n if (!value?.end || !value?.start) return null;\n if (!this.rangeMonthOnlyMode()) return null;\n const start = dayjs(value.start);\n const end = dayjs(value.end);\n return start.isSame(start.startOf('month')) && end.isSame(start.endOf('month'))\n ? null\n : { monthOnly: true };\n }\n\n protected initSingleInput() {\n if (this.initialValue) {\n this.matDatepickerInput.value = this.initialValue;\n this.datepickerClosed();\n }\n }\n\n inputChanged(value: string) {\n const dateString = value.slice(0, this.datePlaceholder.length);\n if (dateString.length === 0) {\n this.control?.setValue(null);\n return;\n }\n if (dateString.length !== this.datePlaceholder.length) {\n return;\n }\n const date = this.parseDateShortFormat(dateString);\n this.control?.setValue(this.formatDateFromViewToModel(date));\n }\n\n datepickerClosed() {\n if (this.matDatepickerInput.value) {\n this.control?.setValue(this.matDatepickerInput.value);\n (this.actualInput.nativeElement as HTMLInputElement).value =\n this.formatDateTimeFromModelToView(\n this.formatDateFromViewToModel(this.matDatepickerInput.value)\n );\n } else {\n (this.actualInput.nativeElement as HTMLInputElement).value = '';\n this.control?.setValue(null);\n }\n this.actualInput.nativeElement.dispatchEvent(new InputEvent('input'));\n }\n\n onMonthSelected(date: Date) {\n if (this.rangeMonthOnlyMode() && date) {\n this.matDateRangePicker.select(dayjs(date).startOf('month').toDate());\n this.matDateRangePicker.select(dayjs(date).endOf('month').toDate());\n this.matDateRangePicker.close();\n }\n }\n\n /**\n * @ignore\n */\n protected initRangeInput() {\n if (this.initialValue) {\n this.matStartDate.value = (this.initialValue as WattDateRange).start;\n this.matEndDate.value = (this.initialValue as WattDateRange).end;\n this.rangePickerClosed();\n }\n }\n\n clearRangePicker() {\n this.control?.setValue(null);\n this.actualInput.nativeElement.dispatchEvent(new InputEvent('input'));\n }\n\n rangeInputChanged(value: string) {\n const startDateString = value.slice(0, this.datePlaceholder.length);\n\n if (startDateString.length === 0) {\n this.control?.setValue(null);\n return;\n }\n\n if (startDateString.length !== this.datePlaceholder.length) {\n return;\n }\n\n const start = this.parseDateShortFormat(startDateString);\n const endDateString = value.slice(this.datePlaceholder.length + this.rangeSeparator.length);\n let end = this.setEndDateToDanishTimeZone(endDateString);\n\n if (end !== null) {\n end = this.setToEndOfDay(end);\n this.control?.setValue({ start, end });\n }\n }\n\n rangePickerClosed() {\n if (this.matDateRangeInput.value?.start && this.matDateRangeInput.value.end) {\n (this.actualInput.nativeElement as HTMLInputElement).value =\n this.formatDateTimeFromModelToView(\n this.formatDateFromViewToModel(this.matDateRangeInput.value?.start)\n ) +\n '-' +\n this.formatDateTimeFromModelToView(\n this.formatDateFromViewToModel(this.matDateRangeInput.value.end)\n );\n this.control?.setValue({\n start: this.formatDateFromViewToModel(this.matDateRangeInput.value.start),\n end: this.formatDateFromViewToModel(this.matDateRangeInput.value.end),\n });\n } else {\n (this.actualInput.nativeElement as HTMLInputElement).value = '';\n this.control?.setValue(null);\n }\n this.actualInput.nativeElement.dispatchEvent(new InputEvent('input'));\n }\n\n /**\n * @ignore\n */\n protected setSingleValue(\n value: Exclude<WattPickerValue, WattDateRange>,\n input: HTMLInputElement\n ) {\n this.setValueToInput(value, input, this.matDatepickerInput);\n }\n\n /**\n * @ignore\n */\n protected setRangeValue(\n value: WattDateRange | null,\n startInput: HTMLInputElement,\n endInput: HTMLInputElement\n ) {\n const { start, end } = value ?? {};\n\n this.setValueToInput(start, startInput, this.matStartDate);\n this.setValueToInput(end, endInput, this.matEndDate);\n }\n\n /**\n * @ignore\n */\n private getInputFormat(): string {\n const localeDateFormat = getLocaleDateFormat(this.locale, FormatWidth.Short);\n\n return localeDateFormat\n .toLowerCase()\n .replace(/d+/, 'dd')\n .replace(/m+/, 'mm')\n .replace(/y+/, 'yyyy')\n .replace(/\\./g, '-'); // seperator\n }\n\n /**\n * @ignore\n */\n private getPlaceholder(inputFormat: string): string {\n return this.locale === danishLocaleCode ? inputFormat.split('y').join('å') : inputFormat;\n }\n\n /**\n * @ignore\n */\n private parseDateShortFormat(value: string): Date {\n return dayjs(value, dateShortFormat).toDate();\n }\n\n /**\n * @ignore\n */\n private setValueToInput<D extends { value: Date | null }>(\n value: string | null | undefined,\n nativeInput: HTMLInputElement,\n matDateInput: D\n ): void {\n nativeInput.value = value ? this.formatDateTimeFromModelToView(value) : '';\n matDateInput.value = value ? dayjs(value).utc().toDate() : null;\n }\n\n /**\n * @ignore\n * Formats Date to full ISO 8601 format (e.g. `2022-08-31T22:00:00.000Z`)\n */\n private formatDateFromViewToModel(value: Date): string {\n return dayjs(value).utc().toISOString();\n }\n\n /**\n * @ignore\n */\n private formatDateTimeFromModelToView(value: string): string {\n return dayjs(value).tz(danishTimeZoneIdentifier).format(dateShortFormat);\n }\n\n /**\n * @ignore\n */\n private toDanishTimeZone(value: Date): Date {\n return dayjs(value.toISOString()).tz(danishTimeZoneIdentifier).toDate();\n }\n\n /**\n * @ignore\n */\n private setToEndOfDay(value: Date): Date {\n return dayjs(value).endOf('day').toDate();\n }\n\n /**\n * @ignore\n */\n private setEndDateToDanishTimeZone(value: string): Date | null {\n const dateBasedOnShortFormat = this.parseDateShortFormat(value);\n\n let maybeDateInDanishTimeZone: Date | null = null;\n\n if (dayjs(dateBasedOnShortFormat).isValid()) {\n maybeDateInDanishTimeZone = this.toDanishTimeZone(dateBasedOnShortFormat);\n }\n\n return maybeDateInDanishTimeZone;\n }\n}\n","<!--\n@license\nCopyright 2020 Energinet DataHub A/S\n\nLicensed under the Apache License, Version 2.0 (the \"License2\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-->\n<watt-field [control]=\"control\" [label]=\"label\">\n @if (range) {\n <mat-date-range-input\n [disabled]=\"disabled\"\n [rangePicker]=\"rangeDatepicker\"\n [min]=\"min() ?? null\"\n [max]=\"max() ?? null\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n >\n <input\n inert\n aria-label=\"start-date-input\"\n matStartDate\n #startDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n\n <input\n inert\n aria-label=\"end-date-input\"\n matEndDate\n #endDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n </mat-date-range-input>\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"rangeInputMask()\"\n [placeholder]=\"rangePlaceholder\"\n (maskApplied)=\"rangeInputChanged($event)\"\n />\n\n <watt-button\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n [attr.aria-pressed]=\"false\"\n (click)=\"rangeDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n\n <mat-date-range-picker\n [panelClass]=\"rangeMonthOnlyMode() ? 'watt-datepicker-range__panel--month-only' : ''\"\n [startView]=\"rangeMonthOnlyMode() ? 'multi-year' : 'month'\"\n [startAt]=\"startAt\"\n (monthSelected)=\"onMonthSelected($event)\"\n (closed)=\"rangePickerClosed()\"\n #rangeDatepicker\n />\n } @else {\n <input\n inert\n matInput\n tabindex=\"-1\"\n aria-label=\"date-input\"\n #dateInput\n autocomplete=\"off\"\n spellcheck=\"false\"\n [disabled]=\"disabled\"\n [min]=\"min()\"\n [max]=\"max()\"\n [matDatepicker]=\"singleDatepicker\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"inputMask()\"\n [placeholder]=\"datePlaceholder\"\n (maskApplied)=\"inputChanged($event)\"\n />\n\n <watt-button\n wattSuffix\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n (click)=\"singleDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n <mat-datepicker\n #singleDatepicker\n panelClass=\"watt-datepicker-single__panel\"\n [dateClass]=\"dateClass\"\n [startAt]=\"startAt\"\n (closed)=\"datepickerClosed()\"\n />\n }\n\n <ng-content />\n <ng-content ngProjectAs=\"watt-field-hint\" select=\"watt-field-hint\" />\n <ng-content ngProjectAs=\"watt-field-error\" select=\"watt-field-error\" />\n</watt-field>\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { Injectable } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\nexport class WattDatepickerIntlService {\n clear = 'Clear';\n select = 'OK';\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nexport { WattDatepickerComponent } from './watt-datepicker.component';\nexport { danishTimeZoneIdentifier } from './watt-datepicker.component';\nexport { WattDatepickerIntlService } from './watt-datepicker-intl.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;AA+CA,MAAM,eAAe,GAAG,YAAY;AACpC,MAAM,gBAAgB,GAAG,IAAI;AACtB,MAAM,wBAAwB,GAAG;AAExC;;;;;;AAMG;AAmBG,MAAO,uBAAwB,SAAQ,cAAc,CAAA;AACtC,IAAA,UAAU,GAAG,MAAM,CAA0B,UAAU,CAAC;AACxD,IAAA,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC;AAC9C,IAAA,SAAS,GAAG,MAAM,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AACxE,IAAA,aAAa,GAAG,MAAM,CAAC,iBAAiB,CAAC;AACzC,IAAA,MAAM,GAAyB,MAAM,CAAC,SAAS,CAAyB;IAEhF,GAAG,GAAG,KAAK,EAAQ;IACnB,GAAG,GAAG,KAAK,EAAQ;AACnB,IAAA,kB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AA,CAAA;sBADjB,SAAS;uBAAC,kBAAkB;gBAI7B,iBAAiB,EAAA,CAAA;sBADhB,SAAS;uBAAC,iBAAiB;gBAO5B,YAAY,EAAA,CAAA;sBADX,SAAS;uBAAC,YAAY;gBAOvB,UAAU,EAAA,CAAA;sBADT,SAAS;uBAAC,UAAU;gBAOrB,WAAW,EAAA,CAAA;sBADV,SAAS;uBAAC,aAAa;gBAOxB,KAAK,EAAA,CAAA;sBADJ,SAAS;uBAAC,WAAW;gBAOtB,UAAU,EAAA,CAAA;sBADT,SAAS;uBAAC,gBAAgB;gBAO3B,QAAQ,EAAA,CAAA;sBADP,SAAS;uBAAC,cAAc;gBAOhB,SAAS,EAAA,CAAA;sBAAjB;;;AE/JH;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAIa,yBAAyB,CAAA;IACpC,KAAK,GAAG,OAAO;IACf,MAAM,GAAG,IAAI;uGAFF,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAzB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,cADZ,MAAM,EAAA,CAAA;;2FACnB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBADrC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACpBlC;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
1
+ {"version":3,"file":"energinet-watt-picker-datepicker.mjs","sources":["../../../libs/watt/package/picker/datepicker/watt-datepicker.component.ts","../../../libs/watt/package/picker/datepicker/watt-datepicker.component.html","../../../libs/watt/package/picker/datepicker/watt-datepicker-intl.service.ts","../../../libs/watt/package/picker/datepicker/index.ts","../../../libs/watt/package/picker/datepicker/energinet-watt-picker-datepicker.ts"],"sourcesContent":["//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { FormatWidth, getLocaleDateFormat } from '@angular/common';\nimport {\n ChangeDetectorRef,\n Component,\n ElementRef,\n LOCALE_ID,\n ViewChild,\n ViewEncapsulation,\n computed,\n inject,\n input,\n AfterViewInit,\n effect,\n linkedSignal,\n booleanAttribute,\n} from '@angular/core';\nimport { AbstractControl, NgControl, Validator } from '@angular/forms';\nimport {\n MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER,\n MatCalendarCellClassFunction,\n MatDateRangeInput,\n MatDateRangePicker,\n MatDatepickerInput,\n MatDatepickerModule,\n MatEndDate,\n MatStartDate,\n} from '@angular/material/datepicker';\nimport { MatFormFieldControl } from '@angular/material/form-field';\nimport { MatInputModule } from '@angular/material/input';\nimport { MaskitoModule } from '@maskito/angular';\nimport { maskitoDateOptionsGenerator, maskitoDateRangeOptionsGenerator } from '@maskito/kit';\n\nimport { WattFieldComponent } from '@energinet/watt/field';\nimport {\n WattDateRange,\n WattLocaleService,\n WattRange,\n WattSupportedLocales,\n dayjs,\n} from '@energinet/watt/core/date';\nimport { WattButtonComponent } from '@energinet/watt/button';\n\nimport {\n WattPickerBase,\n WattPickerValue,\n WattPlaceholderMaskComponent,\n} from '@energinet/watt/picker/__shared';\n\nconst dateShortFormat = 'DD-MM-YYYY';\nconst danishLocaleCode = 'da';\nexport const danishTimeZoneIdentifier = 'Europe/Copenhagen';\n\n/**\n * Usage:\n * `import { WattDatepickerComponent } from '@energinet-datahub/watt/datepicker';`\n *\n * IMPORTANT:\n * The styling is calculated based on our monospaced font.\n */\n@Component({\n selector: 'watt-datepicker',\n templateUrl: './watt-datepicker.component.html',\n styleUrls: ['./watt-datepicker.component.scss'],\n providers: [\n { provide: MatFormFieldControl, useExisting: WattDatepickerComponent },\n MAT_DATEPICKER_SCROLL_STRATEGY_FACTORY_PROVIDER,\n ],\n encapsulation: ViewEncapsulation.None,\n imports: [\n MatDatepickerModule,\n MatInputModule,\n WattButtonComponent,\n WattFieldComponent,\n MaskitoModule,\n WattPlaceholderMaskComponent,\n ],\n})\nexport class WattDatepickerComponent extends WattPickerBase implements Validator, AfterViewInit {\n protected override elementRef = inject<ElementRef<HTMLElement>>(ElementRef);\n protected override changeDetectionRef = inject(ChangeDetectorRef);\n protected override ngControl = inject(NgControl, { optional: true, self: true });\n private localeService = inject(WattLocaleService);\n private locale = inject<WattSupportedLocales>(LOCALE_ID);\n\n max = input<Date>();\n min = input<Date>();\n rangeMonthOnlyMode = input(false);\n startAt = input<Date | null>(null);\n label = input<string>('');\n dateClass = input<MatCalendarCellClassFunction<Date>>(() => '');\n canStepThroughDays = input(false, { transform: booleanAttribute });\n\n /**\n * @ignore\n */\n @ViewChild(MatDatepickerInput)\n matDatepickerInput!: MatDatepickerInput<Date | null>;\n\n @ViewChild(MatDateRangePicker)\n matDateRangePicker!: MatDateRangePicker<Date | null>;\n\n @ViewChild(MatDateRangeInput)\n matDateRangeInput!: MatDateRangeInput<Date | null>;\n\n /**\n * @ignore\n */\n @ViewChild(MatStartDate)\n matStartDate!: MatStartDate<Date | null>;\n\n /**\n * @ignore\n */\n @ViewChild(MatEndDate)\n matEndDate!: MatEndDate<Date | null>;\n\n /**\n * @ignore\n */\n @ViewChild('actualInput')\n actualInput!: ElementRef<HTMLInputElement>;\n\n /**\n * @ignore\n */\n @ViewChild('dateInput')\n input!: ElementRef<HTMLInputElement>;\n\n /**\n * @ignore\n */\n @ViewChild('startDateInput')\n startInput!: ElementRef<HTMLInputElement>;\n\n /**\n * @ignore\n */\n @ViewChild('endDateInput')\n endInput!: ElementRef<HTMLInputElement>;\n /**\n * @ignore\n */\n protected _placeholder = this.getPlaceholder(this.getInputFormat());\n\n /**\n * @ignore\n */\n datePlaceholder = this.getPlaceholderByLocale(this.locale);\n\n /**\n * @ignore\n */\n rangeSeparator = ' - ';\n\n /**\n * @ignore\n */\n rangePlaceholder = this.datePlaceholder + this.rangeSeparator + this.datePlaceholder;\n\n /**\n * @ignore\n */\n inputMask = computed(() =>\n maskitoDateOptionsGenerator({\n mode: 'dd/mm/yyyy',\n separator: '-',\n max: this.max(),\n min: this.min(),\n })\n );\n\n /**\n * @ignore\n */\n rangeInputMask = computed(() =>\n maskitoDateRangeOptionsGenerator({\n mode: 'dd/mm/yyyy',\n dateSeparator: '-',\n max: this.max(),\n min: this.min(),\n })\n );\n\n /**\n * @ignore\n */\n getPlaceholderByLocale(locale: WattSupportedLocales): string {\n return locale === 'da' ? 'dd-mm-åååå' : 'dd-mm-yyyy';\n }\n getRangePlaceholder(): string {\n return this.datePlaceholder + this.rangeSeparator + this.datePlaceholder;\n }\n\n isPrevDayButtonDisabled = linkedSignal(() => this.isPrevDayBeforeOrEqualToMinDate());\n isNextDayButtonDisabled = linkedSignal(() => this.isNextDayAfterOrEqualToMaxDate());\n\n constructor() {\n super(`watt-datepicker-${WattDatepickerComponent.nextId++}`);\n\n effect(() => {\n const locale = this.localeService.locale();\n this.datePlaceholder = this.getPlaceholderByLocale(locale);\n this.rangePlaceholder = this.getRangePlaceholder();\n });\n\n effect(() => {\n this.rangeMonthOnlyMode();\n this.ngControl?.control?.updateValueAndValidity();\n });\n }\n\n override ngAfterViewInit() {\n super.ngAfterViewInit();\n\n this.ngControl?.control?.addValidators(this.validate.bind(this));\n }\n\n validate({ value }: AbstractControl<WattRange<string>>) {\n if (!value?.end || !value?.start) return null;\n if (!this.rangeMonthOnlyMode()) return null;\n const start = dayjs(value.start);\n const end = dayjs(value.end);\n return start.isSame(start.startOf('month')) && end.isSame(start.endOf('month'))\n ? null\n : { monthOnly: true };\n }\n\n protected initSingleInput() {\n if (this.initialValue) {\n this.matDatepickerInput.value = this.initialValue;\n this.datepickerClosed();\n }\n }\n\n inputChanged(value: string) {\n const dateString = value.slice(0, this.datePlaceholder.length);\n\n if (dateString.length === 0) {\n this.control?.setValue(null);\n return;\n }\n\n if (dateString.length !== this.datePlaceholder.length) {\n return;\n }\n\n const date = this.parseDateShortFormat(dateString);\n this.control?.setValue(this.formatDateFromViewToModel(date));\n }\n\n datepickerClosed() {\n if (this.matDatepickerInput.value) {\n this.control?.setValue(this.matDatepickerInput.value);\n\n this.actualInput.nativeElement.value = this.formatDateTimeFromModelToView(\n this.formatDateFromViewToModel(this.matDatepickerInput.value)\n );\n } else {\n this.actualInput.nativeElement.value = '';\n this.control?.setValue(null);\n }\n\n this.isPrevDayButtonDisabled.set(this.isPrevDayBeforeOrEqualToMinDate());\n this.isNextDayButtonDisabled.set(this.isNextDayAfterOrEqualToMaxDate());\n\n this.actualInput.nativeElement.dispatchEvent(new InputEvent('input'));\n }\n\n onMonthSelected(date: Date) {\n if (this.rangeMonthOnlyMode() && date) {\n this.matDateRangePicker.select(dayjs(date).startOf('month').toDate());\n this.matDateRangePicker.select(dayjs(date).endOf('month').toDate());\n this.matDateRangePicker.close();\n }\n }\n\n /**\n * @ignore\n */\n protected initRangeInput() {\n if (this.initialValue) {\n this.matStartDate.value = (this.initialValue as WattDateRange).start;\n this.matEndDate.value = (this.initialValue as WattDateRange).end;\n this.rangePickerClosed();\n }\n }\n\n clearRangePicker() {\n this.control?.setValue(null);\n this.actualInput.nativeElement.dispatchEvent(new InputEvent('input'));\n }\n\n rangeInputChanged(value: string) {\n const startDateString = value.slice(0, this.datePlaceholder.length);\n\n if (startDateString.length === 0) {\n this.control?.setValue(null);\n return;\n }\n\n if (startDateString.length !== this.datePlaceholder.length) {\n return;\n }\n\n const start = this.parseDateShortFormat(startDateString);\n const endDateString = value.slice(this.datePlaceholder.length + this.rangeSeparator.length);\n let end = this.setEndDateToDanishTimeZone(endDateString);\n\n if (end !== null) {\n end = this.setToEndOfDay(end);\n this.control?.setValue({ start, end });\n }\n }\n\n rangePickerClosed() {\n if (this.matDateRangeInput.value?.start && this.matDateRangeInput.value.end) {\n this.actualInput.nativeElement.value =\n this.formatDateTimeFromModelToView(\n this.formatDateFromViewToModel(this.matDateRangeInput.value?.start)\n ) +\n '-' +\n this.formatDateTimeFromModelToView(\n this.formatDateFromViewToModel(this.matDateRangeInput.value.end)\n );\n\n this.control?.setValue({\n start: this.formatDateFromViewToModel(this.matDateRangeInput.value.start),\n end: this.formatDateFromViewToModel(this.matDateRangeInput.value.end),\n });\n } else {\n this.actualInput.nativeElement.value = '';\n this.control?.setValue(null);\n }\n\n this.actualInput.nativeElement.dispatchEvent(new InputEvent('input'));\n }\n\n /**\n * @ignore\n */\n protected setSingleValue(\n value: Exclude<WattPickerValue, WattDateRange>,\n input: HTMLInputElement\n ) {\n this.setValueToInput(value, input, this.matDatepickerInput);\n }\n\n /**\n * @ignore\n */\n protected setRangeValue(\n value: WattDateRange | null,\n startInput: HTMLInputElement,\n endInput: HTMLInputElement\n ) {\n const { start, end } = value ?? {};\n\n this.setValueToInput(start, startInput, this.matStartDate);\n this.setValueToInput(end, endInput, this.matEndDate);\n }\n /**\n * @ignore\n */\n prevDay(): void {\n this.changeDay(-1);\n }\n /**\n * @ignore\n */\n nextDay(): void {\n this.changeDay(1);\n }\n\n /**\n * @ignore\n */\n private changeDay(value: number): void {\n const currentDate = this.matDatepickerInput.value;\n\n if (currentDate) {\n const newDate = dayjs(currentDate).add(value, 'day').toISOString();\n const newDateFormatted = this.formatDateTimeFromModelToView(newDate);\n\n this.inputChanged(newDateFormatted);\n this.datepickerClosed();\n }\n }\n\n /**\n * @ignore\n */\n private isPrevDayBeforeOrEqualToMinDate() {\n const min = this.min();\n const selectedDate = this.matDatepickerInput?.value;\n\n if (!min || !selectedDate) return false;\n\n const isBefore = dayjs(selectedDate).isBefore(min, 'day');\n const isSame = dayjs(selectedDate).isSame(min, 'day');\n\n return isSame || isBefore;\n }\n\n /**\n * @ignore\n */\n private isNextDayAfterOrEqualToMaxDate() {\n const max = this.max();\n const selectedDate = this.matDatepickerInput?.value;\n\n if (!max || !selectedDate) return false;\n\n const isAfter = dayjs(selectedDate).isAfter(max, 'day');\n const isSame = dayjs(selectedDate).isSame(max, 'day');\n\n return isSame || isAfter;\n }\n\n /**\n * @ignore\n */\n private getInputFormat(): string {\n const localeDateFormat = getLocaleDateFormat(this.locale, FormatWidth.Short);\n\n return localeDateFormat\n .toLowerCase()\n .replace(/d+/, 'dd')\n .replace(/m+/, 'mm')\n .replace(/y+/, 'yyyy')\n .replace(/\\./g, '-'); // seperator\n }\n\n /**\n * @ignore\n */\n private getPlaceholder(inputFormat: string): string {\n return this.locale === danishLocaleCode ? inputFormat.split('y').join('å') : inputFormat;\n }\n\n /**\n * @ignore\n */\n private parseDateShortFormat(value: string): Date {\n return dayjs(value, dateShortFormat).toDate();\n }\n\n /**\n * @ignore\n */\n private setValueToInput<D extends { value: Date | null }>(\n value: string | null | undefined,\n nativeInput: HTMLInputElement,\n matDateInput: D\n ): void {\n nativeInput.value = value ? this.formatDateTimeFromModelToView(value) : '';\n matDateInput.value = value ? dayjs(value).utc().toDate() : null;\n }\n\n /**\n * @ignore\n * Formats Date to full ISO 8601 format (e.g. `2022-08-31T22:00:00.000Z`)\n */\n private formatDateFromViewToModel(value: Date): string {\n return dayjs(value).utc().toISOString();\n }\n\n /**\n * @ignore\n */\n private formatDateTimeFromModelToView(value: string): string {\n return dayjs(value).tz(danishTimeZoneIdentifier).format(dateShortFormat);\n }\n\n /**\n * @ignore\n */\n private toDanishTimeZone(value: Date): Date {\n return dayjs(value.toISOString()).tz(danishTimeZoneIdentifier).toDate();\n }\n\n /**\n * @ignore\n */\n private setToEndOfDay(value: Date): Date {\n return dayjs(value).endOf('day').toDate();\n }\n\n /**\n * @ignore\n */\n private setEndDateToDanishTimeZone(value: string): Date | null {\n const dateBasedOnShortFormat = this.parseDateShortFormat(value);\n\n let maybeDateInDanishTimeZone: Date | null = null;\n\n if (dayjs(dateBasedOnShortFormat).isValid()) {\n maybeDateInDanishTimeZone = this.toDanishTimeZone(dateBasedOnShortFormat);\n }\n\n return maybeDateInDanishTimeZone;\n }\n}\n","<!--\n@license\nCopyright 2020 Energinet DataHub A/S\n\nLicensed under the Apache License, Version 2.0 (the \"License2\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-->\n<watt-field [control]=\"control\" [label]=\"label()\">\n @if (range) {\n <mat-date-range-input\n [disabled]=\"disabled\"\n [rangePicker]=\"rangeDatepicker\"\n [min]=\"min() ?? null\"\n [max]=\"max() ?? null\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n >\n <input\n inert\n aria-label=\"start-date-input\"\n matStartDate\n #startDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n\n <input\n inert\n aria-label=\"end-date-input\"\n matEndDate\n #endDateInput\n [readOnly]=\"rangeMonthOnlyMode()\"\n autocomplete=\"off\"\n spellcheck=\"false\"\n [hidden]=\"true\"\n />\n </mat-date-range-input>\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"rangeInputMask()\"\n [placeholder]=\"rangePlaceholder\"\n (maskApplied)=\"rangeInputChanged($event)\"\n />\n\n <watt-button\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n [attr.aria-pressed]=\"false\"\n (click)=\"rangeDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n\n <mat-date-range-picker\n [panelClass]=\"rangeMonthOnlyMode() ? 'watt-datepicker-range__panel--month-only' : ''\"\n [startView]=\"rangeMonthOnlyMode() ? 'multi-year' : 'month'\"\n [startAt]=\"startAt()\"\n (monthSelected)=\"onMonthSelected($event)\"\n (closed)=\"rangePickerClosed()\"\n #rangeDatepicker\n />\n } @else {\n <input\n inert\n matInput\n tabindex=\"-1\"\n aria-label=\"date-input\"\n #dateInput\n autocomplete=\"off\"\n spellcheck=\"false\"\n [disabled]=\"disabled\"\n [min]=\"min()\"\n [max]=\"max()\"\n [matDatepicker]=\"singleDatepicker\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n <input #actualInput class=\"mask-input\" [disabled]=\"disabled\" />\n <watt-placeholder-mask\n [primaryInputElement]=\"actualInput\"\n [mask]=\"inputMask()\"\n [placeholder]=\"datePlaceholder\"\n (maskApplied)=\"inputChanged($event)\"\n />\n\n <watt-button\n wattSuffix\n variant=\"icon\"\n icon=\"date\"\n [disabled]=\"disabled\"\n (click)=\"singleDatepicker.open()\"\n (focusin)=\"onFocusIn()\"\n (focusout)=\"onFocusOut($event)\"\n />\n\n <mat-datepicker\n #singleDatepicker\n panelClass=\"watt-datepicker-single__panel\"\n [dateClass]=\"dateClass()\"\n [startAt]=\"startAt()\"\n (closed)=\"datepickerClosed()\"\n />\n }\n\n <ng-content />\n <ng-content ngProjectAs=\"watt-field-hint\" select=\"watt-field-hint\" />\n <ng-content ngProjectAs=\"watt-field-error\" select=\"watt-field-error\" />\n</watt-field>\n\n@if (!range && canStepThroughDays()) {\n <span\n class=\"watt-datepicker-single__step-through\"\n [class.watt-datepicker-single__has-label]=\"!!label()\"\n >\n <watt-button\n variant=\"icon\"\n icon=\"left\"\n (click)=\"prevDay()\"\n [disabled]=\"disabled || isPrevDayButtonDisabled()\"\n />\n <watt-button\n variant=\"icon\"\n icon=\"right\"\n (click)=\"nextDay()\"\n [disabled]=\"disabled || isNextDayButtonDisabled()\"\n />\n </span>\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { Injectable } from '@angular/core';\n\n@Injectable({ providedIn: 'root' })\nexport class WattDatepickerIntlService {\n clear = 'Clear';\n select = 'OK';\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nexport { WattDatepickerComponent } from './watt-datepicker.component';\nexport { danishTimeZoneIdentifier } from './watt-datepicker.component';\nexport { WattDatepickerIntlService } from './watt-datepicker-intl.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;AAiDA,MAAM,eAAe,GAAG,YAAY;AACpC,MAAM,gBAAgB,GAAG,IAAI;AACtB,MAAM,wBAAwB,GAAG;AAExC;;;;;;AAMG;AAmBG,MAAO,uBAAwB,SAAQ,cAAc,CAAA;AACtC,IAAA,UAAU,GAAG,MAAM,CAA0B,UAAU,CAAC;AACxD,IAAA,kBAAkB,GAAG,MAAM,CAAC,iBAA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,UAAU;gBAOrB,WAAW,EAAA,CAAA;sBADV,SAAS;uBAAC,aAAa;gBAOxB,KAAK,EAAA,CAAA;sBADJ,SAAS;uBAAC,WAAW;gBAOtB,UAAU,EAAA,CAAA;sBADT,SAAS;uBAAC,gBAAgB;gBAO3B,QAAQ,EAAA,CAAA;sBADP,SAAS;uBAAC,cAAc;;;AE3J3B;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAIa,yBAAyB,CAAA;IACpC,KAAK,GAAG,OAAO;IACf,MAAM,GAAG,IAAI;uGAFF,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAzB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,yBAAyB,cADZ,MAAM,EAAA,CAAA;;2FACnB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBADrC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACpBlC;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { computed, signal, input, output, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
2
+ import { computed, signal, input, booleanAttribute, output, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
3
3
  import * as i1 from '@angular/forms';
4
4
  import { FormControl, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
5
5
  import { share } from 'rxjs';
@@ -58,7 +58,7 @@ class WattYearField {
58
58
  /** The maximum selectable date. */
59
59
  max = input();
60
60
  /** Enable buttons to step through years. */
61
- canStepThroughYears = input(false);
61
+ canStepThroughYears = input(false, { transform: booleanAttribute });
62
62
  /** Emits when the selected year has changed. */
63
63
  yearChange = outputFromObservable(this.valueChanges);
64
64
  /** Emits when the field loses focus. */
@@ -1 +1 @@
1
- {"version":3,"file":"energinet-watt-year-field.mjs","sources":["../../../libs/watt/package/year-field/watt-year-field.component.ts","../../../libs/watt/package/year-field/index.ts","../../../libs/watt/package/year-field/energinet-watt-year-field.ts"],"sourcesContent":["//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport {\n input,\n output,\n signal,\n computed,\n Component,\n forwardRef,\n ViewEncapsulation,\n ChangeDetectionStrategy,\n} from '@angular/core';\n\nimport {\n FormControl,\n NG_VALUE_ACCESSOR,\n ReactiveFormsModule,\n ControlValueAccessor,\n} from '@angular/forms';\n\nimport { share } from 'rxjs';\nimport { MatCalendar } from '@angular/material/datepicker';\nimport { outputFromObservable, takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\n\nimport { dayjs } from '@energinet/watt/core/date';\nimport { WattFieldComponent } from '@energinet/watt/field';\nimport { WattButtonComponent } from '@energinet/watt/button';\n\nexport const YEAR_FORMAT = 'YYYY';\n\n/* eslint-disable @angular-eslint/component-class-suffix */\n@Component({\n selector: 'watt-year-field',\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => WattYearField),\n multi: true,\n },\n ],\n imports: [ReactiveFormsModule, MatCalendar, WattButtonComponent, WattFieldComponent],\n styles: [\n `\n watt-year-field {\n display: block;\n width: 100%;\n\n &:has(.watt-year-field__step-through) {\n display: flex;\n flex-align: flex-start;\n\n .watt-year-field__step-through {\n display: flex;\n }\n }\n\n &:has(.watt-year-field__has-label) {\n .watt-year-field__step-through {\n margin-top: 28px;\n }\n }\n }\n\n .watt-year-field-picker {\n position: fixed;\n position-area: bottom span-right;\n position-try-fallbacks: flip-block;\n width: 296px;\n height: 354px;\n inset: unset;\n margin: unset;\n border: 0;\n }\n `,\n ],\n template: `\n <watt-field [label]=\"label()\" [control]=\"control\" [anchorName]=\"anchorName\">\n <input\n #field\n readonly\n [formControl]=\"control\"\n (focus)=\"handleFocus(picker)\"\n (blur)=\"handleBlur(picker, $event)\"\n />\n <watt-button icon=\"date\" variant=\"icon\" (click)=\"field.focus()\" />\n <div\n #picker\n class=\"watt-elevation watt-year-field-picker\"\n popover=\"manual\"\n tabindex=\"0\"\n [style.position-anchor]=\"anchorName\"\n >\n @if (isOpen()) {\n <mat-calendar\n startView=\"multi-year\"\n [startAt]=\"selected()\"\n [selected]=\"selected()\"\n [minDate]=\"min()\"\n [maxDate]=\"max()\"\n (yearSelected)=\"handleSelectedChange(field, $event)\"\n />\n }\n </div>\n <ng-content />\n <ng-content select=\"watt-field-error\" ngProjectAs=\"watt-field-error\" />\n <ng-content select=\"watt-field-hint\" ngProjectAs=\"watt-field-hint\" />\n </watt-field>\n\n @if (canStepThroughYears()) {\n <span class=\"watt-year-field__step-through\" [class.watt-year-field__has-label]=\"!!label()\">\n <watt-button\n variant=\"icon\"\n icon=\"left\"\n (click)=\"prevYear(field)\"\n [disabled]=\"control.disabled || isPrevYearButtonDisabled()\"\n />\n <watt-button\n variant=\"icon\"\n icon=\"right\"\n (click)=\"nextYear(field)\"\n [disabled]=\"control.disabled || isNextYearButtonDisabled()\"\n />\n </span>\n }\n `,\n})\nexport class WattYearField implements ControlValueAccessor {\n // Popovers exists on an entirely different layer, meaning that for anchor positioning they\n // look at the entire tree for the anchor name. This gives each field a unique anchor name.\n private static instance = 0;\n private instance = WattYearField.instance++;\n protected anchorName = `--watt-year-field-popover-anchor-${this.instance}`;\n\n // The format of the inner FormControl is different from that of the outer FormControl\n protected control = new FormControl('', { nonNullable: true });\n\n // `registerOnChange` may subscribe to this component after it has been destroyed, thus\n // triggering an NG0911 from the `takeUntilDestroyed` operator. By sharing the observable,\n // the observable will already be closed and `subscribe` becomes a proper noop.\n private valueChanges = this.control.valueChanges.pipe(takeUntilDestroyed(), share());\n private year = toSignal(this.valueChanges);\n protected selected = computed(() => {\n const date = dayjs(this.year(), YEAR_FORMAT, true);\n if (date.isValid()) return date.toDate();\n return undefined;\n });\n\n // This is used to reset the MatCalendar component by destroying and then recreating it\n // whenever the picker is opened. There is no methods to do it programatically.\n protected isOpen = signal(false);\n\n /** Set the label text for `watt-field`. */\n label = input('');\n\n /** The minimum selectable date. */\n min = input<Date>();\n\n /** The maximum selectable date. */\n max = input<Date>();\n\n /** Enable buttons to step through years. */\n canStepThroughYears = input(false);\n\n /** Emits when the selected year has changed. */\n yearChange = outputFromObservable(this.valueChanges);\n\n /** Emits when the field loses focus. */\n // eslint-disable-next-line @angular-eslint/no-output-native\n blur = output<FocusEvent>();\n\n isPrevYearButtonDisabled = computed(() => this.isPrevYearBeforeOrEqualToMinDate());\n isNextYearButtonDisabled = computed(() => this.isNextYearAfterOrEqualToMaxDate());\n\n protected handleFocus = (picker: HTMLElement) => {\n this.isOpen.set(true);\n picker.showPopover();\n };\n\n protected handleBlur = (picker: HTMLElement, event: FocusEvent) => {\n if (event.relatedTarget instanceof HTMLElement && picker.contains(event.relatedTarget)) {\n const target = event.target as HTMLInputElement; // safe type assertion\n setTimeout(() => target.focus()); // keep focus on input element while using the picker\n } else {\n picker.hidePopover();\n this.isOpen.set(false);\n this.blur.emit(event);\n }\n };\n\n protected handleSelectedChange = (field: HTMLInputElement, date: Date) => {\n field.value = dayjs(date).format(YEAR_FORMAT);\n field.dispatchEvent(new Event('input', { bubbles: true }));\n setTimeout(() => field.blur());\n };\n\n // Implementation for ControlValueAccessor\n writeValue = (value: string | null) => this.control.setValue(value ?? '');\n setDisabledState = (x: boolean) => (x ? this.control.disable() : this.control.enable());\n registerOnTouched = (fn: () => void) => this.blur.subscribe(fn);\n registerOnChange = (fn: (value: string | null) => void) => this.valueChanges.subscribe(fn);\n\n /**\n * @ignore\n */\n protected prevYear(field: HTMLInputElement): void {\n this.changeYear(field, -1);\n }\n /**\n * @ignore\n */\n protected nextYear(field: HTMLInputElement): void {\n this.changeYear(field, 1);\n }\n\n /**\n * @ignore\n */\n private changeYear(field: HTMLInputElement, value: number): void {\n const currentDate = dayjs(field.value, YEAR_FORMAT, true);\n\n if (!currentDate.isValid()) return;\n\n const newDate = currentDate.add(value, 'year');\n this.handleSelectedChange(field, newDate.toDate());\n }\n\n /**\n * @ignore\n */\n isPrevYearBeforeOrEqualToMinDate(): boolean {\n const min = this.min();\n\n if (!min) return false;\n\n const selectedDate = dayjs(this.selected());\n\n const isBefore = selectedDate.isBefore(min, 'year');\n const isSame = selectedDate.isSame(min, 'year');\n\n return isSame || isBefore;\n }\n\n /**\n * @ignore\n */\n isNextYearAfterOrEqualToMaxDate(): boolean {\n const max = this.max();\n\n if (!max) return false;\n\n const selectedDate = dayjs(this.selected());\n\n const isAfter = selectedDate.isAfter(max, 'year');\n const isSame = selectedDate.isSame(max, 'year');\n\n return isSame || isAfter;\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nexport { WattYearField, YEAR_FORMAT } from './watt-year-field.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;A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AAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,mBAAmB,8HAAE,kBAAkB,EAAA,QAAA,EAAA,YAAA,EAAA,MAAA,EAAA,CAAA,SAAA,EAAA,OAAA,EAAA,IAAA,EAAA,UAAA,EAAA,SAAA,EAAA,aAAA,EAAA,YAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FAsFxE,aAAa,EAAA,UAAA,EAAA,CAAA;kBAjGzB,SAAS;+BACE,iBAAiB,EAAA,aAAA,EACZ,iBAAiB,CAAC,IAAI,mBACpB,uBAAuB,CAAC,MAAM,EACpC,SAAA,EAAA;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAE,UAAU,CAAC,mBAAmB,CAAC;AAC5C,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;qBACF,EACQ,OAAA,EAAA,CAAC,mBAAmB,EAAE,WAAW,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,EAmC1E,QAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,weAAA,CAAA,EAAA;;;AC9IH;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
1
+ {"version":3,"file":"energinet-watt-year-field.mjs","sources":["../../../libs/watt/package/year-field/watt-year-field.component.ts","../../../libs/watt/package/year-field/index.ts","../../../libs/watt/package/year-field/energinet-watt-year-field.ts"],"sourcesContent":["//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport {\n input,\n output,\n signal,\n computed,\n Component,\n forwardRef,\n ViewEncapsulation,\n ChangeDetectionStrategy,\n booleanAttribute,\n} from '@angular/core';\n\nimport {\n FormControl,\n NG_VALUE_ACCESSOR,\n ReactiveFormsModule,\n ControlValueAccessor,\n} from '@angular/forms';\n\nimport { share } from 'rxjs';\nimport { MatCalendar } from '@angular/material/datepicker';\nimport { outputFromObservable, takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\n\nimport { dayjs } from '@energinet/watt/core/date';\nimport { WattFieldComponent } from '@energinet/watt/field';\nimport { WattButtonComponent } from '@energinet/watt/button';\n\nexport const YEAR_FORMAT = 'YYYY';\n\n/* eslint-disable @angular-eslint/component-class-suffix */\n@Component({\n selector: 'watt-year-field',\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => WattYearField),\n multi: true,\n },\n ],\n imports: [ReactiveFormsModule, MatCalendar, WattButtonComponent, WattFieldComponent],\n styles: [\n `\n watt-year-field {\n display: block;\n width: 100%;\n\n &:has(.watt-year-field__step-through) {\n display: flex;\n flex-align: flex-start;\n\n .watt-year-field__step-through {\n display: flex;\n }\n }\n\n &:has(.watt-year-field__has-label) {\n .watt-year-field__step-through {\n margin-top: 28px;\n }\n }\n }\n\n .watt-year-field-picker {\n position: fixed;\n position-area: bottom span-right;\n position-try-fallbacks: flip-block;\n width: 296px;\n height: 354px;\n inset: unset;\n margin: unset;\n border: 0;\n }\n `,\n ],\n template: `\n <watt-field [label]=\"label()\" [control]=\"control\" [anchorName]=\"anchorName\">\n <input\n #field\n readonly\n [formControl]=\"control\"\n (focus)=\"handleFocus(picker)\"\n (blur)=\"handleBlur(picker, $event)\"\n />\n <watt-button icon=\"date\" variant=\"icon\" (click)=\"field.focus()\" />\n <div\n #picker\n class=\"watt-elevation watt-year-field-picker\"\n popover=\"manual\"\n tabindex=\"0\"\n [style.position-anchor]=\"anchorName\"\n >\n @if (isOpen()) {\n <mat-calendar\n startView=\"multi-year\"\n [startAt]=\"selected()\"\n [selected]=\"selected()\"\n [minDate]=\"min()\"\n [maxDate]=\"max()\"\n (yearSelected)=\"handleSelectedChange(field, $event)\"\n />\n }\n </div>\n <ng-content />\n <ng-content select=\"watt-field-error\" ngProjectAs=\"watt-field-error\" />\n <ng-content select=\"watt-field-hint\" ngProjectAs=\"watt-field-hint\" />\n </watt-field>\n\n @if (canStepThroughYears()) {\n <span class=\"watt-year-field__step-through\" [class.watt-year-field__has-label]=\"!!label()\">\n <watt-button\n variant=\"icon\"\n icon=\"left\"\n (click)=\"prevYear(field)\"\n [disabled]=\"control.disabled || isPrevYearButtonDisabled()\"\n />\n <watt-button\n variant=\"icon\"\n icon=\"right\"\n (click)=\"nextYear(field)\"\n [disabled]=\"control.disabled || isNextYearButtonDisabled()\"\n />\n </span>\n }\n `,\n})\nexport class WattYearField implements ControlValueAccessor {\n // Popovers exists on an entirely different layer, meaning that for anchor positioning they\n // look at the entire tree for the anchor name. This gives each field a unique anchor name.\n private static instance = 0;\n private instance = WattYearField.instance++;\n protected anchorName = `--watt-year-field-popover-anchor-${this.instance}`;\n\n // The format of the inner FormControl is different from that of the outer FormControl\n protected control = new FormControl('', { nonNullable: true });\n\n // `registerOnChange` may subscribe to this component after it has been destroyed, thus\n // triggering an NG0911 from the `takeUntilDestroyed` operator. By sharing the observable,\n // the observable will already be closed and `subscribe` becomes a proper noop.\n private valueChanges = this.control.valueChanges.pipe(takeUntilDestroyed(), share());\n private year = toSignal(this.valueChanges);\n protected selected = computed(() => {\n const date = dayjs(this.year(), YEAR_FORMAT, true);\n if (date.isValid()) return date.toDate();\n return undefined;\n });\n\n // This is used to reset the MatCalendar component by destroying and then recreating it\n // whenever the picker is opened. There is no methods to do it programatically.\n protected isOpen = signal(false);\n\n /** Set the label text for `watt-field`. */\n label = input('');\n\n /** The minimum selectable date. */\n min = input<Date>();\n\n /** The maximum selectable date. */\n max = input<Date>();\n\n /** Enable buttons to step through years. */\n canStepThroughYears = input(false, { transform: booleanAttribute });\n\n /** Emits when the selected year has changed. */\n yearChange = outputFromObservable(this.valueChanges);\n\n /** Emits when the field loses focus. */\n // eslint-disable-next-line @angular-eslint/no-output-native\n blur = output<FocusEvent>();\n\n isPrevYearButtonDisabled = computed(() => this.isPrevYearBeforeOrEqualToMinDate());\n isNextYearButtonDisabled = computed(() => this.isNextYearAfterOrEqualToMaxDate());\n\n protected handleFocus = (picker: HTMLElement) => {\n this.isOpen.set(true);\n picker.showPopover();\n };\n\n protected handleBlur = (picker: HTMLElement, event: FocusEvent) => {\n if (event.relatedTarget instanceof HTMLElement && picker.contains(event.relatedTarget)) {\n const target = event.target as HTMLInputElement; // safe type assertion\n setTimeout(() => target.focus()); // keep focus on input element while using the picker\n } else {\n picker.hidePopover();\n this.isOpen.set(false);\n this.blur.emit(event);\n }\n };\n\n protected handleSelectedChange = (field: HTMLInputElement, date: Date) => {\n field.value = dayjs(date).format(YEAR_FORMAT);\n field.dispatchEvent(new Event('input', { bubbles: true }));\n setTimeout(() => field.blur());\n };\n\n // Implementation for ControlValueAccessor\n writeValue = (value: string | null) => this.control.setValue(value ?? '');\n setDisabledState = (x: boolean) => (x ? this.control.disable() : this.control.enable());\n registerOnTouched = (fn: () => void) => this.blur.subscribe(fn);\n registerOnChange = (fn: (value: string | null) => void) => this.valueChanges.subscribe(fn);\n\n /**\n * @ignore\n */\n protected prevYear(field: HTMLInputElement): void {\n this.changeYear(field, -1);\n }\n /**\n * @ignore\n */\n protected nextYear(field: HTMLInputElement): void {\n this.changeYear(field, 1);\n }\n\n /**\n * @ignore\n */\n private changeYear(field: HTMLInputElement, value: number): void {\n const currentDate = dayjs(field.value, YEAR_FORMAT, true);\n\n if (!currentDate.isValid()) return;\n\n const newDate = currentDate.add(value, 'year');\n this.handleSelectedChange(field, newDate.toDate());\n }\n\n /**\n * @ignore\n */\n isPrevYearBeforeOrEqualToMinDate(): boolean {\n const min = this.min();\n\n if (!min) return false;\n\n const selectedDate = dayjs(this.selected());\n\n const isBefore = selectedDate.isBefore(min, 'year');\n const isSame = selectedDate.isSame(min, 'year');\n\n return isSame || isBefore;\n }\n\n /**\n * @ignore\n */\n isNextYearAfterOrEqualToMaxDate(): boolean {\n const max = this.max();\n\n if (!max) return false;\n\n const selectedDate = dayjs(this.selected());\n\n const isAfter = selectedDate.isAfter(max, 'year');\n const isSame = selectedDate.isSame(max, 'year');\n\n return isSame || isAfter;\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nexport { WattYearField, YEAR_FORMAT } from './watt-year-field.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;AA4BO,MAAM,WAAW,GAAG;AAE3B;MAkGa,aAAa,CAAA;;;AAGhB,IAAA,OAAO,QAAQ,GAAG,CAAC;AACnB,IAAA,QAAQ,GAAG,aAAa,CAAC,QAAQ,EAAE;AACjC,IAAA,UAAU,GAAG,CAAoC,iCAAA,EAAA,IAAI,CAAC,QAAQ,EAAE;;AAGhE,IAAA,OAAO,GAAG,IAAI,WAAW,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAA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AAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FAsFxE,aAAa,EAAA,UAAA,EAAA,CAAA;kBAjGzB,SAAS;+BACE,iBAAiB,EAAA,aAAA,EACZ,iBAAiB,CAAC,IAAI,mBACpB,uBAAuB,CAAC,MAAM,EACpC,SAAA,EAAA;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAE,UAAU,CAAC,mBAAmB,CAAC;AAC5C,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;qBACF,EACQ,OAAA,EAAA,CAAC,mBAAmB,EAAE,WAAW,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,EAmC1E,QAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,weAAA,CAAA,EAAA;;;AC/IH;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { computed, signal, input, output, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
2
+ import { computed, signal, input, booleanAttribute, output, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
3
3
  import * as i1 from '@angular/forms';
4
4
  import { FormControl, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
5
5
  import { takeUntilDestroyed, toSignal, outputFromObservable } from '@angular/core/rxjs-interop';
@@ -94,7 +94,7 @@ class WattYearMonthField {
94
94
  /** The maximum selectable date. */
95
95
  max = input();
96
96
  /** Enable buttons to step through months. */
97
- canStepThroughMonths = input(false);
97
+ canStepThroughMonths = input(false, { transform: booleanAttribute });
98
98
  /** Emits when the selected month has changed. */
99
99
  monthChange = outputFromObservable(this.valueChanges);
100
100
  /** Emits when the field loses focus. */
@@ -1 +1 @@
1
- {"version":3,"file":"energinet-watt-yearmonth-field.mjs","sources":["../../../libs/watt/package/yearmonth-field/year-month.ts","../../../libs/watt/package/yearmonth-field/watt-yearmonth-field.component.ts","../../../libs/watt/package/yearmonth-field/index.ts","../../../libs/watt/package/yearmonth-field/energinet-watt-yearmonth-field.ts"],"sourcesContent":["//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { dayjs } from '@energinet/watt/core/date';\n\n/** Represents a year and month. */\nexport class YearMonth {\n static readonly VIEW_FORMAT = 'MMMM YYYY';\n static readonly MODEL_FORMAT = 'YYYY-MM';\n\n private constructor(private date: dayjs.Dayjs | null) {}\n\n /** Creates a `YearMonth` instance from a `Date` object. */\n static fromDate = (value: Date) => new YearMonth(dayjs(value));\n\n /** Creates a `YearMonth` instance from a `string` in the view format. */\n static fromView = (value: string) =>\n new YearMonth(value ? dayjs(value, YearMonth.VIEW_FORMAT, true) : null);\n\n /** Creates a `YearMonth` instance from a `string` in the model format. */\n static fromModel = (value: string | null | undefined) =>\n new YearMonth(value ? dayjs(value, YearMonth.MODEL_FORMAT, true) : null);\n\n /** Converts the `YearMonth` instance to a `Date` object. */\n toDate = () => this.date?.toDate() ?? null;\n\n /** Converts the `YearMonth` instance to a `string` in the view format. */\n toView = () => this.date?.format(YearMonth.VIEW_FORMAT) ?? '';\n\n /** Converts the `YearMonth` instance to a `string` in the model format. */\n toModel = () => this.date?.format(YearMonth.MODEL_FORMAT) ?? null;\n}\n\nexport const YEARMONTH_FORMAT = YearMonth.MODEL_FORMAT;\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport {\n ChangeDetectionStrategy,\n Component,\n computed,\n forwardRef,\n input,\n output,\n signal,\n ViewEncapsulation,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormControl,\n NG_VALUE_ACCESSOR,\n ReactiveFormsModule,\n} from '@angular/forms';\nimport { outputFromObservable, takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\nimport { map, share } from 'rxjs';\nimport { MatCalendar } from '@angular/material/datepicker';\n\nimport { dayjs } from '@energinet/watt/core/date';\nimport { WattFieldComponent } from '@energinet/watt/field';\nimport { WattButtonComponent } from '@energinet/watt/button';\n\nimport { YearMonth } from './year-month';\n\n/* eslint-disable @angular-eslint/component-class-suffix */\n@Component({\n selector: 'watt-yearmonth-field',\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => WattYearMonthField),\n multi: true,\n },\n ],\n imports: [ReactiveFormsModule, MatCalendar, WattButtonComponent, WattFieldComponent],\n styles: [\n `\n watt-yearmonth-field {\n display: block;\n width: 100%;\n\n & input {\n text-transform: capitalize;\n }\n\n &:has(.watt-yearmonth-field__step-through) {\n display: flex;\n flex-align: flex-start;\n\n .watt-yearmonth-field__step-through {\n display: flex;\n }\n }\n\n &:has(.watt-yearmonth-field__has-label) {\n .watt-yearmonth-field__step-through {\n margin-top: 28px;\n }\n }\n }\n\n .watt-yearmonth-field-picker {\n position: fixed;\n position-area: bottom span-right;\n position-try-fallbacks: flip-block;\n width: 296px;\n height: 354px;\n inset: unset;\n margin: unset;\n border: 0;\n }\n `,\n ],\n template: `\n <watt-field [label]=\"label()\" [control]=\"control\" [anchorName]=\"anchorName\">\n <input\n #field\n readonly\n [formControl]=\"control\"\n (focus)=\"handleFocus(picker)\"\n (blur)=\"handleBlur(picker, $event)\"\n />\n <watt-button icon=\"date\" variant=\"icon\" (click)=\"field.focus()\" />\n <div\n #picker\n class=\"watt-elevation watt-yearmonth-field-picker\"\n popover=\"manual\"\n tabindex=\"0\"\n [style.position-anchor]=\"anchorName\"\n >\n @if (isOpen()) {\n <mat-calendar\n startView=\"multi-year\"\n [startAt]=\"selected()\"\n [selected]=\"selected()\"\n [minDate]=\"min()\"\n [maxDate]=\"max()\"\n (monthSelected)=\"handleSelectedChange(field, $event)\"\n />\n }\n </div>\n <ng-content />\n <ng-content select=\"watt-field-error\" ngProjectAs=\"watt-field-error\" />\n <ng-content select=\"watt-field-hint\" ngProjectAs=\"watt-field-hint\" />\n </watt-field>\n\n @if (canStepThroughMonths()) {\n <span\n class=\"watt-yearmonth-field__step-through\"\n [class.watt-yearmonth-field__has-label]=\"!!label()\"\n >\n <watt-button\n variant=\"icon\"\n icon=\"left\"\n (click)=\"prevMonth(field)\"\n [disabled]=\"control.disabled || isPrevMonthButtonDisabled()\"\n />\n <watt-button\n variant=\"icon\"\n icon=\"right\"\n (click)=\"nextMonth(field)\"\n [disabled]=\"control.disabled || isNextMonthButtonDisabled()\"\n />\n </span>\n }\n `,\n})\nexport class WattYearMonthField implements ControlValueAccessor {\n // Popovers exists on an entirely different layer, meaning that for anchor positioning they\n // look at the entire tree for the anchor name. This gives each field a unique anchor name.\n private static instance = 0;\n private instance = WattYearMonthField.instance++;\n protected anchorName = `--watt-yearmonth-field-popover-anchor-${this.instance}`;\n\n // The format of the inner FormControl is different from that of the outer FormControl\n protected control = new FormControl('', { nonNullable: true });\n\n // `registerOnChange` may subscribe to this component after it has been destroyed, thus\n // triggering an NG0911 from the `takeUntilDestroyed` operator. By sharing the observable,\n // the observable will already be closed and `subscribe` becomes a proper noop.\n private yearMonthChanges = this.control.valueChanges.pipe(map(YearMonth.fromView));\n private valueChanges = this.yearMonthChanges.pipe(\n map((yearMonth) => yearMonth.toModel()),\n takeUntilDestroyed(),\n share()\n );\n\n private yearMonth = toSignal(this.yearMonthChanges);\n protected selected = computed(() => this.yearMonth()?.toDate());\n\n // This is used to reset the MatCalendar component by destroying and then recreating it\n // whenever the picker is opened. There is no methods to do it programatically.\n protected isOpen = signal(false);\n\n /** Set the label text for `watt-field`. */\n label = input('');\n\n /** The minimum selectable date. */\n min = input<Date>();\n\n /** The maximum selectable date. */\n max = input<Date>();\n\n /** Enable buttons to step through months. */\n canStepThroughMonths = input(false);\n\n /** Emits when the selected month has changed. */\n monthChange = outputFromObservable(this.valueChanges);\n\n /** Emits when the field loses focus. */\n // eslint-disable-next-line @angular-eslint/no-output-native\n blur = output<FocusEvent>();\n\n isPrevMonthButtonDisabled = computed(() => this.isPrevMonthBeforeOrEqualToMinDate());\n isNextMonthButtonDisabled = computed(() => this.isNextMonthAfterOrEqualToMaxDate());\n\n protected handleFocus = (picker: HTMLElement) => {\n this.isOpen.set(true);\n picker.showPopover();\n };\n\n protected handleBlur = (picker: HTMLElement, event: FocusEvent) => {\n if (event.relatedTarget instanceof HTMLElement && picker.contains(event.relatedTarget)) {\n const target = event.target as HTMLInputElement; // safe type assertion\n setTimeout(() => target.focus()); // keep focus on input element while using the picker\n } else {\n picker.hidePopover();\n this.isOpen.set(false);\n this.blur.emit(event);\n }\n };\n\n protected handleSelectedChange = (field: HTMLInputElement, date: Date) => {\n field.value = YearMonth.fromDate(date).toView();\n field.dispatchEvent(new Event('input', { bubbles: true }));\n setTimeout(() => field.blur());\n };\n\n // Implementation for ControlValueAccessor\n writeValue = (value: string | null) => this.control.setValue(YearMonth.fromModel(value).toView());\n setDisabledState = (x: boolean) => (x ? this.control.disable() : this.control.enable());\n registerOnTouched = (fn: () => void) => this.blur.subscribe(fn);\n registerOnChange = (fn: (value: string | null) => void) => this.valueChanges.subscribe(fn);\n\n /**\n * @ignore\n */\n protected prevMonth(field: HTMLInputElement): void {\n this.changeMonth(field, -1);\n }\n /**\n * @ignore\n */\n protected nextMonth(field: HTMLInputElement): void {\n this.changeMonth(field, 1);\n }\n\n /**\n * @ignore\n */\n private changeMonth(field: HTMLInputElement, value: number): void {\n const currentDate = YearMonth.fromView(field.value).toDate();\n\n if (!currentDate) return;\n\n const newDate = dayjs(currentDate).add(value, 'month');\n this.handleSelectedChange(field, newDate.toDate());\n }\n\n /**\n * @ignore\n */\n isPrevMonthBeforeOrEqualToMinDate(): boolean {\n const min = this.min();\n\n if (!min) return false;\n\n const selectedDate = dayjs(this.selected());\n\n const isBefore = selectedDate.isBefore(min, 'month');\n const isSame = selectedDate.isSame(min, 'month');\n\n return isSame || isBefore;\n }\n\n /**\n * @ignore\n */\n isNextMonthAfterOrEqualToMaxDate(): boolean {\n const max = this.max();\n\n if (!max) return false;\n\n const selectedDate = dayjs(this.selected());\n\n const isAfter = selectedDate.isAfter(max, 'month');\n const isSame = selectedDate.isSame(max, 'month');\n\n return isSame || isAfter;\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nexport { WattYearMonthField } from './watt-yearmonth-field.component';\nexport { YEARMONTH_FORMAT } from './year-month';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;AAGA;MACa,SAAS,CAAA;AAIQ,IA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AAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FA6FxE,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAxG9B,SAAS;+BACE,sBAAsB,EAAA,aAAA,EACjB,iBAAiB,CAAC,IAAI,mBACpB,uBAAuB,CAAC,MAAM,EACpC,SAAA,EAAA;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAE,UAAU,CAAC,wBAAwB,CAAC;AACjD,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;qBACF,EACQ,OAAA,EAAA,CAAC,mBAAmB,EAAE,WAAW,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,EAuC1E,QAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,+kBAAA,CAAA,EAAA;;;ACnJH;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
1
+ {"version":3,"file":"energinet-watt-yearmonth-field.mjs","sources":["../../../libs/watt/package/yearmonth-field/year-month.ts","../../../libs/watt/package/yearmonth-field/watt-yearmonth-field.component.ts","../../../libs/watt/package/yearmonth-field/index.ts","../../../libs/watt/package/yearmonth-field/energinet-watt-yearmonth-field.ts"],"sourcesContent":["//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { dayjs } from '@energinet/watt/core/date';\n\n/** Represents a year and month. */\nexport class YearMonth {\n static readonly VIEW_FORMAT = 'MMMM YYYY';\n static readonly MODEL_FORMAT = 'YYYY-MM';\n\n private constructor(private date: dayjs.Dayjs | null) {}\n\n /** Creates a `YearMonth` instance from a `Date` object. */\n static fromDate = (value: Date) => new YearMonth(dayjs(value));\n\n /** Creates a `YearMonth` instance from a `string` in the view format. */\n static fromView = (value: string) =>\n new YearMonth(value ? dayjs(value, YearMonth.VIEW_FORMAT, true) : null);\n\n /** Creates a `YearMonth` instance from a `string` in the model format. */\n static fromModel = (value: string | null | undefined) =>\n new YearMonth(value ? dayjs(value, YearMonth.MODEL_FORMAT, true) : null);\n\n /** Converts the `YearMonth` instance to a `Date` object. */\n toDate = () => this.date?.toDate() ?? null;\n\n /** Converts the `YearMonth` instance to a `string` in the view format. */\n toView = () => this.date?.format(YearMonth.VIEW_FORMAT) ?? '';\n\n /** Converts the `YearMonth` instance to a `string` in the model format. */\n toModel = () => this.date?.format(YearMonth.MODEL_FORMAT) ?? null;\n}\n\nexport const YEARMONTH_FORMAT = YearMonth.MODEL_FORMAT;\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport {\n booleanAttribute,\n ChangeDetectionStrategy,\n Component,\n computed,\n forwardRef,\n input,\n output,\n signal,\n ViewEncapsulation,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormControl,\n NG_VALUE_ACCESSOR,\n ReactiveFormsModule,\n} from '@angular/forms';\nimport { outputFromObservable, takeUntilDestroyed, toSignal } from '@angular/core/rxjs-interop';\nimport { map, share } from 'rxjs';\nimport { MatCalendar } from '@angular/material/datepicker';\n\nimport { dayjs } from '@energinet/watt/core/date';\nimport { WattFieldComponent } from '@energinet/watt/field';\nimport { WattButtonComponent } from '@energinet/watt/button';\n\nimport { YearMonth } from './year-month';\n\n/* eslint-disable @angular-eslint/component-class-suffix */\n@Component({\n selector: 'watt-yearmonth-field',\n encapsulation: ViewEncapsulation.None,\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => WattYearMonthField),\n multi: true,\n },\n ],\n imports: [ReactiveFormsModule, MatCalendar, WattButtonComponent, WattFieldComponent],\n styles: [\n `\n watt-yearmonth-field {\n display: block;\n width: 100%;\n\n & input {\n text-transform: capitalize;\n }\n\n &:has(.watt-yearmonth-field__step-through) {\n display: flex;\n flex-align: flex-start;\n\n .watt-yearmonth-field__step-through {\n display: flex;\n }\n }\n\n &:has(.watt-yearmonth-field__has-label) {\n .watt-yearmonth-field__step-through {\n margin-top: 28px;\n }\n }\n }\n\n .watt-yearmonth-field-picker {\n position: fixed;\n position-area: bottom span-right;\n position-try-fallbacks: flip-block;\n width: 296px;\n height: 354px;\n inset: unset;\n margin: unset;\n border: 0;\n }\n `,\n ],\n template: `\n <watt-field [label]=\"label()\" [control]=\"control\" [anchorName]=\"anchorName\">\n <input\n #field\n readonly\n [formControl]=\"control\"\n (focus)=\"handleFocus(picker)\"\n (blur)=\"handleBlur(picker, $event)\"\n />\n <watt-button icon=\"date\" variant=\"icon\" (click)=\"field.focus()\" />\n <div\n #picker\n class=\"watt-elevation watt-yearmonth-field-picker\"\n popover=\"manual\"\n tabindex=\"0\"\n [style.position-anchor]=\"anchorName\"\n >\n @if (isOpen()) {\n <mat-calendar\n startView=\"multi-year\"\n [startAt]=\"selected()\"\n [selected]=\"selected()\"\n [minDate]=\"min()\"\n [maxDate]=\"max()\"\n (monthSelected)=\"handleSelectedChange(field, $event)\"\n />\n }\n </div>\n <ng-content />\n <ng-content select=\"watt-field-error\" ngProjectAs=\"watt-field-error\" />\n <ng-content select=\"watt-field-hint\" ngProjectAs=\"watt-field-hint\" />\n </watt-field>\n\n @if (canStepThroughMonths()) {\n <span\n class=\"watt-yearmonth-field__step-through\"\n [class.watt-yearmonth-field__has-label]=\"!!label()\"\n >\n <watt-button\n variant=\"icon\"\n icon=\"left\"\n (click)=\"prevMonth(field)\"\n [disabled]=\"control.disabled || isPrevMonthButtonDisabled()\"\n />\n <watt-button\n variant=\"icon\"\n icon=\"right\"\n (click)=\"nextMonth(field)\"\n [disabled]=\"control.disabled || isNextMonthButtonDisabled()\"\n />\n </span>\n }\n `,\n})\nexport class WattYearMonthField implements ControlValueAccessor {\n // Popovers exists on an entirely different layer, meaning that for anchor positioning they\n // look at the entire tree for the anchor name. This gives each field a unique anchor name.\n private static instance = 0;\n private instance = WattYearMonthField.instance++;\n protected anchorName = `--watt-yearmonth-field-popover-anchor-${this.instance}`;\n\n // The format of the inner FormControl is different from that of the outer FormControl\n protected control = new FormControl('', { nonNullable: true });\n\n // `registerOnChange` may subscribe to this component after it has been destroyed, thus\n // triggering an NG0911 from the `takeUntilDestroyed` operator. By sharing the observable,\n // the observable will already be closed and `subscribe` becomes a proper noop.\n private yearMonthChanges = this.control.valueChanges.pipe(map(YearMonth.fromView));\n private valueChanges = this.yearMonthChanges.pipe(\n map((yearMonth) => yearMonth.toModel()),\n takeUntilDestroyed(),\n share()\n );\n\n private yearMonth = toSignal(this.yearMonthChanges);\n protected selected = computed(() => this.yearMonth()?.toDate());\n\n // This is used to reset the MatCalendar component by destroying and then recreating it\n // whenever the picker is opened. There is no methods to do it programatically.\n protected isOpen = signal(false);\n\n /** Set the label text for `watt-field`. */\n label = input('');\n\n /** The minimum selectable date. */\n min = input<Date>();\n\n /** The maximum selectable date. */\n max = input<Date>();\n\n /** Enable buttons to step through months. */\n canStepThroughMonths = input(false, { transform: booleanAttribute });\n\n /** Emits when the selected month has changed. */\n monthChange = outputFromObservable(this.valueChanges);\n\n /** Emits when the field loses focus. */\n // eslint-disable-next-line @angular-eslint/no-output-native\n blur = output<FocusEvent>();\n\n isPrevMonthButtonDisabled = computed(() => this.isPrevMonthBeforeOrEqualToMinDate());\n isNextMonthButtonDisabled = computed(() => this.isNextMonthAfterOrEqualToMaxDate());\n\n protected handleFocus = (picker: HTMLElement) => {\n this.isOpen.set(true);\n picker.showPopover();\n };\n\n protected handleBlur = (picker: HTMLElement, event: FocusEvent) => {\n if (event.relatedTarget instanceof HTMLElement && picker.contains(event.relatedTarget)) {\n const target = event.target as HTMLInputElement; // safe type assertion\n setTimeout(() => target.focus()); // keep focus on input element while using the picker\n } else {\n picker.hidePopover();\n this.isOpen.set(false);\n this.blur.emit(event);\n }\n };\n\n protected handleSelectedChange = (field: HTMLInputElement, date: Date) => {\n field.value = YearMonth.fromDate(date).toView();\n field.dispatchEvent(new Event('input', { bubbles: true }));\n setTimeout(() => field.blur());\n };\n\n // Implementation for ControlValueAccessor\n writeValue = (value: string | null) => this.control.setValue(YearMonth.fromModel(value).toView());\n setDisabledState = (x: boolean) => (x ? this.control.disable() : this.control.enable());\n registerOnTouched = (fn: () => void) => this.blur.subscribe(fn);\n registerOnChange = (fn: (value: string | null) => void) => this.valueChanges.subscribe(fn);\n\n /**\n * @ignore\n */\n protected prevMonth(field: HTMLInputElement): void {\n this.changeMonth(field, -1);\n }\n /**\n * @ignore\n */\n protected nextMonth(field: HTMLInputElement): void {\n this.changeMonth(field, 1);\n }\n\n /**\n * @ignore\n */\n private changeMonth(field: HTMLInputElement, value: number): void {\n const currentDate = YearMonth.fromView(field.value).toDate();\n\n if (!currentDate) return;\n\n const newDate = dayjs(currentDate).add(value, 'month');\n this.handleSelectedChange(field, newDate.toDate());\n }\n\n /**\n * @ignore\n */\n isPrevMonthBeforeOrEqualToMinDate(): boolean {\n const min = this.min();\n\n if (!min) return false;\n\n const selectedDate = dayjs(this.selected());\n\n const isBefore = selectedDate.isBefore(min, 'month');\n const isSame = selectedDate.isSame(min, 'month');\n\n return isSame || isBefore;\n }\n\n /**\n * @ignore\n */\n isNextMonthAfterOrEqualToMaxDate(): boolean {\n const max = this.max();\n\n if (!max) return false;\n\n const selectedDate = dayjs(this.selected());\n\n const isAfter = selectedDate.isAfter(max, 'month');\n const isSame = selectedDate.isSame(max, 'month');\n\n return isSame || isAfter;\n }\n}\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nexport { WattYearMonthField } from './watt-yearmonth-field.component';\nexport { YEARMONTH_FORMAT } from './year-month';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;AAGA;MACa,SAAS,CAAA;AAIQ,IAAA,IAAA;AAH5B,IAAA,OAAgB,WAAW,GAAG,WAAW;AACzC,IAAA,OAAgB,YAAY,GAAG,SAAS;AAExC,IAAA,WAAA,CAA4B,IAAwB,EAAA;QAAxB,IAAI,CAAA,IAAA,GAAJ,IAAI;;;AAGhC,IAAA,OAAO,QAAQ,GAAG,CAAC,KAAW,KAAK,IAAI,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;;AAG9D,IAAA,OAAO,QAAQ,GAAG,CAAC,KAAa,KAC9B,IAAI,SAAS,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,EAAE,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;;AAGzE,IAAA,OAAO,SAAS,GAAG,CAAC,KAAgC,KAClD,IAAI,SAAS,CAAC,KAAK,GAAG,KAAK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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,+kBAAA,CAAA,EAAA;;;ACpJH;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@energinet/watt",
4
- "version": "1.5.8",
4
+ "version": "1.5.10",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  ".": {
@@ -21,8 +21,10 @@ export declare class WattDatepickerComponent extends WattPickerBase implements V
21
21
  max: import("@angular/core").InputSignal<Date | undefined>;
22
22
  min: import("@angular/core").InputSignal<Date | undefined>;
23
23
  rangeMonthOnlyMode: import("@angular/core").InputSignal<boolean>;
24
- startAt: Date | null;
25
- label: string;
24
+ startAt: import("@angular/core").InputSignal<Date | null>;
25
+ label: import("@angular/core").InputSignal<string>;
26
+ dateClass: import("@angular/core").InputSignal<MatCalendarCellClassFunction<Date>>;
27
+ canStepThroughDays: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
26
28
  /**
27
29
  * @ignore
28
30
  */
@@ -40,24 +42,23 @@ export declare class WattDatepickerComponent extends WattPickerBase implements V
40
42
  /**
41
43
  * @ignore
42
44
  */
43
- actualInput: ElementRef;
45
+ actualInput: ElementRef<HTMLInputElement>;
44
46
  /**
45
47
  * @ignore
46
48
  */
47
- input: ElementRef;
49
+ input: ElementRef<HTMLInputElement>;
48
50
  /**
49
51
  * @ignore
50
52
  */
51
- startInput: ElementRef;
53
+ startInput: ElementRef<HTMLInputElement>;
52
54
  /**
53
55
  * @ignore
54
56
  */
55
- endInput: ElementRef;
57
+ endInput: ElementRef<HTMLInputElement>;
56
58
  /**
57
59
  * @ignore
58
60
  */
59
61
  protected _placeholder: string;
60
- dateClass: MatCalendarCellClassFunction<Date>;
61
62
  /**
62
63
  * @ignore
63
64
  */
@@ -83,6 +84,8 @@ export declare class WattDatepickerComponent extends WattPickerBase implements V
83
84
  */
84
85
  getPlaceholderByLocale(locale: WattSupportedLocales): string;
85
86
  getRangePlaceholder(): string;
87
+ isPrevDayButtonDisabled: import("@angular/core").WritableSignal<boolean>;
88
+ isNextDayButtonDisabled: import("@angular/core").WritableSignal<boolean>;
86
89
  constructor();
87
90
  ngAfterViewInit(): void;
88
91
  validate({ value }: AbstractControl<WattRange<string>>): {
@@ -107,6 +110,26 @@ export declare class WattDatepickerComponent extends WattPickerBase implements V
107
110
  * @ignore
108
111
  */
109
112
  protected setRangeValue(value: WattDateRange | null, startInput: HTMLInputElement, endInput: HTMLInputElement): void;
113
+ /**
114
+ * @ignore
115
+ */
116
+ prevDay(): void;
117
+ /**
118
+ * @ignore
119
+ */
120
+ nextDay(): void;
121
+ /**
122
+ * @ignore
123
+ */
124
+ private changeDay;
125
+ /**
126
+ * @ignore
127
+ */
128
+ private isPrevDayBeforeOrEqualToMinDate;
129
+ /**
130
+ * @ignore
131
+ */
132
+ private isNextDayAfterOrEqualToMaxDate;
110
133
  /**
111
134
  * @ignore
112
135
  */
@@ -145,5 +168,5 @@ export declare class WattDatepickerComponent extends WattPickerBase implements V
145
168
  */
146
169
  private setEndDateToDanishTimeZone;
147
170
  static ɵfac: i0.ɵɵFactoryDeclaration<WattDatepickerComponent, never>;
148
- static ɵcmp: i0.ɵɵComponentDeclaration<WattDatepickerComponent, "watt-datepicker", never, { "max": { "alias": "max"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "rangeMonthOnlyMode": { "alias": "rangeMonthOnlyMode"; "required": false; "isSignal": true; }; "startAt": { "alias": "startAt"; "required": false; }; "label": { "alias": "label"; "required": false; }; "dateClass": { "alias": "dateClass"; "required": false; }; }, {}, never, ["*", "watt-field-hint", "watt-field-error"], true, never>;
171
+ static ɵcmp: i0.ɵɵComponentDeclaration<WattDatepickerComponent, "watt-datepicker", never, { "max": { "alias": "max"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "rangeMonthOnlyMode": { "alias": "rangeMonthOnlyMode"; "required": false; "isSignal": true; }; "startAt": { "alias": "startAt"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "dateClass": { "alias": "dateClass"; "required": false; "isSignal": true; }; "canStepThroughDays": { "alias": "canStepThroughDays"; "required": false; "isSignal": true; }; }, {}, never, ["*", "watt-field-hint", "watt-field-error"], true, never>;
149
172
  }
@@ -17,7 +17,7 @@ export declare class WattYearField implements ControlValueAccessor {
17
17
  /** The maximum selectable date. */
18
18
  max: import("@angular/core").InputSignal<Date | undefined>;
19
19
  /** Enable buttons to step through years. */
20
- canStepThroughYears: import("@angular/core").InputSignal<boolean>;
20
+ canStepThroughYears: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
21
21
  /** Emits when the selected year has changed. */
22
22
  yearChange: import("@angular/core").OutputRef<string>;
23
23
  /** Emits when the field loses focus. */
@@ -17,7 +17,7 @@ export declare class WattYearMonthField implements ControlValueAccessor {
17
17
  /** The maximum selectable date. */
18
18
  max: import("@angular/core").InputSignal<Date | undefined>;
19
19
  /** Enable buttons to step through months. */
20
- canStepThroughMonths: import("@angular/core").InputSignal<boolean>;
20
+ canStepThroughMonths: import("@angular/core").InputSignalWithTransform<boolean, unknown>;
21
21
  /** Emits when the selected month has changed. */
22
22
  monthChange: import("@angular/core").OutputRef<string | null>;
23
23
  /** Emits when the field loses focus. */