@energinet/watt 1.4.3 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,198 @@
1
+ import * as i0 from '@angular/core';
2
+ import { computed, signal, input, output, forwardRef, ChangeDetectionStrategy, ViewEncapsulation, Component } from '@angular/core';
3
+ import * as i1 from '@angular/forms';
4
+ import { FormControl, ReactiveFormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
5
+ import { share } from 'rxjs';
6
+ import { MatCalendar } from '@angular/material/datepicker';
7
+ import { takeUntilDestroyed, toSignal, outputFromObservable } from '@angular/core/rxjs-interop';
8
+ import { dayjs } from '@energinet/watt/core/date';
9
+ import { WattFieldComponent } from '@energinet/watt/field';
10
+ import { WattButtonComponent } from '@energinet/watt/button';
11
+
12
+ //#region License
13
+ /**
14
+ * @license
15
+ * Copyright 2020 Energinet DataHub A/S
16
+ *
17
+ * Licensed under the Apache License, Version 2.0 (the "License2");
18
+ * you may not use this file except in compliance with the License.
19
+ * You may obtain a copy of the License at
20
+ *
21
+ * http://www.apache.org/licenses/LICENSE-2.0
22
+ *
23
+ * Unless required by applicable law or agreed to in writing, software
24
+ * distributed under the License is distributed on an "AS IS" BASIS,
25
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
26
+ * See the License for the specific language governing permissions and
27
+ * limitations under the License.
28
+ */
29
+ //#endregion
30
+ const YEAR_FORMAT = 'YYYY';
31
+ /* eslint-disable @angular-eslint/component-class-suffix */
32
+ class WattYearField {
33
+ // Popovers exists on an entirely different layer, meaning that for anchor positioning they
34
+ // look at the entire tree for the anchor name. This gives each field a unique anchor name.
35
+ static instance = 0;
36
+ instance = WattYearField.instance++;
37
+ anchorName = `--watt-year-field-popover-anchor-${this.instance}`;
38
+ // The format of the inner FormControl is different from that of the outer FormControl
39
+ control = new FormControl('', { nonNullable: true });
40
+ // `registerOnChange` may subscribe to this component after it has been destroyed, thus
41
+ // triggering an NG0911 from the `takeUntilDestroyed` operator. By sharing the observable,
42
+ // the observable will already be closed and `subscribe` becomes a proper noop.
43
+ valueChanges = this.control.valueChanges.pipe(takeUntilDestroyed(), share());
44
+ year = toSignal(this.valueChanges);
45
+ selected = computed(() => {
46
+ const date = dayjs(this.year(), YEAR_FORMAT, true);
47
+ if (date.isValid())
48
+ return date.toDate();
49
+ return undefined;
50
+ });
51
+ // This is used to reset the MatCalendar component by destroying and then recreating it
52
+ // whenever the picker is opened. There is no methods to do it programatically.
53
+ isOpen = signal(false);
54
+ /** Set the label text for `watt-field`. */
55
+ label = input('');
56
+ /** The minimum selectable date. */
57
+ min = input();
58
+ /** The maximum selectable date. */
59
+ max = input();
60
+ /** Emits when the selected year has changed. */
61
+ yearChange = outputFromObservable(this.valueChanges);
62
+ /** Emits when the field loses focus. */
63
+ // eslint-disable-next-line @angular-eslint/no-output-native
64
+ blur = output();
65
+ handleFocus = (picker) => {
66
+ this.isOpen.set(true);
67
+ picker.showPopover();
68
+ };
69
+ handleBlur = (picker, event) => {
70
+ if (event.relatedTarget instanceof HTMLElement && picker.contains(event.relatedTarget)) {
71
+ const target = event.target; // safe type assertion
72
+ setTimeout(() => target.focus()); // keep focus on input element while using the picker
73
+ }
74
+ else {
75
+ picker.hidePopover();
76
+ this.isOpen.set(false);
77
+ this.blur.emit(event);
78
+ }
79
+ };
80
+ handleSelectedChange = (field, date) => {
81
+ field.value = dayjs(date).format(YEAR_FORMAT);
82
+ field.dispatchEvent(new Event('input', { bubbles: true }));
83
+ field.blur();
84
+ };
85
+ // Implementation for ControlValueAccessor
86
+ writeValue = (value) => this.control.setValue(value ?? '');
87
+ setDisabledState = (x) => (x ? this.control.disable() : this.control.enable());
88
+ registerOnTouched = (fn) => this.blur.subscribe(fn);
89
+ registerOnChange = (fn) => this.valueChanges.subscribe(fn);
90
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattYearField, deps: [], target: i0.ɵɵFactoryTarget.Component });
91
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.1", type: WattYearField, isStandalone: true, selector: "watt-year-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { yearChange: "yearChange", blur: "blur" }, providers: [
92
+ {
93
+ provide: NG_VALUE_ACCESSOR,
94
+ useExisting: forwardRef(() => WattYearField),
95
+ multi: true,
96
+ },
97
+ ], ngImport: i0, template: `
98
+ <watt-field [label]="label()" [control]="control" [anchorName]="anchorName">
99
+ <input
100
+ #field
101
+ readonly
102
+ [formControl]="control"
103
+ (focus)="handleFocus(picker)"
104
+ (blur)="handleBlur(picker, $event)"
105
+ />
106
+ <watt-button icon="date" variant="icon" (click)="field.focus()" />
107
+ <div
108
+ #picker
109
+ class="watt-elevation watt-year-field-picker"
110
+ popover="manual"
111
+ tabindex="0"
112
+ [style.position-anchor]="anchorName"
113
+ >
114
+ @if (isOpen()) {
115
+ <mat-calendar
116
+ startView="multi-year"
117
+ [startAt]="selected()"
118
+ [selected]="selected()"
119
+ [minDate]="min()"
120
+ [maxDate]="max()"
121
+ (yearSelected)="handleSelectedChange(field, $event)"
122
+ />
123
+ }
124
+ </div>
125
+ <ng-content />
126
+ <ng-content select="watt-field-error" ngProjectAs="watt-field-error" />
127
+ <ng-content select="watt-field-hint" ngProjectAs="watt-field-hint" />
128
+ </watt-field>
129
+ `, isInline: true, styles: ["watt-year-field{display:block;width:100%}.watt-year-field-picker{position:fixed;position-area:bottom span-right;position-try-fallbacks:flip-block;width:296px;height:354px;inset:unset;margin:unset;border:0}\n"], dependencies: [{ kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "component", type: MatCalendar, selector: "mat-calendar", inputs: ["headerComponent", "startAt", "startView", "selected", "minDate", "maxDate", "dateFilter", "dateClass", "comparisonStart", "comparisonEnd", "startDateAccessibleName", "endDateAccessibleName"], outputs: ["selectedChange", "yearSelected", "monthSelected", "viewChanged", "_userSelection", "_userDragDrop"], exportAs: ["matCalendar"] }, { 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"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
130
+ }
131
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattYearField, decorators: [{
132
+ type: Component,
133
+ args: [{ selector: 'watt-year-field', encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, providers: [
134
+ {
135
+ provide: NG_VALUE_ACCESSOR,
136
+ useExisting: forwardRef(() => WattYearField),
137
+ multi: true,
138
+ },
139
+ ], imports: [ReactiveFormsModule, MatCalendar, WattButtonComponent, WattFieldComponent], template: `
140
+ <watt-field [label]="label()" [control]="control" [anchorName]="anchorName">
141
+ <input
142
+ #field
143
+ readonly
144
+ [formControl]="control"
145
+ (focus)="handleFocus(picker)"
146
+ (blur)="handleBlur(picker, $event)"
147
+ />
148
+ <watt-button icon="date" variant="icon" (click)="field.focus()" />
149
+ <div
150
+ #picker
151
+ class="watt-elevation watt-year-field-picker"
152
+ popover="manual"
153
+ tabindex="0"
154
+ [style.position-anchor]="anchorName"
155
+ >
156
+ @if (isOpen()) {
157
+ <mat-calendar
158
+ startView="multi-year"
159
+ [startAt]="selected()"
160
+ [selected]="selected()"
161
+ [minDate]="min()"
162
+ [maxDate]="max()"
163
+ (yearSelected)="handleSelectedChange(field, $event)"
164
+ />
165
+ }
166
+ </div>
167
+ <ng-content />
168
+ <ng-content select="watt-field-error" ngProjectAs="watt-field-error" />
169
+ <ng-content select="watt-field-hint" ngProjectAs="watt-field-hint" />
170
+ </watt-field>
171
+ `, styles: ["watt-year-field{display:block;width:100%}.watt-year-field-picker{position:fixed;position-area:bottom span-right;position-try-fallbacks:flip-block;width:296px;height:354px;inset:unset;margin:unset;border:0}\n"] }]
172
+ }] });
173
+
174
+ //#region License
175
+ /**
176
+ * @license
177
+ * Copyright 2020 Energinet DataHub A/S
178
+ *
179
+ * Licensed under the Apache License, Version 2.0 (the "License2");
180
+ * you may not use this file except in compliance with the License.
181
+ * You may obtain a copy of the License at
182
+ *
183
+ * http://www.apache.org/licenses/LICENSE-2.0
184
+ *
185
+ * Unless required by applicable law or agreed to in writing, software
186
+ * distributed under the License is distributed on an "AS IS" BASIS,
187
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
188
+ * See the License for the specific language governing permissions and
189
+ * limitations under the License.
190
+ */
191
+ //#endregion
192
+
193
+ /**
194
+ * Generated bundle index. Do not edit.
195
+ */
196
+
197
+ export { WattYearField, YEAR_FORMAT };
198
+ //# sourceMappingURL=energinet-watt-year-field.mjs.map
@@ -0,0 +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\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})\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 /** 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 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 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","//#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;AA2BO,MAAM,WAAW,GAAG;AAE3B;MAkEa,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,CA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;;;;;;;;;;;;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.4.3",
4
+ "version": "1.5.0",
5
5
  "license": "Apache-2.0",
6
6
  "exports": {
7
7
  ".": {
@@ -175,6 +175,10 @@
175
175
  "types": "./vater/index.d.ts",
176
176
  "default": "./fesm2022/energinet-watt-vater.mjs"
177
177
  },
178
+ "./year-field": {
179
+ "types": "./year-field/index.d.ts",
180
+ "default": "./fesm2022/energinet-watt-year-field.mjs"
181
+ },
178
182
  "./yearmonth-field": {
179
183
  "types": "./yearmonth-field/index.d.ts",
180
184
  "default": "./fesm2022/energinet-watt-yearmonth-field.mjs"
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2020 Energinet DataHub A/S
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License2");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export { WattYearField, YEAR_FORMAT } from './watt-year-field.component';
@@ -0,0 +1,32 @@
1
+ import { FormControl, ControlValueAccessor } from '@angular/forms';
2
+ import * as i0 from "@angular/core";
3
+ export declare const YEAR_FORMAT = "YYYY";
4
+ export declare class WattYearField implements ControlValueAccessor {
5
+ private static instance;
6
+ private instance;
7
+ protected anchorName: string;
8
+ protected control: FormControl<string>;
9
+ private valueChanges;
10
+ private year;
11
+ protected selected: import("@angular/core").Signal<Date | undefined>;
12
+ protected isOpen: import("@angular/core").WritableSignal<boolean>;
13
+ /** Set the label text for `watt-field`. */
14
+ label: import("@angular/core").InputSignal<string>;
15
+ /** The minimum selectable date. */
16
+ min: import("@angular/core").InputSignal<Date | undefined>;
17
+ /** The maximum selectable date. */
18
+ max: import("@angular/core").InputSignal<Date | undefined>;
19
+ /** Emits when the selected year has changed. */
20
+ yearChange: import("@angular/core").OutputRef<string>;
21
+ /** Emits when the field loses focus. */
22
+ blur: import("@angular/core").OutputEmitterRef<FocusEvent>;
23
+ protected handleFocus: (picker: HTMLElement) => void;
24
+ protected handleBlur: (picker: HTMLElement, event: FocusEvent) => void;
25
+ protected handleSelectedChange: (field: HTMLInputElement, date: Date) => void;
26
+ writeValue: (value: string | null) => void;
27
+ setDisabledState: (x: boolean) => void;
28
+ registerOnTouched: (fn: () => void) => import("@angular/core").OutputRefSubscription;
29
+ registerOnChange: (fn: (value: string | null) => void) => import("rxjs").Subscription;
30
+ static ɵfac: i0.ɵɵFactoryDeclaration<WattYearField, never>;
31
+ static ɵcmp: i0.ɵɵComponentDeclaration<WattYearField, "watt-year-field", never, { "label": { "alias": "label"; "required": false; "isSignal": true; }; "min": { "alias": "min"; "required": false; "isSignal": true; }; "max": { "alias": "max"; "required": false; "isSignal": true; }; }, { "yearChange": "yearChange"; "blur": "blur"; }, never, ["*", "watt-field-error", "watt-field-hint"], true, never>;
32
+ }