@cloudfrogger/goodui 0.0.60 → 0.0.63
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 +247 -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 +140 -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 +19 -0
- package/ai/guides/design-tokens.md +10 -0
- package/ai/guides/layout.md +19 -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 +320 -0
- package/angular/projects/goodui/src/lib/alert.ts +60 -0
- package/angular/projects/goodui/src/lib/app-layout.ts +84 -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 +403 -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/fesm2022/cloudfrogger-goodui.mjs +32 -18
- package/fesm2022/cloudfrogger-goodui.mjs.map +1 -1
- 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 +23 -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 +51 -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 +89 -0
- package/guides/components/typography.md +155 -0
- package/guides/components/world-map.md +72 -0
- package/guides/contributing/design-to-code.md +265 -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 +81 -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
- package/types/cloudfrogger-goodui.d.ts +2 -2
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { Injectable, computed, inject, signal } from '@angular/core';
|
|
2
|
+
import { GoodAlertAppearance, GoodAlertTone } from './alert';
|
|
3
|
+
import { GOODUI_OPTIONS } from './goodui-config';
|
|
4
|
+
import { GoodButtonIcon } from './models';
|
|
5
|
+
import type { GoodProgressAppearance, GoodProgressColor, GoodProgressMode, GoodProgressSize } from './progress';
|
|
6
|
+
|
|
7
|
+
export type GoodNotificationDelivery = 'toast' | 'top' | 'inbox';
|
|
8
|
+
|
|
9
|
+
export interface GoodNotificationAction {
|
|
10
|
+
label: string;
|
|
11
|
+
route?: string;
|
|
12
|
+
run?: () => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface GoodNotificationProgress {
|
|
16
|
+
mode?: GoodProgressMode;
|
|
17
|
+
appearance?: GoodProgressAppearance;
|
|
18
|
+
size?: GoodProgressSize;
|
|
19
|
+
value?: number;
|
|
20
|
+
durationMs?: number;
|
|
21
|
+
loop?: boolean;
|
|
22
|
+
title?: string;
|
|
23
|
+
showPercent?: boolean;
|
|
24
|
+
color?: GoodProgressColor | string;
|
|
25
|
+
ariaLabel?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface GoodNotificationRequest {
|
|
29
|
+
title: string;
|
|
30
|
+
message?: string;
|
|
31
|
+
tone?: GoodAlertTone;
|
|
32
|
+
appearance?: GoodAlertAppearance;
|
|
33
|
+
icon?: GoodButtonIcon;
|
|
34
|
+
delivery?: GoodNotificationDelivery;
|
|
35
|
+
/** Milliseconds until the visible toast leaves. Zero keeps it until acknowledgement or dismissal. */
|
|
36
|
+
duration?: number;
|
|
37
|
+
/** Keep a toast in notification history. Overrides the provideGoodUI default; inbox delivery always stays in history. */
|
|
38
|
+
persist?: boolean;
|
|
39
|
+
requireAcknowledgement?: boolean;
|
|
40
|
+
actions?: readonly GoodNotificationAction[];
|
|
41
|
+
/** Optional Progress shown in the toast and its saved panel entry. */
|
|
42
|
+
progress?: GoodNotificationProgress;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type GoodNotificationUpdate = Partial<Pick<GoodNotificationRequest,
|
|
46
|
+
'title' | 'message' | 'tone' | 'appearance' | 'icon' | 'progress'>>;
|
|
47
|
+
|
|
48
|
+
export interface GoodNotificationEntry extends GoodNotificationRequest {
|
|
49
|
+
id: string;
|
|
50
|
+
createdAt: number;
|
|
51
|
+
read: boolean;
|
|
52
|
+
visible: boolean;
|
|
53
|
+
queued: boolean;
|
|
54
|
+
delivery: GoodNotificationDelivery;
|
|
55
|
+
tone: GoodAlertTone;
|
|
56
|
+
appearance: GoodAlertAppearance;
|
|
57
|
+
persist: boolean;
|
|
58
|
+
requireAcknowledgement: boolean;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Injectable({ providedIn: 'root' })
|
|
62
|
+
export class GoodNotificationCenter {
|
|
63
|
+
private readonly options = inject(GOODUI_OPTIONS);
|
|
64
|
+
private readonly entriesState = signal<readonly GoodNotificationEntry[]>([]);
|
|
65
|
+
private readonly timers = new Map<string, { started: number; remaining: number; handle: ReturnType<typeof setTimeout> }>();
|
|
66
|
+
private nextId = 0;
|
|
67
|
+
|
|
68
|
+
readonly entries = this.entriesState.asReadonly();
|
|
69
|
+
readonly inbox = computed(() => this.entriesState().filter(entry => entry.persist).reverse());
|
|
70
|
+
readonly toasts = computed(() => this.entriesState().filter(entry => entry.visible && entry.delivery !== 'inbox'));
|
|
71
|
+
readonly unreadCount = computed(() => this.inbox().filter(entry => !entry.read).length);
|
|
72
|
+
|
|
73
|
+
publish(request: GoodNotificationRequest): string {
|
|
74
|
+
const id = `good-notification-${++this.nextId}`;
|
|
75
|
+
const delivery = request.delivery ?? 'toast';
|
|
76
|
+
const visible = delivery !== 'inbox' && this.toasts().length < 3;
|
|
77
|
+
const entry: GoodNotificationEntry = {
|
|
78
|
+
...request,
|
|
79
|
+
id,
|
|
80
|
+
createdAt: Date.now(),
|
|
81
|
+
read: false,
|
|
82
|
+
visible,
|
|
83
|
+
queued: delivery !== 'inbox' && !visible,
|
|
84
|
+
delivery,
|
|
85
|
+
tone: request.tone ?? 'neutral',
|
|
86
|
+
appearance: request.appearance ?? 'default',
|
|
87
|
+
persist: delivery === 'inbox' ? true : request.persist ?? this.options.notifications?.persistToHistory ?? true,
|
|
88
|
+
requireAcknowledgement: request.requireAcknowledgement ?? false,
|
|
89
|
+
};
|
|
90
|
+
this.entriesState.update(entries => [...entries, entry]);
|
|
91
|
+
if (visible) this.startTimer(entry);
|
|
92
|
+
return id;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Update a published message without changing its delivery, timestamp, or read state. */
|
|
96
|
+
update(id: string, changes: GoodNotificationUpdate): void {
|
|
97
|
+
this.entriesState.update(entries => entries.map(entry => entry.id === id ? { ...entry, ...changes } : entry));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
dismissToast(id: string): void {
|
|
101
|
+
this.clearTimer(id);
|
|
102
|
+
this.entriesState.update(entries => entries
|
|
103
|
+
.map(entry => entry.id === id ? { ...entry, visible: false } : entry)
|
|
104
|
+
.filter(entry => entry.persist || entry.visible || entry.queued));
|
|
105
|
+
this.promote();
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
acknowledge(id: string): void {
|
|
109
|
+
this.clearTimer(id);
|
|
110
|
+
this.entriesState.update(entries => entries
|
|
111
|
+
.map(entry => entry.id === id ? { ...entry, visible: false, read: true } : entry)
|
|
112
|
+
.filter(entry => entry.persist || entry.visible || entry.queued));
|
|
113
|
+
this.promote();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
markRead(id: string): void {
|
|
117
|
+
this.entriesState.update(entries => entries.map(entry => entry.id === id ? { ...entry, read: true } : entry));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
remove(id: string): void {
|
|
121
|
+
this.clearTimer(id);
|
|
122
|
+
this.entriesState.update(entries => entries.filter(entry => entry.id !== id));
|
|
123
|
+
this.promote();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
pause(id: string): void {
|
|
127
|
+
const timer = this.timers.get(id);
|
|
128
|
+
if (!timer) return;
|
|
129
|
+
clearTimeout(timer.handle);
|
|
130
|
+
timer.remaining = Math.max(0, timer.remaining - (Date.now() - timer.started));
|
|
131
|
+
this.timers.delete(id);
|
|
132
|
+
this.paused.set(id, timer.remaining);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
resume(id: string): void {
|
|
136
|
+
const remaining = this.paused.get(id);
|
|
137
|
+
if (remaining === undefined) return;
|
|
138
|
+
this.paused.delete(id);
|
|
139
|
+
this.schedule(id, Math.max(remaining, 500));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
private readonly paused = new Map<string, number>();
|
|
143
|
+
|
|
144
|
+
private startTimer(entry: GoodNotificationEntry): void {
|
|
145
|
+
const duration = entry.requireAcknowledgement ? 0 : entry.duration === undefined ? 5000 :
|
|
146
|
+
Number.isFinite(entry.duration) ? Math.max(0, entry.duration) : 5000;
|
|
147
|
+
if (duration > 0) this.schedule(entry.id, duration);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
private promote(): void {
|
|
151
|
+
while (this.toasts().length < 3) {
|
|
152
|
+
const next = this.entriesState().find(entry => entry.queued);
|
|
153
|
+
if (!next) return;
|
|
154
|
+
this.entriesState.update(entries => entries.map(entry => entry.id === next.id ? { ...entry, queued: false, visible: true } : entry));
|
|
155
|
+
this.startTimer(next);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private schedule(id: string, duration: number): void {
|
|
160
|
+
const handle = setTimeout(() => this.dismissToast(id), duration);
|
|
161
|
+
this.timers.set(id, { started: Date.now(), remaining: duration, handle });
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
private clearTimer(id: string): void {
|
|
165
|
+
const timer = this.timers.get(id);
|
|
166
|
+
if (timer) clearTimeout(timer.handle);
|
|
167
|
+
this.timers.delete(id);
|
|
168
|
+
this.paused.delete(id);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
|
2
|
+
import { LucideInfo } from '@lucide/angular';
|
|
3
|
+
import { GoodAlertComponent } from './alert';
|
|
4
|
+
import { GoodButtonComponent } from './button';
|
|
5
|
+
import { GoodLinkComponent } from './link';
|
|
6
|
+
import { GoodProgressComponent } from './progress';
|
|
7
|
+
import { GoodNotificationAction, GoodNotificationCenter, GoodNotificationEntry } from './notification-center';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'good-notification-host',
|
|
11
|
+
standalone: true,
|
|
12
|
+
imports: [GoodAlertComponent, GoodButtonComponent, GoodLinkComponent, GoodProgressComponent],
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
host: { class: 'good-notification-host' },
|
|
15
|
+
template: `
|
|
16
|
+
<div class="good-toast-stack good-toast-stack-right" aria-label="Notifications" aria-live="polite">
|
|
17
|
+
@for (item of center.toasts(); track item.id) {
|
|
18
|
+
@if (item.delivery === 'toast') {
|
|
19
|
+
<div class="good-toast" (mouseenter)="center.pause(item.id)" (mouseleave)="center.resume(item.id)"
|
|
20
|
+
(focusin)="center.pause(item.id)" (focusout)="onFocusOut($event, item.id)">
|
|
21
|
+
<good-alert [tone]="item.tone" [appearance]="item.appearance" [title]="item.title"
|
|
22
|
+
[message]="item.message ?? ''" [icon]="item.icon ?? infoIcon"
|
|
23
|
+
[dismissible]="!item.requireAcknowledgement" (closed)="center.dismissToast(item.id)">
|
|
24
|
+
@if (item.progress; as progress) {
|
|
25
|
+
<good-progress [mode]="progress.mode ?? 'determinate'" [appearance]="progress.appearance ?? 'solid'"
|
|
26
|
+
[size]="progress.size ?? 'small'" [value]="progress.value ?? 0"
|
|
27
|
+
[durationMs]="progress.durationMs ?? 5000" [loop]="progress.loop ?? true"
|
|
28
|
+
[title]="progress.title ?? ''" [showPercent]="progress.showPercent ?? true"
|
|
29
|
+
[color]="progress.color ?? (item.tone === 'neutral' ? 'secondary' : item.tone)"
|
|
30
|
+
[ariaLabel]="progress.ariaLabel ?? (item.title + ' progress')" />
|
|
31
|
+
}
|
|
32
|
+
<div goodAlertActions>
|
|
33
|
+
@for (action of item.actions ?? []; track action.label) {
|
|
34
|
+
@if (action.route) { <good-link [route]="action.route" (click)="activate(item, action)">{{ action.label }}</good-link> }
|
|
35
|
+
@else { <good-button size="small" variant="secondary" (click)="activate(item, action)">{{ action.label }}</good-button> }
|
|
36
|
+
}
|
|
37
|
+
@if (item.requireAcknowledgement) { <good-button size="small" (click)="center.acknowledge(item.id)">Acknowledge</good-button> }
|
|
38
|
+
</div>
|
|
39
|
+
</good-alert>
|
|
40
|
+
</div>
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
</div>
|
|
44
|
+
<div class="good-toast-stack good-toast-stack-top" aria-label="Notifications from above" aria-live="polite">
|
|
45
|
+
@for (item of center.toasts(); track item.id) {
|
|
46
|
+
@if (item.delivery === 'top') {
|
|
47
|
+
<div class="good-toast" (mouseenter)="center.pause(item.id)" (mouseleave)="center.resume(item.id)"
|
|
48
|
+
(focusin)="center.pause(item.id)" (focusout)="onFocusOut($event, item.id)">
|
|
49
|
+
<good-alert [tone]="item.tone" [appearance]="item.appearance" [title]="item.title"
|
|
50
|
+
[message]="item.message ?? ''" [icon]="item.icon ?? infoIcon"
|
|
51
|
+
[dismissible]="!item.requireAcknowledgement" (closed)="center.dismissToast(item.id)">
|
|
52
|
+
@if (item.progress; as progress) {
|
|
53
|
+
<good-progress [mode]="progress.mode ?? 'determinate'" [appearance]="progress.appearance ?? 'solid'"
|
|
54
|
+
[size]="progress.size ?? 'small'" [value]="progress.value ?? 0"
|
|
55
|
+
[durationMs]="progress.durationMs ?? 5000" [loop]="progress.loop ?? true"
|
|
56
|
+
[title]="progress.title ?? ''" [showPercent]="progress.showPercent ?? true"
|
|
57
|
+
[color]="progress.color ?? (item.tone === 'neutral' ? 'secondary' : item.tone)"
|
|
58
|
+
[ariaLabel]="progress.ariaLabel ?? (item.title + ' progress')" />
|
|
59
|
+
}
|
|
60
|
+
<div goodAlertActions>
|
|
61
|
+
@for (action of item.actions ?? []; track action.label) {
|
|
62
|
+
@if (action.route) { <good-link [route]="action.route" (click)="activate(item, action)">{{ action.label }}</good-link> }
|
|
63
|
+
@else { <good-button size="small" variant="secondary" (click)="activate(item, action)">{{ action.label }}</good-button> }
|
|
64
|
+
}
|
|
65
|
+
@if (item.requireAcknowledgement) { <good-button size="small" (click)="center.acknowledge(item.id)">Acknowledge</good-button> }
|
|
66
|
+
</div>
|
|
67
|
+
</good-alert>
|
|
68
|
+
</div>
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
</div>
|
|
72
|
+
`,
|
|
73
|
+
})
|
|
74
|
+
export class GoodNotificationHostComponent {
|
|
75
|
+
readonly center = inject(GoodNotificationCenter);
|
|
76
|
+
readonly infoIcon = LucideInfo;
|
|
77
|
+
|
|
78
|
+
activate(item: GoodNotificationEntry, action: GoodNotificationAction): void {
|
|
79
|
+
action.run?.();
|
|
80
|
+
this.center.acknowledge(item.id);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
onFocusOut(event: FocusEvent, id: string): void {
|
|
84
|
+
if (!(event.currentTarget as HTMLElement).contains(event.relatedTarget as Node | null)) this.center.resume(id);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, OnDestroy, booleanAttribute, computed, effect, forwardRef, input, model, signal } from '@angular/core';
|
|
2
|
+
import { AbstractControl, ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator } from '@angular/forms';
|
|
3
|
+
import { LucideDynamicIcon, LucideMinus, LucidePlus } from '@lucide/angular';
|
|
4
|
+
import { GoodButtonIcon } from './models';
|
|
5
|
+
|
|
6
|
+
export type GoodNumberInputSize = 'small' | 'default' | 'large';
|
|
7
|
+
|
|
8
|
+
let nextNumberInputId = 0;
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'good-number-input',
|
|
12
|
+
standalone: true,
|
|
13
|
+
imports: [LucideDynamicIcon],
|
|
14
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
15
|
+
host: { class: 'good-number-input', '[attr.data-full-width]': 'fullWidth()' },
|
|
16
|
+
providers: [
|
|
17
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodNumberInputComponent), multi: true },
|
|
18
|
+
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => GoodNumberInputComponent), multi: true },
|
|
19
|
+
],
|
|
20
|
+
template: `
|
|
21
|
+
@if (showLabel()) { <label class="good-number-label" [for]="fieldId()">{{ label() }}</label> }
|
|
22
|
+
<div class="good-number-control" [attr.data-size]="size()" [attr.data-disabled]="isDisabled()"
|
|
23
|
+
[attr.data-editing]="editing()" [attr.data-animating]="previousText() !== null">
|
|
24
|
+
<button type="button" class="good-number-button" [disabled]="isDisabled() || atMin()"
|
|
25
|
+
[attr.aria-label]="'Decrease ' + label()" (click)="adjust(-1)">
|
|
26
|
+
<svg [lucideIcon]="minusIcon" [size]="iconSize()" aria-hidden="true"></svg>
|
|
27
|
+
</button>
|
|
28
|
+
<div class="good-number-center">
|
|
29
|
+
@if (icon(); as displayIcon) {
|
|
30
|
+
<svg class="good-number-icon" [lucideIcon]="displayIcon" [size]="iconSize()" aria-hidden="true"></svg>
|
|
31
|
+
}
|
|
32
|
+
<div class="good-number-display" aria-hidden="true">
|
|
33
|
+
@if (previousText(); as previous) {
|
|
34
|
+
<span class="good-number-digits good-number-digits-exit">
|
|
35
|
+
@for (digit of previous.split(''); track $index) { <span [style.--digit-index]="$index">{{ digit }}</span> }
|
|
36
|
+
</span>
|
|
37
|
+
<span class="good-number-digits good-number-digits-enter">
|
|
38
|
+
@for (digit of displayText().split(''); track $index) { <span [style.--digit-index]="$index">{{ digit }}</span> }
|
|
39
|
+
</span>
|
|
40
|
+
} @else {
|
|
41
|
+
<span class="good-number-digits">
|
|
42
|
+
@for (digit of displayText().split(''); track $index) { <span>{{ digit }}</span> }
|
|
43
|
+
</span>
|
|
44
|
+
}
|
|
45
|
+
</div>
|
|
46
|
+
<input class="good-number-native" type="number" inputmode="decimal" [id]="fieldId()" [name]="name()"
|
|
47
|
+
[value]="editing() ? draft() : displayText()" [min]="effectiveMin()" [attr.max]="finiteMax()"
|
|
48
|
+
[step]="effectiveStep()" [disabled]="isDisabled()" [attr.aria-label]="label()"
|
|
49
|
+
[attr.aria-describedby]="describedBy() || null" [attr.aria-invalid]="invalid() ? 'true' : null"
|
|
50
|
+
(focus)="onFocus()" (input)="onInput($event)" (blur)="onBlur()" (keydown)="onKeydown($event)" />
|
|
51
|
+
</div>
|
|
52
|
+
<button type="button" class="good-number-button" [disabled]="isDisabled() || atMax()"
|
|
53
|
+
[attr.aria-label]="'Increase ' + label()" (click)="adjust(1)">
|
|
54
|
+
<svg [lucideIcon]="plusIcon" [size]="iconSize()" aria-hidden="true"></svg>
|
|
55
|
+
</button>
|
|
56
|
+
</div>
|
|
57
|
+
`,
|
|
58
|
+
})
|
|
59
|
+
export class GoodNumberInputComponent implements ControlValueAccessor, Validator, OnDestroy {
|
|
60
|
+
readonly value = model(0);
|
|
61
|
+
readonly min = input(0);
|
|
62
|
+
readonly max = input(Infinity);
|
|
63
|
+
readonly step = input(1);
|
|
64
|
+
readonly size = input<GoodNumberInputSize>('default');
|
|
65
|
+
readonly fullWidth = input(true, { transform: booleanAttribute });
|
|
66
|
+
readonly disabled = input(false);
|
|
67
|
+
readonly icon = input<GoodButtonIcon>();
|
|
68
|
+
readonly label = input('Number');
|
|
69
|
+
readonly showLabel = input(false);
|
|
70
|
+
readonly name = input('');
|
|
71
|
+
readonly inputId = input('');
|
|
72
|
+
readonly describedBy = input('');
|
|
73
|
+
|
|
74
|
+
readonly minusIcon = LucideMinus;
|
|
75
|
+
readonly plusIcon = LucidePlus;
|
|
76
|
+
readonly fieldId = computed(() => this.inputId() || this.generatedId);
|
|
77
|
+
readonly effectiveMin = computed(() => Number.isFinite(this.min()) ? this.min() : 0);
|
|
78
|
+
readonly effectiveMax = computed(() => Number.isFinite(this.max()) ? Math.max(this.effectiveMin(), this.max()) : Infinity);
|
|
79
|
+
readonly finiteMax = computed(() => Number.isFinite(this.effectiveMax()) ? this.effectiveMax() : null);
|
|
80
|
+
readonly effectiveStep = computed(() => Number.isFinite(this.step()) && this.step() > 0 ? this.step() : 1);
|
|
81
|
+
readonly displayText = computed(() => String(this.value()));
|
|
82
|
+
readonly atMin = computed(() => this.value() <= this.effectiveMin());
|
|
83
|
+
readonly atMax = computed(() => this.value() >= this.effectiveMax());
|
|
84
|
+
readonly iconSize = computed(() => ({ small: 14, default: 16, large: 20 })[this.size()]);
|
|
85
|
+
readonly editing = signal(false);
|
|
86
|
+
readonly draft = signal('');
|
|
87
|
+
readonly previousText = signal<string | null>(null);
|
|
88
|
+
private readonly formDisabled = signal(false);
|
|
89
|
+
readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
90
|
+
readonly invalid = computed(() => !Number.isFinite(this.value()) || this.value() < this.effectiveMin() || this.value() > this.effectiveMax());
|
|
91
|
+
private readonly generatedId = `good-number-${++nextNumberInputId}`;
|
|
92
|
+
private animationTimer: ReturnType<typeof setTimeout> | null = null;
|
|
93
|
+
private onChange: (value: number) => void = () => {};
|
|
94
|
+
private onTouched: () => void = () => {};
|
|
95
|
+
private onValidatorChange: () => void = () => {};
|
|
96
|
+
|
|
97
|
+
constructor() {
|
|
98
|
+
effect(() => {
|
|
99
|
+
const normalized = this.clamp(this.value());
|
|
100
|
+
if (normalized !== this.value()) {
|
|
101
|
+
this.value.set(normalized);
|
|
102
|
+
this.onChange(normalized);
|
|
103
|
+
}
|
|
104
|
+
this.isDisabled();
|
|
105
|
+
this.onValidatorChange();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
private clamp(value: number): number {
|
|
110
|
+
const finite = Number.isFinite(value) ? value : this.effectiveMin();
|
|
111
|
+
return Math.min(this.effectiveMax(), Math.max(this.effectiveMin(), finite));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private commit(value: number, animate = true): void {
|
|
115
|
+
const next = this.clamp(value);
|
|
116
|
+
if (next === this.value()) return;
|
|
117
|
+
if (this.animationTimer) clearTimeout(this.animationTimer);
|
|
118
|
+
this.previousText.set(animate ? this.displayText() : null);
|
|
119
|
+
this.value.set(next);
|
|
120
|
+
this.onChange(next);
|
|
121
|
+
if (animate) this.animationTimer = setTimeout(() => this.previousText.set(null), 320);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
adjust(direction: -1 | 1): void {
|
|
125
|
+
if (this.isDisabled()) return;
|
|
126
|
+
const step = this.effectiveStep();
|
|
127
|
+
const precision = Math.min(12, Math.max(this.decimals(step), this.decimals(this.value()), this.decimals(this.effectiveMin())));
|
|
128
|
+
const next = Number((this.value() + direction * step).toFixed(precision));
|
|
129
|
+
this.commit(next);
|
|
130
|
+
this.onTouched();
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
private decimals(value: number): number {
|
|
134
|
+
const text = String(value);
|
|
135
|
+
return text.includes('e-') ? Number(text.split('e-')[1]) : (text.split('.')[1]?.length ?? 0);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
onFocus(): void { this.editing.set(true); this.draft.set(this.displayText()); }
|
|
139
|
+
onInput(event: Event): void { this.draft.set((event.target as HTMLInputElement).value); }
|
|
140
|
+
onBlur(): void {
|
|
141
|
+
this.finishEditing();
|
|
142
|
+
this.onTouched();
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
onKeydown(event: KeyboardEvent): void {
|
|
146
|
+
if (event.key === 'ArrowUp' || event.key === 'ArrowDown') {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
this.adjust(event.key === 'ArrowUp' ? 1 : -1);
|
|
149
|
+
this.draft.set(this.displayText());
|
|
150
|
+
} else if (event.key === 'Enter') {
|
|
151
|
+
event.preventDefault();
|
|
152
|
+
(event.target as HTMLInputElement).blur();
|
|
153
|
+
} else if (event.key === 'Escape') {
|
|
154
|
+
this.draft.set(this.displayText());
|
|
155
|
+
(event.target as HTMLInputElement).blur();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private finishEditing(): void {
|
|
160
|
+
if (!this.editing()) return;
|
|
161
|
+
this.editing.set(false);
|
|
162
|
+
const next = Number(this.draft());
|
|
163
|
+
if (this.draft().trim() && Number.isFinite(next)) this.commit(next);
|
|
164
|
+
this.draft.set(this.displayText());
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
validate(_control: AbstractControl): ValidationErrors | null {
|
|
168
|
+
return !this.isDisabled() && this.invalid() ? { numberRange: { min: this.effectiveMin(), max: this.finiteMax() } } : null;
|
|
169
|
+
}
|
|
170
|
+
registerOnValidatorChange(fn: () => void): void { this.onValidatorChange = fn; }
|
|
171
|
+
writeValue(value: unknown): void {
|
|
172
|
+
if (this.animationTimer) clearTimeout(this.animationTimer);
|
|
173
|
+
this.previousText.set(null);
|
|
174
|
+
this.value.set(this.clamp(typeof value === 'number' ? value : Number(value)));
|
|
175
|
+
}
|
|
176
|
+
registerOnChange(fn: (value: number) => void): void { this.onChange = fn; }
|
|
177
|
+
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
|
|
178
|
+
setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); }
|
|
179
|
+
ngOnDestroy(): void { if (this.animationTimer) clearTimeout(this.animationTimer); }
|
|
180
|
+
}
|