@siemens/element-ng 49.14.0 → 51.0.0-rc.5
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/README.md +1 -1
- package/fesm2022/siemens-element-ng-about.mjs +41 -25
- package/fesm2022/siemens-element-ng-about.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-accordion.mjs +58 -40
- package/fesm2022/siemens-element-ng-accordion.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-action-modal.mjs +83 -53
- package/fesm2022/siemens-element-ng-action-modal.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-ag-grid.mjs +15 -12
- package/fesm2022/siemens-element-ng-ag-grid.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-application-header.mjs +176 -166
- package/fesm2022/siemens-element-ng-application-header.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-auto-collapsable-list.mjs +34 -28
- package/fesm2022/siemens-element-ng-auto-collapsable-list.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-autocomplete.mjs +27 -22
- package/fesm2022/siemens-element-ng-autocomplete.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-avatar.mjs +31 -21
- package/fesm2022/siemens-element-ng-avatar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-badge.mjs +9 -8
- package/fesm2022/siemens-element-ng-badge.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-breadcrumb-router.mjs +17 -14
- package/fesm2022/siemens-element-ng-breadcrumb-router.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-breadcrumb.mjs +21 -17
- package/fesm2022/siemens-element-ng-breadcrumb.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-card.mjs +71 -46
- package/fesm2022/siemens-element-ng-card.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-carousel.mjs +57 -33
- package/fesm2022/siemens-element-ng-carousel.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-chat-messages.mjs +181 -117
- package/fesm2022/siemens-element-ng-chat-messages.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-circle-status.mjs +39 -25
- package/fesm2022/siemens-element-ng-circle-status.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-color-picker.mjs +26 -17
- package/fesm2022/siemens-element-ng-color-picker.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-column-selection-dialog.mjs +56 -35
- package/fesm2022/siemens-element-ng-column-selection-dialog.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-common.mjs +12 -12
- package/fesm2022/siemens-element-ng-connection-strength.mjs +14 -12
- package/fesm2022/siemens-element-ng-connection-strength.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-content-action-bar.mjs +36 -27
- package/fesm2022/siemens-element-ng-content-action-bar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-copyright-notice.mjs +19 -14
- package/fesm2022/siemens-element-ng-copyright-notice.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-dashboard.mjs +335 -221
- package/fesm2022/siemens-element-ng-dashboard.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-datatable.mjs +8 -8
- package/fesm2022/siemens-element-ng-datatable.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-date-range-filter.mjs +119 -72
- package/fesm2022/siemens-element-ng-date-range-filter.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-datepicker.mjs +376 -244
- package/fesm2022/siemens-element-ng-datepicker.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-electron-titlebar.mjs +22 -17
- package/fesm2022/siemens-element-ng-electron-titlebar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-empty-state.mjs +15 -12
- package/fesm2022/siemens-element-ng-empty-state.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-file-uploader.mjs +105 -91
- package/fesm2022/siemens-element-ng-file-uploader.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-filter-bar.mjs +32 -24
- package/fesm2022/siemens-element-ng-filter-bar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-filtered-search.mjs +251 -153
- package/fesm2022/siemens-element-ng-filtered-search.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-footer.mjs +12 -10
- package/fesm2022/siemens-element-ng-footer.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-form.mjs +345 -113
- package/fesm2022/siemens-element-ng-form.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-formly-legacy.mjs +99 -0
- package/fesm2022/siemens-element-ng-formly-legacy.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-formly.mjs +222 -316
- package/fesm2022/siemens-element-ng-formly.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-header-dropdown.mjs +40 -30
- package/fesm2022/siemens-element-ng-header-dropdown.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-help-button.mjs +5 -5
- package/fesm2022/siemens-element-ng-help-button.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-icon.mjs +46 -47
- package/fesm2022/siemens-element-ng-icon.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-info-page.mjs +17 -11
- package/fesm2022/siemens-element-ng-info-page.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-inline-notification.mjs +19 -14
- package/fesm2022/siemens-element-ng-inline-notification.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-ip-input.mjs +25 -25
- package/fesm2022/siemens-element-ng-ip-input.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-landing-page.mjs +120 -74
- package/fesm2022/siemens-element-ng-landing-page.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-language-switcher.mjs +16 -12
- package/fesm2022/siemens-element-ng-language-switcher.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-link.mjs +31 -21
- package/fesm2022/siemens-element-ng-link.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-list-details.mjs +76 -56
- package/fesm2022/siemens-element-ng-list-details.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-loading-spinner.mjs +46 -63
- package/fesm2022/siemens-element-ng-loading-spinner.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-localization.mjs +14 -12
- package/fesm2022/siemens-element-ng-localization.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-main-detail-container.mjs +47 -30
- package/fesm2022/siemens-element-ng-main-detail-container.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-maplibre.mjs +42 -0
- package/fesm2022/siemens-element-ng-maplibre.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-markdown-renderer.mjs +6 -5
- package/fesm2022/siemens-element-ng-markdown-renderer.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-menu.mjs +56 -48
- package/fesm2022/siemens-element-ng-menu.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-modal.mjs +14 -11
- package/fesm2022/siemens-element-ng-modal.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-navbar-vertical-next.mjs +249 -204
- package/fesm2022/siemens-element-ng-navbar-vertical-next.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-navbar-vertical.mjs +120 -83
- package/fesm2022/siemens-element-ng-navbar-vertical.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-navbar.mjs +72 -45
- package/fesm2022/siemens-element-ng-navbar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-notification-item.mjs +19 -11
- package/fesm2022/siemens-element-ng-notification-item.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-number-input.mjs +40 -28
- package/fesm2022/siemens-element-ng-number-input.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-pagination.mjs +31 -20
- package/fesm2022/siemens-element-ng-pagination.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-password-strength.mjs +32 -23
- package/fesm2022/siemens-element-ng-password-strength.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-password-toggle.mjs +18 -13
- package/fesm2022/siemens-element-ng-password-toggle.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-phone-number.mjs +123 -139
- package/fesm2022/siemens-element-ng-phone-number.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-photo-upload.mjs +84 -51
- package/fesm2022/siemens-element-ng-photo-upload.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-pills-input.mjs +63 -58
- package/fesm2022/siemens-element-ng-pills-input.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-popover-legacy.mjs +43 -28
- package/fesm2022/siemens-element-ng-popover-legacy.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-popover.mjs +35 -27
- package/fesm2022/siemens-element-ng-popover.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-progressbar.mjs +23 -16
- package/fesm2022/siemens-element-ng-progressbar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-resize-observer.mjs +32 -43
- package/fesm2022/siemens-element-ng-resize-observer.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-result-details-list.mjs +12 -10
- package/fesm2022/siemens-element-ng-result-details-list.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-search-bar.mjs +38 -31
- package/fesm2022/siemens-element-ng-search-bar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-select.mjs +218 -163
- package/fesm2022/siemens-element-ng-select.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-shadow-root.mjs +3 -3
- package/fesm2022/siemens-element-ng-side-panel.mjs +128 -86
- package/fesm2022/siemens-element-ng-side-panel.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-skip-links.mjs +21 -24
- package/fesm2022/siemens-element-ng-skip-links.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-slider.mjs +44 -29
- package/fesm2022/siemens-element-ng-slider.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-split.mjs +273 -293
- package/fesm2022/siemens-element-ng-split.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-status-bar.mjs +65 -51
- package/fesm2022/siemens-element-ng-status-bar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-status-counter.mjs +15 -11
- package/fesm2022/siemens-element-ng-status-counter.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-status-toggle.mjs +26 -16
- package/fesm2022/siemens-element-ng-status-toggle.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-summary-chip.mjs +25 -16
- package/fesm2022/siemens-element-ng-summary-chip.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-summary-widget.mjs +27 -17
- package/fesm2022/siemens-element-ng-summary-widget.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-system-banner.mjs +11 -8
- package/fesm2022/siemens-element-ng-system-banner.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tabs-legacy.mjs +20 -17
- package/fesm2022/siemens-element-ng-tabs-legacy.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tabs.mjs +73 -70
- package/fesm2022/siemens-element-ng-tabs.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-theme.mjs +29 -6
- package/fesm2022/siemens-element-ng-theme.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-threshold.mjs +60 -41
- package/fesm2022/siemens-element-ng-threshold.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-toast-notification.mjs +45 -40
- package/fesm2022/siemens-element-ng-toast-notification.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tooltip.mjs +105 -82
- package/fesm2022/siemens-element-ng-tooltip.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tour.mjs +24 -18
- package/fesm2022/siemens-element-ng-tour.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-translate.mjs +0 -1
- package/fesm2022/siemens-element-ng-translate.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tree-view.mjs +96 -75
- package/fesm2022/siemens-element-ng-tree-view.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-typeahead.mjs +76 -70
- package/fesm2022/siemens-element-ng-typeahead.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-wizard.mjs +72 -48
- package/fesm2022/siemens-element-ng-wizard.mjs.map +1 -1
- package/formly-legacy/package.json +4 -0
- package/maplibre/package.json +4 -0
- package/maplibre/styles/_index.scss +1 -0
- package/maplibre/styles/maplibre-gl.scss +715 -0
- package/package.json +37 -23
- package/schematics/migration.json +4 -4
- package/schematics/migrations/data/class-member-replacement.js +1 -19
- package/schematics/migrations/data/component-property-names.js +1 -25
- package/schematics/migrations/data/element-class-changes.js +1 -28
- package/schematics/migrations/data/element-migration-data.js +2 -0
- package/schematics/migrations/data/element-selectors.js +1 -11
- package/schematics/migrations/data/index.js +0 -4
- package/schematics/migrations/data/migration-test-data.js +9 -6
- package/schematics/migrations/data/provider-function-removals.js +7 -0
- package/schematics/migrations/data/symbol-removals.js +7 -7
- package/schematics/migrations/data/symbol-renaming.js +1 -48
- package/schematics/migrations/element-migration/element-migration.js +3 -6
- package/schematics/migrations/utilities/import-removal.js +39 -0
- package/schematics/migrations/utilities/index.js +2 -0
- package/schematics/migrations/utilities/provider-function-removal.migration.js +116 -0
- package/schematics/ng-update/index.js +1 -1
- package/schematics/ng-update/migrate-split-sizes.js +105 -0
- package/schematics/ng-update/{migrate-to-v49.js → migrate-to-v51.js} +5 -3
- package/template-i18n.json +45 -47
- package/types/siemens-element-ng-application-header.d.ts +8 -28
- package/types/siemens-element-ng-breadcrumb.d.ts +1 -1
- package/types/siemens-element-ng-chat-messages.d.ts +11 -9
- package/types/siemens-element-ng-circle-status.d.ts +1 -1
- package/types/siemens-element-ng-content-action-bar.d.ts +1 -1
- package/types/siemens-element-ng-dashboard.d.ts +2 -2
- package/types/siemens-element-ng-date-range-filter.d.ts +1 -1
- package/types/siemens-element-ng-datepicker.d.ts +3 -14
- package/types/siemens-element-ng-electron-titlebar.d.ts +1 -1
- package/types/siemens-element-ng-file-uploader.d.ts +13 -31
- package/types/siemens-element-ng-filter-bar.d.ts +1 -1
- package/types/siemens-element-ng-filtered-search.d.ts +4 -4
- package/types/siemens-element-ng-form.d.ts +180 -44
- package/types/siemens-element-ng-formly-legacy.d.ts +40 -0
- package/types/siemens-element-ng-formly.d.ts +34 -167
- package/types/siemens-element-ng-icon.d.ts +2 -19
- package/types/siemens-element-ng-ip-input.d.ts +1 -1
- package/types/siemens-element-ng-landing-page.d.ts +2 -2
- package/types/siemens-element-ng-loading-spinner.d.ts +7 -17
- package/types/siemens-element-ng-maplibre.d.ts +26 -0
- package/types/siemens-element-ng-navbar-vertical-next.d.ts +86 -38
- package/types/siemens-element-ng-navbar-vertical.d.ts +1 -1
- package/types/siemens-element-ng-navbar.d.ts +3 -3
- package/types/siemens-element-ng-notification-item.d.ts +12 -0
- package/types/siemens-element-ng-phone-number.d.ts +5 -8
- package/types/siemens-element-ng-photo-upload.d.ts +4 -4
- package/types/siemens-element-ng-resize-observer.d.ts +0 -17
- package/types/siemens-element-ng-search-bar.d.ts +1 -1
- package/types/siemens-element-ng-select.d.ts +1 -1
- package/types/siemens-element-ng-side-panel.d.ts +3 -3
- package/types/siemens-element-ng-split.d.ts +99 -70
- package/types/siemens-element-ng-status-bar.d.ts +5 -13
- package/types/siemens-element-ng-status-counter.d.ts +1 -1
- package/types/siemens-element-ng-tabs.d.ts +1 -2
- package/types/siemens-element-ng-theme.d.ts +12 -2
- package/types/siemens-element-ng-threshold.d.ts +1 -1
- package/types/siemens-element-ng-toast-notification.d.ts +0 -1
- package/types/siemens-element-ng-tooltip.d.ts +7 -7
- package/types/siemens-element-ng-translate.d.ts +2 -5
- package/fesm2022/siemens-element-ng-icon-status.mjs +0 -46
- package/fesm2022/siemens-element-ng-icon-status.mjs.map +0 -1
- package/fesm2022/siemens-element-ng-sort-bar.mjs +0 -99
- package/fesm2022/siemens-element-ng-sort-bar.mjs.map +0 -1
- package/icon-status/package.json +0 -4
- package/schematics/vitest-setup.js +0 -5
- package/sort-bar/package.json +0 -4
- package/types/siemens-element-ng-icon-status.d.ts +0 -25
- package/types/siemens-element-ng-sort-bar.d.ts +0 -59
- /package/{LICENSE.md → LICENSE} +0 -0
|
@@ -1,21 +1,61 @@
|
|
|
1
1
|
import { NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { input, booleanAttribute, inject, computed, ChangeDetectionStrategy, Component, signal, InjectionToken, Injectable, contentChild,
|
|
3
|
+
import { input, booleanAttribute, inject, computed, ChangeDetectionStrategy, Component, signal, InjectionToken, Injectable, contentChild, isSignal, DestroyRef, effect, ElementRef, Injector, Directive, NgModule } from '@angular/core';
|
|
4
4
|
import { SiResponsiveContainerDirective } from '@siemens/element-ng/resize-observer';
|
|
5
|
-
import {
|
|
5
|
+
import { FormField, provideSignalFormsConfig } from '@angular/forms/signals';
|
|
6
6
|
import { SiTranslatePipe, t } from '@siemens/element-translate-ng/translate';
|
|
7
|
+
import { NG_STATUS_CLASSES } from '@angular/forms/signals/compat';
|
|
8
|
+
import { NgControl, RequiredValidator, FormControl } from '@angular/forms';
|
|
7
9
|
import { SiTooltipService } from '@siemens/element-ng/tooltip';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Copyright (c) Siemens 2016 - 2026
|
|
11
13
|
* SPDX-License-Identifier: MIT
|
|
12
14
|
*/
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated This component should no longer be used.
|
|
17
|
+
*
|
|
18
|
+
* When providing a form wide error mapper, use the {@link provideFormValidationErrorMapper}.
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { provideFormValidationErrorMapper } form '@siemens/element-ng/forms'
|
|
21
|
+
*
|
|
22
|
+
* @Component({
|
|
23
|
+
* template: `<form>...</form>`
|
|
24
|
+
* providers: [provideFormValidationErrorMapper({
|
|
25
|
+
* 'name.required': 'CUSTOM_REQUIRED_ERROR'
|
|
26
|
+
* })]
|
|
27
|
+
* })
|
|
28
|
+
* class MyFormComponent {}
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* When using the column layout, use the `form-col-layout` classes.
|
|
32
|
+
*
|
|
33
|
+
* ```html
|
|
34
|
+
* <!-- Responsive column layout -->
|
|
35
|
+
* <form class="responsive-form-col-layout">...</form>
|
|
36
|
+
* <!-- Always column layout -->
|
|
37
|
+
* <form class="form-col-layout">...</form>
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* For a custom breakpoint use the SCSS mixin:
|
|
41
|
+
*
|
|
42
|
+
* ```scss
|
|
43
|
+
* @use '@siemens/element-theme/src/styles/bootstrap/mixins/form-layout';
|
|
44
|
+
*
|
|
45
|
+
* // Custom responsive breakpoint
|
|
46
|
+
* .custom-form-col-layout {
|
|
47
|
+
* // Above 400px the column layout is used
|
|
48
|
+
* @include form-layout.responsive-form-col-layout(400px);
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
13
52
|
class SiFormContainerComponent {
|
|
14
53
|
/**
|
|
15
54
|
* Set the form entity to the container to enable the overall form validation on in
|
|
16
55
|
* the form container edit panel.
|
|
17
56
|
*/
|
|
18
|
-
form = input(
|
|
57
|
+
form = input(/* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [undefined, { debugName: "form" }] : /* istanbul ignore next */ []));
|
|
19
59
|
/**
|
|
20
60
|
* A form container in readonly mode is only displaying the form content without ability
|
|
21
61
|
* to change it. The edit panel with typically save and cancel buttons is hidden. Set
|
|
@@ -23,13 +63,14 @@ class SiFormContainerComponent {
|
|
|
23
63
|
*
|
|
24
64
|
* @defaultValue false
|
|
25
65
|
*/
|
|
26
|
-
readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : {}), transform: booleanAttribute });
|
|
66
|
+
readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
27
67
|
/**
|
|
28
68
|
* The container hosts the form within a siResizeContainer to configure the breakpoint for
|
|
29
69
|
* different screen sizes. Optionally, change the container breakpoints with the contentContainerBreakpoints
|
|
30
70
|
* input.
|
|
31
71
|
*/
|
|
32
|
-
contentContainerBreakpoints = input(
|
|
72
|
+
contentContainerBreakpoints = input(/* @ts-ignore */
|
|
73
|
+
...(ngDevMode ? [undefined, { debugName: "contentContainerBreakpoints" }] : /* istanbul ignore next */ []));
|
|
33
74
|
/**
|
|
34
75
|
* In some scenarios, one may not want the form container to be responsible for the layout relevant
|
|
35
76
|
* `si-container-[xs|...]` classes, but let this be done by a different, nested component, e.g. by a
|
|
@@ -37,7 +78,7 @@ class SiFormContainerComponent {
|
|
|
37
78
|
*
|
|
38
79
|
* @defaultValue false
|
|
39
80
|
*/
|
|
40
|
-
disableContainerBreakpoints = input(false, { ...(ngDevMode ? { debugName: "disableContainerBreakpoints" } : {}), transform: booleanAttribute });
|
|
81
|
+
disableContainerBreakpoints = input(false, { ...(ngDevMode ? { debugName: "disableContainerBreakpoints" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
41
82
|
/**
|
|
42
83
|
* Every validation error has an errorCode. This map holds translate keys for error codes. The keys can
|
|
43
84
|
* be used to display a translated message for each validation error. The defaults old english readable
|
|
@@ -45,7 +86,8 @@ class SiFormContainerComponent {
|
|
|
45
86
|
*
|
|
46
87
|
* Use the input to set your own translate keys for the form validators you need.
|
|
47
88
|
*/
|
|
48
|
-
errorCodeTranslateKeyMap = input(
|
|
89
|
+
errorCodeTranslateKeyMap = input(/* @ts-ignore */
|
|
90
|
+
...(ngDevMode ? [undefined, { debugName: "errorCodeTranslateKeyMap" }] : /* istanbul ignore next */ []));
|
|
49
91
|
/**
|
|
50
92
|
* A map the maps from control names of the form to their translate keys.
|
|
51
93
|
* The initial map is empty and the user is responsible to add the required
|
|
@@ -56,19 +98,21 @@ class SiFormContainerComponent {
|
|
|
56
98
|
* new Map<string, string>()
|
|
57
99
|
* ```
|
|
58
100
|
*/
|
|
59
|
-
controlNameTranslateKeyMap = input(new Map(),
|
|
101
|
+
controlNameTranslateKeyMap = input(new Map(), /* @ts-ignore */
|
|
102
|
+
...(ngDevMode ? [{ debugName: "controlNameTranslateKeyMap" }] : /* istanbul ignore next */ []));
|
|
60
103
|
/**
|
|
61
104
|
* Disables the automatic error printing in all nested {@link SiFormItemComponent}. Error printing will be enabled by default in v46.
|
|
62
105
|
*
|
|
63
106
|
* @defaultValue false
|
|
64
107
|
*/
|
|
65
|
-
disableErrorPrinting = input(false, { ...(ngDevMode ? { debugName: "disableErrorPrinting" } : {}), transform: booleanAttribute });
|
|
108
|
+
disableErrorPrinting = input(false, { ...(ngDevMode ? { debugName: "disableErrorPrinting" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
66
109
|
/**
|
|
67
110
|
* A custom width value to be applied to all labels.
|
|
68
111
|
*
|
|
69
112
|
* @example labelWidth="100px".
|
|
70
113
|
*/
|
|
71
|
-
labelWidth = input(
|
|
114
|
+
labelWidth = input(/* @ts-ignore */
|
|
115
|
+
...(ngDevMode ? [undefined, { debugName: "labelWidth" }] : /* istanbul ignore next */ []));
|
|
72
116
|
hasParentContainer = !!inject(SiFormContainerComponent, {
|
|
73
117
|
optional: true,
|
|
74
118
|
skipSelf: true
|
|
@@ -86,7 +130,8 @@ class SiFormContainerComponent {
|
|
|
86
130
|
return {
|
|
87
131
|
...customMapper
|
|
88
132
|
};
|
|
89
|
-
},
|
|
133
|
+
}, /* @ts-ignore */
|
|
134
|
+
...(ngDevMode ? [{ debugName: "formErrorMapper" }] : /* istanbul ignore next */ []));
|
|
90
135
|
/**
|
|
91
136
|
* Indicates whether the user interacted with the form.
|
|
92
137
|
* @returns `true`, if the user selected at least one form element and
|
|
@@ -121,12 +166,12 @@ class SiFormContainerComponent {
|
|
|
121
166
|
}
|
|
122
167
|
return controlNameTranslateKeyMap.get(controlName) ?? controlName;
|
|
123
168
|
}
|
|
124
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
125
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
169
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
170
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: SiFormContainerComponent, isStandalone: true, selector: "si-form-container", inputs: { form: { classPropertyName: "form", publicName: "form", isSignal: true, isRequired: false, transformFunction: null }, readonly: { classPropertyName: "readonly", publicName: "readonly", isSignal: true, isRequired: false, transformFunction: null }, contentContainerBreakpoints: { classPropertyName: "contentContainerBreakpoints", publicName: "contentContainerBreakpoints", isSignal: true, isRequired: false, transformFunction: null }, disableContainerBreakpoints: { classPropertyName: "disableContainerBreakpoints", publicName: "disableContainerBreakpoints", isSignal: true, isRequired: false, transformFunction: null }, errorCodeTranslateKeyMap: { classPropertyName: "errorCodeTranslateKeyMap", publicName: "errorCodeTranslateKeyMap", isSignal: true, isRequired: false, transformFunction: null }, controlNameTranslateKeyMap: { classPropertyName: "controlNameTranslateKeyMap", publicName: "controlNameTranslateKeyMap", isSignal: true, isRequired: false, transformFunction: null }, disableErrorPrinting: { classPropertyName: "disableErrorPrinting", publicName: "disableErrorPrinting", isSignal: true, isRequired: false, transformFunction: null }, labelWidth: { classPropertyName: "labelWidth", publicName: "labelWidth", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "style.--si-form-label-width": "labelWidth()" } }, ngImport: i0, template: "<div class=\"d-flex flex-column align-content-stretch flex-grow-1 flex-shrink-1\">\n @if (disableContainerBreakpoints() || hasParentContainer) {\n <div class=\"flex-grow-1 flex-shrink-1\">\n <ng-container *ngTemplateOutlet=\"contentTemplate\" />\n </div>\n } @else {\n <div\n class=\"flex-grow-1 flex-shrink-1\"\n siResponsiveContainer\n [breakpoints]=\"contentContainerBreakpoints()\"\n >\n <ng-container *ngTemplateOutlet=\"contentTemplate\" />\n </div>\n }\n\n @if (!readonly()) {\n <div class=\"d-flex flex-row flex-nowrap flex-grow-0 flex-shrink-0 py-4\">\n <div\n class=\"d-flex flex-grow-1 flex-shrink-1 justify-content-end text-end overflow-hidden mx-6 my-auto\"\n [class.text-success]=\"validFormContainerMessage\"\n [class.text-danger]=\"invalidFormContainerMessage\"\n >\n <ng-content select=\"[si-form-container-message]\" />\n </div>\n\n <div class=\"m-auto flex-grow-0 flex-shrink-0\">\n <ng-content select=\"[si-form-container-buttons]\" />\n </div>\n </div>\n }\n</div>\n\n<ng-template #contentTemplate>\n <ng-content select=\"[si-form-container-content]\" />\n</ng-template>\n", styles: [":host{display:flex;flex:1 1 auto;flex-direction:column}:host ::slotted([si-form-container-message]),:host ::ng-deep [si-form-container-message]{max-inline-size:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.form-container-edit-help{text-decoration:underline;cursor:pointer}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "directive", type: SiResponsiveContainerDirective, selector: "[siResponsiveContainer]", inputs: ["resizeThrottle", "breakpoints"], exportAs: ["siResponsiveContainer"] }], changeDetection: i0.ChangeDetectionStrategy.Eager });
|
|
126
171
|
}
|
|
127
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
172
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormContainerComponent, decorators: [{
|
|
128
173
|
type: Component,
|
|
129
|
-
args: [{ selector: 'si-form-container', imports: [NgTemplateOutlet, SiResponsiveContainerDirective], changeDetection: ChangeDetectionStrategy.
|
|
174
|
+
args: [{ selector: 'si-form-container', imports: [NgTemplateOutlet, SiResponsiveContainerDirective], changeDetection: ChangeDetectionStrategy.Eager, host: {
|
|
130
175
|
'[style.--si-form-label-width]': 'labelWidth()'
|
|
131
176
|
}, template: "<div class=\"d-flex flex-column align-content-stretch flex-grow-1 flex-shrink-1\">\n @if (disableContainerBreakpoints() || hasParentContainer) {\n <div class=\"flex-grow-1 flex-shrink-1\">\n <ng-container *ngTemplateOutlet=\"contentTemplate\" />\n </div>\n } @else {\n <div\n class=\"flex-grow-1 flex-shrink-1\"\n siResponsiveContainer\n [breakpoints]=\"contentContainerBreakpoints()\"\n >\n <ng-container *ngTemplateOutlet=\"contentTemplate\" />\n </div>\n }\n\n @if (!readonly()) {\n <div class=\"d-flex flex-row flex-nowrap flex-grow-0 flex-shrink-0 py-4\">\n <div\n class=\"d-flex flex-grow-1 flex-shrink-1 justify-content-end text-end overflow-hidden mx-6 my-auto\"\n [class.text-success]=\"validFormContainerMessage\"\n [class.text-danger]=\"invalidFormContainerMessage\"\n >\n <ng-content select=\"[si-form-container-message]\" />\n </div>\n\n <div class=\"m-auto flex-grow-0 flex-shrink-0\">\n <ng-content select=\"[si-form-container-buttons]\" />\n </div>\n </div>\n }\n</div>\n\n<ng-template #contentTemplate>\n <ng-content select=\"[si-form-container-content]\" />\n</ng-template>\n", styles: [":host{display:flex;flex:1 1 auto;flex-direction:column}:host ::slotted([si-form-container-message]),:host ::ng-deep [si-form-container-message]{max-inline-size:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.form-container-edit-help{text-decoration:underline;cursor:pointer}\n"] }]
|
|
132
177
|
}], propDecorators: { form: [{ type: i0.Input, args: [{ isSignal: true, alias: "form", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], contentContainerBreakpoints: [{ type: i0.Input, args: [{ isSignal: true, alias: "contentContainerBreakpoints", required: false }] }], disableContainerBreakpoints: [{ type: i0.Input, args: [{ isSignal: true, alias: "disableContainerBreakpoints", required: false }] }], errorCodeTranslateKeyMap: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorCodeTranslateKeyMap", required: false }] }], controlNameTranslateKeyMap: [{ type: i0.Input, args: [{ isSignal: true, alias: "controlNameTranslateKeyMap", required: false }] }], disableErrorPrinting: [{ type: i0.Input, args: [{ isSignal: true, alias: "disableErrorPrinting", required: false }] }], labelWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelWidth", required: false }] }] } });
|
|
@@ -138,56 +183,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
138
183
|
class SiFormFieldsetComponent {
|
|
139
184
|
static labelIdCounter = 0;
|
|
140
185
|
/** The label for the entire fieldset. */
|
|
141
|
-
label = input.required(
|
|
186
|
+
label = input.required(/* @ts-ignore */
|
|
187
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
142
188
|
/** Overrides the parent label width. */
|
|
143
|
-
labelWidth = input(
|
|
189
|
+
labelWidth = input(/* @ts-ignore */
|
|
190
|
+
...(ngDevMode ? [undefined, { debugName: "labelWidth" }] : /* istanbul ignore next */ []));
|
|
144
191
|
/**
|
|
145
192
|
* Adds a required marker to the label
|
|
146
193
|
*
|
|
147
194
|
* @defaultValue false
|
|
148
195
|
*/
|
|
149
|
-
required = input(false, { ...(ngDevMode ? { debugName: "required" } : {}), transform: booleanAttribute });
|
|
196
|
+
required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
150
197
|
/**
|
|
151
198
|
* Switches all child inputs to inline mode
|
|
152
199
|
*
|
|
153
200
|
* @defaultValue false
|
|
154
201
|
*/
|
|
155
|
-
inline = input(false, { ...(ngDevMode ? { debugName: "inline" } : {}), transform: booleanAttribute });
|
|
156
|
-
formItems = signal([],
|
|
202
|
+
inline = input(false, { ...(ngDevMode ? { debugName: "inline" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
203
|
+
formItems = signal([], /* @ts-ignore */
|
|
204
|
+
...(ngDevMode ? [{ debugName: "formItems" }] : /* istanbul ignore next */ []));
|
|
157
205
|
/** @internal */
|
|
158
206
|
hasOnlyRadios = computed(() => {
|
|
159
207
|
// Check if the fieldset only contains radio buttons.
|
|
160
|
-
// We can safely assume that, if all items
|
|
208
|
+
// We can safely assume that, if all items reference the same control and if there are at least 2 items.
|
|
161
209
|
const items = this.formItems();
|
|
162
210
|
if (items.length > 1) {
|
|
163
|
-
const first = items[0];
|
|
164
|
-
return items.every(item => item.
|
|
211
|
+
const first = items[0].control();
|
|
212
|
+
return first != null && items.every(item => item.control() === first);
|
|
165
213
|
}
|
|
166
214
|
return false;
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
touched =
|
|
172
|
-
|
|
215
|
+
}, /* @ts-ignore */
|
|
216
|
+
...(ngDevMode ? [{ debugName: "hasOnlyRadios" }] : /* istanbul ignore next */ []));
|
|
217
|
+
errors = computed(() => this.formItems()[0].errors(), /* @ts-ignore */
|
|
218
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
219
|
+
touched = computed(() => this.formItems().some(item => item.touched()), /* @ts-ignore */
|
|
220
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
221
|
+
isRequired = computed(() => this.required() || (this.hasOnlyRadios() && this.formItems().every(item => item.required())), /* @ts-ignore */
|
|
222
|
+
...(ngDevMode ? [{ debugName: "isRequired" }] : /* istanbul ignore next */ []));
|
|
173
223
|
labelId = `__si-form-fieldset-label-${SiFormFieldsetComponent.labelIdCounter++}`;
|
|
174
|
-
ngDoCheck() {
|
|
175
|
-
this.touched.set(this.formItems().some(item => item.ngControl()?.touched));
|
|
176
|
-
}
|
|
177
224
|
/** @internal */
|
|
178
|
-
|
|
225
|
+
registerControl(item) {
|
|
179
226
|
this.formItems.update(items => [...items, item]);
|
|
180
227
|
}
|
|
181
228
|
/** @internal */
|
|
182
|
-
|
|
229
|
+
unregisterControl(item) {
|
|
183
230
|
this.formItems.update(items => items.filter(i => i !== item));
|
|
184
231
|
}
|
|
185
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
186
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
232
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormFieldsetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
233
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: SiFormFieldsetComponent, isStandalone: true, selector: "si-form-fieldset", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, labelWidth: { classPropertyName: "labelWidth", publicName: "labelWidth", isSignal: true, isRequired: false, transformFunction: null }, required: { classPropertyName: "required", publicName: "required", isSignal: true, isRequired: false, transformFunction: null }, inline: { classPropertyName: "inline", publicName: "inline", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "group" }, properties: { "style.--si-form-label-width": "labelWidth()", "attr.aria-labelledby": "labelId" }, classAttribute: "si-form-input" }, ngImport: i0, template: "<div class=\"form-label d-flex gap-2\">\n <span [class.required]=\"isRequired()\" [id]=\"labelId\">{{ label() | translate }}</span>\n <ng-content select=\"[si-help-button]\" />\n</div>\n<div>\n <ng-content />\n @if (hasOnlyRadios()) {\n <div class=\"invalid-feedback\" [class.d-block]=\"touched()\">\n @for (error of errors(); track error) {\n <div>\n {{ error.message | translate: error.params }}\n </div>\n }\n </div>\n }\n</div>\n", styles: [":host.si-form-input{display:flex;flex-direction:column;margin-block-end:12px}:host.si-form-input .form-item-content{flex-grow:1}.form-label:empty{display:none}:host(.form-check):not(.form-check-inline){display:block}:host(.form-check):has(.form-check){padding-block:0}:host-context(.si-container-sm) :host.si-form-input,:host-context(.si-container-md) :host.si-form-input,:host-context(.si-container-lg) :host.si-form-input,:host-context(.si-container-xl) :host.si-form-input,:host-context(.si-container-xxl) :host.si-form-input{display:flex;flex-direction:row;align-items:center}:host-context(.si-container-sm) .form-label,:host-context(.si-container-md) .form-label,:host-context(.si-container-lg) .form-label,:host-context(.si-container-xl) .form-label,:host-context(.si-container-xxl) .form-label{align-self:start;padding-block:8px;padding-inline:16px;inline-size:var(--si-form-label-width, 16.6666666667%);line-height:1rem}:host-context(.si-container-sm) .form-label:empty,:host-context(.si-container-md) .form-label:empty,:host-context(.si-container-lg) .form-label:empty,:host-context(.si-container-xl) .form-label:empty,:host-context(.si-container-xxl) .form-label:empty{display:block}:host-context(.si-container-sm) :host-context(si-form-fieldset) .form-label,:host-context(.si-container-md) :host-context(si-form-fieldset) .form-label,:host-context(.si-container-lg) :host-context(si-form-fieldset) .form-label,:host-context(.si-container-xl) :host-context(si-form-fieldset) .form-label,:host-context(.si-container-xxl) :host-context(si-form-fieldset) .form-label{padding-block:2px 0}:host-context(.si-container-sm) :host(.form-check) .form-label,:host-context(.si-container-md) :host(.form-check) .form-label,:host-context(.si-container-lg) :host(.form-check) .form-label,:host-context(.si-container-xl) :host(.form-check) .form-label,:host-context(.si-container-xxl) :host(.form-check) .form-label{padding-block:2px}\n"], dependencies: [{ kind: "pipe", type: SiTranslatePipe, name: "translate" }] });
|
|
187
234
|
}
|
|
188
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
235
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormFieldsetComponent, decorators: [{
|
|
189
236
|
type: Component,
|
|
190
|
-
args: [{ selector: 'si-form-fieldset', imports: [SiTranslatePipe],
|
|
237
|
+
args: [{ selector: 'si-form-fieldset', imports: [SiTranslatePipe], host: {
|
|
191
238
|
role: 'group',
|
|
192
239
|
class: 'si-form-input',
|
|
193
240
|
'[style.--si-form-label-width]': 'labelWidth()',
|
|
@@ -242,7 +289,7 @@ const buildDefaults = () => ({
|
|
|
242
289
|
// Various
|
|
243
290
|
email: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.EMAIL:Invalid email address`),
|
|
244
291
|
numberFormat: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.NUMBER_FORMAT:Number required`),
|
|
245
|
-
pattern: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.PATTERN:
|
|
292
|
+
pattern: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.PATTERN:Required value format not fulfilled`),
|
|
246
293
|
required: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.REQUIRED:Required`),
|
|
247
294
|
requiredTrue: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.REQUIRED_TRUE:Required`)
|
|
248
295
|
});
|
|
@@ -267,6 +314,30 @@ class SiFormValidationErrorService {
|
|
|
267
314
|
constructor(errorMapper) {
|
|
268
315
|
this.errorMapper = errorMapper;
|
|
269
316
|
}
|
|
317
|
+
/**
|
|
318
|
+
* Resolves validation errors for Angular signal forms.
|
|
319
|
+
*
|
|
320
|
+
* If the validation error has no message associated, the resolution flow of {@link resolveErrors} is followed.
|
|
321
|
+
*
|
|
322
|
+
* @param state - the fieldState of the formfield.
|
|
323
|
+
*/
|
|
324
|
+
resolveFormFieldErrors(state) {
|
|
325
|
+
return state.errors().map(error => {
|
|
326
|
+
const { message, kind, fieldTree, formField, ...rawErrorParams } = error;
|
|
327
|
+
const errorParams = this.getErrorParams(rawErrorParams);
|
|
328
|
+
if (!message) {
|
|
329
|
+
return this.resolveError(kind, state.name(), errorParams);
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
return { message, key: kind, params: errorParams };
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
/** Returns legacy reactive-form parameters stored in `context`, or the signal-form error. */
|
|
337
|
+
getErrorParams(error) {
|
|
338
|
+
const { context } = error;
|
|
339
|
+
return context ?? error;
|
|
340
|
+
}
|
|
270
341
|
/**
|
|
271
342
|
* Resolves the provided form errors to a list of {@link SiFormError}.
|
|
272
343
|
* To resolution order is:
|
|
@@ -306,10 +377,10 @@ class SiFormValidationErrorService {
|
|
|
306
377
|
}
|
|
307
378
|
return undefined;
|
|
308
379
|
}
|
|
309
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
310
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
380
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormValidationErrorService, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
|
|
381
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormValidationErrorService, providedIn: 'root', useFactory: () => new SiFormValidationErrorService(buildDefaults()) });
|
|
311
382
|
}
|
|
312
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
383
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormValidationErrorService, decorators: [{
|
|
313
384
|
type: Injectable,
|
|
314
385
|
args: [{
|
|
315
386
|
providedIn: 'root',
|
|
@@ -317,6 +388,160 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
317
388
|
}]
|
|
318
389
|
}], ctorParameters: () => [{ type: undefined }] });
|
|
319
390
|
|
|
391
|
+
/**
|
|
392
|
+
* Copyright (c) Siemens 2016 - 2026
|
|
393
|
+
* SPDX-License-Identifier: MIT
|
|
394
|
+
*/
|
|
395
|
+
/**
|
|
396
|
+
* Constructs a full form field including error messages, labels and aria-* attributes.
|
|
397
|
+
* It must be used with Angular's signal forms.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```html
|
|
401
|
+
* <si-form-field label="Name">
|
|
402
|
+
* <input class="form-control" [formField]="form.name" />
|
|
403
|
+
*
|
|
404
|
+
* <!-- Optional help button -->
|
|
405
|
+
* <button
|
|
406
|
+
* si-help-button
|
|
407
|
+
* type="button"
|
|
408
|
+
* siHelpTitle="Help for name"
|
|
409
|
+
* siHelpContent="The context help description"
|
|
410
|
+
* >More information about the name</button>
|
|
411
|
+
* </si-form-field>
|
|
412
|
+
* ```
|
|
413
|
+
*/
|
|
414
|
+
class SiFormFieldComponent {
|
|
415
|
+
static idCounter = 0;
|
|
416
|
+
/**
|
|
417
|
+
* The label to be displayed in the form field.
|
|
418
|
+
* It will be translated if a translation key is available.
|
|
419
|
+
*/
|
|
420
|
+
label = input.required(/* @ts-ignore */
|
|
421
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
422
|
+
formField = contentChild.required(FormField, /* @ts-ignore */
|
|
423
|
+
...(ngDevMode ? [{ debugName: "formField" }] : /* istanbul ignore next */ []));
|
|
424
|
+
fieldControl = contentChild(SI_FORM_ITEM_CONTROL, { ...(ngDevMode ? { debugName: "fieldControl" } : /* istanbul ignore next */ {}), descendants: true });
|
|
425
|
+
fieldset = inject(SiFormFieldsetComponent, { optional: true });
|
|
426
|
+
validationErrorService = inject(SiFormValidationErrorService);
|
|
427
|
+
generatedId = `__si-form-field-${SiFormFieldComponent.idCounter++}`;
|
|
428
|
+
/** The id of the connected control, used for the label's `for` attribute. */
|
|
429
|
+
controlId = computed(() => {
|
|
430
|
+
const id = this.fieldControl()?.id;
|
|
431
|
+
return (isSignal(id) ? id() : id) ?? (this.formField().element.id || this.generatedId);
|
|
432
|
+
}, /* @ts-ignore */
|
|
433
|
+
...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
|
|
434
|
+
errormessageId = computed(() => {
|
|
435
|
+
const id = this.fieldControl()?.errormessageId;
|
|
436
|
+
return (isSignal(id) ? id() : id) ?? `${this.controlId()}-errormessage`;
|
|
437
|
+
}, /* @ts-ignore */
|
|
438
|
+
...(ngDevMode ? [{ debugName: "errormessageId" }] : /* istanbul ignore next */ []));
|
|
439
|
+
labelledby = computed(() => {
|
|
440
|
+
const labelledby = this.fieldControl()?.labelledby;
|
|
441
|
+
return isSignal(labelledby) ? labelledby() : labelledby;
|
|
442
|
+
}, /* @ts-ignore */
|
|
443
|
+
...(ngDevMode ? [{ debugName: "labelledby" }] : /* istanbul ignore next */ []));
|
|
444
|
+
/** Whether the connected control is a form-check (checkbox, radio or switch). */
|
|
445
|
+
isFormCheck = computed(() => this.fieldControl()?.isFormCheck ??
|
|
446
|
+
this.formField().element.classList.contains('form-check-input'), /* @ts-ignore */
|
|
447
|
+
...(ngDevMode ? [{ debugName: "isFormCheck" }] : /* istanbul ignore next */ []));
|
|
448
|
+
fieldState = computed(() => this.formField().state(), /* @ts-ignore */
|
|
449
|
+
...(ngDevMode ? [{ debugName: "fieldState" }] : /* istanbul ignore next */ []));
|
|
450
|
+
/** @internal */
|
|
451
|
+
control = computed(() => this.fieldState().fieldTree, /* @ts-ignore */
|
|
452
|
+
...(ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []));
|
|
453
|
+
/** @internal */
|
|
454
|
+
required = computed(() => this.fieldState().required(), /* @ts-ignore */
|
|
455
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
456
|
+
/** @internal */
|
|
457
|
+
showRequired = computed(() => this.required() && !this.isPartOfRadioGroup(), /* @ts-ignore */
|
|
458
|
+
...(ngDevMode ? [{ debugName: "showRequired" }] : /* istanbul ignore next */ []));
|
|
459
|
+
invalid = computed(() => {
|
|
460
|
+
const state = this.fieldState();
|
|
461
|
+
return state.touched() && state.invalid();
|
|
462
|
+
}, /* @ts-ignore */
|
|
463
|
+
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
464
|
+
/** @internal */
|
|
465
|
+
touched = computed(() => this.fieldState().touched(), /* @ts-ignore */
|
|
466
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
467
|
+
isPartOfRadioGroup = computed(() => this.fieldset?.hasOnlyRadios() ?? false, /* @ts-ignore */
|
|
468
|
+
...(ngDevMode ? [{ debugName: "isPartOfRadioGroup" }] : /* istanbul ignore next */ []));
|
|
469
|
+
/** @internal */
|
|
470
|
+
errors = computed(() => {
|
|
471
|
+
const state = this.fieldState();
|
|
472
|
+
if (!state.touched()) {
|
|
473
|
+
return [];
|
|
474
|
+
}
|
|
475
|
+
return this.validationErrorService.resolveFormFieldErrors(state);
|
|
476
|
+
}, /* @ts-ignore */
|
|
477
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
478
|
+
constructor() {
|
|
479
|
+
if (this.fieldset) {
|
|
480
|
+
this.fieldset.registerControl(this);
|
|
481
|
+
inject(DestroyRef).onDestroy(() => this.fieldset.unregisterControl(this));
|
|
482
|
+
}
|
|
483
|
+
effect(() => this.syncControlId());
|
|
484
|
+
effect(() => this.syncErrorDescription());
|
|
485
|
+
effect(() => this.syncInvalidState());
|
|
486
|
+
}
|
|
487
|
+
syncControlId() {
|
|
488
|
+
const element = this.formField().element;
|
|
489
|
+
if (!element.id) {
|
|
490
|
+
element.id = this.generatedId;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
/** Associates the error messages with the projected control for assistive technologies. */
|
|
494
|
+
syncErrorDescription() {
|
|
495
|
+
this.formField().element.setAttribute('aria-describedby', this.errormessageId());
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Reflects the validation state onto the projected control via `aria-invalid`. This is needed
|
|
499
|
+
* because signal forms does not set `aria-invalid`, and the native `:user-invalid` pseudo-class
|
|
500
|
+
* ignores `markAsTouched()`. The matching `.ng-invalid`/`.ng-touched` classes that drive the
|
|
501
|
+
* styling are added by signal forms itself, see `provideSiFormFieldConfig()`.
|
|
502
|
+
*/
|
|
503
|
+
syncInvalidState() {
|
|
504
|
+
const element = this.formField().element;
|
|
505
|
+
if (this.invalid()) {
|
|
506
|
+
element.setAttribute('aria-invalid', 'true');
|
|
507
|
+
}
|
|
508
|
+
else {
|
|
509
|
+
element.removeAttribute('aria-invalid');
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
513
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: SiFormFieldComponent, isStandalone: true, selector: "si-form-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "class.required": "showRequired()", "class.form-check": "isFormCheck()", "class.form-check-inline": "fieldset?.inline()", "class.si-form-input": "!fieldset" } }, queries: [{ propertyName: "formField", first: true, predicate: FormField, descendants: true, isSignal: true }, { propertyName: "fieldControl", first: true, predicate: SI_FORM_ITEM_CONTROL, descendants: true, isSignal: true }], ngImport: i0, template: "@if (!isFormCheck()) {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\n} @else if (!fieldset) {\n <!-- Empty spacer so the control aligns with the label column in form-col-layout. -->\n <div class=\"form-label\"></div>\n}\n<div class=\"form-item-content\">\n <ng-content />\n @if (isFormCheck()) {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\n }\n @if (!isPartOfRadioGroup()) {\n <ng-container [ngTemplateOutlet]=\"feedbackTemplate\" />\n }\n</div>\n\n<ng-template #labelTemplate>\n <div\n class=\"d-flex gap-2\"\n [class.form-label]=\"!isFormCheck()\"\n [class.form-check-label]=\"isFormCheck()\"\n >\n @if (labelledby()) {\n <span [id]=\"labelledby()\" [class.required]=\"showRequired()\">{{ label() | translate }}</span>\n } @else {\n <label [for]=\"controlId()\" [class.required]=\"showRequired()\">{{ label() | translate }}</label>\n }\n <ng-content select=\"[si-help-button]\" />\n </div>\n</ng-template>\n\n<ng-template #feedbackTemplate>\n <div class=\"invalid-feedback\" [class.d-block]=\"errors().length\" [attr.id]=\"errormessageId()\">\n @for (error of errors(); track $index) {\n <div>\n {{ error.message ?? error.key | translate: error.params }}\n </div>\n }\n </div>\n</ng-template>\n", styles: [":host{margin-block-end:12px}:host-context(si-form-fieldset){margin-block-end:0}:host(:not(.form-check)){display:flex;flex-direction:column}:host(:not(.form-check)) .form-item-content{flex-grow:1}.form-label:empty{display:none}:host(.form-check:not(.form-check-inline)){display:block}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: SiTranslatePipe, name: "translate" }] });
|
|
514
|
+
}
|
|
515
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormFieldComponent, decorators: [{
|
|
516
|
+
type: Component,
|
|
517
|
+
args: [{ selector: 'si-form-field', imports: [SiTranslatePipe, NgTemplateOutlet], host: {
|
|
518
|
+
'[class.required]': 'showRequired()',
|
|
519
|
+
'[class.form-check]': 'isFormCheck()',
|
|
520
|
+
'[class.form-check-inline]': 'fieldset?.inline()',
|
|
521
|
+
'[class.si-form-input]': '!fieldset'
|
|
522
|
+
}, template: "@if (!isFormCheck()) {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\n} @else if (!fieldset) {\n <!-- Empty spacer so the control aligns with the label column in form-col-layout. -->\n <div class=\"form-label\"></div>\n}\n<div class=\"form-item-content\">\n <ng-content />\n @if (isFormCheck()) {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\n }\n @if (!isPartOfRadioGroup()) {\n <ng-container [ngTemplateOutlet]=\"feedbackTemplate\" />\n }\n</div>\n\n<ng-template #labelTemplate>\n <div\n class=\"d-flex gap-2\"\n [class.form-label]=\"!isFormCheck()\"\n [class.form-check-label]=\"isFormCheck()\"\n >\n @if (labelledby()) {\n <span [id]=\"labelledby()\" [class.required]=\"showRequired()\">{{ label() | translate }}</span>\n } @else {\n <label [for]=\"controlId()\" [class.required]=\"showRequired()\">{{ label() | translate }}</label>\n }\n <ng-content select=\"[si-help-button]\" />\n </div>\n</ng-template>\n\n<ng-template #feedbackTemplate>\n <div class=\"invalid-feedback\" [class.d-block]=\"errors().length\" [attr.id]=\"errormessageId()\">\n @for (error of errors(); track $index) {\n <div>\n {{ error.message ?? error.key | translate: error.params }}\n </div>\n }\n </div>\n</ng-template>\n", styles: [":host{margin-block-end:12px}:host-context(si-form-fieldset){margin-block-end:0}:host(:not(.form-check)){display:flex;flex-direction:column}:host(:not(.form-check)) .form-item-content{flex-grow:1}.form-label:empty{display:none}:host(.form-check:not(.form-check-inline)){display:block}\n"] }]
|
|
523
|
+
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], formField: [{ type: i0.ContentChild, args: [i0.forwardRef(() => FormField), { isSignal: true }] }], fieldControl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SI_FORM_ITEM_CONTROL), { ...{ descendants: true }, isSignal: true }] }] } });
|
|
524
|
+
|
|
525
|
+
/**
|
|
526
|
+
* Provides the signal forms configuration required by {@link SiFormFieldComponent}.
|
|
527
|
+
*
|
|
528
|
+
* It restores the `ng-*` classes applied by the directives of {@link @angular/forms#FormsModule | FormsModule} / {@link @angular/forms#ReactiveFormsModule | ReactiveFormsModule}.
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```ts
|
|
532
|
+
* bootstrapApplication(AppComponent, {
|
|
533
|
+
* providers: [provideSiFormFieldConfig()]
|
|
534
|
+
* });
|
|
535
|
+
* ```
|
|
536
|
+
*/
|
|
537
|
+
const provideSiFormFieldConfig = (config = {}) => provideSignalFormsConfig({
|
|
538
|
+
...config,
|
|
539
|
+
classes: {
|
|
540
|
+
...NG_STATUS_CLASSES,
|
|
541
|
+
...config.classes
|
|
542
|
+
}
|
|
543
|
+
});
|
|
544
|
+
|
|
320
545
|
/**
|
|
321
546
|
* This will be used by the `si-form-item` to create a form item control if none is provided.
|
|
322
547
|
* This is typically the case for native form controls like `input`, `textarea` and `select`.
|
|
@@ -368,7 +593,8 @@ class SiFormItemComponent {
|
|
|
368
593
|
* The label to be displayed in the form item.
|
|
369
594
|
* It will be translated if a translation key is available.
|
|
370
595
|
*/
|
|
371
|
-
label = input.required(
|
|
596
|
+
label = input.required(/* @ts-ignore */
|
|
597
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
372
598
|
/**
|
|
373
599
|
* A custom width value to be applied to the label.
|
|
374
600
|
* A value of 0 is allowed as well to visually hide away the label area.
|
|
@@ -378,29 +604,35 @@ class SiFormItemComponent {
|
|
|
378
604
|
*
|
|
379
605
|
* @example labelWidth="100px"
|
|
380
606
|
*/
|
|
381
|
-
labelWidth = input(
|
|
607
|
+
labelWidth = input(/* @ts-ignore */
|
|
608
|
+
...(ngDevMode ? [undefined, { debugName: "labelWidth" }] : /* istanbul ignore next */ []));
|
|
382
609
|
/**
|
|
383
610
|
* Disables the automatic error printing. Error printing will be enabled by default in v46.
|
|
384
611
|
*
|
|
385
612
|
* @defaultValue false
|
|
386
613
|
*/
|
|
387
|
-
disableErrorPrinting = input(false, { ...(ngDevMode ? { debugName: "disableErrorPrinting" } : {}), transform: booleanAttribute });
|
|
388
|
-
formErrorMapper = input(
|
|
614
|
+
disableErrorPrinting = input(false, { ...(ngDevMode ? { debugName: "disableErrorPrinting" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
615
|
+
formErrorMapper = input(/* @ts-ignore */
|
|
616
|
+
...(ngDevMode ? [undefined, { debugName: "formErrorMapper" }] : /* istanbul ignore next */ []));
|
|
389
617
|
/**
|
|
390
618
|
* Defines that this form item is required for the overall form to be valid.
|
|
391
619
|
*
|
|
392
620
|
* @defaultValue false
|
|
393
621
|
*/
|
|
394
622
|
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
395
|
-
requiredInput = input(false, { ...(ngDevMode ? { debugName: "requiredInput" } : {}), transform: booleanAttribute, alias: 'required' });
|
|
396
|
-
fieldControlQuery = contentChild(SI_FORM_ITEM_CONTROL, { ...(ngDevMode ? { debugName: "fieldControlQuery" } : {}), descendants: true });
|
|
623
|
+
requiredInput = input(false, { ...(ngDevMode ? { debugName: "requiredInput" } : /* istanbul ignore next */ {}), transform: booleanAttribute, alias: 'required' });
|
|
624
|
+
fieldControlQuery = contentChild(SI_FORM_ITEM_CONTROL, { ...(ngDevMode ? { debugName: "fieldControlQuery" } : /* istanbul ignore next */ {}), descendants: true });
|
|
397
625
|
/** @internal */
|
|
398
|
-
ngControl = contentChild(NgControl, { ...(ngDevMode ? { debugName: "ngControl" } : {}), descendants: true });
|
|
399
|
-
controlElementRef = contentChild(NgControl, { ...(ngDevMode ? { debugName: "controlElementRef" } : {}), read: ElementRef,
|
|
626
|
+
ngControl = contentChild(NgControl, { ...(ngDevMode ? { debugName: "ngControl" } : /* istanbul ignore next */ {}), descendants: true });
|
|
627
|
+
controlElementRef = contentChild(NgControl, { ...(ngDevMode ? { debugName: "controlElementRef" } : /* istanbul ignore next */ {}), read: ElementRef,
|
|
400
628
|
descendants: true });
|
|
401
|
-
requiredValidator = contentChild(RequiredValidator, { ...(ngDevMode ? { debugName: "requiredValidator" } : {}), descendants: true });
|
|
629
|
+
requiredValidator = contentChild(RequiredValidator, { ...(ngDevMode ? { debugName: "requiredValidator" } : /* istanbul ignore next */ {}), descendants: true });
|
|
402
630
|
/** @internal */
|
|
403
|
-
errors = signal([],
|
|
631
|
+
errors = signal([], /* @ts-ignore */
|
|
632
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
633
|
+
/** @internal */
|
|
634
|
+
touched = signal(false, /* @ts-ignore */
|
|
635
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
404
636
|
fieldset = inject(SiFormFieldsetComponent, { optional: true });
|
|
405
637
|
container = inject(SiFormContainerComponent, { optional: true });
|
|
406
638
|
get formItemId() {
|
|
@@ -419,32 +651,41 @@ class SiFormItemComponent {
|
|
|
419
651
|
? (fieldControl?.errormessageId() ?? null)
|
|
420
652
|
: (fieldControl?.errormessageId ?? null);
|
|
421
653
|
}
|
|
422
|
-
fieldControl = computed(() => this.fieldControlQuery() ?? this.fieldControlNative(),
|
|
654
|
+
fieldControl = computed(() => this.fieldControlQuery() ?? this.fieldControlNative(), /* @ts-ignore */
|
|
655
|
+
...(ngDevMode ? [{ debugName: "fieldControl" }] : /* istanbul ignore next */ []));
|
|
423
656
|
validationErrorService = inject(SiFormValidationErrorService);
|
|
424
657
|
requiredTestControl = new FormControl('');
|
|
425
658
|
validator;
|
|
426
659
|
previousErrors;
|
|
427
|
-
hasRequiredValidator = signal(false,
|
|
428
|
-
|
|
660
|
+
hasRequiredValidator = signal(false, /* @ts-ignore */
|
|
661
|
+
...(ngDevMode ? [{ debugName: "hasRequiredValidator" }] : /* istanbul ignore next */ []));
|
|
662
|
+
fieldControlNative = signal(undefined, /* @ts-ignore */
|
|
663
|
+
...(ngDevMode ? [{ debugName: "fieldControlNative" }] : /* istanbul ignore next */ []));
|
|
429
664
|
labelWidthCssVar = computed(() => {
|
|
430
665
|
const labelWidth = this.labelWidth();
|
|
431
666
|
if (typeof labelWidth === 'number') {
|
|
432
667
|
return `${labelWidth}px`;
|
|
433
668
|
}
|
|
434
669
|
return labelWidth;
|
|
435
|
-
},
|
|
670
|
+
}, /* @ts-ignore */
|
|
671
|
+
...(ngDevMode ? [{ debugName: "labelWidthCssVar" }] : /* istanbul ignore next */ []));
|
|
436
672
|
printErrors = computed(() => {
|
|
437
673
|
return !this.disableErrorPrinting() && !(this.container?.disableErrorPrinting() ?? false);
|
|
438
|
-
},
|
|
674
|
+
}, /* @ts-ignore */
|
|
675
|
+
...(ngDevMode ? [{ debugName: "printErrors" }] : /* istanbul ignore next */ []));
|
|
676
|
+
/** @internal */
|
|
677
|
+
required = computed(() => this.requiredInput() || this.hasRequiredValidator(), /* @ts-ignore */
|
|
678
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
439
679
|
/** @internal */
|
|
440
|
-
|
|
680
|
+
control = computed(() => this.ngControl()?.control, /* @ts-ignore */
|
|
681
|
+
...(ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []));
|
|
441
682
|
ngOnChanges(changes) {
|
|
442
683
|
if (changes.formErrorMapper) {
|
|
443
684
|
this.updateValidationMessages();
|
|
444
685
|
}
|
|
445
686
|
}
|
|
446
687
|
ngOnInit() {
|
|
447
|
-
this.fieldset?.
|
|
688
|
+
this.fieldset?.registerControl(this);
|
|
448
689
|
}
|
|
449
690
|
ngAfterContentInit() {
|
|
450
691
|
if (!this.fieldControlQuery()) {
|
|
@@ -454,9 +695,10 @@ class SiFormItemComponent {
|
|
|
454
695
|
ngAfterContentChecked() {
|
|
455
696
|
this.updateRequiredState();
|
|
456
697
|
this.updateValidationMessages();
|
|
698
|
+
this.touched.set(!!this.ngControl()?.touched);
|
|
457
699
|
}
|
|
458
700
|
ngOnDestroy() {
|
|
459
|
-
this.fieldset?.
|
|
701
|
+
this.fieldset?.unregisterControl(this);
|
|
460
702
|
}
|
|
461
703
|
updateRequiredState() {
|
|
462
704
|
const requiredValidator = this.requiredValidator();
|
|
@@ -492,12 +734,12 @@ class SiFormItemComponent {
|
|
|
492
734
|
}
|
|
493
735
|
}
|
|
494
736
|
}
|
|
495
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
496
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
737
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
738
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: SiFormItemComponent, isStandalone: true, selector: "si-form-item", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null }, labelWidth: { classPropertyName: "labelWidth", publicName: "labelWidth", isSignal: true, isRequired: false, transformFunction: null }, disableErrorPrinting: { classPropertyName: "disableErrorPrinting", publicName: "disableErrorPrinting", isSignal: true, isRequired: false, transformFunction: null }, formErrorMapper: { classPropertyName: "formErrorMapper", publicName: "formErrorMapper", isSignal: true, isRequired: false, transformFunction: null }, requiredInput: { classPropertyName: "requiredInput", publicName: "required", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "class.required": "required()", "style.--si-form-label-width": "labelWidthCssVar()", "class.form-check": "fieldControl()?.isFormCheck", "class.form-check-inline": "fieldset?.inline()", "class.si-form-input": "!fieldset" } }, queries: [{ propertyName: "fieldControlQuery", first: true, predicate: SI_FORM_ITEM_CONTROL, descendants: true, isSignal: true }, { propertyName: "ngControl", first: true, predicate: NgControl, descendants: true, isSignal: true }, { propertyName: "controlElementRef", first: true, predicate: NgControl, descendants: true, read: ElementRef, isSignal: true }, { propertyName: "requiredValidator", first: true, predicate: RequiredValidator, descendants: true, isSignal: true }], usesOnChanges: true, ngImport: i0, template: "<!--Block the space if no form-field is provided. Otherwise it looks weird in the formly field inline representation.-->\n@if (fieldControl()?.isFormCheck && !fieldset) {\n <div class=\"form-label\"></div>\n}\n@if (fieldControl()?.isFormCheck) {\n <div class=\"form-item-content\">\n <ng-container [ngTemplateOutlet]=\"content\" />\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\n <ng-container [ngTemplateOutlet]=\"feedbackTemplate\" />\n </div>\n} @else {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\n <div class=\"form-item-content\">\n <ng-container [ngTemplateOutlet]=\"content\" />\n <ng-container [ngTemplateOutlet]=\"feedbackTemplate\" />\n </div>\n}\n\n<ng-template #labelTemplate>\n @if (label()) {\n <div\n class=\"d-flex gap-2\"\n [class.form-label]=\"!fieldControl()?.isFormCheck\"\n [class.form-check-label]=\"fieldControl()?.isFormCheck\"\n >\n @let labeledBy = formItemLabelledBy;\n @let required = this.required() && !this.fieldset?.hasOnlyRadios();\n @if (labeledBy) {\n <span [id]=\"labeledBy\" [class.required]=\"required\">{{ label()! | translate }}</span>\n } @else {\n <label [for]=\"formItemId\" [class.required]=\"required\">{{ label()! | translate }}</label>\n }\n <ng-content select=\"[si-help-button]\" />\n </div>\n }\n</ng-template>\n<ng-template #feedbackTemplate>\n @if (printErrors() && !fieldset?.hasOnlyRadios()) {\n <div class=\"invalid-feedback\" [attr.id]=\"formItemErrormessageId\">\n @for (error of errors(); track error.key) {\n <div>\n {{ error.message | translate: error.params }}\n </div>\n }\n </div>\n }\n <ng-content select=\".warning-feedback, .info-feedback, .invalid-feedback\" />\n</ng-template>\n<ng-template #content>\n <ng-content />\n</ng-template>\n", styles: [":host.si-form-input{display:flex;flex-direction:column;margin-block-end:12px}:host.si-form-input .form-item-content{flex-grow:1}.form-label:empty{display:none}:host(.form-check):not(.form-check-inline){display:block}:host(.form-check):has(.form-check){padding-block:0}:host-context(.si-container-sm) :host.si-form-input,:host-context(.si-container-md) :host.si-form-input,:host-context(.si-container-lg) :host.si-form-input,:host-context(.si-container-xl) :host.si-form-input,:host-context(.si-container-xxl) :host.si-form-input{display:flex;flex-direction:row;align-items:center}:host-context(.si-container-sm) .form-label,:host-context(.si-container-md) .form-label,:host-context(.si-container-lg) .form-label,:host-context(.si-container-xl) .form-label,:host-context(.si-container-xxl) .form-label{align-self:start;padding-block:8px;padding-inline:16px;inline-size:var(--si-form-label-width, 16.6666666667%);line-height:1rem}:host-context(.si-container-sm) .form-label:empty,:host-context(.si-container-md) .form-label:empty,:host-context(.si-container-lg) .form-label:empty,:host-context(.si-container-xl) .form-label:empty,:host-context(.si-container-xxl) .form-label:empty{display:block}:host-context(.si-container-sm) :host-context(si-form-fieldset) .form-label,:host-context(.si-container-md) :host-context(si-form-fieldset) .form-label,:host-context(.si-container-lg) :host-context(si-form-fieldset) .form-label,:host-context(.si-container-xl) :host-context(si-form-fieldset) .form-label,:host-context(.si-container-xxl) :host-context(si-form-fieldset) .form-label{padding-block:2px 0}:host-context(.si-container-sm) :host(.form-check) .form-label,:host-context(.si-container-md) :host(.form-check) .form-label,:host-context(.si-container-lg) :host(.form-check) .form-label,:host-context(.si-container-xl) :host(.form-check) .form-label,:host-context(.si-container-xxl) :host(.form-check) .form-label{padding-block:2px}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: SiTranslatePipe, name: "translate" }] });
|
|
497
739
|
}
|
|
498
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
740
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormItemComponent, decorators: [{
|
|
499
741
|
type: Component,
|
|
500
|
-
args: [{ selector: 'si-form-item', imports: [SiTranslatePipe, NgTemplateOutlet],
|
|
742
|
+
args: [{ selector: 'si-form-item', imports: [SiTranslatePipe, NgTemplateOutlet], host: {
|
|
501
743
|
'[class.required]': 'required()',
|
|
502
744
|
'[style.--si-form-label-width]': 'labelWidthCssVar()',
|
|
503
745
|
'[class.form-check]': 'fieldControl()?.isFormCheck',
|
|
@@ -516,14 +758,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
516
758
|
const SI_FORM_VALIDATION_TOOLTIP_DATA = new InjectionToken('SiFormValidationTooltipData');
|
|
517
759
|
class SiFormValidationTooltipComponent {
|
|
518
760
|
errors = inject(SI_FORM_VALIDATION_TOOLTIP_DATA);
|
|
519
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
520
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
761
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormValidationTooltipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
762
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.7", type: SiFormValidationTooltipComponent, isStandalone: true, selector: "si-form-validation-tooltip", host: { classAttribute: "d-flex flex-column gap-2 text-start" }, ngImport: i0, template: `
|
|
521
763
|
@for (error of errors(); track error.key) {
|
|
522
764
|
<div>{{ error.message | translate: error.params }}</div>
|
|
523
765
|
}
|
|
524
|
-
`, isInline: true, dependencies: [{ kind: "pipe", type: SiTranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.
|
|
766
|
+
`, isInline: true, dependencies: [{ kind: "pipe", type: SiTranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
|
|
525
767
|
}
|
|
526
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
768
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormValidationTooltipComponent, decorators: [{
|
|
527
769
|
type: Component,
|
|
528
770
|
args: [{
|
|
529
771
|
selector: 'si-form-validation-tooltip',
|
|
@@ -533,7 +775,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
533
775
|
<div>{{ error.message | translate: error.params }}</div>
|
|
534
776
|
}
|
|
535
777
|
`,
|
|
536
|
-
changeDetection: ChangeDetectionStrategy.
|
|
778
|
+
changeDetection: ChangeDetectionStrategy.Eager,
|
|
537
779
|
host: {
|
|
538
780
|
'class': 'd-flex flex-column gap-2 text-start'
|
|
539
781
|
}
|
|
@@ -561,60 +803,50 @@ class SiFormValidationTooltipDirective {
|
|
|
561
803
|
tooltipService = inject(SiTooltipService);
|
|
562
804
|
formValidationService = inject(SiFormValidationErrorService);
|
|
563
805
|
formContainer = inject(SiFormContainerComponent, { optional: true });
|
|
564
|
-
formErrorMapper = input(
|
|
806
|
+
formErrorMapper = input(/* @ts-ignore */
|
|
807
|
+
...(ngDevMode ? [undefined, { debugName: "formErrorMapper" }] : /* istanbul ignore next */ []));
|
|
565
808
|
ngControl = inject(NgControl);
|
|
566
809
|
elementRef = inject(ElementRef);
|
|
567
|
-
tooltipRef;
|
|
568
|
-
errors = signal([], ...(ngDevMode ? [{ debugName: "errors" }] : []));
|
|
569
|
-
currentErrors = null;
|
|
570
|
-
touched = null;
|
|
571
810
|
describedBy = `__si-form-validation-tooltip-${SiFormValidationTooltipDirective.idCounter++}`;
|
|
811
|
+
errors = signal([], /* @ts-ignore */
|
|
812
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
813
|
+
touched = signal(false, /* @ts-ignore */
|
|
814
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
815
|
+
canShowTooltip = computed(() => this.errors().length > 0 && this.touched(), /* @ts-ignore */
|
|
816
|
+
...(ngDevMode ? [{ debugName: "canShowTooltip" }] : /* istanbul ignore next */ []));
|
|
817
|
+
currentErrors = null;
|
|
818
|
+
constructor() {
|
|
819
|
+
this.tooltipService.createTooltip({
|
|
820
|
+
placement: () => 'auto',
|
|
821
|
+
element: this.elementRef,
|
|
822
|
+
describedBy: this.describedBy,
|
|
823
|
+
injector: Injector.create({
|
|
824
|
+
providers: [{ provide: SI_FORM_VALIDATION_TOOLTIP_DATA, useValue: this.errors }]
|
|
825
|
+
}),
|
|
826
|
+
canShow: this.canShowTooltip,
|
|
827
|
+
tooltip: () => SiFormValidationTooltipComponent,
|
|
828
|
+
// Not actually used, but errors in the context triggers a resize if the errors changes.
|
|
829
|
+
tooltipContext: this.errors
|
|
830
|
+
});
|
|
831
|
+
}
|
|
572
832
|
ngDoCheck() {
|
|
573
833
|
const nextErrors = this.ngControl.errors;
|
|
574
|
-
|
|
575
|
-
if (this.currentErrors !== nextErrors
|
|
834
|
+
this.touched.set(!!this.ngControl.touched);
|
|
835
|
+
if (this.currentErrors !== nextErrors) {
|
|
576
836
|
this.currentErrors = nextErrors;
|
|
577
|
-
this.touched = nextTouched;
|
|
578
837
|
this.updateErrors();
|
|
579
838
|
}
|
|
580
839
|
}
|
|
581
|
-
ngOnDestroy() {
|
|
582
|
-
this.destroyTooltip();
|
|
583
|
-
}
|
|
584
840
|
updateErrors() {
|
|
585
841
|
const errors = this.formValidationService
|
|
586
842
|
.resolveErrors(this.ngControl.name, this.currentErrors, this.formErrorMapper(), this.formContainer?.formErrorMapper())
|
|
587
843
|
.filter(error => !!error.message);
|
|
588
|
-
const shouldShow = errors.length > 0 && !!this.ngControl.touched;
|
|
589
|
-
if (shouldShow) {
|
|
590
|
-
this.createTooltip();
|
|
591
|
-
}
|
|
592
|
-
else {
|
|
593
|
-
this.destroyTooltip();
|
|
594
|
-
}
|
|
595
844
|
this.errors.set(errors);
|
|
596
845
|
}
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
placement: 'auto',
|
|
600
|
-
element: this.elementRef,
|
|
601
|
-
describedBy: this.describedBy,
|
|
602
|
-
injector: Injector.create({
|
|
603
|
-
providers: [{ provide: SI_FORM_VALIDATION_TOOLTIP_DATA, useValue: this.errors }]
|
|
604
|
-
}),
|
|
605
|
-
tooltip: () => SiFormValidationTooltipComponent,
|
|
606
|
-
// Not actually used, but errors in the context triggers a resize if the errors changes.
|
|
607
|
-
tooltipContext: () => this.errors()
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
destroyTooltip() {
|
|
611
|
-
this.tooltipRef?.destroy();
|
|
612
|
-
this.tooltipRef = undefined;
|
|
613
|
-
}
|
|
614
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiFormValidationTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
615
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "21.0.8", type: SiFormValidationTooltipDirective, isStandalone: true, selector: "[siFormValidationTooltip]", inputs: { formErrorMapper: { classPropertyName: "formErrorMapper", publicName: "formErrorMapper", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-describedby": "describedBy" } }, providers: [SiTooltipService], ngImport: i0 });
|
|
846
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormValidationTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
847
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.7", type: SiFormValidationTooltipDirective, isStandalone: true, selector: "[siFormValidationTooltip]", inputs: { formErrorMapper: { classPropertyName: "formErrorMapper", publicName: "formErrorMapper", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-describedby": "describedBy" } }, providers: [SiTooltipService], ngImport: i0 });
|
|
616
848
|
}
|
|
617
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
849
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormValidationTooltipDirective, decorators: [{
|
|
618
850
|
type: Directive,
|
|
619
851
|
args: [{
|
|
620
852
|
selector: '[siFormValidationTooltip]',
|
|
@@ -623,7 +855,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
623
855
|
'[attr.aria-describedby]': 'describedBy'
|
|
624
856
|
}
|
|
625
857
|
}]
|
|
626
|
-
}], propDecorators: { formErrorMapper: [{ type: i0.Input, args: [{ isSignal: true, alias: "formErrorMapper", required: false }] }] } });
|
|
858
|
+
}], ctorParameters: () => [], propDecorators: { formErrorMapper: [{ type: i0.Input, args: [{ isSignal: true, alias: "formErrorMapper", required: false }] }] } });
|
|
627
859
|
|
|
628
860
|
/**
|
|
629
861
|
* The error mapper is used to resolve an angular validation error to a {@link TranslatableString}.
|
|
@@ -653,11 +885,11 @@ class SiFormModule {
|
|
|
653
885
|
providers: [provideFormValidationErrorMapper(validationErrorMapper)]
|
|
654
886
|
};
|
|
655
887
|
}
|
|
656
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
657
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
658
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
888
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
889
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.7", ngImport: i0, type: SiFormModule, imports: [SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent], exports: [SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent] });
|
|
890
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormModule });
|
|
659
891
|
}
|
|
660
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
892
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImport: i0, type: SiFormModule, decorators: [{
|
|
661
893
|
type: NgModule,
|
|
662
894
|
args: [{
|
|
663
895
|
imports: [SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent],
|
|
@@ -674,5 +906,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
674
906
|
* Generated bundle index. Do not edit.
|
|
675
907
|
*/
|
|
676
908
|
|
|
677
|
-
export { SI_FORM_ITEM_CONTROL, SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent, SiFormModule, SiFormValidationTooltipDirective, provideFormValidationErrorMapper };
|
|
909
|
+
export { SI_FORM_ITEM_CONTROL, SiFormContainerComponent, SiFormFieldComponent, SiFormFieldsetComponent, SiFormItemComponent, SiFormModule, SiFormValidationTooltipDirective, provideFormValidationErrorMapper, provideSiFormFieldConfig };
|
|
678
910
|
//# sourceMappingURL=siemens-element-ng-form.mjs.map
|