@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,313 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, ElementRef, computed, effect, forwardRef, input, model, output, signal, viewChild } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
import { LucideDynamicIcon, LucideMinus, LucidePlus } from '@lucide/angular';
|
|
4
|
+
import { GoodButtonIcon } from './models';
|
|
5
|
+
import { GoodMarkerColor } from './marker-colors';
|
|
6
|
+
|
|
7
|
+
export type GoodRangeSliderMode = 'single' | 'range';
|
|
8
|
+
export type GoodRangeSliderSize = 'small' | 'default' | 'large';
|
|
9
|
+
export type GoodRangeSliderColor = 'brand' | 'accent' | 'secondary' | 'destructive' | 'warning' | 'success' | 'info' | 'text' | GoodMarkerColor;
|
|
10
|
+
export interface GoodRangeSliderRange { start: number; end: number; }
|
|
11
|
+
export interface GoodRangeSliderTick { value: number; label: string; }
|
|
12
|
+
|
|
13
|
+
type Thumb = 'single' | 'start' | 'end';
|
|
14
|
+
|
|
15
|
+
@Component({
|
|
16
|
+
selector: 'good-range-slider',
|
|
17
|
+
standalone: true,
|
|
18
|
+
imports: [LucideDynamicIcon],
|
|
19
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
20
|
+
host: {
|
|
21
|
+
class: 'good-range-slider',
|
|
22
|
+
'[attr.data-mode]': 'mode()',
|
|
23
|
+
'[attr.data-size]': 'size()',
|
|
24
|
+
'[attr.data-color]': 'color()',
|
|
25
|
+
'[attr.data-disabled]': 'isDisabled()',
|
|
26
|
+
'[attr.data-step-buttons]': 'showStepButtons()',
|
|
27
|
+
},
|
|
28
|
+
providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodRangeSliderComponent), multi: true }],
|
|
29
|
+
template: `
|
|
30
|
+
@if (showLabel()) { <span class="good-range-slider-label" [id]="labelId">{{ label() }}</span> }
|
|
31
|
+
<div class="good-range-slider-control">
|
|
32
|
+
@if (showStepButtons()) {
|
|
33
|
+
<button class="good-range-slider-step" type="button" [disabled]="isDisabled() || !canStep(-1)"
|
|
34
|
+
[attr.aria-label]="'Decrease ' + activeLabel()" (click)="adjust(-1)">
|
|
35
|
+
<svg [lucideIcon]="minusIcon" [size]="iconSize()" aria-hidden="true"></svg>
|
|
36
|
+
</button>
|
|
37
|
+
}
|
|
38
|
+
<div class="good-range-slider-track" #track (pointerdown)="onPointerDown($event)"
|
|
39
|
+
(pointermove)="onPointerMove($event)" (pointerup)="onPointerUp($event)" (pointercancel)="onPointerUp($event)">
|
|
40
|
+
<div class="good-range-slider-rail" #rail>
|
|
41
|
+
<span class="good-range-slider-fill" [style.left.%]="fillStart()" [style.width.%]="fillWidth()" aria-hidden="true"></span>
|
|
42
|
+
@if (mode() === 'range') {
|
|
43
|
+
<button type="button" class="good-range-slider-thumb" data-thumb="start" role="slider"
|
|
44
|
+
[style.left.%]="startPercent()" [disabled]="isDisabled()" [attr.aria-label]="label() + ' start'"
|
|
45
|
+
[attr.aria-valuemin]="effectiveMin()" [attr.aria-valuemax]="displayRange().end"
|
|
46
|
+
[attr.aria-valuenow]="displayRange().start" [attr.aria-valuetext]="valueText(displayRange().start)"
|
|
47
|
+
aria-orientation="horizontal" (focus)="activeThumb.set('start')" (blur)="onTouched()"
|
|
48
|
+
(keydown)="onThumbKeydown($event, 'start')">
|
|
49
|
+
@if (icon(); as thumbIcon) { <svg [lucideIcon]="thumbIcon" [size]="iconSize()" aria-hidden="true"></svg> }
|
|
50
|
+
</button>
|
|
51
|
+
<button type="button" class="good-range-slider-thumb" data-thumb="end" role="slider"
|
|
52
|
+
[style.left.%]="endPercent()" [disabled]="isDisabled()" [attr.aria-label]="label() + ' end'"
|
|
53
|
+
[attr.aria-valuemin]="displayRange().start" [attr.aria-valuemax]="effectiveMax()"
|
|
54
|
+
[attr.aria-valuenow]="displayRange().end" [attr.aria-valuetext]="valueText(displayRange().end)"
|
|
55
|
+
aria-orientation="horizontal" (focus)="activeThumb.set('end')" (blur)="onTouched()"
|
|
56
|
+
(keydown)="onThumbKeydown($event, 'end')">
|
|
57
|
+
@if (icon(); as thumbIcon) { <svg [lucideIcon]="thumbIcon" [size]="iconSize()" aria-hidden="true"></svg> }
|
|
58
|
+
</button>
|
|
59
|
+
} @else {
|
|
60
|
+
<button type="button" class="good-range-slider-thumb" data-thumb="single" role="slider"
|
|
61
|
+
[style.left.%]="singlePercent()" [disabled]="isDisabled()" [attr.aria-label]="label()"
|
|
62
|
+
[attr.aria-valuemin]="effectiveMin()" [attr.aria-valuemax]="effectiveMax()"
|
|
63
|
+
[attr.aria-valuenow]="displayValue()" [attr.aria-valuetext]="valueText(displayValue())"
|
|
64
|
+
aria-orientation="horizontal" (blur)="onTouched()" (keydown)="onThumbKeydown($event, 'single')">
|
|
65
|
+
@if (icon(); as thumbIcon) { <svg [lucideIcon]="thumbIcon" [size]="iconSize()" aria-hidden="true"></svg> }
|
|
66
|
+
</button>
|
|
67
|
+
}
|
|
68
|
+
</div>
|
|
69
|
+
</div>
|
|
70
|
+
@if (showStepButtons()) {
|
|
71
|
+
<button class="good-range-slider-step" type="button" [disabled]="isDisabled() || !canStep(1)"
|
|
72
|
+
[attr.aria-label]="'Increase ' + activeLabel()" (click)="adjust(1)">
|
|
73
|
+
<svg [lucideIcon]="plusIcon" [size]="iconSize()" aria-hidden="true"></svg>
|
|
74
|
+
</button>
|
|
75
|
+
}
|
|
76
|
+
</div>
|
|
77
|
+
@if (showBounds()) {
|
|
78
|
+
<div class="good-range-slider-bounds" aria-hidden="true"><span>{{ minLabel() || effectiveMin() }}</span><span>{{ maxLabel() || effectiveMax() }}</span></div>
|
|
79
|
+
}
|
|
80
|
+
@if (visibleTicks().length) {
|
|
81
|
+
<div class="good-range-slider-ticks" aria-hidden="true">
|
|
82
|
+
@for (tick of visibleTicks(); track $index) {
|
|
83
|
+
<span class="good-range-slider-tick" [style.left.%]="tick.percent"
|
|
84
|
+
[style.transform]="tick.percent === 0 ? 'none' : tick.percent === 100 ? 'translateX(-100%)' : 'translateX(-50%)'">
|
|
85
|
+
<span class="good-range-slider-tick-mark"></span>{{ tick.label }}
|
|
86
|
+
</span>
|
|
87
|
+
}
|
|
88
|
+
</div>
|
|
89
|
+
}
|
|
90
|
+
`,
|
|
91
|
+
})
|
|
92
|
+
export class GoodRangeSliderComponent implements ControlValueAccessor {
|
|
93
|
+
readonly mode = input<GoodRangeSliderMode>('single');
|
|
94
|
+
readonly value = model(50);
|
|
95
|
+
readonly rangeValue = model<GoodRangeSliderRange>({ start: 25, end: 75 });
|
|
96
|
+
readonly min = input(0);
|
|
97
|
+
readonly max = input(100);
|
|
98
|
+
readonly step = input(1);
|
|
99
|
+
readonly ticks = input<readonly GoodRangeSliderTick[]>([]);
|
|
100
|
+
readonly label = input('Value');
|
|
101
|
+
readonly showLabel = input(false);
|
|
102
|
+
readonly showBounds = input(false);
|
|
103
|
+
readonly minLabel = input('');
|
|
104
|
+
readonly maxLabel = input('');
|
|
105
|
+
readonly size = input<GoodRangeSliderSize>('default');
|
|
106
|
+
readonly color = input<GoodRangeSliderColor>('brand');
|
|
107
|
+
readonly icon = input<GoodButtonIcon>();
|
|
108
|
+
readonly showStepButtons = input(false);
|
|
109
|
+
readonly disabled = input(false);
|
|
110
|
+
/** Fires once after a user finishes a drag or keyboard/button step. */
|
|
111
|
+
readonly changeCommitted = output<number | GoodRangeSliderRange>();
|
|
112
|
+
|
|
113
|
+
readonly minusIcon = LucideMinus;
|
|
114
|
+
readonly plusIcon = LucidePlus;
|
|
115
|
+
readonly labelId = `good-range-slider-label-${++nextRangeSliderId}`;
|
|
116
|
+
readonly effectiveMin = computed(() => Number.isFinite(this.min()) ? this.min() : 0);
|
|
117
|
+
readonly effectiveMax = computed(() => Number.isFinite(this.max()) ? Math.max(this.effectiveMin(), this.max()) : 100);
|
|
118
|
+
readonly effectiveStep = computed(() => Number.isFinite(this.step()) && this.step() > 0 ? this.step() : 1);
|
|
119
|
+
readonly iconSize = computed(() => ({ small: 12, default: 14, large: 16 })[this.size()]);
|
|
120
|
+
readonly displayValue = computed(() => this.snap(this.value()));
|
|
121
|
+
readonly displayRange = computed(() => this.normalizeRange(this.rangeValue()));
|
|
122
|
+
readonly singlePercent = computed(() => this.percent(this.displayValue()));
|
|
123
|
+
readonly startPercent = computed(() => this.percent(this.displayRange().start));
|
|
124
|
+
readonly endPercent = computed(() => this.percent(this.displayRange().end));
|
|
125
|
+
readonly fillStart = computed(() => this.mode() === 'range' ? this.startPercent() : 0);
|
|
126
|
+
readonly fillWidth = computed(() => this.mode() === 'range' ? this.endPercent() - this.startPercent() : this.singlePercent());
|
|
127
|
+
readonly visibleTicks = computed(() => this.ticks().filter(tick => Number.isFinite(tick.value) && tick.value >= this.effectiveMin() && tick.value <= this.effectiveMax()
|
|
128
|
+
&& (!this.showBounds() || (tick.value !== this.effectiveMin() && tick.value !== this.effectiveMax())))
|
|
129
|
+
.map(tick => ({ ...tick, percent: this.percent(tick.value) })));
|
|
130
|
+
readonly activeThumb = signal<'start' | 'end'>('end');
|
|
131
|
+
readonly activeLabel = computed(() => this.mode() === 'range' ? `${this.label()} ${this.activeThumb()}` : this.label());
|
|
132
|
+
private readonly formDisabled = signal(false);
|
|
133
|
+
readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
134
|
+
private readonly rail = viewChild<ElementRef<HTMLElement>>('rail');
|
|
135
|
+
private readonly track = viewChild<ElementRef<HTMLElement>>('track');
|
|
136
|
+
private dragging: Thumb | null = null;
|
|
137
|
+
private draggingPointerId: number | null = null;
|
|
138
|
+
private dragOffsetX = 0;
|
|
139
|
+
private dragStart: number | GoodRangeSliderRange | null = null;
|
|
140
|
+
private onChange: (value: number | GoodRangeSliderRange) => void = () => {};
|
|
141
|
+
onTouched: () => void = () => {};
|
|
142
|
+
|
|
143
|
+
constructor() {
|
|
144
|
+
effect(() => {
|
|
145
|
+
const value = this.displayValue();
|
|
146
|
+
if (value !== this.value()) {
|
|
147
|
+
this.value.set(value);
|
|
148
|
+
if (this.mode() === 'single') this.onChange(value);
|
|
149
|
+
}
|
|
150
|
+
const range = this.displayRange();
|
|
151
|
+
const current = this.rangeValue();
|
|
152
|
+
if (range.start !== current.start || range.end !== current.end) {
|
|
153
|
+
this.rangeValue.set(range);
|
|
154
|
+
if (this.mode() === 'range') this.onChange(range);
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private precision(value: number): number {
|
|
160
|
+
const text = String(value);
|
|
161
|
+
return text.includes('e-') ? Math.min(12, Number(text.split('e-')[1])) : (text.split('.')[1]?.length ?? 0);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private snap(value: number): number {
|
|
165
|
+
const min = this.effectiveMin();
|
|
166
|
+
const max = this.effectiveMax();
|
|
167
|
+
if (!Number.isFinite(value) || value <= min) return min;
|
|
168
|
+
if (value >= max) return max;
|
|
169
|
+
const next = min + Math.round((value - min) / this.effectiveStep()) * this.effectiveStep();
|
|
170
|
+
return Number(Math.min(max, Math.max(min, next)).toFixed(Math.min(12, Math.max(this.precision(min), this.precision(max), this.precision(this.effectiveStep())))));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private normalizeRange(value: GoodRangeSliderRange): GoodRangeSliderRange {
|
|
174
|
+
const start = this.snap(value?.start);
|
|
175
|
+
const end = this.snap(value?.end);
|
|
176
|
+
return { start: Math.min(start, end), end: Math.max(start, end) };
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
private percent(value: number): number {
|
|
180
|
+
const span = this.effectiveMax() - this.effectiveMin();
|
|
181
|
+
return span > 0 ? 100 * (value - this.effectiveMin()) / span : 0;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
private stepped(value: number, direction: -1 | 1): number {
|
|
185
|
+
const min = this.effectiveMin();
|
|
186
|
+
const max = this.effectiveMax();
|
|
187
|
+
const step = this.effectiveStep();
|
|
188
|
+
if (direction > 0) return value >= max ? max : this.snap(value + step >= max ? max : value + step);
|
|
189
|
+
if (value <= min) return min;
|
|
190
|
+
if (value === max) {
|
|
191
|
+
const lastGrid = min + Math.floor((max - min) / step) * step;
|
|
192
|
+
if (lastGrid < max) return this.snap(lastGrid);
|
|
193
|
+
}
|
|
194
|
+
return this.snap(value - step);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
private current(thumb: Thumb): number {
|
|
198
|
+
return thumb === 'single' ? this.displayValue() : this.displayRange()[thumb];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
private setThumb(thumb: Thumb, proposed: number): void {
|
|
202
|
+
if (this.isDisabled()) return;
|
|
203
|
+
const next = this.snap(proposed);
|
|
204
|
+
if (thumb === 'single') {
|
|
205
|
+
if (next === this.displayValue()) return;
|
|
206
|
+
this.value.set(next);
|
|
207
|
+
this.onChange(next);
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
const previous = this.displayRange();
|
|
211
|
+
const range = thumb === 'start'
|
|
212
|
+
? { start: Math.min(next, previous.end), end: previous.end }
|
|
213
|
+
: { start: previous.start, end: Math.max(next, previous.start) };
|
|
214
|
+
if (range.start === previous.start && range.end === previous.end) return;
|
|
215
|
+
this.rangeValue.set(range);
|
|
216
|
+
this.onChange(range);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
canStep(direction: -1 | 1): boolean {
|
|
220
|
+
const thumb = this.mode() === 'range' ? this.activeThumb() : 'single';
|
|
221
|
+
const next = this.stepped(this.current(thumb), direction);
|
|
222
|
+
if (thumb === 'start') return direction < 0 ? next < this.current(thumb) : next <= this.displayRange().end && next > this.current(thumb);
|
|
223
|
+
if (thumb === 'end') return direction > 0 ? next > this.current(thumb) : next >= this.displayRange().start && next < this.current(thumb);
|
|
224
|
+
return next !== this.current(thumb);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
adjust(direction: -1 | 1): void {
|
|
228
|
+
if (this.isDisabled()) return;
|
|
229
|
+
const thumb = this.mode() === 'range' ? this.activeThumb() : 'single';
|
|
230
|
+
const before = this.current(thumb);
|
|
231
|
+
this.setThumb(thumb, this.stepped(before, direction));
|
|
232
|
+
if (this.current(thumb) !== before) this.commit();
|
|
233
|
+
this.onTouched();
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
onThumbKeydown(event: KeyboardEvent, thumb: Thumb): void {
|
|
237
|
+
if (this.isDisabled()) return;
|
|
238
|
+
const before = this.current(thumb);
|
|
239
|
+
let next: number;
|
|
240
|
+
switch (event.key) {
|
|
241
|
+
case 'ArrowLeft': case 'ArrowDown': next = this.stepped(before, -1); break;
|
|
242
|
+
case 'ArrowRight': case 'ArrowUp': next = this.stepped(before, 1); break;
|
|
243
|
+
case 'Home': next = this.effectiveMin(); break;
|
|
244
|
+
case 'End': next = this.effectiveMax(); break;
|
|
245
|
+
case 'PageDown': next = this.snap(before - 10 * this.effectiveStep()); break;
|
|
246
|
+
case 'PageUp': next = this.snap(before + 10 * this.effectiveStep()); break;
|
|
247
|
+
default: return;
|
|
248
|
+
}
|
|
249
|
+
event.preventDefault();
|
|
250
|
+
this.setThumb(thumb, next);
|
|
251
|
+
if (this.current(thumb) !== before) this.commit();
|
|
252
|
+
this.onTouched();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
onPointerDown(event: PointerEvent): void {
|
|
256
|
+
if (this.isDisabled() || event.button !== 0 || this.draggingPointerId !== null) return;
|
|
257
|
+
const rail = this.rail()?.nativeElement;
|
|
258
|
+
const track = this.track()?.nativeElement;
|
|
259
|
+
if (!rail || !track) return;
|
|
260
|
+
const rect = rail.getBoundingClientRect();
|
|
261
|
+
const position = Math.max(0, Math.min(1, (event.clientX - rect.left) / Math.max(1, rect.width)));
|
|
262
|
+
const clicked = (event.target as Element).closest<HTMLElement>('[data-thumb]')?.dataset['thumb'] as Thumb | undefined;
|
|
263
|
+
const thumb: Thumb = this.mode() === 'single' ? 'single' : clicked === 'start' || clicked === 'end' ? clicked
|
|
264
|
+
: Math.abs(position * 100 - this.startPercent()) <= Math.abs(position * 100 - this.endPercent()) ? 'start' : 'end';
|
|
265
|
+
this.dragging = thumb;
|
|
266
|
+
this.draggingPointerId = event.pointerId;
|
|
267
|
+
this.dragOffsetX = clicked ? event.clientX - (rect.left + rect.width * this.percent(this.current(thumb)) / 100) : 0;
|
|
268
|
+
this.dragStart = this.mode() === 'single' ? this.displayValue() : this.displayRange();
|
|
269
|
+
if (thumb !== 'single') this.activeThumb.set(thumb);
|
|
270
|
+
track.setPointerCapture(event.pointerId);
|
|
271
|
+
track.querySelector<HTMLElement>(`[data-thumb="${thumb}"]`)?.focus();
|
|
272
|
+
if (!clicked) this.setThumb(thumb, this.effectiveMin() + position * (this.effectiveMax() - this.effectiveMin()));
|
|
273
|
+
event.preventDefault();
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
onPointerMove(event: PointerEvent): void {
|
|
277
|
+
if (!this.dragging || event.pointerId !== this.draggingPointerId) return;
|
|
278
|
+
const rect = this.rail()?.nativeElement.getBoundingClientRect();
|
|
279
|
+
if (!rect) return;
|
|
280
|
+
const position = Math.max(0, Math.min(1, (event.clientX - this.dragOffsetX - rect.left) / Math.max(1, rect.width)));
|
|
281
|
+
this.setThumb(this.dragging, this.effectiveMin() + position * (this.effectiveMax() - this.effectiveMin()));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
onPointerUp(event: PointerEvent): void {
|
|
285
|
+
if (!this.dragging || event.pointerId !== this.draggingPointerId) return;
|
|
286
|
+
const track = this.track()?.nativeElement;
|
|
287
|
+
if (track?.hasPointerCapture(event.pointerId)) track.releasePointerCapture(event.pointerId);
|
|
288
|
+
const current = this.mode() === 'single' ? this.displayValue() : this.displayRange();
|
|
289
|
+
if (typeof current === 'number' ? current !== this.dragStart
|
|
290
|
+
: typeof this.dragStart !== 'number' && this.dragStart !== null && (current.start !== this.dragStart.start || current.end !== this.dragStart.end)) this.commit();
|
|
291
|
+
this.dragging = null;
|
|
292
|
+
this.draggingPointerId = null;
|
|
293
|
+
this.dragOffsetX = 0;
|
|
294
|
+
this.dragStart = null;
|
|
295
|
+
this.onTouched();
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
valueText(value: number): string {
|
|
299
|
+
return this.ticks().find(tick => tick.value === value)?.label ?? String(value);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
private commit(): void { this.changeCommitted.emit(this.mode() === 'single' ? this.displayValue() : this.displayRange()); }
|
|
303
|
+
|
|
304
|
+
writeValue(value: number | GoodRangeSliderRange | null): void {
|
|
305
|
+
if (typeof value === 'number') this.value.set(this.snap(value));
|
|
306
|
+
else if (value && typeof value === 'object') this.rangeValue.set(this.normalizeRange(value));
|
|
307
|
+
}
|
|
308
|
+
registerOnChange(fn: (value: number | GoodRangeSliderRange) => void): void { this.onChange = fn; }
|
|
309
|
+
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
|
|
310
|
+
setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); }
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
let nextRangeSliderId = 0;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, computed, forwardRef, input, model, signal } from '@angular/core';
|
|
2
|
+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
3
|
+
import { LucideDynamicIcon, LucideHeart, LucideStar, LucideThumbsUp } from '@lucide/angular';
|
|
4
|
+
import { GoodButtonIcon } from './models';
|
|
5
|
+
|
|
6
|
+
export type GoodRatingSize = 'small' | 'default' | 'large';
|
|
7
|
+
export type GoodRatingIcon = 'star' | 'heart' | 'thumbs-up';
|
|
8
|
+
|
|
9
|
+
let nextRatingId = 0;
|
|
10
|
+
|
|
11
|
+
@Component({
|
|
12
|
+
selector: 'good-rating',
|
|
13
|
+
standalone: true,
|
|
14
|
+
imports: [LucideDynamicIcon],
|
|
15
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
16
|
+
providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodRatingComponent), multi: true }],
|
|
17
|
+
host: { class: 'good-rating' },
|
|
18
|
+
template: `
|
|
19
|
+
@if (readonly()) {
|
|
20
|
+
<div class="good-rating-row" [class.good-rating-fillable]="!customIcon()" [attr.data-icon]="customIcon() ? 'custom' : icon()"
|
|
21
|
+
[style.--good-rating-active-color]="selectedColor() || null" [attr.data-size]="size()" [attr.data-disabled]="isDisabled()"
|
|
22
|
+
role="img" [attr.aria-label]="description()">
|
|
23
|
+
@for (number of positions(); track number) {
|
|
24
|
+
<span class="good-rating-item" [class.good-rating-selected]="number <= selected()">
|
|
25
|
+
<svg [lucideIcon]="iconData()" [size]="iconSize()" aria-hidden="true"></svg>
|
|
26
|
+
</span>
|
|
27
|
+
}
|
|
28
|
+
</div>
|
|
29
|
+
} @else {
|
|
30
|
+
<fieldset class="good-rating-fieldset" [disabled]="isDisabled()" [attr.aria-describedby]="describedBy() || null">
|
|
31
|
+
<legend class="good-sr-only">{{ label() }}</legend>
|
|
32
|
+
<div class="good-rating-row" [class.good-rating-fillable]="!customIcon()" [attr.data-icon]="customIcon() ? 'custom' : icon()"
|
|
33
|
+
[style.--good-rating-active-color]="selectedColor() || null" [attr.data-size]="size()" [attr.data-disabled]="isDisabled()" (mouseleave)="hovered.set(null)">
|
|
34
|
+
@for (number of positions(); track number) {
|
|
35
|
+
<label class="good-rating-item" [class.good-rating-selected]="number <= (hovered() ?? selected())" (mouseenter)="preview(number)">
|
|
36
|
+
<input type="radio" class="good-rating-input" [name]="groupName" [value]="number"
|
|
37
|
+
[checked]="selected() === number" [disabled]="isDisabled()"
|
|
38
|
+
[attr.aria-label]="number + ' of ' + total()" (change)="select(number)" (blur)="onBlur()" />
|
|
39
|
+
<svg [lucideIcon]="iconData()" [size]="iconSize()" aria-hidden="true"></svg>
|
|
40
|
+
</label>
|
|
41
|
+
}
|
|
42
|
+
</div>
|
|
43
|
+
</fieldset>
|
|
44
|
+
}
|
|
45
|
+
`,
|
|
46
|
+
})
|
|
47
|
+
export class GoodRatingComponent implements ControlValueAccessor {
|
|
48
|
+
readonly value = model(1);
|
|
49
|
+
readonly count = input(5);
|
|
50
|
+
readonly icon = input<GoodRatingIcon>('star');
|
|
51
|
+
readonly customIcon = input<GoodButtonIcon>();
|
|
52
|
+
readonly selectedColor = input('');
|
|
53
|
+
readonly size = input<GoodRatingSize>('default');
|
|
54
|
+
readonly readonly = input(false);
|
|
55
|
+
readonly disabled = input(false);
|
|
56
|
+
readonly label = input('Rating');
|
|
57
|
+
readonly describedBy = input('');
|
|
58
|
+
readonly groupName = `good-rating-${++nextRatingId}`;
|
|
59
|
+
private readonly formDisabled = signal(false);
|
|
60
|
+
readonly hovered = signal<number | null>(null);
|
|
61
|
+
readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
62
|
+
readonly total = computed(() => Number.isFinite(this.count()) ? Math.max(1, Math.floor(this.count())) : 5);
|
|
63
|
+
readonly selected = computed(() => Number.isFinite(this.value()) ? Math.min(this.total(), Math.max(1, Math.floor(this.value()))) : 1);
|
|
64
|
+
readonly positions = computed(() => Array.from({ length: this.total() }, (_, index) => index + 1));
|
|
65
|
+
readonly iconData = computed<GoodButtonIcon>(() => this.customIcon() ?? ({ star: LucideStar, heart: LucideHeart, 'thumbs-up': LucideThumbsUp })[this.icon()]);
|
|
66
|
+
readonly iconSize = computed(() => ({ small: 16, default: 20, large: 24 })[this.size()]);
|
|
67
|
+
readonly description = computed(() => `${this.label()}: ${this.selected()} of ${this.total()}`);
|
|
68
|
+
private onChange: (value: number) => void = () => {};
|
|
69
|
+
private onTouched: () => void = () => {};
|
|
70
|
+
|
|
71
|
+
select(number: number): void {
|
|
72
|
+
if (this.isDisabled() || this.readonly()) return;
|
|
73
|
+
const next = Math.min(this.total(), Math.max(1, Math.floor(number)));
|
|
74
|
+
this.value.set(next);
|
|
75
|
+
this.onChange(next);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
preview(number: number): void {
|
|
79
|
+
if (!this.isDisabled()) this.hovered.set(number);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
onBlur(): void { this.onTouched(); }
|
|
83
|
+
writeValue(value: unknown): void {
|
|
84
|
+
const number = typeof value === 'number' && Number.isFinite(value) ? value : 1;
|
|
85
|
+
this.value.set(Math.min(this.total(), Math.max(1, Math.floor(number))));
|
|
86
|
+
}
|
|
87
|
+
registerOnChange(fn: (value: number) => void): void { this.onChange = fn; }
|
|
88
|
+
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
|
|
89
|
+
setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); }
|
|
90
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, ElementRef, OnDestroy, AfterViewInit, booleanAttribute, computed, inject, input, model, output, signal } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
export type GoodResizableOrientation = 'auto' | 'horizontal' | 'vertical';
|
|
4
|
+
export type GoodResizableHandle = 'grip' | 'line' | 'dots' | 'chevrons';
|
|
5
|
+
|
|
6
|
+
let nextResizableId = 0;
|
|
7
|
+
|
|
8
|
+
/** One of the two projected regions. Use side="start" and side="end" once each. */
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'good-resizable-pane',
|
|
11
|
+
standalone: true,
|
|
12
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
13
|
+
host: { class: 'good-resizable-pane', '[attr.data-padding]': 'padding()' },
|
|
14
|
+
template: '<ng-content />',
|
|
15
|
+
})
|
|
16
|
+
export class GoodResizablePaneComponent {
|
|
17
|
+
/** Use none for an edge-to-edge map, editor, or calendar. */
|
|
18
|
+
readonly padding = input<'default' | 'none'>('default');
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Two scrollable panes separated by a pointer- and keyboard-operable divider. */
|
|
22
|
+
@Component({
|
|
23
|
+
selector: 'good-resizable',
|
|
24
|
+
standalone: true,
|
|
25
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
26
|
+
host: {
|
|
27
|
+
class: 'good-resizable',
|
|
28
|
+
'[attr.data-direction]': 'direction()',
|
|
29
|
+
'[attr.data-handle]': 'handle()',
|
|
30
|
+
'[attr.data-disabled]': 'disabled()',
|
|
31
|
+
'[style.height]': 'height()',
|
|
32
|
+
'[style.--good-resizable-start]': 'startTrack()',
|
|
33
|
+
'[style.--good-resizable-end]': 'endTrack()',
|
|
34
|
+
},
|
|
35
|
+
template: `
|
|
36
|
+
<div class="good-resizable-region" [id]="startId"><ng-content select="good-resizable-pane[side=start]" /></div>
|
|
37
|
+
<div class="good-resizable-separator" role="separator"
|
|
38
|
+
[attr.tabindex]="disabled() ? -1 : 0"
|
|
39
|
+
[attr.aria-label]="ariaLabel()"
|
|
40
|
+
[attr.aria-controls]="startId"
|
|
41
|
+
[attr.aria-orientation]="direction() === 'horizontal' ? 'vertical' : 'horizontal'"
|
|
42
|
+
[attr.aria-valuenow]="effectiveSplit()"
|
|
43
|
+
[attr.aria-valuemin]="bounds().min"
|
|
44
|
+
[attr.aria-valuemax]="bounds().max"
|
|
45
|
+
[attr.aria-disabled]="disabled()"
|
|
46
|
+
(pointerdown)="onPointerDown($event)" (pointermove)="onPointerMove($event)"
|
|
47
|
+
(pointerup)="onPointerEnd($event)" (pointercancel)="onPointerEnd($event)"
|
|
48
|
+
(keydown)="onKeydown($event)" (dblclick)="reset()">
|
|
49
|
+
<span class="good-resizable-handle" aria-hidden="true">
|
|
50
|
+
@if (handle() === 'chevrons') { <span class="good-resizable-chevron good-resizable-chevron-first"></span><span class="good-resizable-chevron good-resizable-chevron-last"></span> }
|
|
51
|
+
@else if (handle() === 'grip' || handle() === 'dots') { <span></span><span></span><span></span> }
|
|
52
|
+
</span>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="good-resizable-region" [id]="endId"><ng-content select="good-resizable-pane[side=end]" /></div>
|
|
55
|
+
`,
|
|
56
|
+
})
|
|
57
|
+
export class GoodResizableComponent implements AfterViewInit, OnDestroy {
|
|
58
|
+
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
|
59
|
+
private observer?: ResizeObserver;
|
|
60
|
+
private drag?: { id: number; coordinate: number; split: number; available: number; direction: 'horizontal' | 'vertical' };
|
|
61
|
+
private readonly width = signal(0);
|
|
62
|
+
private readonly uid = ++nextResizableId;
|
|
63
|
+
readonly startId = `good-resizable-start-${this.uid}`;
|
|
64
|
+
readonly endId = `good-resizable-end-${this.uid}`;
|
|
65
|
+
|
|
66
|
+
/** Percentage of the first pane; supports [(split)] and programmatic updates. */
|
|
67
|
+
readonly split = model(50);
|
|
68
|
+
readonly orientation = input<GoodResizableOrientation>('auto');
|
|
69
|
+
readonly handle = input<GoodResizableHandle>('grip');
|
|
70
|
+
readonly height = input('min(70dvh, 560px)');
|
|
71
|
+
readonly minSplit = input(20);
|
|
72
|
+
readonly maxSplit = input(80);
|
|
73
|
+
readonly disabled = input(false, { transform: booleanAttribute });
|
|
74
|
+
readonly ariaLabel = input('Resize panels');
|
|
75
|
+
/** Emitted once when a pointer drag or keyboard adjustment finishes. */
|
|
76
|
+
readonly splitChangeEnd = output<number>();
|
|
77
|
+
|
|
78
|
+
readonly direction = computed<'horizontal' | 'vertical'>(() => {
|
|
79
|
+
const setting = this.orientation();
|
|
80
|
+
return setting === 'auto' ? (this.width() > 0 && this.width() < 680 ? 'vertical' : 'horizontal') : setting;
|
|
81
|
+
});
|
|
82
|
+
readonly bounds = computed(() => {
|
|
83
|
+
const min = Number.isFinite(this.minSplit()) ? Math.max(0, Math.min(100, this.minSplit())) : 20;
|
|
84
|
+
const max = Number.isFinite(this.maxSplit()) ? Math.max(min, Math.min(100, this.maxSplit())) : 80;
|
|
85
|
+
return { min, max };
|
|
86
|
+
});
|
|
87
|
+
readonly effectiveSplit = computed(() => this.clamp(this.split()));
|
|
88
|
+
readonly startTrack = computed(() => `${this.effectiveSplit()}fr`);
|
|
89
|
+
readonly endTrack = computed(() => `${100 - this.effectiveSplit()}fr`);
|
|
90
|
+
|
|
91
|
+
ngAfterViewInit(): void {
|
|
92
|
+
this.width.set(this.host.nativeElement.clientWidth);
|
|
93
|
+
if (typeof ResizeObserver !== 'undefined') {
|
|
94
|
+
this.observer = new ResizeObserver(entries => this.width.set(entries[0]?.contentRect.width ?? 0));
|
|
95
|
+
this.observer.observe(this.host.nativeElement);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
ngOnDestroy(): void { this.observer?.disconnect(); }
|
|
100
|
+
|
|
101
|
+
onPointerDown(event: PointerEvent): void {
|
|
102
|
+
if (this.disabled() || event.button !== 0) return;
|
|
103
|
+
const direction = this.direction();
|
|
104
|
+
const rect = this.host.nativeElement.getBoundingClientRect();
|
|
105
|
+
const separator = event.currentTarget as HTMLElement;
|
|
106
|
+
const available = (direction === 'horizontal' ? rect.width - separator.offsetWidth : rect.height - separator.offsetHeight);
|
|
107
|
+
if (available <= 0) return;
|
|
108
|
+
this.drag = { id: event.pointerId, coordinate: direction === 'horizontal' ? event.clientX : event.clientY,
|
|
109
|
+
split: this.effectiveSplit(), available, direction };
|
|
110
|
+
separator.setPointerCapture(event.pointerId);
|
|
111
|
+
this.host.nativeElement.classList.add('good-resizable-dragging');
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
onPointerMove(event: PointerEvent): void {
|
|
116
|
+
const drag = this.drag;
|
|
117
|
+
if (!drag || drag.id !== event.pointerId) return;
|
|
118
|
+
if (drag.direction !== this.direction()) { this.finishDrag(); return; }
|
|
119
|
+
const coordinate = drag.direction === 'horizontal' ? event.clientX : event.clientY;
|
|
120
|
+
this.split.set(Math.round(this.clamp(drag.split + (coordinate - drag.coordinate) * 100 / drag.available) * 10) / 10);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
onPointerEnd(event: PointerEvent): void {
|
|
124
|
+
if (this.drag?.id !== event.pointerId) return;
|
|
125
|
+
const separator = event.currentTarget as HTMLElement;
|
|
126
|
+
if (separator.hasPointerCapture(event.pointerId)) separator.releasePointerCapture(event.pointerId);
|
|
127
|
+
this.finishDrag();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
onKeydown(event: KeyboardEvent): void {
|
|
131
|
+
if (this.disabled()) return;
|
|
132
|
+
const direction = this.direction();
|
|
133
|
+
const step = event.shiftKey ? 10 : 2;
|
|
134
|
+
let next: number;
|
|
135
|
+
switch (event.key) {
|
|
136
|
+
case 'ArrowLeft': if (direction !== 'horizontal') return; next = this.effectiveSplit() - step; break;
|
|
137
|
+
case 'ArrowRight': if (direction !== 'horizontal') return; next = this.effectiveSplit() + step; break;
|
|
138
|
+
case 'ArrowUp': if (direction !== 'vertical') return; next = this.effectiveSplit() - step; break;
|
|
139
|
+
case 'ArrowDown': if (direction !== 'vertical') return; next = this.effectiveSplit() + step; break;
|
|
140
|
+
case 'Home': next = this.bounds().min; break;
|
|
141
|
+
case 'End': next = this.bounds().max; break;
|
|
142
|
+
default: return;
|
|
143
|
+
}
|
|
144
|
+
event.preventDefault();
|
|
145
|
+
if (next !== this.effectiveSplit()) {
|
|
146
|
+
this.split.set(this.clamp(next));
|
|
147
|
+
this.splitChangeEnd.emit(this.effectiveSplit());
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
reset(): void {
|
|
152
|
+
if (this.disabled()) return;
|
|
153
|
+
this.split.set(this.clamp(50));
|
|
154
|
+
this.splitChangeEnd.emit(this.effectiveSplit());
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
private finishDrag(): void {
|
|
158
|
+
if (!this.drag) return;
|
|
159
|
+
this.drag = undefined;
|
|
160
|
+
this.host.nativeElement.classList.remove('good-resizable-dragging');
|
|
161
|
+
this.splitChangeEnd.emit(this.effectiveSplit());
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private clamp(value: number): number {
|
|
165
|
+
const { min, max } = this.bounds();
|
|
166
|
+
return Math.max(min, Math.min(max, Number.isFinite(value) ? value : 50));
|
|
167
|
+
}
|
|
168
|
+
}
|