@energinet/watt 0.0.1
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/LICENSE +201 -0
- package/badge/index.d.ts +17 -0
- package/badge/watt-badge.component.d.ts +15 -0
- package/breadcrumbs/index.d.ts +17 -0
- package/breadcrumbs/watt-breadcrumbs.component.d.ts +23 -0
- package/button/index.d.ts +17 -0
- package/button/watt-button.component.d.ts +20 -0
- package/card/index.d.ts +18 -0
- package/card/watt-card-title.component.d.ts +6 -0
- package/card/watt-card.component.d.ts +15 -0
- package/checkbox/index.d.ts +17 -0
- package/checkbox/watt-checkbox.component.d.ts +17 -0
- package/chip/index.d.ts +23 -0
- package/chip/watt-action-chip.component.d.ts +8 -0
- package/chip/watt-chip.component.d.ts +8 -0
- package/chip/watt-chip.directive.d.ts +16 -0
- package/chip/watt-date-chip.component.d.ts +29 -0
- package/chip/watt-date-range-chip.component.d.ts +50 -0
- package/chip/watt-filter-chip.component.d.ts +30 -0
- package/chip/watt-menu-chip.component.d.ts +30 -0
- package/clipboard/index.d.ts +18 -0
- package/clipboard/watt-clipboard-intl.service.d.ts +7 -0
- package/clipboard/watt-copy-to-clipboard.directive.d.ts +12 -0
- package/code/index.d.ts +18 -0
- package/code/watt-code.component.d.ts +32 -0
- package/code/watt-code.worker.token.d.ts +18 -0
- package/core/breakpoints/_breakpoints.import.scss +53 -0
- package/core/breakpoints/_include-media.scss +568 -0
- package/core/breakpoints/breakpoints-observer.d.ts +39 -0
- package/core/breakpoints/breakpoints.d.ts +29 -0
- package/core/breakpoints/index.d.ts +18 -0
- package/core/color/+storybook/storybook-colors-overview.component.scss +50 -0
- package/core/color/color-helper.service.d.ts +12 -0
- package/core/color/colors.d.ts +51 -0
- package/core/color/index.d.ts +18 -0
- package/core/date/dayjs.d.ts +22 -0
- package/core/date/index.d.ts +23 -0
- package/core/date/watt-danish-datetime.providers.d.ts +1 -0
- package/core/date/watt-date-adapter.d.ts +31 -0
- package/core/date/watt-date-range.d.ts +25 -0
- package/core/date/watt-date.pipe.d.ts +28 -0
- package/core/date/watt-format-date.d.ts +11 -0
- package/core/date/watt-locale.service.d.ts +13 -0
- package/core/styles/@energinet-datahub/watt/_index.scss +52 -0
- package/core/styles/@energinet-datahub/watt/_utils.scss +16 -0
- package/core/styles/@energinet-datahub/watt/theme/light-theme.scss +71 -0
- package/core/styles/@energinet-datahub/watt/theme/material-overwrites/datepicker.scss +69 -0
- package/core/styles/@energinet-datahub/watt/theme/material-overwrites/snack-bar.scss +26 -0
- package/core/styles/_box-sizing.scss +22 -0
- package/core/styles/_chips.scss +22 -0
- package/core/styles/_elevation.scss +18 -0
- package/core/styles/_hr.scss +20 -0
- package/core/styles/_table.scss +89 -0
- package/core/styles/_tokens.scss +134 -0
- package/core/styles/_tooltip.scss +64 -0
- package/core/styles/_variables.scss +106 -0
- package/core/styles/_vater.scss +69 -0
- package/core/styles/spacing/+storybook/storybook-spacing-overview.component.scss +25 -0
- package/core/styles/spacing/_baseline.scss +23 -0
- package/core/styles/spacing/_inline.scss +38 -0
- package/core/styles/spacing/_inset.scss +61 -0
- package/core/styles/spacing/_spacing.import.scss +113 -0
- package/core/styles/spacing/_stack.scss +38 -0
- package/core/styles/spacing/_variables.scss +14 -0
- package/core/styles/spacing/index.scss +18 -0
- package/core/styles/typography/+storybook/storybook-typography-overview.component.scss +78 -0
- package/core/styles/typography/_rem.scss +24 -0
- package/core/styles/typography/_typography.import.scss +195 -0
- package/core/styles/typography/index.scss +118 -0
- package/data/index.d.ts +20 -0
- package/data/watt-data-actions.component.d.ts +5 -0
- package/data/watt-data-filters.component.d.ts +5 -0
- package/data/watt-data-intl.service.d.ts +15 -0
- package/data/watt-data-table.component.d.ts +27 -0
- package/datetime-field/index.d.ts +17 -0
- package/datetime-field/watt-datetime-field.component.d.ts +39 -0
- package/description-list/index.d.ts +17 -0
- package/description-list/watt-description-list-item.component.d.ts +27 -0
- package/description-list/watt-description-list.component.d.ts +19 -0
- package/drawer/index.d.ts +21 -0
- package/drawer/watt-drawer-actions.component.d.ts +5 -0
- package/drawer/watt-drawer-content.component.d.ts +5 -0
- package/drawer/watt-drawer-heading.component.d.ts +5 -0
- package/drawer/watt-drawer-topbar.component.d.ts +5 -0
- package/drawer/watt-drawer.component.d.ts +61 -0
- package/dropdown/index.d.ts +19 -0
- package/dropdown/watt-dropdown-option.d.ts +22 -0
- package/dropdown/watt-dropdown-value.d.ts +17 -0
- package/dropdown/watt-dropdown.component.d.ts +195 -0
- package/empty-state/icons/explore.d.ts +5 -0
- package/empty-state/icons/no-results.d.ts +5 -0
- package/empty-state/icons/power.d.ts +5 -0
- package/empty-state/index.d.ts +20 -0
- package/empty-state/watt-empty-state.component.d.ts +16 -0
- package/expandable-card/index.d.ts +19 -0
- package/expandable-card/watt-expandable-card.component.d.ts +34 -0
- package/expansion/expansion.component.d.ts +18 -0
- package/expansion/index.d.ts +17 -0
- package/fesm2022/energinet-watt-badge.mjs +66 -0
- package/fesm2022/energinet-watt-badge.mjs.map +1 -0
- package/fesm2022/energinet-watt-breadcrumbs.mjs +116 -0
- package/fesm2022/energinet-watt-breadcrumbs.mjs.map +1 -0
- package/fesm2022/energinet-watt-button.mjs +120 -0
- package/fesm2022/energinet-watt-button.mjs.map +1 -0
- package/fesm2022/energinet-watt-card.mjs +117 -0
- package/fesm2022/energinet-watt-card.mjs.map +1 -0
- package/fesm2022/energinet-watt-checkbox.mjs +118 -0
- package/fesm2022/energinet-watt-checkbox.mjs.map +1 -0
- package/fesm2022/energinet-watt-chip.mjs +760 -0
- package/fesm2022/energinet-watt-chip.mjs.map +1 -0
- package/fesm2022/energinet-watt-clipboard.mjs +118 -0
- package/fesm2022/energinet-watt-clipboard.mjs.map +1 -0
- package/fesm2022/energinet-watt-code.mjs +119 -0
- package/fesm2022/energinet-watt-code.mjs.map +1 -0
- package/fesm2022/energinet-watt-core-breakpoints.mjs +100 -0
- package/fesm2022/energinet-watt-core-breakpoints.mjs.map +1 -0
- package/fesm2022/energinet-watt-core-color.mjs +127 -0
- package/fesm2022/energinet-watt-core-color.mjs.map +1 -0
- package/fesm2022/energinet-watt-core-date.mjs +260 -0
- package/fesm2022/energinet-watt-core-date.mjs.map +1 -0
- package/fesm2022/energinet-watt-data.mjs +286 -0
- package/fesm2022/energinet-watt-data.mjs.map +1 -0
- package/fesm2022/energinet-watt-datetime-field.mjs +233 -0
- package/fesm2022/energinet-watt-datetime-field.mjs.map +1 -0
- package/fesm2022/energinet-watt-description-list.mjs +130 -0
- package/fesm2022/energinet-watt-description-list.mjs.map +1 -0
- package/fesm2022/energinet-watt-drawer.mjs +271 -0
- package/fesm2022/energinet-watt-drawer.mjs.map +1 -0
- package/fesm2022/energinet-watt-dropdown.mjs +423 -0
- package/fesm2022/energinet-watt-dropdown.mjs.map +1 -0
- package/fesm2022/energinet-watt-empty-state.mjs +299 -0
- package/fesm2022/energinet-watt-empty-state.mjs.map +1 -0
- package/fesm2022/energinet-watt-expandable-card.mjs +151 -0
- package/fesm2022/energinet-watt-expandable-card.mjs.map +1 -0
- package/fesm2022/energinet-watt-expansion.mjs +78 -0
- package/fesm2022/energinet-watt-expansion.mjs.map +1 -0
- package/fesm2022/energinet-watt-field.mjs +249 -0
- package/fesm2022/energinet-watt-field.mjs.map +1 -0
- package/fesm2022/energinet-watt-icon-flags.mjs +376 -0
- package/fesm2022/energinet-watt-icon-flags.mjs.map +1 -0
- package/fesm2022/energinet-watt-icon.mjs +195 -0
- package/fesm2022/energinet-watt-icon.mjs.map +1 -0
- package/fesm2022/energinet-watt-modal.mjs +260 -0
- package/fesm2022/energinet-watt-modal.mjs.map +1 -0
- package/fesm2022/energinet-watt-paginator.mjs +164 -0
- package/fesm2022/energinet-watt-paginator.mjs.map +1 -0
- package/fesm2022/energinet-watt-phone-field.mjs +322 -0
- package/fesm2022/energinet-watt-phone-field.mjs.map +1 -0
- package/fesm2022/energinet-watt-picker-__shared.mjs +384 -0
- package/fesm2022/energinet-watt-picker-__shared.mjs.map +1 -0
- package/fesm2022/energinet-watt-picker-datepicker.mjs +430 -0
- package/fesm2022/energinet-watt-picker-datepicker.mjs.map +1 -0
- package/fesm2022/energinet-watt-picker-timepicker.mjs +394 -0
- package/fesm2022/energinet-watt-picker-timepicker.mjs.map +1 -0
- package/fesm2022/energinet-watt-progress-tracker.mjs +141 -0
- package/fesm2022/energinet-watt-progress-tracker.mjs.map +1 -0
- package/fesm2022/energinet-watt-query-params.mjs +95 -0
- package/fesm2022/energinet-watt-query-params.mjs.map +1 -0
- package/fesm2022/energinet-watt-radio.mjs +125 -0
- package/fesm2022/energinet-watt-radio.mjs.map +1 -0
- package/fesm2022/energinet-watt-search.mjs +126 -0
- package/fesm2022/energinet-watt-search.mjs.map +1 -0
- package/fesm2022/energinet-watt-shell.mjs +315 -0
- package/fesm2022/energinet-watt-shell.mjs.map +1 -0
- package/fesm2022/energinet-watt-slider.mjs +159 -0
- package/fesm2022/energinet-watt-slider.mjs.map +1 -0
- package/fesm2022/energinet-watt-spinner.mjs +72 -0
- package/fesm2022/energinet-watt-spinner.mjs.map +1 -0
- package/fesm2022/energinet-watt-stepper.mjs +185 -0
- package/fesm2022/energinet-watt-stepper.mjs.map +1 -0
- package/fesm2022/energinet-watt-table.mjs +423 -0
- package/fesm2022/energinet-watt-table.mjs.map +1 -0
- package/fesm2022/energinet-watt-tabs.mjs +254 -0
- package/fesm2022/energinet-watt-tabs.mjs.map +1 -0
- package/fesm2022/energinet-watt-text-field.mjs +316 -0
- package/fesm2022/energinet-watt-text-field.mjs.map +1 -0
- package/fesm2022/energinet-watt-textarea-field.mjs +136 -0
- package/fesm2022/energinet-watt-textarea-field.mjs.map +1 -0
- package/fesm2022/energinet-watt-toast.mjs +174 -0
- package/fesm2022/energinet-watt-toast.mjs.map +1 -0
- package/fesm2022/energinet-watt-tooltip.mjs +214 -0
- package/fesm2022/energinet-watt-tooltip.mjs.map +1 -0
- package/fesm2022/energinet-watt-utils-css.mjs +72 -0
- package/fesm2022/energinet-watt-utils-css.mjs.map +1 -0
- package/fesm2022/energinet-watt-utils-intersection-observer.mjs +83 -0
- package/fesm2022/energinet-watt-utils-intersection-observer.mjs.map +1 -0
- package/fesm2022/energinet-watt-utils-resize-observer.mjs +144 -0
- package/fesm2022/energinet-watt-utils-resize-observer.mjs.map +1 -0
- package/fesm2022/energinet-watt-validation-message.mjs +114 -0
- package/fesm2022/energinet-watt-validation-message.mjs.map +1 -0
- package/fesm2022/energinet-watt-validators.mjs +40 -0
- package/fesm2022/energinet-watt-validators.mjs.map +1 -0
- package/fesm2022/energinet-watt-vater.mjs +287 -0
- package/fesm2022/energinet-watt-vater.mjs.map +1 -0
- package/fesm2022/energinet-watt.mjs +47 -0
- package/fesm2022/energinet-watt.mjs.map +1 -0
- package/field/index.d.ts +20 -0
- package/field/watt-field-error.component.d.ts +5 -0
- package/field/watt-field-hint.component.d.ts +5 -0
- package/field/watt-field-intl.service.d.ts +8 -0
- package/field/watt-field.component.d.ts +42 -0
- package/icon/flags/index.d.ts +23 -0
- package/icon/flags/watt-flag-de.d.ts +5 -0
- package/icon/flags/watt-flag-dk.d.ts +5 -0
- package/icon/flags/watt-flag-fi.d.ts +5 -0
- package/icon/flags/watt-flag-no.d.ts +5 -0
- package/icon/flags/watt-flag-pl.d.ts +5 -0
- package/icon/flags/watt-flag-se.d.ts +5 -0
- package/icon/flags/watt-flag.d.ts +13 -0
- package/icon/icon.component.d.ts +20 -0
- package/icon/icons.d.ts +82 -0
- package/icon/index.d.ts +17 -0
- package/index.d.ts +33 -0
- package/modal/index.d.ts +18 -0
- package/modal/watt-modal.component.d.ts +86 -0
- package/modal/watt-modal.service.d.ts +62 -0
- package/package.json +237 -0
- package/paginator/index.d.ts +18 -0
- package/paginator/watt-paginator-intl.service.d.ts +14 -0
- package/paginator/watt-paginator.component.d.ts +53 -0
- package/phone-field/index.d.ts +18 -0
- package/phone-field/watt-phone-field-intl.service.d.ts +14 -0
- package/phone-field/watt-phone-field.component.d.ts +75 -0
- package/picker/__shared/index.d.ts +19 -0
- package/picker/__shared/placeholder-mask/watt-placeholder-mask.component.d.ts +34 -0
- package/picker/__shared/watt-picker-base.d.ts +201 -0
- package/picker/__shared/watt-picker-value.d.ts +18 -0
- package/picker/datepicker/index.d.ts +19 -0
- package/picker/datepicker/watt-datepicker-intl.service.d.ts +7 -0
- package/picker/datepicker/watt-datepicker.component.d.ts +149 -0
- package/picker/timepicker/index.d.ts +17 -0
- package/picker/timepicker/maskito-time-range-mask.d.ts +18 -0
- package/picker/timepicker/watt-timepicker.component.d.ts +132 -0
- package/progress-tracker/index.d.ts +20 -0
- package/progress-tracker/watt-progress-tracker-step.component.d.ts +10 -0
- package/progress-tracker/watt-progress-tracker.component.d.ts +5 -0
- package/query-params/index.d.ts +17 -0
- package/query-params/watt-query-params.directive.d.ts +27 -0
- package/radio/index.d.ts +17 -0
- package/radio/watt-radio.component.d.ts +24 -0
- package/search/index.d.ts +17 -0
- package/search/watt-search.component.d.ts +31 -0
- package/shell/index.d.ts +18 -0
- package/shell/nav-list/index.d.ts +18 -0
- package/shell/nav-list/watt-expand-on-active-link.directive.d.ts +26 -0
- package/shell/nav-list/watt-nav-list-item.component.d.ts +16 -0
- package/shell/nav-list/watt-nav-list.component.d.ts +12 -0
- package/shell/shell.component.d.ts +28 -0
- package/slider/index.d.ts +17 -0
- package/slider/watt-slider.component.d.ts +57 -0
- package/spinner/index.d.ts +17 -0
- package/spinner/watt-spinner.component.d.ts +15 -0
- package/stepper/index.d.ts +18 -0
- package/stepper/watt-stepper-step.component.d.ts +34 -0
- package/stepper/watt-stepper.component.d.ts +40 -0
- package/table/index.d.ts +18 -0
- package/table/watt-table-data-source.d.ts +37 -0
- package/table/watt-table.component.d.ts +239 -0
- package/tabs/index.d.ts +26 -0
- package/tabs/watt-link-tab.component.d.ts +7 -0
- package/tabs/watt-link-tabs.component.d.ts +7 -0
- package/tabs/watt-tab.component.d.ts +26 -0
- package/tabs/watt-tabs-action.component.d.ts +5 -0
- package/tabs/watt-tabs.component.d.ts +36 -0
- package/text-field/index.d.ts +17 -0
- package/text-field/watt-text-field.component.d.ts +77 -0
- package/textarea-field/index.d.ts +17 -0
- package/textarea-field/watt-textarea-field.component.d.ts +27 -0
- package/toast/index.d.ts +19 -0
- package/toast/watt-toast.component.d.ts +47 -0
- package/toast/watt-toast.service.d.ts +13 -0
- package/tooltip/index.d.ts +17 -0
- package/tooltip/watt-tooltip.component.d.ts +47 -0
- package/tooltip/watt-tooltip.directive.d.ts +31 -0
- package/utils/css/css-custom-properties.service.d.ts +10 -0
- package/utils/css/index.d.ts +17 -0
- package/utils/intersection-observer/index.d.ts +17 -0
- package/utils/intersection-observer/watt-intersection-observer.service.d.ts +21 -0
- package/utils/resize-observer/index.d.ts +18 -0
- package/utils/resize-observer/watt-resize-observer.directive.d.ts +35 -0
- package/utils/resize-observer/watt-resize-observer.service.d.ts +39 -0
- package/validation-message/index.d.ts +17 -0
- package/validation-message/watt-validation-message.component.d.ts +50 -0
- package/validators/index.d.ts +17 -0
- package/validators/watt-range.validators.d.ts +23 -0
- package/vater/index.d.ts +20 -0
- package/vater/types.d.ts +21 -0
- package/vater/vater-flex.component.d.ts +19 -0
- package/vater/vater-spacer.component.d.ts +5 -0
- package/vater/vater-stack.component.d.ts +14 -0
- package/vater/vater-utility.directive.d.ts +16 -0
|
@@ -0,0 +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":";;;;;;;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,KAAK,EAAE,IAAI;AACZ,yBAAA;qBACF,EACS,QAAA,EAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, ElementRef, forwardRef, HostBinding, Input, ViewEncapsulation, Component } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/forms';
|
|
4
|
+
import { FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
5
|
+
import { WattFieldComponent } from '@energinet/watt/field';
|
|
6
|
+
|
|
7
|
+
//#region License
|
|
8
|
+
/**
|
|
9
|
+
* @license
|
|
10
|
+
* Copyright 2020 Energinet DataHub A/S
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License2");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/
|
|
24
|
+
//#endregion
|
|
25
|
+
class WattTextAreaFieldComponent {
|
|
26
|
+
formControl;
|
|
27
|
+
value;
|
|
28
|
+
placeholder;
|
|
29
|
+
required = false;
|
|
30
|
+
label;
|
|
31
|
+
/** @ignore */
|
|
32
|
+
model;
|
|
33
|
+
/** @ignore */
|
|
34
|
+
element = inject(ElementRef);
|
|
35
|
+
/** @ignore */
|
|
36
|
+
isDisabled = false;
|
|
37
|
+
/** @ignore */
|
|
38
|
+
onChange = () => {
|
|
39
|
+
/* left blank intentionally */
|
|
40
|
+
};
|
|
41
|
+
/** @ignore */
|
|
42
|
+
writeValue(value) {
|
|
43
|
+
this.model = value;
|
|
44
|
+
}
|
|
45
|
+
/** @ignore */
|
|
46
|
+
registerOnChange(fn) {
|
|
47
|
+
this.onChange = fn;
|
|
48
|
+
}
|
|
49
|
+
/** @ignore */
|
|
50
|
+
registerOnTouched(fn) {
|
|
51
|
+
this.element.nativeElement.addEventListener('focusout', fn);
|
|
52
|
+
}
|
|
53
|
+
/** @ignore */
|
|
54
|
+
setDisabledState(isDisabled) {
|
|
55
|
+
this.isDisabled = isDisabled;
|
|
56
|
+
}
|
|
57
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattTextAreaFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
58
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.1", type: WattTextAreaFieldComponent, isStandalone: true, selector: "watt-textarea-field", inputs: { formControl: "formControl", value: "value", placeholder: "placeholder", required: "required", label: "label" }, host: { properties: { "attr.watt-field-disabled": "this.isDisabled" } }, providers: [
|
|
59
|
+
{
|
|
60
|
+
provide: NG_VALUE_ACCESSOR,
|
|
61
|
+
useExisting: forwardRef(() => WattTextAreaFieldComponent),
|
|
62
|
+
multi: true,
|
|
63
|
+
},
|
|
64
|
+
], ngImport: i0, template: `<watt-field [label]="label" [control]="formControl">
|
|
65
|
+
<textarea
|
|
66
|
+
[attr.placeholder]="placeholder"
|
|
67
|
+
[value]="value"
|
|
68
|
+
[(ngModel)]="model"
|
|
69
|
+
[disabled]="isDisabled"
|
|
70
|
+
(ngModelChange)="onChange($event)"
|
|
71
|
+
[required]="required"
|
|
72
|
+
></textarea>
|
|
73
|
+
<ng-content ngProjectAs="watt-field-hint" select="watt-field-hint" />
|
|
74
|
+
<ng-content ngProjectAs="watt-field-error" select="watt-field-error" />
|
|
75
|
+
</watt-field>`, isInline: true, styles: ["watt-textarea-field{display:block;width:100%;--watt-textarea-min-height: 200px}watt-textarea-field textarea{border:none;width:100%;outline:none;padding:var(--watt-space-s);padding-left:0;background-color:transparent;min-height:var(--watt-textarea-min-height)}\n"], dependencies: [{ kind: "ngmodule", type: FormsModule }, { 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.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: WattFieldComponent, selector: "watt-field", inputs: ["control", "label", "id", "chipMode", "tooltip", "placeholder", "anchorName"] }], encapsulation: i0.ViewEncapsulation.None });
|
|
76
|
+
}
|
|
77
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattTextAreaFieldComponent, decorators: [{
|
|
78
|
+
type: Component,
|
|
79
|
+
args: [{ imports: [FormsModule, WattFieldComponent], providers: [
|
|
80
|
+
{
|
|
81
|
+
provide: NG_VALUE_ACCESSOR,
|
|
82
|
+
useExisting: forwardRef(() => WattTextAreaFieldComponent),
|
|
83
|
+
multi: true,
|
|
84
|
+
},
|
|
85
|
+
], selector: 'watt-textarea-field', encapsulation: ViewEncapsulation.None, template: `<watt-field [label]="label" [control]="formControl">
|
|
86
|
+
<textarea
|
|
87
|
+
[attr.placeholder]="placeholder"
|
|
88
|
+
[value]="value"
|
|
89
|
+
[(ngModel)]="model"
|
|
90
|
+
[disabled]="isDisabled"
|
|
91
|
+
(ngModelChange)="onChange($event)"
|
|
92
|
+
[required]="required"
|
|
93
|
+
></textarea>
|
|
94
|
+
<ng-content ngProjectAs="watt-field-hint" select="watt-field-hint" />
|
|
95
|
+
<ng-content ngProjectAs="watt-field-error" select="watt-field-error" />
|
|
96
|
+
</watt-field>`, styles: ["watt-textarea-field{display:block;width:100%;--watt-textarea-min-height: 200px}watt-textarea-field textarea{border:none;width:100%;outline:none;padding:var(--watt-space-s);padding-left:0;background-color:transparent;min-height:var(--watt-textarea-min-height)}\n"] }]
|
|
97
|
+
}], propDecorators: { formControl: [{
|
|
98
|
+
type: Input
|
|
99
|
+
}], value: [{
|
|
100
|
+
type: Input
|
|
101
|
+
}], placeholder: [{
|
|
102
|
+
type: Input
|
|
103
|
+
}], required: [{
|
|
104
|
+
type: Input
|
|
105
|
+
}], label: [{
|
|
106
|
+
type: Input
|
|
107
|
+
}], isDisabled: [{
|
|
108
|
+
type: HostBinding,
|
|
109
|
+
args: ['attr.watt-field-disabled']
|
|
110
|
+
}] } });
|
|
111
|
+
|
|
112
|
+
//#region License
|
|
113
|
+
/**
|
|
114
|
+
* @license
|
|
115
|
+
* Copyright 2020 Energinet DataHub A/S
|
|
116
|
+
*
|
|
117
|
+
* Licensed under the Apache License, Version 2.0 (the "License2");
|
|
118
|
+
* you may not use this file except in compliance with the License.
|
|
119
|
+
* You may obtain a copy of the License at
|
|
120
|
+
*
|
|
121
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
122
|
+
*
|
|
123
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
124
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
125
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
126
|
+
* See the License for the specific language governing permissions and
|
|
127
|
+
* limitations under the License.
|
|
128
|
+
*/
|
|
129
|
+
//#endregion
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Generated bundle index. Do not edit.
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
export { WattTextAreaFieldComponent };
|
|
136
|
+
//# sourceMappingURL=energinet-watt-textarea-field.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"energinet-watt-textarea-field.mjs","sources":["../../../libs/watt/package/textarea-field/watt-textarea-field.component.ts","../../../libs/watt/package/textarea-field/index.ts","../../../libs/watt/package/textarea-field/energinet-watt-textarea-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 forwardRef,\n ViewEncapsulation,\n HostBinding,\n inject,\n ElementRef,\n} from '@angular/core';\nimport { ControlValueAccessor, FormControl, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms';\n\nimport { WattFieldComponent } from '@energinet/watt/field';\n\n@Component({\n imports: [FormsModule, WattFieldComponent],\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => WattTextAreaFieldComponent),\n multi: true,\n },\n ],\n selector: 'watt-textarea-field',\n styleUrls: ['./watt-textarea-field.component.scss'],\n encapsulation: ViewEncapsulation.None,\n template: `<watt-field [label]=\"label\" [control]=\"formControl\">\n <textarea\n [attr.placeholder]=\"placeholder\"\n [value]=\"value\"\n [(ngModel)]=\"model\"\n [disabled]=\"isDisabled\"\n (ngModelChange)=\"onChange($event)\"\n [required]=\"required\"\n ></textarea>\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 WattTextAreaFieldComponent implements ControlValueAccessor {\n @Input() formControl!: FormControl;\n @Input() value!: string;\n @Input() placeholder?: string;\n @Input() required = false;\n @Input() label!: string;\n\n /** @ignore */\n model!: string;\n\n /** @ignore */\n private element = inject(ElementRef);\n\n /** @ignore */\n @HostBinding('attr.watt-field-disabled')\n isDisabled = false;\n\n /** @ignore */\n onChange: (value: string) => void = () => {\n /* left blank intentionally */\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.element.nativeElement.addEventListener('focusout', fn);\n }\n\n /** @ignore */\n setDisabledState(isDisabled: boolean): void {\n this.isDisabled = isDisabled;\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 { WattTextAreaFieldComponent } from './watt-textarea-field.component';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAAA;AACA;;;;;;;;;;;;;;;AAeG;AACH;MAuCa,0BAA0B,CAAA;AAC5B,IAAA,WAAW;AACX,IAAA,KAAK;AACL,IAAA,WAAW;IACX,QAAQ,GAAG,KAAK;AAChB,IAAA,KAAK;;AAGd,IAAA,KAAK;;AAGG,IAAA,OAAO,GAAG,MAAM,CAAC,UAAU,CAAC;;IAIpC,UAAU,GAAG,KAAK;;IAGlB,QAAQ,GAA4B,MAAK;;AAEzC,KAAC;;AAGD,IAAA,UAAU,CAAC,KAAa,EAAA;AACtB,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK;;;AAIpB,IAAA,gBAAgB,CAAC,EAA2B,EAAA;AAC1C,QAAA,IAAI,CAAC,QAAQ,GAAG,EAAE;;;AAIpB,IAAA,iBAAiB,CAAC,EAAc,EAAA;QAC9B,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,UAAU,EAAE,EAAE,CAAC;;;AAI7D,IAAA,gBAAgB,CAAC,UAAmB,EAAA;AAClC,QAAA,IAAI,CAAC,UAAU,GAAG,UAAU;;uGAvCnB,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,UAA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,qBAAA,EAAA,QAAA,EACS,qBAAqB,EAAA,aAAA,EAEhB,iBAAiB,CAAC,IAAI,EAC3B,QAAA,EAAA,CAAA;;;;;;;;;;;AAWI,eAAA,CAAA,EAAA,MAAA,EAAA,CAAA,uQAAA,CAAA,EAAA;8BAGL,WAAW,EAAA,CAAA;sBAAnB;gBACQ,KAAK,EAAA,CAAA;sBAAb;gBACQ,WAAW,EAAA,CAAA;sBAAnB;gBACQ,QAAQ,EAAA,CAAA;sBAAhB;gBACQ,KAAK,EAAA,CAAA;sBAAb;gBAUD,UAAU,EAAA,CAAA;sBADT,WAAW;uBAAC,0BAA0B;;;ACtEzC;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, ChangeDetectorRef, ElementRef, HostBinding, ViewEncapsulation, ChangeDetectionStrategy, Component, Injectable } from '@angular/core';
|
|
3
|
+
import * as i1 from '@angular/material/snack-bar';
|
|
4
|
+
import { MAT_SNACK_BAR_DATA, MatSnackBarRef, MatSnackBarModule } from '@angular/material/snack-bar';
|
|
5
|
+
import { fromEvent, timer, tap, takeUntil, repeat } from 'rxjs';
|
|
6
|
+
import { WattIconComponent } from '@energinet/watt/icon';
|
|
7
|
+
import { WattButtonComponent } from '@energinet/watt/button';
|
|
8
|
+
import { WattSpinnerComponent } from '@energinet/watt/spinner';
|
|
9
|
+
|
|
10
|
+
//#region License
|
|
11
|
+
/**
|
|
12
|
+
* @license
|
|
13
|
+
* Copyright 2020 Energinet DataHub A/S
|
|
14
|
+
*
|
|
15
|
+
* Licensed under the Apache License, Version 2.0 (the "License2");
|
|
16
|
+
* you may not use this file except in compliance with the License.
|
|
17
|
+
* You may obtain a copy of the License at
|
|
18
|
+
*
|
|
19
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
20
|
+
*
|
|
21
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
22
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
23
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
24
|
+
* See the License for the specific language governing permissions and
|
|
25
|
+
* limitations under the License.
|
|
26
|
+
*/
|
|
27
|
+
//#endregion
|
|
28
|
+
/**
|
|
29
|
+
* Usage:
|
|
30
|
+
* `import { WattToastService } from '@energinet-datahub/watt/toast';`
|
|
31
|
+
*/
|
|
32
|
+
class WattToastComponent {
|
|
33
|
+
_config = inject(MAT_SNACK_BAR_DATA);
|
|
34
|
+
cd = inject(ChangeDetectorRef);
|
|
35
|
+
_matSnackBarRef = inject(MatSnackBarRef);
|
|
36
|
+
elementRef = inject(ElementRef);
|
|
37
|
+
get class() {
|
|
38
|
+
this.cd.detectChanges(); // Make sure changes to the config will be detected
|
|
39
|
+
return this.config.type ? `watt-toast watt-toast--${this.config.type}` : 'watt-toast';
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* @ignore
|
|
43
|
+
*/
|
|
44
|
+
config;
|
|
45
|
+
/**
|
|
46
|
+
* @ignore
|
|
47
|
+
*/
|
|
48
|
+
matSnackBarRef;
|
|
49
|
+
/**
|
|
50
|
+
* @ignore
|
|
51
|
+
*/
|
|
52
|
+
dissmissToastSubscription;
|
|
53
|
+
constructor() {
|
|
54
|
+
this.config = this._config;
|
|
55
|
+
this.matSnackBarRef = this._matSnackBarRef;
|
|
56
|
+
this.initDuration(this.config.duration);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @ignore
|
|
60
|
+
*/
|
|
61
|
+
onClose() {
|
|
62
|
+
if (!this.matSnackBarRef)
|
|
63
|
+
return;
|
|
64
|
+
this.matSnackBarRef.dismiss();
|
|
65
|
+
this.dissmissToastSubscription?.unsubscribe();
|
|
66
|
+
}
|
|
67
|
+
update(config) {
|
|
68
|
+
this.config = { ...this.config, ...config };
|
|
69
|
+
if (this.dissmissToastSubscription) {
|
|
70
|
+
this.dissmissToastSubscription.unsubscribe();
|
|
71
|
+
}
|
|
72
|
+
this.initDuration();
|
|
73
|
+
this.cd.detectChanges();
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* @ignore
|
|
77
|
+
* Ensure the toast won't get dismissed when the user hovers over it.
|
|
78
|
+
*/
|
|
79
|
+
initDuration(duration = 5000) {
|
|
80
|
+
// When the type is loading, the developer is responsible for dismissing the toast manually.
|
|
81
|
+
if (this.config.type === 'loading')
|
|
82
|
+
return;
|
|
83
|
+
const mouseEnter$ = fromEvent(this.elementRef.nativeElement, 'mouseenter');
|
|
84
|
+
const mouseLeave$ = fromEvent(this.elementRef.nativeElement, 'mouseleave');
|
|
85
|
+
this.dissmissToastSubscription = timer(duration)
|
|
86
|
+
.pipe(tap(() => this.onClose()), takeUntil(mouseEnter$), repeat({ delay: () => mouseLeave$ }))
|
|
87
|
+
.subscribe();
|
|
88
|
+
}
|
|
89
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattToastComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
90
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.1", type: WattToastComponent, isStandalone: true, selector: "watt-toast", host: { properties: { "class": "this.class" } }, ngImport: i0, template: "<!--\n@license\nCopyright 2020 Energinet DataHub A/S\n\nLicensed under the Apache License, Version 2.0 (the \"License2\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-->\n<span>\n @if (config.type === \"loading\") {\n <watt-spinner [diameter]=\"24\" />\n }\n\n @if (config.type && config.type !== \"loading\") {\n <watt-icon [name]=\"config.type\" />\n }\n <p>{{ config.message }}</p>\n</span>\n<span class=\"toast__actions\">\n @if (config.action && config.actionLabel) {\n <watt-button variant=\"text\" (click)=\"config.action(matSnackBarRef)\">{{\n config.actionLabel\n }}</watt-button>\n }\n\n @if (config.type !== \"loading\") {\n <watt-button data-testid=\"dismiss\" variant=\"icon\" icon=\"close\" (click)=\"onClose()\" />\n }\n</span>\n", styles: [".watt-toast{display:flex;justify-content:space-between;align-items:center;background:var(--watt-color-neutral-white);border-left:6px solid transparent;box-shadow:0 var(--watt-space-m) var(--watt-space-m) #0003,0 32px 64px 3px #2e323433;border-radius:4px;padding:var(--watt-space-s) var(--watt-space-m);max-width:704px;min-height:4rem}.watt-toast--success{border-color:var(--watt-color-state-success)}.watt-toast--info{border-color:var(--watt-color-state-info)}.watt-toast--warning{border-color:var(--watt-color-state-warning)}.watt-toast--danger{border-color:var(--watt-color-state-danger)}.watt-toast span{display:flex;align-items:center}.watt-toast watt-icon,.watt-toast watt-spinner{margin-right:var(--watt-space-m)}.watt-toast watt-button .watt-button--text{text-transform:capitalize}.watt-toast p{margin:0 var(--watt-space-s) 0 0}\n"], dependencies: [{ kind: "ngmodule", type: MatSnackBarModule }, { kind: "component", type: WattButtonComponent, selector: "watt-button", inputs: ["icon", "variant", "type", "formId", "disabled", "loading"] }, { kind: "component", type: WattIconComponent, selector: "watt-icon", inputs: ["name", "label", "size", "state"] }, { kind: "component", type: WattSpinnerComponent, selector: "watt-spinner", inputs: ["diameter", "strokeWidth"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
91
|
+
}
|
|
92
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattToastComponent, decorators: [{
|
|
93
|
+
type: Component,
|
|
94
|
+
args: [{ changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, selector: 'watt-toast', imports: [MatSnackBarModule, WattButtonComponent, WattIconComponent, WattSpinnerComponent], template: "<!--\n@license\nCopyright 2020 Energinet DataHub A/S\n\nLicensed under the Apache License, Version 2.0 (the \"License2\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-->\n<span>\n @if (config.type === \"loading\") {\n <watt-spinner [diameter]=\"24\" />\n }\n\n @if (config.type && config.type !== \"loading\") {\n <watt-icon [name]=\"config.type\" />\n }\n <p>{{ config.message }}</p>\n</span>\n<span class=\"toast__actions\">\n @if (config.action && config.actionLabel) {\n <watt-button variant=\"text\" (click)=\"config.action(matSnackBarRef)\">{{\n config.actionLabel\n }}</watt-button>\n }\n\n @if (config.type !== \"loading\") {\n <watt-button data-testid=\"dismiss\" variant=\"icon\" icon=\"close\" (click)=\"onClose()\" />\n }\n</span>\n", styles: [".watt-toast{display:flex;justify-content:space-between;align-items:center;background:var(--watt-color-neutral-white);border-left:6px solid transparent;box-shadow:0 var(--watt-space-m) var(--watt-space-m) #0003,0 32px 64px 3px #2e323433;border-radius:4px;padding:var(--watt-space-s) var(--watt-space-m);max-width:704px;min-height:4rem}.watt-toast--success{border-color:var(--watt-color-state-success)}.watt-toast--info{border-color:var(--watt-color-state-info)}.watt-toast--warning{border-color:var(--watt-color-state-warning)}.watt-toast--danger{border-color:var(--watt-color-state-danger)}.watt-toast span{display:flex;align-items:center}.watt-toast watt-icon,.watt-toast watt-spinner{margin-right:var(--watt-space-m)}.watt-toast watt-button .watt-button--text{text-transform:capitalize}.watt-toast p{margin:0 var(--watt-space-s) 0 0}\n"] }]
|
|
95
|
+
}], ctorParameters: () => [], propDecorators: { class: [{
|
|
96
|
+
type: HostBinding,
|
|
97
|
+
args: ['class']
|
|
98
|
+
}] } });
|
|
99
|
+
|
|
100
|
+
//#region License
|
|
101
|
+
/**
|
|
102
|
+
* @license
|
|
103
|
+
* Copyright 2020 Energinet DataHub A/S
|
|
104
|
+
*
|
|
105
|
+
* Licensed under the Apache License, Version 2.0 (the "License2");
|
|
106
|
+
* you may not use this file except in compliance with the License.
|
|
107
|
+
* You may obtain a copy of the License at
|
|
108
|
+
*
|
|
109
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
110
|
+
*
|
|
111
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
112
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
113
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
114
|
+
* See the License for the specific language governing permissions and
|
|
115
|
+
* limitations under the License.
|
|
116
|
+
*/
|
|
117
|
+
//#endregion
|
|
118
|
+
class WattToastService {
|
|
119
|
+
_snackBar;
|
|
120
|
+
ref;
|
|
121
|
+
constructor(_snackBar) {
|
|
122
|
+
this._snackBar = _snackBar;
|
|
123
|
+
}
|
|
124
|
+
open(config) {
|
|
125
|
+
this.ref = this._snackBar.openFromComponent(WattToastComponent, {
|
|
126
|
+
data: config,
|
|
127
|
+
});
|
|
128
|
+
return this.ref;
|
|
129
|
+
}
|
|
130
|
+
update(config) {
|
|
131
|
+
if (!this.ref)
|
|
132
|
+
return;
|
|
133
|
+
this.ref.instance.update(config);
|
|
134
|
+
}
|
|
135
|
+
dismiss() {
|
|
136
|
+
if (!this.ref)
|
|
137
|
+
return;
|
|
138
|
+
this.ref.dismiss();
|
|
139
|
+
}
|
|
140
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattToastService, deps: [{ token: i1.MatSnackBar }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
141
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattToastService, providedIn: 'root' });
|
|
142
|
+
}
|
|
143
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattToastService, decorators: [{
|
|
144
|
+
type: Injectable,
|
|
145
|
+
args: [{
|
|
146
|
+
providedIn: 'root',
|
|
147
|
+
}]
|
|
148
|
+
}], ctorParameters: () => [{ type: i1.MatSnackBar }] });
|
|
149
|
+
|
|
150
|
+
//#region License
|
|
151
|
+
/**
|
|
152
|
+
* @license
|
|
153
|
+
* Copyright 2020 Energinet DataHub A/S
|
|
154
|
+
*
|
|
155
|
+
* Licensed under the Apache License, Version 2.0 (the "License2");
|
|
156
|
+
* you may not use this file except in compliance with the License.
|
|
157
|
+
* You may obtain a copy of the License at
|
|
158
|
+
*
|
|
159
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
160
|
+
*
|
|
161
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
162
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
163
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
164
|
+
* See the License for the specific language governing permissions and
|
|
165
|
+
* limitations under the License.
|
|
166
|
+
*/
|
|
167
|
+
//#endregion
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Generated bundle index. Do not edit.
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
export { WattToastComponent, WattToastService };
|
|
174
|
+
//# sourceMappingURL=energinet-watt-toast.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"energinet-watt-toast.mjs","sources":["../../../libs/watt/package/toast/watt-toast.component.ts","../../../libs/watt/package/toast/watt-toast.component.html","../../../libs/watt/package/toast/watt-toast.service.ts","../../../libs/watt/package/toast/index.ts","../../../libs/watt/package/toast/energinet-watt-toast.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 ChangeDetectionStrategy,\n ChangeDetectorRef,\n Component,\n ElementRef,\n HostBinding,\n ViewEncapsulation,\n inject,\n} from '@angular/core';\nimport { MatSnackBarModule, MatSnackBarRef, MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';\nimport { fromEvent, repeat, Subscription, takeUntil, tap, timer } from 'rxjs';\n\nimport { WattIconComponent } from '@energinet/watt/icon';\nimport { WattButtonComponent } from '@energinet/watt/button';\nimport { WattSpinnerComponent } from '@energinet/watt/spinner';\n\nexport type WattToastType = 'success' | 'info' | 'warning' | 'danger' | 'loading';\n\nexport interface WattToastConfig {\n duration?: number;\n type?: WattToastType;\n message: string;\n action?: (wattToastRef: WattToastRef) => void;\n actionLabel?: string;\n}\n\nexport type WattToastRef = MatSnackBarRef<WattToastComponent>;\n\n/**\n * Usage:\n * `import { WattToastService } from '@energinet-datahub/watt/toast';`\n */\n@Component({\n changeDetection: ChangeDetectionStrategy.OnPush,\n encapsulation: ViewEncapsulation.None,\n selector: 'watt-toast',\n styleUrls: ['./watt-toast.component.scss'],\n templateUrl: './watt-toast.component.html',\n imports: [MatSnackBarModule, WattButtonComponent, WattIconComponent, WattSpinnerComponent],\n})\nexport class WattToastComponent {\n private _config = inject(MAT_SNACK_BAR_DATA);\n private cd = inject(ChangeDetectorRef);\n private _matSnackBarRef = inject<MatSnackBarRef<WattToastComponent>>(MatSnackBarRef);\n private elementRef = inject(ElementRef);\n\n @HostBinding('class')\n get class() {\n this.cd.detectChanges(); // Make sure changes to the config will be detected\n return this.config.type ? `watt-toast watt-toast--${this.config.type}` : 'watt-toast';\n }\n\n /**\n * @ignore\n */\n config: WattToastConfig;\n\n /**\n * @ignore\n */\n matSnackBarRef: WattToastRef;\n\n /**\n * @ignore\n */\n private dissmissToastSubscription?: Subscription;\n\n constructor() {\n this.config = this._config;\n this.matSnackBarRef = this._matSnackBarRef;\n this.initDuration(this.config.duration);\n }\n\n /**\n * @ignore\n */\n onClose(): void {\n if (!this.matSnackBarRef) return;\n this.matSnackBarRef.dismiss();\n this.dissmissToastSubscription?.unsubscribe();\n }\n\n update(config: Partial<WattToastConfig>) {\n this.config = { ...this.config, ...config };\n if (this.dissmissToastSubscription) {\n this.dissmissToastSubscription.unsubscribe();\n }\n this.initDuration();\n this.cd.detectChanges();\n }\n\n /**\n * @ignore\n * Ensure the toast won't get dismissed when the user hovers over it.\n */\n private initDuration(duration = 5000): void {\n // When the type is loading, the developer is responsible for dismissing the toast manually.\n if (this.config.type === 'loading') return;\n\n const mouseEnter$ = fromEvent(this.elementRef.nativeElement, 'mouseenter');\n const mouseLeave$ = fromEvent(this.elementRef.nativeElement, 'mouseleave');\n\n this.dissmissToastSubscription = timer(duration)\n .pipe(\n tap(() => this.onClose()),\n takeUntil(mouseEnter$),\n repeat({ delay: () => mouseLeave$ })\n )\n .subscribe();\n }\n}\n","<!--\n@license\nCopyright 2020 Energinet DataHub A/S\n\nLicensed under the Apache License, Version 2.0 (the \"License2\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n-->\n<span>\n @if (config.type === \"loading\") {\n <watt-spinner [diameter]=\"24\" />\n }\n\n @if (config.type && config.type !== \"loading\") {\n <watt-icon [name]=\"config.type\" />\n }\n <p>{{ config.message }}</p>\n</span>\n<span class=\"toast__actions\">\n @if (config.action && config.actionLabel) {\n <watt-button variant=\"text\" (click)=\"config.action(matSnackBarRef)\">{{\n config.actionLabel\n }}</watt-button>\n }\n\n @if (config.type !== \"loading\") {\n <watt-button data-testid=\"dismiss\" variant=\"icon\" icon=\"close\" (click)=\"onClose()\" />\n }\n</span>\n","//#region License\n/**\n * @license\n * Copyright 2020 Energinet DataHub A/S\n *\n * Licensed under the Apache License, Version 2.0 (the \"License2\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n//#endregion\nimport { Injectable } from '@angular/core';\nimport { MatSnackBar, MatSnackBarRef } from '@angular/material/snack-bar';\n\nimport { WattToastComponent, WattToastConfig } from './watt-toast.component';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class WattToastService {\n private ref?: MatSnackBarRef<WattToastComponent>;\n\n constructor(private _snackBar: MatSnackBar) {}\n\n open(config: WattToastConfig): MatSnackBarRef<WattToastComponent> {\n this.ref = this._snackBar.openFromComponent(WattToastComponent, {\n data: config,\n });\n return this.ref;\n }\n\n update(config: Partial<WattToastConfig>): void {\n if (!this.ref) return;\n this.ref.instance.update(config);\n }\n\n dismiss() {\n if (!this.ref) return;\n this.ref.dismiss();\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 { WattToastComponent, WattToastType } from './watt-toast.component';\nexport { WattToastService } from './watt-toast.service';\nexport type { WattToastRef } from './watt-toast.component';\n","/**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,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;;IAGlC,OAAO,GAAA;QACL,IAAI,CAAC,IAAI,CAAC,GAAG;YAAE;AACf,QAAA,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;;uGAnBT,gBAAgB,EAAA,IAAA,EAAA,CAAA,EAAA,KAAA,EAAA,EAAA,CAAA,WAAA,EAAA,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA;AAAhB,IAAA,OAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,gBAAgB,cAFf,MAAM,EAAA,CAAA;;2FAEP,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAH5B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;ACzBD;AACA;;;;;;;;;;;;;;;AAeG;AACH;;ACjBA;;AAEG;;;;"}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { inject, ElementRef, Renderer2, HostBinding, ViewChild, Input, Component, ViewContainerRef, Directive } from '@angular/core';
|
|
3
|
+
import { createPopper } from '@popperjs/core';
|
|
4
|
+
import { Platform } from '@angular/cdk/platform';
|
|
5
|
+
import { FocusMonitor } from '@angular/cdk/a11y';
|
|
6
|
+
import { Subject, takeUntil } from 'rxjs';
|
|
7
|
+
|
|
8
|
+
//#region License
|
|
9
|
+
/**
|
|
10
|
+
* @license
|
|
11
|
+
* Copyright 2020 Energinet DataHub A/S
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the Apache License, Version 2.0 (the "License2");
|
|
14
|
+
* you may not use this file except in compliance with the License.
|
|
15
|
+
* You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
//#endregion
|
|
26
|
+
class WattTooltipComponent {
|
|
27
|
+
static nextId = 0;
|
|
28
|
+
text;
|
|
29
|
+
target;
|
|
30
|
+
position;
|
|
31
|
+
variant;
|
|
32
|
+
arrow;
|
|
33
|
+
id = `watt-tooltip-${WattTooltipComponent.nextId++}`; // used by aria-describedby
|
|
34
|
+
role = 'tooltip';
|
|
35
|
+
get hostClass() {
|
|
36
|
+
return `tooltip-${this.variant}`;
|
|
37
|
+
}
|
|
38
|
+
element = inject(ElementRef).nativeElement;
|
|
39
|
+
platform = inject(Platform);
|
|
40
|
+
renderer = inject(Renderer2);
|
|
41
|
+
focusMonitor = inject(FocusMonitor);
|
|
42
|
+
/** Emits when the component is destroyed. */
|
|
43
|
+
destroyed = new Subject();
|
|
44
|
+
listeners = [];
|
|
45
|
+
showClass = 'show';
|
|
46
|
+
popper = null;
|
|
47
|
+
ngAfterViewInit() {
|
|
48
|
+
this.setupEventListeners();
|
|
49
|
+
this.focusMonitor
|
|
50
|
+
.monitor(this.target, true)
|
|
51
|
+
.pipe(takeUntil(this.destroyed))
|
|
52
|
+
.subscribe((origin) => {
|
|
53
|
+
if (!origin) {
|
|
54
|
+
this.hide();
|
|
55
|
+
}
|
|
56
|
+
else if (origin === 'keyboard') {
|
|
57
|
+
this.show();
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
ngOnDestroy() {
|
|
62
|
+
this.popper?.destroy();
|
|
63
|
+
this.listeners.forEach((listener) => listener());
|
|
64
|
+
this.destroyed.next();
|
|
65
|
+
this.destroyed.complete();
|
|
66
|
+
}
|
|
67
|
+
setupEventListeners() {
|
|
68
|
+
// The mouse events shouldn't be bound on mobile devices, because they can prevent the
|
|
69
|
+
// first tap from firing its click event or can cause the tooltip to open for clicks.
|
|
70
|
+
if (this.platformSupportsMouseEvents()) {
|
|
71
|
+
const mouseEnter = this.renderer.listen(this.target, 'mouseenter', this.show.bind(this));
|
|
72
|
+
const mouseLeave = this.renderer.listen(this.target, 'mouseleave', this.hide.bind(this));
|
|
73
|
+
const wheel = this.renderer.listen(this.target, 'wheel', this.hide.bind(this));
|
|
74
|
+
this.listeners.push(mouseEnter, mouseLeave, wheel);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
const touchStart = this.renderer.listen(this.target, 'touchstart', this.show.bind(this));
|
|
78
|
+
const touchEnd = this.renderer.listen(this.target, 'touchend', this.hide.bind(this));
|
|
79
|
+
const touchCancel = this.renderer.listen(this.target, 'touchcancel', this.hide.bind(this));
|
|
80
|
+
this.listeners.push(touchStart, touchEnd, touchCancel);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
show() {
|
|
84
|
+
if (!this.popper) {
|
|
85
|
+
this.popper = createPopper(this.target, this.element, {
|
|
86
|
+
placement: this.position,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
this.popper.forceUpdate();
|
|
91
|
+
}
|
|
92
|
+
this.renderer.addClass(this.element, this.showClass);
|
|
93
|
+
}
|
|
94
|
+
hide() {
|
|
95
|
+
this.renderer.removeClass(this.element, this.showClass);
|
|
96
|
+
}
|
|
97
|
+
platformSupportsMouseEvents() {
|
|
98
|
+
return !this.platform.IOS && !this.platform.ANDROID;
|
|
99
|
+
}
|
|
100
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattTooltipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
101
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "19.2.1", type: WattTooltipComponent, isStandalone: true, selector: "watt-tooltip", inputs: { text: "text", target: "target", position: "position", variant: "variant" }, host: { properties: { "id": "this.id", "attr.role": "this.role", "class": "this.hostClass" } }, viewQueries: [{ propertyName: "arrow", first: true, predicate: ["arrow"], descendants: true }], ngImport: i0, template: `
|
|
102
|
+
{{ text }}
|
|
103
|
+
<div class="arrow"></div>
|
|
104
|
+
`, isInline: true, styles: [":host{position:absolute;pointer-events:none;z-index:1000;display:inline-block;line-height:18px;border-radius:6px;padding:var(--watt-space-xs) var(--watt-space-s);font-size:.875rem;line-height:1.25rem;font-weight:400;text-transform:none;letter-spacing:0;opacity:0;transition:opacity .3s ease-in-out}:host.tooltip-dark{background:var(--watt-color-primary-dark);color:var(--watt-color-primary-dark-contrast)}:host.tooltip-light{background:var(--watt-color-neutral-white);color:var(--watt-color-primary-light-contrast)}:host.show{opacity:1}:host[data-popper-placement^=top]{inset-block-end:6px!important}:host[data-popper-placement^=bottom]{inset-block-start:6px!important}:host[data-popper-placement^=bottom]>.arrow{top:-4px}:host[data-popper-placement^=left]{inset-inline-end:6px!important}:host[data-popper-placement^=left]>.arrow{right:-4px}:host[data-popper-placement^=right]{inset-inline-start:6px!important}:host[data-popper-placement^=right]>.arrow{left:-4px}:host[data-popper-placement=left]>.arrow,:host[data-popper-placement=right]>.arrow{top:calc(50% - 4px)}:host[data-popper-placement=top]>.arrow,:host[data-popper-placement=bottom]>.arrow{left:calc(50% - 4px)!important}:host[data-popper-placement=top-end]>.arrow,:host[data-popper-placement=bottom-end]>.arrow{left:10px!important}:host[data-popper-placement=top-start]>.arrow,:host[data-popper-placement=bottom-start]>.arrow{left:calc(100% - 18px)}.arrow,.arrow:before{position:absolute;width:8px;height:8px;background:inherit}.arrow{visibility:hidden}.arrow:before{visibility:visible;content:\"\";transform:rotate(45deg)}\n"] });
|
|
105
|
+
}
|
|
106
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattTooltipComponent, decorators: [{
|
|
107
|
+
type: Component,
|
|
108
|
+
args: [{ template: `
|
|
109
|
+
{{ text }}
|
|
110
|
+
<div class="arrow"></div>
|
|
111
|
+
`, selector: 'watt-tooltip', styles: [":host{position:absolute;pointer-events:none;z-index:1000;display:inline-block;line-height:18px;border-radius:6px;padding:var(--watt-space-xs) var(--watt-space-s);font-size:.875rem;line-height:1.25rem;font-weight:400;text-transform:none;letter-spacing:0;opacity:0;transition:opacity .3s ease-in-out}:host.tooltip-dark{background:var(--watt-color-primary-dark);color:var(--watt-color-primary-dark-contrast)}:host.tooltip-light{background:var(--watt-color-neutral-white);color:var(--watt-color-primary-light-contrast)}:host.show{opacity:1}:host[data-popper-placement^=top]{inset-block-end:6px!important}:host[data-popper-placement^=bottom]{inset-block-start:6px!important}:host[data-popper-placement^=bottom]>.arrow{top:-4px}:host[data-popper-placement^=left]{inset-inline-end:6px!important}:host[data-popper-placement^=left]>.arrow{right:-4px}:host[data-popper-placement^=right]{inset-inline-start:6px!important}:host[data-popper-placement^=right]>.arrow{left:-4px}:host[data-popper-placement=left]>.arrow,:host[data-popper-placement=right]>.arrow{top:calc(50% - 4px)}:host[data-popper-placement=top]>.arrow,:host[data-popper-placement=bottom]>.arrow{left:calc(50% - 4px)!important}:host[data-popper-placement=top-end]>.arrow,:host[data-popper-placement=bottom-end]>.arrow{left:10px!important}:host[data-popper-placement=top-start]>.arrow,:host[data-popper-placement=bottom-start]>.arrow{left:calc(100% - 18px)}.arrow,.arrow:before{position:absolute;width:8px;height:8px;background:inherit}.arrow{visibility:hidden}.arrow:before{visibility:visible;content:\"\";transform:rotate(45deg)}\n"] }]
|
|
112
|
+
}], propDecorators: { text: [{
|
|
113
|
+
type: Input
|
|
114
|
+
}], target: [{
|
|
115
|
+
type: Input
|
|
116
|
+
}], position: [{
|
|
117
|
+
type: Input
|
|
118
|
+
}], variant: [{
|
|
119
|
+
type: Input
|
|
120
|
+
}], arrow: [{
|
|
121
|
+
type: ViewChild,
|
|
122
|
+
args: ['arrow']
|
|
123
|
+
}], id: [{
|
|
124
|
+
type: HostBinding
|
|
125
|
+
}], role: [{
|
|
126
|
+
type: HostBinding,
|
|
127
|
+
args: ['attr.role']
|
|
128
|
+
}], hostClass: [{
|
|
129
|
+
type: HostBinding,
|
|
130
|
+
args: ['class']
|
|
131
|
+
}] } });
|
|
132
|
+
|
|
133
|
+
//#region License
|
|
134
|
+
/**
|
|
135
|
+
* @license
|
|
136
|
+
* Copyright 2020 Energinet DataHub A/S
|
|
137
|
+
*
|
|
138
|
+
* Licensed under the Apache License, Version 2.0 (the "License2");
|
|
139
|
+
* you may not use this file except in compliance with the License.
|
|
140
|
+
* You may obtain a copy of the License at
|
|
141
|
+
*
|
|
142
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
143
|
+
*
|
|
144
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
145
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
146
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
147
|
+
* See the License for the specific language governing permissions and
|
|
148
|
+
* limitations under the License.
|
|
149
|
+
*/
|
|
150
|
+
//#endregion
|
|
151
|
+
class WattTooltipDirective {
|
|
152
|
+
text;
|
|
153
|
+
position = 'top';
|
|
154
|
+
variant = 'dark';
|
|
155
|
+
element = inject(ElementRef).nativeElement;
|
|
156
|
+
viewContainerRef = inject(ViewContainerRef);
|
|
157
|
+
ngOnChanges(changes) {
|
|
158
|
+
if (changes['text']) {
|
|
159
|
+
this.createTooltipComponent();
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
createTooltipComponent() {
|
|
163
|
+
const tooltip = this.viewContainerRef.createComponent(WattTooltipComponent);
|
|
164
|
+
tooltip.instance.text = this.text;
|
|
165
|
+
tooltip.instance.target = this.element;
|
|
166
|
+
tooltip.instance.position = this.position;
|
|
167
|
+
tooltip.instance.variant = this.variant;
|
|
168
|
+
this.element.setAttribute('aria-describedby', tooltip.instance.id);
|
|
169
|
+
}
|
|
170
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
171
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "19.2.1", type: WattTooltipDirective, isStandalone: true, selector: "[wattTooltip]", inputs: { text: ["wattTooltip", "text"], position: ["wattTooltipPosition", "position"], variant: ["wattTooltipVariant", "variant"] }, exportAs: ["wattTooltip"], usesOnChanges: true, ngImport: i0 });
|
|
172
|
+
}
|
|
173
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.1", ngImport: i0, type: WattTooltipDirective, decorators: [{
|
|
174
|
+
type: Directive,
|
|
175
|
+
args: [{
|
|
176
|
+
selector: '[wattTooltip]',
|
|
177
|
+
exportAs: 'wattTooltip',
|
|
178
|
+
}]
|
|
179
|
+
}], propDecorators: { text: [{
|
|
180
|
+
type: Input,
|
|
181
|
+
args: ['wattTooltip']
|
|
182
|
+
}], position: [{
|
|
183
|
+
type: Input,
|
|
184
|
+
args: ['wattTooltipPosition']
|
|
185
|
+
}], variant: [{
|
|
186
|
+
type: Input,
|
|
187
|
+
args: ['wattTooltipVariant']
|
|
188
|
+
}] } });
|
|
189
|
+
|
|
190
|
+
//#region License
|
|
191
|
+
/**
|
|
192
|
+
* @license
|
|
193
|
+
* Copyright 2020 Energinet DataHub A/S
|
|
194
|
+
*
|
|
195
|
+
* Licensed under the Apache License, Version 2.0 (the "License2");
|
|
196
|
+
* you may not use this file except in compliance with the License.
|
|
197
|
+
* You may obtain a copy of the License at
|
|
198
|
+
*
|
|
199
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
200
|
+
*
|
|
201
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
202
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
203
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
204
|
+
* See the License for the specific language governing permissions and
|
|
205
|
+
* limitations under the License.
|
|
206
|
+
*/
|
|
207
|
+
//#endregion
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Generated bundle index. Do not edit.
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
export { WattTooltipDirective };
|
|
214
|
+
//# sourceMappingURL=energinet-watt-tooltip.mjs.map
|