@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,305 @@
|
|
|
1
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
2
|
+
import { AbstractControl, ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator } from '@angular/forms';
|
|
3
|
+
import {
|
|
4
|
+
ChangeDetectionStrategy, Component, DestroyRef, OnChanges, OnInit, PLATFORM_ID, SimpleChanges,
|
|
5
|
+
computed, effect, forwardRef, inject, input, model, output, signal,
|
|
6
|
+
} from '@angular/core';
|
|
7
|
+
import type { CountryCode } from 'libphonenumber-js/min';
|
|
8
|
+
import { GOOD_COUNTRY_CODES, goodCountryFlagUrl, loadGoodCountryFlags } from './country-data';
|
|
9
|
+
import { GoodInputSize } from './input';
|
|
10
|
+
import { GoodSelectComponent, GoodSelectOption, GoodSelectValue } from './select';
|
|
11
|
+
import { GOOD_COMPOSITE_REQUIRED_CONTROL } from './required-control';
|
|
12
|
+
|
|
13
|
+
const flagCountries = new Set(GOOD_COUNTRY_CODES);
|
|
14
|
+
type PhoneMetadata = typeof import('libphonenumber-js/min');
|
|
15
|
+
let phoneMetadataLoad: Promise<PhoneMetadata> | undefined;
|
|
16
|
+
const loadPhoneMetadata = (): Promise<PhoneMetadata> => phoneMetadataLoad ??= import('libphonenumber-js/min');
|
|
17
|
+
const onlyDigits = (value: string): string => value.replace(/\D/g, '');
|
|
18
|
+
const nationalDigits = (value: string): string => onlyDigits(value).replace(/^0+/, '');
|
|
19
|
+
const internationalPrefixLength = (value: string): number => value.startsWith('+') ? 1 : value.startsWith('00') ? 2 : 0;
|
|
20
|
+
let nextPhoneId = 0;
|
|
21
|
+
|
|
22
|
+
@Component({
|
|
23
|
+
selector: 'good-input-phone',
|
|
24
|
+
standalone: true,
|
|
25
|
+
imports: [GoodSelectComponent],
|
|
26
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
27
|
+
host: { class: 'good-input-phone' },
|
|
28
|
+
providers: [
|
|
29
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodInputPhoneComponent), multi: true },
|
|
30
|
+
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => GoodInputPhoneComponent), multi: true },
|
|
31
|
+
{ provide: GOOD_COMPOSITE_REQUIRED_CONTROL, useExisting: forwardRef(() => GoodInputPhoneComponent) },
|
|
32
|
+
],
|
|
33
|
+
template: `
|
|
34
|
+
@if (showLabel()) {
|
|
35
|
+
<label class="good-phone-label" [for]="fieldId()">{{ label() }}
|
|
36
|
+
@if (effectiveRequired()) { <span class="good-required-mark" aria-hidden="true">*</span><span class="good-sr-only"> required</span> }
|
|
37
|
+
</label>
|
|
38
|
+
}
|
|
39
|
+
<div class="good-phone-shell" [attr.data-size]="size()" [attr.data-disabled]="isDisabled()"
|
|
40
|
+
[attr.data-readonly]="readonly()" [attr.data-invalid]="error()">
|
|
41
|
+
<good-select class="good-phone-country" label="Country calling code" [options]="countryOptions()"
|
|
42
|
+
[value]="selectedCountry()" (valueChange)="onCountrySelection($event)"
|
|
43
|
+
[size]="size()" [disabled]="isDisabled() || readonly()" [searchable]="true"
|
|
44
|
+
searchPlaceholder="Search country or code" />
|
|
45
|
+
<span class="good-phone-divider" aria-hidden="true"></span>
|
|
46
|
+
<input class="good-phone-number" type="tel" inputmode="tel" [id]="fieldId()"
|
|
47
|
+
[value]="inputText()" [placeholder]="placeholder()" [disabled]="isDisabled()"
|
|
48
|
+
[readOnly]="readonly()" [required]="effectiveRequired()" [attr.aria-label]="label()"
|
|
49
|
+
[attr.aria-required]="effectiveRequired() ? 'true' : null"
|
|
50
|
+
[attr.aria-invalid]="error() ? 'true' : null" [attr.aria-describedby]="describedBy() || null"
|
|
51
|
+
[attr.autocomplete]="autocomplete()" (input)="onNumberInput($event)" (blur)="onBlur()" />
|
|
52
|
+
</div>
|
|
53
|
+
@if (name()) { <input type="hidden" [name]="name()" [value]="value()" [disabled]="isDisabled()" /> }
|
|
54
|
+
`,
|
|
55
|
+
})
|
|
56
|
+
export class GoodInputPhoneComponent implements ControlValueAccessor, Validator, OnInit, OnChanges {
|
|
57
|
+
private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
58
|
+
private readonly destroyRef = inject(DestroyRef);
|
|
59
|
+
private readonly flags = signal<Record<string, string>>({});
|
|
60
|
+
private readonly metadata = signal<PhoneMetadata | null>(null);
|
|
61
|
+
private readonly formDisabled = signal(false);
|
|
62
|
+
private readonly fieldRequired = signal(false);
|
|
63
|
+
private initialized = false;
|
|
64
|
+
private viewReady = false;
|
|
65
|
+
private lastEmittedValue: string | null = null;
|
|
66
|
+
private onChange: (value: string) => void = () => {};
|
|
67
|
+
private onTouched: () => void = () => {};
|
|
68
|
+
private onValidatorChange: () => void = () => {};
|
|
69
|
+
|
|
70
|
+
readonly value = model('');
|
|
71
|
+
readonly country = input<string | null>(null);
|
|
72
|
+
readonly countryChange = output<string>();
|
|
73
|
+
readonly countries = input<readonly string[] | null>(null);
|
|
74
|
+
readonly selectedCountry = signal<CountryCode>('US');
|
|
75
|
+
readonly nationalNumber = signal('');
|
|
76
|
+
readonly inputText = signal('');
|
|
77
|
+
private readonly unresolvedInternational = signal(false);
|
|
78
|
+
readonly label = input('Phone number');
|
|
79
|
+
readonly showLabel = input(false);
|
|
80
|
+
readonly placeholder = input('Phone number');
|
|
81
|
+
readonly size = input<GoodInputSize>('default');
|
|
82
|
+
readonly disabled = input(false);
|
|
83
|
+
readonly readonly = input(false);
|
|
84
|
+
readonly error = input(false);
|
|
85
|
+
readonly required = input(false);
|
|
86
|
+
readonly validateNumber = input(false);
|
|
87
|
+
readonly locale = input('');
|
|
88
|
+
readonly name = input('');
|
|
89
|
+
readonly inputId = input('');
|
|
90
|
+
readonly describedBy = input('');
|
|
91
|
+
readonly autocomplete = input('tel-national');
|
|
92
|
+
private readonly generatedId = `good-phone-${++nextPhoneId}`;
|
|
93
|
+
readonly fieldId = computed(() => this.inputId() || this.generatedId);
|
|
94
|
+
readonly effectiveRequired = computed(() => this.required() || this.fieldRequired());
|
|
95
|
+
readonly isDisabled = computed(() => this.disabled() || this.formDisabled() || !this.availableCountries().length);
|
|
96
|
+
readonly availableCountries = computed(() => {
|
|
97
|
+
const metadata = this.metadata();
|
|
98
|
+
if (!metadata) return [];
|
|
99
|
+
const phoneCountries = metadata.getCountries().filter(code => flagCountries.has(code));
|
|
100
|
+
const requested = this.countries();
|
|
101
|
+
if (!requested) return phoneCountries;
|
|
102
|
+
const allowed = new Set(requested.map(code => code.toUpperCase()));
|
|
103
|
+
return phoneCountries.filter(code => allowed.has(code));
|
|
104
|
+
});
|
|
105
|
+
readonly countryOptions = computed<readonly GoodSelectOption[]>(() => {
|
|
106
|
+
const metadata = this.metadata();
|
|
107
|
+
if (!metadata) return [];
|
|
108
|
+
const locale = this.resolvedLocale();
|
|
109
|
+
const flags = this.flags();
|
|
110
|
+
let sortLocale = locale;
|
|
111
|
+
let names: Intl.DisplayNames;
|
|
112
|
+
try { names = new Intl.DisplayNames([locale], { type: 'region' }); }
|
|
113
|
+
catch { sortLocale = 'en-US'; names = new Intl.DisplayNames([sortLocale], { type: 'region' }); }
|
|
114
|
+
return this.availableCountries().map(code => {
|
|
115
|
+
const callingCode = metadata.getCountryCallingCode(code);
|
|
116
|
+
const name = names.of(code) ?? code;
|
|
117
|
+
return {
|
|
118
|
+
value: code,
|
|
119
|
+
label: `${name} (+${callingCode})`,
|
|
120
|
+
triggerLabel: `+${callingCode}`,
|
|
121
|
+
description: code,
|
|
122
|
+
iconSrc: goodCountryFlagUrl(flags[code]),
|
|
123
|
+
};
|
|
124
|
+
}).sort((a, b) => a.label.localeCompare(b.label, sortLocale));
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
constructor() {
|
|
128
|
+
void loadGoodCountryFlags().then(flags => { if (!this.destroyRef.destroyed) this.flags.set(flags); });
|
|
129
|
+
void loadPhoneMetadata().then(metadata => {
|
|
130
|
+
if (this.destroyRef.destroyed) return;
|
|
131
|
+
this.metadata.set(metadata);
|
|
132
|
+
if (this.viewReady) this.initializePhoneState();
|
|
133
|
+
});
|
|
134
|
+
effect(() => {
|
|
135
|
+
this.effectiveRequired();
|
|
136
|
+
this.isDisabled();
|
|
137
|
+
this.readonly();
|
|
138
|
+
this.validateNumber();
|
|
139
|
+
this.nationalNumber();
|
|
140
|
+
this.unresolvedInternational();
|
|
141
|
+
this.onValidatorChange();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
ngOnInit(): void {
|
|
146
|
+
this.viewReady = true;
|
|
147
|
+
if (this.metadata()) this.initializePhoneState();
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
151
|
+
if (!this.initialized) return;
|
|
152
|
+
if (changes['value']) {
|
|
153
|
+
const incoming = this.value();
|
|
154
|
+
if (incoming === this.lastEmittedValue) this.lastEmittedValue = null;
|
|
155
|
+
else this.applyExternalValue(incoming);
|
|
156
|
+
}
|
|
157
|
+
if (changes['country'] || changes['countries']) {
|
|
158
|
+
const next = this.defaultCountry();
|
|
159
|
+
if (next !== this.selectedCountry()) this.setCountry(next, false);
|
|
160
|
+
} else if (changes['locale'] && !this.nationalNumber() && !this.country()) {
|
|
161
|
+
this.selectedCountry.set(this.defaultCountry());
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
setFieldRequired(required: boolean): void { this.fieldRequired.set(required); }
|
|
166
|
+
validate(_control: AbstractControl): ValidationErrors | null {
|
|
167
|
+
const metadata = this.metadata();
|
|
168
|
+
if (!metadata) return null;
|
|
169
|
+
if (this.isDisabled() || this.readonly()) return null;
|
|
170
|
+
if (this.unresolvedInternational()) return { phone: true };
|
|
171
|
+
if (this.effectiveRequired() && !this.nationalNumber()) return { required: true };
|
|
172
|
+
if (this.validateNumber() && this.nationalNumber() && !metadata.parsePhoneNumberFromString(this.value())?.isPossible()) return { phone: true };
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
registerOnValidatorChange(fn: () => void): void { this.onValidatorChange = fn; }
|
|
176
|
+
writeValue(value: string | null): void { this.applyExternalValue(value ?? ''); }
|
|
177
|
+
registerOnChange(fn: (value: string) => void): void { this.onChange = fn; }
|
|
178
|
+
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
|
|
179
|
+
setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); }
|
|
180
|
+
|
|
181
|
+
onCountrySelection(value: GoodSelectValue): void {
|
|
182
|
+
if (typeof value === 'string' && this.availableCountries().includes(value as CountryCode)) {
|
|
183
|
+
this.inputText.set(this.nationalNumber());
|
|
184
|
+
this.unresolvedInternational.set(false);
|
|
185
|
+
this.setCountry(value as CountryCode, true);
|
|
186
|
+
this.onTouched();
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
onNumberInput(event: Event): void {
|
|
191
|
+
if (this.isDisabled() || this.readonly()) return;
|
|
192
|
+
const raw = (event.target as HTMLInputElement).value;
|
|
193
|
+
this.inputText.set(raw);
|
|
194
|
+
const prefixLength = internationalPrefixLength(raw.trimStart());
|
|
195
|
+
if (prefixLength) {
|
|
196
|
+
const match = this.matchInternational(raw.trimStart(), prefixLength);
|
|
197
|
+
if (match) {
|
|
198
|
+
const previous = this.selectedCountry();
|
|
199
|
+
this.selectedCountry.set(match.country);
|
|
200
|
+
this.nationalNumber.set(match.national);
|
|
201
|
+
this.unresolvedInternational.set(false);
|
|
202
|
+
if (previous !== match.country) this.countryChange.emit(match.country);
|
|
203
|
+
} else {
|
|
204
|
+
this.nationalNumber.set('');
|
|
205
|
+
this.unresolvedInternational.set(true);
|
|
206
|
+
}
|
|
207
|
+
} else {
|
|
208
|
+
this.nationalNumber.set(nationalDigits(raw));
|
|
209
|
+
this.unresolvedInternational.set(false);
|
|
210
|
+
}
|
|
211
|
+
this.emitValue();
|
|
212
|
+
}
|
|
213
|
+
onBlur(): void {
|
|
214
|
+
if (!this.unresolvedInternational()) this.inputText.set(this.nationalNumber());
|
|
215
|
+
this.onTouched();
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
private initializePhoneState(): void {
|
|
219
|
+
if (this.initialized) return;
|
|
220
|
+
this.initialized = true;
|
|
221
|
+
this.selectedCountry.set(this.defaultCountry());
|
|
222
|
+
if (this.value()) this.applyExternalValue(this.value());
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private resolvedLocale(): string {
|
|
226
|
+
return this.locale() || (this.browser ? navigator.language : 'en-US') || 'en-US';
|
|
227
|
+
}
|
|
228
|
+
private defaultCountry(): CountryCode {
|
|
229
|
+
const available = this.availableCountries();
|
|
230
|
+
const explicit = this.country()?.toUpperCase() as CountryCode | undefined;
|
|
231
|
+
if (explicit && available.includes(explicit)) return explicit;
|
|
232
|
+
let region = '';
|
|
233
|
+
try { region = new Intl.Locale(this.resolvedLocale()).maximize().region ?? ''; }
|
|
234
|
+
catch { region = ''; }
|
|
235
|
+
const localeCountry = region.toUpperCase() as CountryCode;
|
|
236
|
+
return available.includes(localeCountry) ? localeCountry : available.includes('US') ? 'US' : available[0] ?? 'US';
|
|
237
|
+
}
|
|
238
|
+
private setCountry(country: CountryCode, emit: boolean): void {
|
|
239
|
+
this.selectedCountry.set(country);
|
|
240
|
+
this.inputText.set(this.nationalNumber());
|
|
241
|
+
this.unresolvedInternational.set(false);
|
|
242
|
+
if (emit) this.countryChange.emit(country);
|
|
243
|
+
this.emitValue();
|
|
244
|
+
}
|
|
245
|
+
private emitValue(): void {
|
|
246
|
+
const metadata = this.metadata();
|
|
247
|
+
if (!metadata) return;
|
|
248
|
+
const number = this.nationalNumber();
|
|
249
|
+
const next = number ? `+${metadata.getCountryCallingCode(this.selectedCountry())}${number}` : '';
|
|
250
|
+
this.lastEmittedValue = next;
|
|
251
|
+
this.value.set(next);
|
|
252
|
+
this.onChange(next);
|
|
253
|
+
this.onValidatorChange();
|
|
254
|
+
}
|
|
255
|
+
private applyExternalValue(value: string): void {
|
|
256
|
+
const raw = String(value ?? '').trim();
|
|
257
|
+
const metadata = this.metadata();
|
|
258
|
+
if (!metadata) { this.value.set(raw); return; }
|
|
259
|
+
if (!raw) {
|
|
260
|
+
this.nationalNumber.set('');
|
|
261
|
+
this.inputText.set('');
|
|
262
|
+
this.unresolvedInternational.set(false);
|
|
263
|
+
this.value.set('');
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
const prefixLength = internationalPrefixLength(raw);
|
|
267
|
+
if (prefixLength) {
|
|
268
|
+
const match = this.matchInternational(raw, prefixLength);
|
|
269
|
+
if (match) {
|
|
270
|
+
this.selectedCountry.set(match.country);
|
|
271
|
+
this.nationalNumber.set(match.national);
|
|
272
|
+
this.inputText.set(match.national);
|
|
273
|
+
this.unresolvedInternational.set(false);
|
|
274
|
+
this.value.set(match.national ? `+${match.callingCode}${match.national}` : '');
|
|
275
|
+
} else {
|
|
276
|
+
this.nationalNumber.set('');
|
|
277
|
+
this.inputText.set(raw);
|
|
278
|
+
this.unresolvedInternational.set(true);
|
|
279
|
+
this.value.set('');
|
|
280
|
+
}
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
const national = nationalDigits(raw);
|
|
284
|
+
this.nationalNumber.set(national);
|
|
285
|
+
this.inputText.set(national);
|
|
286
|
+
this.unresolvedInternational.set(false);
|
|
287
|
+
this.value.set(national ? `+${metadata.getCountryCallingCode(this.selectedCountry())}${national}` : '');
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
private matchInternational(raw: string, prefixLength: number): { country: CountryCode; callingCode: string; national: string } | null {
|
|
291
|
+
const metadata = this.metadata();
|
|
292
|
+
if (!metadata) return null;
|
|
293
|
+
const digits = onlyDigits(raw.slice(prefixLength));
|
|
294
|
+
const callingCodes = [...new Set(this.availableCountries().map(code => metadata.getCountryCallingCode(code)))].sort((a, b) => b.length - a.length);
|
|
295
|
+
const callingCode = callingCodes.find(code => digits.startsWith(code));
|
|
296
|
+
if (!callingCode) return null;
|
|
297
|
+
const candidates = this.availableCountries().filter(code => metadata.getCountryCallingCode(code) === callingCode);
|
|
298
|
+
const parsed = metadata.parsePhoneNumberFromString(`+${digits}`)?.country;
|
|
299
|
+
const explicit = this.country()?.toUpperCase() as CountryCode | undefined;
|
|
300
|
+
const country = [parsed, this.selectedCountry(), explicit, this.defaultCountry(), ...candidates]
|
|
301
|
+
.find(code => code && candidates.includes(code)) as CountryCode | undefined;
|
|
302
|
+
if (!country) return null;
|
|
303
|
+
return { country, callingCode, national: nationalDigits(digits.slice(callingCode.length)) };
|
|
304
|
+
}
|
|
305
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, ElementRef, computed, effect, forwardRef, input, model, output, signal, viewChild } from '@angular/core';
|
|
2
|
+
import { AbstractControl, ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator, Validators } from '@angular/forms';
|
|
3
|
+
import { LucideDynamicIcon } from '@lucide/angular';
|
|
4
|
+
import { GoodButtonIcon } from './models';
|
|
5
|
+
|
|
6
|
+
export type GoodInputSize = 'small' | 'default' | 'large';
|
|
7
|
+
export type GoodInputType = 'text' | 'email' | 'password' | 'search' | 'tel' | 'url' | 'number' | 'file';
|
|
8
|
+
export type GoodInputAddonTone = 'inline' | 'contrast';
|
|
9
|
+
|
|
10
|
+
@Component({
|
|
11
|
+
selector: 'good-input',
|
|
12
|
+
standalone: true,
|
|
13
|
+
imports: [LucideDynamicIcon],
|
|
14
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
15
|
+
providers: [
|
|
16
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodInputComponent), multi: true },
|
|
17
|
+
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => GoodInputComponent), multi: true },
|
|
18
|
+
],
|
|
19
|
+
template: `
|
|
20
|
+
<label class="good-input-field" [attr.data-size]="size()" [attr.data-status]="status()" [attr.data-type]="type()">
|
|
21
|
+
@if (showLabel()) { <span class="good-input-label">{{ label() }}@if (effectiveRequired()) { <span class="good-required-mark" aria-hidden="true">*</span><span class="good-sr-only"> required</span> }</span> }
|
|
22
|
+
<span class="good-input-shell">
|
|
23
|
+
@if (startText() || startIcon()) {
|
|
24
|
+
<span class="good-input-addon" data-side="start" [attr.data-tone]="startTone()" aria-hidden="true">
|
|
25
|
+
@if (startIcon(); as icon) { <svg class="good-input-icon" [lucideIcon]="icon" [size]="iconSize()"></svg> }
|
|
26
|
+
@else { {{ startText() }} }
|
|
27
|
+
</span>
|
|
28
|
+
}
|
|
29
|
+
@if (type() === 'file') {
|
|
30
|
+
<span class="good-input-file-content" aria-hidden="true">
|
|
31
|
+
<span class="good-input-file-action">File</span>
|
|
32
|
+
<span class="good-input-file-name" [class.good-input-file-selected]="hasFiles()">{{ fileNames() }}</span>
|
|
33
|
+
</span>
|
|
34
|
+
<input #fileInput class="good-input-native-file" type="file" [disabled]="isDisabled() || readonly()"
|
|
35
|
+
[required]="effectiveRequired()" [accept]="accept() || null" [multiple]="multiple()" [name]="name()"
|
|
36
|
+
[id]="inputId() || null" [attr.aria-label]="accessibleLabel()" [attr.aria-invalid]="error() ? 'true' : null"
|
|
37
|
+
[attr.aria-describedby]="describedBy() || null" (change)="onFileChange($event)" (blur)="onBlur()" />
|
|
38
|
+
} @else {
|
|
39
|
+
<input class="good-input-native" [type]="type()" [value]="value()" [placeholder]="placeholder()"
|
|
40
|
+
[disabled]="isDisabled()" [readOnly]="readonly()" [required]="effectiveRequired()" [name]="name()"
|
|
41
|
+
[id]="inputId() || null" [attr.aria-label]="accessibleLabel()" [attr.aria-invalid]="error() ? 'true' : null"
|
|
42
|
+
[attr.aria-describedby]="describedBy() || null" [attr.aria-expanded]="ariaExpanded()"
|
|
43
|
+
[attr.aria-controls]="ariaControls() || null" [attr.aria-haspopup]="hasPopup() || null" [attr.autocomplete]="autocomplete() || null"
|
|
44
|
+
(input)="onTextInput($event)" (blur)="onBlur()" />
|
|
45
|
+
}
|
|
46
|
+
@if (endText() || endIcon()) {
|
|
47
|
+
<span class="good-input-addon" data-side="end" [attr.data-tone]="endTone()" aria-hidden="true">
|
|
48
|
+
@if (endIcon(); as icon) { <svg class="good-input-icon" [lucideIcon]="icon" [size]="iconSize()"></svg> }
|
|
49
|
+
@else { {{ endText() }} }
|
|
50
|
+
</span>
|
|
51
|
+
}
|
|
52
|
+
</span>
|
|
53
|
+
</label>
|
|
54
|
+
`,
|
|
55
|
+
host: { class: 'good-input' },
|
|
56
|
+
})
|
|
57
|
+
export class GoodInputComponent implements ControlValueAccessor, Validator {
|
|
58
|
+
readonly label = input.required<string>();
|
|
59
|
+
readonly showLabel = input(false);
|
|
60
|
+
readonly type = input<GoodInputType>('text');
|
|
61
|
+
readonly size = input<GoodInputSize>('default');
|
|
62
|
+
readonly value = model('');
|
|
63
|
+
readonly placeholder = input('');
|
|
64
|
+
readonly disabled = input(false);
|
|
65
|
+
readonly readonly = input(false);
|
|
66
|
+
readonly error = input(false);
|
|
67
|
+
readonly required = input(false);
|
|
68
|
+
readonly fieldRequired = signal(false);
|
|
69
|
+
readonly effectiveRequired = computed(() => this.required() || this.fieldRequired());
|
|
70
|
+
readonly name = input('');
|
|
71
|
+
readonly inputId = input('');
|
|
72
|
+
readonly describedBy = input('');
|
|
73
|
+
readonly autocomplete = input('');
|
|
74
|
+
readonly ariaExpanded = input<boolean | null>(null);
|
|
75
|
+
readonly ariaControls = input('');
|
|
76
|
+
readonly hasPopup = input('');
|
|
77
|
+
readonly accept = input('');
|
|
78
|
+
readonly multiple = input(false);
|
|
79
|
+
readonly startIcon = input<GoodButtonIcon>();
|
|
80
|
+
readonly endIcon = input<GoodButtonIcon>();
|
|
81
|
+
readonly startText = input('');
|
|
82
|
+
readonly endText = input('');
|
|
83
|
+
readonly startTone = input<GoodInputAddonTone>('inline');
|
|
84
|
+
readonly endTone = input<GoodInputAddonTone>('inline');
|
|
85
|
+
readonly filesChange = output<FileList | null>();
|
|
86
|
+
readonly fileNames = signal('No files selected');
|
|
87
|
+
readonly hasFiles = signal(false);
|
|
88
|
+
readonly iconSize = computed(() => ({ small: 14, default: 16, large: 20 })[this.size()]);
|
|
89
|
+
readonly accessibleLabel = computed(() => [this.label(), !this.startIcon() && this.startText(), !this.endIcon() && this.endText()].filter(Boolean).join(', '));
|
|
90
|
+
private readonly formDisabled = signal(false);
|
|
91
|
+
readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
92
|
+
readonly status = computed(() => this.isDisabled() ? 'disabled' : this.error() ? 'error' : this.readonly() ? 'readonly' : 'default');
|
|
93
|
+
private readonly fileInput = viewChild<ElementRef<HTMLInputElement>>('fileInput');
|
|
94
|
+
private onChange: (value: string | FileList | null) => void = () => {};
|
|
95
|
+
private onTouched: () => void = () => {};
|
|
96
|
+
private onValidatorChange: () => void = () => {};
|
|
97
|
+
|
|
98
|
+
constructor() {
|
|
99
|
+
effect(() => {
|
|
100
|
+
this.effectiveRequired();
|
|
101
|
+
this.isDisabled();
|
|
102
|
+
this.readonly();
|
|
103
|
+
this.onValidatorChange();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
setFieldRequired(required: boolean): void { this.fieldRequired.set(required); }
|
|
108
|
+
validate(control: AbstractControl): ValidationErrors | null {
|
|
109
|
+
return this.effectiveRequired() && !this.isDisabled() && !this.readonly() ? Validators.required(control) : null;
|
|
110
|
+
}
|
|
111
|
+
registerOnValidatorChange(fn: () => void): void { this.onValidatorChange = fn; }
|
|
112
|
+
|
|
113
|
+
onTextInput(event: Event): void {
|
|
114
|
+
const next = (event.target as HTMLInputElement).value;
|
|
115
|
+
this.value.set(next);
|
|
116
|
+
this.onChange(next);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
onFileChange(event: Event): void {
|
|
120
|
+
const files = (event.target as HTMLInputElement).files;
|
|
121
|
+
this.hasFiles.set(!!files?.length);
|
|
122
|
+
this.fileNames.set(files?.length ? Array.from(files, file => file.name).join(', ') : 'No files selected');
|
|
123
|
+
this.filesChange.emit(files);
|
|
124
|
+
this.onChange(files);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
onBlur(): void { this.onTouched(); }
|
|
128
|
+
writeValue(value: unknown): void {
|
|
129
|
+
if (this.type() === 'file') {
|
|
130
|
+
if (value == null) {
|
|
131
|
+
const input = this.fileInput()?.nativeElement;
|
|
132
|
+
if (input) input.value = '';
|
|
133
|
+
this.hasFiles.set(false);
|
|
134
|
+
this.fileNames.set('No files selected');
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
this.value.set(value == null ? '' : String(value));
|
|
139
|
+
}
|
|
140
|
+
registerOnChange(fn: (value: string | FileList | null) => void): void { this.onChange = fn; }
|
|
141
|
+
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
|
|
142
|
+
setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); }
|
|
143
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<good-card>
|
|
2
|
+
<good-card-header [title]="title()" [headingLevel]="3">
|
|
3
|
+
@if (showDataToggle()) {
|
|
4
|
+
<good-button goodCardActions variant="ghost" size="small" [iconOnly]="true"
|
|
5
|
+
[icon]="dataVisible() ? chartIcon : tableIcon" [ariaPressed]="dataVisible()"
|
|
6
|
+
[ariaLabel]="dataVisible() ? 'Show chart' : 'Show data'"
|
|
7
|
+
(click)="dataVisible.set(!dataVisible())" />
|
|
8
|
+
}
|
|
9
|
+
</good-card-header>
|
|
10
|
+
<div class="good-chart-config" aria-hidden="true"><ng-content /></div>
|
|
11
|
+
@if (resolved().errors.length) {
|
|
12
|
+
<div class="good-chart-message" role="alert">{{ resolved().errors.join(' ') }}</div>
|
|
13
|
+
} @else if (!resolved().lines.length || !tableRows().length) {
|
|
14
|
+
<div class="good-chart-message">No data to display.</div>
|
|
15
|
+
} @else if (dataVisible()) {
|
|
16
|
+
<p class="good-chart-table-hint">Scroll horizontally to see all series.</p>
|
|
17
|
+
<good-table [label]="title() + ' data'" tableStyle="compact" [data]="tableRows()"
|
|
18
|
+
[columns]="tableColumns()" [reorderable]="false" />
|
|
19
|
+
} @else {
|
|
20
|
+
<div #plot class="good-chart-plot">
|
|
21
|
+
<svg [attr.viewBox]="'0 0 ' + width() + ' ' + height" role="img"
|
|
22
|
+
[attr.aria-label]="ariaLabel() || title()" preserveAspectRatio="xMidYMid meet">
|
|
23
|
+
@for (tick of yTicks(); track $index) {
|
|
24
|
+
<line class="good-chart-grid" [attr.x1]="left" [attr.x2]="width() - right"
|
|
25
|
+
[attr.y1]="tick.y" [attr.y2]="tick.y" />
|
|
26
|
+
<text class="good-chart-tick good-chart-y-tick" [attr.x]="left - 9" [attr.y]="tick.y + 4">{{ tick.label }}</text>
|
|
27
|
+
}
|
|
28
|
+
<line class="good-chart-baseline" [attr.x1]="left" [attr.x2]="width() - right"
|
|
29
|
+
[attr.y1]="top + plotHeight" [attr.y2]="top + plotHeight" />
|
|
30
|
+
@for (tick of xTicks(); track $index) {
|
|
31
|
+
@if (tick.visible) {
|
|
32
|
+
<text class="good-chart-tick good-chart-x-tick" [attr.x]="tick.x"
|
|
33
|
+
[attr.y]="top + plotHeight + 19">{{ tick.label }}</text>
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
@for (line of renderedLines(); track line.id) {
|
|
37
|
+
<path class="good-chart-line-path" [attr.d]="line.path" [attr.stroke]="line.colorValue" />
|
|
38
|
+
@for (dot of line.dots; track $index) {
|
|
39
|
+
<circle class="good-chart-point" [attr.cx]="dot.x" [attr.cy]="dot.y" r="3"
|
|
40
|
+
[attr.stroke]="line.colorValue" />
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
</svg>
|
|
44
|
+
@if (yAxis().label) { <span class="good-chart-y-label">{{ yAxis().label }}</span> }
|
|
45
|
+
@if (xAxis().label) { <span class="good-chart-x-label">{{ xAxis().label }}</span> }
|
|
46
|
+
</div>
|
|
47
|
+
<div class="good-chart-legend" aria-label="Series legend">
|
|
48
|
+
@for (line of renderedLines(); track line.id) {
|
|
49
|
+
<span class="good-chart-legend-item"><i [style.background]="line.colorValue" aria-hidden="true"></i>{{ line.label }}</span>
|
|
50
|
+
}
|
|
51
|
+
</div>
|
|
52
|
+
}
|
|
53
|
+
</good-card>
|