@masmarino/gabarit 2.0.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -85
- package/accordion/README.md +56 -0
- package/alert/README.md +87 -0
- package/app-shell/README.md +133 -0
- package/auth/README.md +155 -0
- package/auth-activate/README.md +119 -0
- package/auth-login/README.md +113 -0
- package/auth-register/README.md +104 -0
- package/auth-reset-password/README.md +120 -0
- package/autocomplete/README.md +77 -0
- package/avatar/README.md +34 -0
- package/avatar-group/README.md +47 -0
- package/badge/README.md +177 -0
- package/bar-chart/README.md +44 -0
- package/breadcrumb/README.md +38 -0
- package/button/README.md +175 -0
- package/card/README.md +179 -0
- package/checkbox/README.md +50 -0
- package/checkbox-group/README.md +78 -0
- package/confirm-danger-modal/README.md +77 -0
- package/copy-button/README.md +90 -0
- package/copy-field/README.md +54 -0
- package/date-picker/README.md +84 -0
- package/description-list/README.md +63 -0
- package/dimension-card/README.md +39 -0
- package/disclosure/README.md +48 -0
- package/divider/README.md +31 -0
- package/drawer/README.md +49 -0
- package/empty-state/README.md +84 -0
- package/fesm2022/masmarino-gabarit-accordion.mjs +243 -0
- package/fesm2022/masmarino-gabarit-accordion.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-alert.mjs +208 -0
- package/fesm2022/masmarino-gabarit-alert.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-app-shell.mjs +378 -0
- package/fesm2022/masmarino-gabarit-app-shell.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-auth-activate.mjs +415 -0
- package/fesm2022/masmarino-gabarit-auth-activate.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-auth-login.mjs +467 -0
- package/fesm2022/masmarino-gabarit-auth-login.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-auth-register.mjs +457 -0
- package/fesm2022/masmarino-gabarit-auth-register.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-auth-reset-password.mjs +364 -0
- package/fesm2022/masmarino-gabarit-auth-reset-password.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-auth.mjs +844 -0
- package/fesm2022/masmarino-gabarit-auth.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-autocomplete.mjs +475 -0
- package/fesm2022/masmarino-gabarit-autocomplete.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-avatar-group.mjs +202 -0
- package/fesm2022/masmarino-gabarit-avatar-group.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-avatar.mjs +107 -0
- package/fesm2022/masmarino-gabarit-avatar.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-badge.mjs +449 -0
- package/fesm2022/masmarino-gabarit-badge.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-bar-chart.mjs +408 -0
- package/fesm2022/masmarino-gabarit-bar-chart.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-breadcrumb.mjs +59 -0
- package/fesm2022/masmarino-gabarit-breadcrumb.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-button.mjs +374 -0
- package/fesm2022/masmarino-gabarit-button.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-card.mjs +400 -0
- package/fesm2022/masmarino-gabarit-card.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-chart.mjs +1289 -0
- package/fesm2022/masmarino-gabarit-chart.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-checkbox-group.mjs +335 -0
- package/fesm2022/masmarino-gabarit-checkbox-group.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-checkbox.mjs +170 -0
- package/fesm2022/masmarino-gabarit-checkbox.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-confirm-danger-modal.mjs +387 -0
- package/fesm2022/masmarino-gabarit-confirm-danger-modal.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-copy-button.mjs +407 -0
- package/fesm2022/masmarino-gabarit-copy-button.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-copy-field.mjs +229 -0
- package/fesm2022/masmarino-gabarit-copy-field.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-date-picker.mjs +1242 -0
- package/fesm2022/masmarino-gabarit-date-picker.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-description-list.mjs +127 -0
- package/fesm2022/masmarino-gabarit-description-list.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-dimension-card.mjs +162 -0
- package/fesm2022/masmarino-gabarit-dimension-card.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-disclosure.mjs +154 -0
- package/fesm2022/masmarino-gabarit-disclosure.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-divider.mjs +90 -0
- package/fesm2022/masmarino-gabarit-divider.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-docs.mjs +16 -2
- package/fesm2022/masmarino-gabarit-docs.mjs.map +1 -1
- package/fesm2022/masmarino-gabarit-drawer.mjs +209 -0
- package/fesm2022/masmarino-gabarit-drawer.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-empty-state.mjs +226 -0
- package/fesm2022/masmarino-gabarit-empty-state.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-file-upload.mjs +335 -0
- package/fesm2022/masmarino-gabarit-file-upload.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-floating-panel.mjs +24 -0
- package/fesm2022/masmarino-gabarit-floating-panel.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-format.mjs +345 -0
- package/fesm2022/masmarino-gabarit-format.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-funnel-chart.mjs +247 -0
- package/fesm2022/masmarino-gabarit-funnel-chart.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-gauge-bar.mjs +180 -0
- package/fesm2022/masmarino-gabarit-gauge-bar.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-git-field.mjs +127 -0
- package/fesm2022/masmarino-gabarit-git-field.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-icon-marker.mjs +150 -0
- package/fesm2022/masmarino-gabarit-icon-marker.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-icon.mjs +308 -0
- package/fesm2022/masmarino-gabarit-icon.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-input.mjs +493 -0
- package/fesm2022/masmarino-gabarit-input.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-job-graph.mjs +216 -0
- package/fesm2022/masmarino-gabarit-job-graph.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-job-status.mjs +104 -0
- package/fesm2022/masmarino-gabarit-job-status.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-line-chart.mjs +574 -0
- package/fesm2022/masmarino-gabarit-line-chart.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-list-card.mjs +320 -0
- package/fesm2022/masmarino-gabarit-list-card.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-list-row.mjs +58 -0
- package/fesm2022/masmarino-gabarit-list-row.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-list-toolbar.mjs +369 -0
- package/fesm2022/masmarino-gabarit-list-toolbar.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-menu.mjs +464 -0
- package/fesm2022/masmarino-gabarit-menu.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-mfa-enrollment.mjs +897 -0
- package/fesm2022/masmarino-gabarit-mfa-enrollment.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-mfa-settings.mjs +629 -0
- package/fesm2022/masmarino-gabarit-mfa-settings.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-modal.mjs +260 -0
- package/fesm2022/masmarino-gabarit-modal.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-nav-tabs.mjs +332 -0
- package/fesm2022/masmarino-gabarit-nav-tabs.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-notification-dot.mjs +119 -0
- package/fesm2022/masmarino-gabarit-notification-dot.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-page-header.mjs +78 -0
- package/fesm2022/masmarino-gabarit-page-header.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-page-layout.mjs +157 -0
- package/fesm2022/masmarino-gabarit-page-layout.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-pagination.mjs +415 -0
- package/fesm2022/masmarino-gabarit-pagination.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-panel.mjs +80 -0
- package/fesm2022/masmarino-gabarit-panel.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-passkey-settings.mjs +606 -0
- package/fesm2022/masmarino-gabarit-passkey-settings.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-pie-chart.mjs +317 -0
- package/fesm2022/masmarino-gabarit-pie-chart.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-popover.mjs +142 -0
- package/fesm2022/masmarino-gabarit-popover.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-radio-group.mjs +202 -0
- package/fesm2022/masmarino-gabarit-radio-group.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-save-status.mjs +142 -0
- package/fesm2022/masmarino-gabarit-save-status.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-search-bar.mjs +576 -0
- package/fesm2022/masmarino-gabarit-search-bar.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-secret-reveal.mjs +348 -0
- package/fesm2022/masmarino-gabarit-secret-reveal.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-segmented-control.mjs +272 -0
- package/fesm2022/masmarino-gabarit-segmented-control.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-select.mjs +512 -0
- package/fesm2022/masmarino-gabarit-select.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-skeleton-list.mjs +189 -0
- package/fesm2022/masmarino-gabarit-skeleton-list.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-skeleton.mjs +109 -0
- package/fesm2022/masmarino-gabarit-skeleton.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-slider.mjs +239 -0
- package/fesm2022/masmarino-gabarit-slider.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-sparkline.mjs +276 -0
- package/fesm2022/masmarino-gabarit-sparkline.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-spinner.mjs +86 -0
- package/fesm2022/masmarino-gabarit-spinner.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-stat-grid.mjs +139 -0
- package/fesm2022/masmarino-gabarit-stat-grid.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-stat-tile.mjs +312 -0
- package/fesm2022/masmarino-gabarit-stat-tile.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-stepper.mjs +219 -0
- package/fesm2022/masmarino-gabarit-stepper.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-switch.mjs +151 -0
- package/fesm2022/masmarino-gabarit-switch.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-table.mjs +206 -0
- package/fesm2022/masmarino-gabarit-table.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-tabs.mjs +210 -0
- package/fesm2022/masmarino-gabarit-tabs.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-tag-input.mjs +288 -0
- package/fesm2022/masmarino-gabarit-tag-input.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-tag.mjs +155 -0
- package/fesm2022/masmarino-gabarit-tag.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-textarea.mjs +369 -0
- package/fesm2022/masmarino-gabarit-textarea.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-timeline-chart.mjs +521 -0
- package/fesm2022/masmarino-gabarit-timeline-chart.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-toaster.mjs +220 -0
- package/fesm2022/masmarino-gabarit-toaster.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-tooltip.mjs +185 -0
- package/fesm2022/masmarino-gabarit-tooltip.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-tree.mjs +258 -0
- package/fesm2022/masmarino-gabarit-tree.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit-user-chip.mjs +106 -0
- package/fesm2022/masmarino-gabarit-user-chip.mjs.map +1 -0
- package/fesm2022/masmarino-gabarit.mjs +83 -24785
- package/fesm2022/masmarino-gabarit.mjs.map +1 -1
- package/file-upload/README.md +47 -0
- package/funnel-chart/README.md +39 -0
- package/gauge-bar/README.md +35 -0
- package/git-field/README.md +34 -0
- package/icon/README.md +52 -0
- package/icon-marker/README.md +37 -0
- package/input/README.md +120 -0
- package/job-graph/README.md +76 -0
- package/job-status/README.md +34 -0
- package/line-chart/README.md +52 -0
- package/list-card/README.md +144 -0
- package/list-row/README.md +72 -0
- package/list-toolbar/README.md +52 -0
- package/menu/README.md +90 -0
- package/mfa-enrollment/README.md +189 -0
- package/mfa-settings/README.md +154 -0
- package/modal/README.md +72 -0
- package/nav-tabs/README.md +106 -0
- package/notification-dot/README.md +43 -0
- package/package.json +329 -1
- package/page-header/README.md +56 -0
- package/page-layout/README.md +76 -0
- package/pagination/README.md +73 -0
- package/panel/README.md +56 -0
- package/passkey-settings/README.md +120 -0
- package/pie-chart/README.md +85 -0
- package/popover/README.md +62 -0
- package/radio-group/README.md +47 -0
- package/save-status/README.md +44 -0
- package/search-bar/README.md +84 -0
- package/secret-reveal/README.md +60 -0
- package/segmented-control/README.md +79 -0
- package/select/README.md +61 -0
- package/skeleton/README.md +49 -0
- package/skeleton-list/README.md +40 -0
- package/slider/README.md +44 -0
- package/sparkline/README.md +37 -0
- package/spinner/README.md +41 -0
- package/stat-grid/README.md +47 -0
- package/stat-tile/README.md +75 -0
- package/stepper/README.md +67 -0
- package/switch/README.md +51 -0
- package/table/README.md +75 -0
- package/tabs/README.md +34 -0
- package/tag/README.md +34 -0
- package/tag-input/README.md +45 -0
- package/textarea/README.md +76 -0
- package/timeline-chart/README.md +49 -0
- package/toaster/README.md +92 -0
- package/tooltip/README.md +50 -0
- package/tree/README.md +79 -0
- package/types/masmarino-gabarit-accordion.d.ts +54 -0
- package/types/masmarino-gabarit-alert.d.ts +65 -0
- package/types/masmarino-gabarit-app-shell.d.ts +102 -0
- package/types/masmarino-gabarit-auth-activate.d.ts +70 -0
- package/types/masmarino-gabarit-auth-login.d.ts +63 -0
- package/types/masmarino-gabarit-auth-register.d.ts +66 -0
- package/types/masmarino-gabarit-auth-reset-password.d.ts +53 -0
- package/types/masmarino-gabarit-auth.d.ts +543 -0
- package/types/masmarino-gabarit-autocomplete.d.ts +140 -0
- package/types/masmarino-gabarit-avatar-group.d.ts +60 -0
- package/types/masmarino-gabarit-avatar.d.ts +31 -0
- package/types/masmarino-gabarit-badge.d.ts +139 -0
- package/types/masmarino-gabarit-bar-chart.d.ts +111 -0
- package/types/masmarino-gabarit-breadcrumb.d.ts +12 -0
- package/types/masmarino-gabarit-button.d.ts +108 -0
- package/types/masmarino-gabarit-card.d.ts +102 -0
- package/types/masmarino-gabarit-chart.d.ts +361 -0
- package/types/masmarino-gabarit-checkbox-group.d.ts +113 -0
- package/types/masmarino-gabarit-checkbox.d.ts +49 -0
- package/types/masmarino-gabarit-confirm-danger-modal.d.ts +94 -0
- package/types/masmarino-gabarit-copy-button.d.ts +111 -0
- package/types/masmarino-gabarit-copy-field.d.ts +64 -0
- package/types/masmarino-gabarit-date-picker.d.ts +399 -0
- package/types/masmarino-gabarit-description-list.d.ts +40 -0
- package/types/masmarino-gabarit-dimension-card.d.ts +55 -0
- package/types/masmarino-gabarit-disclosure.d.ts +44 -0
- package/types/masmarino-gabarit-divider.d.ts +20 -0
- package/types/masmarino-gabarit-docs.d.ts +2 -1
- package/types/masmarino-gabarit-drawer.d.ts +51 -0
- package/types/masmarino-gabarit-empty-state.d.ts +67 -0
- package/types/masmarino-gabarit-file-upload.d.ts +95 -0
- package/types/masmarino-gabarit-floating-panel.d.ts +14 -0
- package/types/masmarino-gabarit-format.d.ts +54 -0
- package/types/masmarino-gabarit-funnel-chart.d.ts +78 -0
- package/types/masmarino-gabarit-gauge-bar.d.ts +54 -0
- package/types/masmarino-gabarit-git-field.d.ts +39 -0
- package/types/masmarino-gabarit-icon-marker.d.ts +47 -0
- package/types/masmarino-gabarit-icon.d.ts +23 -0
- package/types/masmarino-gabarit-input.d.ts +181 -0
- package/types/masmarino-gabarit-job-graph.d.ts +63 -0
- package/types/masmarino-gabarit-job-status.d.ts +20 -0
- package/types/masmarino-gabarit-line-chart.d.ts +153 -0
- package/types/masmarino-gabarit-list-card.d.ts +87 -0
- package/types/masmarino-gabarit-list-row.d.ts +14 -0
- package/types/masmarino-gabarit-list-toolbar.d.ts +100 -0
- package/types/masmarino-gabarit-menu.d.ts +93 -0
- package/types/masmarino-gabarit-mfa-enrollment.d.ts +142 -0
- package/types/masmarino-gabarit-mfa-settings.d.ts +89 -0
- package/types/masmarino-gabarit-modal.d.ts +60 -0
- package/types/masmarino-gabarit-nav-tabs.d.ts +65 -0
- package/types/masmarino-gabarit-notification-dot.d.ts +34 -0
- package/types/masmarino-gabarit-page-header.d.ts +20 -0
- package/types/masmarino-gabarit-page-layout.d.ts +46 -0
- package/types/masmarino-gabarit-pagination.d.ts +109 -0
- package/types/masmarino-gabarit-panel.d.ts +21 -0
- package/types/masmarino-gabarit-passkey-settings.d.ts +94 -0
- package/types/masmarino-gabarit-pie-chart.d.ts +94 -0
- package/types/masmarino-gabarit-popover.d.ts +33 -0
- package/types/masmarino-gabarit-radio-group.d.ts +66 -0
- package/types/masmarino-gabarit-save-status.d.ts +39 -0
- package/types/masmarino-gabarit-search-bar.d.ts +183 -0
- package/types/masmarino-gabarit-secret-reveal.d.ts +95 -0
- package/types/masmarino-gabarit-segmented-control.d.ts +76 -0
- package/types/masmarino-gabarit-select.d.ts +146 -0
- package/types/masmarino-gabarit-skeleton-list.d.ts +54 -0
- package/types/masmarino-gabarit-skeleton.d.ts +26 -0
- package/types/masmarino-gabarit-slider.d.ts +73 -0
- package/types/masmarino-gabarit-sparkline.d.ts +70 -0
- package/types/masmarino-gabarit-spinner.d.ts +20 -0
- package/types/masmarino-gabarit-stat-grid.d.ts +39 -0
- package/types/masmarino-gabarit-stat-tile.d.ts +79 -0
- package/types/masmarino-gabarit-stepper.d.ts +67 -0
- package/types/masmarino-gabarit-switch.d.ts +42 -0
- package/types/masmarino-gabarit-table.d.ts +60 -0
- package/types/masmarino-gabarit-tabs.d.ts +40 -0
- package/types/masmarino-gabarit-tag-input.d.ts +78 -0
- package/types/masmarino-gabarit-tag.d.ts +35 -0
- package/types/masmarino-gabarit-textarea.d.ts +109 -0
- package/types/masmarino-gabarit-timeline-chart.d.ts +145 -0
- package/types/masmarino-gabarit-toaster.d.ts +62 -0
- package/types/masmarino-gabarit-tooltip.d.ts +39 -0
- package/types/masmarino-gabarit-tree.d.ts +71 -0
- package/types/masmarino-gabarit-user-chip.d.ts +26 -0
- package/types/masmarino-gabarit.d.ts +83 -6599
- package/user-chip/README.md +42 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, booleanAttribute, computed, forwardRef, input, signal, viewChild } from "@angular/core";
|
|
3
|
+
import { NG_VALUE_ACCESSOR } from "@angular/forms";
|
|
4
|
+
import { Icon } from "@masmarino/gabarit/icon";
|
|
5
|
+
let nextId = 0;
|
|
6
|
+
function formatFileSize(bytes) {
|
|
7
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
8
|
+
if (bytes < 1048576) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
9
|
+
return `${(bytes / 1048576).toFixed(1)} MB`;
|
|
10
|
+
}
|
|
11
|
+
var FileUpload = class FileUpload {
|
|
12
|
+
fileInput = viewChild("fileInput", ...ngDevMode ? [{ debugName: "fileInput" }] : /* istanbul ignore next */ []);
|
|
13
|
+
id = input(`gbt-file-upload-${++nextId}`, ...ngDevMode ? [{ debugName: "id" }] : /* istanbul ignore next */ []);
|
|
14
|
+
label = input("", ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
|
|
15
|
+
multiple = input(false, {
|
|
16
|
+
...ngDevMode ? { debugName: "multiple" } : /* istanbul ignore next */ {},
|
|
17
|
+
transform: booleanAttribute
|
|
18
|
+
});
|
|
19
|
+
accept = input("", ...ngDevMode ? [{ debugName: "accept" }] : /* istanbul ignore next */ []);
|
|
20
|
+
maxSizeMb = input(null, ...ngDevMode ? [{ debugName: "maxSizeMb" }] : /* istanbul ignore next */ []);
|
|
21
|
+
disabled = input(false, {
|
|
22
|
+
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
23
|
+
transform: booleanAttribute
|
|
24
|
+
});
|
|
25
|
+
errorMessage = input(null, ...ngDevMode ? [{ debugName: "errorMessage" }] : /* istanbul ignore next */ []);
|
|
26
|
+
dropLabel = input("Drag and drop a file here, or click to browse", ...ngDevMode ? [{ debugName: "dropLabel" }] : /* istanbul ignore next */ []);
|
|
27
|
+
removeLabel = input((name) => `Remove ${name}`, ...ngDevMode ? [{ debugName: "removeLabel" }] : /* istanbul ignore next */ []);
|
|
28
|
+
oversizeMessage = input((name, maxSizeMb) => `${name} exceeds ${maxSizeMb} MB and was not added.`, ...ngDevMode ? [{ debugName: "oversizeMessage" }] : /* istanbul ignore next */ []);
|
|
29
|
+
extraFileMessage = input((name) => `${name} was not added — only one file is allowed.`, ...ngDevMode ? [{ debugName: "extraFileMessage" }] : /* istanbul ignore next */ []);
|
|
30
|
+
files = signal([], ...ngDevMode ? [{ debugName: "files" }] : /* istanbul ignore next */ []);
|
|
31
|
+
rejections = signal([], ...ngDevMode ? [{ debugName: "rejections" }] : /* istanbul ignore next */ []);
|
|
32
|
+
dragOver = signal(false, ...ngDevMode ? [{ debugName: "dragOver" }] : /* istanbul ignore next */ []);
|
|
33
|
+
formatFileSize = formatFileSize;
|
|
34
|
+
formDisabled = signal(false, ...ngDevMode ? [{ debugName: "formDisabled" }] : /* istanbul ignore next */ []);
|
|
35
|
+
isDisabled = computed(() => this.disabled() || this.formDisabled(), ...ngDevMode ? [{ debugName: "isDisabled" }] : /* istanbul ignore next */ []);
|
|
36
|
+
onChange = () => {};
|
|
37
|
+
onTouched = () => {};
|
|
38
|
+
writeValue(value) {
|
|
39
|
+
this.files.set(value ?? []);
|
|
40
|
+
}
|
|
41
|
+
registerOnChange(fn) {
|
|
42
|
+
this.onChange = fn;
|
|
43
|
+
}
|
|
44
|
+
registerOnTouched(fn) {
|
|
45
|
+
this.onTouched = fn;
|
|
46
|
+
}
|
|
47
|
+
setDisabledState(isDisabled) {
|
|
48
|
+
this.formDisabled.set(isDisabled);
|
|
49
|
+
}
|
|
50
|
+
openPicker() {
|
|
51
|
+
if (this.isDisabled()) return;
|
|
52
|
+
this.fileInput()?.nativeElement.click();
|
|
53
|
+
}
|
|
54
|
+
onFilesSelected(event) {
|
|
55
|
+
const input = event.target;
|
|
56
|
+
this.addFiles(input.files);
|
|
57
|
+
input.value = "";
|
|
58
|
+
}
|
|
59
|
+
onDragEnter(event) {
|
|
60
|
+
event.preventDefault();
|
|
61
|
+
if (!this.isDisabled()) this.dragOver.set(true);
|
|
62
|
+
}
|
|
63
|
+
onDragOver(event) {
|
|
64
|
+
event.preventDefault();
|
|
65
|
+
}
|
|
66
|
+
onDragLeave(event) {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
this.dragOver.set(false);
|
|
69
|
+
}
|
|
70
|
+
onDrop(event) {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
this.dragOver.set(false);
|
|
73
|
+
if (this.isDisabled()) return;
|
|
74
|
+
this.addFiles(event.dataTransfer?.files ?? null);
|
|
75
|
+
}
|
|
76
|
+
removeFile(file) {
|
|
77
|
+
if (this.isDisabled()) return;
|
|
78
|
+
const next = this.files().filter((f) => f !== file);
|
|
79
|
+
this.files.set(next);
|
|
80
|
+
this.onChange(next);
|
|
81
|
+
this.onTouched();
|
|
82
|
+
}
|
|
83
|
+
addFiles(fileList) {
|
|
84
|
+
if (!fileList || fileList.length === 0) return;
|
|
85
|
+
const incoming = Array.from(fileList);
|
|
86
|
+
const maxSizeMb = this.maxSizeMb();
|
|
87
|
+
const accepted = [];
|
|
88
|
+
const rejected = [];
|
|
89
|
+
for (const file of incoming) if (maxSizeMb !== null && file.size > maxSizeMb * 1024 * 1024) rejected.push(this.oversizeMessage()(file.name, maxSizeMb));
|
|
90
|
+
else accepted.push(file);
|
|
91
|
+
const extra = this.multiple() ? [] : accepted.slice(1);
|
|
92
|
+
for (const file of extra) rejected.push(this.extraFileMessage()(file.name));
|
|
93
|
+
this.rejections.set(rejected);
|
|
94
|
+
if (accepted.length === 0) return;
|
|
95
|
+
const next = this.multiple() ? [...this.files(), ...accepted] : accepted.slice(0, 1);
|
|
96
|
+
this.files.set(next);
|
|
97
|
+
this.onChange(next);
|
|
98
|
+
this.onTouched();
|
|
99
|
+
}
|
|
100
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
101
|
+
minVersion: "12.0.0",
|
|
102
|
+
version: "22.2.0",
|
|
103
|
+
ngImport: i0,
|
|
104
|
+
type: FileUpload,
|
|
105
|
+
deps: [],
|
|
106
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
107
|
+
});
|
|
108
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
109
|
+
minVersion: "17.0.0",
|
|
110
|
+
version: "22.2.0",
|
|
111
|
+
type: FileUpload,
|
|
112
|
+
isStandalone: true,
|
|
113
|
+
selector: "gbt-file-upload",
|
|
114
|
+
inputs: {
|
|
115
|
+
id: {
|
|
116
|
+
classPropertyName: "id",
|
|
117
|
+
publicName: "id",
|
|
118
|
+
isSignal: true,
|
|
119
|
+
isRequired: false,
|
|
120
|
+
transformFunction: null
|
|
121
|
+
},
|
|
122
|
+
label: {
|
|
123
|
+
classPropertyName: "label",
|
|
124
|
+
publicName: "label",
|
|
125
|
+
isSignal: true,
|
|
126
|
+
isRequired: false,
|
|
127
|
+
transformFunction: null
|
|
128
|
+
},
|
|
129
|
+
multiple: {
|
|
130
|
+
classPropertyName: "multiple",
|
|
131
|
+
publicName: "multiple",
|
|
132
|
+
isSignal: true,
|
|
133
|
+
isRequired: false,
|
|
134
|
+
transformFunction: null
|
|
135
|
+
},
|
|
136
|
+
accept: {
|
|
137
|
+
classPropertyName: "accept",
|
|
138
|
+
publicName: "accept",
|
|
139
|
+
isSignal: true,
|
|
140
|
+
isRequired: false,
|
|
141
|
+
transformFunction: null
|
|
142
|
+
},
|
|
143
|
+
maxSizeMb: {
|
|
144
|
+
classPropertyName: "maxSizeMb",
|
|
145
|
+
publicName: "maxSizeMb",
|
|
146
|
+
isSignal: true,
|
|
147
|
+
isRequired: false,
|
|
148
|
+
transformFunction: null
|
|
149
|
+
},
|
|
150
|
+
disabled: {
|
|
151
|
+
classPropertyName: "disabled",
|
|
152
|
+
publicName: "disabled",
|
|
153
|
+
isSignal: true,
|
|
154
|
+
isRequired: false,
|
|
155
|
+
transformFunction: null
|
|
156
|
+
},
|
|
157
|
+
errorMessage: {
|
|
158
|
+
classPropertyName: "errorMessage",
|
|
159
|
+
publicName: "errorMessage",
|
|
160
|
+
isSignal: true,
|
|
161
|
+
isRequired: false,
|
|
162
|
+
transformFunction: null
|
|
163
|
+
},
|
|
164
|
+
dropLabel: {
|
|
165
|
+
classPropertyName: "dropLabel",
|
|
166
|
+
publicName: "dropLabel",
|
|
167
|
+
isSignal: true,
|
|
168
|
+
isRequired: false,
|
|
169
|
+
transformFunction: null
|
|
170
|
+
},
|
|
171
|
+
removeLabel: {
|
|
172
|
+
classPropertyName: "removeLabel",
|
|
173
|
+
publicName: "removeLabel",
|
|
174
|
+
isSignal: true,
|
|
175
|
+
isRequired: false,
|
|
176
|
+
transformFunction: null
|
|
177
|
+
},
|
|
178
|
+
oversizeMessage: {
|
|
179
|
+
classPropertyName: "oversizeMessage",
|
|
180
|
+
publicName: "oversizeMessage",
|
|
181
|
+
isSignal: true,
|
|
182
|
+
isRequired: false,
|
|
183
|
+
transformFunction: null
|
|
184
|
+
},
|
|
185
|
+
extraFileMessage: {
|
|
186
|
+
classPropertyName: "extraFileMessage",
|
|
187
|
+
publicName: "extraFileMessage",
|
|
188
|
+
isSignal: true,
|
|
189
|
+
isRequired: false,
|
|
190
|
+
transformFunction: null
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
providers: [{
|
|
194
|
+
provide: NG_VALUE_ACCESSOR,
|
|
195
|
+
useExisting: forwardRef(() => FileUpload),
|
|
196
|
+
multi: true
|
|
197
|
+
}],
|
|
198
|
+
viewQueries: [{
|
|
199
|
+
propertyName: "fileInput",
|
|
200
|
+
first: true,
|
|
201
|
+
predicate: ["fileInput"],
|
|
202
|
+
descendants: true,
|
|
203
|
+
isSignal: true
|
|
204
|
+
}],
|
|
205
|
+
ngImport: i0,
|
|
206
|
+
template: "<div class=\"gbt-file-upload\">\n @if (label()) {\n <span class=\"gbt-file-upload__label\" [id]=\"id() + '-label'\">{{ label() }}</span>\n }\n <button\n type=\"button\"\n class=\"gbt-file-upload__dropzone\"\n [class.gbt-file-upload__dropzone--drag-over]=\"dragOver()\"\n [disabled]=\"isDisabled()\"\n [attr.aria-labelledby]=\"label() ? id() + '-label' : null\"\n [attr.aria-describedby]=\"errorMessage() ? id() + '-error' : null\"\n (click)=\"openPicker()\"\n (dragenter)=\"onDragEnter($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop($event)\"\n >\n <gbt-icon name=\"upload\" class=\"gbt-file-upload__icon\" aria-hidden=\"true\" />\n <span class=\"gbt-file-upload__hint\">{{ dropLabel() }}</span>\n </button>\n <input\n #fileInput\n type=\"file\"\n class=\"gbt-file-upload__input\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n [multiple]=\"multiple()\"\n [attr.accept]=\"accept() || null\"\n [disabled]=\"isDisabled()\"\n (change)=\"onFilesSelected($event)\"\n />\n @if (rejections().length > 0) {\n <div class=\"gbt-file-upload__rejections\" role=\"alert\">\n <ul>\n @for (message of rejections(); track message) {\n <li>{{ message }}</li>\n }\n </ul>\n </div>\n }\n @if (files().length > 0) {\n <ul class=\"gbt-file-upload__files\">\n @for (file of files(); track file) {\n <li class=\"gbt-file-upload__file\">\n <span class=\"gbt-file-upload__file-name\">{{ file.name }}</span>\n <span class=\"gbt-file-upload__file-size\">{{ formatFileSize(file.size) }}</span>\n <button\n type=\"button\"\n class=\"gbt-file-upload__file-remove\"\n [disabled]=\"isDisabled()\"\n [attr.aria-label]=\"removeLabel()(file.name)\"\n (click)=\"removeFile(file)\"\n >\n <gbt-icon name=\"x\" aria-hidden=\"true\" />\n </button>\n </li>\n }\n </ul>\n }\n @if (errorMessage()) {\n <p [id]=\"id() + '-error'\" class=\"gbt-file-upload__error\" role=\"alert\">{{ errorMessage() }}</p>\n }\n</div>\n",
|
|
207
|
+
styles: [".gbt-file-upload{display:flex;flex-direction:column;gap:.5rem}.gbt-file-upload__label{font-size:.8125rem;font-weight:600;color:var(--text-secondary)}.gbt-file-upload__dropzone{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;gap:.5rem;width:100%;padding:1.5rem 1rem;background:var(--bg-panel);border:1px dashed var(--border-color);border-radius:var(--site-border-radius-sm);color:var(--text-secondary);cursor:pointer;transition:border-color .15s cubic-bezier(.4,0,.2,1),background .15s cubic-bezier(.4,0,.2,1)}.gbt-file-upload__dropzone:hover:not(:disabled){border-color:var(--primary)}.gbt-file-upload__dropzone:focus-visible{outline:2px solid var(--gbt-focus-ring, var(--focus-ring));outline-offset:2px}.gbt-file-upload__dropzone--drag-over{background:color-mix(in srgb,var(--primary) 8%,var(--bg-panel));border-color:var(--primary)}.gbt-file-upload__dropzone:disabled{cursor:not-allowed;opacity:.5}.gbt-file-upload__icon{color:var(--text-discret)}.gbt-file-upload__hint{font-size:13px;text-align:center}.gbt-file-upload__input{position:absolute;width:1px;height:1px;overflow:hidden;opacity:0}.gbt-file-upload__rejections{font-size:.75rem;color:var(--color-error-text)}.gbt-file-upload__rejections ul{margin:0;padding:0;list-style:none}.gbt-file-upload__files{display:flex;flex-direction:column;gap:.375rem;margin:0;padding:0;list-style:none}.gbt-file-upload__file{box-sizing:border-box;display:flex;align-items:center;gap:.5rem;padding:.5rem .625rem;background:var(--bg-panel);border-radius:var(--site-border-radius-sm)}.gbt-file-upload__file-name{flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:13px;color:var(--text-primary)}.gbt-file-upload__file-size{flex-shrink:0;font-size:12px;color:var(--text-secondary)}.gbt-file-upload__file-remove{position:relative;display:inline-flex;flex-shrink:0;background:none;border:none;color:var(--text-secondary);cursor:pointer}.gbt-file-upload__file-remove:hover:not(:disabled){color:var(--text-primary)}.gbt-file-upload__file-remove:focus-visible{outline:2px solid var(--gbt-focus-ring, var(--focus-ring));outline-offset:2px}.gbt-file-upload__file-remove:disabled{cursor:not-allowed;opacity:.5}.gbt-file-upload__file-remove:before{content:\"\";position:absolute;inset:50% auto auto 50%;width:max(100%,24px);height:max(100%,24px);transform:translate(-50%,-50%)}.gbt-file-upload__error{margin:0;font-size:.75rem;color:var(--color-error-text)}@media(prefers-reduced-motion:reduce){.gbt-file-upload__dropzone{transition:none}}\n"],
|
|
208
|
+
dependencies: [{
|
|
209
|
+
kind: "component",
|
|
210
|
+
type: Icon,
|
|
211
|
+
selector: "gbt-icon",
|
|
212
|
+
inputs: ["name"]
|
|
213
|
+
}],
|
|
214
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
215
|
+
});
|
|
216
|
+
};
|
|
217
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
218
|
+
minVersion: "12.0.0",
|
|
219
|
+
version: "22.2.0",
|
|
220
|
+
ngImport: i0,
|
|
221
|
+
type: FileUpload,
|
|
222
|
+
decorators: [{
|
|
223
|
+
type: Component,
|
|
224
|
+
args: [{
|
|
225
|
+
selector: "gbt-file-upload",
|
|
226
|
+
standalone: true,
|
|
227
|
+
imports: [Icon],
|
|
228
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
229
|
+
providers: [{
|
|
230
|
+
provide: NG_VALUE_ACCESSOR,
|
|
231
|
+
useExisting: forwardRef(() => FileUpload),
|
|
232
|
+
multi: true
|
|
233
|
+
}],
|
|
234
|
+
template: "<div class=\"gbt-file-upload\">\n @if (label()) {\n <span class=\"gbt-file-upload__label\" [id]=\"id() + '-label'\">{{ label() }}</span>\n }\n <button\n type=\"button\"\n class=\"gbt-file-upload__dropzone\"\n [class.gbt-file-upload__dropzone--drag-over]=\"dragOver()\"\n [disabled]=\"isDisabled()\"\n [attr.aria-labelledby]=\"label() ? id() + '-label' : null\"\n [attr.aria-describedby]=\"errorMessage() ? id() + '-error' : null\"\n (click)=\"openPicker()\"\n (dragenter)=\"onDragEnter($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop($event)\"\n >\n <gbt-icon name=\"upload\" class=\"gbt-file-upload__icon\" aria-hidden=\"true\" />\n <span class=\"gbt-file-upload__hint\">{{ dropLabel() }}</span>\n </button>\n <input\n #fileInput\n type=\"file\"\n class=\"gbt-file-upload__input\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n [multiple]=\"multiple()\"\n [attr.accept]=\"accept() || null\"\n [disabled]=\"isDisabled()\"\n (change)=\"onFilesSelected($event)\"\n />\n @if (rejections().length > 0) {\n <div class=\"gbt-file-upload__rejections\" role=\"alert\">\n <ul>\n @for (message of rejections(); track message) {\n <li>{{ message }}</li>\n }\n </ul>\n </div>\n }\n @if (files().length > 0) {\n <ul class=\"gbt-file-upload__files\">\n @for (file of files(); track file) {\n <li class=\"gbt-file-upload__file\">\n <span class=\"gbt-file-upload__file-name\">{{ file.name }}</span>\n <span class=\"gbt-file-upload__file-size\">{{ formatFileSize(file.size) }}</span>\n <button\n type=\"button\"\n class=\"gbt-file-upload__file-remove\"\n [disabled]=\"isDisabled()\"\n [attr.aria-label]=\"removeLabel()(file.name)\"\n (click)=\"removeFile(file)\"\n >\n <gbt-icon name=\"x\" aria-hidden=\"true\" />\n </button>\n </li>\n }\n </ul>\n }\n @if (errorMessage()) {\n <p [id]=\"id() + '-error'\" class=\"gbt-file-upload__error\" role=\"alert\">{{ errorMessage() }}</p>\n }\n</div>\n",
|
|
235
|
+
styles: [".gbt-file-upload{display:flex;flex-direction:column;gap:.5rem}.gbt-file-upload__label{font-size:.8125rem;font-weight:600;color:var(--text-secondary)}.gbt-file-upload__dropzone{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;gap:.5rem;width:100%;padding:1.5rem 1rem;background:var(--bg-panel);border:1px dashed var(--border-color);border-radius:var(--site-border-radius-sm);color:var(--text-secondary);cursor:pointer;transition:border-color .15s cubic-bezier(.4,0,.2,1),background .15s cubic-bezier(.4,0,.2,1)}.gbt-file-upload__dropzone:hover:not(:disabled){border-color:var(--primary)}.gbt-file-upload__dropzone:focus-visible{outline:2px solid var(--gbt-focus-ring, var(--focus-ring));outline-offset:2px}.gbt-file-upload__dropzone--drag-over{background:color-mix(in srgb,var(--primary) 8%,var(--bg-panel));border-color:var(--primary)}.gbt-file-upload__dropzone:disabled{cursor:not-allowed;opacity:.5}.gbt-file-upload__icon{color:var(--text-discret)}.gbt-file-upload__hint{font-size:13px;text-align:center}.gbt-file-upload__input{position:absolute;width:1px;height:1px;overflow:hidden;opacity:0}.gbt-file-upload__rejections{font-size:.75rem;color:var(--color-error-text)}.gbt-file-upload__rejections ul{margin:0;padding:0;list-style:none}.gbt-file-upload__files{display:flex;flex-direction:column;gap:.375rem;margin:0;padding:0;list-style:none}.gbt-file-upload__file{box-sizing:border-box;display:flex;align-items:center;gap:.5rem;padding:.5rem .625rem;background:var(--bg-panel);border-radius:var(--site-border-radius-sm)}.gbt-file-upload__file-name{flex:1;min-width:0;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-size:13px;color:var(--text-primary)}.gbt-file-upload__file-size{flex-shrink:0;font-size:12px;color:var(--text-secondary)}.gbt-file-upload__file-remove{position:relative;display:inline-flex;flex-shrink:0;background:none;border:none;color:var(--text-secondary);cursor:pointer}.gbt-file-upload__file-remove:hover:not(:disabled){color:var(--text-primary)}.gbt-file-upload__file-remove:focus-visible{outline:2px solid var(--gbt-focus-ring, var(--focus-ring));outline-offset:2px}.gbt-file-upload__file-remove:disabled{cursor:not-allowed;opacity:.5}.gbt-file-upload__file-remove:before{content:\"\";position:absolute;inset:50% auto auto 50%;width:max(100%,24px);height:max(100%,24px);transform:translate(-50%,-50%)}.gbt-file-upload__error{margin:0;font-size:.75rem;color:var(--color-error-text)}@media(prefers-reduced-motion:reduce){.gbt-file-upload__dropzone{transition:none}}\n"]
|
|
236
|
+
}]
|
|
237
|
+
}],
|
|
238
|
+
propDecorators: {
|
|
239
|
+
fileInput: [{
|
|
240
|
+
type: i0.ViewChild,
|
|
241
|
+
args: ["fileInput", { isSignal: true }]
|
|
242
|
+
}],
|
|
243
|
+
id: [{
|
|
244
|
+
type: i0.Input,
|
|
245
|
+
args: [{
|
|
246
|
+
isSignal: true,
|
|
247
|
+
alias: "id",
|
|
248
|
+
required: false
|
|
249
|
+
}]
|
|
250
|
+
}],
|
|
251
|
+
label: [{
|
|
252
|
+
type: i0.Input,
|
|
253
|
+
args: [{
|
|
254
|
+
isSignal: true,
|
|
255
|
+
alias: "label",
|
|
256
|
+
required: false
|
|
257
|
+
}]
|
|
258
|
+
}],
|
|
259
|
+
multiple: [{
|
|
260
|
+
type: i0.Input,
|
|
261
|
+
args: [{
|
|
262
|
+
isSignal: true,
|
|
263
|
+
alias: "multiple",
|
|
264
|
+
required: false
|
|
265
|
+
}]
|
|
266
|
+
}],
|
|
267
|
+
accept: [{
|
|
268
|
+
type: i0.Input,
|
|
269
|
+
args: [{
|
|
270
|
+
isSignal: true,
|
|
271
|
+
alias: "accept",
|
|
272
|
+
required: false
|
|
273
|
+
}]
|
|
274
|
+
}],
|
|
275
|
+
maxSizeMb: [{
|
|
276
|
+
type: i0.Input,
|
|
277
|
+
args: [{
|
|
278
|
+
isSignal: true,
|
|
279
|
+
alias: "maxSizeMb",
|
|
280
|
+
required: false
|
|
281
|
+
}]
|
|
282
|
+
}],
|
|
283
|
+
disabled: [{
|
|
284
|
+
type: i0.Input,
|
|
285
|
+
args: [{
|
|
286
|
+
isSignal: true,
|
|
287
|
+
alias: "disabled",
|
|
288
|
+
required: false
|
|
289
|
+
}]
|
|
290
|
+
}],
|
|
291
|
+
errorMessage: [{
|
|
292
|
+
type: i0.Input,
|
|
293
|
+
args: [{
|
|
294
|
+
isSignal: true,
|
|
295
|
+
alias: "errorMessage",
|
|
296
|
+
required: false
|
|
297
|
+
}]
|
|
298
|
+
}],
|
|
299
|
+
dropLabel: [{
|
|
300
|
+
type: i0.Input,
|
|
301
|
+
args: [{
|
|
302
|
+
isSignal: true,
|
|
303
|
+
alias: "dropLabel",
|
|
304
|
+
required: false
|
|
305
|
+
}]
|
|
306
|
+
}],
|
|
307
|
+
removeLabel: [{
|
|
308
|
+
type: i0.Input,
|
|
309
|
+
args: [{
|
|
310
|
+
isSignal: true,
|
|
311
|
+
alias: "removeLabel",
|
|
312
|
+
required: false
|
|
313
|
+
}]
|
|
314
|
+
}],
|
|
315
|
+
oversizeMessage: [{
|
|
316
|
+
type: i0.Input,
|
|
317
|
+
args: [{
|
|
318
|
+
isSignal: true,
|
|
319
|
+
alias: "oversizeMessage",
|
|
320
|
+
required: false
|
|
321
|
+
}]
|
|
322
|
+
}],
|
|
323
|
+
extraFileMessage: [{
|
|
324
|
+
type: i0.Input,
|
|
325
|
+
args: [{
|
|
326
|
+
isSignal: true,
|
|
327
|
+
alias: "extraFileMessage",
|
|
328
|
+
required: false
|
|
329
|
+
}]
|
|
330
|
+
}]
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
export { FileUpload };
|
|
334
|
+
|
|
335
|
+
//# sourceMappingURL=masmarino-gabarit-file-upload.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"masmarino-gabarit-file-upload.mjs","names":[],"sources":["../../../projects/gabarit/file-upload/file-upload.ts","../../../projects/gabarit/file-upload/file-upload.html"],"sourcesContent":["import {\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n booleanAttribute,\n computed,\n forwardRef,\n input,\n signal,\n viewChild,\n} from '@angular/core'\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'\nimport { Icon } from '@masmarino/gabarit/icon'\n\nlet nextId = 0\n\nfunction formatFileSize(bytes: number): string {\n if (bytes < 1024) {\n return `${bytes} B`\n }\n if (bytes < 1024 * 1024) {\n return `${(bytes / 1024).toFixed(1)} KB`\n }\n return `${(bytes / (1024 * 1024)).toFixed(1)} MB`\n}\n\n@Component({\n selector: 'gbt-file-upload',\n standalone: true,\n imports: [Icon],\n templateUrl: './file-upload.html',\n styleUrl: './file-upload.scss',\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => FileUpload),\n multi: true,\n },\n ],\n})\nexport class FileUpload implements ControlValueAccessor {\n private readonly fileInput = viewChild<ElementRef<HTMLInputElement>>('fileInput')\n\n id = input<string>(`gbt-file-upload-${++nextId}`)\n label = input<string>('')\n multiple = input(false, { transform: booleanAttribute })\n accept = input<string>('')\n maxSizeMb = input<number | null>(null)\n disabled = input(false, { transform: booleanAttribute })\n errorMessage = input<string | null>(null)\n dropLabel = input<string>('Drag and drop a file here, or click to browse')\n removeLabel = input<(name: string) => string>((name) => `Remove ${name}`)\n oversizeMessage = input<(name: string, maxSizeMb: number) => string>(\n (name, maxSizeMb) => `${name} exceeds ${maxSizeMb} MB and was not added.`,\n )\n extraFileMessage = input<(name: string) => string>(\n (name) => `${name} was not added — only one file is allowed.`,\n )\n\n protected readonly files = signal<File[]>([])\n protected readonly rejections = signal<string[]>([])\n protected readonly dragOver = signal(false)\n\n protected readonly formatFileSize = formatFileSize\n\n private readonly formDisabled = signal(false)\n protected readonly isDisabled = computed(() => this.disabled() || this.formDisabled())\n\n private onChange: (value: File[]) => void = () => {}\n private onTouched: () => void = () => {}\n\n writeValue(value: File[] | null): void {\n this.files.set(value ?? [])\n }\n\n registerOnChange(fn: (value: File[]) => void): void {\n this.onChange = fn\n }\n\n registerOnTouched(fn: () => void): void {\n this.onTouched = fn\n }\n\n setDisabledState(isDisabled: boolean): void {\n this.formDisabled.set(isDisabled)\n }\n\n protected openPicker(): void {\n if (this.isDisabled()) {\n return\n }\n this.fileInput()?.nativeElement.click()\n }\n\n protected onFilesSelected(event: Event): void {\n const input = event.target as HTMLInputElement\n this.addFiles(input.files)\n input.value = ''\n }\n\n protected onDragEnter(event: DragEvent): void {\n event.preventDefault()\n if (!this.isDisabled()) {\n this.dragOver.set(true)\n }\n }\n\n protected onDragOver(event: DragEvent): void {\n event.preventDefault()\n }\n\n protected onDragLeave(event: DragEvent): void {\n event.preventDefault()\n this.dragOver.set(false)\n }\n\n protected onDrop(event: DragEvent): void {\n event.preventDefault()\n this.dragOver.set(false)\n if (this.isDisabled()) {\n return\n }\n this.addFiles(event.dataTransfer?.files ?? null)\n }\n\n protected removeFile(file: File): void {\n if (this.isDisabled()) {\n return\n }\n const next = this.files().filter((f) => f !== file)\n this.files.set(next)\n this.onChange(next)\n this.onTouched()\n }\n\n private addFiles(fileList: FileList | null): void {\n if (!fileList || fileList.length === 0) {\n return\n }\n const incoming = Array.from(fileList)\n const maxSizeMb = this.maxSizeMb()\n const accepted: File[] = []\n const rejected: string[] = []\n for (const file of incoming) {\n if (maxSizeMb !== null && file.size > maxSizeMb * 1024 * 1024) {\n rejected.push(this.oversizeMessage()(file.name, maxSizeMb))\n } else {\n accepted.push(file)\n }\n }\n const extra = this.multiple() ? [] : accepted.slice(1)\n for (const file of extra) {\n rejected.push(this.extraFileMessage()(file.name))\n }\n this.rejections.set(rejected)\n if (accepted.length === 0) {\n return\n }\n const next = this.multiple() ? [...this.files(), ...accepted] : accepted.slice(0, 1)\n this.files.set(next)\n this.onChange(next)\n this.onTouched()\n }\n}\n","<div class=\"gbt-file-upload\">\n @if (label()) {\n <span class=\"gbt-file-upload__label\" [id]=\"id() + '-label'\">{{ label() }}</span>\n }\n <button\n type=\"button\"\n class=\"gbt-file-upload__dropzone\"\n [class.gbt-file-upload__dropzone--drag-over]=\"dragOver()\"\n [disabled]=\"isDisabled()\"\n [attr.aria-labelledby]=\"label() ? id() + '-label' : null\"\n [attr.aria-describedby]=\"errorMessage() ? id() + '-error' : null\"\n (click)=\"openPicker()\"\n (dragenter)=\"onDragEnter($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop($event)\"\n >\n <gbt-icon name=\"upload\" class=\"gbt-file-upload__icon\" aria-hidden=\"true\" />\n <span class=\"gbt-file-upload__hint\">{{ dropLabel() }}</span>\n </button>\n <input\n #fileInput\n type=\"file\"\n class=\"gbt-file-upload__input\"\n tabindex=\"-1\"\n aria-hidden=\"true\"\n [multiple]=\"multiple()\"\n [attr.accept]=\"accept() || null\"\n [disabled]=\"isDisabled()\"\n (change)=\"onFilesSelected($event)\"\n />\n @if (rejections().length > 0) {\n <div class=\"gbt-file-upload__rejections\" role=\"alert\">\n <ul>\n @for (message of rejections(); track message) {\n <li>{{ message }}</li>\n }\n </ul>\n </div>\n }\n @if (files().length > 0) {\n <ul class=\"gbt-file-upload__files\">\n @for (file of files(); track file) {\n <li class=\"gbt-file-upload__file\">\n <span class=\"gbt-file-upload__file-name\">{{ file.name }}</span>\n <span class=\"gbt-file-upload__file-size\">{{ formatFileSize(file.size) }}</span>\n <button\n type=\"button\"\n class=\"gbt-file-upload__file-remove\"\n [disabled]=\"isDisabled()\"\n [attr.aria-label]=\"removeLabel()(file.name)\"\n (click)=\"removeFile(file)\"\n >\n <gbt-icon name=\"x\" aria-hidden=\"true\" />\n </button>\n </li>\n }\n </ul>\n }\n @if (errorMessage()) {\n <p [id]=\"id() + '-error'\" class=\"gbt-file-upload__error\" role=\"alert\">{{ errorMessage() }}</p>\n }\n</div>\n"],"mappings":";;;;AAcA,IAAI,SAAS;AAEb,SAAS,eAAe,OAAa;CACnC,IAAI,QAAQ,MACV,OAAO,GAAG,MAAK;CAEjB,IAAI,QAAQ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AA,CAAA;EAAA,CAAA;EAAA,cAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,WAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,aAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,iBAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;EAAA,kBAAA,CAAA;GAAA,MAAA,GAAA;GAAA,MAAA,CAAA;IAAA,UAAA;IAAA,OAAA;IAAA,UAAA;GAAA,CAAA;EAAA,CAAA;CAAA;AAAA,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { DOCUMENT, DestroyRef, inject } from "@angular/core";
|
|
2
|
+
const GAP = 6;
|
|
3
|
+
function floatingPanelAnchor(open, trigger, anchorBottom) {
|
|
4
|
+
if (!open || !trigger) return null;
|
|
5
|
+
const rect = trigger.getBoundingClientRect();
|
|
6
|
+
return {
|
|
7
|
+
rect,
|
|
8
|
+
bottom: (anchorBottom ? anchorBottom(rect) : rect.bottom) + GAP,
|
|
9
|
+
left: rect.left
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function followPageScroll(follow) {
|
|
13
|
+
const view = inject(DOCUMENT).defaultView;
|
|
14
|
+
if (!view) return;
|
|
15
|
+
const listener = () => follow();
|
|
16
|
+
view.addEventListener("scroll", listener, {
|
|
17
|
+
capture: true,
|
|
18
|
+
passive: true
|
|
19
|
+
});
|
|
20
|
+
inject(DestroyRef).onDestroy(() => view.removeEventListener("scroll", listener, { capture: true }));
|
|
21
|
+
}
|
|
22
|
+
export { floatingPanelAnchor, followPageScroll };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=masmarino-gabarit-floating-panel.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"masmarino-gabarit-floating-panel.mjs","names":[],"sources":["../../../projects/gabarit/floating-panel/floating-panel-position.ts"],"sourcesContent":["import { DOCUMENT, DestroyRef, inject } from '@angular/core'\n\nconst GAP = 6\n\nexport interface FloatingPanelAnchor {\n rect: DOMRect\n bottom: number\n left: number\n}\n\n/** Returns `null` (panel closed, or trigger not in the DOM) when the caller should leave `panelStyle` untouched. */\nexport function floatingPanelAnchor(\n open: boolean,\n trigger: HTMLElement | null,\n anchorBottom?: (rect: DOMRect) => number,\n): FloatingPanelAnchor | null {\n if (!open || !trigger) {\n return null\n }\n const rect = trigger.getBoundingClientRect()\n return {\n rect,\n bottom: (anchorBottom ? anchorBottom(rect) : rect.bottom) + GAP,\n left: rect.left,\n }\n}\n\n/**\n * Calls `follow` on every scroll in the page: the window's, and that of any scrolling container — the app shell's\n * `main`, a modal's body — since a panel fixed to the viewport must follow its trigger through all of them. Scroll\n * events don't bubble, so the listener sits on the window's capture phase. Call it in an injection context; it stops\n * with the component.\n */\nexport function followPageScroll(follow: () => void): void {\n const view = inject(DOCUMENT).defaultView\n if (!view) {\n return\n }\n const listener = () => follow()\n view.addEventListener('scroll', listener, { capture: true, passive: true })\n inject(DestroyRef).onDestroy(() =>\n view.removeEventListener('scroll', listener, { capture: true }),\n )\n}\n"],"mappings":";AAEA,MAAM,MAAM;AASZ,SAAgB,oBACd,MACA,SACA,cAAwC;CAExC,IAAI,CAAC,QAAQ,CAAC,SACZ,OAAO;CAET,MAAM,OAAO,QAAQ,sBAAqB;CAC1C,OAAO;EACL;EACA,SAAS,eAAe,aAAa,IAAI,IAAI,KAAK,UAAU;EAC5D,MAAM,KAAK;CACZ;AACH;AAQA,SAAgB,iBAAiB,QAAkB;CACjD,MAAM,OAAO,OAAO,QAAQ,CAAC,CAAC;CAC9B,IAAI,CAAC,MACH;CAEF,MAAM,iBAAiB,OAAM;CAC7B,KAAK,iBAAiB,UAAU,UAAU;EAAE,SAAS;EAAM,SAAS;CAAI,CAAE;CAC1E,OAAO,UAAU,CAAC,CAAC,gBACjB,KAAK,oBAAoB,UAAU,UAAU,EAAE,SAAS,KAAI,CAAE,CAAC;AAEnE"}
|