@cloudfrogger/goodui 0.0.59 → 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,336 @@
|
|
|
1
|
+
import { DOCUMENT, isPlatformBrowser } from '@angular/common';
|
|
2
|
+
import { AbstractControl, ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator } from '@angular/forms';
|
|
3
|
+
import {
|
|
4
|
+
ChangeDetectionStrategy, Component, ElementRef, HostListener, OnDestroy, PLATFORM_ID,
|
|
5
|
+
computed, effect, forwardRef, inject, input, model, output, signal, viewChild,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
import { LucideCheck, LucideChevronDown, LucideDynamicIcon, LucideSearch } from '@lucide/angular';
|
|
8
|
+
import { GoodBadgeComponent } from './badge';
|
|
9
|
+
import { GoodButtonIcon, GoodButtonSize } from './models';
|
|
10
|
+
|
|
11
|
+
export interface GoodSelectOption {
|
|
12
|
+
value: string;
|
|
13
|
+
label: string;
|
|
14
|
+
/** Compact text in the closed trigger; the full label remains the accessible name. */
|
|
15
|
+
triggerLabel?: string;
|
|
16
|
+
description?: string;
|
|
17
|
+
icon?: GoodButtonIcon;
|
|
18
|
+
iconSrc?: string;
|
|
19
|
+
tags?: readonly string[];
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type GoodSelectValue = string | readonly string[] | null;
|
|
24
|
+
|
|
25
|
+
let nextSelectId = 0;
|
|
26
|
+
|
|
27
|
+
@Component({
|
|
28
|
+
selector: 'good-select',
|
|
29
|
+
standalone: true,
|
|
30
|
+
imports: [GoodBadgeComponent, LucideDynamicIcon],
|
|
31
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
32
|
+
providers: [
|
|
33
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodSelectComponent), multi: true },
|
|
34
|
+
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => GoodSelectComponent), multi: true },
|
|
35
|
+
],
|
|
36
|
+
host: { class: 'good-select', '(focusout)': 'onFocusOut($event)' },
|
|
37
|
+
template: `
|
|
38
|
+
@if (showLabel()) {
|
|
39
|
+
<label class="good-select-label" [for]="triggerId">{{ label() }}
|
|
40
|
+
@if (required()) { <span class="good-required-mark" aria-hidden="true">*</span><span class="good-sr-only"> required</span> }
|
|
41
|
+
</label>
|
|
42
|
+
}
|
|
43
|
+
<div class="good-select-control" [attr.data-size]="size()" [attr.data-disabled]="isDisabled()"
|
|
44
|
+
[attr.data-open]="open()" [attr.data-invalid]="error()">
|
|
45
|
+
@if (multiple()) {
|
|
46
|
+
@for (option of selectedOptions(); track option.value) {
|
|
47
|
+
<good-badge class="good-select-chip" [label]="option.label" [icon]="option.icon" [iconSrc]="option.iconSrc"
|
|
48
|
+
color="secondary" variant="light" [size]="size() === 'large' ? 'default' : 'small'"
|
|
49
|
+
[removable]="!isDisabled() && !option.disabled" [removeLabel]="'Remove ' + option.label"
|
|
50
|
+
(removed)="remove(option.value)" />
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
<button #trigger class="good-select-trigger" type="button" role="combobox" [id]="triggerId"
|
|
54
|
+
aria-haspopup="listbox" [attr.aria-controls]="open() ? listId : null" [attr.aria-expanded]="open()"
|
|
55
|
+
[attr.aria-label]="triggerLabel()" [attr.aria-required]="required() ? 'true' : null"
|
|
56
|
+
[attr.aria-invalid]="error() ? 'true' : null" [attr.aria-describedby]="describedBy() || null"
|
|
57
|
+
[disabled]="isDisabled()" (click)="toggle()" (keydown)="onKeydown($event)">
|
|
58
|
+
@if (!multiple() && selectedOptions()[0]; as selected) {
|
|
59
|
+
@if (selected.icon; as icon) { <svg class="good-select-trigger-icon" [lucideIcon]="icon" [size]="iconSize()" aria-hidden="true"></svg> }
|
|
60
|
+
@else if (selected.iconSrc; as source) { <img class="good-select-option-image" [src]="source" alt="" /> }
|
|
61
|
+
<span class="good-select-trigger-text">{{ selected.triggerLabel ?? selected.label }}</span>
|
|
62
|
+
} @else if (!multiple() || !selectedOptions().length) {
|
|
63
|
+
<span class="good-select-placeholder">{{ placeholder() }}</span>
|
|
64
|
+
} @else {
|
|
65
|
+
<span class="good-select-add-more">Add more</span>
|
|
66
|
+
}
|
|
67
|
+
<svg class="good-select-chevron" [lucideIcon]="chevronIcon" [size]="iconSize()" aria-hidden="true"></svg>
|
|
68
|
+
</button>
|
|
69
|
+
</div>
|
|
70
|
+
@if (open()) {
|
|
71
|
+
<div #panel class="good-select-popup" [id]="popupId"
|
|
72
|
+
[style.left.px]="position().left" [style.top.px]="position().top"
|
|
73
|
+
[style.width.px]="position().width" [style.max-height.px]="position().maxHeight"
|
|
74
|
+
[style.visibility]="positionReady() ? 'visible' : 'hidden'">
|
|
75
|
+
@if (searchable()) {
|
|
76
|
+
<div class="good-select-search">
|
|
77
|
+
<svg [lucideIcon]="searchIcon" [size]="16" aria-hidden="true"></svg>
|
|
78
|
+
<input #searchInput type="search" [value]="query()" [placeholder]="searchPlaceholder()"
|
|
79
|
+
[attr.aria-label]="'Search ' + label()" [attr.aria-controls]="listId"
|
|
80
|
+
[attr.aria-activedescendant]="activeOptionId()"
|
|
81
|
+
(input)="onSearch($event)" (keydown)="onKeydown($event)" />
|
|
82
|
+
</div>
|
|
83
|
+
}
|
|
84
|
+
<div #list class="good-select-list" role="listbox" [id]="listId" [attr.aria-label]="label()"
|
|
85
|
+
[attr.aria-multiselectable]="multiple() ? 'true' : null"
|
|
86
|
+
[attr.aria-activedescendant]="activeOptionId()" tabindex="0"
|
|
87
|
+
(keydown)="onKeydown($event)">
|
|
88
|
+
@for (option of filteredOptions(); track option.value; let index = $index) {
|
|
89
|
+
<div class="good-select-option" role="option" [id]="optionId(index)"
|
|
90
|
+
[attr.aria-selected]="isSelected(option.value)" [attr.aria-disabled]="isOptionDisabled(option)"
|
|
91
|
+
[attr.data-active]="activeIndex() === index" [attr.data-selected]="isSelected(option.value)"
|
|
92
|
+
(pointerenter)="activeIndex.set(index)" (click)="choose(option)">
|
|
93
|
+
@if (option.icon; as icon) { <svg class="good-select-option-icon" [lucideIcon]="icon" [size]="optionIconSize()" aria-hidden="true"></svg> }
|
|
94
|
+
@else if (option.iconSrc; as source) { <img class="good-select-option-image" [src]="source" alt="" /> }
|
|
95
|
+
<span class="good-select-option-copy">
|
|
96
|
+
<span class="good-select-option-label">{{ option.label }}</span>
|
|
97
|
+
@if (option.description) { <span class="good-select-option-description">{{ option.description }}</span> }
|
|
98
|
+
</span>
|
|
99
|
+
@if (option.tags?.length) {
|
|
100
|
+
<span class="good-select-option-tags" aria-hidden="true">
|
|
101
|
+
@for (tag of option.tags; track tag) { <span class="good-select-option-tag">{{ tag }}</span> }
|
|
102
|
+
</span>
|
|
103
|
+
}
|
|
104
|
+
@if (isSelected(option.value)) { <svg class="good-select-check" [lucideIcon]="checkIcon" [size]="16" aria-hidden="true"></svg> }
|
|
105
|
+
</div>
|
|
106
|
+
} @empty { <div class="good-select-empty" role="status">{{ emptyMessage() }}</div> }
|
|
107
|
+
</div>
|
|
108
|
+
@if (multiple() && maxSelected() !== null) {
|
|
109
|
+
<div class="good-select-limit" role="status">{{ selectedValues().length }} / {{ maxSelected() }} selected</div>
|
|
110
|
+
}
|
|
111
|
+
</div>
|
|
112
|
+
}
|
|
113
|
+
`,
|
|
114
|
+
})
|
|
115
|
+
export class GoodSelectComponent implements ControlValueAccessor, Validator, OnDestroy {
|
|
116
|
+
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
|
117
|
+
private readonly document = inject(DOCUMENT);
|
|
118
|
+
private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
119
|
+
private readonly trigger = viewChild<ElementRef<HTMLButtonElement>>('trigger');
|
|
120
|
+
private readonly panel = viewChild<ElementRef<HTMLElement>>('panel');
|
|
121
|
+
private readonly list = viewChild<ElementRef<HTMLElement>>('list');
|
|
122
|
+
private readonly searchInput = viewChild<ElementRef<HTMLInputElement>>('searchInput');
|
|
123
|
+
private readonly formDisabled = signal(false);
|
|
124
|
+
private onChange: (value: GoodSelectValue) => void = () => {};
|
|
125
|
+
private onTouched: () => void = () => {};
|
|
126
|
+
private onValidatorChange: () => void = () => {};
|
|
127
|
+
readonly options = input<readonly GoodSelectOption[]>([]);
|
|
128
|
+
readonly value = model<GoodSelectValue>(null);
|
|
129
|
+
readonly multiple = input(false);
|
|
130
|
+
readonly maxSelected = input<number | null>(null);
|
|
131
|
+
readonly size = input<GoodButtonSize>('default');
|
|
132
|
+
readonly disabled = input(false);
|
|
133
|
+
readonly required = input(false);
|
|
134
|
+
readonly error = input(false);
|
|
135
|
+
readonly label = input('Select');
|
|
136
|
+
readonly showLabel = input(false);
|
|
137
|
+
readonly placeholder = input('Select an option');
|
|
138
|
+
readonly searchable = input(false);
|
|
139
|
+
readonly searchPlaceholder = input('Search options');
|
|
140
|
+
readonly emptyMessage = input('No options found');
|
|
141
|
+
readonly describedBy = input('');
|
|
142
|
+
readonly selectionChange = output<GoodSelectValue>();
|
|
143
|
+
readonly open = signal(false);
|
|
144
|
+
readonly query = signal('');
|
|
145
|
+
readonly activeIndex = signal(-1);
|
|
146
|
+
readonly position = signal({ left: 0, top: 0, width: 240, maxHeight: 320 });
|
|
147
|
+
readonly positionReady = signal(false);
|
|
148
|
+
readonly listId = `good-select-${++nextSelectId}-list`;
|
|
149
|
+
readonly popupId = `${this.listId}-popup`;
|
|
150
|
+
readonly triggerId = `${this.listId}-trigger`;
|
|
151
|
+
readonly chevronIcon = LucideChevronDown;
|
|
152
|
+
readonly checkIcon = LucideCheck;
|
|
153
|
+
readonly searchIcon = LucideSearch;
|
|
154
|
+
readonly iconSize = computed(() => ({ small: 14, default: 16, large: 20 })[this.size()]);
|
|
155
|
+
readonly optionIconSize = computed(() => this.size() === 'large' ? 20 : 16);
|
|
156
|
+
readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
157
|
+
readonly selectedValues = computed(() => {
|
|
158
|
+
const current = this.value();
|
|
159
|
+
const values = Array.isArray(current) ? current : current == null ? [] : [current as string];
|
|
160
|
+
const available = new Set(this.options().map(option => option.value));
|
|
161
|
+
const selected = [...new Set(values)].filter(value => available.has(value));
|
|
162
|
+
return this.multiple() ? selected : selected.slice(0, 1);
|
|
163
|
+
});
|
|
164
|
+
readonly selectedOptions = computed(() => this.selectedValues()
|
|
165
|
+
.map(value => this.options().find(option => option.value === value))
|
|
166
|
+
.filter((option): option is GoodSelectOption => !!option));
|
|
167
|
+
readonly filteredOptions = computed(() => {
|
|
168
|
+
const query = this.query().trim().toLowerCase();
|
|
169
|
+
return query ? this.options().filter(option =>
|
|
170
|
+
[option.label, option.description, option.value, ...(option.tags ?? [])]
|
|
171
|
+
.filter(Boolean).some(text => text!.toLowerCase().includes(query))) : this.options();
|
|
172
|
+
});
|
|
173
|
+
readonly activeOptionId = computed(() => this.open() && this.activeIndex() >= 0 && this.activeIndex() < this.filteredOptions().length
|
|
174
|
+
? this.optionId(this.activeIndex()) : null);
|
|
175
|
+
readonly triggerLabel = computed(() => {
|
|
176
|
+
const values = this.selectedOptions();
|
|
177
|
+
return this.multiple()
|
|
178
|
+
? `${this.label()}: ${values.length ? values.map(option => option.label).join(', ') : this.placeholder()}`
|
|
179
|
+
: `${this.label()}: ${values[0]?.label ?? this.placeholder()}`;
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
private readonly scrollHandler = (event: Event): void => {
|
|
183
|
+
if (this.open() && !this.host.nativeElement.contains(event.target as Node)) this.positionPanel();
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
constructor() {
|
|
187
|
+
if (this.browser) this.document.addEventListener('scroll', this.scrollHandler, true);
|
|
188
|
+
effect(() => {
|
|
189
|
+
if (this.isDisabled() && this.open()) this.close();
|
|
190
|
+
this.required();
|
|
191
|
+
this.options();
|
|
192
|
+
this.value();
|
|
193
|
+
this.multiple();
|
|
194
|
+
this.maxSelected();
|
|
195
|
+
this.onValidatorChange();
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
ngOnDestroy(): void { if (this.browser) this.document.removeEventListener('scroll', this.scrollHandler, true); }
|
|
200
|
+
|
|
201
|
+
validate(_control: AbstractControl): ValidationErrors | null {
|
|
202
|
+
if (this.isDisabled()) return null;
|
|
203
|
+
if (this.required() && !this.selectedValues().length) return { required: true };
|
|
204
|
+
const limit = this.maxSelected();
|
|
205
|
+
return this.multiple() && limit !== null && Number.isFinite(limit) && this.selectedValues().length > Math.max(0, Math.floor(limit))
|
|
206
|
+
? { maxSelected: { max: Math.max(0, Math.floor(limit)), actual: this.selectedValues().length } } : null;
|
|
207
|
+
}
|
|
208
|
+
registerOnValidatorChange(fn: () => void): void { this.onValidatorChange = fn; }
|
|
209
|
+
writeValue(value: GoodSelectValue): void { this.value.set(value); }
|
|
210
|
+
registerOnChange(fn: (value: GoodSelectValue) => void): void { this.onChange = fn; }
|
|
211
|
+
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
|
|
212
|
+
setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); }
|
|
213
|
+
|
|
214
|
+
toggle(): void { this.open() ? this.close() : this.show(); }
|
|
215
|
+
show(): void {
|
|
216
|
+
if (this.isDisabled() || this.open()) return;
|
|
217
|
+
this.query.set('');
|
|
218
|
+
this.activeIndex.set(this.firstAvailableIndex(this.options()));
|
|
219
|
+
this.positionReady.set(false);
|
|
220
|
+
this.open.set(true);
|
|
221
|
+
if (this.browser) requestAnimationFrame(() => {
|
|
222
|
+
this.positionPanel();
|
|
223
|
+
requestAnimationFrame(() => {
|
|
224
|
+
(this.searchable() ? this.searchInput()?.nativeElement : this.list()?.nativeElement)?.focus();
|
|
225
|
+
this.scrollActiveIntoView();
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
close(restoreFocus = false): void {
|
|
230
|
+
if (!this.open()) return;
|
|
231
|
+
this.open.set(false);
|
|
232
|
+
this.positionReady.set(false);
|
|
233
|
+
this.onTouched();
|
|
234
|
+
if (restoreFocus && this.browser) requestAnimationFrame(() => this.trigger()?.nativeElement.focus());
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
onSearch(event: Event): void {
|
|
238
|
+
this.query.set((event.target as HTMLInputElement).value);
|
|
239
|
+
this.activeIndex.set(this.firstAvailableIndex(this.filteredOptions()));
|
|
240
|
+
this.scrollActiveIntoView();
|
|
241
|
+
}
|
|
242
|
+
isSelected(value: string): boolean { return this.selectedValues().includes(value); }
|
|
243
|
+
isOptionDisabled(option: GoodSelectOption): boolean {
|
|
244
|
+
const limit = this.maxSelected();
|
|
245
|
+
return !!option.disabled || !!(this.multiple() && limit !== null && Number.isFinite(limit)
|
|
246
|
+
&& this.selectedValues().length >= Math.max(0, Math.floor(limit)) && !this.isSelected(option.value));
|
|
247
|
+
}
|
|
248
|
+
choose(option: GoodSelectOption): void {
|
|
249
|
+
if (this.isDisabled() || this.isOptionDisabled(option)) return;
|
|
250
|
+
if (this.multiple()) {
|
|
251
|
+
const values = this.selectedValues();
|
|
252
|
+
this.setValue(this.isSelected(option.value) ? values.filter(value => value !== option.value) : [...values, option.value]);
|
|
253
|
+
this.searchInput()?.nativeElement.focus();
|
|
254
|
+
} else {
|
|
255
|
+
this.setValue(option.value);
|
|
256
|
+
this.close(true);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
remove(value: string): void {
|
|
260
|
+
const option = this.options().find(item => item.value === value);
|
|
261
|
+
if (this.isDisabled() || option?.disabled || !this.multiple()) return;
|
|
262
|
+
this.setValue(this.selectedValues().filter(item => item !== value));
|
|
263
|
+
if (this.browser) requestAnimationFrame(() => this.trigger()?.nativeElement.focus());
|
|
264
|
+
}
|
|
265
|
+
optionId(index: number): string { return `${this.listId}-option-${index}`; }
|
|
266
|
+
|
|
267
|
+
onKeydown(event: KeyboardEvent): void {
|
|
268
|
+
const key = event.key;
|
|
269
|
+
if (!this.open()) {
|
|
270
|
+
if (['ArrowDown', 'ArrowUp', 'Enter', ' '].includes(key)) { event.preventDefault(); this.show(); }
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
if (key === 'Escape') { event.preventDefault(); this.close(true); return; }
|
|
274
|
+
if (key === 'Tab') { this.close(); return; }
|
|
275
|
+
if (event.target instanceof HTMLInputElement && (key === 'Home' || key === 'End')) return;
|
|
276
|
+
if (key === 'ArrowDown' || key === 'ArrowUp' || key === 'Home' || key === 'End') {
|
|
277
|
+
event.preventDefault();
|
|
278
|
+
const options = this.filteredOptions();
|
|
279
|
+
const available = options.map((option, index) => !this.isOptionDisabled(option) ? index : -1).filter(index => index >= 0);
|
|
280
|
+
if (!available.length) return;
|
|
281
|
+
const current = available.indexOf(this.activeIndex());
|
|
282
|
+
const next = key === 'Home' ? available[0] : key === 'End' ? available[available.length - 1]
|
|
283
|
+
: available[(current + (key === 'ArrowDown' ? 1 : available.length - 1)) % available.length];
|
|
284
|
+
this.activeIndex.set(next);
|
|
285
|
+
this.scrollActiveIntoView();
|
|
286
|
+
} else if (key === 'Enter' || (key === ' ' && !(event.target instanceof HTMLInputElement))) {
|
|
287
|
+
event.preventDefault();
|
|
288
|
+
const option = this.filteredOptions()[this.activeIndex()];
|
|
289
|
+
if (option) this.choose(option);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
onFocusOut(event: FocusEvent): void {
|
|
293
|
+
if (event.relatedTarget && this.host.nativeElement.contains(event.relatedTarget as Node)) return;
|
|
294
|
+
this.onTouched();
|
|
295
|
+
if (this.open()) this.close();
|
|
296
|
+
}
|
|
297
|
+
@HostListener('document:pointerdown', ['$event'])
|
|
298
|
+
onDocumentPointerDown(event: PointerEvent): void {
|
|
299
|
+
if (this.open() && !this.host.nativeElement.contains(event.target as Node)) this.close();
|
|
300
|
+
}
|
|
301
|
+
@HostListener('window:resize')
|
|
302
|
+
onResize(): void { if (this.open()) this.positionPanel(); }
|
|
303
|
+
|
|
304
|
+
private setValue(value: GoodSelectValue): void {
|
|
305
|
+
this.value.set(value);
|
|
306
|
+
this.onChange(value);
|
|
307
|
+
this.selectionChange.emit(value);
|
|
308
|
+
this.onValidatorChange();
|
|
309
|
+
}
|
|
310
|
+
private firstAvailableIndex(options: readonly GoodSelectOption[]): number {
|
|
311
|
+
return options.findIndex(option => !this.isOptionDisabled(option));
|
|
312
|
+
}
|
|
313
|
+
private scrollActiveIntoView(): void {
|
|
314
|
+
if (!this.browser) return;
|
|
315
|
+
requestAnimationFrame(() => this.document.getElementById(this.optionId(this.activeIndex()))?.scrollIntoView({ block: 'nearest' }));
|
|
316
|
+
}
|
|
317
|
+
private positionPanel(): void {
|
|
318
|
+
const trigger = this.trigger()?.nativeElement;
|
|
319
|
+
const panel = this.panel()?.nativeElement;
|
|
320
|
+
if (!trigger || !panel || !this.open()) return;
|
|
321
|
+
const rect = this.host.nativeElement.querySelector<HTMLElement>('.good-select-control')!.getBoundingClientRect();
|
|
322
|
+
const edge = 8;
|
|
323
|
+
const style = getComputedStyle(this.host.nativeElement);
|
|
324
|
+
const gap = parseFloat(style.getPropertyValue('--good-select-popup-gap')) || 6;
|
|
325
|
+
const width = Math.min(Math.max(rect.width, 240), window.innerWidth - edge * 2);
|
|
326
|
+
const preferredHeight = parseFloat(style.getPropertyValue('--good-select-panel-max-height')) || 320;
|
|
327
|
+
const maxHeight = Math.max(120, Math.min(preferredHeight, window.innerHeight - edge * 2));
|
|
328
|
+
const height = Math.min(panel.scrollHeight, maxHeight);
|
|
329
|
+
const below = window.innerHeight - rect.bottom - edge - gap;
|
|
330
|
+
const above = rect.top - edge - gap;
|
|
331
|
+
const top = below >= height || below >= above ? rect.bottom + gap : Math.max(edge, rect.top - height - gap);
|
|
332
|
+
const left = Math.max(edge, Math.min(rect.left, window.innerWidth - width - edge));
|
|
333
|
+
this.position.set({ top, left, width, maxHeight: Math.min(maxHeight, Math.max(below, above, 160)) });
|
|
334
|
+
this.positionReady.set(true);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, contentChildren, effect, forwardRef, inject, input, signal } from '@angular/core';
|
|
2
|
+
import { RouterLink } from '@angular/router';
|
|
3
|
+
import { GoodIconComponent } from './icon';
|
|
4
|
+
import { GoodNavItem, GoodSidebarSection, goodItemContainsRoute, goodRouteActive } from './models';
|
|
5
|
+
|
|
6
|
+
let nextPanelId = 0;
|
|
7
|
+
|
|
8
|
+
class GoodSidebarAccordion {
|
|
9
|
+
readonly selected = signal<Record<number, string | null>>({});
|
|
10
|
+
reset(): void { this.selected.set({}); }
|
|
11
|
+
|
|
12
|
+
isOpen(depth: number, id: string, initiallyOpen: boolean): boolean {
|
|
13
|
+
const selected = this.selected()[depth];
|
|
14
|
+
return selected === undefined ? initiallyOpen : selected === id;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
toggle(depth: number, id: string, currentlyOpen: boolean): void {
|
|
18
|
+
this.selected.update(value => ({ ...value, [depth]: currentlyOpen ? null : id }));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
@Component({
|
|
23
|
+
selector: 'good-sidebar-submenu-item',
|
|
24
|
+
standalone: true,
|
|
25
|
+
imports: [RouterLink],
|
|
26
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
27
|
+
template: `
|
|
28
|
+
@if (link() && !disabled()) {
|
|
29
|
+
<a class="good-submenu-link" [class.good-is-active]="isActive()" [routerLink]="link()"
|
|
30
|
+
[attr.aria-current]="isActive() ? 'page' : null" [attr.aria-disabled]="disabled() ? 'true' : null"
|
|
31
|
+
[tabIndex]="disabled() ? -1 : 0">
|
|
32
|
+
<span class="good-submenu-dot" aria-hidden="true"></span><span class="good-menu-label">{{ text() }}</span>
|
|
33
|
+
</a>
|
|
34
|
+
} @else {
|
|
35
|
+
<span class="good-submenu-link good-is-disabled"><span class="good-submenu-dot"></span>{{ text() }}</span>
|
|
36
|
+
}
|
|
37
|
+
`,
|
|
38
|
+
host: { class: 'good-sidebar-submenu-item' },
|
|
39
|
+
})
|
|
40
|
+
export class GoodSidebarSubmenuItemComponent {
|
|
41
|
+
readonly item = input<GoodNavItem | null>(null);
|
|
42
|
+
readonly label = input('');
|
|
43
|
+
readonly route = input<string | undefined>();
|
|
44
|
+
readonly active = input(false);
|
|
45
|
+
readonly activeMatch = input<'exact' | 'prefix'>('prefix');
|
|
46
|
+
readonly activeRoute = input('');
|
|
47
|
+
readonly disabled = computed(() => this.item()?.disabled ?? false);
|
|
48
|
+
readonly text = computed(() => this.item()?.label ?? this.label());
|
|
49
|
+
readonly link = computed(() => this.item()?.route ?? this.route());
|
|
50
|
+
readonly isActive = computed(() => this.active() || goodRouteActive(this.link(), this.activeRoute(), this.item()?.activeMatch ?? this.activeMatch()));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@Component({
|
|
54
|
+
selector: 'good-sidebar-submenu-group',
|
|
55
|
+
standalone: true,
|
|
56
|
+
imports: [GoodSidebarSubmenuItemComponent, forwardRef(() => GoodSidebarSubmenuGroupComponent)],
|
|
57
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
58
|
+
template: `
|
|
59
|
+
<div class="good-submenu-group">
|
|
60
|
+
<button type="button" class="good-submenu-heading" [attr.aria-expanded]="isOpen()"
|
|
61
|
+
[attr.aria-controls]="panelId" (click)="toggle()">
|
|
62
|
+
<span class="good-menu-label">{{ text() }}</span><span class="good-menu-indicator" aria-hidden="true">{{ isOpen() ? '−' : '+' }}</span>
|
|
63
|
+
</button>
|
|
64
|
+
<div class="good-submenu-children" [id]="panelId" [hidden]="!isOpen()">
|
|
65
|
+
@for (child of children(); track child.id) {
|
|
66
|
+
@if (child.children?.length) {
|
|
67
|
+
<good-sidebar-submenu-group [item]="child" [activeRoute]="activeRoute()" [depth]="depth() + 1" />
|
|
68
|
+
} @else {
|
|
69
|
+
<good-sidebar-submenu-item [item]="child" [activeRoute]="activeRoute()" />
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
<ng-content />
|
|
73
|
+
</div>
|
|
74
|
+
</div>
|
|
75
|
+
`,
|
|
76
|
+
host: { class: 'good-sidebar-submenu-group' },
|
|
77
|
+
})
|
|
78
|
+
export class GoodSidebarSubmenuGroupComponent {
|
|
79
|
+
private readonly accordion = inject(GoodSidebarAccordion, { optional: true });
|
|
80
|
+
readonly panelId = `good-submenu-panel-${++nextPanelId}`;
|
|
81
|
+
readonly item = input<GoodNavItem | null>(null);
|
|
82
|
+
readonly label = input('');
|
|
83
|
+
readonly expanded = input(false);
|
|
84
|
+
readonly activeRoute = input('');
|
|
85
|
+
readonly depth = input(1);
|
|
86
|
+
readonly localOpen = signal<boolean | null>(null);
|
|
87
|
+
readonly children = computed(() => this.item()?.children ?? []);
|
|
88
|
+
readonly text = computed(() => this.item()?.label ?? this.label());
|
|
89
|
+
readonly initiallyOpen = computed(() => this.expanded() || (!!this.item() && goodItemContainsRoute(this.item()!, this.activeRoute())));
|
|
90
|
+
readonly isOpen = computed(() => this.accordion
|
|
91
|
+
? this.accordion.isOpen(this.depth(), this.panelId, this.initiallyOpen())
|
|
92
|
+
: (this.localOpen() ?? this.initiallyOpen()));
|
|
93
|
+
|
|
94
|
+
toggle(): void {
|
|
95
|
+
if (this.accordion) this.accordion.toggle(this.depth(), this.panelId, this.isOpen());
|
|
96
|
+
else this.localOpen.set(!this.isOpen());
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
@Component({
|
|
101
|
+
selector: 'good-sidebar-item',
|
|
102
|
+
standalone: true,
|
|
103
|
+
imports: [GoodIconComponent, GoodSidebarSubmenuGroupComponent, GoodSidebarSubmenuItemComponent, RouterLink],
|
|
104
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
105
|
+
template: `
|
|
106
|
+
@if (hasChildren()) {
|
|
107
|
+
<button type="button" class="good-sidebar-row" [class.good-is-active]="isActive()" [class.good-is-disabled]="item()?.disabled ?? false" [disabled]="item()?.disabled ?? false"
|
|
108
|
+
[attr.aria-expanded]="isOpen()" [attr.aria-controls]="panelId" (click)="toggle()">
|
|
109
|
+
@if (iconName()) { <good-icon [name]="iconName()!" /> }
|
|
110
|
+
<span class="good-menu-label">{{ text() }}</span>
|
|
111
|
+
@if (badgeText()) { <span class="good-menu-badge">{{ badgeText() }}</span> }
|
|
112
|
+
<span class="good-menu-indicator" aria-hidden="true">{{ isOpen() ? '−' : '+' }}</span>
|
|
113
|
+
</button>
|
|
114
|
+
<div class="good-sidebar-children" [id]="panelId" [hidden]="!isOpen()">
|
|
115
|
+
@for (child of children(); track child.id) {
|
|
116
|
+
@if (child.children?.length) {
|
|
117
|
+
<good-sidebar-submenu-group [item]="child" [activeRoute]="activeRoute()" [depth]="1" />
|
|
118
|
+
} @else {
|
|
119
|
+
<good-sidebar-submenu-item [item]="child" [activeRoute]="activeRoute()" />
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
<ng-content />
|
|
123
|
+
</div>
|
|
124
|
+
} @else if (link() && !item()?.disabled) {
|
|
125
|
+
<a class="good-sidebar-row" [class.good-is-active]="isActive()" [routerLink]="link()"
|
|
126
|
+
[attr.aria-current]="isActive() ? 'page' : null">
|
|
127
|
+
@if (iconName()) { <good-icon [name]="iconName()!" /> }
|
|
128
|
+
<span class="good-menu-label">{{ text() }}</span>
|
|
129
|
+
@if (badgeText()) { <span class="good-menu-badge">{{ badgeText() }}</span> }
|
|
130
|
+
</a>
|
|
131
|
+
} @else {
|
|
132
|
+
<span class="good-sidebar-row good-is-disabled">
|
|
133
|
+
@if (iconName()) { <good-icon [name]="iconName()!" /> }
|
|
134
|
+
<span class="good-menu-label">{{ text() }}</span>
|
|
135
|
+
</span>
|
|
136
|
+
}
|
|
137
|
+
`,
|
|
138
|
+
host: { class: 'good-sidebar-item' },
|
|
139
|
+
})
|
|
140
|
+
export class GoodSidebarItemComponent {
|
|
141
|
+
private readonly accordion = inject(GoodSidebarAccordion, { optional: true });
|
|
142
|
+
readonly panelId = `good-sidebar-panel-${++nextPanelId}`;
|
|
143
|
+
readonly item = input<GoodNavItem | null>(null);
|
|
144
|
+
readonly label = input('');
|
|
145
|
+
readonly icon = input<GoodNavItem['icon']>();
|
|
146
|
+
readonly route = input<string | undefined>();
|
|
147
|
+
readonly badge = input<string | undefined>();
|
|
148
|
+
readonly active = input(false);
|
|
149
|
+
readonly activeMatch = input<'exact' | 'prefix'>('prefix');
|
|
150
|
+
readonly expanded = input(false);
|
|
151
|
+
readonly activeRoute = input('');
|
|
152
|
+
readonly projectedGroups = contentChildren(GoodSidebarSubmenuGroupComponent);
|
|
153
|
+
readonly children = computed(() => this.item()?.children ?? []);
|
|
154
|
+
readonly hasChildren = computed(() => this.children().length > 0 || this.projectedGroups().length > 0);
|
|
155
|
+
readonly text = computed(() => this.item()?.label ?? this.label());
|
|
156
|
+
readonly iconName = computed(() => this.item()?.icon ?? this.icon());
|
|
157
|
+
readonly link = computed(() => this.item()?.route ?? this.route());
|
|
158
|
+
readonly badgeText = computed(() => this.item()?.badge ?? this.badge());
|
|
159
|
+
readonly isActive = computed(() => this.active() || goodRouteActive(this.link(), this.activeRoute(), this.item()?.activeMatch ?? this.activeMatch()));
|
|
160
|
+
readonly initiallyOpen = computed(() => this.expanded() || (!!this.item() && goodItemContainsRoute(this.item()!, this.activeRoute())));
|
|
161
|
+
readonly localOpen = signal<boolean | null>(null);
|
|
162
|
+
readonly isOpen = computed(() => this.accordion
|
|
163
|
+
? this.accordion.isOpen(0, this.panelId, this.initiallyOpen())
|
|
164
|
+
: (this.localOpen() ?? this.initiallyOpen()));
|
|
165
|
+
|
|
166
|
+
toggle(): void {
|
|
167
|
+
if (this.accordion) this.accordion.toggle(0, this.panelId, this.isOpen());
|
|
168
|
+
else this.localOpen.set(!this.isOpen());
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
@Component({
|
|
173
|
+
selector: 'good-sidebar-menu-container',
|
|
174
|
+
standalone: true,
|
|
175
|
+
imports: [GoodSidebarItemComponent],
|
|
176
|
+
providers: [GoodSidebarAccordion],
|
|
177
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
178
|
+
template: `
|
|
179
|
+
@if (heading()) { <h2 class="good-sidebar-heading">{{ heading() }}</h2> }
|
|
180
|
+
<div class="good-sidebar-items">
|
|
181
|
+
@for (item of items(); track item.id) {
|
|
182
|
+
<good-sidebar-item [item]="item" [activeRoute]="activeRoute()" />
|
|
183
|
+
}
|
|
184
|
+
<ng-content />
|
|
185
|
+
</div>
|
|
186
|
+
`,
|
|
187
|
+
host: { class: 'good-sidebar-menu-container' },
|
|
188
|
+
})
|
|
189
|
+
export class GoodSidebarMenuContainerComponent {
|
|
190
|
+
private readonly accordion = inject(GoodSidebarAccordion);
|
|
191
|
+
readonly heading = input('');
|
|
192
|
+
readonly items = input<readonly GoodNavItem[]>([]);
|
|
193
|
+
readonly activeRoute = input('');
|
|
194
|
+
|
|
195
|
+
constructor() {
|
|
196
|
+
effect(() => {
|
|
197
|
+
this.activeRoute();
|
|
198
|
+
this.accordion.reset();
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
@Component({
|
|
204
|
+
selector: 'good-sidebar-container',
|
|
205
|
+
standalone: true,
|
|
206
|
+
imports: [GoodSidebarMenuContainerComponent],
|
|
207
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
208
|
+
template: `
|
|
209
|
+
<div class="good-sidebar-brand" [class.good-has-dark-logo]="!!brandLogoDarkSrc()">
|
|
210
|
+
@if (brandLogoSrc()) {
|
|
211
|
+
<img class="good-brand-logo good-brand-logo-light" [src]="brandLogoSrc()" [alt]="brand()" />
|
|
212
|
+
@if (brandLogoDarkSrc()) { <img class="good-brand-logo good-brand-logo-dark" [src]="brandLogoDarkSrc()" [alt]="brand()" /> }
|
|
213
|
+
} @else {
|
|
214
|
+
<span class="good-brand-mark" aria-hidden="true"></span><span class="good-brand-name">{{ brand() }}</span>
|
|
215
|
+
}
|
|
216
|
+
</div>
|
|
217
|
+
<nav class="good-sidebar-scroll" aria-label="Hauptnavigation">
|
|
218
|
+
@for (section of sections(); track section.id) {
|
|
219
|
+
<good-sidebar-menu-container [heading]="section.heading ?? ''" [items]="section.items" [activeRoute]="activeRoute()" />
|
|
220
|
+
}
|
|
221
|
+
<ng-content />
|
|
222
|
+
</nav>
|
|
223
|
+
`,
|
|
224
|
+
host: { class: 'good-sidebar-container' },
|
|
225
|
+
})
|
|
226
|
+
export class GoodSidebarContainerComponent {
|
|
227
|
+
readonly brand = input('GOODUI');
|
|
228
|
+
readonly brandLogoSrc = input('');
|
|
229
|
+
readonly brandLogoDarkSrc = input('');
|
|
230
|
+
readonly sections = input<readonly GoodSidebarSection[]>([]);
|
|
231
|
+
readonly activeRoute = input('');
|
|
232
|
+
}
|