@cloudfrogger/goodui 0.0.59 → 0.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -0
- package/ai/README.md +47 -0
- package/ai/case-studies/index.md +10 -0
- package/ai/case-studies/vpshoster.md +18 -0
- package/ai/case-studies/webmailer.md +21 -0
- package/ai/catalog/README.md +7 -0
- package/ai/catalog/component.schema.json +289 -0
- package/ai/catalog/components/div-goodDetailRow.json +33 -0
- package/ai/catalog/components/form-goodForm.json +84 -0
- package/ai/catalog/components/good-action-bar.json +83 -0
- package/ai/catalog/components/good-action-group.json +143 -0
- package/ai/catalog/components/good-action-menu.json +121 -0
- package/ai/catalog/components/good-alert.json +184 -0
- package/ai/catalog/components/good-app-layout.json +245 -0
- package/ai/catalog/components/good-assistant-body.json +43 -0
- package/ai/catalog/components/good-assistant-footer.json +43 -0
- package/ai/catalog/components/good-assistant-header.json +43 -0
- package/ai/catalog/components/good-assistant-main.json +61 -0
- package/ai/catalog/components/good-assistant-mobile.json +43 -0
- package/ai/catalog/components/good-assistant-panel.json +131 -0
- package/ai/catalog/components/good-avatar-menu-item.json +82 -0
- package/ai/catalog/components/good-avatar-menu.json +83 -0
- package/ai/catalog/components/good-badge.json +180 -0
- package/ai/catalog/components/good-bar-chart.json +118 -0
- package/ai/catalog/components/good-brand-icon.json +71 -0
- package/ai/catalog/components/good-breadcrumbs.json +102 -0
- package/ai/catalog/components/good-button.json +192 -0
- package/ai/catalog/components/good-calendar.json +430 -0
- package/ai/catalog/components/good-card-footer.json +63 -0
- package/ai/catalog/components/good-card-header.json +100 -0
- package/ai/catalog/components/good-card.json +57 -0
- package/ai/catalog/components/good-chart-axis.json +168 -0
- package/ai/catalog/components/good-chart-bar.json +89 -0
- package/ai/catalog/components/good-chart-histogram.json +78 -0
- package/ai/catalog/components/good-chart-line.json +89 -0
- package/ai/catalog/components/good-chart-scatter.json +87 -0
- package/ai/catalog/components/good-checkbox.json +171 -0
- package/ai/catalog/components/good-citation.json +62 -0
- package/ai/catalog/components/good-code-block.json +116 -0
- package/ai/catalog/components/good-color-controls.json +58 -0
- package/ai/catalog/components/good-color-picker.json +141 -0
- package/ai/catalog/components/good-column.json +53 -0
- package/ai/catalog/components/good-columns.json +77 -0
- package/ai/catalog/components/good-date-input.json +386 -0
- package/ai/catalog/components/good-detail-list.json +43 -0
- package/ai/catalog/components/good-dropdown.json +259 -0
- package/ai/catalog/components/good-error-page.json +133 -0
- package/ai/catalog/components/good-error-text.json +43 -0
- package/ai/catalog/components/good-expandable.json +159 -0
- package/ai/catalog/components/good-eyebrow.json +61 -0
- package/ai/catalog/components/good-field-label.json +62 -0
- package/ai/catalog/components/good-form-field.json +67 -0
- package/ai/catalog/components/good-form-row.json +70 -0
- package/ai/catalog/components/good-group.json +150 -0
- package/ai/catalog/components/good-heading-group.json +45 -0
- package/ai/catalog/components/good-heading.json +69 -0
- package/ai/catalog/components/good-hint.json +43 -0
- package/ai/catalog/components/good-histogram.json +103 -0
- package/ai/catalog/components/good-icon.json +97 -0
- package/ai/catalog/components/good-image-input.json +190 -0
- package/ai/catalog/components/good-image-preview.json +97 -0
- package/ai/catalog/components/good-inline-image.json +131 -0
- package/ai/catalog/components/good-input-phone.json +226 -0
- package/ai/catalog/components/good-input.json +350 -0
- package/ai/catalog/components/good-line-chart.json +94 -0
- package/ai/catalog/components/good-link.json +147 -0
- package/ai/catalog/components/good-listbox.json +248 -0
- package/ai/catalog/components/good-main-menu.json +138 -0
- package/ai/catalog/components/good-main-view.json +179 -0
- package/ai/catalog/components/good-map-color-scale.json +163 -0
- package/ai/catalog/components/good-map-overlay.json +136 -0
- package/ai/catalog/components/good-modal-footer.json +63 -0
- package/ai/catalog/components/good-modal-header.json +73 -0
- package/ai/catalog/components/good-modal.json +131 -0
- package/ai/catalog/components/good-month-calendar.json +170 -0
- package/ai/catalog/components/good-notification-host.json +46 -0
- package/ai/catalog/components/good-notifications.json +72 -0
- package/ai/catalog/components/good-number-input.json +180 -0
- package/ai/catalog/components/good-paragraph.json +47 -0
- package/ai/catalog/components/good-pdf-preview.json +153 -0
- package/ai/catalog/components/good-pin-input.json +211 -0
- package/ai/catalog/components/good-progress.json +158 -0
- package/ai/catalog/components/good-prose.json +43 -0
- package/ai/catalog/components/good-radio-group.json +181 -0
- package/ai/catalog/components/good-range-slider.json +285 -0
- package/ai/catalog/components/good-rating.json +160 -0
- package/ai/catalog/components/good-resizable-pane.json +61 -0
- package/ai/catalog/components/good-resizable.json +185 -0
- package/ai/catalog/components/good-rich-text-editor.json +164 -0
- package/ai/catalog/components/good-scatter-chart.json +94 -0
- package/ai/catalog/components/good-search.json +60 -0
- package/ai/catalog/components/good-section.json +43 -0
- package/ai/catalog/components/good-select-country.json +205 -0
- package/ai/catalog/components/good-select-font.json +111 -0
- package/ai/catalog/components/good-select.json +217 -0
- package/ai/catalog/components/good-separator.json +59 -0
- package/ai/catalog/components/good-settings.json +60 -0
- package/ai/catalog/components/good-sidebar-container.json +112 -0
- package/ai/catalog/components/good-sidebar-item.json +210 -0
- package/ai/catalog/components/good-sidebar-menu-container.json +80 -0
- package/ai/catalog/components/good-sidebar-submenu-group.json +98 -0
- package/ai/catalog/components/good-sidebar-submenu-item.json +113 -0
- package/ai/catalog/components/good-signature-pad.json +115 -0
- package/ai/catalog/components/good-sparkline.json +188 -0
- package/ai/catalog/components/good-status-icon.json +425 -0
- package/ai/catalog/components/good-subheading.json +67 -0
- package/ai/catalog/components/good-subnav.json +132 -0
- package/ai/catalog/components/good-summary.json +43 -0
- package/ai/catalog/components/good-switch.json +167 -0
- package/ai/catalog/components/good-tab.json +129 -0
- package/ai/catalog/components/good-table.json +294 -0
- package/ai/catalog/components/good-tabs.json +90 -0
- package/ai/catalog/components/good-textarea.json +194 -0
- package/ai/catalog/components/good-theme-toggle.json +57 -0
- package/ai/catalog/components/good-timeline-section.json +105 -0
- package/ai/catalog/components/good-timeline-step.json +248 -0
- package/ai/catalog/components/good-timeline.json +302 -0
- package/ai/catalog/components/good-topbar-dropdown-item.json +115 -0
- package/ai/catalog/components/good-topbar-dropdown-menu.json +85 -0
- package/ai/catalog/components/good-topbar-menu-container.json +96 -0
- package/ai/catalog/components/good-topbar-menu-item.json +99 -0
- package/ai/catalog/components/good-topbar-submenu.json +77 -0
- package/ai/catalog/components/good-topbar.json +259 -0
- package/ai/catalog/components/good-world-map.json +145 -0
- package/ai/catalog/components/goodCardActions.json +33 -0
- package/ai/catalog/components/goodDropdownFooter.json +33 -0
- package/ai/catalog/components/goodDropdownHeader.json +33 -0
- package/ai/catalog/components/goodExpandableHeader.json +33 -0
- package/ai/catalog/components/ng-template-goodListboxItem.json +33 -0
- package/ai/catalog/components/ng-template-goodTableCell.json +43 -0
- package/ai/catalog/index.json +1484 -0
- package/ai/catalog/index.schema.json +13 -0
- package/ai/examples/angular.json +26 -0
- package/ai/examples/edit-form.html +13 -0
- package/ai/examples/edit-form.ts +18 -0
- package/ai/examples/index.html +1 -0
- package/ai/examples/login.html +11 -0
- package/ai/examples/login.ts +14 -0
- package/ai/examples/main.ts +25 -0
- package/ai/examples/settings.html +10 -0
- package/ai/examples/settings.ts +13 -0
- package/ai/examples/table-view.html +3 -0
- package/ai/examples/table-view.ts +21 -0
- package/ai/examples/tsconfig.json +27 -0
- package/ai/guides/common-mistakes.md +9 -0
- package/ai/guides/component-discovery.md +17 -0
- package/ai/guides/design-tokens.md +10 -0
- package/ai/guides/layout.md +17 -0
- package/ai/guides/page-patterns.md +39 -0
- package/ai/install.mjs +25 -0
- package/ai/manifest.json +6 -0
- package/ai/skill/goodui/SKILL.md +27 -0
- package/angular/projects/goodui/package.json +28 -0
- package/angular/projects/goodui/src/action-bar.css +20 -0
- package/angular/projects/goodui/src/assistant-panel.css +38 -0
- package/angular/projects/goodui/src/calendar.css +161 -0
- package/angular/projects/goodui/src/chart.css +35 -0
- package/angular/projects/goodui/src/color-picker.css +40 -0
- package/angular/projects/goodui/src/error-page.css +24 -0
- package/angular/projects/goodui/src/lib/action-bar.ts +161 -0
- package/angular/projects/goodui/src/lib/action-group.ts +31 -0
- package/angular/projects/goodui/src/lib/action-menu.ts +81 -0
- package/angular/projects/goodui/src/lib/actions.ts +318 -0
- package/angular/projects/goodui/src/lib/alert.ts +60 -0
- package/angular/projects/goodui/src/lib/app-layout.ts +79 -0
- package/angular/projects/goodui/src/lib/assistant-panel.ts +133 -0
- package/angular/projects/goodui/src/lib/badge.ts +47 -0
- package/angular/projects/goodui/src/lib/bar-chart.html +80 -0
- package/angular/projects/goodui/src/lib/bar-chart.ts +233 -0
- package/angular/projects/goodui/src/lib/breadcrumbs.ts +81 -0
- package/angular/projects/goodui/src/lib/button.ts +38 -0
- package/angular/projects/goodui/src/lib/calendar-layout.ts +68 -0
- package/angular/projects/goodui/src/lib/calendar-service.ts +144 -0
- package/angular/projects/goodui/src/lib/calendar-working-hours.ts +65 -0
- package/angular/projects/goodui/src/lib/calendar.html +200 -0
- package/angular/projects/goodui/src/lib/calendar.ts +471 -0
- package/angular/projects/goodui/src/lib/card.ts +64 -0
- package/angular/projects/goodui/src/lib/chart-colors.ts +22 -0
- package/angular/projects/goodui/src/lib/chart-data.ts +269 -0
- package/angular/projects/goodui/src/lib/checkbox.ts +87 -0
- package/angular/projects/goodui/src/lib/code-block.ts +147 -0
- package/angular/projects/goodui/src/lib/color-controls.ts +107 -0
- package/angular/projects/goodui/src/lib/color-picker.ts +142 -0
- package/angular/projects/goodui/src/lib/color-utils.ts +69 -0
- package/angular/projects/goodui/src/lib/country-data.ts +16 -0
- package/angular/projects/goodui/src/lib/date-input.ts +542 -0
- package/angular/projects/goodui/src/lib/dropdown.ts +309 -0
- package/angular/projects/goodui/src/lib/error-page.ts +46 -0
- package/angular/projects/goodui/src/lib/expandable.ts +64 -0
- package/angular/projects/goodui/src/lib/form.ts +12 -0
- package/angular/projects/goodui/src/lib/goodui-config.ts +16 -0
- package/angular/projects/goodui/src/lib/group.ts +45 -0
- package/angular/projects/goodui/src/lib/histogram.html +52 -0
- package/angular/projects/goodui/src/lib/histogram.ts +146 -0
- package/angular/projects/goodui/src/lib/icon.ts +44 -0
- package/angular/projects/goodui/src/lib/image-input.ts +154 -0
- package/angular/projects/goodui/src/lib/image-preview.ts +26 -0
- package/angular/projects/goodui/src/lib/input-phone.ts +305 -0
- package/angular/projects/goodui/src/lib/input.ts +143 -0
- package/angular/projects/goodui/src/lib/line-chart.html +53 -0
- package/angular/projects/goodui/src/lib/line-chart.ts +193 -0
- package/angular/projects/goodui/src/lib/link.ts +46 -0
- package/angular/projects/goodui/src/lib/listbox.ts +254 -0
- package/angular/projects/goodui/src/lib/main-view.ts +39 -0
- package/angular/projects/goodui/src/lib/marker-colors.ts +7 -0
- package/angular/projects/goodui/src/lib/modal.ts +199 -0
- package/angular/projects/goodui/src/lib/models.ts +115 -0
- package/angular/projects/goodui/src/lib/month-calendar.ts +289 -0
- package/angular/projects/goodui/src/lib/notification-center.ts +170 -0
- package/angular/projects/goodui/src/lib/notification-host.ts +86 -0
- package/angular/projects/goodui/src/lib/number-input.ts +180 -0
- package/angular/projects/goodui/src/lib/pdf-preview.ts +242 -0
- package/angular/projects/goodui/src/lib/pdf-worker.generated.ts +2 -0
- package/angular/projects/goodui/src/lib/pin-input.ts +193 -0
- package/angular/projects/goodui/src/lib/progress.ts +93 -0
- package/angular/projects/goodui/src/lib/provide-goodui.ts +15 -0
- package/angular/projects/goodui/src/lib/radio-group.ts +94 -0
- package/angular/projects/goodui/src/lib/range-slider.ts +313 -0
- package/angular/projects/goodui/src/lib/rating.ts +90 -0
- package/angular/projects/goodui/src/lib/required-control.ts +4 -0
- package/angular/projects/goodui/src/lib/resizable.ts +168 -0
- package/angular/projects/goodui/src/lib/rich-text-command.ts +111 -0
- package/angular/projects/goodui/src/lib/rich-text-editor.html +193 -0
- package/angular/projects/goodui/src/lib/rich-text-editor.ts +864 -0
- package/angular/projects/goodui/src/lib/rich-text-sanitize.ts +99 -0
- package/angular/projects/goodui/src/lib/scatter-chart.html +48 -0
- package/angular/projects/goodui/src/lib/scatter-chart.ts +150 -0
- package/angular/projects/goodui/src/lib/select-country.ts +104 -0
- package/angular/projects/goodui/src/lib/select-font.ts +189 -0
- package/angular/projects/goodui/src/lib/select.ts +336 -0
- package/angular/projects/goodui/src/lib/sidebar.ts +232 -0
- package/angular/projects/goodui/src/lib/signature-pad.ts +238 -0
- package/angular/projects/goodui/src/lib/sparkline.html +15 -0
- package/angular/projects/goodui/src/lib/sparkline.ts +106 -0
- package/angular/projects/goodui/src/lib/status-icon.ts +79 -0
- package/angular/projects/goodui/src/lib/subnav.ts +156 -0
- package/angular/projects/goodui/src/lib/switch.ts +54 -0
- package/angular/projects/goodui/src/lib/table.ts +538 -0
- package/angular/projects/goodui/src/lib/tabs.ts +251 -0
- package/angular/projects/goodui/src/lib/textarea.ts +83 -0
- package/angular/projects/goodui/src/lib/theme.ts +49 -0
- package/angular/projects/goodui/src/lib/timeline.ts +252 -0
- package/angular/projects/goodui/src/lib/topbar.ts +402 -0
- package/angular/projects/goodui/src/lib/typography.ts +250 -0
- package/angular/projects/goodui/src/lib/world-map-data.ts +3 -0
- package/angular/projects/goodui/src/lib/world-map.html +73 -0
- package/angular/projects/goodui/src/lib/world-map.ts +391 -0
- package/angular/projects/goodui/src/month-calendar.css +47 -0
- package/angular/projects/goodui/src/pdf-preview.css +25 -0
- package/angular/projects/goodui/src/progress.css +38 -0
- package/angular/projects/goodui/src/public-api.ts +74 -0
- package/angular/projects/goodui/src/range-slider.css +54 -0
- package/angular/projects/goodui/src/resizable.css +32 -0
- package/angular/projects/goodui/src/rich-text-editor.css +33 -0
- package/angular/projects/goodui/src/select-font.css +16 -0
- package/angular/projects/goodui/src/signature-pad.css +14 -0
- package/angular/projects/goodui/src/styles.css +1105 -0
- package/angular/projects/goodui/src/timeline.css +138 -0
- package/angular/projects/goodui/src/tokens.generated.css +754 -0
- package/design/component-map.json +2233 -0
- package/design-tokens/penpot.tokens.json +3339 -0
- package/design.md +452 -0
- package/guides/README.md +17 -0
- package/guides/components/action-bar.md +43 -0
- package/guides/components/action-group.md +43 -0
- package/guides/components/action-menu.md +22 -0
- package/guides/components/alert.md +28 -0
- package/guides/components/assistant-panel.md +50 -0
- package/guides/components/avatar-menu.md +34 -0
- package/guides/components/badge.md +39 -0
- package/guides/components/bar-chart.md +40 -0
- package/guides/components/breadcrumbs.md +37 -0
- package/guides/components/button.md +40 -0
- package/guides/components/calendar.md +166 -0
- package/guides/components/card.md +62 -0
- package/guides/components/chart-axis.md +5 -0
- package/guides/components/chart-bar.md +5 -0
- package/guides/components/chart-data.md +58 -0
- package/guides/components/chart-histogram.md +16 -0
- package/guides/components/chart-line.md +5 -0
- package/guides/components/chart-scatter.md +14 -0
- package/guides/components/checkbox.md +36 -0
- package/guides/components/code-block.md +35 -0
- package/guides/components/color-controls.md +22 -0
- package/guides/components/column.md +5 -0
- package/guides/components/columns.md +13 -0
- package/guides/components/date-input.md +62 -0
- package/guides/components/detail-list.md +25 -0
- package/guides/components/dropdown.md +48 -0
- package/guides/components/error-page.md +31 -0
- package/guides/components/expandable.md +36 -0
- package/guides/components/form.md +49 -0
- package/guides/components/group.md +41 -0
- package/guides/components/histogram.md +45 -0
- package/guides/components/icon.md +13 -0
- package/guides/components/image-input.md +34 -0
- package/guides/components/input-phone.md +45 -0
- package/guides/components/input.md +59 -0
- package/guides/components/line-chart.md +37 -0
- package/guides/components/link.md +31 -0
- package/guides/components/listbox.md +109 -0
- package/guides/components/main-menu.md +11 -0
- package/guides/components/main-view.md +21 -0
- package/guides/components/modal.md +58 -0
- package/guides/components/month-calendar.md +88 -0
- package/guides/components/notifications.md +76 -0
- package/guides/components/number-input.md +21 -0
- package/guides/components/pdf-preview.md +38 -0
- package/guides/components/pin-input.md +37 -0
- package/guides/components/progress.md +41 -0
- package/guides/components/radio-group.md +41 -0
- package/guides/components/range-slider.md +42 -0
- package/guides/components/rating.md +39 -0
- package/guides/components/resizable-pane.md +3 -0
- package/guides/components/resizable.md +75 -0
- package/guides/components/rich-text-editor.md +113 -0
- package/guides/components/scatter-chart.md +43 -0
- package/guides/components/search.md +9 -0
- package/guides/components/select-font.md +16 -0
- package/guides/components/select.md +65 -0
- package/guides/components/settings.md +11 -0
- package/guides/components/sidebar.md +47 -0
- package/guides/components/signature-pad.md +45 -0
- package/guides/components/sparkline.md +31 -0
- package/guides/components/status-icon.md +32 -0
- package/guides/components/submenus.md +30 -0
- package/guides/components/subnav.md +54 -0
- package/guides/components/switch.md +48 -0
- package/guides/components/table.md +256 -0
- package/guides/components/tabs.md +46 -0
- package/guides/components/textarea.md +44 -0
- package/guides/components/theme-toggle.md +33 -0
- package/guides/components/timeline-section.md +7 -0
- package/guides/components/timeline-step.md +12 -0
- package/guides/components/timeline.md +179 -0
- package/guides/components/topbar.md +83 -0
- package/guides/components/typography.md +155 -0
- package/guides/components/world-map.md +72 -0
- package/guides/contributing/design-to-code.md +261 -0
- package/guides/deployment/drone.md +77 -0
- package/guides/examples/user-registration.md +11 -0
- package/guides/foundations/naming.md +7 -0
- package/guides/foundations/tokens.md +203 -0
- package/guides/intro.md +80 -0
- package/guides/layout/app-layout.md +64 -0
- package/guides/layout/layout-rules.md +16 -0
- package/homepage/src/app/examples/calendar-workspace/calendar-workspace-page.html +22 -0
- package/homepage/src/app/examples/calendar-workspace/calendar-workspace-page.ts +111 -0
- package/homepage/src/app/examples/calendar-workspace/source-code.generated.ts +3 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/billing-page.html +166 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/billing-page.ts +134 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/cloudhoster-store.ts +92 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/create-database-page.html +93 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/create-database-page.ts +115 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/database-detail-page.html +202 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/database-detail-page.ts +143 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/databases-page.html +70 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/databases-page.ts +44 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/home-page.html +70 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/home-page.ts +32 -0
- package/homepage/src/app/examples/case-studies/cloudhoster/source-code.generated.ts +12 -0
- package/homepage/src/app/examples/case-studies/vpshoster/create-server-page.html +208 -0
- package/homepage/src/app/examples/case-studies/vpshoster/create-server-page.ts +214 -0
- package/homepage/src/app/examples/case-studies/vpshoster/overview-page.html +35 -0
- package/homepage/src/app/examples/case-studies/vpshoster/overview-page.ts +17 -0
- package/homepage/src/app/examples/case-studies/vpshoster/servers-page.html +111 -0
- package/homepage/src/app/examples/case-studies/vpshoster/servers-page.ts +206 -0
- package/homepage/src/app/examples/case-studies/vpshoster/source-code.generated.ts +6 -0
- package/homepage/src/app/examples/case-studies/vpshoster/vps-store.ts +92 -0
- package/homepage/src/app/examples/case-studies/webmailer/webmailer-page.html +35 -0
- package/homepage/src/app/examples/case-studies/webmailer/webmailer-page.ts +17 -0
- package/homepage/src/app/examples/error-pages/error-pages-example-page.html +27 -0
- package/homepage/src/app/examples/error-pages/error-pages-example-page.ts +34 -0
- package/homepage/src/app/examples/error-pages/not-found-page.html +8 -0
- package/homepage/src/app/examples/error-pages/not-found-page.ts +19 -0
- package/homepage/src/app/examples/error-pages/server-error-page.html +8 -0
- package/homepage/src/app/examples/error-pages/server-error-page.ts +20 -0
- package/homepage/src/app/examples/error-pages/source-code.generated.ts +7 -0
- package/homepage/src/app/examples/mail-compose/mail-compose-page.html +25 -0
- package/homepage/src/app/examples/mail-compose/mail-compose-page.ts +28 -0
- package/homepage/src/app/examples/mail-workspace/mail-workspace-page.html +59 -0
- package/homepage/src/app/examples/mail-workspace/mail-workspace-page.ts +128 -0
- package/homepage/src/app/examples/mail-workspace/source-code.generated.ts +3 -0
- package/homepage/src/app/examples/notifications/notifications-page.html +51 -0
- package/homepage/src/app/examples/notifications/notifications-page.ts +133 -0
- package/homepage/src/app/examples/notifications/source-code.generated.ts +3 -0
- package/homepage/src/app/examples/pdf-reader/pdf-reader-page.html +27 -0
- package/homepage/src/app/examples/pdf-reader/pdf-reader-page.ts +39 -0
- package/homepage/src/app/examples/pdf-reader/source-code.generated.ts +3 -0
- package/homepage/src/app/examples/user-registration/source-code.generated.ts +5 -0
- package/homepage/src/app/examples/user-registration/user-registration-example-page.html +11 -0
- package/homepage/src/app/examples/user-registration/user-registration-example-page.ts +21 -0
- package/homepage/src/app/examples/user-registration/user-registration-form.html +116 -0
- package/homepage/src/app/examples/user-registration/user-registration-form.ts +93 -0
- package/homepage/src/app/examples/user-registration/user-registration-page.html +11 -0
- package/homepage/src/app/examples/user-registration/user-registration-page.ts +23 -0
- package/package.json +2 -2
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, ElementRef, HostListener, PLATFORM_ID, computed, effect, forwardRef, inject, input, model, output, signal, viewChild } from '@angular/core';
|
|
3
|
+
import { AbstractControl, ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator } from '@angular/forms';
|
|
4
|
+
import { LucideCalendarDays, LucideChevronLeft, LucideChevronRight, LucideX } from '@lucide/angular';
|
|
5
|
+
import { GoodButtonComponent } from './button';
|
|
6
|
+
import { GoodInputAddonTone, GoodInputComponent, GoodInputSize } from './input';
|
|
7
|
+
import { GoodButtonIcon } from './models';
|
|
8
|
+
import { GOOD_COMPOSITE_REQUIRED_CONTROL } from './required-control';
|
|
9
|
+
|
|
10
|
+
export type GoodDateMode = 'date' | 'range' | 'multiple' | 'month' | 'year';
|
|
11
|
+
export type GoodDatePlacement = 'bottom-start' | 'bottom-center' | 'bottom-end' | 'top-start' | 'top-center' | 'top-end';
|
|
12
|
+
export interface GoodDateRange { start: string | null; end: string | null; }
|
|
13
|
+
export type GoodDateValue = string | readonly string[] | GoodDateRange | null;
|
|
14
|
+
export interface GoodDatePreset { id: string; label: string; value: GoodDateValue; }
|
|
15
|
+
type CalendarView = 'days' | 'months' | 'years';
|
|
16
|
+
interface DayCell { iso: string; day: number; inMonth: boolean; disabled: boolean; }
|
|
17
|
+
let nextDateInputId = 0;
|
|
18
|
+
|
|
19
|
+
const isoDay = (date: Date): string => `${date.getFullYear().toString().padStart(4, '0')}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
|
|
20
|
+
const dayPart = (value: string): string => value.slice(0, 10);
|
|
21
|
+
const dateFromIso = (value: string): Date => new Date(Number(value.slice(0, 4)), Number(value.slice(5, 7)) - 1, Number(value.slice(8, 10)));
|
|
22
|
+
const isIsoDay = (value: string): boolean => /^\d{4}-\d{2}-\d{2}$/.test(value) && isoDay(dateFromIso(value)) === value;
|
|
23
|
+
const withTime = (day: string, time: string): string => `${day}T${time}`;
|
|
24
|
+
|
|
25
|
+
@Component({
|
|
26
|
+
selector: 'good-date-input',
|
|
27
|
+
standalone: true,
|
|
28
|
+
imports: [GoodInputComponent, GoodButtonComponent],
|
|
29
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
30
|
+
host: { class: 'good-date-input', '[attr.data-size]': 'size()' },
|
|
31
|
+
providers: [
|
|
32
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodDateInputComponent), multi: true },
|
|
33
|
+
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => GoodDateInputComponent), multi: true },
|
|
34
|
+
{ provide: GOOD_COMPOSITE_REQUIRED_CONTROL, useExisting: forwardRef(() => GoodDateInputComponent) },
|
|
35
|
+
],
|
|
36
|
+
template: `
|
|
37
|
+
<good-input #field [label]="label()" [showLabel]="showLabel()" [size]="size()" [value]="draftText()"
|
|
38
|
+
[placeholder]="placeholder() || examplePlaceholder()" [disabled]="isDisabled()" [error]="error() || invalidText()"
|
|
39
|
+
[required]="effectiveRequired()" [name]="name()" [inputId]="inputId()" [describedBy]="describedBy()"
|
|
40
|
+
[startIcon]="startIcon()" [endIcon]="resolvedEndIcon()" [startText]="startText()" [endText]="endText()"
|
|
41
|
+
[startTone]="startTone()" [endTone]="endTone()" autocomplete="off"
|
|
42
|
+
[ariaExpanded]="open()" [ariaControls]="panelId" hasPopup="dialog"
|
|
43
|
+
(valueChange)="onTextChange($event)" (click)="openCalendar(false)" (focusout)="onFieldBlur($event)"
|
|
44
|
+
(keydown.enter)="onFieldEnter($event)" (keydown.arrowdown)="onFieldArrowDown($event)" />
|
|
45
|
+
|
|
46
|
+
@if (open()) {
|
|
47
|
+
<dialog #panel class="good-date-panel" [id]="panelId" [attr.aria-label]="mobileDialog() ? null : calendarLabel()"
|
|
48
|
+
[attr.aria-labelledby]="mobileDialog() ? mobileTitleId : null" [attr.data-modal]="mobileDialog()"
|
|
49
|
+
[style.top.px]="panelPosition().top" [style.left.px]="panelPosition().left" [style.visibility]="positionReady() ? 'visible' : 'hidden'"
|
|
50
|
+
(keydown)="onPanelKeydown($event)" (cancel)="onPanelCancel($event)" (click)="onPanelClick($event)">
|
|
51
|
+
<div class="good-date-mobile-heading">
|
|
52
|
+
<h2 [id]="mobileTitleId">{{ calendarLabel() }}</h2>
|
|
53
|
+
<good-button variant="ghost" size="default" [icon]="closeIcon" [iconOnly]="true" ariaLabel="Close calendar"
|
|
54
|
+
(click)="closeAndFocus()" />
|
|
55
|
+
</div>
|
|
56
|
+
<header class="good-date-panel-header">
|
|
57
|
+
<good-button variant="ghost" size="small" [icon]="chevronLeft" [iconOnly]="true" ariaLabel="Previous period"
|
|
58
|
+
[disabled]="!canNavigate(-1)" (click)="navigate(-1)" />
|
|
59
|
+
<div class="good-date-period">
|
|
60
|
+
@if (view() === 'days') {
|
|
61
|
+
<button type="button" (click)="view.set('months')">{{ monthName() }}</button>
|
|
62
|
+
<button type="button" (click)="view.set('years')">{{ visibleYear() }}</button>
|
|
63
|
+
} @else if (view() === 'months') {
|
|
64
|
+
<button type="button" (click)="view.set('years')">{{ visibleYear() }}</button>
|
|
65
|
+
} @else {
|
|
66
|
+
<span>{{ yearPageStart() }}–{{ yearPageStart() + 11 }}</span>
|
|
67
|
+
}
|
|
68
|
+
</div>
|
|
69
|
+
<good-button variant="ghost" size="small" [icon]="chevronRight" [iconOnly]="true" ariaLabel="Next period"
|
|
70
|
+
[disabled]="!canNavigate(1)" (click)="navigate(1)" />
|
|
71
|
+
</header>
|
|
72
|
+
|
|
73
|
+
<div class="good-date-panel-body">
|
|
74
|
+
|
|
75
|
+
@if (view() === 'days') {
|
|
76
|
+
<div class="good-date-weekdays" aria-hidden="true">
|
|
77
|
+
@for (name of weekdayNames(); track $index) { <span>{{ name }}</span> }
|
|
78
|
+
</div>
|
|
79
|
+
<div class="good-date-grid good-date-days" role="group" [attr.aria-label]="monthName() + ' ' + visibleYear()">
|
|
80
|
+
@for (cell of dayCells(); track cell.iso) {
|
|
81
|
+
<button type="button" class="good-date-day" [attr.data-date]="cell.iso" [attr.data-outside]="!cell.inMonth"
|
|
82
|
+
[attr.data-today]="cell.iso === today()" [attr.data-selected]="isSelected(cell.iso)"
|
|
83
|
+
[attr.data-in-range]="isInRange(cell.iso)" [attr.aria-label]="dayLabel(cell.iso)"
|
|
84
|
+
[attr.aria-pressed]="isSelected(cell.iso)" [disabled]="!cell.inMonth || cell.disabled"
|
|
85
|
+
[tabIndex]="cell.iso === activeDay() ? 0 : -1" (click)="selectDay(cell.iso)">{{ cell.day }}</button>
|
|
86
|
+
}
|
|
87
|
+
</div>
|
|
88
|
+
} @else if (view() === 'months') {
|
|
89
|
+
<div class="good-date-grid good-date-months" role="group" [attr.aria-label]="'Months in ' + visibleYear()">
|
|
90
|
+
@for (month of months(); track month.index) {
|
|
91
|
+
<button type="button" [disabled]="!periodSelectable(visibleYear(), month.index)"
|
|
92
|
+
[attr.aria-pressed]="isMonthSelected(month.index)" (click)="selectMonth(month.index)">{{ month.label }}</button>
|
|
93
|
+
}
|
|
94
|
+
</div>
|
|
95
|
+
} @else {
|
|
96
|
+
<div class="good-date-grid good-date-years" role="group" aria-label="Years">
|
|
97
|
+
@for (year of years(); track year) {
|
|
98
|
+
<button type="button" [disabled]="!periodSelectable(year)" [attr.aria-pressed]="isYearSelected(year)"
|
|
99
|
+
(click)="selectYear(year)">{{ year }}</button>
|
|
100
|
+
}
|
|
101
|
+
</div>
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@if (showTime() && mode() !== 'month' && mode() !== 'year') {
|
|
105
|
+
<div class="good-date-time">
|
|
106
|
+
<label>{{ mode() === 'range' ? 'Start time' : 'Time' }}
|
|
107
|
+
<input type="time" [lang]="effectiveLocale()" [value]="startTime()" (input)="startTime.set($any($event.target).value)" />
|
|
108
|
+
</label>
|
|
109
|
+
@if (mode() === 'range') {
|
|
110
|
+
<label>End time<input type="time" [lang]="effectiveLocale()" [value]="endTime()" (input)="endTime.set($any($event.target).value)" /></label>
|
|
111
|
+
}
|
|
112
|
+
</div>
|
|
113
|
+
}
|
|
114
|
+
@if (presets().length) {
|
|
115
|
+
<div class="good-date-presets" aria-label="Quick selections">
|
|
116
|
+
@for (preset of presets(); track preset.id) {
|
|
117
|
+
<button type="button" [disabled]="!isValidValue(preset.value, true)" (click)="selectPreset(preset)">{{ preset.label }}</button>
|
|
118
|
+
}
|
|
119
|
+
</div>
|
|
120
|
+
}
|
|
121
|
+
</div>
|
|
122
|
+
<footer class="good-date-panel-footer">
|
|
123
|
+
<button type="button" class="good-date-clear" [disabled]="effectiveRequired()" (click)="clear()">Clear</button>
|
|
124
|
+
@if (mode() === 'multiple' || showTime()) {
|
|
125
|
+
<good-button size="small" [disabled]="!canApply()" (click)="apply()">{{ showTime() ? 'Apply' : 'Done' }}</good-button>
|
|
126
|
+
}
|
|
127
|
+
</footer>
|
|
128
|
+
</dialog>
|
|
129
|
+
}
|
|
130
|
+
`,
|
|
131
|
+
})
|
|
132
|
+
export class GoodDateInputComponent implements ControlValueAccessor, Validator {
|
|
133
|
+
readonly panelId = `good-date-panel-${++nextDateInputId}`;
|
|
134
|
+
readonly mobileTitleId = `${this.panelId}-title`;
|
|
135
|
+
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
|
136
|
+
private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
137
|
+
private readonly panel = viewChild<ElementRef<HTMLDialogElement>>('panel');
|
|
138
|
+
private previousOverflow: string | null = null;
|
|
139
|
+
private onChange: (value: GoodDateValue) => void = () => {};
|
|
140
|
+
private onTouched: () => void = () => {};
|
|
141
|
+
private onValidatorChange: () => void = () => {};
|
|
142
|
+
private readonly formDisabled = signal(false);
|
|
143
|
+
readonly fieldRequired = signal(false);
|
|
144
|
+
readonly value = model<GoodDateValue>(null);
|
|
145
|
+
readonly selectionChange = output<GoodDateValue>();
|
|
146
|
+
readonly label = input('Date');
|
|
147
|
+
readonly showLabel = input(false);
|
|
148
|
+
readonly size = input<GoodInputSize>('default');
|
|
149
|
+
readonly mode = input<GoodDateMode>('date');
|
|
150
|
+
readonly locale = input('');
|
|
151
|
+
readonly firstDayOfWeek = input(1);
|
|
152
|
+
readonly disabledWeekdays = input<readonly number[]>([0, 6]);
|
|
153
|
+
readonly disablePast = input(false);
|
|
154
|
+
readonly min = input('');
|
|
155
|
+
readonly max = input('');
|
|
156
|
+
readonly showTime = input(false);
|
|
157
|
+
readonly presets = input<readonly GoodDatePreset[]>([]);
|
|
158
|
+
readonly placement = input<GoodDatePlacement>('bottom-start');
|
|
159
|
+
readonly disabled = input(false);
|
|
160
|
+
readonly error = input(false);
|
|
161
|
+
readonly required = input(false);
|
|
162
|
+
readonly name = input('');
|
|
163
|
+
readonly inputId = input('');
|
|
164
|
+
readonly describedBy = input('');
|
|
165
|
+
readonly placeholder = input('');
|
|
166
|
+
readonly startIcon = input<GoodButtonIcon>();
|
|
167
|
+
readonly endIcon = input<GoodButtonIcon>();
|
|
168
|
+
readonly startText = input('');
|
|
169
|
+
readonly endText = input('');
|
|
170
|
+
readonly startTone = input<GoodInputAddonTone>('inline');
|
|
171
|
+
readonly endTone = input<GoodInputAddonTone>('inline');
|
|
172
|
+
readonly calendarIcon = LucideCalendarDays;
|
|
173
|
+
readonly chevronLeft = LucideChevronLeft;
|
|
174
|
+
readonly chevronRight = LucideChevronRight;
|
|
175
|
+
readonly closeIcon = LucideX;
|
|
176
|
+
readonly open = signal(false);
|
|
177
|
+
readonly mobileDialog = signal(false);
|
|
178
|
+
readonly view = signal<CalendarView>('days');
|
|
179
|
+
readonly visibleYear = signal(new Date().getFullYear());
|
|
180
|
+
readonly visibleMonth = signal(new Date().getMonth());
|
|
181
|
+
readonly activeDay = signal(isoDay(new Date()));
|
|
182
|
+
readonly pending = signal<GoodDateValue>(null);
|
|
183
|
+
readonly startTime = signal('09:00');
|
|
184
|
+
readonly endTime = signal('17:00');
|
|
185
|
+
readonly draftText = signal('');
|
|
186
|
+
readonly invalidText = signal(false);
|
|
187
|
+
readonly panelPosition = signal({ top: 0, left: 0 });
|
|
188
|
+
readonly positionReady = signal(false);
|
|
189
|
+
readonly effectiveRequired = computed(() => this.required() || this.fieldRequired());
|
|
190
|
+
readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
191
|
+
readonly effectiveLocale = computed(() => this.locale() || (this.browser ? navigator.language : 'en-US'));
|
|
192
|
+
readonly resolvedEndIcon = computed(() => this.endIcon() ?? (this.endText() ? undefined : this.calendarIcon));
|
|
193
|
+
readonly today = computed(() => isoDay(new Date()));
|
|
194
|
+
readonly monthName = computed(() => new Intl.DateTimeFormat(this.effectiveLocale(), { month: 'long' }).format(new Date(this.visibleYear(), this.visibleMonth(), 1)));
|
|
195
|
+
readonly yearPageStart = computed(() => Math.floor(this.visibleYear() / 12) * 12);
|
|
196
|
+
readonly years = computed(() => Array.from({ length: 12 }, (_, i) => this.yearPageStart() + i));
|
|
197
|
+
readonly months = computed(() => Array.from({ length: 12 }, (_, index) => ({ index, label: new Intl.DateTimeFormat(this.effectiveLocale(), { month: 'short' }).format(new Date(2024, index, 1)) })));
|
|
198
|
+
readonly weekdayNames = computed(() => Array.from({ length: 7 }, (_, i) => new Intl.DateTimeFormat(this.effectiveLocale(), { weekday: 'short' }).format(new Date(2024, 0, 7 + (this.weekStart() + i) % 7))));
|
|
199
|
+
readonly dayCells = computed<readonly DayCell[]>(() => {
|
|
200
|
+
const first = new Date(this.visibleYear(), this.visibleMonth(), 1);
|
|
201
|
+
const offset = (first.getDay() - this.weekStart() + 7) % 7;
|
|
202
|
+
return Array.from({ length: 42 }, (_, index) => {
|
|
203
|
+
const date = new Date(this.visibleYear(), this.visibleMonth(), 1 - offset + index);
|
|
204
|
+
const iso = isoDay(date);
|
|
205
|
+
return { iso, day: date.getDate(), inMonth: date.getMonth() === this.visibleMonth(), disabled: !this.isSelectableDay(iso) };
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
readonly canApply = computed(() => this.pending() !== null && this.isValidValue(this.pending(), false));
|
|
209
|
+
|
|
210
|
+
constructor() {
|
|
211
|
+
effect(() => { this.draftText.set(this.formatValue(this.value())); this.invalidText.set(false); });
|
|
212
|
+
effect(() => { this.effectiveRequired(); this.isDisabled(); this.min(); this.max(); this.disabledWeekdays(); this.disablePast(); this.mode(); this.value(); this.onValidatorChange(); });
|
|
213
|
+
if (this.browser) {
|
|
214
|
+
const reposition = () => { if (this.open() && !this.mobileDialog()) this.positionPanel(); };
|
|
215
|
+
document.addEventListener('scroll', reposition, true);
|
|
216
|
+
inject(DestroyRef).onDestroy(() => { document.removeEventListener('scroll', reposition, true); this.close(); });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
private weekStart(): number { return ((this.firstDayOfWeek() % 7) + 7) % 7; }
|
|
221
|
+
setFieldRequired(required: boolean): void { this.fieldRequired.set(required); }
|
|
222
|
+
writeValue(value: GoodDateValue): void { this.value.set(value); }
|
|
223
|
+
registerOnChange(fn: (value: GoodDateValue) => void): void { this.onChange = fn; }
|
|
224
|
+
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
|
|
225
|
+
registerOnValidatorChange(fn: () => void): void { this.onValidatorChange = fn; }
|
|
226
|
+
setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); if (disabled) this.close(); }
|
|
227
|
+
validate(_control: AbstractControl): ValidationErrors | null {
|
|
228
|
+
if (this.isDisabled()) return null;
|
|
229
|
+
const value = this.value();
|
|
230
|
+
if (!value || (Array.isArray(value) && !value.length)) return this.effectiveRequired() ? { required: true } : null;
|
|
231
|
+
return this.isValidValue(value, false) ? null : { dateUnavailable: true };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
private publish(value: GoodDateValue): void {
|
|
235
|
+
this.value.set(value);
|
|
236
|
+
this.onChange(value);
|
|
237
|
+
this.onTouched();
|
|
238
|
+
this.selectionChange.emit(value);
|
|
239
|
+
this.invalidText.set(false);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
private initialView(): CalendarView { return this.mode() === 'month' ? 'months' : this.mode() === 'year' ? 'years' : 'days'; }
|
|
243
|
+
openCalendar(focusDay: boolean): void {
|
|
244
|
+
if (this.isDisabled() || this.open()) return;
|
|
245
|
+
const first = this.firstSelectedDate(this.value()) || this.today();
|
|
246
|
+
const date = /^\d{4}(?:-(?:0[1-9]|1[0-2]))?$/.test(first)
|
|
247
|
+
? new Date(Number(first.slice(0, 4)), Number(first.slice(5, 7) || 1) - 1, 1)
|
|
248
|
+
: isIsoDay(dayPart(first)) ? dateFromIso(first) : new Date();
|
|
249
|
+
const active = new Date(date);
|
|
250
|
+
if (this.initialView() === 'days') {
|
|
251
|
+
for (let i = 0; i < 366 && !this.isSelectableDay(isoDay(active)); i++) active.setDate(active.getDate() + 1);
|
|
252
|
+
}
|
|
253
|
+
this.visibleYear.set(active.getFullYear()); this.visibleMonth.set(active.getMonth()); this.activeDay.set(isoDay(active));
|
|
254
|
+
this.pending.set(this.value()); this.view.set(this.initialView());
|
|
255
|
+
const current = this.value();
|
|
256
|
+
const value = this.firstSelectedDate(current);
|
|
257
|
+
if (value?.includes('T')) this.startTime.set(value.slice(11, 16));
|
|
258
|
+
if (this.mode() === 'range' && this.isRange(current) && current.end?.includes('T')) this.endTime.set(current.end.slice(11, 16));
|
|
259
|
+
this.mobileDialog.set(this.browser && matchMedia('(max-width: 640px), (pointer: coarse)').matches);
|
|
260
|
+
this.open.set(true); this.positionReady.set(false);
|
|
261
|
+
if (this.browser) requestAnimationFrame(() => this.showPanel(focusDay));
|
|
262
|
+
}
|
|
263
|
+
private showPanel(focusDay: boolean): void {
|
|
264
|
+
const panel = this.panel()?.nativeElement;
|
|
265
|
+
if (!this.open() || !panel || panel.open) return;
|
|
266
|
+
if (this.mobileDialog()) {
|
|
267
|
+
this.lockScroll();
|
|
268
|
+
panel.showModal();
|
|
269
|
+
this.positionReady.set(true);
|
|
270
|
+
requestAnimationFrame(() => {
|
|
271
|
+
if (focusDay) this.focusActiveDay();
|
|
272
|
+
else panel.querySelector<HTMLButtonElement>('.good-date-mobile-heading button')?.focus();
|
|
273
|
+
});
|
|
274
|
+
} else {
|
|
275
|
+
panel.show();
|
|
276
|
+
this.positionPanel();
|
|
277
|
+
if (focusDay) this.focusActiveDay();
|
|
278
|
+
else this.focusField();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
private lockScroll(): void {
|
|
282
|
+
if (this.previousOverflow !== null) return;
|
|
283
|
+
this.previousOverflow = document.documentElement.style.overflow;
|
|
284
|
+
document.documentElement.style.overflow = 'hidden';
|
|
285
|
+
}
|
|
286
|
+
private unlockScroll(): void {
|
|
287
|
+
if (this.previousOverflow === null) return;
|
|
288
|
+
document.documentElement.style.overflow = this.previousOverflow;
|
|
289
|
+
this.previousOverflow = null;
|
|
290
|
+
}
|
|
291
|
+
close(): void {
|
|
292
|
+
const panel = this.panel()?.nativeElement;
|
|
293
|
+
if (panel?.open) panel.close();
|
|
294
|
+
this.unlockScroll();
|
|
295
|
+
this.open.set(false); this.positionReady.set(false);
|
|
296
|
+
}
|
|
297
|
+
closeAndFocus(): void { this.close(); this.focusField(); }
|
|
298
|
+
onPanelCancel(event: Event): void { event.preventDefault(); this.closeAndFocus(); }
|
|
299
|
+
onPanelClick(event: MouseEvent): void {
|
|
300
|
+
if (!this.mobileDialog() || event.target !== this.panel()?.nativeElement) return;
|
|
301
|
+
const bounds = this.panel()!.nativeElement.getBoundingClientRect();
|
|
302
|
+
if (event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom) this.closeAndFocus();
|
|
303
|
+
}
|
|
304
|
+
@HostListener('document:pointerdown', ['$event']) onDocumentPointer(event: PointerEvent): void {
|
|
305
|
+
if (!this.open()) return;
|
|
306
|
+
if (this.mobileDialog()) {
|
|
307
|
+
const bounds = this.panel()?.nativeElement.getBoundingClientRect();
|
|
308
|
+
if (bounds && (event.clientX < bounds.left || event.clientX > bounds.right || event.clientY < bounds.top || event.clientY > bounds.bottom)) {
|
|
309
|
+
event.preventDefault();
|
|
310
|
+
this.closeAndFocus();
|
|
311
|
+
}
|
|
312
|
+
} else if (!this.host.nativeElement.contains(event.target as Node)) this.close();
|
|
313
|
+
}
|
|
314
|
+
@HostListener('document:keydown.escape', ['$event']) onEscape(event: Event): void {
|
|
315
|
+
if (!this.open() || this.mobileDialog()) return;
|
|
316
|
+
event.preventDefault(); this.closeAndFocus();
|
|
317
|
+
}
|
|
318
|
+
@HostListener('document:focusin', ['$event']) onDocumentFocus(event: FocusEvent): void {
|
|
319
|
+
if (this.open() && !this.mobileDialog() && !this.host.nativeElement.contains(event.target as Node)) this.close();
|
|
320
|
+
}
|
|
321
|
+
@HostListener('window:resize') onResize(): void {
|
|
322
|
+
if (!this.open()) return;
|
|
323
|
+
const mobile = matchMedia('(max-width: 640px), (pointer: coarse)').matches;
|
|
324
|
+
if (mobile !== this.mobileDialog()) {
|
|
325
|
+
const panel = this.panel()?.nativeElement;
|
|
326
|
+
if (panel?.open) panel.close();
|
|
327
|
+
this.unlockScroll();
|
|
328
|
+
this.mobileDialog.set(mobile);
|
|
329
|
+
requestAnimationFrame(() => this.showPanel(false));
|
|
330
|
+
} else if (!mobile) this.positionPanel();
|
|
331
|
+
}
|
|
332
|
+
private positionPanel(): void {
|
|
333
|
+
const field = this.host.nativeElement.querySelector('good-input')?.getBoundingClientRect();
|
|
334
|
+
const panel = this.panel()?.nativeElement;
|
|
335
|
+
if (!field || !panel) return;
|
|
336
|
+
const bounds = panel.getBoundingClientRect();
|
|
337
|
+
const width = bounds.width || 344, height = bounds.height || 410, gap = 6, margin = 12;
|
|
338
|
+
let top = this.placement().startsWith('top') ? field.top - height - gap : field.bottom + gap;
|
|
339
|
+
if (top + height > innerHeight - margin && field.top >= height + gap + margin) top = field.top - height - gap;
|
|
340
|
+
top = Math.max(margin, Math.min(top, innerHeight - height - margin));
|
|
341
|
+
const align = this.placement().split('-')[1];
|
|
342
|
+
let left = align === 'center' ? field.left + (field.width - width) / 2 : align === 'end' ? field.right - width : field.left;
|
|
343
|
+
left = Math.max(margin, Math.min(left, innerWidth - width - margin));
|
|
344
|
+
this.panelPosition.set({ top, left }); this.positionReady.set(true);
|
|
345
|
+
}
|
|
346
|
+
private focusField(): void { this.host.nativeElement.querySelector<HTMLInputElement>('good-input input')?.focus(); }
|
|
347
|
+
private focusActiveDay(): void { queueMicrotask(() => this.panel()?.nativeElement.querySelector<HTMLButtonElement>(`[data-date="${this.activeDay()}"]`)?.focus()); }
|
|
348
|
+
onFieldArrowDown(event: Event): void { event.preventDefault(); if (this.open()) this.focusActiveDay(); else this.openCalendar(true); }
|
|
349
|
+
onFieldEnter(event: Event): void { event.preventDefault(); this.commitText(); if (!this.invalidText()) this.close(); }
|
|
350
|
+
onFieldBlur(event: FocusEvent): void {
|
|
351
|
+
if (this.host.nativeElement.contains(event.relatedTarget as Node)) return;
|
|
352
|
+
this.commitText(); this.onTouched();
|
|
353
|
+
}
|
|
354
|
+
onTextChange(text: string): void { this.draftText.set(text); this.invalidText.set(false); }
|
|
355
|
+
private commitText(): void {
|
|
356
|
+
const text = this.draftText().trim();
|
|
357
|
+
if (text === this.formatValue(this.value())) return;
|
|
358
|
+
if (!text) { if (!this.effectiveRequired()) this.publish(null); else this.invalidText.set(true); return; }
|
|
359
|
+
const parsed = this.parseValue(text);
|
|
360
|
+
if (parsed !== undefined && this.isValidValue(parsed, false)) this.publish(parsed);
|
|
361
|
+
else this.invalidText.set(true);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
navigate(direction: -1 | 1): void {
|
|
365
|
+
if (!this.canNavigate(direction)) return;
|
|
366
|
+
if (this.view() === 'years') this.visibleYear.update(year => year + direction * 12);
|
|
367
|
+
else if (this.view() === 'months') this.visibleYear.update(year => year + direction);
|
|
368
|
+
else {
|
|
369
|
+
const next = new Date(this.visibleYear(), this.visibleMonth() + direction, 1);
|
|
370
|
+
this.visibleYear.set(next.getFullYear()); this.visibleMonth.set(next.getMonth());
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
canNavigate(direction: -1 | 1): boolean {
|
|
374
|
+
if (this.view() === 'years') return this.years().some(year => this.periodSelectable(year + direction * 12));
|
|
375
|
+
if (this.view() === 'months') return this.periodSelectable(this.visibleYear() + direction);
|
|
376
|
+
const next = new Date(this.visibleYear(), this.visibleMonth() + direction, 1);
|
|
377
|
+
return this.periodSelectable(next.getFullYear(), next.getMonth());
|
|
378
|
+
}
|
|
379
|
+
selectMonth(month: number): void {
|
|
380
|
+
if (!this.periodSelectable(this.visibleYear(), month)) return;
|
|
381
|
+
this.visibleMonth.set(month);
|
|
382
|
+
if (this.mode() === 'month') { this.publish(`${this.visibleYear()}-${String(month + 1).padStart(2, '0')}`); this.close(); this.focusField(); }
|
|
383
|
+
else this.view.set('days');
|
|
384
|
+
}
|
|
385
|
+
selectYear(year: number): void {
|
|
386
|
+
if (!this.periodSelectable(year)) return;
|
|
387
|
+
this.visibleYear.set(year);
|
|
388
|
+
if (this.mode() === 'year') { this.publish(String(year)); this.close(); this.focusField(); }
|
|
389
|
+
else this.view.set('months');
|
|
390
|
+
}
|
|
391
|
+
selectDay(day: string): void {
|
|
392
|
+
if (!this.isSelectableDay(day)) return;
|
|
393
|
+
this.activeDay.set(day);
|
|
394
|
+
const mode = this.mode(), previous = this.pending();
|
|
395
|
+
if (mode === 'date') this.pending.set(this.showTime() ? withTime(day, this.startTime()) : day);
|
|
396
|
+
else if (mode === 'range') {
|
|
397
|
+
const range = this.isRange(previous) ? previous : { start: null, end: null };
|
|
398
|
+
const start = range.start && !range.end && day >= dayPart(range.start) ? range.start : null;
|
|
399
|
+
this.pending.set(start ? { start, end: this.showTime() ? withTime(day, this.endTime()) : day } : { start: this.showTime() ? withTime(day, this.startTime()) : day, end: null });
|
|
400
|
+
} else if (mode === 'multiple') {
|
|
401
|
+
const values = Array.isArray(previous) ? previous.filter((item): item is string => typeof item === 'string') : [];
|
|
402
|
+
this.pending.set(values.some(item => dayPart(item) === day) ? values.filter(item => dayPart(item) !== day) : [...values, this.showTime() ? withTime(day, this.startTime()) : day].sort());
|
|
403
|
+
}
|
|
404
|
+
const next = this.pending();
|
|
405
|
+
if (!this.showTime()) {
|
|
406
|
+
if (mode === 'multiple') this.publish(next);
|
|
407
|
+
else if (mode === 'date' || (mode === 'range' && this.isRange(next) && !!next.end)) { this.publish(next); this.close(); this.focusField(); }
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
apply(): void {
|
|
411
|
+
let next = this.pending();
|
|
412
|
+
if (this.showTime()) {
|
|
413
|
+
if (this.mode() === 'date' && typeof next === 'string') next = withTime(dayPart(next), this.startTime());
|
|
414
|
+
if (this.mode() === 'range' && this.isRange(next)) next = { start: next.start && withTime(dayPart(next.start), this.startTime()), end: next.end && withTime(dayPart(next.end), this.endTime()) };
|
|
415
|
+
if (this.mode() === 'multiple' && Array.isArray(next)) next = next.map(item => withTime(dayPart(item), this.startTime()));
|
|
416
|
+
}
|
|
417
|
+
if (!this.isValidValue(next, false)) return;
|
|
418
|
+
this.publish(next); this.close(); this.focusField();
|
|
419
|
+
}
|
|
420
|
+
clear(): void { if (this.effectiveRequired()) return; this.publish(null); this.close(); this.focusField(); }
|
|
421
|
+
selectPreset(preset: GoodDatePreset): void {
|
|
422
|
+
if (!this.isValidValue(preset.value, true)) return;
|
|
423
|
+
this.publish(preset.value); this.close(); this.focusField();
|
|
424
|
+
}
|
|
425
|
+
onPanelKeydown(event: KeyboardEvent): void {
|
|
426
|
+
if (this.view() !== 'days' || !(event.target instanceof HTMLElement) || !event.target.classList.contains('good-date-day')) return;
|
|
427
|
+
const delta: Record<string, number> = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 };
|
|
428
|
+
if (!(event.key in delta) && !['Home', 'End', 'PageUp', 'PageDown'].includes(event.key)) return;
|
|
429
|
+
event.preventDefault();
|
|
430
|
+
const active = dateFromIso(this.activeDay());
|
|
431
|
+
if (event.key in delta) active.setDate(active.getDate() + delta[event.key]);
|
|
432
|
+
else if (event.key === 'Home') active.setDate(active.getDate() - (active.getDay() - this.weekStart() + 7) % 7);
|
|
433
|
+
else if (event.key === 'End') active.setDate(active.getDate() + (6 - (active.getDay() - this.weekStart() + 7) % 7));
|
|
434
|
+
else active.setMonth(active.getMonth() + (event.key === 'PageUp' ? -1 : 1) * (event.shiftKey ? 12 : 1));
|
|
435
|
+
for (let i = 0; i < 366 && !this.isSelectableDay(isoDay(active)); i++) active.setDate(active.getDate() + (event.key === 'ArrowLeft' || event.key === 'ArrowUp' || event.key === 'PageUp' ? -1 : 1));
|
|
436
|
+
if (!this.isSelectableDay(isoDay(active))) return;
|
|
437
|
+
this.visibleYear.set(active.getFullYear()); this.visibleMonth.set(active.getMonth()); this.activeDay.set(isoDay(active)); this.focusActiveDay();
|
|
438
|
+
}
|
|
439
|
+
isSelected(day: string): boolean {
|
|
440
|
+
const current = this.pending();
|
|
441
|
+
if (typeof current === 'string') return dayPart(current) === day;
|
|
442
|
+
if (Array.isArray(current)) return current.some(value => dayPart(value) === day);
|
|
443
|
+
return this.isRange(current) && (current.start && dayPart(current.start) === day || current.end && dayPart(current.end) === day) || false;
|
|
444
|
+
}
|
|
445
|
+
isInRange(day: string): boolean { const range = this.pending(); return this.isRange(range) && !!range.start && !!range.end && day > dayPart(range.start) && day < dayPart(range.end); }
|
|
446
|
+
isMonthSelected(month: number): boolean { const value = this.pending(); return typeof value === 'string' && value.slice(0, 7) === `${this.visibleYear()}-${String(month + 1).padStart(2, '0')}`; }
|
|
447
|
+
isYearSelected(year: number): boolean { const value = this.pending(); return typeof value === 'string' && value.slice(0, 4) === String(year); }
|
|
448
|
+
dayLabel(day: string): string { return new Intl.DateTimeFormat(this.effectiveLocale(), { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' }).format(dateFromIso(day)); }
|
|
449
|
+
calendarLabel(): string { return ({ date: 'Choose date', range: 'Choose date range', multiple: 'Choose dates', month: 'Choose month', year: 'Choose year' })[this.mode()]; }
|
|
450
|
+
periodSelectable(year: number, month?: number): boolean {
|
|
451
|
+
if (year < 1 || year > 9999) return false;
|
|
452
|
+
const first = month === undefined ? 0 : month, last = month === undefined ? 11 : month;
|
|
453
|
+
for (let m = first; m <= last; m++) for (let d = 1, count = new Date(year, m + 1, 0).getDate(); d <= count; d++) if (this.isSelectableDay(isoDay(new Date(year, m, d)))) return true;
|
|
454
|
+
return false;
|
|
455
|
+
}
|
|
456
|
+
isSelectableDay(day: string): boolean {
|
|
457
|
+
if (!isIsoDay(day) || (this.min() && day < this.min().slice(0, 10)) || (this.max() && day > this.max().slice(0, 10)) || (this.disablePast() && day < this.today())) return false;
|
|
458
|
+
return !this.disabledWeekdays().includes(dateFromIso(day).getDay());
|
|
459
|
+
}
|
|
460
|
+
private isRange(value: GoodDateValue): value is GoodDateRange { return !!value && typeof value === 'object' && !Array.isArray(value) && 'start' in value && 'end' in value; }
|
|
461
|
+
private firstSelectedDate(value: GoodDateValue): string | null {
|
|
462
|
+
if (typeof value === 'string') return value;
|
|
463
|
+
if (Array.isArray(value)) return value[0] || null;
|
|
464
|
+
return this.isRange(value) && value.start ? value.start : null;
|
|
465
|
+
}
|
|
466
|
+
isValidValue(value: GoodDateValue, allowEmpty: boolean): boolean {
|
|
467
|
+
if (value == null) return allowEmpty || !this.effectiveRequired();
|
|
468
|
+
const mode = this.mode();
|
|
469
|
+
if (mode === 'year') return typeof value === 'string' && /^\d{4}$/.test(value) && this.periodSelectable(Number(value));
|
|
470
|
+
if (mode === 'month') return typeof value === 'string' && /^\d{4}-(0[1-9]|1[0-2])$/.test(value) && this.periodSelectable(Number(value.slice(0, 4)), Number(value.slice(5, 7)) - 1);
|
|
471
|
+
const validDate = (item: string): boolean => this.isSelectableDay(dayPart(item)) && (!this.showTime() || /^\d{4}-\d{2}-\d{2}T([01]\d|2[0-3]):[0-5]\d$/.test(item));
|
|
472
|
+
if (mode === 'date') return typeof value === 'string' && validDate(value);
|
|
473
|
+
if (mode === 'multiple') return Array.isArray(value) && (allowEmpty || !this.effectiveRequired() || value.length > 0) && value.every(item => typeof item === 'string' && validDate(item)) && new Set(value.map(dayPart)).size === value.length;
|
|
474
|
+
return this.isRange(value) && !!value.start && !!value.end && validDate(value.start) && validDate(value.end) && dayPart(value.start) <= dayPart(value.end) && (!this.showTime() || value.start <= value.end);
|
|
475
|
+
}
|
|
476
|
+
private formatValue(value: GoodDateValue): string {
|
|
477
|
+
if (typeof value === 'string') {
|
|
478
|
+
if (this.mode() === 'year') return value;
|
|
479
|
+
if (this.mode() === 'month') return new Intl.DateTimeFormat(this.effectiveLocale(), { year: 'numeric', month: 'long' }).format(new Date(Number(value.slice(0, 4)), Number(value.slice(5, 7)) - 1, 1));
|
|
480
|
+
return this.formatDate(value);
|
|
481
|
+
}
|
|
482
|
+
if (Array.isArray(value)) return value.map(item => this.formatDate(item)).join('; ');
|
|
483
|
+
if (this.isRange(value)) return [value.start && this.formatDate(value.start), value.end && this.formatDate(value.end)].filter(Boolean).join(' – ');
|
|
484
|
+
return '';
|
|
485
|
+
}
|
|
486
|
+
private formatDate(value: string): string {
|
|
487
|
+
if (!isIsoDay(dayPart(value))) return value;
|
|
488
|
+
const date = dateFromIso(value);
|
|
489
|
+
if (value.includes('T')) date.setHours(Number(value.slice(11, 13)), Number(value.slice(14, 16)));
|
|
490
|
+
return new Intl.DateTimeFormat(this.effectiveLocale(), value.includes('T') ? { year: 'numeric', month: '2-digit', day: '2-digit', hour: 'numeric', minute: '2-digit' } : { year: 'numeric', month: '2-digit', day: '2-digit' }).format(date);
|
|
491
|
+
}
|
|
492
|
+
examplePlaceholder(): string {
|
|
493
|
+
if (this.mode() === 'year') return 'YYYY';
|
|
494
|
+
if (this.mode() === 'month') return new Intl.DateTimeFormat(this.effectiveLocale(), { year: 'numeric', month: 'long' }).format(new Date(2024, 0, 1));
|
|
495
|
+
const example = this.formatDate(this.showTime() ? '2024-01-15T09:00' : '2024-01-15');
|
|
496
|
+
return this.mode() === 'range' ? `${example} – ${example}` : this.mode() === 'multiple' ? `${example}; ${example}` : example;
|
|
497
|
+
}
|
|
498
|
+
private parseValue(text: string): GoodDateValue | undefined {
|
|
499
|
+
if (this.mode() === 'year') return /^\d{4}$/.test(text) ? text : undefined;
|
|
500
|
+
if (this.mode() === 'month') {
|
|
501
|
+
if (/^\d{4}-(0[1-9]|1[0-2])$/.test(text)) return text;
|
|
502
|
+
const name = text.replace(/[\d\p{P}\p{S}]/gu, ' ').trim().toLocaleLowerCase(this.effectiveLocale());
|
|
503
|
+
const month = this.months().find(item => item.label.toLocaleLowerCase(this.effectiveLocale()) === name || new Intl.DateTimeFormat(this.effectiveLocale(), { month: 'long' }).format(new Date(2024, item.index, 1)).toLocaleLowerCase(this.effectiveLocale()) === name);
|
|
504
|
+
const year = text.match(/\b\d{4}\b/)?.[0];
|
|
505
|
+
return month && year ? `${year}-${String(month.index + 1).padStart(2, '0')}` : undefined;
|
|
506
|
+
}
|
|
507
|
+
if (this.mode() === 'multiple') {
|
|
508
|
+
const items = text.split(/\s*;\s*/).map(item => this.parseDate(item));
|
|
509
|
+
return items.every((item): item is string => !!item) ? items : undefined;
|
|
510
|
+
}
|
|
511
|
+
if (this.mode() === 'range') {
|
|
512
|
+
const items = text.split(/\s+[–—]\s+/);
|
|
513
|
+
if (items.length !== 2) return undefined;
|
|
514
|
+
const start = this.parseDate(items[0]), end = this.parseDate(items[1]);
|
|
515
|
+
return start && end ? { start, end } : undefined;
|
|
516
|
+
}
|
|
517
|
+
return this.parseDate(text);
|
|
518
|
+
}
|
|
519
|
+
private parseDate(text: string): string | undefined {
|
|
520
|
+
const locale = this.effectiveLocale();
|
|
521
|
+
const digits = new Map(Array.from({ length: 10 }, (_, i) => [new Intl.NumberFormat(locale, { useGrouping: false }).format(i), String(i)]));
|
|
522
|
+
const normalized = [...text].map(char => digits.get(char) ?? char).join('');
|
|
523
|
+
if (isIsoDay(normalized)) return this.showTime() ? undefined : normalized;
|
|
524
|
+
if (this.showTime() && /^\d{4}-\d{2}-\d{2}T([01]\d|2[0-3]):[0-5]\d$/.test(normalized) && isIsoDay(dayPart(normalized))) return normalized;
|
|
525
|
+
const numbers = normalized.match(/\d+/g)?.map(Number) ?? [];
|
|
526
|
+
if (numbers.length < 3) return undefined;
|
|
527
|
+
const order = new Intl.DateTimeFormat(locale, { year: 'numeric', month: '2-digit', day: '2-digit' }).formatToParts(new Date(2024, 10, 23)).filter(p => ['year', 'month', 'day'].includes(p.type)).map(p => p.type);
|
|
528
|
+
const parts = Object.fromEntries(order.map((part, index) => [part, numbers[index]]));
|
|
529
|
+
const day = `${String(parts['year']).padStart(4, '0')}-${String(parts['month']).padStart(2, '0')}-${String(parts['day']).padStart(2, '0')}`;
|
|
530
|
+
if (!isIsoDay(day)) return undefined;
|
|
531
|
+
if (!this.showTime()) return day;
|
|
532
|
+
let hour = numbers[3], minute = numbers[4];
|
|
533
|
+
if (hour === undefined || minute === undefined || minute > 59) return undefined;
|
|
534
|
+
const am = new Intl.DateTimeFormat(locale, { hour: 'numeric', hour12: true }).formatToParts(new Date(2024, 0, 1, 9)).find(p => p.type === 'dayPeriod')?.value.toLowerCase();
|
|
535
|
+
const pm = new Intl.DateTimeFormat(locale, { hour: 'numeric', hour12: true }).formatToParts(new Date(2024, 0, 1, 21)).find(p => p.type === 'dayPeriod')?.value.toLowerCase();
|
|
536
|
+
const lower = text.toLowerCase();
|
|
537
|
+
if (pm && lower.includes(pm)) hour = hour % 12 + 12;
|
|
538
|
+
else if (am && lower.includes(am)) hour = hour % 12;
|
|
539
|
+
if (hour > 23) return undefined;
|
|
540
|
+
return withTime(day, `${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`);
|
|
541
|
+
}
|
|
542
|
+
}
|