@energinet/watt 2.0.7 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/fesm2022/energinet-watt-badge.mjs.map +1 -1
  2. package/fesm2022/energinet-watt-breadcrumbs.mjs.map +1 -1
  3. package/fesm2022/energinet-watt-button.mjs.map +1 -1
  4. package/fesm2022/energinet-watt-card.mjs.map +1 -1
  5. package/fesm2022/energinet-watt-checkbox.mjs.map +1 -1
  6. package/fesm2022/energinet-watt-chip.mjs.map +1 -1
  7. package/fesm2022/energinet-watt-code.mjs.map +1 -1
  8. package/fesm2022/energinet-watt-core-breakpoints.mjs.map +1 -1
  9. package/fesm2022/energinet-watt-core-color.mjs.map +1 -1
  10. package/fesm2022/energinet-watt-core-date.mjs.map +1 -1
  11. package/fesm2022/energinet-watt-data.mjs.map +1 -1
  12. package/fesm2022/energinet-watt-datetime-field.mjs.map +1 -1
  13. package/fesm2022/energinet-watt-description-list.mjs.map +1 -1
  14. package/fesm2022/energinet-watt-drawer.mjs.map +1 -1
  15. package/fesm2022/energinet-watt-dropdown.mjs.map +1 -1
  16. package/fesm2022/energinet-watt-dropzone.mjs.map +1 -1
  17. package/fesm2022/energinet-watt-empty-state.mjs.map +1 -1
  18. package/fesm2022/energinet-watt-expandable-card.mjs.map +1 -1
  19. package/fesm2022/energinet-watt-expansion.mjs.map +1 -1
  20. package/fesm2022/energinet-watt-field.mjs.map +1 -1
  21. package/fesm2022/energinet-watt-icon-flags.mjs.map +1 -1
  22. package/fesm2022/energinet-watt-icon.mjs.map +1 -1
  23. package/fesm2022/energinet-watt-modal.mjs.map +1 -1
  24. package/fesm2022/energinet-watt-paginator.mjs.map +1 -1
  25. package/fesm2022/energinet-watt-phone-field.mjs.map +1 -1
  26. package/fesm2022/energinet-watt-picker-__shared.mjs.map +1 -1
  27. package/fesm2022/energinet-watt-picker-datepicker.mjs.map +1 -1
  28. package/fesm2022/energinet-watt-picker-timepicker.mjs.map +1 -1
  29. package/fesm2022/energinet-watt-progress-tracker.mjs.map +1 -1
  30. package/fesm2022/energinet-watt-radio.mjs.map +1 -1
  31. package/fesm2022/energinet-watt-search.mjs.map +1 -1
  32. package/fesm2022/energinet-watt-segmented-buttons.mjs.map +1 -1
  33. package/fesm2022/energinet-watt-shell.mjs.map +1 -1
  34. package/fesm2022/energinet-watt-slide-toggle.mjs.map +1 -1
  35. package/fesm2022/energinet-watt-spinner.mjs.map +1 -1
  36. package/fesm2022/energinet-watt-stepper.mjs.map +1 -1
  37. package/fesm2022/energinet-watt-table.mjs.map +1 -1
  38. package/fesm2022/energinet-watt-tabs.mjs.map +1 -1
  39. package/fesm2022/energinet-watt-text-field.mjs.map +1 -1
  40. package/fesm2022/energinet-watt-textarea-field.mjs.map +1 -1
  41. package/fesm2022/energinet-watt-toast.mjs.map +1 -1
  42. package/fesm2022/energinet-watt-tooltip.mjs.map +1 -1
  43. package/fesm2022/energinet-watt-utils-css.mjs.map +1 -1
  44. package/fesm2022/energinet-watt-utils-resize-observer.mjs.map +1 -1
  45. package/fesm2022/energinet-watt-validation-message.mjs.map +1 -1
  46. package/fesm2022/energinet-watt-validators.mjs +9 -0
  47. package/fesm2022/energinet-watt-validators.mjs.map +1 -1
  48. package/fesm2022/energinet-watt-vater.mjs.map +1 -1
  49. package/fesm2022/energinet-watt-year-field.mjs.map +1 -1
  50. package/fesm2022/energinet-watt-yearmonth-field.mjs.map +1 -1
  51. package/package.json +1 -1
  52. package/validators/watt-range.validators.d.ts +1 -0
@@ -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 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,E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,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;;;AC/IH;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,CAAA,iCAAA,EAAoC,IAAI,CAAC,QAAQ,EAAE;;AAGhE,IAAA,OAAO,GAAG,IAAI,WAAW,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;;;;AAKtD,IAAA,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,KAAK,EAAE,CAAC;AAC5E,IAAA,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC;AAChC,IAAA,QAAQ,GAAG,QAAQ,CAAC,MAAK;AACjC,QAAA,MAAM,IAAI,GAAG,KAAK,CAAC,IA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AAC,mBAAmB,CAAC;AAC5C,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;qBACF,EAAA,OAAA,EACQ,CAAC,mBAAmB,EAAE,WAAW,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,EAAA,QAAA,EAmC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDT,EAAA,CAAA,EAAA,MAAA,EAAA,CAAA,weAAA,CAAA,EAAA;;;AC/IH;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
@@ -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 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,CAAC,KAAK,EAAE,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC;;AAG1E,IAAA,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,IAAI;;AAG1C,IAAA,MAAM,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE;;AAG7D,IAAA,OAAO,GAAG,MAAM,IA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EAAA,iBAAA,EAAA,eAAA,EAAA,yBAAA,EAAA,uBAAA,CAAA,EAAA,OAAA,EAAA,CAAA,gBAAA,EAAA,cAAA,EAAA,eAAA,EAAA,aAAA,EAAA,gBAAA,EAAA,eAAA,CAAA,EAAA,QAAA,EAAA,CAAA,aAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAA,mBAAmB,sIAAE,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;;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;;;ACpJH;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;AACz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AA,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,EAAA,SAAA,EACpC;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,iBAAiB;AAC1B,4BAAA,WAAW,EAAE,UAAU,CAAC,wBAAwB,CAAC;AACjD,4BAAA,KAAK,EAAE,IAAI;AACZ,yBAAA;qBACF,EAAA,OAAA,EACQ,CAAC,mBAAmB,EAAE,WAAW,EAAE,mBAAmB,EAAE,kBAAkB,CAAC,EAAA,QAAA,EAuC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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": "2.0.7",
4
+ "version": "2.0.9",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  ".": {
@@ -20,4 +20,5 @@ export declare class WattRangeValidators {
20
20
  static startRequired: ValidatorFn;
21
21
  static endRequired: ValidatorFn;
22
22
  static maxDays: (maxDays: number) => ValidatorFn;
23
+ static maxMonths: (maxMonths: number) => ValidatorFn;
23
24
  }