@siemens/element-ng 47.2.0 → 47.4.0
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 +18 -6
- package/autocomplete/index.d.ts +8 -0
- package/autocomplete/package.json +3 -0
- package/autocomplete/si-autocomplete-listbox.directive.d.ts +31 -0
- package/autocomplete/si-autocomplete-option.directive.d.ts +31 -0
- package/autocomplete/si-autocomplete.directive.d.ts +14 -0
- package/autocomplete/si-autocomplete.model.d.ts +7 -0
- package/autocomplete/si-autocomplete.module.d.ts +9 -0
- package/badge/index.d.ts +5 -0
- package/badge/package.json +3 -0
- package/badge/si-badge.component.d.ts +17 -0
- package/breadcrumb/breadcrumb-item.model.d.ts +36 -0
- package/breadcrumb/index.d.ts +7 -0
- package/breadcrumb/package.json +3 -0
- package/breadcrumb/si-breadcrumb-item-template.directive.d.ts +10 -0
- package/breadcrumb/si-breadcrumb.component.d.ts +46 -0
- package/breadcrumb/si-breadcrumb.module.d.ts +7 -0
- package/card/index.d.ts +6 -0
- package/card/package.json +3 -0
- package/card/si-card.component.d.ts +79 -0
- package/card/si-card.module.d.ts +7 -0
- package/circle-status/index.d.ts +6 -0
- package/circle-status/package.json +3 -0
- package/circle-status/si-circle-status.component.d.ts +66 -0
- package/circle-status/si-circle-status.module.d.ts +7 -0
- package/column-selection-dialog/column-selection-editor/si-column-selection-editor.component.d.ts +23 -0
- package/column-selection-dialog/index.d.ts +6 -0
- package/column-selection-dialog/package.json +3 -0
- package/column-selection-dialog/si-column-selection-dialog.component.d.ts +114 -0
- package/column-selection-dialog/si-column-selection-dialog.service.d.ts +20 -0
- package/column-selection-dialog/si-column-selection-dialog.types.d.ts +68 -0
- package/common/models/status-type.model.d.ts +2 -2
- package/content-action-bar/index.d.ts +7 -0
- package/content-action-bar/package.json +3 -0
- package/content-action-bar/si-content-action-bar-toggle.component.d.ts +6 -0
- package/content-action-bar/si-content-action-bar.component.d.ts +72 -0
- package/content-action-bar/si-content-action-bar.model.d.ts +9 -0
- package/content-action-bar/si-content-action-bar.module.d.ts +7 -0
- package/date-range-filter/index.d.ts +8 -0
- package/date-range-filter/package.json +3 -0
- package/date-range-filter/si-date-range-calculation.service.d.ts +33 -0
- package/date-range-filter/si-date-range-filter.component.d.ts +248 -0
- package/date-range-filter/si-date-range-filter.module.d.ts +7 -0
- package/date-range-filter/si-date-range-filter.types.d.ts +40 -0
- package/date-range-filter/si-relative-date.component.d.ts +31 -0
- package/datepicker/components/si-calendar-body.component.d.ts +137 -0
- package/datepicker/components/si-calendar-date-cell.directive.d.ts +16 -0
- package/datepicker/components/si-calendar-direction-button.component.d.ts +18 -0
- package/datepicker/components/si-compare-adapter.d.ts +37 -0
- package/datepicker/components/si-day-selection.component.d.ts +76 -0
- package/datepicker/components/si-initial-focus.component.d.ts +74 -0
- package/datepicker/components/si-month-selection.component.d.ts +62 -0
- package/datepicker/components/si-year-selection.component.d.ts +65 -0
- package/datepicker/date-time-helper.d.ts +302 -0
- package/datepicker/index.d.ts +15 -0
- package/datepicker/package.json +3 -0
- package/datepicker/si-calendar-button.component.d.ts +49 -0
- package/datepicker/si-date-input.directive.d.ts +114 -0
- package/datepicker/si-date-range.component.d.ts +150 -0
- package/datepicker/si-datepicker-overlay.component.d.ts +82 -0
- package/datepicker/si-datepicker-overlay.directive.d.ts +104 -0
- package/datepicker/si-datepicker.component.d.ts +228 -0
- package/datepicker/si-datepicker.directive.d.ts +62 -0
- package/datepicker/si-datepicker.model.d.ts +129 -0
- package/datepicker/si-datepicker.module.d.ts +12 -0
- package/datepicker/si-timepicker.component.d.ts +214 -0
- package/electron-titlebar/electron.helpers.d.ts +5 -0
- package/electron-titlebar/index.d.ts +7 -0
- package/electron-titlebar/package.json +3 -0
- package/electron-titlebar/si-electron-titlebar.component.d.ts +72 -0
- package/electron-titlebar/si-electron-titlebar.module.d.ts +7 -0
- package/fesm2022/siemens-element-ng-application-header.mjs +2 -2
- package/fesm2022/siemens-element-ng-application-header.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-autocomplete.mjs +235 -0
- package/fesm2022/siemens-element-ng-autocomplete.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-badge.mjs +59 -0
- package/fesm2022/siemens-element-ng-badge.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-breadcrumb.mjs +302 -0
- package/fesm2022/siemens-element-ng-breadcrumb.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-card.mjs +122 -0
- package/fesm2022/siemens-element-ng-card.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-circle-status.mjs +146 -0
- package/fesm2022/siemens-element-ng-circle-status.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-column-selection-dialog.mjs +369 -0
- package/fesm2022/siemens-element-ng-column-selection-dialog.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-common.mjs +1 -1
- package/fesm2022/siemens-element-ng-common.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-content-action-bar.mjs +200 -0
- package/fesm2022/siemens-element-ng-content-action-bar.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-date-range-filter.mjs +649 -0
- package/fesm2022/siemens-element-ng-date-range-filter.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-datepicker.mjs +4231 -0
- package/fesm2022/siemens-element-ng-datepicker.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-electron-titlebar.mjs +142 -0
- package/fesm2022/siemens-element-ng-electron-titlebar.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-file-uploader.mjs +751 -0
- package/fesm2022/siemens-element-ng-file-uploader.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-filter-bar.mjs +153 -0
- package/fesm2022/siemens-element-ng-filter-bar.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-form.mjs +827 -0
- package/fesm2022/siemens-element-ng-form.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-icon-status.mjs +65 -0
- package/fesm2022/siemens-element-ng-icon-status.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-icon.mjs +22 -2
- package/fesm2022/siemens-element-ng-icon.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-info-page.mjs +63 -0
- package/fesm2022/siemens-element-ng-info-page.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-inline-notification.mjs +4 -6
- package/fesm2022/siemens-element-ng-inline-notification.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-ip-input.mjs +451 -0
- package/fesm2022/siemens-element-ng-ip-input.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-language-switcher.mjs +90 -0
- package/fesm2022/siemens-element-ng-language-switcher.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-localization.mjs +306 -0
- package/fesm2022/siemens-element-ng-localization.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-number-input.mjs +267 -0
- package/fesm2022/siemens-element-ng-number-input.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-password-strength.mjs +177 -0
- package/fesm2022/siemens-element-ng-password-strength.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-photo-upload.mjs +480 -0
- package/fesm2022/siemens-element-ng-photo-upload.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-pills-input.mjs +397 -0
- package/fesm2022/siemens-element-ng-pills-input.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-popover-next.mjs +259 -0
- package/fesm2022/siemens-element-ng-popover-next.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-popover.mjs +256 -0
- package/fesm2022/siemens-element-ng-popover.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-progressbar.mjs +83 -0
- package/fesm2022/siemens-element-ng-progressbar.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-search-bar.mjs +193 -0
- package/fesm2022/siemens-element-ng-search-bar.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-select.mjs +1166 -0
- package/fesm2022/siemens-element-ng-select.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-skip-links.mjs +117 -0
- package/fesm2022/siemens-element-ng-skip-links.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-slider.mjs +313 -0
- package/fesm2022/siemens-element-ng-slider.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-sort-bar.mjs +89 -0
- package/fesm2022/siemens-element-ng-sort-bar.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-split.mjs +575 -0
- package/fesm2022/siemens-element-ng-split.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-status-toggle.mjs +196 -0
- package/fesm2022/siemens-element-ng-status-toggle.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-summary-widget.mjs +77 -0
- package/fesm2022/siemens-element-ng-summary-widget.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-system-banner.mjs +47 -0
- package/fesm2022/siemens-element-ng-system-banner.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-tabs.mjs +395 -0
- package/fesm2022/siemens-element-ng-tabs.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-toast-notification.mjs +227 -0
- package/fesm2022/siemens-element-ng-toast-notification.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-translate.mjs.map +1 -1
- package/fesm2022/siemens-element-ng-typeahead.mjs +746 -0
- package/fesm2022/siemens-element-ng-typeahead.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-unauthorized-page.mjs +76 -0
- package/fesm2022/siemens-element-ng-unauthorized-page.mjs.map +1 -0
- package/fesm2022/siemens-element-ng-wizard.mjs +465 -0
- package/fesm2022/siemens-element-ng-wizard.mjs.map +1 -0
- package/file-uploader/index.d.ts +8 -0
- package/file-uploader/package.json +3 -0
- package/file-uploader/si-file-dropzone.component.d.ts +106 -0
- package/file-uploader/si-file-uploader.component.d.ts +296 -0
- package/file-uploader/si-file-uploader.model.d.ts +12 -0
- package/file-uploader/si-file-uploader.module.d.ts +8 -0
- package/filter-bar/filter.d.ts +26 -0
- package/filter-bar/index.d.ts +8 -0
- package/filter-bar/package.json +3 -0
- package/filter-bar/si-filter-bar.component.d.ts +65 -0
- package/filter-bar/si-filter-bar.module.d.ts +7 -0
- package/filter-bar/si-filter-pill.component.d.ts +20 -0
- package/form/form-fieldset/si-form-fieldset.component.d.ts +40 -0
- package/form/index.d.ts +14 -0
- package/form/package.json +3 -0
- package/form/si-form-container/si-form-container.component.d.ts +155 -0
- package/form/si-form-item/si-form-field-native.control.d.ts +22 -0
- package/form/si-form-item/si-form-item.component.d.ts +90 -0
- package/form/si-form-item-control-input.directive.d.ts +18 -0
- package/form/si-form-item.control.d.ts +35 -0
- package/form/si-form-validation-error.model.d.ts +55 -0
- package/form/si-form-validation-error.provider.d.ts +11 -0
- package/form/si-form-validation-error.service.d.ts +42 -0
- package/form/si-form-validation-tooltip/si-form-validation-tooltip.component.d.ts +13 -0
- package/form/si-form-validation-tooltip/si-form-validation-tooltip.directive.d.ts +42 -0
- package/form/si-form.module.d.ts +25 -0
- package/icon/element-icons.d.ts +20 -0
- package/icon-status/index.d.ts +6 -0
- package/icon-status/package.json +3 -0
- package/icon-status/si-icon-status.component.d.ts +24 -0
- package/icon-status/si-icon-status.module.d.ts +7 -0
- package/info-page/index.d.ts +5 -0
- package/info-page/package.json +3 -0
- package/info-page/si-info-page.component.d.ts +38 -0
- package/inline-notification/si-inline-notification.component.d.ts +0 -2
- package/ip-input/address-utils.d.ts +28 -0
- package/ip-input/address-validators.d.ts +21 -0
- package/ip-input/index.d.ts +7 -0
- package/ip-input/package.json +3 -0
- package/ip-input/si-ip-input.directive.d.ts +53 -0
- package/ip-input/si-ip4-input.directive.d.ts +9 -0
- package/ip-input/si-ip6-input.directive.d.ts +10 -0
- package/language-switcher/index.d.ts +7 -0
- package/language-switcher/iso-language-value.d.ts +14 -0
- package/language-switcher/package.json +3 -0
- package/language-switcher/si-language-switcher.component.d.ts +32 -0
- package/language-switcher/si-language-switcher.module.d.ts +7 -0
- package/localization/index.d.ts +8 -0
- package/localization/package.json +3 -0
- package/localization/si-directionality.d.ts +41 -0
- package/localization/si-locale-id.d.ts +22 -0
- package/localization/si-locale-store.d.ts +16 -0
- package/localization/si-locale.service.d.ts +73 -0
- package/number-input/index.d.ts +6 -0
- package/number-input/package.json +3 -0
- package/number-input/si-number-input.component.d.ts +106 -0
- package/number-input/si-number-input.module.d.ts +7 -0
- package/package.json +163 -3
- package/password-strength/index.d.ts +7 -0
- package/password-strength/package.json +3 -0
- package/password-strength/si-password-strength.component.d.ts +25 -0
- package/password-strength/si-password-strength.directive.d.ts +54 -0
- package/password-strength/si-password-strength.module.d.ts +8 -0
- package/photo-upload/index.d.ts +6 -0
- package/photo-upload/package.json +3 -0
- package/photo-upload/si-image-cropper-style.component.d.ts +5 -0
- package/photo-upload/si-photo-upload.component.d.ts +298 -0
- package/pills-input/index.d.ts +9 -0
- package/pills-input/package.json +3 -0
- package/pills-input/si-input-pill.component.d.ts +9 -0
- package/pills-input/si-pills-input-csv.directive.d.ts +8 -0
- package/pills-input/si-pills-input-email.directive.d.ts +10 -0
- package/pills-input/si-pills-input-pattern-base.d.ts +19 -0
- package/pills-input/si-pills-input-value-handler.d.ts +12 -0
- package/pills-input/si-pills-input.component.d.ts +87 -0
- package/pills-input/si-pills-input.module.d.ts +9 -0
- package/popover/index.d.ts +6 -0
- package/popover/package.json +3 -0
- package/popover/si-popover.component.d.ts +26 -0
- package/popover/si-popover.directive.d.ts +89 -0
- package/popover/si-popover.module.d.ts +7 -0
- package/popover-next/index.d.ts +7 -0
- package/popover-next/package.json +3 -0
- package/popover-next/si-popover-description.directive.d.ts +7 -0
- package/popover-next/si-popover-next.directive.d.ts +61 -0
- package/popover-next/si-popover-title.directive.d.ts +7 -0
- package/popover-next/si-popover.component.d.ts +27 -0
- package/progressbar/index.d.ts +6 -0
- package/progressbar/package.json +3 -0
- package/progressbar/si-progressbar.component.d.ts +43 -0
- package/progressbar/si-progressbar.module.d.ts +7 -0
- package/search-bar/index.d.ts +6 -0
- package/search-bar/package.json +3 -0
- package/search-bar/si-search-bar.component.d.ts +87 -0
- package/search-bar/si-search-bar.module.d.ts +7 -0
- package/select/index.d.ts +18 -0
- package/select/options/si-select-complex-options.directive.d.ts +69 -0
- package/select/options/si-select-lazy-options.directive.d.ts +38 -0
- package/select/options/si-select-option.source.d.ts +49 -0
- package/select/options/si-select-options-strategy.base.d.ts +35 -0
- package/select/options/si-select-options-strategy.d.ts +37 -0
- package/select/options/si-select-simple-options.directive.d.ts +34 -0
- package/select/package.json +3 -0
- package/select/select-input/si-select-input.component.d.ts +43 -0
- package/select/select-list/si-select-list-has-filter.component.d.ts +20 -0
- package/select/select-list/si-select-list.base.d.ts +37 -0
- package/select/select-list/si-select-list.component.d.ts +15 -0
- package/select/select-option/si-select-option-row.component.d.ts +16 -0
- package/select/select-option/si-select-option.component.d.ts +9 -0
- package/select/selection/si-select-multi-value.directive.d.ts +26 -0
- package/select/selection/si-select-selection-strategy.d.ts +58 -0
- package/select/selection/si-select-single-value.directive.d.ts +26 -0
- package/select/si-select-action.directive.d.ts +12 -0
- package/select/si-select-actions.directive.d.ts +5 -0
- package/select/si-select-group-template.directive.d.ts +20 -0
- package/select/si-select-option-row-template.directive.d.ts +9 -0
- package/select/si-select-option-template.directive.d.ts +21 -0
- package/select/si-select.component.d.ts +96 -0
- package/select/si-select.module.d.ts +15 -0
- package/select/si-select.types.d.ts +65 -0
- package/skip-links/index.d.ts +5 -0
- package/skip-links/package.json +3 -0
- package/skip-links/si-skip-link-target.directive.d.ts +27 -0
- package/skip-links/si-skip-links.component.d.ts +9 -0
- package/skip-links/skip-link.service.d.ts +14 -0
- package/slider/index.d.ts +6 -0
- package/slider/package.json +3 -0
- package/slider/si-slider.component.d.ts +129 -0
- package/slider/si-slider.module.d.ts +7 -0
- package/sort-bar/index.d.ts +6 -0
- package/sort-bar/package.json +3 -0
- package/sort-bar/si-sort-bar.component.d.ts +42 -0
- package/sort-bar/si-sort-bar.module.d.ts +7 -0
- package/split/index.d.ts +8 -0
- package/split/package.json +3 -0
- package/split/si-split-part.component.d.ts +154 -0
- package/split/si-split.component.d.ts +48 -0
- package/split/si-split.interfaces.d.ts +17 -0
- package/split/si-split.module.d.ts +8 -0
- package/status-toggle/index.d.ts +6 -0
- package/status-toggle/package.json +3 -0
- package/status-toggle/si-status-toggle.component.d.ts +54 -0
- package/status-toggle/status-toggle.model.d.ts +26 -0
- package/summary-widget/index.d.ts +5 -0
- package/summary-widget/package.json +3 -0
- package/summary-widget/si-summary-widget.component.d.ts +44 -0
- package/system-banner/index.d.ts +5 -0
- package/system-banner/package.json +3 -0
- package/system-banner/system-banner.component.d.ts +23 -0
- package/tabs/index.d.ts +7 -0
- package/tabs/package.json +3 -0
- package/tabs/si-tab/index.d.ts +5 -0
- package/tabs/si-tab/si-tab.component.d.ts +58 -0
- package/tabs/si-tabs.module.d.ts +8 -0
- package/tabs/si-tabset/index.d.ts +5 -0
- package/tabs/si-tabset/si-tabset.component.d.ts +100 -0
- package/template-i18n.json +111 -1
- package/toast-notification/index.d.ts +6 -0
- package/toast-notification/package.json +3 -0
- package/toast-notification/si-toast-notification/si-toast-notification.component.d.ts +17 -0
- package/toast-notification/si-toast-notification-drawer/si-toast-notification-drawer.component.d.ts +9 -0
- package/toast-notification/si-toast-notification.service.d.ts +41 -0
- package/toast-notification/si-toast.model.d.ts +25 -0
- package/translate/si-translatable-keys.interface.d.ts +110 -0
- package/typeahead/index.d.ts +8 -0
- package/typeahead/package.json +3 -0
- package/typeahead/si-typeahead-item-template.directive.d.ts +7 -0
- package/typeahead/si-typeahead.component.d.ts +22 -0
- package/typeahead/si-typeahead.directive.d.ts +196 -0
- package/typeahead/si-typeahead.model.d.ts +60 -0
- package/typeahead/si-typeahead.module.d.ts +8 -0
- package/typeahead/si-typeahead.sorting.d.ts +10 -0
- package/unauthorized-page/index.d.ts +6 -0
- package/unauthorized-page/package.json +3 -0
- package/unauthorized-page/si-unauthorized-page.component.d.ts +35 -0
- package/unauthorized-page/si-unauthorized-page.module.d.ts +7 -0
- package/wizard/index.d.ts +7 -0
- package/wizard/package.json +3 -0
- package/wizard/si-wizard-step.component.d.ts +21 -0
- package/wizard/si-wizard.component.d.ts +196 -0
- package/wizard/si-wizard.module.d.ts +8 -0
|
@@ -0,0 +1,751 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { input, booleanAttribute, output, computed, viewChild, inject, LOCALE_ID, ChangeDetectionStrategy, Component, numberAttribute, ChangeDetectorRef, NgModule } from '@angular/core';
|
|
3
|
+
import { addIcons, elementUpload, SiIconNextComponent, elementRedo, elementDocument, elementDelete, elementCancel, SiIconComponent } from '@siemens/element-ng/icon';
|
|
4
|
+
import * as i1 from '@siemens/element-translate-ng/translate';
|
|
5
|
+
import { SiTranslateModule } from '@siemens/element-translate-ng/translate';
|
|
6
|
+
import { NgClass } from '@angular/common';
|
|
7
|
+
import { HttpHeaders, HttpClient, HttpRequest, HttpResponse, HttpEventType } from '@angular/common/http';
|
|
8
|
+
import { SiInlineNotificationComponent } from '@siemens/element-ng/inline-notification';
|
|
9
|
+
import { SiProgressbarComponent } from '@siemens/element-ng/progressbar';
|
|
10
|
+
import { retry } from 'rxjs/operators';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Copyright Siemens 2016 - 2025.
|
|
14
|
+
* SPDX-License-Identifier: MIT
|
|
15
|
+
*/
|
|
16
|
+
class SiFileDropzoneComponent {
|
|
17
|
+
/**
|
|
18
|
+
* Text or translation key of the input file selector (is combined with the `uploadTextRest`).
|
|
19
|
+
*
|
|
20
|
+
* @defaultValue
|
|
21
|
+
* ```
|
|
22
|
+
* $localize`:@@SI_FILE_UPLOADER.FILE_SELECT:click to upload`
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
uploadTextFileSelect = input($localize `:@@SI_FILE_UPLOADER.FILE_SELECT:click to upload`);
|
|
26
|
+
/**
|
|
27
|
+
* Text or translation key of the drag&drop field (is combined with the `uploadTextFileSelect`).
|
|
28
|
+
*
|
|
29
|
+
* @defaultValue
|
|
30
|
+
* ```
|
|
31
|
+
* $localize`:@@SI_FILE_UPLOADER.DROP:Drop files here or`
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
uploadDropText = input($localize `:@@SI_FILE_UPLOADER.DROP:Drop files here or`);
|
|
35
|
+
/**
|
|
36
|
+
* Text or translation key for max file size.
|
|
37
|
+
*
|
|
38
|
+
* @defaultValue
|
|
39
|
+
* ```
|
|
40
|
+
* $localize`:@@SI_FILE_UPLOADER.MAX_SIZE:Maximum upload size`
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
maxFileSizeText = input($localize `:@@SI_FILE_UPLOADER.MAX_SIZE:Maximum upload size`);
|
|
44
|
+
/**
|
|
45
|
+
* Text or translation key for accepted types.
|
|
46
|
+
*
|
|
47
|
+
* @defaultValue
|
|
48
|
+
* ```
|
|
49
|
+
* $localize`:@@SI_FILE_UPLOADER.ACCEPTED_FILE_TYPES:Accepted file types`
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
acceptText = input($localize `:@@SI_FILE_UPLOADER.ACCEPTED_FILE_TYPES:Accepted file types`);
|
|
53
|
+
/**
|
|
54
|
+
* Text or translation key of message title if incorrect file type is dragged / dropped.
|
|
55
|
+
*
|
|
56
|
+
* @defaultValue
|
|
57
|
+
* ```
|
|
58
|
+
* $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Incorrect file type selected`
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
errorTextFileType = input($localize `:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Incorrect file type selected`);
|
|
62
|
+
/**
|
|
63
|
+
* Message or translation key if file exceeds the maximum file size limit.
|
|
64
|
+
*
|
|
65
|
+
* @defaultValue
|
|
66
|
+
* ```
|
|
67
|
+
* $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
errorTextFileMaxSize = input($localize `:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`);
|
|
71
|
+
/**
|
|
72
|
+
* Define which file types are suggested in file browser.
|
|
73
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept
|
|
74
|
+
*/
|
|
75
|
+
accept = input();
|
|
76
|
+
/**
|
|
77
|
+
* Define maximal allowed file size in bytes.
|
|
78
|
+
*/
|
|
79
|
+
maxFileSize = input();
|
|
80
|
+
/**
|
|
81
|
+
* Defines whether the file input allows selecting multiple files.
|
|
82
|
+
* When {@link directoryUpload} is enabled, this will have no effect.
|
|
83
|
+
*
|
|
84
|
+
* @defaultValue false
|
|
85
|
+
*/
|
|
86
|
+
multiple = input(false, { transform: booleanAttribute });
|
|
87
|
+
/**
|
|
88
|
+
* Event emitted when files are added.
|
|
89
|
+
*/
|
|
90
|
+
filesAdded = output();
|
|
91
|
+
/**
|
|
92
|
+
* Enable directory upload.
|
|
93
|
+
*
|
|
94
|
+
* @defaultValue false
|
|
95
|
+
*/
|
|
96
|
+
directoryUpload = input(false, { transform: booleanAttribute });
|
|
97
|
+
maxFileSizeString = computed(() => {
|
|
98
|
+
const maxFileSize = this.maxFileSize();
|
|
99
|
+
return maxFileSize ? this.fileSizeToString(maxFileSize) : '';
|
|
100
|
+
});
|
|
101
|
+
icons = addIcons({ elementUpload });
|
|
102
|
+
dragOver = false;
|
|
103
|
+
fileInput = viewChild.required('fileInput');
|
|
104
|
+
locale = inject(LOCALE_ID).toString();
|
|
105
|
+
numberFormat = new Intl.NumberFormat(this.locale, { maximumFractionDigits: 2 });
|
|
106
|
+
dropHandler(event) {
|
|
107
|
+
event.preventDefault();
|
|
108
|
+
if (this.directoryUpload()) {
|
|
109
|
+
this.handleItems(event.dataTransfer.items);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.handleFiles(event.dataTransfer.files);
|
|
113
|
+
}
|
|
114
|
+
this.dragOver = false;
|
|
115
|
+
}
|
|
116
|
+
dragOverHandler(event) {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
event.stopPropagation();
|
|
119
|
+
this.dragOver = true;
|
|
120
|
+
}
|
|
121
|
+
inputEnterHandler() {
|
|
122
|
+
this.fileInput().nativeElement.click();
|
|
123
|
+
}
|
|
124
|
+
inputHandler(event) {
|
|
125
|
+
this.handleFiles(event.target.files);
|
|
126
|
+
}
|
|
127
|
+
handleFiles(files) {
|
|
128
|
+
if (!files?.length) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const newFiles = [];
|
|
132
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
133
|
+
for (let i = 0; i < files.length; i++) {
|
|
134
|
+
newFiles.push(this.makeUploadFile(files[i]));
|
|
135
|
+
}
|
|
136
|
+
newFiles.sort((a, b) => a.fileName.localeCompare(b.fileName));
|
|
137
|
+
this.filesAdded.emit(newFiles);
|
|
138
|
+
this.reset();
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Reset all the files inside the native file input (and therefore the dropzone).
|
|
142
|
+
*/
|
|
143
|
+
reset() {
|
|
144
|
+
this.fileInput().nativeElement.value = '';
|
|
145
|
+
}
|
|
146
|
+
makeUploadFile(file) {
|
|
147
|
+
const uploadFile = {
|
|
148
|
+
fileName: file.name,
|
|
149
|
+
file,
|
|
150
|
+
size: this.fileSizeToString(file.size),
|
|
151
|
+
progress: 0,
|
|
152
|
+
status: 'added'
|
|
153
|
+
};
|
|
154
|
+
// use MIME type of file if set. Otherwise fall back to file name ending
|
|
155
|
+
const ext = '.' + uploadFile.file.name.split('.').pop();
|
|
156
|
+
if (!this.verifyFileType(uploadFile.file.type, ext)) {
|
|
157
|
+
uploadFile.status = 'invalid';
|
|
158
|
+
uploadFile.errorText = this.errorTextFileType();
|
|
159
|
+
}
|
|
160
|
+
else if (!this.verifyFileSize(uploadFile.file.size)) {
|
|
161
|
+
uploadFile.status = 'invalid';
|
|
162
|
+
uploadFile.errorText = this.errorTextFileMaxSize();
|
|
163
|
+
}
|
|
164
|
+
return uploadFile;
|
|
165
|
+
}
|
|
166
|
+
verifyFileSize(size) {
|
|
167
|
+
const maxFileSize = this.maxFileSize();
|
|
168
|
+
return !maxFileSize || size <= maxFileSize;
|
|
169
|
+
}
|
|
170
|
+
verifyFileType(fileType, ext) {
|
|
171
|
+
const accept = this.accept();
|
|
172
|
+
if (!accept) {
|
|
173
|
+
return true;
|
|
174
|
+
}
|
|
175
|
+
if (fileType === undefined && ext === undefined) {
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
// Spec says that comma is the delimiter for filetypes. Also allow pipe for compatibility
|
|
179
|
+
return accept.split(/,|\|/).some(acceptedType => {
|
|
180
|
+
// convert accept glob into regex (example: images/* --> images/.*)
|
|
181
|
+
const acceptedRegexStr = acceptedType.replace('.', '.').replace('*', '.*').trim();
|
|
182
|
+
const acceptedRegex = new RegExp(acceptedRegexStr, 'i');
|
|
183
|
+
// if fileType is set and accepted type looks like a MIME type, match that otherwise extension
|
|
184
|
+
if (fileType && acceptedType.includes('/')) {
|
|
185
|
+
return !!fileType.match(acceptedRegex);
|
|
186
|
+
}
|
|
187
|
+
return !!ext?.match(acceptedRegex);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
fileSizeToString(num) {
|
|
191
|
+
let suffix = 'B';
|
|
192
|
+
if (num >= 1_073_741_824) {
|
|
193
|
+
num /= 1_073_741_824;
|
|
194
|
+
suffix = 'GB';
|
|
195
|
+
}
|
|
196
|
+
if (num >= 1_048_576) {
|
|
197
|
+
num /= 1_048_576;
|
|
198
|
+
suffix = 'MB';
|
|
199
|
+
}
|
|
200
|
+
else if (num >= 1_024) {
|
|
201
|
+
num /= 1_024;
|
|
202
|
+
suffix = 'KB';
|
|
203
|
+
}
|
|
204
|
+
return this.numberFormat.format(num) + suffix;
|
|
205
|
+
}
|
|
206
|
+
handleItems(items) {
|
|
207
|
+
const newFiles = [];
|
|
208
|
+
let pendingEntries = 0;
|
|
209
|
+
const traverseFileTree = (item) => {
|
|
210
|
+
if (item.isFile) {
|
|
211
|
+
item.file(file => {
|
|
212
|
+
newFiles.push(this.makeUploadFile(file));
|
|
213
|
+
if (--pendingEntries === 0) {
|
|
214
|
+
this.filesAdded.emit(newFiles);
|
|
215
|
+
this.reset();
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
else if (item.isDirectory) {
|
|
220
|
+
const dirReader = item.createReader();
|
|
221
|
+
dirReader.readEntries(entries => {
|
|
222
|
+
for (const entry of entries) {
|
|
223
|
+
pendingEntries++;
|
|
224
|
+
traverseFileTree(entry);
|
|
225
|
+
}
|
|
226
|
+
if (--pendingEntries === 0) {
|
|
227
|
+
this.filesAdded.emit(newFiles);
|
|
228
|
+
this.reset();
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
};
|
|
233
|
+
// items is not an array but of type DataTransferItemList
|
|
234
|
+
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
235
|
+
for (let i = 0; i < items.length; i++) {
|
|
236
|
+
const item = items[i].webkitGetAsEntry();
|
|
237
|
+
if (item) {
|
|
238
|
+
pendingEntries++;
|
|
239
|
+
traverseFileTree(item);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiFileDropzoneComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
244
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: SiFileDropzoneComponent, isStandalone: true, selector: "si-file-dropzone", inputs: { uploadTextFileSelect: { classPropertyName: "uploadTextFileSelect", publicName: "uploadTextFileSelect", isSignal: true, isRequired: false, transformFunction: null }, uploadDropText: { classPropertyName: "uploadDropText", publicName: "uploadDropText", isSignal: true, isRequired: false, transformFunction: null }, maxFileSizeText: { classPropertyName: "maxFileSizeText", publicName: "maxFileSizeText", isSignal: true, isRequired: false, transformFunction: null }, acceptText: { classPropertyName: "acceptText", publicName: "acceptText", isSignal: true, isRequired: false, transformFunction: null }, errorTextFileType: { classPropertyName: "errorTextFileType", publicName: "errorTextFileType", isSignal: true, isRequired: false, transformFunction: null }, errorTextFileMaxSize: { classPropertyName: "errorTextFileMaxSize", publicName: "errorTextFileMaxSize", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, maxFileSize: { classPropertyName: "maxFileSize", publicName: "maxFileSize", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, directoryUpload: { classPropertyName: "directoryUpload", publicName: "directoryUpload", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { filesAdded: "filesAdded" }, viewQueries: [{ propertyName: "fileInput", first: true, predicate: ["fileInput"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n class=\"drag-and-drop rounded p-6\"\n [class.drag-over]=\"dragOver\"\n (drop)=\"dropHandler($event)\"\n (dragover)=\"dragOverHandler($event)\"\n (dragleave)=\"dragOver = false\"\n>\n <si-icon-next class=\"mb-6 si-display-3\" [icon]=\"icons.elementUpload\" />\n <span class=\"drag-and-drop-description si-title-2 d-flex\">\n <span>{{ uploadDropText() | translate }}</span>\n \n <label class=\"select-file si-title-2 mb-0\">\n <span tabindex=\"0\" (keydown.enter)=\"inputEnterHandler()\">{{\n uploadTextFileSelect() | translate\n }}</span>\n <input\n #fileInput\n type=\"file\"\n tabindex=\"-1\"\n class=\"d-none\"\n [attr.webkitdirectory]=\"directoryUpload() ? true : null\"\n [accept]=\"accept()\"\n [multiple]=\"multiple()\"\n (change)=\"inputHandler($event)\"\n (cancel)=\"$event.stopPropagation()\"\n />\n </label>\n </span>\n @if (maxFileSize() || accept()) {\n <div class=\"allowed si-caption mt-6\">\n @if (maxFileSize()) {\n {{ maxFileSizeText() | translate }}: {{ maxFileSizeString() }}.\n }\n @if (accept()) {\n {{ acceptText() | translate }}: {{ accept() }}.\n }\n </div>\n }\n</div>\n", styles: [":host{display:block}.select-file{margin-block-end:0;cursor:pointer;color:var(--element-ui-0)}.select-file:hover,.select-file:active{text-decoration:underline}.drag-and-drop{background-color:var(--element-base-1);border:1px dashed var(--element-ui-2);display:flex;flex-direction:column;justify-content:center;align-items:center}.drag-and-drop.drag-over{border:1px solid var(--element-focus-default);box-shadow:0 0 0 1px var(--element-focus-default)}\n"], dependencies: [{ kind: "component", type: SiIconNextComponent, selector: "si-icon-next", inputs: ["icon"] }, { kind: "ngmodule", type: SiTranslateModule }, { kind: "pipe", type: i1.SiTranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
245
|
+
}
|
|
246
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiFileDropzoneComponent, decorators: [{
|
|
247
|
+
type: Component,
|
|
248
|
+
args: [{ selector: 'si-file-dropzone', changeDetection: ChangeDetectionStrategy.OnPush, imports: [SiIconNextComponent, SiTranslateModule], template: "<div\n class=\"drag-and-drop rounded p-6\"\n [class.drag-over]=\"dragOver\"\n (drop)=\"dropHandler($event)\"\n (dragover)=\"dragOverHandler($event)\"\n (dragleave)=\"dragOver = false\"\n>\n <si-icon-next class=\"mb-6 si-display-3\" [icon]=\"icons.elementUpload\" />\n <span class=\"drag-and-drop-description si-title-2 d-flex\">\n <span>{{ uploadDropText() | translate }}</span>\n \n <label class=\"select-file si-title-2 mb-0\">\n <span tabindex=\"0\" (keydown.enter)=\"inputEnterHandler()\">{{\n uploadTextFileSelect() | translate\n }}</span>\n <input\n #fileInput\n type=\"file\"\n tabindex=\"-1\"\n class=\"d-none\"\n [attr.webkitdirectory]=\"directoryUpload() ? true : null\"\n [accept]=\"accept()\"\n [multiple]=\"multiple()\"\n (change)=\"inputHandler($event)\"\n (cancel)=\"$event.stopPropagation()\"\n />\n </label>\n </span>\n @if (maxFileSize() || accept()) {\n <div class=\"allowed si-caption mt-6\">\n @if (maxFileSize()) {\n {{ maxFileSizeText() | translate }}: {{ maxFileSizeString() }}.\n }\n @if (accept()) {\n {{ acceptText() | translate }}: {{ accept() }}.\n }\n </div>\n }\n</div>\n", styles: [":host{display:block}.select-file{margin-block-end:0;cursor:pointer;color:var(--element-ui-0)}.select-file:hover,.select-file:active{text-decoration:underline}.drag-and-drop{background-color:var(--element-base-1);border:1px dashed var(--element-ui-2);display:flex;flex-direction:column;justify-content:center;align-items:center}.drag-and-drop.drag-over{border:1px solid var(--element-focus-default);box-shadow:0 0 0 1px var(--element-focus-default)}\n"] }]
|
|
249
|
+
}] });
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Copyright Siemens 2016 - 2025.
|
|
253
|
+
* SPDX-License-Identifier: MIT
|
|
254
|
+
*/
|
|
255
|
+
class SiFileUploaderComponent {
|
|
256
|
+
/**
|
|
257
|
+
* Text of the link to open the file select dialog (follows `uploadDropText`).
|
|
258
|
+
*
|
|
259
|
+
* @defaultValue
|
|
260
|
+
* ```
|
|
261
|
+
* $localize`:@@SI_FILE_UPLOADER.FILE_SELECT:click to upload`
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
uploadTextFileSelect = input($localize `:@@SI_FILE_UPLOADER.FILE_SELECT:click to upload`);
|
|
265
|
+
/**
|
|
266
|
+
* Text instructing a user to drop the files inside the dropzone.
|
|
267
|
+
*
|
|
268
|
+
* @defaultValue
|
|
269
|
+
* ```
|
|
270
|
+
* $localize`:@@SI_FILE_UPLOADER.DROP:Drop files here or`
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
uploadDropText = input($localize `:@@SI_FILE_UPLOADER.DROP:Drop files here or`);
|
|
274
|
+
/**
|
|
275
|
+
* Text to describe the maximum file size.
|
|
276
|
+
*
|
|
277
|
+
* @defaultValue
|
|
278
|
+
* ```
|
|
279
|
+
* $localize`:@@SI_FILE_UPLOADER.MAX_SIZE:Maximum upload size`
|
|
280
|
+
* ```
|
|
281
|
+
*/
|
|
282
|
+
maxFileSizeText = input($localize `:@@SI_FILE_UPLOADER.MAX_SIZE:Maximum upload size`);
|
|
283
|
+
/**
|
|
284
|
+
* Error message shown when the maximum number of files are reached.
|
|
285
|
+
*
|
|
286
|
+
* @defaultValue
|
|
287
|
+
* ```
|
|
288
|
+
* $localize`:@@SI_FILE_UPLOADER.MAX_FILE_REACHED:Maximum number of files reached`
|
|
289
|
+
* ```
|
|
290
|
+
*/
|
|
291
|
+
maxFilesReachedText = input($localize `:@@SI_FILE_UPLOADER.MAX_FILE_REACHED:Maximum number of files reached`);
|
|
292
|
+
/**
|
|
293
|
+
* Text for the accepted file types.
|
|
294
|
+
*
|
|
295
|
+
* @defaultValue
|
|
296
|
+
* ```
|
|
297
|
+
* $localize`:@@SI_FILE_UPLOADER.ACCEPTED_FILE_TYPES:Accepted file types`
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
acceptText = input($localize `:@@SI_FILE_UPLOADER.ACCEPTED_FILE_TYPES:Accepted file types`);
|
|
301
|
+
/**
|
|
302
|
+
* Text used inside the upload button.
|
|
303
|
+
*
|
|
304
|
+
* @defaultValue
|
|
305
|
+
* ```
|
|
306
|
+
* $localize`:@@SI_FILE_UPLOADER.UPLOAD:Upload`
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
uploadButtonText = input($localize `:@@SI_FILE_UPLOADER.UPLOAD:Upload`);
|
|
310
|
+
/**
|
|
311
|
+
* Text used inside the clear button.
|
|
312
|
+
*
|
|
313
|
+
* @defaultValue
|
|
314
|
+
* ```
|
|
315
|
+
* $localize`:@@SI_FILE_UPLOADER.CLEAR:Clear`
|
|
316
|
+
* ```
|
|
317
|
+
*/
|
|
318
|
+
clearButtonText = input($localize `:@@SI_FILE_UPLOADER.CLEAR:Clear`);
|
|
319
|
+
/**
|
|
320
|
+
* Text shown during the file upload.
|
|
321
|
+
*
|
|
322
|
+
* @defaultValue
|
|
323
|
+
* ```
|
|
324
|
+
* $localize`:@@SI_FILE_UPLOADER.UPLOADING:Uploading`
|
|
325
|
+
* ```
|
|
326
|
+
*/
|
|
327
|
+
uploadingText = input($localize `:@@SI_FILE_UPLOADER.UPLOADING:Uploading`);
|
|
328
|
+
/**
|
|
329
|
+
* Text shown to remove a file from the file list. Required for a11y.
|
|
330
|
+
*
|
|
331
|
+
* @defaultValue
|
|
332
|
+
* ```
|
|
333
|
+
* $localize`:@@SI_FILE_UPLOADER.REMOVE:Remove`
|
|
334
|
+
* ```
|
|
335
|
+
*/
|
|
336
|
+
removeButtonText = input($localize `:@@SI_FILE_UPLOADER.REMOVE:Remove`);
|
|
337
|
+
/**
|
|
338
|
+
* Text of cancel button. Shown during upload. Required for a11y.
|
|
339
|
+
*
|
|
340
|
+
* @defaultValue
|
|
341
|
+
* ```
|
|
342
|
+
* $localize`:@@SI_FILE_UPLOADER.CANCEL:Cancel`
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
cancelButtonText = input($localize `:@@SI_FILE_UPLOADER.CANCEL:Cancel`);
|
|
346
|
+
/**
|
|
347
|
+
* Text shown if the upload was successful.
|
|
348
|
+
*
|
|
349
|
+
* @defaultValue
|
|
350
|
+
* ```
|
|
351
|
+
* $localize`:@@SI_FILE_UPLOADER.UPLOAD_COMPLETED:Upload completed`
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
successTextTitle = input($localize `:@@SI_FILE_UPLOADER.UPLOAD_COMPLETED:Upload completed`);
|
|
355
|
+
/**
|
|
356
|
+
* Text shown if the upload failed.
|
|
357
|
+
*
|
|
358
|
+
* @defaultValue
|
|
359
|
+
* ```
|
|
360
|
+
* $localize`:@@SI_FILE_UPLOADER.UPLOAD_FAILED:Upload failed`
|
|
361
|
+
* ```
|
|
362
|
+
*/
|
|
363
|
+
errorUploadFailed = input($localize `:@@SI_FILE_UPLOADER.UPLOAD_FAILED:Upload failed`);
|
|
364
|
+
/**
|
|
365
|
+
* On failed upload, show the error received from the server.
|
|
366
|
+
*
|
|
367
|
+
* @defaultValue false
|
|
368
|
+
*/
|
|
369
|
+
showHttpError = input(false, { transform: booleanAttribute });
|
|
370
|
+
/**
|
|
371
|
+
* Text shown to indicate that an incorrect file type was added to file list.
|
|
372
|
+
*
|
|
373
|
+
* @defaultValue
|
|
374
|
+
* ```
|
|
375
|
+
* $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Incorrect file type selected`
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
errorTextFileType = input($localize `:@@SI_FILE_UPLOADER.ERROR_FILE_TYPE:Incorrect file type selected`);
|
|
379
|
+
/**
|
|
380
|
+
* Message or translation key if file exceeds the maximum file size limit.
|
|
381
|
+
*
|
|
382
|
+
* @defaultValue
|
|
383
|
+
* ```
|
|
384
|
+
* $localize`:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`
|
|
385
|
+
* ```
|
|
386
|
+
*/
|
|
387
|
+
errorTextFileMaxSize = input($localize `:@@SI_FILE_UPLOADER.ERROR_FILE_SIZE_EXCEEDED:File exceeds allowed maximum size`);
|
|
388
|
+
/**
|
|
389
|
+
* Config for HTTP request to upload file.
|
|
390
|
+
*
|
|
391
|
+
* @defaultValue
|
|
392
|
+
* ```
|
|
393
|
+
* {
|
|
394
|
+
* headers: new HttpHeaders({ 'Accept': 'application/json' }),
|
|
395
|
+
* method: 'POST',
|
|
396
|
+
* url: '',
|
|
397
|
+
* fieldName: 'upload_file',
|
|
398
|
+
* responseType: 'json'
|
|
399
|
+
* }
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
uploadConfig = input({
|
|
403
|
+
headers: new HttpHeaders({ 'Accept': 'application/json' }),
|
|
404
|
+
method: 'POST',
|
|
405
|
+
url: '',
|
|
406
|
+
fieldName: 'upload_file',
|
|
407
|
+
responseType: 'json'
|
|
408
|
+
});
|
|
409
|
+
/**
|
|
410
|
+
* Define which file types are suggested in file browser.
|
|
411
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#attr-accept
|
|
412
|
+
*/
|
|
413
|
+
accept = input();
|
|
414
|
+
/**
|
|
415
|
+
* Define maximal allowed file size in bytes.
|
|
416
|
+
*
|
|
417
|
+
* @defaultValue undefined
|
|
418
|
+
*/
|
|
419
|
+
maxFileSize = input(undefined, {
|
|
420
|
+
transform: numberAttribute
|
|
421
|
+
});
|
|
422
|
+
/**
|
|
423
|
+
* Define maximal allowed number of files.
|
|
424
|
+
* When {@link directoryUpload} is enabled, this will have no effect.
|
|
425
|
+
* @defaultValue 10
|
|
426
|
+
*/
|
|
427
|
+
maxFiles = input(10, { transform: numberAttribute });
|
|
428
|
+
/**
|
|
429
|
+
* Maximum number of concurrent uploads.
|
|
430
|
+
*
|
|
431
|
+
* @defaultValue 3
|
|
432
|
+
*/
|
|
433
|
+
maxConcurrentUploads = input(3, { transform: numberAttribute });
|
|
434
|
+
/**
|
|
435
|
+
* Numbers of retries for failed uploads.
|
|
436
|
+
*
|
|
437
|
+
* @defaultValue 0
|
|
438
|
+
*/
|
|
439
|
+
retries = input(0, { transform: numberAttribute });
|
|
440
|
+
/**
|
|
441
|
+
* Auto-upload mode - automatically start upload once files are added.
|
|
442
|
+
*
|
|
443
|
+
* @defaultValue false
|
|
444
|
+
*/
|
|
445
|
+
autoUpload = input(false, { transform: booleanAttribute });
|
|
446
|
+
/**
|
|
447
|
+
* Disable the upload button.
|
|
448
|
+
*
|
|
449
|
+
* @defaultValue false
|
|
450
|
+
*/
|
|
451
|
+
disableUpload = input(false, { transform: booleanAttribute });
|
|
452
|
+
/**
|
|
453
|
+
* Enable directory upload mode.
|
|
454
|
+
* When enabled, the file input will accept directories and upload all files within as a flat list.
|
|
455
|
+
* The hierarchy of the directory will not be preserved.
|
|
456
|
+
* The `maxFiles` property will have no effect when `directoryUpload` is enabled.
|
|
457
|
+
*
|
|
458
|
+
* **Note:** This feature is not yet available for safari (iOS)
|
|
459
|
+
*
|
|
460
|
+
* @defaultValue false
|
|
461
|
+
*/
|
|
462
|
+
directoryUpload = input(false, { transform: booleanAttribute });
|
|
463
|
+
/**
|
|
464
|
+
* Emits when a user press cancel during upload. The event provides the file details.
|
|
465
|
+
*/
|
|
466
|
+
uploadCanceled = output();
|
|
467
|
+
/**
|
|
468
|
+
* Output callback event will provide you if upload is finished. If an error
|
|
469
|
+
* occurred it will be emitted.
|
|
470
|
+
*/
|
|
471
|
+
uploadCompleted = output();
|
|
472
|
+
/**
|
|
473
|
+
* Output which fires whenever new files are added to or removed from the uploader.
|
|
474
|
+
*/
|
|
475
|
+
filesChanges = output();
|
|
476
|
+
icons = addIcons({
|
|
477
|
+
elementCancel,
|
|
478
|
+
elementDelete,
|
|
479
|
+
elementDocument,
|
|
480
|
+
elementRedo
|
|
481
|
+
});
|
|
482
|
+
files = [];
|
|
483
|
+
pending = 0;
|
|
484
|
+
uploading = 0;
|
|
485
|
+
uploadEnabled = false;
|
|
486
|
+
maxFilesReached = false;
|
|
487
|
+
dropZone = viewChild.required('dropZone');
|
|
488
|
+
cdRef = inject(ChangeDetectorRef);
|
|
489
|
+
http = inject(HttpClient, { optional: true });
|
|
490
|
+
ngOnChanges(changes) {
|
|
491
|
+
if (changes.maxFiles || changes.disableUpload) {
|
|
492
|
+
this.updateStates();
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
handleFiles(files) {
|
|
496
|
+
if (!files?.length) {
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
const maxFiles = this.maxFiles();
|
|
500
|
+
// for single-file case, replace exiting file if any
|
|
501
|
+
if (maxFiles === 1 && this.files.length) {
|
|
502
|
+
this.reset(false);
|
|
503
|
+
}
|
|
504
|
+
let numValid = this.countValid();
|
|
505
|
+
for (const file of files) {
|
|
506
|
+
const duplicate = this.isDuplicate(file);
|
|
507
|
+
if (duplicate) {
|
|
508
|
+
// in case this is duplicated: reset if already uploaded or not handled yet
|
|
509
|
+
if (duplicate.status !== 'uploading' && duplicate.status !== 'queued') {
|
|
510
|
+
Object.assign(duplicate, file);
|
|
511
|
+
}
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
const canAdd = numValid + 1 <= maxFiles;
|
|
515
|
+
const valid = file.status === 'added';
|
|
516
|
+
if (valid && !canAdd) {
|
|
517
|
+
this.maxFilesReached = true;
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
else if (valid) {
|
|
521
|
+
numValid++;
|
|
522
|
+
}
|
|
523
|
+
this.files.push(file);
|
|
524
|
+
}
|
|
525
|
+
this.files.sort((a, b) => a.fileName.localeCompare(b.fileName));
|
|
526
|
+
this.filesChanges.emit(this.files.slice());
|
|
527
|
+
this.updateStates();
|
|
528
|
+
// needed for drag drop of directory
|
|
529
|
+
this.cdRef.markForCheck();
|
|
530
|
+
if (this.autoUpload()) {
|
|
531
|
+
this.fileUpload(false);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
removeFile(index) {
|
|
535
|
+
if (index >= 0) {
|
|
536
|
+
this.files.splice(index, 1);
|
|
537
|
+
this.filesChanges.emit(this.files.slice());
|
|
538
|
+
this.dropZone().reset();
|
|
539
|
+
this.updateStates();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
cancelUpload(file) {
|
|
543
|
+
if (file.subscription) {
|
|
544
|
+
file.subscription.unsubscribe();
|
|
545
|
+
file.subscription = undefined;
|
|
546
|
+
this.uploading--;
|
|
547
|
+
}
|
|
548
|
+
this.pending--;
|
|
549
|
+
file.status = 'added';
|
|
550
|
+
file.progress = 0;
|
|
551
|
+
this.updateStates();
|
|
552
|
+
const { status, fileName, size, progress } = file;
|
|
553
|
+
this.uploadCanceled.emit({
|
|
554
|
+
status,
|
|
555
|
+
fileName,
|
|
556
|
+
size,
|
|
557
|
+
progress,
|
|
558
|
+
file: file.file
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
retryUpload(file) {
|
|
562
|
+
file.status = 'added';
|
|
563
|
+
this.doUpload([file], true);
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Reset the state.
|
|
567
|
+
*/
|
|
568
|
+
reset(emit = true) {
|
|
569
|
+
this.files.forEach(f => f.subscription?.unsubscribe());
|
|
570
|
+
this.files = [];
|
|
571
|
+
this.dropZone().reset();
|
|
572
|
+
this.updateStates();
|
|
573
|
+
if (emit) {
|
|
574
|
+
this.filesChanges.emit([]);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
/**
|
|
578
|
+
* Uploads the file
|
|
579
|
+
*/
|
|
580
|
+
fileUpload(doRetry = true) {
|
|
581
|
+
if (!this.uploadEnabled) {
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
this.uploadEnabled = false;
|
|
585
|
+
this.doUpload(this.files, doRetry);
|
|
586
|
+
}
|
|
587
|
+
doUpload(files, doRetry) {
|
|
588
|
+
for (const file of files) {
|
|
589
|
+
if (file.status !== 'added' && (!doRetry || file.status !== 'error')) {
|
|
590
|
+
continue;
|
|
591
|
+
}
|
|
592
|
+
this.pending++;
|
|
593
|
+
file.status = 'queued';
|
|
594
|
+
}
|
|
595
|
+
this.processQueue();
|
|
596
|
+
}
|
|
597
|
+
processQueue() {
|
|
598
|
+
for (let i = 0; i < this.files.length && this.uploading < this.maxConcurrentUploads(); i++) {
|
|
599
|
+
const file = this.files[i];
|
|
600
|
+
if (file.status === 'queued') {
|
|
601
|
+
this.uploading++;
|
|
602
|
+
this.uploadOneFile(file);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
uploadOneFile(file) {
|
|
607
|
+
let formData;
|
|
608
|
+
const config = this.uploadConfig();
|
|
609
|
+
if (!config.sendBinary) {
|
|
610
|
+
formData = new FormData();
|
|
611
|
+
if (config.additionalFields) {
|
|
612
|
+
Object.keys(config.additionalFields).forEach(key => {
|
|
613
|
+
formData.append(key, config.additionalFields[key]);
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
// this needs to be last for AWS
|
|
617
|
+
formData.append(config.fieldName, file.file, file.fileName);
|
|
618
|
+
}
|
|
619
|
+
const headers = config.headers instanceof HttpHeaders ? config.headers : new HttpHeaders(config.headers);
|
|
620
|
+
const req = new HttpRequest(config.method, config.url, formData ?? file.file, {
|
|
621
|
+
headers,
|
|
622
|
+
responseType: config.responseType,
|
|
623
|
+
reportProgress: true
|
|
624
|
+
});
|
|
625
|
+
file.status = 'uploading';
|
|
626
|
+
file.errorText = undefined;
|
|
627
|
+
file.httpErrorText = undefined;
|
|
628
|
+
const requestHandler = config.handler ??
|
|
629
|
+
(this.http ? (r) => this.http.request(r) : undefined);
|
|
630
|
+
if (!requestHandler) {
|
|
631
|
+
return;
|
|
632
|
+
}
|
|
633
|
+
file.subscription = requestHandler(req)
|
|
634
|
+
.pipe(retry(this.retries()))
|
|
635
|
+
.subscribe({
|
|
636
|
+
next: event => this.handleUploadEvent(file, event),
|
|
637
|
+
error: (error) => this.handleUploadError(file, error),
|
|
638
|
+
complete: () => this.handleUploadComplete(file)
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
// this is a light check for duplicate file - name and size only, not content!
|
|
642
|
+
isDuplicate(file) {
|
|
643
|
+
for (const uploadFile of this.files) {
|
|
644
|
+
if (uploadFile.file.name === file.file.name && uploadFile.file.size === file.file.size) {
|
|
645
|
+
return uploadFile;
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
handleUploadEvent(file, httpEvent) {
|
|
651
|
+
if (httpEvent instanceof HttpResponse) {
|
|
652
|
+
file.successResponse = httpEvent;
|
|
653
|
+
}
|
|
654
|
+
else if (httpEvent.type === HttpEventType.UploadProgress && httpEvent.total) {
|
|
655
|
+
file.progress = Math.floor((100 * httpEvent.loaded) / httpEvent.total);
|
|
656
|
+
this.cdRef.markForCheck();
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
handleUploadError(file, error) {
|
|
660
|
+
this.uploadCompleted.emit({ file: file.fileName, error });
|
|
661
|
+
file.status = 'error';
|
|
662
|
+
file.errorText = this.errorUploadFailed();
|
|
663
|
+
if (this.showHttpError() && error.status && error.statusText) {
|
|
664
|
+
file.httpErrorText = `${error.status}: ${error.statusText}`;
|
|
665
|
+
}
|
|
666
|
+
this.oneUploadDone(file);
|
|
667
|
+
}
|
|
668
|
+
handleUploadComplete(file) {
|
|
669
|
+
this.uploadCompleted.emit({ file: file.fileName, response: file.successResponse });
|
|
670
|
+
file.status = 'success';
|
|
671
|
+
file.progress = 100;
|
|
672
|
+
file.successResponse = undefined;
|
|
673
|
+
if (this.autoUpload()) {
|
|
674
|
+
this.fadeOut(file);
|
|
675
|
+
}
|
|
676
|
+
this.oneUploadDone(file);
|
|
677
|
+
}
|
|
678
|
+
oneUploadDone(file) {
|
|
679
|
+
file.subscription = undefined;
|
|
680
|
+
this.pending--;
|
|
681
|
+
this.uploading--;
|
|
682
|
+
this.updateStates();
|
|
683
|
+
this.processQueue();
|
|
684
|
+
}
|
|
685
|
+
fadeOut(file) {
|
|
686
|
+
setTimeout(() => {
|
|
687
|
+
file.fadeOut = true;
|
|
688
|
+
this.cdRef.markForCheck();
|
|
689
|
+
setTimeout(() => {
|
|
690
|
+
this.removeFile(this.files.indexOf(file));
|
|
691
|
+
this.cdRef.markForCheck();
|
|
692
|
+
}, 500);
|
|
693
|
+
this.cdRef.markForCheck();
|
|
694
|
+
}, 3500);
|
|
695
|
+
}
|
|
696
|
+
updateStates() {
|
|
697
|
+
this.uploadEnabled =
|
|
698
|
+
!this.disableUpload() &&
|
|
699
|
+
!this.pending &&
|
|
700
|
+
this.files.some(f => f.status === 'added' || f.status === 'error');
|
|
701
|
+
if (this.maxFilesReached && this.countValid() < this.maxFiles()) {
|
|
702
|
+
this.maxFilesReached = false;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
countValid() {
|
|
706
|
+
return this.files.reduce((acc, f) => acc + (f.status !== 'invalid' ? 1 : 0), 0);
|
|
707
|
+
}
|
|
708
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiFileUploaderComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
709
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.0.6", type: SiFileUploaderComponent, isStandalone: true, selector: "si-file-uploader", inputs: { uploadTextFileSelect: { classPropertyName: "uploadTextFileSelect", publicName: "uploadTextFileSelect", isSignal: true, isRequired: false, transformFunction: null }, uploadDropText: { classPropertyName: "uploadDropText", publicName: "uploadDropText", isSignal: true, isRequired: false, transformFunction: null }, maxFileSizeText: { classPropertyName: "maxFileSizeText", publicName: "maxFileSizeText", isSignal: true, isRequired: false, transformFunction: null }, maxFilesReachedText: { classPropertyName: "maxFilesReachedText", publicName: "maxFilesReachedText", isSignal: true, isRequired: false, transformFunction: null }, acceptText: { classPropertyName: "acceptText", publicName: "acceptText", isSignal: true, isRequired: false, transformFunction: null }, uploadButtonText: { classPropertyName: "uploadButtonText", publicName: "uploadButtonText", isSignal: true, isRequired: false, transformFunction: null }, clearButtonText: { classPropertyName: "clearButtonText", publicName: "clearButtonText", isSignal: true, isRequired: false, transformFunction: null }, uploadingText: { classPropertyName: "uploadingText", publicName: "uploadingText", isSignal: true, isRequired: false, transformFunction: null }, removeButtonText: { classPropertyName: "removeButtonText", publicName: "removeButtonText", isSignal: true, isRequired: false, transformFunction: null }, cancelButtonText: { classPropertyName: "cancelButtonText", publicName: "cancelButtonText", isSignal: true, isRequired: false, transformFunction: null }, successTextTitle: { classPropertyName: "successTextTitle", publicName: "successTextTitle", isSignal: true, isRequired: false, transformFunction: null }, errorUploadFailed: { classPropertyName: "errorUploadFailed", publicName: "errorUploadFailed", isSignal: true, isRequired: false, transformFunction: null }, showHttpError: { classPropertyName: "showHttpError", publicName: "showHttpError", isSignal: true, isRequired: false, transformFunction: null }, errorTextFileType: { classPropertyName: "errorTextFileType", publicName: "errorTextFileType", isSignal: true, isRequired: false, transformFunction: null }, errorTextFileMaxSize: { classPropertyName: "errorTextFileMaxSize", publicName: "errorTextFileMaxSize", isSignal: true, isRequired: false, transformFunction: null }, uploadConfig: { classPropertyName: "uploadConfig", publicName: "uploadConfig", isSignal: true, isRequired: false, transformFunction: null }, accept: { classPropertyName: "accept", publicName: "accept", isSignal: true, isRequired: false, transformFunction: null }, maxFileSize: { classPropertyName: "maxFileSize", publicName: "maxFileSize", isSignal: true, isRequired: false, transformFunction: null }, maxFiles: { classPropertyName: "maxFiles", publicName: "maxFiles", isSignal: true, isRequired: false, transformFunction: null }, maxConcurrentUploads: { classPropertyName: "maxConcurrentUploads", publicName: "maxConcurrentUploads", isSignal: true, isRequired: false, transformFunction: null }, retries: { classPropertyName: "retries", publicName: "retries", isSignal: true, isRequired: false, transformFunction: null }, autoUpload: { classPropertyName: "autoUpload", publicName: "autoUpload", isSignal: true, isRequired: false, transformFunction: null }, disableUpload: { classPropertyName: "disableUpload", publicName: "disableUpload", isSignal: true, isRequired: false, transformFunction: null }, directoryUpload: { classPropertyName: "directoryUpload", publicName: "directoryUpload", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { uploadCanceled: "uploadCanceled", uploadCompleted: "uploadCompleted", filesChanges: "filesChanges" }, viewQueries: [{ propertyName: "dropZone", first: true, predicate: ["dropZone"], descendants: true, isSignal: true }], usesOnChanges: true, ngImport: i0, template: "<si-file-dropzone\n #dropZone\n [ngClass]=\"autoUpload() ? 'mb-8' : 'mb-4'\"\n [uploadTextFileSelect]=\"uploadTextFileSelect()\"\n [uploadDropText]=\"uploadDropText()\"\n [multiple]=\"maxFiles() > 1\"\n [directoryUpload]=\"directoryUpload()\"\n [maxFileSizeText]=\"maxFileSizeText()\"\n [acceptText]=\"acceptText()\"\n [errorTextFileType]=\"errorTextFileType()\"\n [errorTextFileMaxSize]=\"errorTextFileMaxSize()\"\n [accept]=\"accept()\"\n [maxFileSize]=\"maxFileSize()\"\n (filesAdded)=\"handleFiles($event)\"\n/>\n\n@if (maxFilesReached) {\n <si-inline-notification class=\"mb-4\" severity=\"info\" [message]=\"maxFilesReachedText()\" />\n}\n\n<div class=\"file-list\">\n @for (file of files; track file) {\n <div\n class=\"file d-flex\"\n [ngClass]=\"autoUpload() ? 'mb-8' : 'mb-4'\"\n [class.fade-out]=\"file.fadeOut\"\n >\n <si-icon-next class=\"icon align-self-center ms-6 me-4\" [icon]=\"icons.elementDocument\" />\n <div class=\"flex-fill overflow-hidden\">\n <div class=\"file-info\">\n <div class=\"file-name text-truncate si-title-2\">{{ file.fileName }}</div>\n <div class=\"file-size text-secondary\">{{ file.size }}</div>\n </div>\n @if (file.errorText) {\n <div\n class=\"error text-truncate d-flex align-items-center\"\n [class.text-warning]=\"file.status === 'invalid'\"\n [class.text-danger]=\"file.status === 'error'\"\n >\n <si-icon\n class=\"d-inline-block my-n2 me-2\"\n size=\"icon-small\"\n stackedIcon=\"element-state-exclamation-mark smooth-auto\"\n alt=\"\"\n [icon]=\"\n file.status === 'invalid' ? 'element-triangle-filled' : 'element-circle-filled'\n \"\n [color]=\"file.status === 'invalid' ? 'status-warning' : 'status-danger'\"\n [stackedColor]=\"\n file.status === 'invalid' ? 'status-warning-contrast' : 'status-danger-contrast'\n \"\n />\n {{ file.errorText | translate }}\n @if (file.httpErrorText) {\n : {{ file.httpErrorText }}\n }\n </div>\n }\n @if (!file.errorText) {\n <div class=\"position-relative\">\n <div class=\"position-absolute si-caption end-0 mt-n8\">{{ file.progress }} %</div>\n <si-progressbar\n height=\"small\"\n [value]=\"file.progress\"\n [ariaLabel]=\"uploadingText() | translate\"\n />\n </div>\n }\n </div>\n <div class=\"status align-self-center text-nowrap ps-4 pe-6\">\n @if (file.status === 'error') {\n <button\n type=\"button\"\n class=\"btn btn-circle btn-sm btn-tertiary me-4\"\n [disabled]=\"!uploadEnabled\"\n [title]=\"uploadButtonText() | translate\"\n [attr.aria-label]=\"uploadButtonText() | translate\"\n (click)=\"retryUpload(file)\"\n >\n <si-icon-next [icon]=\"icons.elementRedo\" />\n </button>\n }\n @if (file.status === 'added' || file.status === 'error' || file.status === 'invalid') {\n <button\n type=\"button\"\n class=\"btn btn-circle btn-sm btn-ghost\"\n [title]=\"removeButtonText() | translate\"\n [attr.aria-label]=\"removeButtonText() | translate\"\n (click)=\"removeFile($index)\"\n >\n <si-icon-next [icon]=\"icons.elementDelete\" />\n </button>\n }\n @if (file.status === 'uploading' || file.status === 'queued') {\n <button\n type=\"button\"\n class=\"btn btn-circle btn-sm btn-tertiary\"\n [title]=\"cancelButtonText() | translate\"\n [attr.aria-label]=\"cancelButtonText() | translate\"\n (click)=\"cancelUpload(file)\"\n >\n <si-icon-next [icon]=\"icons.elementCancel\" />\n </button>\n }\n @if (file.status === 'success') {\n <si-icon\n class=\"mx-2\"\n icon=\"element-circle-filled\"\n color=\"status-success\"\n stackedIcon=\"element-state-tick smooth-auto\"\n stackedColor=\"status-success-contrast\"\n [alt]=\"successTextTitle()\"\n />\n }\n </div>\n </div>\n }\n</div>\n\n@if (!autoUpload()) {\n <div class=\"buttons text-end\">\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n [disabled]=\"pending || !files.length\"\n (click)=\"reset()\"\n >{{ clearButtonText() | translate }}</button\n >\n <button\n type=\"button\"\n class=\"btn btn-primary\"\n [disabled]=\"!uploadEnabled\"\n (click)=\"fileUpload()\"\n >{{ uploadButtonText() | translate }}</button\n >\n </div>\n}\n", styles: [":host{display:flex;flex-direction:column;justify-content:center;align-items:stretch}:host>*{min-inline-size:320px;max-inline-size:680px;inline-size:100%;align-self:center}.file-list{overflow-y:auto}.file-info{display:flex;justify-content:center;flex-direction:column;block-size:56px}.file{min-block-size:72px;transition:opacity calc(.5s * var(--element-animations-enabled, 1))}.fade-out{opacity:0}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: SiFileDropzoneComponent, selector: "si-file-dropzone", inputs: ["uploadTextFileSelect", "uploadDropText", "maxFileSizeText", "acceptText", "errorTextFileType", "errorTextFileMaxSize", "accept", "maxFileSize", "multiple", "directoryUpload"], outputs: ["filesAdded"] }, { kind: "component", type: SiIconComponent, selector: "si-icon", inputs: ["icon", "color", "stackedIcon", "stackedColor", "alt", "size"] }, { kind: "component", type: SiIconNextComponent, selector: "si-icon-next", inputs: ["icon"] }, { kind: "component", type: SiInlineNotificationComponent, selector: "si-inline-notification", inputs: ["severity", "heading", "message", "action", "translationParams", "embedded"] }, { kind: "component", type: SiProgressbarComponent, selector: "si-progressbar", inputs: ["ariaLabel", "max", "value", "heading", "progress", "height"] }, { kind: "ngmodule", type: SiTranslateModule }, { kind: "pipe", type: i1.SiTranslatePipe, name: "translate" }] });
|
|
710
|
+
}
|
|
711
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiFileUploaderComponent, decorators: [{
|
|
712
|
+
type: Component,
|
|
713
|
+
args: [{ selector: 'si-file-uploader', imports: [
|
|
714
|
+
NgClass,
|
|
715
|
+
SiFileDropzoneComponent,
|
|
716
|
+
SiIconComponent,
|
|
717
|
+
SiIconNextComponent,
|
|
718
|
+
SiInlineNotificationComponent,
|
|
719
|
+
SiProgressbarComponent,
|
|
720
|
+
SiTranslateModule
|
|
721
|
+
], template: "<si-file-dropzone\n #dropZone\n [ngClass]=\"autoUpload() ? 'mb-8' : 'mb-4'\"\n [uploadTextFileSelect]=\"uploadTextFileSelect()\"\n [uploadDropText]=\"uploadDropText()\"\n [multiple]=\"maxFiles() > 1\"\n [directoryUpload]=\"directoryUpload()\"\n [maxFileSizeText]=\"maxFileSizeText()\"\n [acceptText]=\"acceptText()\"\n [errorTextFileType]=\"errorTextFileType()\"\n [errorTextFileMaxSize]=\"errorTextFileMaxSize()\"\n [accept]=\"accept()\"\n [maxFileSize]=\"maxFileSize()\"\n (filesAdded)=\"handleFiles($event)\"\n/>\n\n@if (maxFilesReached) {\n <si-inline-notification class=\"mb-4\" severity=\"info\" [message]=\"maxFilesReachedText()\" />\n}\n\n<div class=\"file-list\">\n @for (file of files; track file) {\n <div\n class=\"file d-flex\"\n [ngClass]=\"autoUpload() ? 'mb-8' : 'mb-4'\"\n [class.fade-out]=\"file.fadeOut\"\n >\n <si-icon-next class=\"icon align-self-center ms-6 me-4\" [icon]=\"icons.elementDocument\" />\n <div class=\"flex-fill overflow-hidden\">\n <div class=\"file-info\">\n <div class=\"file-name text-truncate si-title-2\">{{ file.fileName }}</div>\n <div class=\"file-size text-secondary\">{{ file.size }}</div>\n </div>\n @if (file.errorText) {\n <div\n class=\"error text-truncate d-flex align-items-center\"\n [class.text-warning]=\"file.status === 'invalid'\"\n [class.text-danger]=\"file.status === 'error'\"\n >\n <si-icon\n class=\"d-inline-block my-n2 me-2\"\n size=\"icon-small\"\n stackedIcon=\"element-state-exclamation-mark smooth-auto\"\n alt=\"\"\n [icon]=\"\n file.status === 'invalid' ? 'element-triangle-filled' : 'element-circle-filled'\n \"\n [color]=\"file.status === 'invalid' ? 'status-warning' : 'status-danger'\"\n [stackedColor]=\"\n file.status === 'invalid' ? 'status-warning-contrast' : 'status-danger-contrast'\n \"\n />\n {{ file.errorText | translate }}\n @if (file.httpErrorText) {\n : {{ file.httpErrorText }}\n }\n </div>\n }\n @if (!file.errorText) {\n <div class=\"position-relative\">\n <div class=\"position-absolute si-caption end-0 mt-n8\">{{ file.progress }} %</div>\n <si-progressbar\n height=\"small\"\n [value]=\"file.progress\"\n [ariaLabel]=\"uploadingText() | translate\"\n />\n </div>\n }\n </div>\n <div class=\"status align-self-center text-nowrap ps-4 pe-6\">\n @if (file.status === 'error') {\n <button\n type=\"button\"\n class=\"btn btn-circle btn-sm btn-tertiary me-4\"\n [disabled]=\"!uploadEnabled\"\n [title]=\"uploadButtonText() | translate\"\n [attr.aria-label]=\"uploadButtonText() | translate\"\n (click)=\"retryUpload(file)\"\n >\n <si-icon-next [icon]=\"icons.elementRedo\" />\n </button>\n }\n @if (file.status === 'added' || file.status === 'error' || file.status === 'invalid') {\n <button\n type=\"button\"\n class=\"btn btn-circle btn-sm btn-ghost\"\n [title]=\"removeButtonText() | translate\"\n [attr.aria-label]=\"removeButtonText() | translate\"\n (click)=\"removeFile($index)\"\n >\n <si-icon-next [icon]=\"icons.elementDelete\" />\n </button>\n }\n @if (file.status === 'uploading' || file.status === 'queued') {\n <button\n type=\"button\"\n class=\"btn btn-circle btn-sm btn-tertiary\"\n [title]=\"cancelButtonText() | translate\"\n [attr.aria-label]=\"cancelButtonText() | translate\"\n (click)=\"cancelUpload(file)\"\n >\n <si-icon-next [icon]=\"icons.elementCancel\" />\n </button>\n }\n @if (file.status === 'success') {\n <si-icon\n class=\"mx-2\"\n icon=\"element-circle-filled\"\n color=\"status-success\"\n stackedIcon=\"element-state-tick smooth-auto\"\n stackedColor=\"status-success-contrast\"\n [alt]=\"successTextTitle()\"\n />\n }\n </div>\n </div>\n }\n</div>\n\n@if (!autoUpload()) {\n <div class=\"buttons text-end\">\n <button\n type=\"button\"\n class=\"btn btn-secondary me-4\"\n [disabled]=\"pending || !files.length\"\n (click)=\"reset()\"\n >{{ clearButtonText() | translate }}</button\n >\n <button\n type=\"button\"\n class=\"btn btn-primary\"\n [disabled]=\"!uploadEnabled\"\n (click)=\"fileUpload()\"\n >{{ uploadButtonText() | translate }}</button\n >\n </div>\n}\n", styles: [":host{display:flex;flex-direction:column;justify-content:center;align-items:stretch}:host>*{min-inline-size:320px;max-inline-size:680px;inline-size:100%;align-self:center}.file-list{overflow-y:auto}.file-info{display:flex;justify-content:center;flex-direction:column;block-size:56px}.file{min-block-size:72px;transition:opacity calc(.5s * var(--element-animations-enabled, 1))}.fade-out{opacity:0}\n"] }]
|
|
722
|
+
}] });
|
|
723
|
+
|
|
724
|
+
/**
|
|
725
|
+
* Copyright Siemens 2016 - 2025.
|
|
726
|
+
* SPDX-License-Identifier: MIT
|
|
727
|
+
*/
|
|
728
|
+
class SiFileUploaderModule {
|
|
729
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiFileUploaderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
730
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.0.6", ngImport: i0, type: SiFileUploaderModule, imports: [SiFileDropzoneComponent, SiFileUploaderComponent], exports: [SiFileDropzoneComponent, SiFileUploaderComponent] });
|
|
731
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiFileUploaderModule, imports: [SiFileDropzoneComponent, SiFileUploaderComponent] });
|
|
732
|
+
}
|
|
733
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.0.6", ngImport: i0, type: SiFileUploaderModule, decorators: [{
|
|
734
|
+
type: NgModule,
|
|
735
|
+
args: [{
|
|
736
|
+
imports: [SiFileDropzoneComponent, SiFileUploaderComponent],
|
|
737
|
+
exports: [SiFileDropzoneComponent, SiFileUploaderComponent]
|
|
738
|
+
}]
|
|
739
|
+
}] });
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Copyright Siemens 2016 - 2025.
|
|
743
|
+
* SPDX-License-Identifier: MIT
|
|
744
|
+
*/
|
|
745
|
+
|
|
746
|
+
/**
|
|
747
|
+
* Generated bundle index. Do not edit.
|
|
748
|
+
*/
|
|
749
|
+
|
|
750
|
+
export { SiFileDropzoneComponent, SiFileUploaderComponent, SiFileUploaderModule };
|
|
751
|
+
//# sourceMappingURL=siemens-element-ng-file-uploader.mjs.map
|