@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,199 @@
|
|
|
1
|
+
import { DOCUMENT } from '@angular/common';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, Injectable, effect, inject, input, model, output, viewChild } from '@angular/core';
|
|
3
|
+
import { LucideX } from '@lucide/angular';
|
|
4
|
+
import { GoodButtonComponent } from './button';
|
|
5
|
+
|
|
6
|
+
export type GoodModalSize = 'small' | 'default' | 'large';
|
|
7
|
+
export type GoodModalPresentation = 'dialog' | 'fullwidth' | 'overlay';
|
|
8
|
+
export type GoodModalDismissReason = 'close-button' | 'escape' | 'backdrop' | 'native';
|
|
9
|
+
|
|
10
|
+
let nextModalId = 0;
|
|
11
|
+
|
|
12
|
+
@Injectable({ providedIn: 'root' })
|
|
13
|
+
class GoodModalStackService {
|
|
14
|
+
private readonly document = inject(DOCUMENT);
|
|
15
|
+
private readonly stack: GoodModalComponent[] = [];
|
|
16
|
+
private previousOverflow: string | null = null;
|
|
17
|
+
|
|
18
|
+
activate(modal: GoodModalComponent): void {
|
|
19
|
+
if (this.stack.includes(modal)) return;
|
|
20
|
+
modal.rememberOrigin(this.document.activeElement);
|
|
21
|
+
if (this.stack.length === 0) {
|
|
22
|
+
this.previousOverflow = this.document.documentElement.style.overflow;
|
|
23
|
+
this.document.documentElement.style.overflow = 'hidden';
|
|
24
|
+
} else {
|
|
25
|
+
this.stack.at(-1)?.suspend();
|
|
26
|
+
}
|
|
27
|
+
this.stack.push(modal);
|
|
28
|
+
modal.show(false);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
deactivate(modal: GoodModalComponent): void {
|
|
32
|
+
const index = this.stack.indexOf(modal);
|
|
33
|
+
if (index < 0) return;
|
|
34
|
+
const wasTop = index === this.stack.length - 1;
|
|
35
|
+
this.stack.splice(index, 1);
|
|
36
|
+
modal.hide();
|
|
37
|
+
if (!wasTop) return;
|
|
38
|
+
const previous = this.stack.at(-1);
|
|
39
|
+
if (previous) {
|
|
40
|
+
previous.show(true);
|
|
41
|
+
} else {
|
|
42
|
+
this.document.documentElement.style.overflow = this.previousOverflow ?? '';
|
|
43
|
+
this.previousOverflow = null;
|
|
44
|
+
modal.restoreOrigin();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@Component({
|
|
50
|
+
selector: 'good-modal',
|
|
51
|
+
standalone: true,
|
|
52
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
53
|
+
host: { class: 'good-modal' },
|
|
54
|
+
template: `
|
|
55
|
+
<dialog #dialog class="good-modal-dialog" tabindex="-1" [attr.aria-labelledby]="titleId"
|
|
56
|
+
[attr.data-size]="size()" [attr.data-presentation]="presentation()"
|
|
57
|
+
[attr.data-blur]="blurBackground()" [attr.data-scroll]="scrollBody() ? 'body' : 'dialog'"
|
|
58
|
+
(cancel)="onCancel($event)" (close)="onNativeClose()" (click)="onDialogClick($event)">
|
|
59
|
+
<div class="good-modal-panel">
|
|
60
|
+
<ng-content select="good-modal-header" />
|
|
61
|
+
<div class="good-modal-body"><ng-content /></div>
|
|
62
|
+
<ng-content select="good-modal-footer" />
|
|
63
|
+
</div>
|
|
64
|
+
</dialog>
|
|
65
|
+
`,
|
|
66
|
+
})
|
|
67
|
+
export class GoodModalComponent {
|
|
68
|
+
private readonly document = inject(DOCUMENT);
|
|
69
|
+
private readonly stack = inject(GoodModalStackService);
|
|
70
|
+
private readonly dialog = viewChild<ElementRef<HTMLDialogElement>>('dialog');
|
|
71
|
+
private returnFocus: HTMLElement | null = null;
|
|
72
|
+
private suspendedFocus: HTMLElement | null = null;
|
|
73
|
+
private skippedCloseEvents = 0;
|
|
74
|
+
|
|
75
|
+
readonly titleId = `good-modal-title-${++nextModalId}`;
|
|
76
|
+
readonly open = model(false);
|
|
77
|
+
readonly size = input<GoodModalSize>('default');
|
|
78
|
+
readonly presentation = input<GoodModalPresentation>('dialog');
|
|
79
|
+
readonly blurBackground = input(true);
|
|
80
|
+
readonly scrollBody = input(false);
|
|
81
|
+
readonly closeOnBackdrop = input(true);
|
|
82
|
+
readonly dismissed = output<GoodModalDismissReason>();
|
|
83
|
+
|
|
84
|
+
constructor() {
|
|
85
|
+
effect(() => {
|
|
86
|
+
if (!this.dialog()) return;
|
|
87
|
+
if (this.open()) this.stack.activate(this);
|
|
88
|
+
else this.stack.deactivate(this);
|
|
89
|
+
});
|
|
90
|
+
inject(DestroyRef).onDestroy(() => this.stack.deactivate(this));
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
rememberOrigin(element: Element | null): void {
|
|
94
|
+
this.returnFocus = element && 'focus' in element ? element as HTMLElement : null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
suspend(): void {
|
|
98
|
+
const dialog = this.dialog()?.nativeElement;
|
|
99
|
+
if (!dialog?.open) return;
|
|
100
|
+
const active = this.document.activeElement;
|
|
101
|
+
this.suspendedFocus = active && 'focus' in active && dialog.contains(active) ? active as HTMLElement : null;
|
|
102
|
+
this.hide();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
show(resume: boolean): void {
|
|
106
|
+
const dialog = this.dialog()?.nativeElement;
|
|
107
|
+
if (!dialog || dialog.open) return;
|
|
108
|
+
dialog.showModal();
|
|
109
|
+
queueMicrotask(() => {
|
|
110
|
+
if (!dialog.open) return;
|
|
111
|
+
if (resume && this.suspendedFocus?.isConnected && dialog.contains(this.suspendedFocus)) {
|
|
112
|
+
this.suspendedFocus.focus();
|
|
113
|
+
} else {
|
|
114
|
+
this.focusFirst(dialog);
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
hide(): void {
|
|
120
|
+
const dialog = this.dialog()?.nativeElement;
|
|
121
|
+
if (!dialog?.open) return;
|
|
122
|
+
this.skippedCloseEvents++;
|
|
123
|
+
dialog.close();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
restoreOrigin(): void {
|
|
127
|
+
const origin = this.returnFocus;
|
|
128
|
+
queueMicrotask(() => { if (origin?.isConnected) origin.focus(); });
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
close(reason: GoodModalDismissReason = 'close-button'): void {
|
|
132
|
+
if (!this.open()) return;
|
|
133
|
+
this.open.set(false);
|
|
134
|
+
this.dismissed.emit(reason);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
onCancel(event: Event): void {
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
this.close('escape');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
onDialogClick(event: MouseEvent): void {
|
|
143
|
+
if (event.target === this.dialog()?.nativeElement && this.closeOnBackdrop()) this.close('backdrop');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
onNativeClose(): void {
|
|
147
|
+
if (this.skippedCloseEvents > 0) {
|
|
148
|
+
this.skippedCloseEvents--;
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
this.close('native');
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
private focusFirst(dialog: HTMLDialogElement): void {
|
|
155
|
+
const selector = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
156
|
+
const first = [...dialog.querySelectorAll<HTMLElement>(selector)]
|
|
157
|
+
.find(element => element.tabIndex >= 0 && element.getClientRects().length > 0);
|
|
158
|
+
(first ?? dialog).focus();
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@Component({
|
|
163
|
+
selector: 'good-modal-header',
|
|
164
|
+
standalone: true,
|
|
165
|
+
imports: [GoodButtonComponent],
|
|
166
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
167
|
+
host: { class: 'good-modal-header' },
|
|
168
|
+
template: `
|
|
169
|
+
<header class="good-modal-header-content">
|
|
170
|
+
<div class="good-modal-header-copy">
|
|
171
|
+
<h2 class="good-modal-title" [id]="modal.titleId">{{ title() }}</h2>
|
|
172
|
+
@if (description()) { <p class="good-modal-description">{{ description() }}</p> }
|
|
173
|
+
</div>
|
|
174
|
+
<ng-content select="[goodModalHeaderActions]" />
|
|
175
|
+
@if (closable()) {
|
|
176
|
+
<good-button class="good-modal-close" variant="ghost" size="small" [icon]="closeIcon" [iconOnly]="true"
|
|
177
|
+
ariaLabel="Close dialog" (click)="modal.close('close-button')" />
|
|
178
|
+
}
|
|
179
|
+
</header>
|
|
180
|
+
`,
|
|
181
|
+
})
|
|
182
|
+
export class GoodModalHeaderComponent {
|
|
183
|
+
readonly modal = inject(GoodModalComponent);
|
|
184
|
+
readonly closeIcon = LucideX;
|
|
185
|
+
readonly title = input.required<string>();
|
|
186
|
+
readonly description = input('');
|
|
187
|
+
readonly closable = input(true);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
@Component({
|
|
191
|
+
selector: 'good-modal-footer',
|
|
192
|
+
standalone: true,
|
|
193
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
194
|
+
host: { class: 'good-modal-footer' },
|
|
195
|
+
template: `<footer class="good-modal-footer-content" [attr.data-align]="align()"><ng-content /></footer>`,
|
|
196
|
+
})
|
|
197
|
+
export class GoodModalFooterComponent {
|
|
198
|
+
readonly align = input<'start' | 'end' | 'between'>('end');
|
|
199
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import type { LucideIcon, LucideIconData } from '@lucide/angular';
|
|
2
|
+
|
|
3
|
+
export type GoodButtonIcon = LucideIcon | LucideIconData;
|
|
4
|
+
export type GoodButtonVariant = 'default' | 'secondary' | 'destructive' | 'outline' | 'ghost';
|
|
5
|
+
export type GoodButtonSize = 'small' | 'default' | 'large';
|
|
6
|
+
|
|
7
|
+
export interface GoodNavItem {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
icon?: GoodIconName;
|
|
11
|
+
route?: string;
|
|
12
|
+
/** Use exact for an overview route that is also the prefix of sibling pages. */
|
|
13
|
+
activeMatch?: 'exact' | 'prefix';
|
|
14
|
+
badge?: string;
|
|
15
|
+
children?: readonly GoodNavItem[];
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface GoodSidebarSection {
|
|
20
|
+
id: string;
|
|
21
|
+
heading?: string;
|
|
22
|
+
items: readonly GoodNavItem[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface GoodTopbarItem {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
icon?: GoodIconName;
|
|
29
|
+
route?: string;
|
|
30
|
+
children?: readonly GoodTopbarItem[];
|
|
31
|
+
separatorBefore?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface GoodSubnavItem {
|
|
35
|
+
id: string;
|
|
36
|
+
label: string;
|
|
37
|
+
route?: string;
|
|
38
|
+
children?: readonly GoodSubnavItem[];
|
|
39
|
+
disabled?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface GoodSubnavAction {
|
|
43
|
+
id: string;
|
|
44
|
+
label: string;
|
|
45
|
+
icon?: GoodButtonIcon;
|
|
46
|
+
iconOnly?: boolean;
|
|
47
|
+
variant?: GoodButtonVariant;
|
|
48
|
+
size?: GoodButtonSize;
|
|
49
|
+
route?: string;
|
|
50
|
+
action?: () => void;
|
|
51
|
+
menuItems?: readonly GoodMenuAction[];
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface GoodUser {
|
|
55
|
+
name: string;
|
|
56
|
+
email?: string;
|
|
57
|
+
initials?: string;
|
|
58
|
+
avatarUrl?: string;
|
|
59
|
+
badge?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface GoodNotification {
|
|
63
|
+
id: string;
|
|
64
|
+
title: string;
|
|
65
|
+
description?: string;
|
|
66
|
+
/** Creation time in Unix milliseconds. Enables chronological sorting and localized date/time display. */
|
|
67
|
+
createdAt?: number;
|
|
68
|
+
/** Legacy display text used when createdAt is unavailable. */
|
|
69
|
+
time?: string;
|
|
70
|
+
read?: boolean;
|
|
71
|
+
route?: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface GoodMenuAction {
|
|
75
|
+
id: string;
|
|
76
|
+
label: string;
|
|
77
|
+
icon?: GoodIconName;
|
|
78
|
+
route?: string;
|
|
79
|
+
action?: () => void;
|
|
80
|
+
children?: readonly GoodMenuAction[];
|
|
81
|
+
detail?: string;
|
|
82
|
+
separatorBefore?: boolean;
|
|
83
|
+
variant?: 'default' | 'sign-out';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface GoodSearchItem {
|
|
87
|
+
id: string;
|
|
88
|
+
label: string;
|
|
89
|
+
description?: string;
|
|
90
|
+
route: string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export type GoodIconName =
|
|
94
|
+
| 'dashboard' | 'account' | 'network' | 'home' | 'settings'
|
|
95
|
+
| 'search' | 'bell' | 'menu' | 'close' | 'chevron-down'
|
|
96
|
+
| 'chevron-right' | 'sun' | 'moon' | 'monitor' | 'grid' | 'logout'
|
|
97
|
+
| 'calendar' | 'question' | 'card' | 'book' | 'contact' | 'star' | 'message' | 'globe' | 'check';
|
|
98
|
+
|
|
99
|
+
export function goodRouteActive(route: string | undefined, current: string, activeMatch: 'exact' | 'prefix' = 'prefix'): boolean {
|
|
100
|
+
if (!route) return false;
|
|
101
|
+
const normalized = route === '/' ? '/' : route.replace(/\/$/, '');
|
|
102
|
+
return current === normalized || (activeMatch === 'prefix' && normalized !== '/' && current.startsWith(`${normalized}/`));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function goodItemContainsRoute(item: GoodNavItem, current: string): boolean {
|
|
106
|
+
return goodRouteActive(item.route, current, item.activeMatch) || !!item.children?.some(child => goodItemContainsRoute(child, current));
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function goodTopbarItemContainsRoute(item: GoodTopbarItem, current: string): boolean {
|
|
110
|
+
return goodRouteActive(item.route, current) || !!item.children?.some(child => goodTopbarItemContainsRoute(child, current));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function goodSubnavItemContainsRoute(item: GoodSubnavItem, current: string): boolean {
|
|
114
|
+
return goodRouteActive(item.route, current) || !!item.children?.some(child => goodSubnavItemContainsRoute(child, current));
|
|
115
|
+
}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ChangeDetectionStrategy, Component, ElementRef, LOCALE_ID, computed, inject,
|
|
3
|
+
input, model, output, signal, viewChild,
|
|
4
|
+
} from '@angular/core';
|
|
5
|
+
import { GOOD_MARKER_COLORS, GoodMarkerColor } from './marker-colors';
|
|
6
|
+
|
|
7
|
+
export type GoodMonthCalendarSelectionMode = 'day' | 'week';
|
|
8
|
+
export type GoodMonthCalendarOrientation = 'horizontal' | 'vertical';
|
|
9
|
+
|
|
10
|
+
export interface GoodMonthCalendarHighlight {
|
|
11
|
+
date: string;
|
|
12
|
+
color: GoodMarkerColor;
|
|
13
|
+
label?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface GoodMonthCalendarSelection {
|
|
17
|
+
mode: GoodMonthCalendarSelectionMode;
|
|
18
|
+
start: string;
|
|
19
|
+
endExclusive: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface MonthDay {
|
|
23
|
+
date: string;
|
|
24
|
+
number: number;
|
|
25
|
+
outside: boolean;
|
|
26
|
+
today: boolean;
|
|
27
|
+
highlight?: GoodMonthCalendarHighlight;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface MonthBlock {
|
|
31
|
+
key: string;
|
|
32
|
+
label: string;
|
|
33
|
+
days: MonthDay[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const pad = (value: number): string => String(value).padStart(2, '0');
|
|
37
|
+
const dayIso = (date: Date): string => `${String(date.getFullYear()).padStart(4, '0')}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`;
|
|
38
|
+
const monthIso = (date: Date): string => dayIso(date).slice(0, 7);
|
|
39
|
+
const makeDate = (year: number, month: number, day = 1): Date => {
|
|
40
|
+
const date = new Date(0);
|
|
41
|
+
date.setHours(12, 0, 0, 0);
|
|
42
|
+
date.setFullYear(year, month, day);
|
|
43
|
+
return date;
|
|
44
|
+
};
|
|
45
|
+
const addDays = (date: Date, days: number): Date => makeDate(date.getFullYear(), date.getMonth(), date.getDate() + days);
|
|
46
|
+
const parseDay = (value: string | null): Date | null => {
|
|
47
|
+
if (!value || !/^\d{4}-\d{2}-\d{2}$/.test(value)) return null;
|
|
48
|
+
const [year, month, day] = value.split('-').map(Number);
|
|
49
|
+
const date = makeDate(year, month - 1, day);
|
|
50
|
+
return year >= 1 && year <= 9999 && dayIso(date) === value ? date : null;
|
|
51
|
+
};
|
|
52
|
+
const parseMonth = (value: string): Date | null => {
|
|
53
|
+
if (!/^\d{4}-\d{2}$/.test(value)) return null;
|
|
54
|
+
const [year, month] = value.split('-').map(Number);
|
|
55
|
+
return year >= 1 && year <= 9999 && month >= 1 && month <= 12 ? makeDate(year, month - 1) : null;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
@Component({
|
|
59
|
+
selector: 'good-month-calendar',
|
|
60
|
+
standalone: true,
|
|
61
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
62
|
+
host: {
|
|
63
|
+
class: 'good-month-calendar',
|
|
64
|
+
'[attr.data-orientation]': 'orientation()',
|
|
65
|
+
'[attr.data-selection-mode]': 'selectionMode()',
|
|
66
|
+
'[attr.data-disabled]': 'disabled()',
|
|
67
|
+
'[style.--good-month-calendar-count]': 'visibleCount()',
|
|
68
|
+
},
|
|
69
|
+
template: `
|
|
70
|
+
<div class="good-month-calendar-frame">
|
|
71
|
+
<div class="good-month-calendar-toolbar">
|
|
72
|
+
<button type="button" class="good-month-calendar-nav" aria-label="Previous month"
|
|
73
|
+
[disabled]="disabled() || !canNavigate(-1)" (click)="navigate(-1)">
|
|
74
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m15 18-6-6 6-6" /></svg>
|
|
75
|
+
</button>
|
|
76
|
+
<button #yearTrigger type="button" class="good-month-calendar-year" aria-label="Choose year"
|
|
77
|
+
[disabled]="disabled()" [attr.aria-haspopup]="'dialog'" (click)="openYearPicker()">{{ anchor().getFullYear() }}</button>
|
|
78
|
+
<button type="button" class="good-month-calendar-nav" aria-label="Next month"
|
|
79
|
+
[disabled]="disabled() || !canNavigate(1)" (click)="navigate(1)">
|
|
80
|
+
<svg viewBox="0 0 24 24" aria-hidden="true"><path d="m9 18 6-6-6-6" /></svg>
|
|
81
|
+
</button>
|
|
82
|
+
</div>
|
|
83
|
+
<div class="good-month-calendar-blocks">
|
|
84
|
+
@for (block of blocks(); track block.key) {
|
|
85
|
+
<section class="good-month-calendar-block" [attr.aria-label]="block.label">
|
|
86
|
+
<h3 class="good-month-calendar-month">{{ block.label }}</h3>
|
|
87
|
+
<div class="good-month-calendar-weekdays" aria-hidden="true">
|
|
88
|
+
@for (name of weekdays(); track $index) { <span>{{ name }}</span> }
|
|
89
|
+
</div>
|
|
90
|
+
<div class="good-month-calendar-days">
|
|
91
|
+
@for (day of block.days; track day.date) {
|
|
92
|
+
<button type="button" class="good-month-calendar-day" [attr.data-date]="day.date"
|
|
93
|
+
[attr.data-outside]="day.outside" [attr.data-today]="day.today"
|
|
94
|
+
[attr.data-selected]="isSelected(day.date)" [attr.data-highlight]="!!day.highlight"
|
|
95
|
+
[style.--good-month-calendar-marker]="markerColor(day.highlight)"
|
|
96
|
+
[attr.aria-label]="dayLabel(day)" [attr.aria-pressed]="isSelected(day.date)"
|
|
97
|
+
[disabled]="disabled()" (click)="select(day.date)" (keydown)="onDayKeydown($event, day.date)">
|
|
98
|
+
<span class="good-month-calendar-number">{{ day.number }}</span>
|
|
99
|
+
@if (day.highlight) { <span class="good-month-calendar-dot" aria-hidden="true"></span> }
|
|
100
|
+
</button>
|
|
101
|
+
}
|
|
102
|
+
</div>
|
|
103
|
+
</section>
|
|
104
|
+
}
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
|
|
108
|
+
<dialog #yearDialog class="good-month-calendar-year-dialog" aria-label="Choose year" (close)="onYearDialogClose()"
|
|
109
|
+
(click)="onYearDialogClick($event)">
|
|
110
|
+
<div class="good-month-calendar-year-content">
|
|
111
|
+
<h2>Choose year</h2>
|
|
112
|
+
<div class="good-month-calendar-year-options">
|
|
113
|
+
@for (year of yearOptions(); track year) {
|
|
114
|
+
<button type="button" [attr.aria-current]="year === anchor().getFullYear() ? 'date' : null"
|
|
115
|
+
(click)="chooseYear(year)">{{ year }}</button>
|
|
116
|
+
}
|
|
117
|
+
</div>
|
|
118
|
+
<form (submit)="submitYear($event)">
|
|
119
|
+
<label for="{{ yearInputId }}">Enter a year</label>
|
|
120
|
+
<div class="good-month-calendar-year-entry">
|
|
121
|
+
<input #yearInput [id]="yearInputId" type="number" min="1" max="9999" step="1" inputmode="numeric"
|
|
122
|
+
[value]="anchor().getFullYear()" />
|
|
123
|
+
<button type="submit">Go</button>
|
|
124
|
+
</div>
|
|
125
|
+
</form>
|
|
126
|
+
<button type="button" class="good-month-calendar-year-cancel" (click)="closeYearPicker()">Cancel</button>
|
|
127
|
+
</div>
|
|
128
|
+
</dialog>
|
|
129
|
+
`,
|
|
130
|
+
})
|
|
131
|
+
export class GoodMonthCalendarComponent {
|
|
132
|
+
private static nextId = 0;
|
|
133
|
+
readonly yearInputId = `good-month-calendar-year-${++GoodMonthCalendarComponent.nextId}`;
|
|
134
|
+
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
|
135
|
+
private readonly angularLocale = inject(LOCALE_ID);
|
|
136
|
+
private readonly yearDialog = viewChild<ElementRef<HTMLDialogElement>>('yearDialog');
|
|
137
|
+
private readonly yearInput = viewChild<ElementRef<HTMLInputElement>>('yearInput');
|
|
138
|
+
private readonly yearTrigger = viewChild<ElementRef<HTMLButtonElement>>('yearTrigger');
|
|
139
|
+
|
|
140
|
+
readonly month = model(monthIso(new Date()));
|
|
141
|
+
readonly selected = model<string | null>(null);
|
|
142
|
+
readonly selectionMode = input<GoodMonthCalendarSelectionMode>('day');
|
|
143
|
+
readonly months = input(1);
|
|
144
|
+
readonly orientation = input<GoodMonthCalendarOrientation>('horizontal');
|
|
145
|
+
readonly weekStartsOn = input(1);
|
|
146
|
+
readonly locale = input('');
|
|
147
|
+
readonly highlights = input<readonly GoodMonthCalendarHighlight[]>([]);
|
|
148
|
+
readonly disabled = input(false);
|
|
149
|
+
readonly selectionChange = output<GoodMonthCalendarSelection>();
|
|
150
|
+
readonly monthChanged = output<string>();
|
|
151
|
+
readonly yearPickerOpen = signal(false);
|
|
152
|
+
|
|
153
|
+
readonly effectiveLocale = computed(() => this.locale() || (this.angularLocale !== 'en-US' ? this.angularLocale : (typeof navigator !== 'undefined' ? navigator.language : 'en-US')));
|
|
154
|
+
readonly anchor = computed(() => parseMonth(this.month()) ?? makeDate(new Date().getFullYear(), new Date().getMonth()));
|
|
155
|
+
readonly visibleCount = computed(() => Math.max(1, Math.min(12, Math.trunc(this.months()) || 1)));
|
|
156
|
+
readonly weekStart = computed(() => ((this.weekStartsOn() % 7) + 7) % 7);
|
|
157
|
+
readonly weekdays = computed(() => Array.from({ length: 7 }, (_, index) => {
|
|
158
|
+
const date = makeDate(2024, 0, 7 + (this.weekStart() + index) % 7);
|
|
159
|
+
return new Intl.DateTimeFormat(this.effectiveLocale(), { weekday: 'short' }).format(date).replace(/\.$/, '').slice(0, 2);
|
|
160
|
+
}));
|
|
161
|
+
readonly yearOptions = computed(() => {
|
|
162
|
+
const start = Math.max(1, Math.min(9992, this.anchor().getFullYear() - 3));
|
|
163
|
+
return Array.from({ length: 8 }, (_, index) => start + index);
|
|
164
|
+
});
|
|
165
|
+
readonly blocks = computed<MonthBlock[]>(() => {
|
|
166
|
+
const anchor = this.anchor();
|
|
167
|
+
const locale = this.effectiveLocale();
|
|
168
|
+
const today = dayIso(new Date());
|
|
169
|
+
const highlighted = new Map(this.highlights().filter(item => GOOD_MARKER_COLORS.includes(item.color)).map(item => [item.date, item]));
|
|
170
|
+
return Array.from({ length: this.visibleCount() }, (_, offset) => {
|
|
171
|
+
const first = makeDate(anchor.getFullYear(), anchor.getMonth() + offset);
|
|
172
|
+
const shift = (first.getDay() - this.weekStart() + 7) % 7;
|
|
173
|
+
const count = Math.ceil((shift + makeDate(first.getFullYear(), first.getMonth() + 1, 0).getDate()) / 7) * 7;
|
|
174
|
+
const start = addDays(first, -shift);
|
|
175
|
+
return {
|
|
176
|
+
key: monthIso(first),
|
|
177
|
+
label: new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(first),
|
|
178
|
+
days: Array.from({ length: count }, (_, index) => {
|
|
179
|
+
const date = addDays(start, index);
|
|
180
|
+
const iso = dayIso(date);
|
|
181
|
+
return { date: iso, number: date.getDate(), outside: date.getMonth() !== first.getMonth(), today: iso === today, highlight: highlighted.get(iso) };
|
|
182
|
+
}),
|
|
183
|
+
};
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
markerColor(highlight?: GoodMonthCalendarHighlight): string | null {
|
|
188
|
+
return highlight && GOOD_MARKER_COLORS.includes(highlight.color) ? `var(--good-color-marker-${highlight.color})` : null;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
dayLabel(day: MonthDay): string {
|
|
192
|
+
const date = parseDay(day.date)!;
|
|
193
|
+
const label = new Intl.DateTimeFormat(this.effectiveLocale(), { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }).format(date);
|
|
194
|
+
return day.highlight?.label ? `${label}, ${day.highlight.label}` : label;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
isSelected(value: string): boolean {
|
|
198
|
+
const selected = parseDay(this.selected());
|
|
199
|
+
const date = parseDay(value);
|
|
200
|
+
if (!selected || !date) return false;
|
|
201
|
+
if (this.selectionMode() === 'day') return value === dayIso(selected);
|
|
202
|
+
const start = this.startOfWeek(selected);
|
|
203
|
+
return date >= start && date < addDays(start, 7);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
select(value: string): void {
|
|
207
|
+
if (this.disabled()) return;
|
|
208
|
+
const date = parseDay(value);
|
|
209
|
+
if (!date) return;
|
|
210
|
+
const start = this.selectionMode() === 'week' ? this.startOfWeek(date) : date;
|
|
211
|
+
const next = dayIso(start);
|
|
212
|
+
this.selected.set(next);
|
|
213
|
+
this.selectionChange.emit({ mode: this.selectionMode(), start: next, endExclusive: dayIso(addDays(start, this.selectionMode() === 'week' ? 7 : 1)) });
|
|
214
|
+
if (!this.blocks().some(block => block.key === monthIso(date))) this.setMonth(monthIso(date));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
canNavigate(direction: -1 | 1): boolean {
|
|
218
|
+
const date = makeDate(this.anchor().getFullYear(), this.anchor().getMonth() + direction);
|
|
219
|
+
return date.getFullYear() >= 1 && date.getFullYear() <= 9999;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
navigate(direction: -1 | 1): void {
|
|
223
|
+
if (this.disabled() || !this.canNavigate(direction)) return;
|
|
224
|
+
const date = this.anchor();
|
|
225
|
+
this.setMonth(monthIso(makeDate(date.getFullYear(), date.getMonth() + direction)));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
openYearPicker(): void {
|
|
229
|
+
if (this.disabled()) return;
|
|
230
|
+
const dialog = this.yearDialog()?.nativeElement;
|
|
231
|
+
if (!dialog || dialog.open) return;
|
|
232
|
+
dialog.showModal();
|
|
233
|
+
this.yearPickerOpen.set(true);
|
|
234
|
+
const input = this.yearInput()?.nativeElement;
|
|
235
|
+
if (input) { input.value = String(this.anchor().getFullYear()); input.focus(); input.select(); }
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
closeYearPicker(): void { this.yearDialog()?.nativeElement.close(); }
|
|
239
|
+
|
|
240
|
+
onYearDialogClose(): void {
|
|
241
|
+
this.yearPickerOpen.set(false);
|
|
242
|
+
this.yearTrigger()?.nativeElement.focus();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
onYearDialogClick(event: MouseEvent): void {
|
|
246
|
+
if (event.target === this.yearDialog()?.nativeElement) this.closeYearPicker();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
chooseYear(year: number): void {
|
|
250
|
+
if (!Number.isInteger(year) || year < 1 || year > 9999) return;
|
|
251
|
+
const anchor = this.anchor();
|
|
252
|
+
this.setMonth(monthIso(makeDate(year, anchor.getMonth())));
|
|
253
|
+
this.closeYearPicker();
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
submitYear(event: Event): void {
|
|
257
|
+
event.preventDefault();
|
|
258
|
+
const input = this.yearInput()?.nativeElement;
|
|
259
|
+
if (!input) return;
|
|
260
|
+
const year = Number(input.value);
|
|
261
|
+
if (!input.value || !Number.isInteger(year) || year < 1 || year > 9999) { input.setCustomValidity('Enter a year from 1 to 9999.'); input.reportValidity(); return; }
|
|
262
|
+
input.setCustomValidity('');
|
|
263
|
+
this.chooseYear(year);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
onDayKeydown(event: KeyboardEvent, value: string): void {
|
|
267
|
+
const date = parseDay(value);
|
|
268
|
+
if (!date) return;
|
|
269
|
+
const move = ({ ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 } as Record<string, number>)[event.key];
|
|
270
|
+
let target: Date | null = move === undefined ? null : addDays(date, move);
|
|
271
|
+
if (event.key === 'Home') target = addDays(date, -(date.getDay() - this.weekStart() + 7) % 7);
|
|
272
|
+
if (event.key === 'End') target = addDays(date, 6 - (date.getDay() - this.weekStart() + 7) % 7);
|
|
273
|
+
if (event.key === 'PageUp' || event.key === 'PageDown') {
|
|
274
|
+
const nextMonth = makeDate(date.getFullYear(), date.getMonth() + (event.key === 'PageUp' ? -1 : 1));
|
|
275
|
+
const lastDay = makeDate(nextMonth.getFullYear(), nextMonth.getMonth() + 1, 0).getDate();
|
|
276
|
+
target = makeDate(nextMonth.getFullYear(), nextMonth.getMonth(), Math.min(date.getDate(), lastDay));
|
|
277
|
+
}
|
|
278
|
+
if (!target || target.getFullYear() < 1 || target.getFullYear() > 9999) return;
|
|
279
|
+
event.preventDefault();
|
|
280
|
+
const iso = dayIso(target);
|
|
281
|
+
if (!this.blocks().some(block => block.days.some(day => day.date === iso))) this.setMonth(monthIso(target));
|
|
282
|
+
queueMicrotask(() => this.host.nativeElement.querySelector<HTMLButtonElement>(`.good-month-calendar-day[data-date="${iso}"]`)?.focus());
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
private startOfWeek(date: Date): Date { return addDays(date, -(date.getDay() - this.weekStart() + 7) % 7); }
|
|
286
|
+
private setMonth(next: string): void {
|
|
287
|
+
if (next !== this.month()) { this.month.set(next); this.monthChanged.emit(next); }
|
|
288
|
+
}
|
|
289
|
+
}
|