@siemens/element-ng 49.12.0 → 51.0.0-rc.3
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 +56 -39
- package/fesm2022/siemens-element-ng-accordion.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-action-modal.mjs +81 -51
- 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 +170 -143
- 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 +34 -33
- 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 +18 -15
- 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 +55 -32
- package/fesm2022/siemens-element-ng-carousel.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-chat-messages.mjs +175 -111
- package/fesm2022/siemens-element-ng-chat-messages.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-circle-status.mjs +37 -24
- package/fesm2022/siemens-element-ng-circle-status.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-color-picker.mjs +24 -16
- package/fesm2022/siemens-element-ng-color-picker.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-column-selection-dialog.mjs +52 -33
- 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 +35 -26
- 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 +327 -213
- 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 +358 -234
- package/fesm2022/siemens-element-ng-datepicker.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-electron-titlebar.mjs +21 -16
- 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 +93 -81
- package/fesm2022/siemens-element-ng-file-uploader.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-filter-bar.mjs +29 -22
- package/fesm2022/siemens-element-ng-filter-bar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-filtered-search.mjs +243 -147
- 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 +289 -128
- 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 +220 -315
- package/fesm2022/siemens-element-ng-formly.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-header-dropdown.mjs +46 -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 +20 -16
- package/fesm2022/siemens-element-ng-ip-input.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-landing-page.mjs +118 -72
- 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 +73 -54
- package/fesm2022/siemens-element-ng-list-details.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-loading-spinner.mjs +42 -33
- 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 +46 -29
- package/fesm2022/siemens-element-ng-main-detail-container.mjs.map +1 -1
- 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 +12 -10
- package/fesm2022/siemens-element-ng-modal.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-navbar-vertical-next.mjs +133 -94
- package/fesm2022/siemens-element-ng-navbar-vertical-next.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-navbar-vertical.mjs +117 -81
- package/fesm2022/siemens-element-ng-navbar-vertical.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-navbar.mjs +67 -41
- 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 +38 -27
- 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 +31 -22
- 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 +138 -134
- package/fesm2022/siemens-element-ng-phone-number.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-photo-upload.mjs +76 -45
- 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 +33 -26
- 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 +32 -24
- package/fesm2022/siemens-element-ng-search-bar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-select.mjs +212 -154
- 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 +119 -75
- package/fesm2022/siemens-element-ng-side-panel.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-skip-links.mjs +14 -13
- package/fesm2022/siemens-element-ng-skip-links.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-slider.mjs +42 -28
- package/fesm2022/siemens-element-ng-slider.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-split.mjs +268 -254
- package/fesm2022/siemens-element-ng-split.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-status-bar.mjs +57 -47
- 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 +22 -14
- 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 +16 -15
- package/fesm2022/siemens-element-ng-tabs-legacy.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tabs.mjs +88 -47
- package/fesm2022/siemens-element-ng-tabs.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-theme.mjs +5 -4
- package/fesm2022/siemens-element-ng-theme.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-threshold.mjs +59 -40
- 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 +218 -117
- package/fesm2022/siemens-element-ng-tooltip.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tour.mjs +28 -19
- 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 +93 -74
- package/fesm2022/siemens-element-ng-tree-view.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-typeahead.mjs +75 -67
- 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/package.json +20 -22
- 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-to-v49.js → migrate-to-v51.js} +2 -2
- package/template-i18n.json +3 -6
- package/types/siemens-element-ng-application-header.d.ts +13 -25
- package/types/siemens-element-ng-autocomplete.d.ts +19 -19
- package/types/siemens-element-ng-chat-messages.d.ts +6 -4
- package/types/siemens-element-ng-circle-status.d.ts +1 -1
- package/types/siemens-element-ng-date-range-filter.d.ts +1 -1
- package/types/siemens-element-ng-datepicker.d.ts +1 -12
- package/types/siemens-element-ng-file-uploader.d.ts +5 -23
- package/types/siemens-element-ng-filtered-search.d.ts +1 -1
- package/types/siemens-element-ng-form.d.ts +135 -40
- 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-header-dropdown.d.ts +5 -0
- package/types/siemens-element-ng-icon.d.ts +2 -19
- package/types/siemens-element-ng-navbar-vertical-next.d.ts +6 -1
- package/types/siemens-element-ng-notification-item.d.ts +12 -0
- package/types/siemens-element-ng-phone-number.d.ts +6 -9
- package/types/siemens-element-ng-resize-observer.d.ts +0 -17
- package/types/siemens-element-ng-split.d.ts +95 -63
- 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 +4 -0
- package/types/siemens-element-ng-toast-notification.d.ts +0 -1
- package/types/siemens-element-ng-tooltip.d.ts +10 -26
- package/types/siemens-element-ng-translate.d.ts +1 -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,9 +1,11 @@
|
|
|
1
1
|
import { NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
|
-
import { input, booleanAttribute, inject, computed, ChangeDetectionStrategy, Component, signal,
|
|
3
|
+
import { input, booleanAttribute, inject, computed, ChangeDetectionStrategy, Component, signal, Injectable, contentChild, DestroyRef, effect, InjectionToken, ElementRef, isSignal, 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
|
/**
|
|
@@ -15,7 +17,8 @@ class SiFormContainerComponent {
|
|
|
15
17
|
* Set the form entity to the container to enable the overall form validation on in
|
|
16
18
|
* the form container edit panel.
|
|
17
19
|
*/
|
|
18
|
-
form = input(
|
|
20
|
+
form = input(/* @ts-ignore */
|
|
21
|
+
...(ngDevMode ? [undefined, { debugName: "form" }] : /* istanbul ignore next */ []));
|
|
19
22
|
/**
|
|
20
23
|
* A form container in readonly mode is only displaying the form content without ability
|
|
21
24
|
* to change it. The edit panel with typically save and cancel buttons is hidden. Set
|
|
@@ -23,13 +26,14 @@ class SiFormContainerComponent {
|
|
|
23
26
|
*
|
|
24
27
|
* @defaultValue false
|
|
25
28
|
*/
|
|
26
|
-
readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : {}), transform: booleanAttribute });
|
|
29
|
+
readonly = input(false, { ...(ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
27
30
|
/**
|
|
28
31
|
* The container hosts the form within a siResizeContainer to configure the breakpoint for
|
|
29
32
|
* different screen sizes. Optionally, change the container breakpoints with the contentContainerBreakpoints
|
|
30
33
|
* input.
|
|
31
34
|
*/
|
|
32
|
-
contentContainerBreakpoints = input(
|
|
35
|
+
contentContainerBreakpoints = input(/* @ts-ignore */
|
|
36
|
+
...(ngDevMode ? [undefined, { debugName: "contentContainerBreakpoints" }] : /* istanbul ignore next */ []));
|
|
33
37
|
/**
|
|
34
38
|
* In some scenarios, one may not want the form container to be responsible for the layout relevant
|
|
35
39
|
* `si-container-[xs|...]` classes, but let this be done by a different, nested component, e.g. by a
|
|
@@ -37,7 +41,7 @@ class SiFormContainerComponent {
|
|
|
37
41
|
*
|
|
38
42
|
* @defaultValue false
|
|
39
43
|
*/
|
|
40
|
-
disableContainerBreakpoints = input(false, { ...(ngDevMode ? { debugName: "disableContainerBreakpoints" } : {}), transform: booleanAttribute });
|
|
44
|
+
disableContainerBreakpoints = input(false, { ...(ngDevMode ? { debugName: "disableContainerBreakpoints" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
41
45
|
/**
|
|
42
46
|
* Every validation error has an errorCode. This map holds translate keys for error codes. The keys can
|
|
43
47
|
* be used to display a translated message for each validation error. The defaults old english readable
|
|
@@ -45,7 +49,8 @@ class SiFormContainerComponent {
|
|
|
45
49
|
*
|
|
46
50
|
* Use the input to set your own translate keys for the form validators you need.
|
|
47
51
|
*/
|
|
48
|
-
errorCodeTranslateKeyMap = input(
|
|
52
|
+
errorCodeTranslateKeyMap = input(/* @ts-ignore */
|
|
53
|
+
...(ngDevMode ? [undefined, { debugName: "errorCodeTranslateKeyMap" }] : /* istanbul ignore next */ []));
|
|
49
54
|
/**
|
|
50
55
|
* A map the maps from control names of the form to their translate keys.
|
|
51
56
|
* The initial map is empty and the user is responsible to add the required
|
|
@@ -56,19 +61,21 @@ class SiFormContainerComponent {
|
|
|
56
61
|
* new Map<string, string>()
|
|
57
62
|
* ```
|
|
58
63
|
*/
|
|
59
|
-
controlNameTranslateKeyMap = input(new Map(),
|
|
64
|
+
controlNameTranslateKeyMap = input(new Map(), /* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [{ debugName: "controlNameTranslateKeyMap" }] : /* istanbul ignore next */ []));
|
|
60
66
|
/**
|
|
61
67
|
* Disables the automatic error printing in all nested {@link SiFormItemComponent}. Error printing will be enabled by default in v46.
|
|
62
68
|
*
|
|
63
69
|
* @defaultValue false
|
|
64
70
|
*/
|
|
65
|
-
disableErrorPrinting = input(false, { ...(ngDevMode ? { debugName: "disableErrorPrinting" } : {}), transform: booleanAttribute });
|
|
71
|
+
disableErrorPrinting = input(false, { ...(ngDevMode ? { debugName: "disableErrorPrinting" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
66
72
|
/**
|
|
67
73
|
* A custom width value to be applied to all labels.
|
|
68
74
|
*
|
|
69
75
|
* @example labelWidth="100px".
|
|
70
76
|
*/
|
|
71
|
-
labelWidth = input(
|
|
77
|
+
labelWidth = input(/* @ts-ignore */
|
|
78
|
+
...(ngDevMode ? [undefined, { debugName: "labelWidth" }] : /* istanbul ignore next */ []));
|
|
72
79
|
hasParentContainer = !!inject(SiFormContainerComponent, {
|
|
73
80
|
optional: true,
|
|
74
81
|
skipSelf: true
|
|
@@ -86,7 +93,8 @@ class SiFormContainerComponent {
|
|
|
86
93
|
return {
|
|
87
94
|
...customMapper
|
|
88
95
|
};
|
|
89
|
-
},
|
|
96
|
+
}, /* @ts-ignore */
|
|
97
|
+
...(ngDevMode ? [{ debugName: "formErrorMapper" }] : /* istanbul ignore next */ []));
|
|
90
98
|
/**
|
|
91
99
|
* Indicates whether the user interacted with the form.
|
|
92
100
|
* @returns `true`, if the user selected at least one form element and
|
|
@@ -121,12 +129,12 @@ class SiFormContainerComponent {
|
|
|
121
129
|
}
|
|
122
130
|
return controlNameTranslateKeyMap.get(controlName) ?? controlName;
|
|
123
131
|
}
|
|
124
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
125
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
132
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
133
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", 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
134
|
}
|
|
127
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
135
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormContainerComponent, decorators: [{
|
|
128
136
|
type: Component,
|
|
129
|
-
args: [{ selector: 'si-form-container', imports: [NgTemplateOutlet, SiResponsiveContainerDirective], changeDetection: ChangeDetectionStrategy.
|
|
137
|
+
args: [{ selector: 'si-form-container', imports: [NgTemplateOutlet, SiResponsiveContainerDirective], changeDetection: ChangeDetectionStrategy.Eager, host: {
|
|
130
138
|
'[style.--si-form-label-width]': 'labelWidth()'
|
|
131
139
|
}, 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
140
|
}], 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 +146,58 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
138
146
|
class SiFormFieldsetComponent {
|
|
139
147
|
static labelIdCounter = 0;
|
|
140
148
|
/** The label for the entire fieldset. */
|
|
141
|
-
label = input.required(
|
|
149
|
+
label = input.required(/* @ts-ignore */
|
|
150
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
142
151
|
/** Overrides the parent label width. */
|
|
143
|
-
labelWidth = input(
|
|
152
|
+
labelWidth = input(/* @ts-ignore */
|
|
153
|
+
...(ngDevMode ? [undefined, { debugName: "labelWidth" }] : /* istanbul ignore next */ []));
|
|
144
154
|
/**
|
|
145
155
|
* Adds a required marker to the label
|
|
146
156
|
*
|
|
147
157
|
* @defaultValue false
|
|
148
158
|
*/
|
|
149
|
-
required = input(false, { ...(ngDevMode ? { debugName: "required" } : {}), transform: booleanAttribute });
|
|
159
|
+
required = input(false, { ...(ngDevMode ? { debugName: "required" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
150
160
|
/**
|
|
151
161
|
* Switches all child inputs to inline mode
|
|
152
162
|
*
|
|
153
163
|
* @defaultValue false
|
|
154
164
|
*/
|
|
155
|
-
inline = input(false, { ...(ngDevMode ? { debugName: "inline" } : {}), transform: booleanAttribute });
|
|
156
|
-
formItems = signal([],
|
|
165
|
+
inline = input(false, { ...(ngDevMode ? { debugName: "inline" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
166
|
+
formItems = signal([], /* @ts-ignore */
|
|
167
|
+
...(ngDevMode ? [{ debugName: "formItems" }] : /* istanbul ignore next */ []));
|
|
157
168
|
/** @internal */
|
|
158
169
|
hasOnlyRadios = computed(() => {
|
|
159
170
|
// Check if the fieldset only contains radio buttons.
|
|
160
|
-
// We can safely assume that, if all items
|
|
171
|
+
// We can safely assume that, if all items reference the same control and if there are at least 2 items.
|
|
161
172
|
const items = this.formItems();
|
|
162
173
|
if (items.length > 1) {
|
|
163
|
-
const first = items[0];
|
|
164
|
-
return items.every(item => item.
|
|
174
|
+
const first = items[0].control();
|
|
175
|
+
return first != null && items.every(item => item.control() === first);
|
|
165
176
|
}
|
|
166
177
|
return false;
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
touched =
|
|
172
|
-
|
|
178
|
+
}, /* @ts-ignore */
|
|
179
|
+
...(ngDevMode ? [{ debugName: "hasOnlyRadios" }] : /* istanbul ignore next */ []));
|
|
180
|
+
errors = computed(() => this.formItems()[0].errors(), /* @ts-ignore */
|
|
181
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
182
|
+
touched = computed(() => this.formItems().some(item => item.touched()), /* @ts-ignore */
|
|
183
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
184
|
+
isRequired = computed(() => this.required() || (this.hasOnlyRadios() && this.formItems().every(item => item.required())), /* @ts-ignore */
|
|
185
|
+
...(ngDevMode ? [{ debugName: "isRequired" }] : /* istanbul ignore next */ []));
|
|
173
186
|
labelId = `__si-form-fieldset-label-${SiFormFieldsetComponent.labelIdCounter++}`;
|
|
174
|
-
ngDoCheck() {
|
|
175
|
-
this.touched.set(this.formItems().some(item => item.ngControl()?.touched));
|
|
176
|
-
}
|
|
177
187
|
/** @internal */
|
|
178
|
-
|
|
188
|
+
registerControl(item) {
|
|
179
189
|
this.formItems.update(items => [...items, item]);
|
|
180
190
|
}
|
|
181
191
|
/** @internal */
|
|
182
|
-
|
|
192
|
+
unregisterControl(item) {
|
|
183
193
|
this.formItems.update(items => items.filter(i => i !== item));
|
|
184
194
|
}
|
|
185
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
186
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
195
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormFieldsetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
196
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", 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
197
|
}
|
|
188
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
198
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormFieldsetComponent, decorators: [{
|
|
189
199
|
type: Component,
|
|
190
|
-
args: [{ selector: 'si-form-fieldset', imports: [SiTranslatePipe],
|
|
200
|
+
args: [{ selector: 'si-form-fieldset', imports: [SiTranslatePipe], host: {
|
|
191
201
|
role: 'group',
|
|
192
202
|
class: 'si-form-input',
|
|
193
203
|
'[style.--si-form-label-width]': 'labelWidth()',
|
|
@@ -195,12 +205,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
195
205
|
}, 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"] }]
|
|
196
206
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], labelWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelWidth", required: false }] }], required: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], inline: [{ type: i0.Input, args: [{ isSignal: true, alias: "inline", required: false }] }] } });
|
|
197
207
|
|
|
198
|
-
/**
|
|
199
|
-
* Copyright (c) Siemens 2016 - 2026
|
|
200
|
-
* SPDX-License-Identifier: MIT
|
|
201
|
-
*/
|
|
202
|
-
const SI_FORM_ITEM_CONTROL = new InjectionToken('si.form-item.control');
|
|
203
|
-
|
|
204
208
|
/**
|
|
205
209
|
* Copyright (c) Siemens 2016 - 2026
|
|
206
210
|
* SPDX-License-Identifier: MIT
|
|
@@ -267,6 +271,24 @@ class SiFormValidationErrorService {
|
|
|
267
271
|
constructor(errorMapper) {
|
|
268
272
|
this.errorMapper = errorMapper;
|
|
269
273
|
}
|
|
274
|
+
/**
|
|
275
|
+
* Resolves validation errors for Angular signal forms.
|
|
276
|
+
*
|
|
277
|
+
* If the validation error has no message associated, the resolution flow of {@link resolveErrors} is followed.
|
|
278
|
+
*
|
|
279
|
+
* @param state - the fieldState of the formfield.
|
|
280
|
+
*/
|
|
281
|
+
resolveFormFieldErrors(state) {
|
|
282
|
+
return state.errors().map(error => {
|
|
283
|
+
const { message, kind, ...params } = error;
|
|
284
|
+
if (!message) {
|
|
285
|
+
return this.resolveError(kind, state.name(), params);
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
return { message, key: kind, params };
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
270
292
|
/**
|
|
271
293
|
* Resolves the provided form errors to a list of {@link SiFormError}.
|
|
272
294
|
* To resolution order is:
|
|
@@ -306,10 +328,10 @@ class SiFormValidationErrorService {
|
|
|
306
328
|
}
|
|
307
329
|
return undefined;
|
|
308
330
|
}
|
|
309
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
310
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
331
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormValidationErrorService, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
|
|
332
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormValidationErrorService, providedIn: 'root', useFactory: () => new SiFormValidationErrorService(buildDefaults()) });
|
|
311
333
|
}
|
|
312
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
334
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormValidationErrorService, decorators: [{
|
|
313
335
|
type: Injectable,
|
|
314
336
|
args: [{
|
|
315
337
|
providedIn: 'root',
|
|
@@ -317,6 +339,148 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
317
339
|
}]
|
|
318
340
|
}], ctorParameters: () => [{ type: undefined }] });
|
|
319
341
|
|
|
342
|
+
/**
|
|
343
|
+
* Copyright (c) Siemens 2016 - 2026
|
|
344
|
+
* SPDX-License-Identifier: MIT
|
|
345
|
+
*/
|
|
346
|
+
/**
|
|
347
|
+
* Constructs a full form field including error messages, labels and aria-* attributes.
|
|
348
|
+
* It must be used with Angular's signal forms.
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```html
|
|
352
|
+
* <si-form-field label="Name">
|
|
353
|
+
* <input class="form-control" [formField]="form.name" />
|
|
354
|
+
*
|
|
355
|
+
* <!-- Optional help button -->
|
|
356
|
+
* <button
|
|
357
|
+
* si-help-button
|
|
358
|
+
* type="button"
|
|
359
|
+
* siHelpTitle="Help for name"
|
|
360
|
+
* siHelpContent="The context help description"
|
|
361
|
+
* >More information about the name</button>
|
|
362
|
+
* </si-form-field>
|
|
363
|
+
* ```
|
|
364
|
+
*/
|
|
365
|
+
class SiFormFieldComponent {
|
|
366
|
+
static idCounter = 0;
|
|
367
|
+
/**
|
|
368
|
+
* The label to be displayed in the form field.
|
|
369
|
+
* It will be translated if a translation key is available.
|
|
370
|
+
*/
|
|
371
|
+
label = input.required(/* @ts-ignore */
|
|
372
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
373
|
+
formField = contentChild.required(FormField);
|
|
374
|
+
fieldset = inject(SiFormFieldsetComponent, { optional: true });
|
|
375
|
+
validationErrorService = inject(SiFormValidationErrorService);
|
|
376
|
+
generatedId = `__si-form-field-${SiFormFieldComponent.idCounter++}`;
|
|
377
|
+
/** The id of the connected control, used for the label's `for` attribute. */
|
|
378
|
+
controlId = computed(() => this.formField().element.id || this.generatedId, /* @ts-ignore */
|
|
379
|
+
...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
|
|
380
|
+
errormessageId = computed(() => `${this.controlId()}-errormessage`, /* @ts-ignore */
|
|
381
|
+
...(ngDevMode ? [{ debugName: "errormessageId" }] : /* istanbul ignore next */ []));
|
|
382
|
+
/** Whether the connected control is a form-check (checkbox, radio or switch). */
|
|
383
|
+
isFormCheck = computed(() => this.formField().element.classList.contains('form-check-input'), /* @ts-ignore */
|
|
384
|
+
...(ngDevMode ? [{ debugName: "isFormCheck" }] : /* istanbul ignore next */ []));
|
|
385
|
+
fieldState = computed(() => this.formField().state(), /* @ts-ignore */
|
|
386
|
+
...(ngDevMode ? [{ debugName: "fieldState" }] : /* istanbul ignore next */ []));
|
|
387
|
+
/** @internal */
|
|
388
|
+
control = computed(() => this.fieldState().fieldTree, /* @ts-ignore */
|
|
389
|
+
...(ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []));
|
|
390
|
+
/** @internal */
|
|
391
|
+
required = computed(() => this.fieldState().required(), /* @ts-ignore */
|
|
392
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
393
|
+
invalid = computed(() => {
|
|
394
|
+
const state = this.fieldState();
|
|
395
|
+
return state.touched() && state.invalid();
|
|
396
|
+
}, /* @ts-ignore */
|
|
397
|
+
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
398
|
+
/** @internal */
|
|
399
|
+
touched = computed(() => this.fieldState().touched(), /* @ts-ignore */
|
|
400
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
401
|
+
isPartOfRadioGroup = computed(() => this.fieldset?.hasOnlyRadios() ?? false, /* @ts-ignore */
|
|
402
|
+
...(ngDevMode ? [{ debugName: "isPartOfRadioGroup" }] : /* istanbul ignore next */ []));
|
|
403
|
+
/** @internal */
|
|
404
|
+
errors = computed(() => {
|
|
405
|
+
const state = this.fieldState();
|
|
406
|
+
if (!state.touched()) {
|
|
407
|
+
return [];
|
|
408
|
+
}
|
|
409
|
+
return this.validationErrorService.resolveFormFieldErrors(state);
|
|
410
|
+
}, /* @ts-ignore */
|
|
411
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
412
|
+
constructor() {
|
|
413
|
+
if (this.fieldset) {
|
|
414
|
+
this.fieldset.registerControl(this);
|
|
415
|
+
inject(DestroyRef).onDestroy(() => this.fieldset.unregisterControl(this));
|
|
416
|
+
}
|
|
417
|
+
effect(() => this.syncControlId());
|
|
418
|
+
effect(() => this.syncErrorDescription());
|
|
419
|
+
effect(() => this.syncInvalidState());
|
|
420
|
+
}
|
|
421
|
+
syncControlId() {
|
|
422
|
+
const element = this.formField().element;
|
|
423
|
+
if (!element.id) {
|
|
424
|
+
element.id = this.generatedId;
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
/** Associates the error messages with the projected control for assistive technologies. */
|
|
428
|
+
syncErrorDescription() {
|
|
429
|
+
this.formField().element.setAttribute('aria-describedby', this.errormessageId());
|
|
430
|
+
}
|
|
431
|
+
/**
|
|
432
|
+
* Reflects the validation state onto the projected control via `aria-invalid`. This is needed
|
|
433
|
+
* because signal forms does not set `aria-invalid`, and the native `:user-invalid` pseudo-class
|
|
434
|
+
* ignores `markAsTouched()`. The matching `.ng-invalid`/`.ng-touched` classes that drive the
|
|
435
|
+
* styling are added by signal forms itself, see `provideSiFormFieldConfig()`.
|
|
436
|
+
*/
|
|
437
|
+
syncInvalidState() {
|
|
438
|
+
const element = this.formField().element;
|
|
439
|
+
if (this.invalid()) {
|
|
440
|
+
element.setAttribute('aria-invalid', 'true');
|
|
441
|
+
}
|
|
442
|
+
else {
|
|
443
|
+
element.removeAttribute('aria-invalid');
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
447
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: SiFormFieldComponent, isStandalone: true, selector: "si-form-field", inputs: { label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: true, transformFunction: null } }, host: { properties: { "class.required": "required() && !isPartOfRadioGroup()", "class.form-check": "isFormCheck()", "class.form-check-inline": "fieldset?.inline()" } }, queries: [{ propertyName: "formField", first: true, predicate: FormField, descendants: true, isSignal: true }], ngImport: i0, template: "@if (!isFormCheck()) {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\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 <label [for]=\"controlId()\" [class.required]=\"required() && !isPartOfRadioGroup()\">{{\n label() | translate\n }}</label>\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" }] });
|
|
448
|
+
}
|
|
449
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormFieldComponent, decorators: [{
|
|
450
|
+
type: Component,
|
|
451
|
+
args: [{ selector: 'si-form-field', imports: [SiTranslatePipe, NgTemplateOutlet], host: {
|
|
452
|
+
'[class.required]': 'required() && !isPartOfRadioGroup()',
|
|
453
|
+
'[class.form-check]': 'isFormCheck()',
|
|
454
|
+
'[class.form-check-inline]': 'fieldset?.inline()'
|
|
455
|
+
}, template: "@if (!isFormCheck()) {\n <ng-container [ngTemplateOutlet]=\"labelTemplate\" />\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 <label [for]=\"controlId()\" [class.required]=\"required() && !isPartOfRadioGroup()\">{{\n label() | translate\n }}</label>\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"] }]
|
|
456
|
+
}], ctorParameters: () => [], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], formField: [{ type: i0.ContentChild, args: [i0.forwardRef(() => FormField), { isSignal: true }] }] } });
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* Provides the signal forms configuration required by {@link SiFormFieldComponent}.
|
|
460
|
+
*
|
|
461
|
+
* It restores the `ng-*` classes applied by the directives of {@link @angular/forms#FormsModule | FormsModule} / {@link @angular/forms#ReactiveFormsModule | ReactiveFormsModule}.
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```ts
|
|
465
|
+
* bootstrapApplication(AppComponent, {
|
|
466
|
+
* providers: [provideSiFormFieldConfig()]
|
|
467
|
+
* });
|
|
468
|
+
* ```
|
|
469
|
+
*/
|
|
470
|
+
const provideSiFormFieldConfig = (config = {}) => provideSignalFormsConfig({
|
|
471
|
+
...config,
|
|
472
|
+
classes: {
|
|
473
|
+
...NG_STATUS_CLASSES,
|
|
474
|
+
...config.classes
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Copyright (c) Siemens 2016 - 2026
|
|
480
|
+
* SPDX-License-Identifier: MIT
|
|
481
|
+
*/
|
|
482
|
+
const SI_FORM_ITEM_CONTROL = new InjectionToken('si.form-item.control');
|
|
483
|
+
|
|
320
484
|
/**
|
|
321
485
|
* This will be used by the `si-form-item` to create a form item control if none is provided.
|
|
322
486
|
* This is typically the case for native form controls like `input`, `textarea` and `select`.
|
|
@@ -368,7 +532,8 @@ class SiFormItemComponent {
|
|
|
368
532
|
* The label to be displayed in the form item.
|
|
369
533
|
* It will be translated if a translation key is available.
|
|
370
534
|
*/
|
|
371
|
-
label = input.required(
|
|
535
|
+
label = input.required(/* @ts-ignore */
|
|
536
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
372
537
|
/**
|
|
373
538
|
* A custom width value to be applied to the label.
|
|
374
539
|
* A value of 0 is allowed as well to visually hide away the label area.
|
|
@@ -378,29 +543,35 @@ class SiFormItemComponent {
|
|
|
378
543
|
*
|
|
379
544
|
* @example labelWidth="100px"
|
|
380
545
|
*/
|
|
381
|
-
labelWidth = input(
|
|
546
|
+
labelWidth = input(/* @ts-ignore */
|
|
547
|
+
...(ngDevMode ? [undefined, { debugName: "labelWidth" }] : /* istanbul ignore next */ []));
|
|
382
548
|
/**
|
|
383
549
|
* Disables the automatic error printing. Error printing will be enabled by default in v46.
|
|
384
550
|
*
|
|
385
551
|
* @defaultValue false
|
|
386
552
|
*/
|
|
387
|
-
disableErrorPrinting = input(false, { ...(ngDevMode ? { debugName: "disableErrorPrinting" } : {}), transform: booleanAttribute });
|
|
388
|
-
formErrorMapper = input(
|
|
553
|
+
disableErrorPrinting = input(false, { ...(ngDevMode ? { debugName: "disableErrorPrinting" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
554
|
+
formErrorMapper = input(/* @ts-ignore */
|
|
555
|
+
...(ngDevMode ? [undefined, { debugName: "formErrorMapper" }] : /* istanbul ignore next */ []));
|
|
389
556
|
/**
|
|
390
557
|
* Defines that this form item is required for the overall form to be valid.
|
|
391
558
|
*
|
|
392
559
|
* @defaultValue false
|
|
393
560
|
*/
|
|
394
561
|
// 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 });
|
|
562
|
+
requiredInput = input(false, { ...(ngDevMode ? { debugName: "requiredInput" } : /* istanbul ignore next */ {}), transform: booleanAttribute, alias: 'required' });
|
|
563
|
+
fieldControlQuery = contentChild(SI_FORM_ITEM_CONTROL, { ...(ngDevMode ? { debugName: "fieldControlQuery" } : /* istanbul ignore next */ {}), descendants: true });
|
|
397
564
|
/** @internal */
|
|
398
|
-
ngControl = contentChild(NgControl, { ...(ngDevMode ? { debugName: "ngControl" } : {}), descendants: true });
|
|
399
|
-
controlElementRef = contentChild(NgControl, { ...(ngDevMode ? { debugName: "controlElementRef" } : {}), read: ElementRef,
|
|
565
|
+
ngControl = contentChild(NgControl, { ...(ngDevMode ? { debugName: "ngControl" } : /* istanbul ignore next */ {}), descendants: true });
|
|
566
|
+
controlElementRef = contentChild(NgControl, { ...(ngDevMode ? { debugName: "controlElementRef" } : /* istanbul ignore next */ {}), read: ElementRef,
|
|
400
567
|
descendants: true });
|
|
401
|
-
requiredValidator = contentChild(RequiredValidator, { ...(ngDevMode ? { debugName: "requiredValidator" } : {}), descendants: true });
|
|
568
|
+
requiredValidator = contentChild(RequiredValidator, { ...(ngDevMode ? { debugName: "requiredValidator" } : /* istanbul ignore next */ {}), descendants: true });
|
|
569
|
+
/** @internal */
|
|
570
|
+
errors = signal([], /* @ts-ignore */
|
|
571
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
402
572
|
/** @internal */
|
|
403
|
-
|
|
573
|
+
touched = signal(false, /* @ts-ignore */
|
|
574
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
404
575
|
fieldset = inject(SiFormFieldsetComponent, { optional: true });
|
|
405
576
|
container = inject(SiFormContainerComponent, { optional: true });
|
|
406
577
|
get formItemId() {
|
|
@@ -419,32 +590,41 @@ class SiFormItemComponent {
|
|
|
419
590
|
? (fieldControl?.errormessageId() ?? null)
|
|
420
591
|
: (fieldControl?.errormessageId ?? null);
|
|
421
592
|
}
|
|
422
|
-
fieldControl = computed(() => this.fieldControlQuery() ?? this.fieldControlNative(),
|
|
593
|
+
fieldControl = computed(() => this.fieldControlQuery() ?? this.fieldControlNative(), /* @ts-ignore */
|
|
594
|
+
...(ngDevMode ? [{ debugName: "fieldControl" }] : /* istanbul ignore next */ []));
|
|
423
595
|
validationErrorService = inject(SiFormValidationErrorService);
|
|
424
596
|
requiredTestControl = new FormControl('');
|
|
425
597
|
validator;
|
|
426
598
|
previousErrors;
|
|
427
|
-
hasRequiredValidator = signal(false,
|
|
428
|
-
|
|
599
|
+
hasRequiredValidator = signal(false, /* @ts-ignore */
|
|
600
|
+
...(ngDevMode ? [{ debugName: "hasRequiredValidator" }] : /* istanbul ignore next */ []));
|
|
601
|
+
fieldControlNative = signal(undefined, /* @ts-ignore */
|
|
602
|
+
...(ngDevMode ? [{ debugName: "fieldControlNative" }] : /* istanbul ignore next */ []));
|
|
429
603
|
labelWidthCssVar = computed(() => {
|
|
430
604
|
const labelWidth = this.labelWidth();
|
|
431
605
|
if (typeof labelWidth === 'number') {
|
|
432
606
|
return `${labelWidth}px`;
|
|
433
607
|
}
|
|
434
608
|
return labelWidth;
|
|
435
|
-
},
|
|
609
|
+
}, /* @ts-ignore */
|
|
610
|
+
...(ngDevMode ? [{ debugName: "labelWidthCssVar" }] : /* istanbul ignore next */ []));
|
|
436
611
|
printErrors = computed(() => {
|
|
437
612
|
return !this.disableErrorPrinting() && !(this.container?.disableErrorPrinting() ?? false);
|
|
438
|
-
},
|
|
613
|
+
}, /* @ts-ignore */
|
|
614
|
+
...(ngDevMode ? [{ debugName: "printErrors" }] : /* istanbul ignore next */ []));
|
|
615
|
+
/** @internal */
|
|
616
|
+
required = computed(() => this.requiredInput() || this.hasRequiredValidator(), /* @ts-ignore */
|
|
617
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
439
618
|
/** @internal */
|
|
440
|
-
|
|
619
|
+
control = computed(() => this.ngControl()?.control, /* @ts-ignore */
|
|
620
|
+
...(ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []));
|
|
441
621
|
ngOnChanges(changes) {
|
|
442
622
|
if (changes.formErrorMapper) {
|
|
443
623
|
this.updateValidationMessages();
|
|
444
624
|
}
|
|
445
625
|
}
|
|
446
626
|
ngOnInit() {
|
|
447
|
-
this.fieldset?.
|
|
627
|
+
this.fieldset?.registerControl(this);
|
|
448
628
|
}
|
|
449
629
|
ngAfterContentInit() {
|
|
450
630
|
if (!this.fieldControlQuery()) {
|
|
@@ -454,9 +634,10 @@ class SiFormItemComponent {
|
|
|
454
634
|
ngAfterContentChecked() {
|
|
455
635
|
this.updateRequiredState();
|
|
456
636
|
this.updateValidationMessages();
|
|
637
|
+
this.touched.set(!!this.ngControl()?.touched);
|
|
457
638
|
}
|
|
458
639
|
ngOnDestroy() {
|
|
459
|
-
this.fieldset?.
|
|
640
|
+
this.fieldset?.unregisterControl(this);
|
|
460
641
|
}
|
|
461
642
|
updateRequiredState() {
|
|
462
643
|
const requiredValidator = this.requiredValidator();
|
|
@@ -492,12 +673,12 @@ class SiFormItemComponent {
|
|
|
492
673
|
}
|
|
493
674
|
}
|
|
494
675
|
}
|
|
495
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
496
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
676
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
677
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", 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
678
|
}
|
|
498
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
679
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormItemComponent, decorators: [{
|
|
499
680
|
type: Component,
|
|
500
|
-
args: [{ selector: 'si-form-item', imports: [SiTranslatePipe, NgTemplateOutlet],
|
|
681
|
+
args: [{ selector: 'si-form-item', imports: [SiTranslatePipe, NgTemplateOutlet], host: {
|
|
501
682
|
'[class.required]': 'required()',
|
|
502
683
|
'[style.--si-form-label-width]': 'labelWidthCssVar()',
|
|
503
684
|
'[class.form-check]': 'fieldControl()?.isFormCheck',
|
|
@@ -516,14 +697,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
516
697
|
const SI_FORM_VALIDATION_TOOLTIP_DATA = new InjectionToken('SiFormValidationTooltipData');
|
|
517
698
|
class SiFormValidationTooltipComponent {
|
|
518
699
|
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: "
|
|
700
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormValidationTooltipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
701
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: SiFormValidationTooltipComponent, isStandalone: true, selector: "si-form-validation-tooltip", host: { classAttribute: "d-flex flex-column gap-2 text-start" }, ngImport: i0, template: `
|
|
521
702
|
@for (error of errors(); track error.key) {
|
|
522
703
|
<div>{{ error.message | translate: error.params }}</div>
|
|
523
704
|
}
|
|
524
|
-
`, isInline: true, dependencies: [{ kind: "pipe", type: SiTranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.
|
|
705
|
+
`, isInline: true, dependencies: [{ kind: "pipe", type: SiTranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
|
|
525
706
|
}
|
|
526
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
707
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormValidationTooltipComponent, decorators: [{
|
|
527
708
|
type: Component,
|
|
528
709
|
args: [{
|
|
529
710
|
selector: 'si-form-validation-tooltip',
|
|
@@ -533,7 +714,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
533
714
|
<div>{{ error.message | translate: error.params }}</div>
|
|
534
715
|
}
|
|
535
716
|
`,
|
|
536
|
-
changeDetection: ChangeDetectionStrategy.
|
|
717
|
+
changeDetection: ChangeDetectionStrategy.Eager,
|
|
537
718
|
host: {
|
|
538
719
|
'class': 'd-flex flex-column gap-2 text-start'
|
|
539
720
|
}
|
|
@@ -561,70 +742,62 @@ class SiFormValidationTooltipDirective {
|
|
|
561
742
|
tooltipService = inject(SiTooltipService);
|
|
562
743
|
formValidationService = inject(SiFormValidationErrorService);
|
|
563
744
|
formContainer = inject(SiFormContainerComponent, { optional: true });
|
|
564
|
-
formErrorMapper = input(
|
|
745
|
+
formErrorMapper = input(/* @ts-ignore */
|
|
746
|
+
...(ngDevMode ? [undefined, { debugName: "formErrorMapper" }] : /* istanbul ignore next */ []));
|
|
565
747
|
ngControl = inject(NgControl);
|
|
566
748
|
elementRef = inject(ElementRef);
|
|
567
749
|
tooltipRef;
|
|
568
|
-
errors = signal([],
|
|
750
|
+
errors = signal([], /* @ts-ignore */
|
|
751
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
569
752
|
currentErrors = null;
|
|
570
753
|
touched = null;
|
|
571
|
-
// Use a counter to track how many events are matched that keep the tooltip active.
|
|
572
|
-
// Active means we are listening to error changes.
|
|
573
|
-
activationCount = 0;
|
|
574
754
|
describedBy = `__si-form-validation-tooltip-${SiFormValidationTooltipDirective.idCounter++}`;
|
|
575
755
|
ngDoCheck() {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
this.
|
|
756
|
+
const nextErrors = this.ngControl.errors;
|
|
757
|
+
const nextTouched = this.ngControl.touched;
|
|
758
|
+
if (this.currentErrors !== nextErrors || this.touched !== nextTouched) {
|
|
759
|
+
this.currentErrors = nextErrors;
|
|
760
|
+
this.touched = nextTouched;
|
|
580
761
|
this.updateErrors();
|
|
581
762
|
}
|
|
582
763
|
}
|
|
583
764
|
ngOnDestroy() {
|
|
584
765
|
this.destroyTooltip();
|
|
585
766
|
}
|
|
586
|
-
increaseActivation() {
|
|
587
|
-
this.activationCount++;
|
|
588
|
-
if (this.activationCount === 1) {
|
|
589
|
-
this.updateErrors();
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
767
|
updateErrors() {
|
|
593
768
|
const errors = this.formValidationService
|
|
594
769
|
.resolveErrors(this.ngControl.name, this.currentErrors, this.formErrorMapper(), this.formContainer?.formErrorMapper())
|
|
595
770
|
.filter(error => !!error.message);
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
element: this.elementRef,
|
|
600
|
-
describedBy: this.describedBy,
|
|
601
|
-
injector: Injector.create({
|
|
602
|
-
providers: [{ provide: SI_FORM_VALIDATION_TOOLTIP_DATA, useValue: this.errors }]
|
|
603
|
-
}),
|
|
604
|
-
tooltip: () => SiFormValidationTooltipComponent,
|
|
605
|
-
tooltipContext: () => undefined
|
|
606
|
-
});
|
|
607
|
-
this.tooltipRef.show();
|
|
771
|
+
const shouldShow = errors.length > 0 && !!this.ngControl.touched;
|
|
772
|
+
if (shouldShow) {
|
|
773
|
+
this.createTooltip();
|
|
608
774
|
}
|
|
609
|
-
else
|
|
775
|
+
else {
|
|
610
776
|
this.destroyTooltip();
|
|
611
777
|
}
|
|
612
778
|
this.errors.set(errors);
|
|
613
779
|
}
|
|
614
|
-
|
|
615
|
-
this.
|
|
616
|
-
|
|
617
|
-
this.
|
|
618
|
-
|
|
780
|
+
createTooltip() {
|
|
781
|
+
this.tooltipRef ??= this.tooltipService.createTooltip({
|
|
782
|
+
placement: 'auto',
|
|
783
|
+
element: this.elementRef,
|
|
784
|
+
describedBy: this.describedBy,
|
|
785
|
+
injector: Injector.create({
|
|
786
|
+
providers: [{ provide: SI_FORM_VALIDATION_TOOLTIP_DATA, useValue: this.errors }]
|
|
787
|
+
}),
|
|
788
|
+
tooltip: () => SiFormValidationTooltipComponent,
|
|
789
|
+
// Not actually used, but errors in the context triggers a resize if the errors changes.
|
|
790
|
+
tooltipContext: () => this.errors()
|
|
791
|
+
});
|
|
619
792
|
}
|
|
620
793
|
destroyTooltip() {
|
|
621
794
|
this.tooltipRef?.destroy();
|
|
622
795
|
this.tooltipRef = undefined;
|
|
623
796
|
}
|
|
624
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
625
|
-
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "
|
|
797
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormValidationTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
798
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.0.5", 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 });
|
|
626
799
|
}
|
|
627
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
800
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormValidationTooltipDirective, decorators: [{
|
|
628
801
|
type: Directive,
|
|
629
802
|
args: [{
|
|
630
803
|
selector: '[siFormValidationTooltip]',
|
|
@@ -633,19 +806,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
633
806
|
'[attr.aria-describedby]': 'describedBy'
|
|
634
807
|
}
|
|
635
808
|
}]
|
|
636
|
-
}], propDecorators: { formErrorMapper: [{ type: i0.Input, args: [{ isSignal: true, alias: "formErrorMapper", required: false }] }]
|
|
637
|
-
type: HostListener,
|
|
638
|
-
args: ['focus']
|
|
639
|
-
}, {
|
|
640
|
-
type: HostListener,
|
|
641
|
-
args: ['mouseenter']
|
|
642
|
-
}], decreaseActivation: [{
|
|
643
|
-
type: HostListener,
|
|
644
|
-
args: ['blur']
|
|
645
|
-
}, {
|
|
646
|
-
type: HostListener,
|
|
647
|
-
args: ['mouseleave']
|
|
648
|
-
}] } });
|
|
809
|
+
}], propDecorators: { formErrorMapper: [{ type: i0.Input, args: [{ isSignal: true, alias: "formErrorMapper", required: false }] }] } });
|
|
649
810
|
|
|
650
811
|
/**
|
|
651
812
|
* The error mapper is used to resolve an angular validation error to a {@link TranslatableString}.
|
|
@@ -675,11 +836,11 @@ class SiFormModule {
|
|
|
675
836
|
providers: [provideFormValidationErrorMapper(validationErrorMapper)]
|
|
676
837
|
};
|
|
677
838
|
}
|
|
678
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
679
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
680
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
839
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
840
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.5", ngImport: i0, type: SiFormModule, imports: [SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent], exports: [SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent] });
|
|
841
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormModule });
|
|
681
842
|
}
|
|
682
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
843
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: SiFormModule, decorators: [{
|
|
683
844
|
type: NgModule,
|
|
684
845
|
args: [{
|
|
685
846
|
imports: [SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent],
|
|
@@ -696,5 +857,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
696
857
|
* Generated bundle index. Do not edit.
|
|
697
858
|
*/
|
|
698
859
|
|
|
699
|
-
export { SI_FORM_ITEM_CONTROL, SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent, SiFormModule, SiFormValidationTooltipDirective, provideFormValidationErrorMapper };
|
|
860
|
+
export { SI_FORM_ITEM_CONTROL, SiFormContainerComponent, SiFormFieldComponent, SiFormFieldsetComponent, SiFormItemComponent, SiFormModule, SiFormValidationTooltipDirective, provideFormValidationErrorMapper, provideSiFormFieldConfig };
|
|
700
861
|
//# sourceMappingURL=siemens-element-ng-form.mjs.map
|