@energinet/watt 1.6.0 → 1.6.2
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.
- package/fesm2022/energinet-watt-drawer.mjs +18 -1
- package/fesm2022/energinet-watt-drawer.mjs.map +1 -1
- package/fesm2022/energinet-watt-field.mjs +3 -2
- package/fesm2022/energinet-watt-field.mjs.map +1 -1
- package/fesm2022/energinet-watt-text-field.mjs +2 -2
- package/fesm2022/energinet-watt-text-field.mjs.map +1 -1
- package/field/watt-field.component.d.ts +2 -1
- package/package.json +1 -1
|
@@ -148,7 +148,7 @@ class WattDrawerComponent {
|
|
|
148
148
|
cdkTrapFocus = viewChild.required(CdkTrapFocus);
|
|
149
149
|
bypassClickCheck = false;
|
|
150
150
|
writableIsOpen = signal(false);
|
|
151
|
-
// Multiple drawers open at the same time
|
|
151
|
+
// Multiple drawers open at the same time are not allowed. This keeps track of
|
|
152
152
|
// the currently opened drawer and closes it when a new drawer is opened.
|
|
153
153
|
static currentDrawer;
|
|
154
154
|
/** Used to adjust drawer size to best fit the content. */
|
|
@@ -187,6 +187,23 @@ class WattDrawerComponent {
|
|
|
187
187
|
this.topBar()?.nativeElement.animate(APPEAR_ANIMATION_FRAMES, APPEAR_ANIMATION_DELAY);
|
|
188
188
|
});
|
|
189
189
|
});
|
|
190
|
+
// Who doesn't love a good workaround, right?
|
|
191
|
+
// Let's make the drawer resize itself whenever the `size` input changes.
|
|
192
|
+
//
|
|
193
|
+
// The `mat-drawer` component offers the `autosize` input for this.
|
|
194
|
+
// However, it is specifically mentioned that this options should be used at own risk,
|
|
195
|
+
// as it could cause performance issues.
|
|
196
|
+
// See: https://material.angular.dev/components/sidenav/overview#resizing-an-open-sidenav
|
|
197
|
+
//
|
|
198
|
+
// So to work around this, a simple `resize` event is dispatched whenever the `size` input changes.
|
|
199
|
+
// This works because `mat-drawer` uses `ViewportRuler` from `@angular/cdk/scrolling`
|
|
200
|
+
// (see https://github.com/angular/components/blob/19.2.1/src/material/sidenav/drawer.ts#L811-L816)
|
|
201
|
+
// to listen to `resize` events and re-calculates margins applied to the drawer content
|
|
202
|
+
// (see https://github.com/angular/components/blob/20.0.0-rc.2/src/cdk/scrolling/viewport-ruler.ts#L50-L53).
|
|
203
|
+
effect(() => {
|
|
204
|
+
this.size();
|
|
205
|
+
document.dispatchEvent(new Event('resize', { bubbles: true }));
|
|
206
|
+
});
|
|
190
207
|
}
|
|
191
208
|
/** @ignore */
|
|
192
209
|
handleDocumentClick(event) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"energinet-watt-drawer.mjs","sources":["../../../libs/watt/package/drawer/watt-drawer-topbar.component.ts","../../../libs/watt/package/drawer/watt-drawer-actions.component.ts","../../../libs/watt/package/drawer/watt-drawer-content.component.ts","../../../libs/watt/package/drawer/watt-drawer-heading.component.ts","../../../libs/watt/package/drawer/watt-drawer.component.ts","../../../libs/watt/package/drawer/watt-drawer.component.html","../../../libs/watt/package/drawer/index.ts","../../../libs/watt/package/drawer/energinet-watt-drawer.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 { Component } from '@angular/core';\n\n@Component({\n selector: 'watt-drawer-topbar',\n template: `<ng-content />`,\n styleUrls: ['./watt-drawer-topbar.component.scss'],\n})\nexport class WattDrawerTopbarComponent {}\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 { Component } from '@angular/core';\n\n@Component({\n selector: 'watt-drawer-actions',\n styles: `\n :host {\n flex-shrink: 0;\n display: flex;\n justify-content: flex-end;\n align-items: flex-start;\n gap: var(--watt-space-m);\n margin-left: auto;\n margin-right: var(--watt-space-ml);\n }\n `,\n template: `<ng-content select=\"watt-button\" />`,\n})\nexport class WattDrawerActionsComponent {}\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 { Component } from '@angular/core';\n\n@Component({\n selector: 'watt-drawer-content',\n template: `<ng-content />`,\n styles: [\n `\n :host {\n overflow: auto;\n }\n `,\n ],\n})\nexport class WattDrawerContentComponent {}\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 { Component, ViewEncapsulation } from '@angular/core';\n\n@Component({\n selector: 'watt-drawer-heading',\n encapsulation: ViewEncapsulation.None,\n template: `<ng-content />`,\n styles: [\n `\n watt-drawer-heading {\n margin-left: var(--watt-space-ml);\n }\n\n watt-drawer-heading h1,\n watt-drawer-heading h2,\n watt-drawer-heading h3,\n watt-drawer-heading h4,\n watt-drawer-heading h5,\n watt-drawer-heading h6 {\n margin: 0;\n line-height: 48px !important; /* align with actions */\n }\n `,\n ],\n})\nexport class WattDrawerHeadingComponent {}\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 inject,\n input,\n output,\n Component,\n OnDestroy,\n viewChild,\n ElementRef,\n ChangeDetectionStrategy,\n signal,\n untracked,\n booleanAttribute,\n contentChild,\n effect,\n} from '@angular/core';\n\nimport { OverlayContainer } from '@angular/cdk/overlay';\nimport { CdkTrapFocus, A11yModule } from '@angular/cdk/a11y';\nimport { MatSidenavModule } from '@angular/material/sidenav';\n\nimport { WattButtonComponent } from '@energinet/watt/button';\nimport { WattSpinnerComponent } from '@energinet/watt/spinner';\n\nimport { WattDrawerTopbarComponent } from './watt-drawer-topbar.component';\nimport { WattDrawerActionsComponent } from './watt-drawer-actions.component';\nimport { WattDrawerContentComponent } from './watt-drawer-content.component';\nimport { WattDrawerHeadingComponent } from './watt-drawer-heading.component';\n\nexport type WattDrawerSize = 'small' | 'normal' | 'large';\n\nconst APPEAR_ANIMATION_DELAY = 250;\nconst APPEAR_ANIMATION_FRAMES = {\n transform: ['translateX(30px)', 'translateX(0)'],\n opacity: ['0', '1'],\n};\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n selector: 'watt-drawer',\n styleUrls: ['./watt-drawer.component.scss'],\n templateUrl: './watt-drawer.component.html',\n host: {\n '(document:click)': 'handleDocumentClick($event)',\n '(keydown.escape)': 'handleEscKeyPressed()',\n },\n imports: [A11yModule, MatSidenavModule, WattButtonComponent, WattSpinnerComponent],\n})\nexport class WattDrawerComponent implements OnDestroy {\n private elementRef = inject(ElementRef);\n private overlayContainer = inject(OverlayContainer);\n private content = contentChild(WattDrawerContentComponent, { read: ElementRef });\n private heading = contentChild(WattDrawerHeadingComponent, { read: ElementRef });\n private topBar = contentChild(WattDrawerTopbarComponent, { read: ElementRef });\n private cdkTrapFocus = viewChild.required(CdkTrapFocus);\n private bypassClickCheck = false;\n private writableIsOpen = signal(false);\n\n // Multiple drawers open at the same time is not allowed. This keeps track of\n // the currently opened drawer and closes it when a new drawer is opened.\n private static currentDrawer?: WattDrawerComponent;\n\n /** Used to adjust drawer size to best fit the content. */\n size = input<WattDrawerSize>('normal');\n\n /**\n * Whether the drawer should open automatically. If `key` is provided and\n * `autoOpen` is true, the drawer will open every time the key changes.\n */\n autoOpen = input(false, { transform: booleanAttribute });\n\n /**\n * Used to track the current drawer when reusing the same drawer instance to\n * render different content. This is required when interactions outside the\n * drawer should result in updating the drawer's content instead of closing it.\n */\n key = input<unknown>();\n\n /** Whether the drawer should show a loading state. */\n loading = input(false);\n\n /** Adds a brief animation to indicate that the content has changed. */\n animateOnKeyChange = input(false);\n\n /** Emits whenever the drawer is fully closed. */\n closed = output<void>();\n\n /** Whether the drawer is open. */\n isOpen = this.writableIsOpen.asReadonly();\n\n constructor() {\n effect(() => {\n this.key();\n if (this.autoOpen()) this.open();\n if (!this.animateOnKeyChange()) return;\n untracked(() => {\n if (!this.isOpen()) return;\n this.content()?.nativeElement.animate(APPEAR_ANIMATION_FRAMES, APPEAR_ANIMATION_DELAY);\n this.heading()?.nativeElement.animate(APPEAR_ANIMATION_FRAMES, APPEAR_ANIMATION_DELAY);\n this.topBar()?.nativeElement.animate(APPEAR_ANIMATION_FRAMES, APPEAR_ANIMATION_DELAY);\n });\n });\n }\n\n /** @ignore */\n handleDocumentClick(event: MouseEvent) {\n // Prevent closing when the click triggered a call to `open`\n if (this.bypassClickCheck) return;\n\n // Check if the click originated from within the drawer element\n const isClickInside = this.elementRef.nativeElement.contains(event.target);\n if (isClickInside) return;\n\n // Check if the click originated from within an overlay (such as a modal)\n const overlayContainerEl = this.overlayContainer.getContainerElement();\n const isOverlayClick = overlayContainerEl.contains(event.target as Node);\n if (isOverlayClick) return;\n\n // Click is allowed to close the drawer now\n this.close();\n }\n\n /** @ignore */\n handleEscKeyPressed() {\n this.close();\n }\n\n /** @ignore */\n ngOnDestroy(): void {\n if (WattDrawerComponent.currentDrawer === this) {\n WattDrawerComponent.currentDrawer = undefined;\n }\n }\n\n /** Opens the drawer. Subsequent calls are ignored while the drawer is opened. */\n open() {\n // Trap focus whenever open is called. This doesn't work on the\n // initial call (when first opening the drawer), but this is\n // handled by the autoFocus property on mat-drawer.\n this.cdkTrapFocus().focusTrap.focusInitialElementWhenReady();\n\n // Disable click outside check until the current event loop is finished.\n // This might seem hackish, but the order of execution is stable here.\n // Also prevents an issue when the drawer is destroyed and then recreated,\n // causing the click outside check to trigger immediately if the drawer\n // is created and opened in response to a click event.\n this.bypassClickCheck = true;\n setTimeout(() => {\n this.bypassClickCheck = false;\n }, 0);\n\n // Without `untracked`, if this is called in a reactive context (such as an `effect`),\n // it will be triggered twice due to `isOpen` being tracked and immediately updated.\n if (untracked(this.isOpen)) return;\n WattDrawerComponent.currentDrawer?.close();\n WattDrawerComponent.currentDrawer = this;\n this.writableIsOpen.set(true);\n }\n\n /** Closes the drawer. */\n close() {\n if (!untracked(this.isOpen)) return;\n WattDrawerComponent.currentDrawer = undefined;\n this.writableIsOpen.set(false);\n }\n}\n\nexport const WATT_DRAWER = [\n WattDrawerComponent,\n WattDrawerTopbarComponent,\n WattDrawerActionsComponent,\n WattDrawerContentComponent,\n WattDrawerHeadingComponent,\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<mat-drawer-container class=\"watt-drawer-container\" [hasBackdrop]=\"false\">\n <mat-drawer\n class=\"watt-drawer watt-space-inset-s watt-drawer--{{ size() }}\"\n mode=\"side\"\n position=\"end\"\n [opened]=\"isOpen()\"\n (closed)=\"closed.emit()\"\n [disableClose]=\"true\"\n [autoFocus]=\"true\"\n [cdkTrapFocus]=\"true\"\n >\n <div class=\"watt-drawer__grid-container\">\n <header>\n <ng-content select=\"watt-drawer-topbar\" />\n <watt-button class=\"close-btn\" variant=\"icon\" icon=\"close\" (click)=\"close()\" />\n </header>\n\n <article class=\"watt-drawer__content\">\n <div class=\"watt-drawer__actions\">\n <ng-content select=\"watt-drawer-heading\" />\n <ng-content select=\"watt-drawer-actions\" />\n </div>\n <ng-content select=\"watt-drawer-content\" />\n </article>\n </div>\n\n @if (loading()) {\n <div class=\"watt-drawer__spinner\">\n <watt-spinner />\n </div>\n }\n </mat-drawer>\n</mat-drawer-container>\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 { WattDrawerTopbarComponent } from './watt-drawer-topbar.component';\nexport { WattDrawerActionsComponent } from './watt-drawer-actions.component';\nexport { WattDrawerContentComponent } from './watt-drawer-content.component';\nexport { WattDrawerHeadingComponent } from './watt-drawer-heading.component';\nexport { WattDrawerComponent, WATT_DRAWER, WattDrawerSize } from './watt-drawer.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAQa,yBAAyB,CAAA;uGAAzB,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAzB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,yBAAyB,8EAH1B,CAAgB,cAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,iLAAA,CAAA,EAAA,CAAA;;2FAGf,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBALrC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,oBAAoB,YACpB,CAAgB,cAAA,CAAA,EAAA,MAAA,EAAA,CAAA,iLAAA,CAAA,EAAA;;;ACtB5B;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAkBa,0BAA0B,CAAA;uGAA1B,0BAA0B,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAA1B,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,0BAA0B,+EAF3B,CAAqC,mCAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,gKAAA,CAAA,EAAA,CAAA;;2FAEpC,0BAA0B,E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AC5C,EACQ,OAAA,EAAA,CAAC,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,EAAA,QAAA,EAAA,6nDAAA,EAAA,MAAA,EAAA,CAAA,m8BAAA,CAAA,EAAA;;AAyHvE,MAAA,WAAW,GAAG;IACzB,mBAAmB;IACnB,yBAAyB;IACzB,0BAA0B;IAC1B,0BAA0B;IAC1B,0BAA0B;;;AE7L5B;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"energinet-watt-drawer.mjs","sources":["../../../libs/watt/package/drawer/watt-drawer-topbar.component.ts","../../../libs/watt/package/drawer/watt-drawer-actions.component.ts","../../../libs/watt/package/drawer/watt-drawer-content.component.ts","../../../libs/watt/package/drawer/watt-drawer-heading.component.ts","../../../libs/watt/package/drawer/watt-drawer.component.ts","../../../libs/watt/package/drawer/watt-drawer.component.html","../../../libs/watt/package/drawer/index.ts","../../../libs/watt/package/drawer/energinet-watt-drawer.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 { Component } from '@angular/core';\n\n@Component({\n selector: 'watt-drawer-topbar',\n template: `<ng-content />`,\n styleUrls: ['./watt-drawer-topbar.component.scss'],\n})\nexport class WattDrawerTopbarComponent {}\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 { Component } from '@angular/core';\n\n@Component({\n selector: 'watt-drawer-actions',\n styles: `\n :host {\n flex-shrink: 0;\n display: flex;\n justify-content: flex-end;\n align-items: flex-start;\n gap: var(--watt-space-m);\n margin-left: auto;\n margin-right: var(--watt-space-ml);\n }\n `,\n template: `<ng-content select=\"watt-button\" />`,\n})\nexport class WattDrawerActionsComponent {}\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 { Component } from '@angular/core';\n\n@Component({\n selector: 'watt-drawer-content',\n template: `<ng-content />`,\n styles: [\n `\n :host {\n overflow: auto;\n }\n `,\n ],\n})\nexport class WattDrawerContentComponent {}\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 { Component, ViewEncapsulation } from '@angular/core';\n\n@Component({\n selector: 'watt-drawer-heading',\n encapsulation: ViewEncapsulation.None,\n template: `<ng-content />`,\n styles: [\n `\n watt-drawer-heading {\n margin-left: var(--watt-space-ml);\n }\n\n watt-drawer-heading h1,\n watt-drawer-heading h2,\n watt-drawer-heading h3,\n watt-drawer-heading h4,\n watt-drawer-heading h5,\n watt-drawer-heading h6 {\n margin: 0;\n line-height: 48px !important; /* align with actions */\n }\n `,\n ],\n})\nexport class WattDrawerHeadingComponent {}\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 inject,\n input,\n output,\n Component,\n OnDestroy,\n viewChild,\n ElementRef,\n ChangeDetectionStrategy,\n signal,\n untracked,\n booleanAttribute,\n contentChild,\n effect,\n} from '@angular/core';\n\nimport { OverlayContainer } from '@angular/cdk/overlay';\nimport { CdkTrapFocus, A11yModule } from '@angular/cdk/a11y';\nimport { MatSidenavModule } from '@angular/material/sidenav';\n\nimport { WattButtonComponent } from '@energinet/watt/button';\nimport { WattSpinnerComponent } from '@energinet/watt/spinner';\n\nimport { WattDrawerTopbarComponent } from './watt-drawer-topbar.component';\nimport { WattDrawerActionsComponent } from './watt-drawer-actions.component';\nimport { WattDrawerContentComponent } from './watt-drawer-content.component';\nimport { WattDrawerHeadingComponent } from './watt-drawer-heading.component';\n\nexport type WattDrawerSize = 'small' | 'normal' | 'large';\n\nconst APPEAR_ANIMATION_DELAY = 250;\nconst APPEAR_ANIMATION_FRAMES = {\n transform: ['translateX(30px)', 'translateX(0)'],\n opacity: ['0', '1'],\n};\n\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n selector: 'watt-drawer',\n styleUrls: ['./watt-drawer.component.scss'],\n templateUrl: './watt-drawer.component.html',\n host: {\n '(document:click)': 'handleDocumentClick($event)',\n '(keydown.escape)': 'handleEscKeyPressed()',\n },\n imports: [A11yModule, MatSidenavModule, WattButtonComponent, WattSpinnerComponent],\n})\nexport class WattDrawerComponent implements OnDestroy {\n private elementRef = inject(ElementRef);\n private overlayContainer = inject(OverlayContainer);\n private content = contentChild(WattDrawerContentComponent, { read: ElementRef });\n private heading = contentChild(WattDrawerHeadingComponent, { read: ElementRef });\n private topBar = contentChild(WattDrawerTopbarComponent, { read: ElementRef });\n private cdkTrapFocus = viewChild.required(CdkTrapFocus);\n private bypassClickCheck = false;\n private writableIsOpen = signal(false);\n\n // Multiple drawers open at the same time are not allowed. This keeps track of\n // the currently opened drawer and closes it when a new drawer is opened.\n private static currentDrawer?: WattDrawerComponent;\n\n /** Used to adjust drawer size to best fit the content. */\n size = input<WattDrawerSize>('normal');\n\n /**\n * Whether the drawer should open automatically. If `key` is provided and\n * `autoOpen` is true, the drawer will open every time the key changes.\n */\n autoOpen = input(false, { transform: booleanAttribute });\n\n /**\n * Used to track the current drawer when reusing the same drawer instance to\n * render different content. This is required when interactions outside the\n * drawer should result in updating the drawer's content instead of closing it.\n */\n key = input<unknown>();\n\n /** Whether the drawer should show a loading state. */\n loading = input(false);\n\n /** Adds a brief animation to indicate that the content has changed. */\n animateOnKeyChange = input(false);\n\n /** Emits whenever the drawer is fully closed. */\n closed = output<void>();\n\n /** Whether the drawer is open. */\n isOpen = this.writableIsOpen.asReadonly();\n\n constructor() {\n effect(() => {\n this.key();\n if (this.autoOpen()) this.open();\n if (!this.animateOnKeyChange()) return;\n untracked(() => {\n if (!this.isOpen()) return;\n this.content()?.nativeElement.animate(APPEAR_ANIMATION_FRAMES, APPEAR_ANIMATION_DELAY);\n this.heading()?.nativeElement.animate(APPEAR_ANIMATION_FRAMES, APPEAR_ANIMATION_DELAY);\n this.topBar()?.nativeElement.animate(APPEAR_ANIMATION_FRAMES, APPEAR_ANIMATION_DELAY);\n });\n });\n\n // Who doesn't love a good workaround, right?\n // Let's make the drawer resize itself whenever the `size` input changes.\n //\n // The `mat-drawer` component offers the `autosize` input for this.\n // However, it is specifically mentioned that this options should be used at own risk,\n // as it could cause performance issues.\n // See: https://material.angular.dev/components/sidenav/overview#resizing-an-open-sidenav\n //\n // So to work around this, a simple `resize` event is dispatched whenever the `size` input changes.\n // This works because `mat-drawer` uses `ViewportRuler` from `@angular/cdk/scrolling`\n // (see https://github.com/angular/components/blob/19.2.1/src/material/sidenav/drawer.ts#L811-L816)\n // to listen to `resize` events and re-calculates margins applied to the drawer content\n // (see https://github.com/angular/components/blob/20.0.0-rc.2/src/cdk/scrolling/viewport-ruler.ts#L50-L53).\n effect(() => {\n this.size();\n\n document.dispatchEvent(new Event('resize', { bubbles: true }));\n });\n }\n\n /** @ignore */\n handleDocumentClick(event: MouseEvent) {\n // Prevent closing when the click triggered a call to `open`\n if (this.bypassClickCheck) return;\n\n // Check if the click originated from within the drawer element\n const isClickInside = this.elementRef.nativeElement.contains(event.target);\n if (isClickInside) return;\n\n // Check if the click originated from within an overlay (such as a modal)\n const overlayContainerEl = this.overlayContainer.getContainerElement();\n const isOverlayClick = overlayContainerEl.contains(event.target as Node);\n if (isOverlayClick) return;\n\n // Click is allowed to close the drawer now\n this.close();\n }\n\n /** @ignore */\n handleEscKeyPressed() {\n this.close();\n }\n\n /** @ignore */\n ngOnDestroy(): void {\n if (WattDrawerComponent.currentDrawer === this) {\n WattDrawerComponent.currentDrawer = undefined;\n }\n }\n\n /** Opens the drawer. Subsequent calls are ignored while the drawer is opened. */\n open() {\n // Trap focus whenever open is called. This doesn't work on the\n // initial call (when first opening the drawer), but this is\n // handled by the autoFocus property on mat-drawer.\n this.cdkTrapFocus().focusTrap.focusInitialElementWhenReady();\n\n // Disable click outside check until the current event loop is finished.\n // This might seem hackish, but the order of execution is stable here.\n // Also prevents an issue when the drawer is destroyed and then recreated,\n // causing the click outside check to trigger immediately if the drawer\n // is created and opened in response to a click event.\n this.bypassClickCheck = true;\n setTimeout(() => {\n this.bypassClickCheck = false;\n }, 0);\n\n // Without `untracked`, if this is called in a reactive context (such as an `effect`),\n // it will be triggered twice due to `isOpen` being tracked and immediately updated.\n if (untracked(this.isOpen)) return;\n WattDrawerComponent.currentDrawer?.close();\n WattDrawerComponent.currentDrawer = this;\n this.writableIsOpen.set(true);\n }\n\n /** Closes the drawer. */\n close() {\n if (!untracked(this.isOpen)) return;\n WattDrawerComponent.currentDrawer = undefined;\n this.writableIsOpen.set(false);\n }\n}\n\nexport const WATT_DRAWER = [\n WattDrawerComponent,\n WattDrawerTopbarComponent,\n WattDrawerActionsComponent,\n WattDrawerContentComponent,\n WattDrawerHeadingComponent,\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<mat-drawer-container class=\"watt-drawer-container\" [hasBackdrop]=\"false\">\n <mat-drawer\n class=\"watt-drawer watt-space-inset-s watt-drawer--{{ size() }}\"\n mode=\"side\"\n position=\"end\"\n [opened]=\"isOpen()\"\n (closed)=\"closed.emit()\"\n [disableClose]=\"true\"\n [autoFocus]=\"true\"\n [cdkTrapFocus]=\"true\"\n >\n <div class=\"watt-drawer__grid-container\">\n <header>\n <ng-content select=\"watt-drawer-topbar\" />\n <watt-button class=\"close-btn\" variant=\"icon\" icon=\"close\" (click)=\"close()\" />\n </header>\n\n <article class=\"watt-drawer__content\">\n <div class=\"watt-drawer__actions\">\n <ng-content select=\"watt-drawer-heading\" />\n <ng-content select=\"watt-drawer-actions\" />\n </div>\n <ng-content select=\"watt-drawer-content\" />\n </article>\n </div>\n\n @if (loading()) {\n <div class=\"watt-drawer__spinner\">\n <watt-spinner />\n </div>\n }\n </mat-drawer>\n</mat-drawer-container>\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 { WattDrawerTopbarComponent } from './watt-drawer-topbar.component';\nexport { WattDrawerActionsComponent } from './watt-drawer-actions.component';\nexport { WattDrawerContentComponent } from './watt-drawer-content.component';\nexport { WattDrawerHeadingComponent } from './watt-drawer-heading.component';\nexport { WattDrawerComponent, WATT_DRAWER, WattDrawerSize } from './watt-drawer.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAQa,yBAAyB,CAAA;uGAAzB,yBAAyB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAzB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,yBAAyB,8EAH1B,CAAgB,cAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,iLAAA,CAAA,EAAA,CAAA;;2FAGf,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBALrC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,oBAAoB,YACpB,CAAgB,cAAA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A,QAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAE,mBAAmB,EAAA,QAAA,EAAA,aAAA,EAAA,MAAA,EAAA,CAAA,MAAA,EAAA,SAAA,EAAA,MAAA,EAAA,QAAA,EAAA,UAAA,EAAA,SAAA,CAAA,EAAA,EAAA,EAAA,IAAA,EAAA,WAAA,EAAA,IAAA,EAAE,oBAAoB,EAAA,QAAA,EAAA,cAAA,EAAA,MAAA,EAAA,CAAA,UAAA,EAAA,aAAA,CAAA,EAAA,CAAA,EAAA,eAAA,EAAA,EAAA,CAAA,uBAAA,CAAA,MAAA,EAAA,CAAA;;2FAEtE,mBAAmB,EAAA,UAAA,EAAA,CAAA;kBAX/B,SAAS;AACS,YAAA,IAAA,EAAA,CAAA,EAAA,eAAA,EAAA,uBAAuB,CAAC,MAAM,EACrC,QAAA,EAAA,aAAa,EAGjB,IAAA,EAAA;AACJ,wBAAA,kBAAkB,EAAE,6BAA6B;AACjD,wBAAA,kBAAkB,EAAE,uBAAuB;qBAC5C,EACQ,OAAA,EAAA,CAAC,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,oBAAoB,CAAC,EAAA,QAAA,EAAA,6nDAAA,EAAA,MAAA,EAAA,CAAA,m8BAAA,CAAA,EAAA;;AA4IvE,MAAA,WAAW,GAAG;IACzB,mBAAmB;IACnB,yBAAyB;IACzB,0BAA0B;IAC1B,0BAA0B;IAC1B,0BAA0B;;;AEhN5B;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, ViewEncapsulation, Component, inject, input, signal, computed, viewChild, ChangeDetectionStrategy } from '@angular/core';
|
|
2
|
+
import { Injectable, ViewEncapsulation, Component, inject, ElementRef, input, signal, computed, viewChild, ChangeDetectionStrategy } from '@angular/core';
|
|
3
3
|
import { Validators } from '@angular/forms';
|
|
4
4
|
import { filter, switchMap, startWith, map, tap } from 'rxjs/operators';
|
|
5
5
|
import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
@@ -86,6 +86,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
|
|
|
86
86
|
//#endregion
|
|
87
87
|
class WattFieldComponent {
|
|
88
88
|
intl = inject(WattFieldIntlService);
|
|
89
|
+
elementRef = inject(ElementRef);
|
|
89
90
|
control = input(null);
|
|
90
91
|
label = input();
|
|
91
92
|
id = input();
|
|
@@ -101,7 +102,7 @@ class WattFieldComponent {
|
|
|
101
102
|
isRequired = signal(false);
|
|
102
103
|
isEmpty = computed(() => this.errors()?.['required'] || this.errors()?.['rangeRequired']);
|
|
103
104
|
// Used for text fields with autocomplete
|
|
104
|
-
wrapper = viewChild
|
|
105
|
+
wrapper = viewChild('wrapper');
|
|
105
106
|
constructor() {
|
|
106
107
|
const control$ = toObservable(this.control).pipe(filter((control) => control !== null));
|
|
107
108
|
// Track value in order to update ghost and filler
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"energinet-watt-field.mjs","sources":["../../../libs/watt/package/field/watt-field-intl.service.ts","../../../libs/watt/package/field/watt-field-error.component.ts","../../../libs/watt/package/field/watt-field.component.ts","../../../libs/watt/package/field/watt-field-hint.component.ts","../../../libs/watt/package/field/index.ts","../../../libs/watt/package/field/energinet-watt-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 { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class WattFieldIntlService {\n readonly changes: Subject<void> = new Subject<void>();\n required = 'Field is required';\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 { Component, ViewEncapsulation } from '@angular/core';\n\n@Component({\n selector: 'watt-field-error',\n template: `<ng-content />`,\n encapsulation: ViewEncapsulation.None,\n styles: [\n `\n watt-field-error {\n color: var(--watt-color-state-danger);\n }\n `,\n ],\n})\nexport class WattFieldErrorComponent {}\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 ElementRef,\n ViewEncapsulation,\n computed,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core';\nimport { FormControl, ValidationErrors, Validators } from '@angular/forms';\nimport { filter, map, startWith, switchMap, tap } from 'rxjs/operators';\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';\n\nimport { WattIconComponent } from '@energinet/watt/icon';\nimport { WattTooltipDirective } from '@energinet/watt/tooltip';\nimport { VaterStackComponent } from '@energinet/watt/vater';\nimport { WattRangeValidators } from '@energinet/watt/validators';\n\nimport { WattFieldIntlService } from './watt-field-intl.service';\nimport { WattFieldErrorComponent } from './watt-field-error.component';\nimport { NgTemplateOutlet } from '@angular/common';\n\n@Component({\n selector: 'watt-field',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [\n NgTemplateOutlet,\n WattIconComponent,\n WattTooltipDirective,\n WattFieldErrorComponent,\n VaterStackComponent,\n ],\n styleUrls: ['./watt-field.component.scss'],\n template: `\n @if (chipMode()) {\n <span class=\"watt-label\">\n <ng-container *ngTemplateOutlet=\"template\" />\n </span>\n } @else {\n <label [attr.for]=\"id()\">\n <ng-container *ngTemplateOutlet=\"template\" />\n </label>\n }\n\n <ng-template #template>\n @if (label()) {\n <span class=\"label\" [class.required]=\"isRequired()\">\n {{ label() }}\n @if (tooltip(); as tooltip) {\n <watt-icon name=\"info\" wattTooltipPosition=\"top\" [wattTooltip]=\"tooltip\" />\n }\n </span>\n }\n <vater-stack direction=\"row\" gap=\"s\">\n <div\n #wrapper\n class=\"watt-field-wrapper\"\n [class.watt-field--has-placeholder]=\"!!placeholder()\"\n [style.anchor-name]=\"anchorName()\"\n >\n @if (placeholder()) {\n <div class=\"watt-field-placeholder\" aria-hidden=\"true\">\n <span class=\"watt-field-ghost\">{{ ghost() }}</span>\n <span class=\"watt-field-filler\">{{ filler() }}</span>\n </div>\n }\n <ng-content />\n </div>\n <ng-content select=\"watt-field-descriptor\" />\n </vater-stack>\n <ng-content select=\"[popover]\" />\n <ng-content select=\"watt-field-hint\" />\n <ng-content select=\"watt-field-error\" />\n @if (isEmpty()) {\n <watt-field-error>{{ intl.required }}</watt-field-error>\n }\n </ng-template>\n `,\n host: {\n '[class.watt-field--chip]': 'chipMode()',\n '[class.watt-field--unlabelled]': 'unlabelled()',\n '[class.watt-field--disabled]': 'control()?.disabled',\n },\n})\nexport class WattFieldComponent {\n intl = inject(WattFieldIntlService);\n\n control = input<FormControl | null>(null);\n label = input<string>();\n id = input<string>();\n chipMode = input(false);\n tooltip = input<string>();\n placeholder = input('');\n anchorName = input<string>();\n\n value = signal('');\n filler = computed(() => this.placeholder().slice(this.value().length));\n ghost = computed(() => this.value().slice(0, this.placeholder().length));\n\n unlabelled = computed(() => !this.label());\n\n errors = signal<ValidationErrors | null>(null);\n isRequired = signal(false);\n isEmpty = computed(() => this.errors()?.['required'] || this.errors()?.['rangeRequired']);\n\n // Used for text fields with autocomplete\n wrapper = viewChild.required<ElementRef>('wrapper');\n\n constructor() {\n const control$ = toObservable(this.control).pipe(filter((control) => control !== null));\n\n // Track value in order to update ghost and filler\n const value$ = control$.pipe(\n switchMap((control) =>\n control.valueChanges.pipe(\n startWith(control.value),\n map((value) => (value === null || value === undefined ? '' : value.toString())),\n tap((value) => this.value.set(value))\n )\n ),\n takeUntilDestroyed()\n );\n\n // Track status in order to update required state and show errors\n const status$ = control$.pipe(\n switchMap((control) =>\n control.statusChanges.pipe(\n startWith(control.status),\n tap(() => this.isRequired.set(this.isRequiredControl(control))),\n tap(() => this.errors.set(control.errors))\n )\n ),\n takeUntilDestroyed()\n );\n\n // Subscribe for side effects\n value$.subscribe();\n status$.subscribe();\n }\n\n isRequiredControl(control: FormControl) {\n const validators = [Validators.required, WattRangeValidators.required];\n return validators.some((validator) => control.hasValidator(validator));\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\nimport { Component } from '@angular/core';\n\n@Component({\n selector: 'watt-field-hint',\n styles: [\n `\n :host {\n color: var(--watt-color-neutral-grey-700);\n }\n `,\n ],\n template: `<ng-content />`,\n})\nexport class WattFieldHintComponent {}\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 { WattFieldComponent } from './watt-field.component';\nexport { WattFieldErrorComponent } from './watt-field-error.component';\nexport { WattFieldHintComponent } from './watt-field-hint.component';\nexport { WattFieldIntlService } from './watt-field-intl.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAKa,oBAAoB,CAAA;AACtB,IAAA,OAAO,GAAkB,IAAI,OAAO,EAAQ;IACrD,QAAQ,GAAG,mBAAmB;uGAFnB,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAApB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,cADP,MAAM,EAAA,CAAA;;2FACnB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACrBlC;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAea,uBAAuB,CAAA;uGAAvB,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,C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,2EAFvB,CAAgB,cAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,mDAAA,CAAA,EAAA,CAAA;;2FAEf,sBAAsB,EAAA,UAAA,EAAA,CAAA;kBAXlC,SAAS;AACE,YAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,iBAAiB,YAQjB,CAAgB,cAAA,CAAA,EAAA,MAAA,EAAA,CAAA,mDAAA,CAAA,EAAA;;;AC7B5B;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"energinet-watt-field.mjs","sources":["../../../libs/watt/package/field/watt-field-intl.service.ts","../../../libs/watt/package/field/watt-field-error.component.ts","../../../libs/watt/package/field/watt-field.component.ts","../../../libs/watt/package/field/watt-field-hint.component.ts","../../../libs/watt/package/field/index.ts","../../../libs/watt/package/field/energinet-watt-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 { Injectable } from '@angular/core';\nimport { Subject } from 'rxjs';\n\n@Injectable({ providedIn: 'root' })\nexport class WattFieldIntlService {\n readonly changes: Subject<void> = new Subject<void>();\n required = 'Field is required';\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 { Component, ViewEncapsulation } from '@angular/core';\n\n@Component({\n selector: 'watt-field-error',\n template: `<ng-content />`,\n encapsulation: ViewEncapsulation.None,\n styles: [\n `\n watt-field-error {\n color: var(--watt-color-state-danger);\n }\n `,\n ],\n})\nexport class WattFieldErrorComponent {}\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 ElementRef,\n ViewEncapsulation,\n computed,\n inject,\n input,\n signal,\n viewChild,\n} from '@angular/core';\nimport { FormControl, ValidationErrors, Validators } from '@angular/forms';\nimport { filter, map, startWith, switchMap, tap } from 'rxjs/operators';\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop';\n\nimport { WattIconComponent } from '@energinet/watt/icon';\nimport { WattTooltipDirective } from '@energinet/watt/tooltip';\nimport { VaterStackComponent } from '@energinet/watt/vater';\nimport { WattRangeValidators } from '@energinet/watt/validators';\n\nimport { WattFieldIntlService } from './watt-field-intl.service';\nimport { WattFieldErrorComponent } from './watt-field-error.component';\nimport { NgTemplateOutlet } from '@angular/common';\n\n@Component({\n selector: 'watt-field',\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n imports: [\n NgTemplateOutlet,\n WattIconComponent,\n WattTooltipDirective,\n WattFieldErrorComponent,\n VaterStackComponent,\n ],\n styleUrls: ['./watt-field.component.scss'],\n template: `\n @if (chipMode()) {\n <span class=\"watt-label\">\n <ng-container *ngTemplateOutlet=\"template\" />\n </span>\n } @else {\n <label [attr.for]=\"id()\">\n <ng-container *ngTemplateOutlet=\"template\" />\n </label>\n }\n\n <ng-template #template>\n @if (label()) {\n <span class=\"label\" [class.required]=\"isRequired()\">\n {{ label() }}\n @if (tooltip(); as tooltip) {\n <watt-icon name=\"info\" wattTooltipPosition=\"top\" [wattTooltip]=\"tooltip\" />\n }\n </span>\n }\n <vater-stack direction=\"row\" gap=\"s\">\n <div\n #wrapper\n class=\"watt-field-wrapper\"\n [class.watt-field--has-placeholder]=\"!!placeholder()\"\n [style.anchor-name]=\"anchorName()\"\n >\n @if (placeholder()) {\n <div class=\"watt-field-placeholder\" aria-hidden=\"true\">\n <span class=\"watt-field-ghost\">{{ ghost() }}</span>\n <span class=\"watt-field-filler\">{{ filler() }}</span>\n </div>\n }\n <ng-content />\n </div>\n <ng-content select=\"watt-field-descriptor\" />\n </vater-stack>\n <ng-content select=\"[popover]\" />\n <ng-content select=\"watt-field-hint\" />\n <ng-content select=\"watt-field-error\" />\n @if (isEmpty()) {\n <watt-field-error>{{ intl.required }}</watt-field-error>\n }\n </ng-template>\n `,\n host: {\n '[class.watt-field--chip]': 'chipMode()',\n '[class.watt-field--unlabelled]': 'unlabelled()',\n '[class.watt-field--disabled]': 'control()?.disabled',\n },\n})\nexport class WattFieldComponent {\n intl = inject(WattFieldIntlService);\n elementRef = inject<ElementRef>(ElementRef);\n\n control = input<FormControl | null>(null);\n label = input<string>();\n id = input<string>();\n chipMode = input(false);\n tooltip = input<string>();\n placeholder = input('');\n anchorName = input<string>();\n\n value = signal('');\n filler = computed(() => this.placeholder().slice(this.value().length));\n ghost = computed(() => this.value().slice(0, this.placeholder().length));\n\n unlabelled = computed(() => !this.label());\n\n errors = signal<ValidationErrors | null>(null);\n isRequired = signal(false);\n isEmpty = computed(() => this.errors()?.['required'] || this.errors()?.['rangeRequired']);\n\n // Used for text fields with autocomplete\n wrapper = viewChild<ElementRef>('wrapper');\n\n constructor() {\n const control$ = toObservable(this.control).pipe(filter((control) => control !== null));\n\n // Track value in order to update ghost and filler\n const value$ = control$.pipe(\n switchMap((control) =>\n control.valueChanges.pipe(\n startWith(control.value),\n map((value) => (value === null || value === undefined ? '' : value.toString())),\n tap((value) => this.value.set(value))\n )\n ),\n takeUntilDestroyed()\n );\n\n // Track status in order to update required state and show errors\n const status$ = control$.pipe(\n switchMap((control) =>\n control.statusChanges.pipe(\n startWith(control.status),\n tap(() => this.isRequired.set(this.isRequiredControl(control))),\n tap(() => this.errors.set(control.errors))\n )\n ),\n takeUntilDestroyed()\n );\n\n // Subscribe for side effects\n value$.subscribe();\n status$.subscribe();\n }\n\n isRequiredControl(control: FormControl) {\n const validators = [Validators.required, WattRangeValidators.required];\n return validators.some((validator) => control.hasValidator(validator));\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\nimport { Component } from '@angular/core';\n\n@Component({\n selector: 'watt-field-hint',\n styles: [\n `\n :host {\n color: var(--watt-color-neutral-grey-700);\n }\n `,\n ],\n template: `<ng-content />`,\n})\nexport class WattFieldHintComponent {}\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 { WattFieldComponent } from './watt-field.component';\nexport { WattFieldErrorComponent } from './watt-field-error.component';\nexport { WattFieldHintComponent } from './watt-field-hint.component';\nexport { WattFieldIntlService } from './watt-field-intl.service';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAKa,oBAAoB,CAAA;AACtB,IAAA,OAAO,GAAkB,IAAI,OAAO,EAAQ;IACrD,QAAQ,GAAG,mBAAmB;uGAFnB,oBAAoB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAApB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,oBAAoB,cADP,MAAM,EAAA,CAAA;;2FACnB,oBAAoB,EAAA,UAAA,EAAA,CAAA;kBADhC,UAAU;mBAAC,EAAE,UAAU,EAAE,MAAM,EAAE;;;ACrBlC;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAea,uBAAuB,CAAA;uGAAvB,uBAAuB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,SAAA,EAAA,CAAA;AAAvB,IAAA,OAAA,IAAA,GAAA,EAAA,CAAA,oBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,IAAA,EAAA,uBAAuB,4EAVxB,CAAgB,cAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,MAAA,EAAA,CAAA,0DAAA,CAAA,EAAA,aAAA,EAAA,EAAA,CAAA,iBAAA,CAAA,IAAA,EAAA,CAAA;;2FAUf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B5B;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
|
@@ -165,7 +165,7 @@ class WattTextFieldComponent {
|
|
|
165
165
|
(input)="onChanged($event)"
|
|
166
166
|
[maxlength]="maxLength"
|
|
167
167
|
[matAutocomplete]="auto"
|
|
168
|
-
[matAutocompleteConnectedTo]="{ elementRef: wattField.wrapper() }"
|
|
168
|
+
[matAutocompleteConnectedTo]="{ elementRef: wattField.wrapper() ?? wattField.elementRef }"
|
|
169
169
|
#inputField
|
|
170
170
|
/>
|
|
171
171
|
|
|
@@ -230,7 +230,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImpor
|
|
|
230
230
|
(input)="onChanged($event)"
|
|
231
231
|
[maxlength]="maxLength"
|
|
232
232
|
[matAutocomplete]="auto"
|
|
233
|
-
[matAutocompleteConnectedTo]="{ elementRef: wattField.wrapper() }"
|
|
233
|
+
[matAutocompleteConnectedTo]="{ elementRef: wattField.wrapper() ?? wattField.elementRef }"
|
|
234
234
|
#inputField
|
|
235
235
|
/>
|
|
236
236
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"energinet-watt-text-field.mjs","sources":["../../../libs/watt/package/text-field/watt-text-field.component.ts","../../../libs/watt/package/text-field/index.ts","../../../libs/watt/package/text-field/energinet-watt-text-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 Component,\n Input,\n ViewEncapsulation,\n HostBinding,\n ElementRef,\n ViewChild,\n forwardRef,\n AfterViewInit,\n inject,\n EventEmitter,\n Output,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormControl,\n NG_VALUE_ACCESSOR,\n ReactiveFormsModule,\n} from '@angular/forms';\nimport { MatAutocomplete, MatAutocompleteModule } from '@angular/material/autocomplete';\n\nimport { WattFieldComponent } from '@energinet/watt/field';\nimport { WattIconComponent, WattIcon } from '@energinet/watt/icon';\n\nexport type WattInputTypes = 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';\n\n@Component({\n imports: [MatAutocompleteModule, ReactiveFormsModule, WattFieldComponent, WattIconComponent],\n selector: 'watt-text-field',\n styleUrls: ['./watt-text-field.component.scss'],\n encapsulation: ViewEncapsulation.None,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => WattTextFieldComponent),\n multi: true,\n },\n ],\n template: `<watt-field\n #wattField\n [control]=\"formControl\"\n [label]=\"label\"\n [tooltip]=\"tooltip\"\n matAutocompleteOrigin\n >\n @if (prefix) {\n <watt-icon [name]=\"prefix\" />\n }\n\n @if (!autocompleteOptions) {\n <input\n [attr.aria-label]=\"label\"\n [attr.type]=\"type\"\n [attr.placeholder]=\"placeholder\"\n [value]=\"value\"\n [formControl]=\"formControl\"\n (blur)=\"onTouched()\"\n (input)=\"onChanged($event)\"\n [maxlength]=\"maxLength\"\n #inputField\n />\n } @else {\n <input\n [attr.aria-label]=\"label\"\n [attr.type]=\"type\"\n [attr.placeholder]=\"placeholder\"\n [value]=\"value\"\n [formControl]=\"formControl\"\n (blur)=\"onTouched()\"\n (input)=\"onChanged($event)\"\n [maxlength]=\"maxLength\"\n [matAutocomplete]=\"auto\"\n [matAutocompleteConnectedTo]=\"{ elementRef: wattField.wrapper() }\"\n #inputField\n />\n\n <mat-autocomplete\n #auto=\"matAutocomplete\"\n class=\"watt-autocomplete-panel\"\n (optionSelected)=\"autocompleteOptionSelected.emit($event.option.value)\"\n >\n @for (option of autocompleteOptions; track option) {\n <mat-option [value]=\"option\">\n {{ option }}\n </mat-option>\n }\n </mat-autocomplete>\n }\n\n <ng-content />\n <ng-content ngProjectAs=\"watt-field-descriptor\" select=\".descriptor\" />\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})\nexport class WattTextFieldComponent implements ControlValueAccessor, AfterViewInit {\n @Input() value!: string;\n @Input() type: WattInputTypes = 'text';\n @Input() placeholder?: string;\n @Input() label = '';\n @Input() tooltip?: string;\n @Input() prefix?: WattIcon;\n @Input() maxLength: string | number | null = null;\n @Input() formControl!: FormControl;\n @Input() autocompleteOptions!: string[];\n @Input() autocompleteMatcherFn!: (value: string, option: string) => boolean;\n\n /** @ignore */\n @ViewChild(MatAutocomplete) autocompleteRef!: MatAutocomplete;\n\n /**\n * Emits the value of the input field when it changes.\n */\n @Output() searchChanged = new EventEmitter<string>();\n\n /**\n * Emits the value of the input field when an autocomplete option is selected.\n */\n @Output() autocompleteOptionSelected = new EventEmitter<string>();\n\n /**\n * Emits the value of the input field when an autocomplete option is selected.\n */\n @Output() autocompleteOptionDeselected = new EventEmitter<void>();\n\n /** @ignore */\n private element = inject(ElementRef);\n\n /** @ignore */\n @ViewChild('inputField') inputField!: ElementRef<HTMLInputElement>;\n model!: string;\n\n /** @ignore */\n @HostBinding('attr.watt-field-disabled')\n isDisabled = false;\n\n /** @ignore */\n onTouchedCallbacks: (() => void)[] = [];\n\n /** @ignore */\n ngAfterViewInit(): void {\n const attrName = 'data-testid';\n const testIdAttribute = this.element.nativeElement.getAttribute(attrName);\n this.element.nativeElement.removeAttribute(attrName);\n this.inputField.nativeElement.setAttribute(attrName, testIdAttribute);\n this.registerOnTouched(() => {\n const trimmedValue = this.inputField.nativeElement.value.trim();\n this.inputField.nativeElement.value = trimmedValue;\n this.formControl.setValue(trimmedValue);\n });\n }\n\n /** @ignore */\n onChanged(event: Event): void {\n const value = (event.target as HTMLInputElement).value;\n\n if (this.autocompleteRef) {\n // Reset the autocomplete selection if the value is not matching anymore, and auto-select if the value has a match\n this.autocompleteRef.options.forEach((option) => {\n const isMatchingOption = this.autocompleteMatcherFn\n ? this.autocompleteMatcherFn(value, option.value)\n : option.value === value;\n\n if (isMatchingOption) {\n option.select(false);\n this.autocompleteOptionSelected.emit(option.value);\n } else {\n option.deselect(false);\n this.autocompleteOptionDeselected.emit();\n }\n });\n }\n\n this.searchChanged.emit(value);\n this.onChange(value);\n }\n\n /** @ignore */\n onChange: (value: string) => void = () => {\n /* noop function */\n };\n\n /** @ignore */\n onTouched: () => void = () => {\n for (const callback of this.onTouchedCallbacks) {\n callback();\n }\n };\n\n /** @ignore */\n writeValue(value: string): void {\n this.model = value;\n }\n\n /** @ignore */\n registerOnChange(fn: (value: string) => void): void {\n this.onChange = fn;\n }\n\n /** @ignore */\n registerOnTouched(fn: () => void): void {\n this.onTouchedCallbacks.push(fn);\n }\n\n /** @ignore */\n setDisabledState(isDisabled: boolean): void {\n this.isDisabled = isDisabled;\n }\n\n /** @ignore */\n setFocus(): void {\n this.inputField.nativeElement.focus();\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 { WattTextFieldComponent } from './watt-text-field.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAgGa,sBAAsB,CAAA;AACxB,IAAA,KAAK;IACL,IAAI,GAAmB,MAAM;AAC7B,IAAA,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;;;;;;AAuDI,eAAA,CAAA,EAAA,MAAA,EAAA,CAAA,+MAAA,CAAA,EAAA;8BAGL,KAAK,EAAA,CAAA;sBAAb;gBACQ,IAAI,EAAA,CAAA;sBAAZ;gBACQ,WAAW,EAAA,CAAA;sBAAnB;gBACQ,KAAK,EAAA,CAAA;sBAAb;gBACQ,OAAO,EAAA,CAAA;sBAAf;gBACQ,MAAM,EAAA,CAAA;sBAAd;gBACQ,SAAS,EAAA,CAAA;sBAAjB;gBACQ,WAAW,EAAA,CAAA;sBAAnB;gBACQ,mBAAmB,EAAA,CAAA;sBAA3B;gBACQ,qBAAqB,EAAA,CAAA;sBAA7B;gBAG2B,eAAe,EAAA,CAAA;sBAA1C,SAAS;uBAAC,eAAe;gBAKhB,aAAa,EAAA,CAAA;sBAAtB;gBAKS,0BAA0B,EAAA,CAAA;sBAAnC;gBAKS,4BAA4B,EAAA,CAAA;sBAArC;gBAMwB,UAAU,EAAA,CAAA;sBAAlC,SAAS;uBAAC,YAAY;gBAKvB,UAAU,EAAA,CAAA;sBADT,WAAW;uBAAC,0BAA0B;;;ACvJzC;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"energinet-watt-text-field.mjs","sources":["../../../libs/watt/package/text-field/watt-text-field.component.ts","../../../libs/watt/package/text-field/index.ts","../../../libs/watt/package/text-field/energinet-watt-text-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 Component,\n Input,\n ViewEncapsulation,\n HostBinding,\n ElementRef,\n ViewChild,\n forwardRef,\n AfterViewInit,\n inject,\n EventEmitter,\n Output,\n} from '@angular/core';\nimport {\n ControlValueAccessor,\n FormControl,\n NG_VALUE_ACCESSOR,\n ReactiveFormsModule,\n} from '@angular/forms';\nimport { MatAutocomplete, MatAutocompleteModule } from '@angular/material/autocomplete';\n\nimport { WattFieldComponent } from '@energinet/watt/field';\nimport { WattIconComponent, WattIcon } from '@energinet/watt/icon';\n\nexport type WattInputTypes = 'text' | 'password' | 'email' | 'number' | 'tel' | 'url';\n\n@Component({\n imports: [MatAutocompleteModule, ReactiveFormsModule, WattFieldComponent, WattIconComponent],\n selector: 'watt-text-field',\n styleUrls: ['./watt-text-field.component.scss'],\n encapsulation: ViewEncapsulation.None,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => WattTextFieldComponent),\n multi: true,\n },\n ],\n template: `<watt-field\n #wattField\n [control]=\"formControl\"\n [label]=\"label\"\n [tooltip]=\"tooltip\"\n matAutocompleteOrigin\n >\n @if (prefix) {\n <watt-icon [name]=\"prefix\" />\n }\n\n @if (!autocompleteOptions) {\n <input\n [attr.aria-label]=\"label\"\n [attr.type]=\"type\"\n [attr.placeholder]=\"placeholder\"\n [value]=\"value\"\n [formControl]=\"formControl\"\n (blur)=\"onTouched()\"\n (input)=\"onChanged($event)\"\n [maxlength]=\"maxLength\"\n #inputField\n />\n } @else {\n <input\n [attr.aria-label]=\"label\"\n [attr.type]=\"type\"\n [attr.placeholder]=\"placeholder\"\n [value]=\"value\"\n [formControl]=\"formControl\"\n (blur)=\"onTouched()\"\n (input)=\"onChanged($event)\"\n [maxlength]=\"maxLength\"\n [matAutocomplete]=\"auto\"\n [matAutocompleteConnectedTo]=\"{ elementRef: wattField.wrapper() ?? wattField.elementRef }\"\n #inputField\n />\n\n <mat-autocomplete\n #auto=\"matAutocomplete\"\n class=\"watt-autocomplete-panel\"\n (optionSelected)=\"autocompleteOptionSelected.emit($event.option.value)\"\n >\n @for (option of autocompleteOptions; track option) {\n <mat-option [value]=\"option\">\n {{ option }}\n </mat-option>\n }\n </mat-autocomplete>\n }\n\n <ng-content />\n <ng-content ngProjectAs=\"watt-field-descriptor\" select=\".descriptor\" />\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})\nexport class WattTextFieldComponent implements ControlValueAccessor, AfterViewInit {\n @Input() value!: string;\n @Input() type: WattInputTypes = 'text';\n @Input() placeholder?: string;\n @Input() label = '';\n @Input() tooltip?: string;\n @Input() prefix?: WattIcon;\n @Input() maxLength: string | number | null = null;\n @Input() formControl!: FormControl;\n @Input() autocompleteOptions!: string[];\n @Input() autocompleteMatcherFn!: (value: string, option: string) => boolean;\n\n /** @ignore */\n @ViewChild(MatAutocomplete) autocompleteRef!: MatAutocomplete;\n\n /**\n * Emits the value of the input field when it changes.\n */\n @Output() searchChanged = new EventEmitter<string>();\n\n /**\n * Emits the value of the input field when an autocomplete option is selected.\n */\n @Output() autocompleteOptionSelected = new EventEmitter<string>();\n\n /**\n * Emits the value of the input field when an autocomplete option is selected.\n */\n @Output() autocompleteOptionDeselected = new EventEmitter<void>();\n\n /** @ignore */\n private element = inject(ElementRef);\n\n /** @ignore */\n @ViewChild('inputField') inputField!: ElementRef<HTMLInputElement>;\n model!: string;\n\n /** @ignore */\n @HostBinding('attr.watt-field-disabled')\n isDisabled = false;\n\n /** @ignore */\n onTouchedCallbacks: (() => void)[] = [];\n\n /** @ignore */\n ngAfterViewInit(): void {\n const attrName = 'data-testid';\n const testIdAttribute = this.element.nativeElement.getAttribute(attrName);\n this.element.nativeElement.removeAttribute(attrName);\n this.inputField.nativeElement.setAttribute(attrName, testIdAttribute);\n this.registerOnTouched(() => {\n const trimmedValue = this.inputField.nativeElement.value.trim();\n this.inputField.nativeElement.value = trimmedValue;\n this.formControl.setValue(trimmedValue);\n });\n }\n\n /** @ignore */\n onChanged(event: Event): void {\n const value = (event.target as HTMLInputElement).value;\n\n if (this.autocompleteRef) {\n // Reset the autocomplete selection if the value is not matching anymore, and auto-select if the value has a match\n this.autocompleteRef.options.forEach((option) => {\n const isMatchingOption = this.autocompleteMatcherFn\n ? this.autocompleteMatcherFn(value, option.value)\n : option.value === value;\n\n if (isMatchingOption) {\n option.select(false);\n this.autocompleteOptionSelected.emit(option.value);\n } else {\n option.deselect(false);\n this.autocompleteOptionDeselected.emit();\n }\n });\n }\n\n this.searchChanged.emit(value);\n this.onChange(value);\n }\n\n /** @ignore */\n onChange: (value: string) => void = () => {\n /* noop function */\n };\n\n /** @ignore */\n onTouched: () => void = () => {\n for (const callback of this.onTouchedCallbacks) {\n callback();\n }\n };\n\n /** @ignore */\n writeValue(value: string): void {\n this.model = value;\n }\n\n /** @ignore */\n registerOnChange(fn: (value: string) => void): void {\n this.onChange = fn;\n }\n\n /** @ignore */\n registerOnTouched(fn: () => void): void {\n this.onTouchedCallbacks.push(fn);\n }\n\n /** @ignore */\n setDisabledState(isDisabled: boolean): void {\n this.isDisabled = isDisabled;\n }\n\n /** @ignore */\n setFocus(): void {\n this.inputField.nativeElement.focus();\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 { WattTextFieldComponent } from './watt-text-field.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAgGa,sBAAsB,CAAA;AACxB,IAAA,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDI,eAAA,CAAA,EAAA,MAAA,EAAA,CAAA,+MAAA,CAAA,EAAA;8BAGL,KAAK,EAAA,CAAA;sBAAb;gBACQ,IAAI,EAAA,CAAA;sBAAZ;gBACQ,WAAW,EAAA,CAAA;sBAAnB;gBACQ,KAAK,EAAA,CAAA;sBAAb;gBACQ,OAAO,EAAA,CAAA;sBAAf;gBACQ,MAAM,EAAA,CAAA;sBAAd;gBACQ,SAAS,EAAA,CAAA;sBAAjB;gBACQ,WAAW,EAAA,CAAA;sBAAnB;gBACQ,mBAAmB,EAAA,CAAA;sBAA3B;gBACQ,qBAAqB,EAAA,CAAA;sBAA7B;gBAG2B,eAAe,EAAA,CAAA;sBAA1C,SAAS;uBAAC,eAAe;gBAKhB,aAAa,EAAA,CAAA;sBAAtB;gBAKS,0BAA0B,EAAA,CAAA;sBAAnC;gBAKS,4BAA4B,EAAA,CAAA;sBAArC;gBAMwB,UAAU,EAAA,CAAA;sBAAlC,SAAS;uBAAC,YAAY;gBAKvB,UAAU,EAAA,CAAA;sBADT,WAAW;uBAAC,0BAA0B;;;ACvJzC;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
|
@@ -20,6 +20,7 @@ import { WattFieldIntlService } from './watt-field-intl.service';
|
|
|
20
20
|
import * as i0 from "@angular/core";
|
|
21
21
|
export declare class WattFieldComponent {
|
|
22
22
|
intl: WattFieldIntlService;
|
|
23
|
+
elementRef: ElementRef<any>;
|
|
23
24
|
control: import("@angular/core").InputSignal<FormControl<any> | null>;
|
|
24
25
|
label: import("@angular/core").InputSignal<string | undefined>;
|
|
25
26
|
id: import("@angular/core").InputSignal<string | undefined>;
|
|
@@ -34,7 +35,7 @@ export declare class WattFieldComponent {
|
|
|
34
35
|
errors: import("@angular/core").WritableSignal<ValidationErrors | null>;
|
|
35
36
|
isRequired: import("@angular/core").WritableSignal<boolean>;
|
|
36
37
|
isEmpty: import("@angular/core").Signal<any>;
|
|
37
|
-
wrapper: import("@angular/core").Signal<ElementRef<any
|
|
38
|
+
wrapper: import("@angular/core").Signal<ElementRef<any> | undefined>;
|
|
38
39
|
constructor();
|
|
39
40
|
isRequiredControl(control: FormControl): boolean;
|
|
40
41
|
static ɵfac: i0.ɵɵFactoryDeclaration<WattFieldComponent, never>;
|