@cloudfrogger/goodui 0.0.60 → 0.0.62
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 +10 -0
- package/ai/README.md +47 -0
- package/ai/case-studies/index.md +10 -0
- package/ai/case-studies/vpshoster.md +18 -0
- package/ai/case-studies/webmailer.md +21 -0
- package/ai/catalog/README.md +7 -0
- package/ai/catalog/component.schema.json +289 -0
- package/ai/catalog/components/div-goodDetailRow.json +33 -0
- package/ai/catalog/components/form-goodForm.json +84 -0
- package/ai/catalog/components/good-action-bar.json +83 -0
- package/ai/catalog/components/good-action-group.json +143 -0
- package/ai/catalog/components/good-action-menu.json +121 -0
- package/ai/catalog/components/good-alert.json +184 -0
- package/ai/catalog/components/good-app-layout.json +245 -0
- package/ai/catalog/components/good-assistant-body.json +43 -0
- package/ai/catalog/components/good-assistant-footer.json +43 -0
- package/ai/catalog/components/good-assistant-header.json +43 -0
- package/ai/catalog/components/good-assistant-main.json +61 -0
- package/ai/catalog/components/good-assistant-mobile.json +43 -0
- package/ai/catalog/components/good-assistant-panel.json +131 -0
- package/ai/catalog/components/good-avatar-menu-item.json +82 -0
- package/ai/catalog/components/good-avatar-menu.json +83 -0
- package/ai/catalog/components/good-badge.json +180 -0
- package/ai/catalog/components/good-bar-chart.json +118 -0
- package/ai/catalog/components/good-brand-icon.json +71 -0
- package/ai/catalog/components/good-breadcrumbs.json +102 -0
- package/ai/catalog/components/good-button.json +192 -0
- package/ai/catalog/components/good-calendar.json +430 -0
- package/ai/catalog/components/good-card-footer.json +63 -0
- package/ai/catalog/components/good-card-header.json +100 -0
- package/ai/catalog/components/good-card.json +57 -0
- package/ai/catalog/components/good-chart-axis.json +168 -0
- package/ai/catalog/components/good-chart-bar.json +89 -0
- package/ai/catalog/components/good-chart-histogram.json +78 -0
- package/ai/catalog/components/good-chart-line.json +89 -0
- package/ai/catalog/components/good-chart-scatter.json +87 -0
- package/ai/catalog/components/good-checkbox.json +171 -0
- package/ai/catalog/components/good-citation.json +62 -0
- package/ai/catalog/components/good-code-block.json +116 -0
- package/ai/catalog/components/good-color-controls.json +58 -0
- package/ai/catalog/components/good-color-picker.json +141 -0
- package/ai/catalog/components/good-column.json +53 -0
- package/ai/catalog/components/good-columns.json +77 -0
- package/ai/catalog/components/good-date-input.json +386 -0
- package/ai/catalog/components/good-detail-list.json +43 -0
- package/ai/catalog/components/good-dropdown.json +259 -0
- package/ai/catalog/components/good-error-page.json +133 -0
- package/ai/catalog/components/good-error-text.json +43 -0
- package/ai/catalog/components/good-expandable.json +159 -0
- package/ai/catalog/components/good-eyebrow.json +61 -0
- package/ai/catalog/components/good-field-label.json +62 -0
- package/ai/catalog/components/good-form-field.json +67 -0
- package/ai/catalog/components/good-form-row.json +70 -0
- package/ai/catalog/components/good-group.json +150 -0
- package/ai/catalog/components/good-heading-group.json +45 -0
- package/ai/catalog/components/good-heading.json +69 -0
- package/ai/catalog/components/good-hint.json +43 -0
- package/ai/catalog/components/good-histogram.json +103 -0
- package/ai/catalog/components/good-icon.json +97 -0
- package/ai/catalog/components/good-image-input.json +190 -0
- package/ai/catalog/components/good-image-preview.json +97 -0
- package/ai/catalog/components/good-inline-image.json +131 -0
- package/ai/catalog/components/good-input-phone.json +226 -0
- package/ai/catalog/components/good-input.json +350 -0
- package/ai/catalog/components/good-line-chart.json +94 -0
- package/ai/catalog/components/good-link.json +147 -0
- package/ai/catalog/components/good-listbox.json +248 -0
- package/ai/catalog/components/good-main-menu.json +138 -0
- package/ai/catalog/components/good-main-view.json +179 -0
- package/ai/catalog/components/good-map-color-scale.json +163 -0
- package/ai/catalog/components/good-map-overlay.json +136 -0
- package/ai/catalog/components/good-modal-footer.json +63 -0
- package/ai/catalog/components/good-modal-header.json +73 -0
- package/ai/catalog/components/good-modal.json +131 -0
- package/ai/catalog/components/good-month-calendar.json +170 -0
- package/ai/catalog/components/good-notification-host.json +46 -0
- package/ai/catalog/components/good-notifications.json +72 -0
- package/ai/catalog/components/good-number-input.json +180 -0
- package/ai/catalog/components/good-paragraph.json +47 -0
- package/ai/catalog/components/good-pdf-preview.json +153 -0
- package/ai/catalog/components/good-pin-input.json +211 -0
- package/ai/catalog/components/good-progress.json +158 -0
- package/ai/catalog/components/good-prose.json +43 -0
- package/ai/catalog/components/good-radio-group.json +181 -0
- package/ai/catalog/components/good-range-slider.json +285 -0
- package/ai/catalog/components/good-rating.json +160 -0
- package/ai/catalog/components/good-resizable-pane.json +61 -0
- package/ai/catalog/components/good-resizable.json +185 -0
- package/ai/catalog/components/good-rich-text-editor.json +164 -0
- package/ai/catalog/components/good-scatter-chart.json +94 -0
- package/ai/catalog/components/good-search.json +60 -0
- package/ai/catalog/components/good-section.json +43 -0
- package/ai/catalog/components/good-select-country.json +205 -0
- package/ai/catalog/components/good-select-font.json +111 -0
- package/ai/catalog/components/good-select.json +217 -0
- package/ai/catalog/components/good-separator.json +59 -0
- package/ai/catalog/components/good-settings.json +60 -0
- package/ai/catalog/components/good-sidebar-container.json +112 -0
- package/ai/catalog/components/good-sidebar-item.json +210 -0
- package/ai/catalog/components/good-sidebar-menu-container.json +80 -0
- package/ai/catalog/components/good-sidebar-submenu-group.json +98 -0
- package/ai/catalog/components/good-sidebar-submenu-item.json +113 -0
- package/ai/catalog/components/good-signature-pad.json +115 -0
- package/ai/catalog/components/good-sparkline.json +188 -0
- package/ai/catalog/components/good-status-icon.json +425 -0
- package/ai/catalog/components/good-subheading.json +67 -0
- package/ai/catalog/components/good-subnav.json +132 -0
- package/ai/catalog/components/good-summary.json +43 -0
- package/ai/catalog/components/good-switch.json +167 -0
- package/ai/catalog/components/good-tab.json +129 -0
- package/ai/catalog/components/good-table.json +294 -0
- package/ai/catalog/components/good-tabs.json +90 -0
- package/ai/catalog/components/good-textarea.json +194 -0
- package/ai/catalog/components/good-theme-toggle.json +57 -0
- package/ai/catalog/components/good-timeline-section.json +105 -0
- package/ai/catalog/components/good-timeline-step.json +248 -0
- package/ai/catalog/components/good-timeline.json +302 -0
- package/ai/catalog/components/good-topbar-dropdown-item.json +115 -0
- package/ai/catalog/components/good-topbar-dropdown-menu.json +85 -0
- package/ai/catalog/components/good-topbar-menu-container.json +96 -0
- package/ai/catalog/components/good-topbar-menu-item.json +99 -0
- package/ai/catalog/components/good-topbar-submenu.json +77 -0
- package/ai/catalog/components/good-topbar.json +259 -0
- package/ai/catalog/components/good-world-map.json +145 -0
- package/ai/catalog/components/goodCardActions.json +33 -0
- package/ai/catalog/components/goodDropdownFooter.json +33 -0
- package/ai/catalog/components/goodDropdownHeader.json +33 -0
- package/ai/catalog/components/goodExpandableHeader.json +33 -0
- package/ai/catalog/components/ng-template-goodListboxItem.json +33 -0
- package/ai/catalog/components/ng-template-goodTableCell.json +43 -0
- package/ai/catalog/index.json +1484 -0
- package/ai/catalog/index.schema.json +13 -0
- package/ai/examples/angular.json +26 -0
- package/ai/examples/edit-form.html +13 -0
- package/ai/examples/edit-form.ts +18 -0
- package/ai/examples/index.html +1 -0
- package/ai/examples/login.html +11 -0
- package/ai/examples/login.ts +14 -0
- package/ai/examples/main.ts +25 -0
- package/ai/examples/settings.html +10 -0
- package/ai/examples/settings.ts +13 -0
- package/ai/examples/table-view.html +3 -0
- package/ai/examples/table-view.ts +21 -0
- package/ai/examples/tsconfig.json +27 -0
- package/ai/guides/common-mistakes.md +9 -0
- package/ai/guides/component-discovery.md +17 -0
- package/ai/guides/design-tokens.md +10 -0
- package/ai/guides/layout.md +17 -0
- package/ai/guides/page-patterns.md +39 -0
- package/ai/install.mjs +25 -0
- package/ai/manifest.json +6 -0
- package/ai/skill/goodui/SKILL.md +27 -0
- package/angular/projects/goodui/package.json +28 -0
- package/angular/projects/goodui/src/action-bar.css +20 -0
- package/angular/projects/goodui/src/assistant-panel.css +38 -0
- package/angular/projects/goodui/src/calendar.css +161 -0
- package/angular/projects/goodui/src/chart.css +35 -0
- package/angular/projects/goodui/src/color-picker.css +40 -0
- package/angular/projects/goodui/src/error-page.css +24 -0
- package/angular/projects/goodui/src/lib/action-bar.ts +161 -0
- package/angular/projects/goodui/src/lib/action-group.ts +31 -0
- package/angular/projects/goodui/src/lib/action-menu.ts +81 -0
- package/angular/projects/goodui/src/lib/actions.ts +318 -0
- package/angular/projects/goodui/src/lib/alert.ts +60 -0
- package/angular/projects/goodui/src/lib/app-layout.ts +79 -0
- package/angular/projects/goodui/src/lib/assistant-panel.ts +133 -0
- package/angular/projects/goodui/src/lib/badge.ts +47 -0
- package/angular/projects/goodui/src/lib/bar-chart.html +80 -0
- package/angular/projects/goodui/src/lib/bar-chart.ts +233 -0
- package/angular/projects/goodui/src/lib/breadcrumbs.ts +81 -0
- package/angular/projects/goodui/src/lib/button.ts +38 -0
- package/angular/projects/goodui/src/lib/calendar-layout.ts +68 -0
- package/angular/projects/goodui/src/lib/calendar-service.ts +144 -0
- package/angular/projects/goodui/src/lib/calendar-working-hours.ts +65 -0
- package/angular/projects/goodui/src/lib/calendar.html +200 -0
- package/angular/projects/goodui/src/lib/calendar.ts +471 -0
- package/angular/projects/goodui/src/lib/card.ts +64 -0
- package/angular/projects/goodui/src/lib/chart-colors.ts +22 -0
- package/angular/projects/goodui/src/lib/chart-data.ts +269 -0
- package/angular/projects/goodui/src/lib/checkbox.ts +87 -0
- package/angular/projects/goodui/src/lib/code-block.ts +147 -0
- package/angular/projects/goodui/src/lib/color-controls.ts +107 -0
- package/angular/projects/goodui/src/lib/color-picker.ts +142 -0
- package/angular/projects/goodui/src/lib/color-utils.ts +69 -0
- package/angular/projects/goodui/src/lib/country-data.ts +16 -0
- package/angular/projects/goodui/src/lib/date-input.ts +542 -0
- package/angular/projects/goodui/src/lib/dropdown.ts +309 -0
- package/angular/projects/goodui/src/lib/error-page.ts +46 -0
- package/angular/projects/goodui/src/lib/expandable.ts +64 -0
- package/angular/projects/goodui/src/lib/form.ts +12 -0
- package/angular/projects/goodui/src/lib/goodui-config.ts +16 -0
- package/angular/projects/goodui/src/lib/group.ts +45 -0
- package/angular/projects/goodui/src/lib/histogram.html +52 -0
- package/angular/projects/goodui/src/lib/histogram.ts +146 -0
- package/angular/projects/goodui/src/lib/icon.ts +44 -0
- package/angular/projects/goodui/src/lib/image-input.ts +154 -0
- package/angular/projects/goodui/src/lib/image-preview.ts +26 -0
- package/angular/projects/goodui/src/lib/input-phone.ts +305 -0
- package/angular/projects/goodui/src/lib/input.ts +143 -0
- package/angular/projects/goodui/src/lib/line-chart.html +53 -0
- package/angular/projects/goodui/src/lib/line-chart.ts +193 -0
- package/angular/projects/goodui/src/lib/link.ts +46 -0
- package/angular/projects/goodui/src/lib/listbox.ts +254 -0
- package/angular/projects/goodui/src/lib/main-view.ts +39 -0
- package/angular/projects/goodui/src/lib/marker-colors.ts +7 -0
- package/angular/projects/goodui/src/lib/modal.ts +199 -0
- package/angular/projects/goodui/src/lib/models.ts +115 -0
- package/angular/projects/goodui/src/lib/month-calendar.ts +289 -0
- package/angular/projects/goodui/src/lib/notification-center.ts +170 -0
- package/angular/projects/goodui/src/lib/notification-host.ts +86 -0
- package/angular/projects/goodui/src/lib/number-input.ts +180 -0
- package/angular/projects/goodui/src/lib/pdf-preview.ts +242 -0
- package/angular/projects/goodui/src/lib/pdf-worker.generated.ts +2 -0
- package/angular/projects/goodui/src/lib/pin-input.ts +193 -0
- package/angular/projects/goodui/src/lib/progress.ts +93 -0
- package/angular/projects/goodui/src/lib/provide-goodui.ts +15 -0
- package/angular/projects/goodui/src/lib/radio-group.ts +94 -0
- package/angular/projects/goodui/src/lib/range-slider.ts +313 -0
- package/angular/projects/goodui/src/lib/rating.ts +90 -0
- package/angular/projects/goodui/src/lib/required-control.ts +4 -0
- package/angular/projects/goodui/src/lib/resizable.ts +168 -0
- package/angular/projects/goodui/src/lib/rich-text-command.ts +111 -0
- package/angular/projects/goodui/src/lib/rich-text-editor.html +193 -0
- package/angular/projects/goodui/src/lib/rich-text-editor.ts +864 -0
- package/angular/projects/goodui/src/lib/rich-text-sanitize.ts +99 -0
- package/angular/projects/goodui/src/lib/scatter-chart.html +48 -0
- package/angular/projects/goodui/src/lib/scatter-chart.ts +150 -0
- package/angular/projects/goodui/src/lib/select-country.ts +104 -0
- package/angular/projects/goodui/src/lib/select-font.ts +189 -0
- package/angular/projects/goodui/src/lib/select.ts +336 -0
- package/angular/projects/goodui/src/lib/sidebar.ts +232 -0
- package/angular/projects/goodui/src/lib/signature-pad.ts +238 -0
- package/angular/projects/goodui/src/lib/sparkline.html +15 -0
- package/angular/projects/goodui/src/lib/sparkline.ts +106 -0
- package/angular/projects/goodui/src/lib/status-icon.ts +79 -0
- package/angular/projects/goodui/src/lib/subnav.ts +156 -0
- package/angular/projects/goodui/src/lib/switch.ts +54 -0
- package/angular/projects/goodui/src/lib/table.ts +538 -0
- package/angular/projects/goodui/src/lib/tabs.ts +251 -0
- package/angular/projects/goodui/src/lib/textarea.ts +83 -0
- package/angular/projects/goodui/src/lib/theme.ts +49 -0
- package/angular/projects/goodui/src/lib/timeline.ts +252 -0
- package/angular/projects/goodui/src/lib/topbar.ts +402 -0
- package/angular/projects/goodui/src/lib/typography.ts +250 -0
- package/angular/projects/goodui/src/lib/world-map-data.ts +3 -0
- package/angular/projects/goodui/src/lib/world-map.html +73 -0
- package/angular/projects/goodui/src/lib/world-map.ts +391 -0
- package/angular/projects/goodui/src/month-calendar.css +47 -0
- package/angular/projects/goodui/src/pdf-preview.css +25 -0
- package/angular/projects/goodui/src/progress.css +38 -0
- package/angular/projects/goodui/src/public-api.ts +74 -0
- package/angular/projects/goodui/src/range-slider.css +54 -0
- package/angular/projects/goodui/src/resizable.css +32 -0
- package/angular/projects/goodui/src/rich-text-editor.css +33 -0
- package/angular/projects/goodui/src/select-font.css +16 -0
- package/angular/projects/goodui/src/signature-pad.css +14 -0
- package/angular/projects/goodui/src/styles.css +1105 -0
- package/angular/projects/goodui/src/timeline.css +138 -0
- package/angular/projects/goodui/src/tokens.generated.css +754 -0
- package/design/component-map.json +2233 -0
- package/design-tokens/penpot.tokens.json +3339 -0
- package/design.md +452 -0
- package/guides/README.md +17 -0
- package/guides/components/action-bar.md +43 -0
- package/guides/components/action-group.md +43 -0
- package/guides/components/action-menu.md +22 -0
- package/guides/components/alert.md +28 -0
- package/guides/components/assistant-panel.md +50 -0
- package/guides/components/avatar-menu.md +34 -0
- package/guides/components/badge.md +39 -0
- package/guides/components/bar-chart.md +40 -0
- package/guides/components/breadcrumbs.md +37 -0
- package/guides/components/button.md +40 -0
- package/guides/components/calendar.md +166 -0
- package/guides/components/card.md +62 -0
- package/guides/components/chart-axis.md +5 -0
- package/guides/components/chart-bar.md +5 -0
- package/guides/components/chart-data.md +58 -0
- package/guides/components/chart-histogram.md +16 -0
- package/guides/components/chart-line.md +5 -0
- package/guides/components/chart-scatter.md +14 -0
- package/guides/components/checkbox.md +36 -0
- package/guides/components/code-block.md +35 -0
- package/guides/components/color-controls.md +22 -0
- package/guides/components/column.md +5 -0
- package/guides/components/columns.md +13 -0
- package/guides/components/date-input.md +62 -0
- package/guides/components/detail-list.md +25 -0
- package/guides/components/dropdown.md +48 -0
- package/guides/components/error-page.md +31 -0
- package/guides/components/expandable.md +36 -0
- package/guides/components/form.md +49 -0
- package/guides/components/group.md +41 -0
- package/guides/components/histogram.md +45 -0
- package/guides/components/icon.md +13 -0
- package/guides/components/image-input.md +34 -0
- package/guides/components/input-phone.md +45 -0
- package/guides/components/input.md +59 -0
- package/guides/components/line-chart.md +37 -0
- package/guides/components/link.md +31 -0
- package/guides/components/listbox.md +109 -0
- package/guides/components/main-menu.md +11 -0
- package/guides/components/main-view.md +21 -0
- package/guides/components/modal.md +58 -0
- package/guides/components/month-calendar.md +88 -0
- package/guides/components/notifications.md +76 -0
- package/guides/components/number-input.md +21 -0
- package/guides/components/pdf-preview.md +38 -0
- package/guides/components/pin-input.md +37 -0
- package/guides/components/progress.md +41 -0
- package/guides/components/radio-group.md +41 -0
- package/guides/components/range-slider.md +42 -0
- package/guides/components/rating.md +39 -0
- package/guides/components/resizable-pane.md +3 -0
- package/guides/components/resizable.md +75 -0
- package/guides/components/rich-text-editor.md +113 -0
- package/guides/components/scatter-chart.md +43 -0
- package/guides/components/search.md +9 -0
- package/guides/components/select-font.md +16 -0
- package/guides/components/select.md +65 -0
- package/guides/components/settings.md +11 -0
- package/guides/components/sidebar.md +47 -0
- package/guides/components/signature-pad.md +45 -0
- package/guides/components/sparkline.md +31 -0
- package/guides/components/status-icon.md +32 -0
- package/guides/components/submenus.md +30 -0
- package/guides/components/subnav.md +54 -0
- package/guides/components/switch.md +48 -0
- package/guides/components/table.md +256 -0
- package/guides/components/tabs.md +46 -0
- package/guides/components/textarea.md +44 -0
- package/guides/components/theme-toggle.md +33 -0
- package/guides/components/timeline-section.md +7 -0
- package/guides/components/timeline-step.md +12 -0
- package/guides/components/timeline.md +179 -0
- package/guides/components/topbar.md +83 -0
- package/guides/components/typography.md +155 -0
- package/guides/components/world-map.md +72 -0
- package/guides/contributing/design-to-code.md +261 -0
- package/guides/deployment/drone.md +77 -0
- package/guides/examples/user-registration.md +11 -0
- package/guides/foundations/naming.md +7 -0
- package/guides/foundations/tokens.md +203 -0
- package/guides/intro.md +80 -0
- package/guides/layout/app-layout.md +64 -0
- package/guides/layout/layout-rules.md +16 -0
- package/homepage/src/app/examples/calendar-workspace/calendar-workspace-page.html +22 -0
- package/homepage/src/app/examples/calendar-workspace/calendar-workspace-page.ts +111 -0
- package/homepage/src/app/examples/calendar-workspace/source-code.generated.ts +3 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/billing-page.html +166 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/billing-page.ts +134 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/cloudhoster-store.ts +92 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/create-database-page.html +93 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/create-database-page.ts +115 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/database-detail-page.html +202 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/database-detail-page.ts +143 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/databases-page.html +70 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/databases-page.ts +44 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/home-page.html +70 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/home-page.ts +32 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/source-code.generated.ts +12 -0
- package/homepage/src/app/examples/case-studies/vpshoster/create-server-page.html +208 -0
- package/homepage/src/app/examples/case-studies/vpshoster/create-server-page.ts +214 -0
- package/homepage/src/app/examples/case-studies/vpshoster/overview-page.html +35 -0
- package/homepage/src/app/examples/case-studies/vpshoster/overview-page.ts +17 -0
- package/homepage/src/app/examples/case-studies/vpshoster/servers-page.html +111 -0
- package/homepage/src/app/examples/case-studies/vpshoster/servers-page.ts +206 -0
- package/homepage/src/app/examples/case-studies/vpshoster/source-code.generated.ts +6 -0
- package/homepage/src/app/examples/case-studies/vpshoster/vps-store.ts +92 -0
- package/homepage/src/app/examples/case-studies/webmailer/webmailer-page.html +35 -0
- package/homepage/src/app/examples/case-studies/webmailer/webmailer-page.ts +17 -0
- package/homepage/src/app/examples/error-pages/error-pages-example-page.html +27 -0
- package/homepage/src/app/examples/error-pages/error-pages-example-page.ts +34 -0
- package/homepage/src/app/examples/error-pages/not-found-page.html +8 -0
- package/homepage/src/app/examples/error-pages/not-found-page.ts +19 -0
- package/homepage/src/app/examples/error-pages/server-error-page.html +8 -0
- package/homepage/src/app/examples/error-pages/server-error-page.ts +20 -0
- package/homepage/src/app/examples/error-pages/source-code.generated.ts +7 -0
- package/homepage/src/app/examples/mail-compose/mail-compose-page.html +25 -0
- package/homepage/src/app/examples/mail-compose/mail-compose-page.ts +28 -0
- package/homepage/src/app/examples/mail-workspace/mail-workspace-page.html +59 -0
- package/homepage/src/app/examples/mail-workspace/mail-workspace-page.ts +128 -0
- package/homepage/src/app/examples/mail-workspace/source-code.generated.ts +3 -0
- package/homepage/src/app/examples/notifications/notifications-page.html +51 -0
- package/homepage/src/app/examples/notifications/notifications-page.ts +133 -0
- package/homepage/src/app/examples/notifications/source-code.generated.ts +3 -0
- package/homepage/src/app/examples/pdf-reader/pdf-reader-page.html +27 -0
- package/homepage/src/app/examples/pdf-reader/pdf-reader-page.ts +39 -0
- package/homepage/src/app/examples/pdf-reader/source-code.generated.ts +3 -0
- package/homepage/src/app/examples/user-registration/source-code.generated.ts +5 -0
- package/homepage/src/app/examples/user-registration/user-registration-example-page.html +11 -0
- package/homepage/src/app/examples/user-registration/user-registration-example-page.ts +21 -0
- package/homepage/src/app/examples/user-registration/user-registration-form.html +116 -0
- package/homepage/src/app/examples/user-registration/user-registration-form.ts +93 -0
- package/homepage/src/app/examples/user-registration/user-registration-page.html +11 -0
- package/homepage/src/app/examples/user-registration/user-registration-page.ts +23 -0
- package/package.json +2 -2
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, ElementRef, computed, contentChildren, effect, input, signal, viewChild } from '@angular/core';
|
|
2
|
+
import { LucideChartColumn, LucideTable2 } from '@lucide/angular';
|
|
3
|
+
import { GoodButtonComponent } from './button';
|
|
4
|
+
import { GoodCardActionsDirective, GoodCardComponent, GoodCardHeaderComponent } from './card';
|
|
5
|
+
import { resolveChartColor } from './chart-colors';
|
|
6
|
+
import { GoodChartAxisDefinition, GoodChartDataSource, GoodHistogramSeriesDefinition, resolveHistogram } from './chart-data';
|
|
7
|
+
import { GoodChartAxisComponent } from './line-chart';
|
|
8
|
+
import { GoodTableColumn, GoodTableComponent } from './table';
|
|
9
|
+
|
|
10
|
+
@Component({ selector: 'good-chart-histogram', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush,
|
|
11
|
+
host: { style: 'display:none' }, template: '' })
|
|
12
|
+
export class GoodChartHistogramComponent {
|
|
13
|
+
readonly source = input.required<string>();
|
|
14
|
+
readonly valueKey = input.required<string>();
|
|
15
|
+
readonly label = input('');
|
|
16
|
+
readonly color = input('');
|
|
17
|
+
|
|
18
|
+
definition(): GoodHistogramSeriesDefinition {
|
|
19
|
+
return { source: this.source(), valueKey: this.valueKey(), label: this.label(), color: this.color() };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface HistogramBar { id: string; x: number; y: number; width: number; height: number; color: string; title: string }
|
|
24
|
+
|
|
25
|
+
@Component({
|
|
26
|
+
selector: 'good-histogram', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush,
|
|
27
|
+
imports: [GoodButtonComponent, GoodCardComponent, GoodCardHeaderComponent, GoodCardActionsDirective, GoodTableComponent],
|
|
28
|
+
host: { class: 'good-histogram' }, templateUrl: './histogram.html',
|
|
29
|
+
})
|
|
30
|
+
export class GoodHistogramComponent {
|
|
31
|
+
readonly title = input.required<string>();
|
|
32
|
+
readonly ariaLabel = input('');
|
|
33
|
+
readonly sources = input.required<readonly GoodChartDataSource[]>();
|
|
34
|
+
readonly binCount = input(8);
|
|
35
|
+
readonly colors = input<readonly string[]>([]);
|
|
36
|
+
readonly showDataToggle = input(false);
|
|
37
|
+
readonly tableIcon = LucideTable2;
|
|
38
|
+
readonly chartIcon = LucideChartColumn;
|
|
39
|
+
readonly axes = contentChildren(GoodChartAxisComponent);
|
|
40
|
+
readonly seriesDefinitions = contentChildren(GoodChartHistogramComponent);
|
|
41
|
+
readonly plotElement = viewChild<ElementRef<HTMLElement>>('plot');
|
|
42
|
+
readonly dataVisible = signal(false);
|
|
43
|
+
readonly width = signal(700);
|
|
44
|
+
private readonly observePlot = effect(onCleanup => {
|
|
45
|
+
const element = this.plotElement()?.nativeElement;
|
|
46
|
+
if (!element || typeof ResizeObserver === 'undefined') return;
|
|
47
|
+
const observer = new ResizeObserver(entries => this.width.set(Math.max(280, Math.round(entries[0].contentRect.width))));
|
|
48
|
+
observer.observe(element);
|
|
49
|
+
onCleanup(() => observer.disconnect());
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
readonly xAxis = computed<GoodChartAxisDefinition>(() => this.axes().find(axis => axis.position() === 'x')?.definition() ?? { type: 'number' });
|
|
53
|
+
readonly yAxis = computed<GoodChartAxisDefinition>(() => this.axes().find(axis => axis.position() === 'y')?.definition() ?? { type: 'number', label: 'Count' });
|
|
54
|
+
readonly resolved = computed(() => {
|
|
55
|
+
const axis = this.xAxis();
|
|
56
|
+
return resolveHistogram(this.sources(), this.seriesDefinitions().map(series => series.definition()),
|
|
57
|
+
this.binCount(), typeof axis.min === 'number' ? axis.min : null,
|
|
58
|
+
typeof axis.max === 'number' ? axis.max : null);
|
|
59
|
+
});
|
|
60
|
+
readonly errors = computed(() => {
|
|
61
|
+
const errors = [...this.resolved().errors];
|
|
62
|
+
if (this.xAxis().type !== 'number') errors.push('Histogram: the X axis must be number.');
|
|
63
|
+
if (this.yAxis().type !== 'number') errors.push('Histogram: the Y axis must be number.');
|
|
64
|
+
if (this.xAxis().min != null && typeof this.xAxis().min !== 'number') errors.push('Histogram: X minimum must be numeric.');
|
|
65
|
+
if (this.xAxis().max != null && typeof this.xAxis().max !== 'number') errors.push('Histogram: X maximum must be numeric.');
|
|
66
|
+
if (this.yAxis().min != null && this.yAxis().min !== 0) errors.push('Histogram: Y minimum must be zero.');
|
|
67
|
+
const yMax = this.yAxis().max;
|
|
68
|
+
if (yMax != null && (typeof yMax !== 'number' || !Number.isInteger(yMax) || yMax <= 0))
|
|
69
|
+
errors.push('Histogram: Y maximum must be a positive integer.');
|
|
70
|
+
return errors;
|
|
71
|
+
});
|
|
72
|
+
readonly height = 300;
|
|
73
|
+
readonly left = 55;
|
|
74
|
+
readonly top = 16;
|
|
75
|
+
readonly bottom = 47;
|
|
76
|
+
readonly right = 18;
|
|
77
|
+
readonly plotWidth = computed(() => Math.max(100, this.width() - this.left - this.right));
|
|
78
|
+
readonly plotHeight = this.height - this.top - this.bottom;
|
|
79
|
+
readonly yMax = computed(() => {
|
|
80
|
+
const largest = Math.max(0, ...this.resolved().bins.flatMap(bin => bin.counts));
|
|
81
|
+
const requested = this.yAxis().max;
|
|
82
|
+
if (typeof requested === 'number' && Number.isInteger(requested) && requested > 0) return requested;
|
|
83
|
+
const target = Math.max(2, Math.min(10, Math.round(this.yAxis().ticks ?? 5)));
|
|
84
|
+
const step = largest <= 9 ? 1 : Math.ceil(largest / (target - 1));
|
|
85
|
+
return Math.max(1, Math.ceil(largest / step) * step);
|
|
86
|
+
});
|
|
87
|
+
readonly yTicks = computed(() => {
|
|
88
|
+
const target = Math.max(2, Math.min(10, Math.round(this.yAxis().ticks ?? 5)));
|
|
89
|
+
const step = this.yMax() <= 9 ? 1 : Math.max(1, Math.ceil(this.yMax() / (target - 1)));
|
|
90
|
+
const ticks = [];
|
|
91
|
+
for (let value = 0; value <= this.yMax(); value += step) {
|
|
92
|
+
ticks.push({ y: this.yPosition(value), label: this.format(value, 0) });
|
|
93
|
+
}
|
|
94
|
+
return ticks;
|
|
95
|
+
});
|
|
96
|
+
readonly xTicks = computed(() => {
|
|
97
|
+
const bins = this.resolved().bins;
|
|
98
|
+
if (!bins.length) return [];
|
|
99
|
+
const every = Math.max(1, Math.ceil(bins.length / Math.max(2, Math.floor(this.plotWidth() / 55))));
|
|
100
|
+
return Array.from({ length: bins.length + 1 }, (_, index) => ({
|
|
101
|
+
x: this.left + index * this.plotWidth() / bins.length,
|
|
102
|
+
label: this.format(index === bins.length ? bins.at(-1)!.end : bins[index].start, this.xAxis().precision),
|
|
103
|
+
visible: index % every === 0 || index === bins.length,
|
|
104
|
+
}));
|
|
105
|
+
});
|
|
106
|
+
readonly binPrecision = computed(() => {
|
|
107
|
+
const values = this.resolved().bins.flatMap(bin => [bin.start, bin.end]);
|
|
108
|
+
for (let digits = 0; digits <= 6; digits++) {
|
|
109
|
+
const factor = 10 ** digits;
|
|
110
|
+
if (values.every(value => Math.abs(value * factor - Math.round(value * factor)) < 1e-7)) return digits;
|
|
111
|
+
}
|
|
112
|
+
return 6;
|
|
113
|
+
});
|
|
114
|
+
readonly bars = computed<readonly HistogramBar[]>(() => {
|
|
115
|
+
const bins = this.resolved().bins;
|
|
116
|
+
const series = this.resolved().series;
|
|
117
|
+
const binWidth = this.plotWidth() / Math.max(1, bins.length);
|
|
118
|
+
const barWidth = binWidth / Math.max(1, series.length);
|
|
119
|
+
return bins.flatMap((bin, binIndex) => bin.counts.map((count, seriesIndex) => {
|
|
120
|
+
const y = this.yPosition(Math.min(this.yMax(), count));
|
|
121
|
+
return { id: `${binIndex}:${seriesIndex}`, x: this.left + binIndex * binWidth + seriesIndex * barWidth,
|
|
122
|
+
y, width: barWidth, height: this.top + this.plotHeight - y,
|
|
123
|
+
color: resolveChartColor(series[seriesIndex].color, this.colors(), seriesIndex),
|
|
124
|
+
title: `${series[seriesIndex].label}, ${this.rangeLabel(bin.start, bin.end)}: ${count}` };
|
|
125
|
+
}));
|
|
126
|
+
});
|
|
127
|
+
readonly legend = computed(() => this.resolved().series.map((series, index) => ({
|
|
128
|
+
id: series.id, label: series.label, color: resolveChartColor(series.color, this.colors(), index),
|
|
129
|
+
})));
|
|
130
|
+
readonly tableRows = computed(() => this.resolved().bins.map(bin => {
|
|
131
|
+
const row: Record<string, string | number> = { range: this.rangeLabel(bin.start, bin.end) };
|
|
132
|
+
bin.counts.forEach((count, index) => row[`series${index}`] = count);
|
|
133
|
+
return row;
|
|
134
|
+
}));
|
|
135
|
+
readonly tableColumns = computed<GoodTableColumn<Record<string, string | number>>[]>(() => [
|
|
136
|
+
{ accessorKey: 'range', header: this.xAxis().label || 'Range' },
|
|
137
|
+
...this.resolved().series.map((series, index) => ({ accessorKey: `series${index}`, header: series.label, meta: { align: 'end' as const } })),
|
|
138
|
+
]);
|
|
139
|
+
|
|
140
|
+
yPosition(count: number): number { return this.top + (this.yMax() - count) * this.plotHeight / this.yMax(); }
|
|
141
|
+
rangeLabel(start: number, end: number): string { return `${this.format(start, this.binPrecision())}–${this.format(end, this.binPrecision())}`; }
|
|
142
|
+
format(value: number, precision: number | undefined): string {
|
|
143
|
+
const digits = precision == null ? (Number.isInteger(value) ? 0 : 1) : Math.max(0, Math.min(6, Math.round(precision)));
|
|
144
|
+
return new Intl.NumberFormat('en-US', { maximumFractionDigits: digits, minimumFractionDigits: digits }).format(value);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input } from '@angular/core';
|
|
2
|
+
import { GoodIconName } from './models';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'good-icon',
|
|
6
|
+
standalone: true,
|
|
7
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
8
|
+
template: `
|
|
9
|
+
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8"
|
|
10
|
+
stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">
|
|
11
|
+
@switch (name()) {
|
|
12
|
+
@case ('dashboard') { <rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/> }
|
|
13
|
+
@case ('grid') { <rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><rect x="14" y="14" width="7" height="7" rx="1"/> }
|
|
14
|
+
@case ('account') { <circle cx="12" cy="8" r="4"/><path d="M4 21a8 8 0 0 1 16 0"/> }
|
|
15
|
+
@case ('network') { <circle cx="12" cy="4" r="2"/><circle cx="5" cy="19" r="2"/><circle cx="19" cy="19" r="2"/><path d="m11 6-5 11m7-11 5 11M7 19h10"/> }
|
|
16
|
+
@case ('home') { <path d="m3 10 9-7 9 7v11H3z"/><path d="M9 21v-7h6v7"/> }
|
|
17
|
+
@case ('settings') { <circle cx="12" cy="12" r="3"/><path d="M12 2v2m0 16v2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42M2 12h2m16 0h2M4.93 19.07l1.42-1.42m11.3-11.3 1.42-1.42"/> }
|
|
18
|
+
@case ('search') { <circle cx="11" cy="11" r="7"/><path d="m20 20-4-4"/> }
|
|
19
|
+
@case ('bell') { <path d="M18 8a6 6 0 0 0-12 0c0 7-3 7-3 9h18c0-2-3-2-3-9ZM10 21h4"/> }
|
|
20
|
+
@case ('menu') { <path d="M4 6h16M4 12h16M4 18h16"/> }
|
|
21
|
+
@case ('close') { <path d="M5 5l14 14M19 5 5 19"/> }
|
|
22
|
+
@case ('chevron-down') { <path d="m6 9 6 6 6-6"/> }
|
|
23
|
+
@case ('chevron-right') { <path d="m9 6 6 6-6 6"/> }
|
|
24
|
+
@case ('sun') { <circle cx="12" cy="12" r="4"/><path d="M12 2v2m0 16v2M4.93 4.93l1.42 1.42m11.3 11.3 1.42 1.42M2 12h2m16 0h2M4.93 19.07l1.42-1.42m11.3-11.3 1.42-1.42"/> }
|
|
25
|
+
@case ('moon') { <path d="M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401"/> }
|
|
26
|
+
@case ('monitor') { <rect x="3" y="4" width="18" height="14" rx="2"/><path d="M8 22h8m-4-4v4"/> }
|
|
27
|
+
@case ('logout') { <path d="M10 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h5M16 17l5-5-5-5m5 5H9"/> }
|
|
28
|
+
@case ('calendar') { <rect x="3" y="5" width="18" height="16" rx="2"/><path d="M7 3v4M17 3v4M3 10h18"/> }
|
|
29
|
+
@case ('question') { <circle cx="12" cy="12" r="9"/><path d="M9.6 9a2.5 2.5 0 0 1 4.8 1c0 1.8-2.4 2-2.4 3.5M12 17h.01"/> }
|
|
30
|
+
@case ('card') { <rect x="3" y="5" width="18" height="14" rx="3"/><path d="M3 10h18M7 15h4"/> }
|
|
31
|
+
@case ('book') { <rect x="4" y="3" width="16" height="18" rx="2"/><path d="M8 8h8M8 12h8M8 16h5"/> }
|
|
32
|
+
@case ('contact') { <circle cx="12" cy="5" r="2"/><circle cx="5" cy="17" r="2"/><circle cx="19" cy="17" r="2"/><path d="m10.5 6.6-4 8M13.5 6.6l4 8M7 17h10"/> }
|
|
33
|
+
@case ('star') { <path d="m12 2 3.1 6.4 7 .9-5.1 5 .9 7-5.9-3.2-5.9 3.2.9-7-5.1-5 7-.9z"/> }
|
|
34
|
+
@case ('check') { <rect x="3" y="3" width="18" height="18" rx="4"/><path d="m7 12 3 3 7-7"/> }
|
|
35
|
+
@case ('message') { <path d="M5 4h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 4V6a2 2 0 0 1 1-2Z"/><path d="M10 9a2 2 0 0 1 4 1c0 1-2 1.5-2 2.5M12 15h.01"/> }
|
|
36
|
+
@case ('globe') { <circle cx="12" cy="12" r="9"/><path d="M3 12h18M12 3c3 3 4 6 4 9s-1 6-4 9M12 3c-3 3-4 6-4 9s1 6 4 9"/> }
|
|
37
|
+
}
|
|
38
|
+
</svg>
|
|
39
|
+
`,
|
|
40
|
+
host: { class: 'good-icon' },
|
|
41
|
+
})
|
|
42
|
+
export class GoodIconComponent {
|
|
43
|
+
readonly name = input.required<GoodIconName>();
|
|
44
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, computed, effect, forwardRef, inject, input, output, signal, viewChild } from '@angular/core';
|
|
2
|
+
import { AbstractControl, ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator } from '@angular/forms';
|
|
3
|
+
import { LucideDynamicIcon, LucideImage, LucideX } from '@lucide/angular';
|
|
4
|
+
import { GoodButtonComponent } from './button';
|
|
5
|
+
import { GoodImagePreviewComponent } from './image-preview';
|
|
6
|
+
|
|
7
|
+
export type GoodImageInputShape = 'square' | 'circle';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'good-image-input',
|
|
11
|
+
standalone: true,
|
|
12
|
+
imports: [LucideDynamicIcon, GoodButtonComponent, GoodImagePreviewComponent],
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
host: { class: 'good-image-input', '[attr.data-shape]': 'shape()', '[attr.data-disabled]': 'isDisabled()', '[attr.data-error]': 'error()' },
|
|
15
|
+
providers: [
|
|
16
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodImageInputComponent), multi: true },
|
|
17
|
+
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => GoodImageInputComponent), multi: true },
|
|
18
|
+
],
|
|
19
|
+
template: `
|
|
20
|
+
<div class="good-image-input-frame">
|
|
21
|
+
@if (imageUrl(); as image) {
|
|
22
|
+
@if (previewable() && !isDisabled()) {
|
|
23
|
+
<button type="button" class="good-image-input-preview" [attr.aria-label]="'Preview ' + label()"
|
|
24
|
+
(click)="previewOpen.set(true)">
|
|
25
|
+
<img [src]="image" alt="" />
|
|
26
|
+
</button>
|
|
27
|
+
} @else if (!isDisabled()) {
|
|
28
|
+
<button type="button" class="good-image-input-preview good-image-input-replace" [attr.aria-label]="'Change ' + label()"
|
|
29
|
+
(click)="openPicker()">
|
|
30
|
+
<img [src]="image" alt="" />
|
|
31
|
+
</button>
|
|
32
|
+
} @else {
|
|
33
|
+
<img class="good-image-input-image" [src]="image" [alt]="alt() || label()" />
|
|
34
|
+
}
|
|
35
|
+
} @else {
|
|
36
|
+
<button type="button" class="good-image-input-empty" [disabled]="isDisabled()" [attr.aria-label]="'Choose ' + label()"
|
|
37
|
+
(click)="openPicker()">
|
|
38
|
+
<svg [lucideIcon]="placeholderIcon" [size]="32" aria-hidden="true"></svg>
|
|
39
|
+
<span>No image selected</span>
|
|
40
|
+
</button>
|
|
41
|
+
}
|
|
42
|
+
@if (imageUrl() && showRemoveButton() && !isDisabled()) {
|
|
43
|
+
<good-button class="good-image-input-remove" variant="secondary" size="small" [icon]="removeIcon"
|
|
44
|
+
[iconOnly]="true" [ariaLabel]="'Remove ' + label()" (click)="removeImage()" />
|
|
45
|
+
}
|
|
46
|
+
</div>
|
|
47
|
+
@if (caption() && imageUrl()) { <p class="good-image-input-caption">{{ caption() }}</p> }
|
|
48
|
+
@if (showUploadButton()) {
|
|
49
|
+
<good-button variant="secondary" size="small" [disabled]="isDisabled()" (click)="openPicker()">Upload new picture</good-button>
|
|
50
|
+
}
|
|
51
|
+
<input #fileInput class="good-sr-only" type="file" accept="image/*" tabindex="-1" [id]="inputId() || null" [name]="name()"
|
|
52
|
+
[disabled]="isDisabled()" [required]="effectiveRequired() && !imageUrl()" [attr.aria-label]="label()"
|
|
53
|
+
[attr.aria-invalid]="error() ? 'true' : null" [attr.aria-describedby]="describedBy() || null"
|
|
54
|
+
(change)="onFileChange($event)" (blur)="onTouched()" />
|
|
55
|
+
@if (previewable() && imageUrl()) {
|
|
56
|
+
<good-image-preview [(open)]="previewOpen" [src]="imageUrl()" [alt]="alt() || label()" [caption]="caption()" />
|
|
57
|
+
}
|
|
58
|
+
`,
|
|
59
|
+
})
|
|
60
|
+
export class GoodImageInputComponent implements ControlValueAccessor, Validator {
|
|
61
|
+
readonly shape = input<GoodImageInputShape>('square');
|
|
62
|
+
readonly src = input('');
|
|
63
|
+
readonly alt = input('');
|
|
64
|
+
readonly caption = input('');
|
|
65
|
+
readonly label = input('Image');
|
|
66
|
+
readonly inputId = input('');
|
|
67
|
+
readonly name = input('');
|
|
68
|
+
readonly describedBy = input('');
|
|
69
|
+
readonly disabled = input(false);
|
|
70
|
+
readonly error = input(false);
|
|
71
|
+
readonly required = input(false);
|
|
72
|
+
readonly showUploadButton = input(true);
|
|
73
|
+
readonly showRemoveButton = input(true);
|
|
74
|
+
readonly previewable = input(false);
|
|
75
|
+
readonly selected = output<File>();
|
|
76
|
+
readonly removed = output<void>();
|
|
77
|
+
readonly placeholderIcon = LucideImage;
|
|
78
|
+
readonly removeIcon = LucideX;
|
|
79
|
+
readonly previewOpen = signal(false);
|
|
80
|
+
readonly fieldRequired = signal(false);
|
|
81
|
+
readonly effectiveRequired = computed(() => this.required() || this.fieldRequired());
|
|
82
|
+
private readonly formDisabled = signal(false);
|
|
83
|
+
readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
84
|
+
private readonly objectUrl = signal('');
|
|
85
|
+
private readonly sourceRemoved = signal(false);
|
|
86
|
+
private previousSrc = '';
|
|
87
|
+
readonly imageUrl = computed(() => this.objectUrl() || (this.sourceRemoved() ? '' : this.src()));
|
|
88
|
+
private readonly fileInput = viewChild<ElementRef<HTMLInputElement>>('fileInput');
|
|
89
|
+
private onChange: (file: File | null) => void = () => {};
|
|
90
|
+
onTouched: () => void = () => {};
|
|
91
|
+
private onValidatorChange: () => void = () => {};
|
|
92
|
+
|
|
93
|
+
constructor() {
|
|
94
|
+
effect(() => { this.effectiveRequired(); this.isDisabled(); this.imageUrl(); this.onValidatorChange(); });
|
|
95
|
+
effect(() => {
|
|
96
|
+
const next = this.src();
|
|
97
|
+
if (next !== this.previousSrc) {
|
|
98
|
+
this.previousSrc = next;
|
|
99
|
+
this.sourceRemoved.set(false);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
inject(DestroyRef).onDestroy(() => this.releaseObjectUrl());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
setFieldRequired(required: boolean): void { this.fieldRequired.set(required); }
|
|
106
|
+
validate(_control: AbstractControl): ValidationErrors | null {
|
|
107
|
+
return this.effectiveRequired() && !this.isDisabled() && !this.imageUrl() ? { required: true } : null;
|
|
108
|
+
}
|
|
109
|
+
registerOnValidatorChange(fn: () => void): void { this.onValidatorChange = fn; }
|
|
110
|
+
registerOnChange(fn: (file: File | null) => void): void { this.onChange = fn; }
|
|
111
|
+
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
|
|
112
|
+
setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); }
|
|
113
|
+
|
|
114
|
+
writeValue(file: File | null): void {
|
|
115
|
+
this.releaseObjectUrl();
|
|
116
|
+
if (file instanceof File) this.objectUrl.set(URL.createObjectURL(file));
|
|
117
|
+
else this.sourceRemoved.set(false);
|
|
118
|
+
if (!file && this.fileInput()) this.fileInput()!.nativeElement.value = '';
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
openPicker(): void {
|
|
122
|
+
if (this.isDisabled()) return;
|
|
123
|
+
this.fileInput()?.nativeElement.click();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
onFileChange(event: Event): void {
|
|
127
|
+
const file = (event.target as HTMLInputElement).files?.[0];
|
|
128
|
+
if (!file) return;
|
|
129
|
+
if (!file.type.startsWith('image/')) { (event.target as HTMLInputElement).value = ''; return; }
|
|
130
|
+
this.releaseObjectUrl();
|
|
131
|
+
this.objectUrl.set(URL.createObjectURL(file));
|
|
132
|
+
this.sourceRemoved.set(false);
|
|
133
|
+
this.onChange(file);
|
|
134
|
+
this.onTouched();
|
|
135
|
+
this.selected.emit(file);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
removeImage(): void {
|
|
139
|
+
if (this.isDisabled()) return;
|
|
140
|
+
this.previewOpen.set(false);
|
|
141
|
+
this.releaseObjectUrl();
|
|
142
|
+
this.sourceRemoved.set(true);
|
|
143
|
+
if (this.fileInput()) this.fileInput()!.nativeElement.value = '';
|
|
144
|
+
this.onChange(null);
|
|
145
|
+
this.onTouched();
|
|
146
|
+
this.removed.emit();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
private releaseObjectUrl(): void {
|
|
150
|
+
const url = this.objectUrl();
|
|
151
|
+
if (url) URL.revokeObjectURL(url);
|
|
152
|
+
this.objectUrl.set('');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, input, model } from '@angular/core';
|
|
2
|
+
import { GoodModalComponent, GoodModalHeaderComponent } from './modal';
|
|
3
|
+
|
|
4
|
+
@Component({
|
|
5
|
+
selector: 'good-image-preview',
|
|
6
|
+
standalone: true,
|
|
7
|
+
imports: [GoodModalComponent, GoodModalHeaderComponent],
|
|
8
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
9
|
+
host: { class: 'good-image-preview' },
|
|
10
|
+
template: `
|
|
11
|
+
<good-modal [(open)]="open" presentation="overlay" [scrollBody]="true">
|
|
12
|
+
<good-modal-header [title]="title()" />
|
|
13
|
+
<figure class="good-image-preview-figure">
|
|
14
|
+
<img [src]="src()" [alt]="alt()" />
|
|
15
|
+
@if (caption()) { <figcaption>{{ caption() }}</figcaption> }
|
|
16
|
+
</figure>
|
|
17
|
+
</good-modal>
|
|
18
|
+
`,
|
|
19
|
+
})
|
|
20
|
+
export class GoodImagePreviewComponent {
|
|
21
|
+
readonly open = model(false);
|
|
22
|
+
readonly src = input.required<string>();
|
|
23
|
+
readonly alt = input.required<string>();
|
|
24
|
+
readonly caption = input('');
|
|
25
|
+
readonly title = input('Image preview');
|
|
26
|
+
}
|