@siemens/element-ng 49.16.0 → 51.0.0-rc.10
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 +59 -41
- 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 +143 -148
- package/fesm2022/siemens-element-ng-ag-grid.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-application-header.mjs +180 -188
- 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 +34 -24
- 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 +72 -47
- package/fesm2022/siemens-element-ng-card.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-carousel.mjs +58 -34
- package/fesm2022/siemens-element-ng-carousel.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-chat-messages.mjs +323 -215
- 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 +44 -34
- package/fesm2022/siemens-element-ng-color-picker.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-column-selection-dialog.mjs +58 -37
- package/fesm2022/siemens-element-ng-column-selection-dialog.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-common.mjs +22 -22
- package/fesm2022/siemens-element-ng-common.mjs.map +1 -1
- 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 +37 -28
- 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 +337 -223
- package/fesm2022/siemens-element-ng-dashboard.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-datatable.mjs +12 -15
- package/fesm2022/siemens-element-ng-datatable.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-date-range-filter.mjs +126 -76
- package/fesm2022/siemens-element-ng-date-range-filter.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-datepicker.mjs +393 -251
- 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 +33 -25
- package/fesm2022/siemens-element-ng-filter-bar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-filtered-search.mjs +274 -165
- 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 +361 -116
- 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 +224 -318
- 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 +6 -6
- package/fesm2022/siemens-element-ng-help-button.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-icon.mjs +56 -57
- 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 +19 -15
- package/fesm2022/siemens-element-ng-ip-input.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-landing-page.mjs +121 -75
- 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 +132 -66
- package/fesm2022/siemens-element-ng-list-details.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-loading-spinner.mjs +51 -64
- 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 +116 -51
- package/fesm2022/siemens-element-ng-main-detail-container.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-maplibre.mjs +401 -0
- package/fesm2022/siemens-element-ng-maplibre.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-markdown-directives-tabs.mjs +70 -0
- package/fesm2022/siemens-element-ng-markdown-directives-tabs.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-markdown-extensions-citations.mjs +215 -0
- package/fesm2022/siemens-element-ng-markdown-extensions-citations.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-markdown-extensions-katex.mjs +76 -0
- package/fesm2022/siemens-element-ng-markdown-extensions-katex.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-markdown-extensions-mermaid.mjs +86 -0
- package/fesm2022/siemens-element-ng-markdown-extensions-mermaid.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-markdown-hightlighter-highlightjs.mjs +130 -0
- package/fesm2022/siemens-element-ng-markdown-hightlighter-highlightjs.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-markdown.mjs +800 -0
- package/fesm2022/siemens-element-ng-markdown.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-menu.mjs +71 -57
- 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 +251 -206
- package/fesm2022/siemens-element-ng-navbar-vertical-next.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-navbar-vertical.mjs +123 -86
- 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 +41 -29
- 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 +33 -24
- package/fesm2022/siemens-element-ng-password-strength.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-password-toggle.mjs +19 -14
- package/fesm2022/siemens-element-ng-password-toggle.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-phone-number.mjs +144 -139
- package/fesm2022/siemens-element-ng-phone-number.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-photo-upload.mjs +85 -52
- package/fesm2022/siemens-element-ng-photo-upload.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-pills-input.mjs +56 -41
- 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 -37
- package/fesm2022/siemens-element-ng-search-bar.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-select.mjs +265 -170
- package/fesm2022/siemens-element-ng-select.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-shadow-root.mjs +4 -4
- package/fesm2022/siemens-element-ng-shadow-root.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-side-panel.mjs +181 -104
- 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 +45 -30
- package/fesm2022/siemens-element-ng-slider.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-source-chip.mjs +79 -0
- package/fesm2022/siemens-element-ng-source-chip.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-split.mjs +290 -306
- package/fesm2022/siemens-element-ng-split.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-status-bar.mjs +66 -52
- 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 +13 -10
- 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 +156 -131
- 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 +62 -42
- package/fesm2022/siemens-element-ng-threshold.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-toast-notification.mjs +59 -40
- package/fesm2022/siemens-element-ng-toast-notification.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tooltip.mjs +108 -82
- package/fesm2022/siemens-element-ng-tooltip.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-tour.mjs +36 -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 +113 -84
- package/fesm2022/siemens-element-ng-tree-view.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-typeahead.mjs +69 -49
- package/fesm2022/siemens-element-ng-typeahead.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-wizard.mjs +95 -54
- 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 +724 -0
- package/markdown/directives/tabs/package.json +4 -0
- package/markdown/extensions/citations/package.json +4 -0
- package/markdown/extensions/katex/package.json +4 -0
- package/markdown/extensions/mermaid/package.json +4 -0
- package/markdown/hightlighter/highlightjs/package.json +4 -0
- package/markdown/package.json +4 -0
- package/package.json +96 -25
- package/schematics/collection.json +5 -0
- package/schematics/{migrations/icon-path-migration → migrate-tabs-legacy}/index.js +1 -1
- package/schematics/migrate-tabs-legacy/migrate-tabs-legacy-rule.js +675 -0
- package/schematics/migrate-tabs-legacy/schema.json +14 -0
- 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/component-property-to-child.js +11 -0
- package/schematics/migrations/data/css-custom-properties.js +224 -0
- package/schematics/migrations/data/element-class-changes.js +116 -18
- package/schematics/migrations/data/element-migration-data.js +6 -0
- package/schematics/migrations/data/element-selectors.js +1 -9
- package/schematics/migrations/data/index.js +0 -4
- package/schematics/migrations/data/migration-test-data.js +49 -6
- package/schematics/migrations/data/provider-function-removals.js +7 -0
- package/schematics/migrations/data/symbol-removals.js +17 -7
- package/schematics/migrations/data/symbol-renaming.js +3 -44
- package/schematics/migrations/element-migration/element-migration.js +6 -6
- package/schematics/migrations/utilities/component-property-to-child.migration.js +73 -0
- package/schematics/migrations/utilities/css-custom-property.migration.js +51 -0
- package/schematics/migrations/utilities/element-class-change.migration.js +10 -5
- package/schematics/migrations/utilities/import-removal.js +39 -0
- package/schematics/migrations/utilities/index.js +4 -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-content-formatter.js +288 -0
- package/schematics/ng-update/migrate-list-details-units.js +86 -0
- package/schematics/ng-update/migrate-main-detail-units.js +89 -0
- package/schematics/ng-update/migrate-markdown-renderer.js +106 -0
- package/schematics/ng-update/migrate-spacers.js +32 -0
- package/schematics/ng-update/migrate-split-collapse.js +276 -0
- package/schematics/ng-update/migrate-split-scale.js +524 -0
- package/schematics/ng-update/migrate-split-sizes.js +107 -0
- package/schematics/ng-update/migrate-to-v51.js +35 -0
- package/schematics/utils/index.js +1 -0
- package/schematics/utils/template-edit-utils.js +35 -0
- package/schematics/utils/template-utils.js +31 -45
- package/source-chip/package.json +4 -0
- package/template-i18n.json +78 -47
- package/types/siemens-element-ng-application-header.d.ts +7 -33
- package/types/siemens-element-ng-avatar.d.ts +1 -1
- package/types/siemens-element-ng-breadcrumb.d.ts +1 -1
- package/types/siemens-element-ng-chat-messages.d.ts +118 -70
- 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-datatable.d.ts +5 -56
- package/types/siemens-element-ng-date-range-filter.d.ts +1 -1
- package/types/siemens-element-ng-datepicker.d.ts +8 -15
- 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 +183 -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-landing-page.d.ts +2 -2
- package/types/siemens-element-ng-list-details.d.ts +25 -3
- package/types/siemens-element-ng-loading-spinner.d.ts +11 -17
- package/types/siemens-element-ng-main-detail-container.d.ts +23 -3
- package/types/siemens-element-ng-maplibre.d.ts +190 -0
- package/types/siemens-element-ng-markdown-directives-tabs.d.ts +10 -0
- package/types/siemens-element-ng-markdown-extensions-citations.d.ts +11 -0
- package/types/siemens-element-ng-markdown-extensions-katex.d.ts +19 -0
- package/types/siemens-element-ng-markdown-extensions-mermaid.d.ts +11 -0
- package/types/siemens-element-ng-markdown-hightlighter-highlightjs.d.ts +48 -0
- package/types/siemens-element-ng-markdown.d.ts +367 -0
- package/types/siemens-element-ng-menu.d.ts +2 -0
- package/types/siemens-element-ng-navbar-vertical-next.d.ts +87 -39
- 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 +28 -10
- 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 +2 -9
- package/types/siemens-element-ng-select.d.ts +32 -5
- package/types/siemens-element-ng-side-panel.d.ts +25 -11
- package/types/siemens-element-ng-source-chip.d.ts +53 -0
- package/types/siemens-element-ng-split.d.ts +101 -78
- 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-system-banner.d.ts +2 -2
- 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 +35 -5
- package/types/siemens-element-ng-tree-view.d.ts +3 -0
- package/types/siemens-element-ng-wizard.d.ts +18 -3
- 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-markdown-renderer.mjs +0 -263
- package/fesm2022/siemens-element-ng-markdown-renderer.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/markdown-renderer/package.json +0 -4
- package/schematics/migrations/icon-path-migration/icon-path-migration.js +0 -95
- package/schematics/ng-update/migrate-to-v49.js +0 -21
- 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-markdown-renderer.d.ts +0 -36
- 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.8", ngImport: i0, type: SiFormContainerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
170
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", 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.8", 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,61 +183,66 @@ 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
|
-
//
|
|
208
|
+
// Reactive and signal form radios share a control, while template-driven radios share a name.
|
|
161
209
|
const items = this.formItems();
|
|
162
210
|
if (items.length > 1) {
|
|
163
|
-
const first = items[0];
|
|
164
|
-
|
|
211
|
+
const first = items[0].control();
|
|
212
|
+
const firstRadioGroupName = items[0].radioGroupName?.();
|
|
213
|
+
return ((first != null && items.every(item => item.control() === first)) ||
|
|
214
|
+
(firstRadioGroupName != null &&
|
|
215
|
+
items.every(item => item.radioGroupName?.() === firstRadioGroupName)));
|
|
165
216
|
}
|
|
166
217
|
return false;
|
|
167
|
-
},
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
touched =
|
|
172
|
-
|
|
218
|
+
}, /* @ts-ignore */
|
|
219
|
+
...(ngDevMode ? [{ debugName: "hasOnlyRadios" }] : /* istanbul ignore next */ []));
|
|
220
|
+
errors = computed(() => this.formItems()[0].errors(), /* @ts-ignore */
|
|
221
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
222
|
+
touched = computed(() => this.formItems().some(item => item.touched()), /* @ts-ignore */
|
|
223
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
224
|
+
isRequired = computed(() => this.required() || (this.hasOnlyRadios() && this.formItems().every(item => item.required())), /* @ts-ignore */
|
|
225
|
+
...(ngDevMode ? [{ debugName: "isRequired" }] : /* istanbul ignore next */ []));
|
|
173
226
|
labelId = `__si-form-fieldset-label-${SiFormFieldsetComponent.labelIdCounter++}`;
|
|
174
|
-
ngDoCheck() {
|
|
175
|
-
this.touched.set(this.formItems().some(item => item.ngControl()?.touched));
|
|
176
|
-
}
|
|
177
227
|
/** @internal */
|
|
178
|
-
|
|
228
|
+
registerControl(item) {
|
|
179
229
|
this.formItems.update(items => [...items, item]);
|
|
180
230
|
}
|
|
181
231
|
/** @internal */
|
|
182
|
-
|
|
232
|
+
unregisterControl(item) {
|
|
183
233
|
this.formItems.update(items => items.filter(i => i !== item));
|
|
184
234
|
}
|
|
185
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
186
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
235
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormFieldsetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
236
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", 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-fieldset" }, 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 <div [class]=\"inline() ? '' : 'd-flex flex-column gap-2 mb-2'\">\n <ng-content />\n </div>\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-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:calc(calc(var(--si-sys-sizing-spacing-y-40) - 1px) + 1px);padding-inline:var(--si-sys-sizing-spacing-x-60);inline-size:var(--si-form-label-width, 16.6666666667%);line-height:calc(var(--si-sys-typography-font-size-body) * var(--si-sys-typography-line-height-body))}: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:var(--si-sys-sizing-spacing-y-10) 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
237
|
}
|
|
188
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
238
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormFieldsetComponent, decorators: [{
|
|
189
239
|
type: Component,
|
|
190
|
-
args: [{ selector: 'si-form-fieldset', imports: [SiTranslatePipe],
|
|
240
|
+
args: [{ selector: 'si-form-fieldset', imports: [SiTranslatePipe], host: {
|
|
191
241
|
role: 'group',
|
|
192
|
-
class: 'si-form-
|
|
242
|
+
class: 'si-form-fieldset',
|
|
193
243
|
'[style.--si-form-label-width]': 'labelWidth()',
|
|
194
244
|
'[attr.aria-labelledby]': 'labelId'
|
|
195
|
-
}, 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
|
|
245
|
+
}, 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 <div [class]=\"inline() ? '' : 'd-flex flex-column gap-2 mb-2'\">\n <ng-content />\n </div>\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-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:calc(calc(var(--si-sys-sizing-spacing-y-40) - 1px) + 1px);padding-inline:var(--si-sys-sizing-spacing-x-60);inline-size:var(--si-form-label-width, 16.6666666667%);line-height:calc(var(--si-sys-typography-font-size-body) * var(--si-sys-typography-line-height-body))}: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:var(--si-sys-sizing-spacing-y-10) 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
246
|
}], 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
247
|
|
|
198
248
|
/**
|
|
@@ -242,7 +292,7 @@ const buildDefaults = () => ({
|
|
|
242
292
|
// Various
|
|
243
293
|
email: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.EMAIL:Invalid email address`),
|
|
244
294
|
numberFormat: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.NUMBER_FORMAT:Number required`),
|
|
245
|
-
pattern: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.PATTERN:
|
|
295
|
+
pattern: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.PATTERN:Required value format not fulfilled`),
|
|
246
296
|
required: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.REQUIRED:Required`),
|
|
247
297
|
requiredTrue: t(() => $localize `:@@SI_FORM_CONTAINER.ERROR.REQUIRED_TRUE:Required`)
|
|
248
298
|
});
|
|
@@ -267,6 +317,30 @@ class SiFormValidationErrorService {
|
|
|
267
317
|
constructor(errorMapper) {
|
|
268
318
|
this.errorMapper = errorMapper;
|
|
269
319
|
}
|
|
320
|
+
/**
|
|
321
|
+
* Resolves validation errors for Angular signal forms.
|
|
322
|
+
*
|
|
323
|
+
* If the validation error has no message associated, the resolution flow of {@link resolveErrors} is followed.
|
|
324
|
+
*
|
|
325
|
+
* @param state - the fieldState of the formfield.
|
|
326
|
+
*/
|
|
327
|
+
resolveFormFieldErrors(state) {
|
|
328
|
+
return state.errors().map(error => {
|
|
329
|
+
const { message, kind, fieldTree, formField, ...rawErrorParams } = error;
|
|
330
|
+
const errorParams = this.getErrorParams(rawErrorParams);
|
|
331
|
+
if (!message) {
|
|
332
|
+
return this.resolveError(kind, state.name(), errorParams);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
return { message, key: kind, params: errorParams };
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
/** Returns legacy reactive-form parameters stored in `context`, or the signal-form error. */
|
|
340
|
+
getErrorParams(error) {
|
|
341
|
+
const { context } = error;
|
|
342
|
+
return context ?? error;
|
|
343
|
+
}
|
|
270
344
|
/**
|
|
271
345
|
* Resolves the provided form errors to a list of {@link SiFormError}.
|
|
272
346
|
* To resolution order is:
|
|
@@ -306,10 +380,10 @@ class SiFormValidationErrorService {
|
|
|
306
380
|
}
|
|
307
381
|
return undefined;
|
|
308
382
|
}
|
|
309
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
310
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "
|
|
383
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormValidationErrorService, deps: "invalid", target: i0.ɵɵFactoryTarget.Injectable });
|
|
384
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormValidationErrorService, providedIn: 'root', useFactory: () => new SiFormValidationErrorService(buildDefaults()) });
|
|
311
385
|
}
|
|
312
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
386
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormValidationErrorService, decorators: [{
|
|
313
387
|
type: Injectable,
|
|
314
388
|
args: [{
|
|
315
389
|
providedIn: 'root',
|
|
@@ -317,6 +391,160 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
317
391
|
}]
|
|
318
392
|
}], ctorParameters: () => [{ type: undefined }] });
|
|
319
393
|
|
|
394
|
+
/**
|
|
395
|
+
* Copyright (c) Siemens 2016 - 2026
|
|
396
|
+
* SPDX-License-Identifier: MIT
|
|
397
|
+
*/
|
|
398
|
+
/**
|
|
399
|
+
* Constructs a full form field including error messages, labels and aria-* attributes.
|
|
400
|
+
* It must be used with Angular's signal forms.
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```html
|
|
404
|
+
* <si-form-field label="Name">
|
|
405
|
+
* <input class="form-control" [formField]="form.name" />
|
|
406
|
+
*
|
|
407
|
+
* <!-- Optional help button -->
|
|
408
|
+
* <button
|
|
409
|
+
* si-help-button
|
|
410
|
+
* type="button"
|
|
411
|
+
* siHelpTitle="Help for name"
|
|
412
|
+
* siHelpContent="The context help description"
|
|
413
|
+
* >More information about the name</button>
|
|
414
|
+
* </si-form-field>
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
class SiFormFieldComponent {
|
|
418
|
+
static idCounter = 0;
|
|
419
|
+
/**
|
|
420
|
+
* The label to be displayed in the form field.
|
|
421
|
+
* It will be translated if a translation key is available.
|
|
422
|
+
*/
|
|
423
|
+
label = input.required(/* @ts-ignore */
|
|
424
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
425
|
+
formField = contentChild.required(FormField, /* @ts-ignore */
|
|
426
|
+
...(ngDevMode ? [{ debugName: "formField" }] : /* istanbul ignore next */ []));
|
|
427
|
+
fieldControl = contentChild(SI_FORM_ITEM_CONTROL, { ...(ngDevMode ? { debugName: "fieldControl" } : /* istanbul ignore next */ {}), descendants: true });
|
|
428
|
+
fieldset = inject(SiFormFieldsetComponent, { optional: true });
|
|
429
|
+
validationErrorService = inject(SiFormValidationErrorService);
|
|
430
|
+
generatedId = `__si-form-field-${SiFormFieldComponent.idCounter++}`;
|
|
431
|
+
/** The id of the connected control, used for the label's `for` attribute. */
|
|
432
|
+
controlId = computed(() => {
|
|
433
|
+
const id = this.fieldControl()?.id;
|
|
434
|
+
return (isSignal(id) ? id() : id) ?? (this.formField().element.id || this.generatedId);
|
|
435
|
+
}, /* @ts-ignore */
|
|
436
|
+
...(ngDevMode ? [{ debugName: "controlId" }] : /* istanbul ignore next */ []));
|
|
437
|
+
errormessageId = computed(() => {
|
|
438
|
+
const id = this.fieldControl()?.errormessageId;
|
|
439
|
+
return (isSignal(id) ? id() : id) ?? `${this.controlId()}-errormessage`;
|
|
440
|
+
}, /* @ts-ignore */
|
|
441
|
+
...(ngDevMode ? [{ debugName: "errormessageId" }] : /* istanbul ignore next */ []));
|
|
442
|
+
labelledby = computed(() => {
|
|
443
|
+
const labelledby = this.fieldControl()?.labelledby;
|
|
444
|
+
return isSignal(labelledby) ? labelledby() : labelledby;
|
|
445
|
+
}, /* @ts-ignore */
|
|
446
|
+
...(ngDevMode ? [{ debugName: "labelledby" }] : /* istanbul ignore next */ []));
|
|
447
|
+
/** Whether the connected control is a form-check (checkbox, radio or switch). */
|
|
448
|
+
isFormCheck = computed(() => this.fieldControl()?.isFormCheck ??
|
|
449
|
+
this.formField().element.classList.contains('form-check-input'), /* @ts-ignore */
|
|
450
|
+
...(ngDevMode ? [{ debugName: "isFormCheck" }] : /* istanbul ignore next */ []));
|
|
451
|
+
fieldState = computed(() => this.formField().state(), /* @ts-ignore */
|
|
452
|
+
...(ngDevMode ? [{ debugName: "fieldState" }] : /* istanbul ignore next */ []));
|
|
453
|
+
/** @internal */
|
|
454
|
+
control = computed(() => this.fieldState().fieldTree, /* @ts-ignore */
|
|
455
|
+
...(ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []));
|
|
456
|
+
/** @internal */
|
|
457
|
+
required = computed(() => this.fieldState().required(), /* @ts-ignore */
|
|
458
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
459
|
+
/** @internal */
|
|
460
|
+
showRequired = computed(() => this.required() && !this.isPartOfRadioGroup(), /* @ts-ignore */
|
|
461
|
+
...(ngDevMode ? [{ debugName: "showRequired" }] : /* istanbul ignore next */ []));
|
|
462
|
+
invalid = computed(() => {
|
|
463
|
+
const state = this.fieldState();
|
|
464
|
+
return state.touched() && state.invalid();
|
|
465
|
+
}, /* @ts-ignore */
|
|
466
|
+
...(ngDevMode ? [{ debugName: "invalid" }] : /* istanbul ignore next */ []));
|
|
467
|
+
/** @internal */
|
|
468
|
+
touched = computed(() => this.fieldState().touched(), /* @ts-ignore */
|
|
469
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
470
|
+
isPartOfRadioGroup = computed(() => this.fieldset?.hasOnlyRadios() ?? false, /* @ts-ignore */
|
|
471
|
+
...(ngDevMode ? [{ debugName: "isPartOfRadioGroup" }] : /* istanbul ignore next */ []));
|
|
472
|
+
/** @internal */
|
|
473
|
+
errors = computed(() => {
|
|
474
|
+
const state = this.fieldState();
|
|
475
|
+
if (!state.touched()) {
|
|
476
|
+
return [];
|
|
477
|
+
}
|
|
478
|
+
return this.validationErrorService.resolveFormFieldErrors(state);
|
|
479
|
+
}, /* @ts-ignore */
|
|
480
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
481
|
+
constructor() {
|
|
482
|
+
if (this.fieldset) {
|
|
483
|
+
this.fieldset.registerControl(this);
|
|
484
|
+
inject(DestroyRef).onDestroy(() => this.fieldset.unregisterControl(this));
|
|
485
|
+
}
|
|
486
|
+
effect(() => this.syncControlId());
|
|
487
|
+
effect(() => this.syncErrorDescription());
|
|
488
|
+
effect(() => this.syncInvalidState());
|
|
489
|
+
}
|
|
490
|
+
syncControlId() {
|
|
491
|
+
const element = this.formField().element;
|
|
492
|
+
if (!element.id) {
|
|
493
|
+
element.id = this.generatedId;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
/** Associates the error messages with the projected control for assistive technologies. */
|
|
497
|
+
syncErrorDescription() {
|
|
498
|
+
this.formField().element.setAttribute('aria-describedby', this.errormessageId());
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Reflects the validation state onto the projected control via `aria-invalid`. This is needed
|
|
502
|
+
* because signal forms does not set `aria-invalid`, and the native `:user-invalid` pseudo-class
|
|
503
|
+
* ignores `markAsTouched()`. The matching `.ng-invalid`/`.ng-touched` classes that drive the
|
|
504
|
+
* styling are added by signal forms itself, see `provideSiFormFieldConfig()`.
|
|
505
|
+
*/
|
|
506
|
+
syncInvalidState() {
|
|
507
|
+
const element = this.formField().element;
|
|
508
|
+
if (this.invalid()) {
|
|
509
|
+
element.setAttribute('aria-invalid', 'true');
|
|
510
|
+
}
|
|
511
|
+
else {
|
|
512
|
+
element.removeAttribute('aria-invalid');
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormFieldComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
516
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", 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(.si-form-input){margin-block-end:var(--si-sys-sizing-spacing-y-60)}: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" }] });
|
|
517
|
+
}
|
|
518
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormFieldComponent, decorators: [{
|
|
519
|
+
type: Component,
|
|
520
|
+
args: [{ selector: 'si-form-field', imports: [SiTranslatePipe, NgTemplateOutlet], host: {
|
|
521
|
+
'[class.required]': 'showRequired()',
|
|
522
|
+
'[class.form-check]': 'isFormCheck()',
|
|
523
|
+
'[class.form-check-inline]': 'fieldset?.inline()',
|
|
524
|
+
'[class.si-form-input]': '!fieldset'
|
|
525
|
+
}, 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(.si-form-input){margin-block-end:var(--si-sys-sizing-spacing-y-60)}: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"] }]
|
|
526
|
+
}], 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 }] }] } });
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Provides the signal forms configuration required by {@link SiFormFieldComponent}.
|
|
530
|
+
*
|
|
531
|
+
* It restores the `ng-*` classes applied by the directives of {@link @angular/forms#FormsModule | FormsModule} / {@link @angular/forms#ReactiveFormsModule | ReactiveFormsModule}.
|
|
532
|
+
*
|
|
533
|
+
* @example
|
|
534
|
+
* ```ts
|
|
535
|
+
* bootstrapApplication(AppComponent, {
|
|
536
|
+
* providers: [provideSiFormFieldConfig()]
|
|
537
|
+
* });
|
|
538
|
+
* ```
|
|
539
|
+
*/
|
|
540
|
+
const provideSiFormFieldConfig = (config = {}) => provideSignalFormsConfig({
|
|
541
|
+
...config,
|
|
542
|
+
classes: {
|
|
543
|
+
...NG_STATUS_CLASSES,
|
|
544
|
+
...config.classes
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
|
|
320
548
|
/**
|
|
321
549
|
* This will be used by the `si-form-item` to create a form item control if none is provided.
|
|
322
550
|
* This is typically the case for native form controls like `input`, `textarea` and `select`.
|
|
@@ -368,7 +596,8 @@ class SiFormItemComponent {
|
|
|
368
596
|
* The label to be displayed in the form item.
|
|
369
597
|
* It will be translated if a translation key is available.
|
|
370
598
|
*/
|
|
371
|
-
label = input.required(
|
|
599
|
+
label = input.required(/* @ts-ignore */
|
|
600
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
372
601
|
/**
|
|
373
602
|
* A custom width value to be applied to the label.
|
|
374
603
|
* A value of 0 is allowed as well to visually hide away the label area.
|
|
@@ -378,30 +607,36 @@ class SiFormItemComponent {
|
|
|
378
607
|
*
|
|
379
608
|
* @example labelWidth="100px"
|
|
380
609
|
*/
|
|
381
|
-
labelWidth = input(
|
|
610
|
+
labelWidth = input(/* @ts-ignore */
|
|
611
|
+
...(ngDevMode ? [undefined, { debugName: "labelWidth" }] : /* istanbul ignore next */ []));
|
|
382
612
|
/**
|
|
383
613
|
* Disables the automatic error printing. Error printing will be enabled by default in v46.
|
|
384
614
|
*
|
|
385
615
|
* @defaultValue false
|
|
386
616
|
*/
|
|
387
|
-
disableErrorPrinting = input(false, { ...(ngDevMode ? { debugName: "disableErrorPrinting" } : {}), transform: booleanAttribute });
|
|
617
|
+
disableErrorPrinting = input(false, { ...(ngDevMode ? { debugName: "disableErrorPrinting" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
388
618
|
/** Maps validation errors of the contained control to custom messages. */
|
|
389
|
-
formErrorMapper = input(
|
|
619
|
+
formErrorMapper = input(/* @ts-ignore */
|
|
620
|
+
...(ngDevMode ? [undefined, { debugName: "formErrorMapper" }] : /* istanbul ignore next */ []));
|
|
390
621
|
/**
|
|
391
622
|
* Defines that this form item is required for the overall form to be valid.
|
|
392
623
|
*
|
|
393
624
|
* @defaultValue false
|
|
394
625
|
*/
|
|
395
626
|
// eslint-disable-next-line @angular-eslint/no-input-rename
|
|
396
|
-
requiredInput = input(false, { ...(ngDevMode ? { debugName: "requiredInput" } : {}), transform: booleanAttribute, alias: 'required' });
|
|
397
|
-
fieldControlQuery = contentChild(SI_FORM_ITEM_CONTROL, { ...(ngDevMode ? { debugName: "fieldControlQuery" } : {}), descendants: true });
|
|
627
|
+
requiredInput = input(false, { ...(ngDevMode ? { debugName: "requiredInput" } : /* istanbul ignore next */ {}), transform: booleanAttribute, alias: 'required' });
|
|
628
|
+
fieldControlQuery = contentChild(SI_FORM_ITEM_CONTROL, { ...(ngDevMode ? { debugName: "fieldControlQuery" } : /* istanbul ignore next */ {}), descendants: true });
|
|
398
629
|
/** @internal */
|
|
399
|
-
ngControl = contentChild(NgControl, { ...(ngDevMode ? { debugName: "ngControl" } : {}), descendants: true });
|
|
400
|
-
controlElementRef = contentChild(NgControl, { ...(ngDevMode ? { debugName: "controlElementRef" } : {}), read: ElementRef,
|
|
630
|
+
ngControl = contentChild(NgControl, { ...(ngDevMode ? { debugName: "ngControl" } : /* istanbul ignore next */ {}), descendants: true });
|
|
631
|
+
controlElementRef = contentChild(NgControl, { ...(ngDevMode ? { debugName: "controlElementRef" } : /* istanbul ignore next */ {}), read: ElementRef,
|
|
401
632
|
descendants: true });
|
|
402
|
-
requiredValidator = contentChild(RequiredValidator, { ...(ngDevMode ? { debugName: "requiredValidator" } : {}), descendants: true });
|
|
633
|
+
requiredValidator = contentChild(RequiredValidator, { ...(ngDevMode ? { debugName: "requiredValidator" } : /* istanbul ignore next */ {}), descendants: true });
|
|
634
|
+
/** @internal */
|
|
635
|
+
errors = signal([], /* @ts-ignore */
|
|
636
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
403
637
|
/** @internal */
|
|
404
|
-
|
|
638
|
+
touched = signal(false, /* @ts-ignore */
|
|
639
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
405
640
|
fieldset = inject(SiFormFieldsetComponent, { optional: true });
|
|
406
641
|
container = inject(SiFormContainerComponent, { optional: true });
|
|
407
642
|
get formItemId() {
|
|
@@ -420,32 +655,51 @@ class SiFormItemComponent {
|
|
|
420
655
|
? (fieldControl?.errormessageId() ?? null)
|
|
421
656
|
: (fieldControl?.errormessageId ?? null);
|
|
422
657
|
}
|
|
423
|
-
fieldControl = computed(() => this.fieldControlQuery() ?? this.fieldControlNative(),
|
|
658
|
+
fieldControl = computed(() => this.fieldControlQuery() ?? this.fieldControlNative(), /* @ts-ignore */
|
|
659
|
+
...(ngDevMode ? [{ debugName: "fieldControl" }] : /* istanbul ignore next */ []));
|
|
424
660
|
validationErrorService = inject(SiFormValidationErrorService);
|
|
425
661
|
requiredTestControl = new FormControl('');
|
|
426
662
|
validator;
|
|
427
663
|
previousErrors;
|
|
428
|
-
hasRequiredValidator = signal(false,
|
|
429
|
-
|
|
664
|
+
hasRequiredValidator = signal(false, /* @ts-ignore */
|
|
665
|
+
...(ngDevMode ? [{ debugName: "hasRequiredValidator" }] : /* istanbul ignore next */ []));
|
|
666
|
+
fieldControlNative = signal(undefined, /* @ts-ignore */
|
|
667
|
+
...(ngDevMode ? [{ debugName: "fieldControlNative" }] : /* istanbul ignore next */ []));
|
|
430
668
|
labelWidthCssVar = computed(() => {
|
|
431
669
|
const labelWidth = this.labelWidth();
|
|
432
670
|
if (typeof labelWidth === 'number') {
|
|
433
671
|
return `${labelWidth}px`;
|
|
434
672
|
}
|
|
435
673
|
return labelWidth;
|
|
436
|
-
},
|
|
674
|
+
}, /* @ts-ignore */
|
|
675
|
+
...(ngDevMode ? [{ debugName: "labelWidthCssVar" }] : /* istanbul ignore next */ []));
|
|
437
676
|
printErrors = computed(() => {
|
|
438
677
|
return !this.disableErrorPrinting() && !(this.container?.disableErrorPrinting() ?? false);
|
|
439
|
-
},
|
|
678
|
+
}, /* @ts-ignore */
|
|
679
|
+
...(ngDevMode ? [{ debugName: "printErrors" }] : /* istanbul ignore next */ []));
|
|
680
|
+
/** @internal */
|
|
681
|
+
required = computed(() => this.requiredInput() || this.hasRequiredValidator(), /* @ts-ignore */
|
|
682
|
+
...(ngDevMode ? [{ debugName: "required" }] : /* istanbul ignore next */ []));
|
|
440
683
|
/** @internal */
|
|
441
|
-
|
|
684
|
+
control = computed(() => this.ngControl()?.control, /* @ts-ignore */
|
|
685
|
+
...(ngDevMode ? [{ debugName: "control" }] : /* istanbul ignore next */ []));
|
|
686
|
+
/** @internal */
|
|
687
|
+
radioGroupName = computed(() => {
|
|
688
|
+
const element = this.controlElementRef()?.nativeElement;
|
|
689
|
+
if (element?.tagName === 'INPUT') {
|
|
690
|
+
const inputElement = element;
|
|
691
|
+
return inputElement.type === 'radio' ? inputElement.name || undefined : undefined;
|
|
692
|
+
}
|
|
693
|
+
return undefined;
|
|
694
|
+
}, /* @ts-ignore */
|
|
695
|
+
...(ngDevMode ? [{ debugName: "radioGroupName" }] : /* istanbul ignore next */ []));
|
|
442
696
|
ngOnChanges(changes) {
|
|
443
697
|
if (changes.formErrorMapper) {
|
|
444
698
|
this.updateValidationMessages();
|
|
445
699
|
}
|
|
446
700
|
}
|
|
447
701
|
ngOnInit() {
|
|
448
|
-
this.fieldset?.
|
|
702
|
+
this.fieldset?.registerControl(this);
|
|
449
703
|
}
|
|
450
704
|
ngAfterContentInit() {
|
|
451
705
|
if (!this.fieldControlQuery()) {
|
|
@@ -455,9 +709,10 @@ class SiFormItemComponent {
|
|
|
455
709
|
ngAfterContentChecked() {
|
|
456
710
|
this.updateRequiredState();
|
|
457
711
|
this.updateValidationMessages();
|
|
712
|
+
this.touched.set(!!this.ngControl()?.touched);
|
|
458
713
|
}
|
|
459
714
|
ngOnDestroy() {
|
|
460
|
-
this.fieldset?.
|
|
715
|
+
this.fieldset?.unregisterControl(this);
|
|
461
716
|
}
|
|
462
717
|
updateRequiredState() {
|
|
463
718
|
const requiredValidator = this.requiredValidator();
|
|
@@ -493,18 +748,18 @@ class SiFormItemComponent {
|
|
|
493
748
|
}
|
|
494
749
|
}
|
|
495
750
|
}
|
|
496
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
497
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
751
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormItemComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
752
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", 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 align-items-start\"\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-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:calc(calc(var(--si-sys-sizing-spacing-y-40) - 1px) + 1px);padding-inline:var(--si-sys-sizing-spacing-x-60);inline-size:var(--si-form-label-width, 16.6666666667%);line-height:calc(var(--si-sys-typography-font-size-body) * var(--si-sys-typography-line-height-body))}: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:var(--si-sys-sizing-spacing-y-10) 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" }] });
|
|
498
753
|
}
|
|
499
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
754
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormItemComponent, decorators: [{
|
|
500
755
|
type: Component,
|
|
501
|
-
args: [{ selector: 'si-form-item', imports: [SiTranslatePipe, NgTemplateOutlet],
|
|
756
|
+
args: [{ selector: 'si-form-item', imports: [SiTranslatePipe, NgTemplateOutlet], host: {
|
|
502
757
|
'[class.required]': 'required()',
|
|
503
758
|
'[style.--si-form-label-width]': 'labelWidthCssVar()',
|
|
504
759
|
'[class.form-check]': 'fieldControl()?.isFormCheck',
|
|
505
760
|
'[class.form-check-inline]': 'fieldset?.inline()',
|
|
506
761
|
'[class.si-form-input]': '!fieldset'
|
|
507
|
-
}, 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
|
|
762
|
+
}, 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 align-items-start\"\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-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:calc(calc(var(--si-sys-sizing-spacing-y-40) - 1px) + 1px);padding-inline:var(--si-sys-sizing-spacing-x-60);inline-size:var(--si-form-label-width, 16.6666666667%);line-height:calc(var(--si-sys-typography-font-size-body) * var(--si-sys-typography-line-height-body))}: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:var(--si-sys-sizing-spacing-y-10) 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"] }]
|
|
508
763
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: true }] }], labelWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelWidth", required: false }] }], disableErrorPrinting: [{ type: i0.Input, args: [{ isSignal: true, alias: "disableErrorPrinting", required: false }] }], formErrorMapper: [{ type: i0.Input, args: [{ isSignal: true, alias: "formErrorMapper", required: false }] }], requiredInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "required", required: false }] }], fieldControlQuery: [{ type: i0.ContentChild, args: [i0.forwardRef(() => SI_FORM_ITEM_CONTROL), { ...{ descendants: true }, isSignal: true }] }], ngControl: [{ type: i0.ContentChild, args: [i0.forwardRef(() => NgControl), { ...{ descendants: true }, isSignal: true }] }], controlElementRef: [{ type: i0.ContentChild, args: [i0.forwardRef(() => NgControl), { ...{
|
|
509
764
|
read: ElementRef,
|
|
510
765
|
descendants: true
|
|
@@ -517,14 +772,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
517
772
|
const SI_FORM_VALIDATION_TOOLTIP_DATA = new InjectionToken('SiFormValidationTooltipData');
|
|
518
773
|
class SiFormValidationTooltipComponent {
|
|
519
774
|
errors = inject(SI_FORM_VALIDATION_TOOLTIP_DATA);
|
|
520
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
521
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
775
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormValidationTooltipComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
776
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.8", type: SiFormValidationTooltipComponent, isStandalone: true, selector: "si-form-validation-tooltip", host: { classAttribute: "d-flex flex-column gap-2 text-start" }, ngImport: i0, template: `
|
|
522
777
|
@for (error of errors(); track error.key) {
|
|
523
778
|
<div>{{ error.message | translate: error.params }}</div>
|
|
524
779
|
}
|
|
525
|
-
`, isInline: true, dependencies: [{ kind: "pipe", type: SiTranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.
|
|
780
|
+
`, isInline: true, dependencies: [{ kind: "pipe", type: SiTranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.Eager });
|
|
526
781
|
}
|
|
527
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
782
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormValidationTooltipComponent, decorators: [{
|
|
528
783
|
type: Component,
|
|
529
784
|
args: [{
|
|
530
785
|
selector: 'si-form-validation-tooltip',
|
|
@@ -534,7 +789,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
534
789
|
<div>{{ error.message | translate: error.params }}</div>
|
|
535
790
|
}
|
|
536
791
|
`,
|
|
537
|
-
changeDetection: ChangeDetectionStrategy.
|
|
792
|
+
changeDetection: ChangeDetectionStrategy.Eager,
|
|
538
793
|
host: {
|
|
539
794
|
'class': 'd-flex flex-column gap-2 text-start'
|
|
540
795
|
}
|
|
@@ -563,60 +818,50 @@ class SiFormValidationTooltipDirective {
|
|
|
563
818
|
formValidationService = inject(SiFormValidationErrorService);
|
|
564
819
|
formContainer = inject(SiFormContainerComponent, { optional: true });
|
|
565
820
|
/** Maps validation errors of the associated form control to custom tooltip messages. */
|
|
566
|
-
formErrorMapper = input(
|
|
821
|
+
formErrorMapper = input(/* @ts-ignore */
|
|
822
|
+
...(ngDevMode ? [undefined, { debugName: "formErrorMapper" }] : /* istanbul ignore next */ []));
|
|
567
823
|
ngControl = inject(NgControl);
|
|
568
824
|
elementRef = inject(ElementRef);
|
|
569
|
-
tooltipRef;
|
|
570
|
-
errors = signal([], ...(ngDevMode ? [{ debugName: "errors" }] : []));
|
|
571
|
-
currentErrors = null;
|
|
572
|
-
touched = null;
|
|
573
825
|
describedBy = `__si-form-validation-tooltip-${SiFormValidationTooltipDirective.idCounter++}`;
|
|
826
|
+
errors = signal([], /* @ts-ignore */
|
|
827
|
+
...(ngDevMode ? [{ debugName: "errors" }] : /* istanbul ignore next */ []));
|
|
828
|
+
touched = signal(false, /* @ts-ignore */
|
|
829
|
+
...(ngDevMode ? [{ debugName: "touched" }] : /* istanbul ignore next */ []));
|
|
830
|
+
canShowTooltip = computed(() => this.errors().length > 0 && this.touched(), /* @ts-ignore */
|
|
831
|
+
...(ngDevMode ? [{ debugName: "canShowTooltip" }] : /* istanbul ignore next */ []));
|
|
832
|
+
currentErrors = null;
|
|
833
|
+
constructor() {
|
|
834
|
+
this.tooltipService.createTooltip({
|
|
835
|
+
placement: () => 'auto',
|
|
836
|
+
element: this.elementRef,
|
|
837
|
+
describedBy: this.describedBy,
|
|
838
|
+
injector: Injector.create({
|
|
839
|
+
providers: [{ provide: SI_FORM_VALIDATION_TOOLTIP_DATA, useValue: this.errors }]
|
|
840
|
+
}),
|
|
841
|
+
canShow: this.canShowTooltip,
|
|
842
|
+
tooltip: () => SiFormValidationTooltipComponent,
|
|
843
|
+
// Not actually used, but errors in the context triggers a resize if the errors changes.
|
|
844
|
+
tooltipContext: this.errors
|
|
845
|
+
});
|
|
846
|
+
}
|
|
574
847
|
ngDoCheck() {
|
|
575
848
|
const nextErrors = this.ngControl.errors;
|
|
576
|
-
|
|
577
|
-
if (this.currentErrors !== nextErrors
|
|
849
|
+
this.touched.set(!!this.ngControl.touched);
|
|
850
|
+
if (this.currentErrors !== nextErrors) {
|
|
578
851
|
this.currentErrors = nextErrors;
|
|
579
|
-
this.touched = nextTouched;
|
|
580
852
|
this.updateErrors();
|
|
581
853
|
}
|
|
582
854
|
}
|
|
583
|
-
ngOnDestroy() {
|
|
584
|
-
this.destroyTooltip();
|
|
585
|
-
}
|
|
586
855
|
updateErrors() {
|
|
587
856
|
const errors = this.formValidationService
|
|
588
857
|
.resolveErrors(this.ngControl.name, this.currentErrors, this.formErrorMapper(), this.formContainer?.formErrorMapper())
|
|
589
858
|
.filter(error => !!error.message);
|
|
590
|
-
const shouldShow = errors.length > 0 && !!this.ngControl.touched;
|
|
591
|
-
if (shouldShow) {
|
|
592
|
-
this.createTooltip();
|
|
593
|
-
}
|
|
594
|
-
else {
|
|
595
|
-
this.destroyTooltip();
|
|
596
|
-
}
|
|
597
859
|
this.errors.set(errors);
|
|
598
860
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
placement: 'auto',
|
|
602
|
-
element: this.elementRef,
|
|
603
|
-
describedBy: this.describedBy,
|
|
604
|
-
injector: Injector.create({
|
|
605
|
-
providers: [{ provide: SI_FORM_VALIDATION_TOOLTIP_DATA, useValue: this.errors }]
|
|
606
|
-
}),
|
|
607
|
-
tooltip: () => SiFormValidationTooltipComponent,
|
|
608
|
-
// Not actually used, but errors in the context triggers a resize if the errors changes.
|
|
609
|
-
tooltipContext: () => this.errors()
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
destroyTooltip() {
|
|
613
|
-
this.tooltipRef?.destroy();
|
|
614
|
-
this.tooltipRef = undefined;
|
|
615
|
-
}
|
|
616
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: SiFormValidationTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
617
|
-
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 });
|
|
861
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormValidationTooltipDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
862
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "22.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 });
|
|
618
863
|
}
|
|
619
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
864
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormValidationTooltipDirective, decorators: [{
|
|
620
865
|
type: Directive,
|
|
621
866
|
args: [{
|
|
622
867
|
selector: '[siFormValidationTooltip]',
|
|
@@ -625,7 +870,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
625
870
|
'[attr.aria-describedby]': 'describedBy'
|
|
626
871
|
}
|
|
627
872
|
}]
|
|
628
|
-
}], propDecorators: { formErrorMapper: [{ type: i0.Input, args: [{ isSignal: true, alias: "formErrorMapper", required: false }] }] } });
|
|
873
|
+
}], ctorParameters: () => [], propDecorators: { formErrorMapper: [{ type: i0.Input, args: [{ isSignal: true, alias: "formErrorMapper", required: false }] }] } });
|
|
629
874
|
|
|
630
875
|
/**
|
|
631
876
|
* The error mapper is used to resolve an angular validation error to a {@link TranslatableString}.
|
|
@@ -655,11 +900,11 @@ class SiFormModule {
|
|
|
655
900
|
providers: [provideFormValidationErrorMapper(validationErrorMapper)]
|
|
656
901
|
};
|
|
657
902
|
}
|
|
658
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
659
|
-
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "
|
|
660
|
-
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "
|
|
903
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
904
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "22.0.8", ngImport: i0, type: SiFormModule, imports: [SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent], exports: [SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent] });
|
|
905
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormModule });
|
|
661
906
|
}
|
|
662
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
907
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: SiFormModule, decorators: [{
|
|
663
908
|
type: NgModule,
|
|
664
909
|
args: [{
|
|
665
910
|
imports: [SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent],
|
|
@@ -676,5 +921,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.0.8", ngImpor
|
|
|
676
921
|
* Generated bundle index. Do not edit.
|
|
677
922
|
*/
|
|
678
923
|
|
|
679
|
-
export { SI_FORM_ITEM_CONTROL, SiFormContainerComponent, SiFormFieldsetComponent, SiFormItemComponent, SiFormModule, SiFormValidationTooltipDirective, provideFormValidationErrorMapper };
|
|
924
|
+
export { SI_FORM_ITEM_CONTROL, SiFormContainerComponent, SiFormFieldComponent, SiFormFieldsetComponent, SiFormItemComponent, SiFormModule, SiFormValidationTooltipDirective, provideFormValidationErrorMapper, provideSiFormFieldConfig };
|
|
680
925
|
//# sourceMappingURL=siemens-element-ng-form.mjs.map
|