@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,99 @@
|
|
|
1
|
+
import { normalizeHex, rgbToHex } from './color-utils';
|
|
2
|
+
import { GOOD_FONT_OPTIONS, goodFontFamilyCss } from './select-font';
|
|
3
|
+
|
|
4
|
+
const allowedTags = new Set('p div h1 h2 h3 h4 h5 h6 strong b em i u s strike sup sub code small blockquote pre span br ul ol li a img table thead tbody tr th td caption hr'.split(' '));
|
|
5
|
+
const droppedTags = new Set('script style iframe object embed form input button select textarea svg math template meta link'.split(' '));
|
|
6
|
+
const blockTags = new Set('p div h1 h2 h3 h4 h5 h6 blockquote pre li th td caption'.split(' '));
|
|
7
|
+
const listTypes = new Set(['disc', 'circle', 'square', 'decimal', 'lower-alpha', 'upper-alpha', 'lower-greek', 'lower-roman', 'upper-roman']);
|
|
8
|
+
|
|
9
|
+
export function safeRichTextUrl(value: string, image = false): string | null {
|
|
10
|
+
const url = value.trim();
|
|
11
|
+
if (image && /^data:image\/(png|jpeg|gif|webp);base64,[a-z0-9+/=]+$/i.test(url)) return url;
|
|
12
|
+
if (/^https?:\/\//i.test(url)) return url;
|
|
13
|
+
if (!image && /^(mailto:|tel:|#[^\s]+|\/[^/])/i.test(url)) return url;
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function safeColor(value: string): string | null {
|
|
18
|
+
const hex = normalizeHex(value);
|
|
19
|
+
if (hex) return hex;
|
|
20
|
+
const channels = /^rgba?\(\s*(\d{1,3})[,\s]+(\d{1,3})[,\s]+(\d{1,3})(?:[,\s/]+[\d.]+)?\s*\)$/i.exec(value);
|
|
21
|
+
if (!channels) return null;
|
|
22
|
+
return rgbToHex({ r: Number(channels[1]), g: Number(channels[2]), b: Number(channels[3]) });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function safeStyle(source: HTMLElement, target: HTMLElement, tag: string): void {
|
|
26
|
+
const style = source.style;
|
|
27
|
+
if (blockTags.has(tag)) {
|
|
28
|
+
const align = style.textAlign;
|
|
29
|
+
if (['left', 'center', 'right', 'justify'].includes(align)) target.style.textAlign = align;
|
|
30
|
+
}
|
|
31
|
+
if (tag === 'span' || tag === 'small') {
|
|
32
|
+
const color = safeColor(style.color), background = safeColor(style.backgroundColor);
|
|
33
|
+
if (color) target.style.color = color;
|
|
34
|
+
if (background) target.style.backgroundColor = background;
|
|
35
|
+
const size = /^([\d.]+)px$/.exec(style.fontSize);
|
|
36
|
+
if (size && Number(size[1]) >= 8 && Number(size[1]) <= 72) target.style.fontSize = `${Number(size[1])}px`;
|
|
37
|
+
if (style.fontVariant === 'small-caps') target.style.fontVariant = 'small-caps';
|
|
38
|
+
const requestedFont = style.fontFamily.split(',')[0]?.trim().replace(/^["']|["']$/g, '');
|
|
39
|
+
if (requestedFont && GOOD_FONT_OPTIONS.some(font => font.value.toLowerCase() === requestedFont.toLowerCase())) {
|
|
40
|
+
target.style.fontFamily = goodFontFamilyCss(requestedFont) ?? '';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if ((tag === 'ol' || tag === 'ul') && listTypes.has(style.listStyleType)) target.style.listStyleType = style.listStyleType;
|
|
44
|
+
if (tag === 'table') {
|
|
45
|
+
const width = /^([1-9]\d?|100)%$|^([1-9]\d{1,3})px$/.exec(style.width);
|
|
46
|
+
if (width && (!width[2] || Number(width[2]) <= 5000)) target.style.width = width[0];
|
|
47
|
+
}
|
|
48
|
+
if (tag === 'tr') {
|
|
49
|
+
const height = /^(\d{2,4})px$/.exec(style.height);
|
|
50
|
+
if (height && Number(height[1]) >= 32 && Number(height[1]) <= 2000) target.style.height = height[0];
|
|
51
|
+
}
|
|
52
|
+
if (tag === 'td' || tag === 'th') {
|
|
53
|
+
const padding = /^(\d{1,2})px$/.exec(style.padding);
|
|
54
|
+
if (padding && Number(padding[1]) <= 24) target.style.padding = padding[0];
|
|
55
|
+
const width = /^(\d{2,4})px$/.exec(style.width);
|
|
56
|
+
if (width && Number(width[1]) >= 64 && Number(width[1]) <= 2000) target.style.width = width[0];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Removes executable markup and unsupported attributes before HTML enters or leaves the editor. */
|
|
61
|
+
export function sanitizeRichText(document: Document, html: string): string {
|
|
62
|
+
const source = document.createElement('template');
|
|
63
|
+
source.innerHTML = html;
|
|
64
|
+
const clean = document.createElement('div');
|
|
65
|
+
const visit = (node: Node, parent: Node): void => {
|
|
66
|
+
if (node.nodeType === Node.TEXT_NODE) { parent.appendChild(document.createTextNode(node.textContent ?? '')); return; }
|
|
67
|
+
if (!(node instanceof HTMLElement)) return;
|
|
68
|
+
const tag = node.tagName.toLowerCase();
|
|
69
|
+
if (droppedTags.has(tag)) return;
|
|
70
|
+
if (!allowedTags.has(tag)) { for (const child of [...node.childNodes]) visit(child, parent); return; }
|
|
71
|
+
const element = document.createElement(tag);
|
|
72
|
+
if (tag === 'a') {
|
|
73
|
+
const href = safeRichTextUrl(node.getAttribute('href') ?? '');
|
|
74
|
+
if (href) element.setAttribute('href', href);
|
|
75
|
+
if (node.getAttribute('target') === '_blank') {
|
|
76
|
+
element.setAttribute('target', '_blank');
|
|
77
|
+
element.setAttribute('rel', 'noopener noreferrer');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (tag === 'img') {
|
|
81
|
+
const src = safeRichTextUrl(node.getAttribute('src') ?? '', true);
|
|
82
|
+
if (!src) return;
|
|
83
|
+
element.setAttribute('src', src);
|
|
84
|
+
element.setAttribute('alt', node.getAttribute('alt') ?? '');
|
|
85
|
+
}
|
|
86
|
+
if (tag === 'td' || tag === 'th') for (const key of ['colspan', 'rowspan']) {
|
|
87
|
+
const count = Number(node.getAttribute(key));
|
|
88
|
+
if (Number.isInteger(count) && count > 1 && count <= 20) element.setAttribute(key, String(count));
|
|
89
|
+
}
|
|
90
|
+
if (tag === 'th' && ['col', 'row'].includes(node.getAttribute('scope') ?? '')) {
|
|
91
|
+
element.setAttribute('scope', node.getAttribute('scope')!);
|
|
92
|
+
}
|
|
93
|
+
safeStyle(node, element, tag);
|
|
94
|
+
parent.appendChild(element);
|
|
95
|
+
for (const child of [...node.childNodes]) visit(child, element);
|
|
96
|
+
};
|
|
97
|
+
for (const child of [...source.content.childNodes]) visit(child, clean);
|
|
98
|
+
return clean.innerHTML;
|
|
99
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 (errors().length) {
|
|
12
|
+
<div class="good-chart-message" role="alert">{{ errors().join(' ') }}</div>
|
|
13
|
+
} @else if (!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 columns.</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
|
+
@for (tick of xTicks(); track $index) {
|
|
29
|
+
<line class="good-chart-grid good-chart-x-grid" [attr.x1]="tick.x" [attr.x2]="tick.x"
|
|
30
|
+
[attr.y1]="top" [attr.y2]="top + plotHeight" />
|
|
31
|
+
<text class="good-chart-tick good-chart-x-tick" [attr.x]="tick.x"
|
|
32
|
+
[attr.y]="top + plotHeight + 19">{{ tick.label }}</text>
|
|
33
|
+
}
|
|
34
|
+
@for (point of points(); track point.id) {
|
|
35
|
+
<circle class="good-chart-scatter-point" [attr.cx]="point.x" [attr.cy]="point.y"
|
|
36
|
+
r="5" [attr.fill]="point.color"><title>{{ point.label }}</title></circle>
|
|
37
|
+
}
|
|
38
|
+
</svg>
|
|
39
|
+
@if (yAxis().label) { <span class="good-chart-y-label">{{ yAxis().label }}</span> }
|
|
40
|
+
@if (xAxis().label) { <span class="good-chart-x-label">{{ xAxis().label }}</span> }
|
|
41
|
+
</div>
|
|
42
|
+
<div class="good-chart-legend" aria-label="Series legend">
|
|
43
|
+
@for (series of legend(); track series.id) {
|
|
44
|
+
<span class="good-chart-legend-item"><i [style.background]="series.color" aria-hidden="true"></i>{{ series.label }}</span>
|
|
45
|
+
}
|
|
46
|
+
</div>
|
|
47
|
+
}
|
|
48
|
+
</good-card>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { ChangeDetectionStrategy, Component, ElementRef, computed, contentChildren, effect, input, signal, viewChild } from '@angular/core';
|
|
2
|
+
import { LucideChartScatter, LucideTable2 } from '@lucide/angular';
|
|
3
|
+
import { GoodButtonComponent } from './button';
|
|
4
|
+
import { GoodCardActionsDirective, GoodCardComponent, GoodCardHeaderComponent } from './card';
|
|
5
|
+
import { resolveChartColor } from './chart-colors';
|
|
6
|
+
import { GoodChartAxisDefinition, GoodChartDataSource, GoodChartSeriesDefinition, resolveScatterSeries } from './chart-data';
|
|
7
|
+
import { GoodChartAxisComponent } from './line-chart';
|
|
8
|
+
import { GoodTableColumn, GoodTableComponent } from './table';
|
|
9
|
+
|
|
10
|
+
@Component({ selector: 'good-chart-scatter', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush,
|
|
11
|
+
host: { style: 'display:none' }, template: '' })
|
|
12
|
+
export class GoodChartScatterComponent {
|
|
13
|
+
readonly source = input.required<string>();
|
|
14
|
+
readonly xKey = input.required<string>();
|
|
15
|
+
readonly yKey = input.required<string>();
|
|
16
|
+
readonly label = input('');
|
|
17
|
+
readonly color = input('');
|
|
18
|
+
|
|
19
|
+
definition(): GoodChartSeriesDefinition {
|
|
20
|
+
return { source: this.source(), xKey: this.xKey(), yKey: this.yKey(), label: this.label(), color: this.color() };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface ScatterPoint { id: string; x: number; y: number; color: string; label: string }
|
|
25
|
+
|
|
26
|
+
@Component({
|
|
27
|
+
selector: 'good-scatter-chart', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush,
|
|
28
|
+
imports: [GoodButtonComponent, GoodCardComponent, GoodCardHeaderComponent, GoodCardActionsDirective, GoodTableComponent],
|
|
29
|
+
host: { class: 'good-scatter-chart' }, templateUrl: './scatter-chart.html',
|
|
30
|
+
})
|
|
31
|
+
export class GoodScatterChartComponent {
|
|
32
|
+
readonly title = input.required<string>();
|
|
33
|
+
readonly ariaLabel = input('');
|
|
34
|
+
readonly sources = input.required<readonly GoodChartDataSource[]>();
|
|
35
|
+
readonly colors = input<readonly string[]>([]);
|
|
36
|
+
readonly showDataToggle = input(false);
|
|
37
|
+
readonly tableIcon = LucideTable2;
|
|
38
|
+
readonly chartIcon = LucideChartScatter;
|
|
39
|
+
readonly axes = contentChildren(GoodChartAxisComponent);
|
|
40
|
+
readonly seriesDefinitions = contentChildren(GoodChartScatterComponent);
|
|
41
|
+
readonly plotElement = viewChild<ElementRef<HTMLElement>>('plot');
|
|
42
|
+
readonly dataVisible = signal(false);
|
|
43
|
+
readonly width = signal(700);
|
|
44
|
+
private readonly observePlot = effect(onCleanup => {
|
|
45
|
+
const element = this.plotElement()?.nativeElement;
|
|
46
|
+
if (!element || typeof ResizeObserver === 'undefined') return;
|
|
47
|
+
const observer = new ResizeObserver(entries => this.width.set(Math.max(280, Math.round(entries[0].contentRect.width))));
|
|
48
|
+
observer.observe(element);
|
|
49
|
+
onCleanup(() => observer.disconnect());
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
readonly xAxis = computed<GoodChartAxisDefinition>(() => this.axes().find(axis => axis.position() === 'x')?.definition() ?? { type: 'number' });
|
|
53
|
+
readonly yAxis = computed<GoodChartAxisDefinition>(() => this.axes().find(axis => axis.position() === 'y')?.definition() ?? { type: 'number' });
|
|
54
|
+
readonly resolved = computed(() => resolveScatterSeries(this.sources(), this.seriesDefinitions().map(series => series.definition()), this.xAxis()));
|
|
55
|
+
readonly errors = computed(() => {
|
|
56
|
+
const errors = [...this.resolved().errors];
|
|
57
|
+
if (this.yAxis().type !== 'number') errors.push('Scatter: the Y axis must be number.');
|
|
58
|
+
for (const [position, axis] of [['X', this.xAxis()], ['Y', this.yAxis()]] as const) {
|
|
59
|
+
const min = this.bound(axis.min, axis.type);
|
|
60
|
+
const max = this.bound(axis.max, axis.type);
|
|
61
|
+
if (axis.min != null && min == null) errors.push(`${position} axis: invalid minimum.`);
|
|
62
|
+
if (axis.max != null && max == null) errors.push(`${position} axis: invalid maximum.`);
|
|
63
|
+
if (min != null && max != null && min >= max) errors.push(`${position} axis: min must be smaller than max.`);
|
|
64
|
+
}
|
|
65
|
+
return errors;
|
|
66
|
+
});
|
|
67
|
+
readonly height = 300;
|
|
68
|
+
readonly left = 55;
|
|
69
|
+
readonly top = 16;
|
|
70
|
+
readonly bottom = 47;
|
|
71
|
+
readonly right = 18;
|
|
72
|
+
readonly plotWidth = computed(() => Math.max(100, this.width() - this.left - this.right));
|
|
73
|
+
readonly plotHeight = this.height - this.top - this.bottom;
|
|
74
|
+
|
|
75
|
+
readonly xDomain = computed<[number, number]>(() => this.domain(
|
|
76
|
+
this.resolved().lines.flatMap(line => line.points.map(point => Number(point.x))), this.xAxis()));
|
|
77
|
+
readonly yDomain = computed<[number, number]>(() => this.domain(
|
|
78
|
+
this.resolved().lines.flatMap(line => line.points.map(point => point.y)), this.yAxis()));
|
|
79
|
+
|
|
80
|
+
readonly xTicks = computed(() => {
|
|
81
|
+
const [min, max] = this.xDomain();
|
|
82
|
+
const count = Math.max(2, Math.min(Math.floor(this.plotWidth() / 58), Math.round(this.xAxis().ticks ?? 5)));
|
|
83
|
+
return Array.from({ length: count }, (_, index) => {
|
|
84
|
+
const value = min + (max - min) * index / (count - 1);
|
|
85
|
+
return { x: this.xPosition(value), label: this.formatX(value) };
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
readonly yTicks = computed(() => {
|
|
89
|
+
const [min, max] = this.yDomain();
|
|
90
|
+
const count = Math.max(2, Math.min(10, Math.round(this.yAxis().ticks ?? 5)));
|
|
91
|
+
return Array.from({ length: count }, (_, index) => {
|
|
92
|
+
const value = min + (max - min) * index / (count - 1);
|
|
93
|
+
return { y: this.yPosition(value), label: this.formatNumber(value, this.yAxis().precision) };
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
readonly points = computed<readonly ScatterPoint[]>(() => this.resolved().lines.flatMap((series, seriesIndex) =>
|
|
97
|
+
series.points.map((point, pointIndex) => ({
|
|
98
|
+
id: `${series.id}:${pointIndex}`, x: this.xPosition(Number(point.x)), y: this.yPosition(point.y),
|
|
99
|
+
color: resolveChartColor(series.color, this.colors(), seriesIndex),
|
|
100
|
+
label: `${series.label}, ${this.xAxis().label || 'X'}: ${this.formatX(Number(point.x))}, ${this.yAxis().label || 'Y'}: ${this.formatNumber(point.y, undefined)}`,
|
|
101
|
+
})).filter(point => Number.isFinite(point.x) && Number.isFinite(point.y) &&
|
|
102
|
+
point.x >= this.left && point.x <= this.width() - this.right &&
|
|
103
|
+
point.y >= this.top && point.y <= this.top + this.plotHeight)));
|
|
104
|
+
readonly legend = computed(() => this.resolved().lines.map((series, index) => ({
|
|
105
|
+
id: series.id, label: series.label, color: resolveChartColor(series.color, this.colors(), index),
|
|
106
|
+
})));
|
|
107
|
+
readonly tableRows = computed(() => this.resolved().lines.flatMap(series => series.points.map(point => ({
|
|
108
|
+
series: series.label, x: this.formatX(Number(point.x)), y: point.y,
|
|
109
|
+
}))));
|
|
110
|
+
readonly tableColumns = computed<GoodTableColumn<{ series: string; x: string; y: number }>[]>(() => [
|
|
111
|
+
{ accessorKey: 'series', header: 'Series' },
|
|
112
|
+
{ accessorKey: 'x', header: this.xAxis().label || 'X', meta: { align: 'end' } },
|
|
113
|
+
{ accessorKey: 'y', header: this.yAxis().label || 'Y', meta: { align: 'end' } },
|
|
114
|
+
]);
|
|
115
|
+
|
|
116
|
+
xPosition(value: number): number {
|
|
117
|
+
const [min, max] = this.xDomain();
|
|
118
|
+
return this.left + (value - min) * this.plotWidth() / (max - min);
|
|
119
|
+
}
|
|
120
|
+
yPosition(value: number): number {
|
|
121
|
+
const [min, max] = this.yDomain();
|
|
122
|
+
return this.top + (max - value) * this.plotHeight / (max - min);
|
|
123
|
+
}
|
|
124
|
+
private domain(values: readonly number[], axis: GoodChartAxisDefinition): [number, number] {
|
|
125
|
+
const finite = values.filter(Number.isFinite);
|
|
126
|
+
const rawMin = finite.length ? Math.min(...finite) : 0;
|
|
127
|
+
const rawMax = finite.length ? Math.max(...finite) : 1;
|
|
128
|
+
const padding = Math.max(axis.type === 'time' ? 86_400_000 : .5, (rawMax - rawMin) * .08);
|
|
129
|
+
const min = this.bound(axis.min, axis.type) ?? rawMin - padding;
|
|
130
|
+
const max = this.bound(axis.max, axis.type) ?? rawMax + padding;
|
|
131
|
+
return min < max ? [min, max] : [min - padding, max + padding];
|
|
132
|
+
}
|
|
133
|
+
private bound(value: GoodChartAxisDefinition['min'], type: GoodChartAxisDefinition['type']): number | null {
|
|
134
|
+
if (value == null) return null;
|
|
135
|
+
const number = type === 'time' ? new Date(value).getTime() : typeof value === 'number' ? value : NaN;
|
|
136
|
+
return Number.isFinite(number) ? number : null;
|
|
137
|
+
}
|
|
138
|
+
formatNumber(value: number, precision: number | undefined): string {
|
|
139
|
+
const digits = precision == null ? (Number.isInteger(value) ? 0 : 1) : Math.max(0, Math.min(4, Math.round(precision)));
|
|
140
|
+
return new Intl.NumberFormat('en-US', { maximumFractionDigits: digits, minimumFractionDigits: digits }).format(value);
|
|
141
|
+
}
|
|
142
|
+
formatX(value: number): string {
|
|
143
|
+
if (this.xAxis().type !== 'time') return this.formatNumber(value, this.xAxis().precision);
|
|
144
|
+
const group = this.xAxis().groupBy;
|
|
145
|
+
const options: Intl.DateTimeFormatOptions = group === 'year' ? { year: 'numeric', timeZone: 'UTC' } :
|
|
146
|
+
group === 'month' ? { month: 'short', year: '2-digit', timeZone: 'UTC' } :
|
|
147
|
+
{ month: 'short', day: 'numeric', timeZone: 'UTC' };
|
|
148
|
+
return new Intl.DateTimeFormat('en-US', options).format(value);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { AbstractControl, ControlValueAccessor, NG_VALIDATORS, NG_VALUE_ACCESSOR, ValidationErrors, Validator } from '@angular/forms';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, DestroyRef, computed, effect, forwardRef, inject, input, model, signal } from '@angular/core';
|
|
3
|
+
import { GoodButtonSize } from './models';
|
|
4
|
+
import { GoodSelectComponent, GoodSelectOption, GoodSelectValue } from './select';
|
|
5
|
+
import { GOOD_COUNTRY_CODES, goodCountryFlagUrl, loadGoodCountryFlags } from './country-data';
|
|
6
|
+
|
|
7
|
+
export { GOOD_COUNTRY_CODES } from './country-data';
|
|
8
|
+
|
|
9
|
+
@Component({
|
|
10
|
+
selector: 'good-select-country',
|
|
11
|
+
standalone: true,
|
|
12
|
+
imports: [GoodSelectComponent],
|
|
13
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
14
|
+
providers: [
|
|
15
|
+
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodSelectCountryComponent), multi: true },
|
|
16
|
+
{ provide: NG_VALIDATORS, useExisting: forwardRef(() => GoodSelectCountryComponent), multi: true },
|
|
17
|
+
],
|
|
18
|
+
host: { class: 'good-select-country' },
|
|
19
|
+
template: `
|
|
20
|
+
<good-select [options]="countryOptions()" [value]="value()" (valueChange)="onValueChange($event)"
|
|
21
|
+
[multiple]="multiple()" [maxSelected]="maxSelected()" [size]="size()" [disabled]="isDisabled()"
|
|
22
|
+
[required]="required()" [error]="error()" [label]="label()" [showLabel]="showLabel()"
|
|
23
|
+
[placeholder]="placeholder()" [searchable]="searchable()" [searchPlaceholder]="searchPlaceholder()"
|
|
24
|
+
[describedBy]="describedBy()" />
|
|
25
|
+
`,
|
|
26
|
+
})
|
|
27
|
+
export class GoodSelectCountryComponent implements ControlValueAccessor, Validator {
|
|
28
|
+
private readonly destroyRef = inject(DestroyRef);
|
|
29
|
+
private readonly flagMarkup = signal<Record<string, string>>({});
|
|
30
|
+
readonly value = model<GoodSelectValue>(null);
|
|
31
|
+
readonly countries = input<readonly string[] | null>(null);
|
|
32
|
+
readonly excludedCountries = input<readonly string[]>([]);
|
|
33
|
+
readonly locale = input('en-US');
|
|
34
|
+
readonly multiple = input(false);
|
|
35
|
+
readonly maxSelected = input<number | null>(null);
|
|
36
|
+
readonly size = input<GoodButtonSize>('default');
|
|
37
|
+
readonly disabled = input(false);
|
|
38
|
+
readonly required = input(false);
|
|
39
|
+
readonly error = input(false);
|
|
40
|
+
readonly label = input('Country');
|
|
41
|
+
readonly showLabel = input(false);
|
|
42
|
+
readonly placeholder = input('Select a country');
|
|
43
|
+
readonly searchable = input(true);
|
|
44
|
+
readonly searchPlaceholder = input('Search countries');
|
|
45
|
+
readonly describedBy = input('');
|
|
46
|
+
private readonly formDisabled = signal(false);
|
|
47
|
+
readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
48
|
+
readonly countryOptions = computed<readonly GoodSelectOption[]>(() => {
|
|
49
|
+
const flags = this.flagMarkup();
|
|
50
|
+
const selected = this.countries()?.map(code => code.toUpperCase()) ?? GOOD_COUNTRY_CODES;
|
|
51
|
+
const excluded = new Set(this.excludedCountries().map(code => code.toUpperCase()));
|
|
52
|
+
let locale = this.locale();
|
|
53
|
+
let displayNames: Intl.DisplayNames;
|
|
54
|
+
try { displayNames = new Intl.DisplayNames([locale], { type: 'region' }); }
|
|
55
|
+
catch { locale = 'en-US'; displayNames = new Intl.DisplayNames([locale], { type: 'region' }); }
|
|
56
|
+
return [...new Set(selected)].filter(code => GOOD_COUNTRY_CODES.includes(code) && !excluded.has(code))
|
|
57
|
+
.map(code => ({
|
|
58
|
+
value: code,
|
|
59
|
+
label: displayNames.of(code) ?? code,
|
|
60
|
+
description: code,
|
|
61
|
+
iconSrc: goodCountryFlagUrl(flags[code]),
|
|
62
|
+
}))
|
|
63
|
+
.sort((left, right) => left.label.localeCompare(right.label, locale));
|
|
64
|
+
});
|
|
65
|
+
private onChange: (value: GoodSelectValue) => void = () => {};
|
|
66
|
+
private onTouched: () => void = () => {};
|
|
67
|
+
private onValidatorChange: () => void = () => {};
|
|
68
|
+
|
|
69
|
+
constructor() {
|
|
70
|
+
void loadGoodCountryFlags().then(flags => { if (!this.destroyRef.destroyed) this.flagMarkup.set(flags); });
|
|
71
|
+
effect(() => {
|
|
72
|
+
this.countryOptions();
|
|
73
|
+
this.required();
|
|
74
|
+
this.isDisabled();
|
|
75
|
+
this.value();
|
|
76
|
+
this.multiple();
|
|
77
|
+
this.maxSelected();
|
|
78
|
+
this.onValidatorChange();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
onValueChange(value: GoodSelectValue): void {
|
|
83
|
+
this.value.set(value);
|
|
84
|
+
this.onChange(value);
|
|
85
|
+
this.onTouched();
|
|
86
|
+
this.onValidatorChange();
|
|
87
|
+
}
|
|
88
|
+
validate(_control: AbstractControl): ValidationErrors | null {
|
|
89
|
+
const value = this.value();
|
|
90
|
+
const allowed = new Set(this.countryOptions().map(option => option.value));
|
|
91
|
+
const values = Array.isArray(value) ? value : value == null ? [] : [value as string];
|
|
92
|
+
const selected = [...new Set(values)].filter(code => allowed.has(code));
|
|
93
|
+
if (this.isDisabled()) return null;
|
|
94
|
+
if (this.required() && !selected.length) return { required: true };
|
|
95
|
+
const limit = this.maxSelected();
|
|
96
|
+
return this.multiple() && limit !== null && Number.isFinite(limit) && selected.length > Math.max(0, Math.floor(limit))
|
|
97
|
+
? { maxSelected: { max: Math.max(0, Math.floor(limit)), actual: selected.length } } : null;
|
|
98
|
+
}
|
|
99
|
+
registerOnValidatorChange(fn: () => void): void { this.onValidatorChange = fn; }
|
|
100
|
+
writeValue(value: GoodSelectValue): void { this.value.set(value); }
|
|
101
|
+
registerOnChange(fn: (value: GoodSelectValue) => void): void { this.onChange = fn; }
|
|
102
|
+
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
|
|
103
|
+
setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); }
|
|
104
|
+
}
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { isPlatformBrowser } from '@angular/common';
|
|
2
|
+
import { ChangeDetectionStrategy, Component, ElementRef, HostListener, PLATFORM_ID, computed, effect, forwardRef, inject, input, model, output, signal, viewChild } from '@angular/core';
|
|
3
|
+
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
|
4
|
+
import { LucideCheck, LucideChevronDown, LucideDynamicIcon } from '@lucide/angular';
|
|
5
|
+
import { GoodButtonSize } from './models';
|
|
6
|
+
|
|
7
|
+
export interface GoodFontOption {
|
|
8
|
+
/** CSS font-family name, without a fallback list. */
|
|
9
|
+
value: string;
|
|
10
|
+
label: string;
|
|
11
|
+
fallback: 'sans-serif' | 'serif' | 'monospace';
|
|
12
|
+
generic?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const GOOD_FONT_OPTIONS: readonly GoodFontOption[] = [
|
|
16
|
+
{ value: 'sans-serif', label: 'Sans serif', fallback: 'sans-serif', generic: true },
|
|
17
|
+
{ value: 'serif', label: 'Serif', fallback: 'serif', generic: true },
|
|
18
|
+
{ value: 'monospace', label: 'Monospace', fallback: 'monospace', generic: true },
|
|
19
|
+
{ value: 'system-ui', label: 'System UI', fallback: 'sans-serif', generic: true },
|
|
20
|
+
{ value: 'Arial', label: 'Arial', fallback: 'sans-serif' },
|
|
21
|
+
{ value: 'Helvetica', label: 'Helvetica', fallback: 'sans-serif' },
|
|
22
|
+
{ value: 'Verdana', label: 'Verdana', fallback: 'sans-serif' },
|
|
23
|
+
{ value: 'Tahoma', label: 'Tahoma', fallback: 'sans-serif' },
|
|
24
|
+
{ value: 'Trebuchet MS', label: 'Trebuchet MS', fallback: 'sans-serif' },
|
|
25
|
+
{ value: 'Segoe UI', label: 'Segoe UI', fallback: 'sans-serif' },
|
|
26
|
+
{ value: 'Georgia', label: 'Georgia', fallback: 'serif' },
|
|
27
|
+
{ value: 'Times New Roman', label: 'Times New Roman', fallback: 'serif' },
|
|
28
|
+
{ value: 'Palatino Linotype', label: 'Palatino Linotype', fallback: 'serif' },
|
|
29
|
+
{ value: 'Garamond', label: 'Garamond', fallback: 'serif' },
|
|
30
|
+
{ value: 'Courier New', label: 'Courier New', fallback: 'monospace' },
|
|
31
|
+
{ value: 'Consolas', label: 'Consolas', fallback: 'monospace' },
|
|
32
|
+
{ value: 'Lucida Console', label: 'Lucida Console', fallback: 'monospace' },
|
|
33
|
+
{ value: 'Impact', label: 'Impact', fallback: 'sans-serif' },
|
|
34
|
+
{ value: 'Comic Sans MS', label: 'Comic Sans MS', fallback: 'sans-serif' },
|
|
35
|
+
{ value: 'Liberation Sans', label: 'Liberation Sans', fallback: 'sans-serif' },
|
|
36
|
+
{ value: 'Liberation Serif', label: 'Liberation Serif', fallback: 'serif' },
|
|
37
|
+
{ value: 'Liberation Mono', label: 'Liberation Mono', fallback: 'monospace' },
|
|
38
|
+
{ value: 'DejaVu Sans', label: 'DejaVu Sans', fallback: 'sans-serif' },
|
|
39
|
+
{ value: 'DejaVu Serif', label: 'DejaVu Serif', fallback: 'serif' },
|
|
40
|
+
{ value: 'DejaVu Sans Mono', label: 'DejaVu Sans Mono', fallback: 'monospace' },
|
|
41
|
+
{ value: 'Noto Sans', label: 'Noto Sans', fallback: 'sans-serif' },
|
|
42
|
+
{ value: 'Noto Serif', label: 'Noto Serif', fallback: 'serif' },
|
|
43
|
+
{ value: 'Noto Mono', label: 'Noto Mono', fallback: 'monospace' },
|
|
44
|
+
{ value: 'Ubuntu', label: 'Ubuntu', fallback: 'sans-serif' },
|
|
45
|
+
{ value: 'Roboto', label: 'Roboto', fallback: 'sans-serif' },
|
|
46
|
+
{ value: 'Inter', label: 'Inter', fallback: 'sans-serif' },
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
/** Only offer a named family when the browser can load that exact local face. */
|
|
50
|
+
export async function detectAvailableFonts(options: readonly GoodFontOption[] = GOOD_FONT_OPTIONS,
|
|
51
|
+
FontFaceClass: typeof FontFace | null = typeof FontFace === 'undefined' ? null : FontFace): Promise<GoodFontOption[]> {
|
|
52
|
+
if (!FontFaceClass) return options.filter(option => option.generic);
|
|
53
|
+
const availability = await Promise.all(options.map(async option => {
|
|
54
|
+
if (option.generic) return true;
|
|
55
|
+
if (!/^[a-z][a-z0-9 .-]*$/i.test(option.value)) return false;
|
|
56
|
+
try {
|
|
57
|
+
await new FontFaceClass('goodui-local-font-probe', `local("${option.value}")`).load();
|
|
58
|
+
return true;
|
|
59
|
+
} catch { return false; }
|
|
60
|
+
}));
|
|
61
|
+
return options.filter((_, index) => availability[index]);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function goodFontFamilyCss(value: string, options: readonly GoodFontOption[] = GOOD_FONT_OPTIONS): string | null {
|
|
65
|
+
const option = options.find(font => font.value.toLowerCase() === value.trim().replace(/^["']|["']$/g, '').toLowerCase());
|
|
66
|
+
if (!option) return null;
|
|
67
|
+
return option.generic ? option.value : `"${option.value}", ${option.fallback}`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let nextFontSelectId = 0;
|
|
71
|
+
|
|
72
|
+
@Component({
|
|
73
|
+
selector: 'good-select-font', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush,
|
|
74
|
+
imports: [LucideDynamicIcon],
|
|
75
|
+
providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => GoodSelectFontComponent), multi: true }],
|
|
76
|
+
host: { class: 'good-select-font' },
|
|
77
|
+
template: `
|
|
78
|
+
<button #trigger type="button" class="good-select-font-trigger" role="combobox" aria-haspopup="listbox"
|
|
79
|
+
[attr.data-size]="size()" [attr.aria-label]="label() + ': ' + (selected()?.label ?? 'Choose font')"
|
|
80
|
+
[attr.aria-expanded]="open()" [attr.aria-controls]="open() ? listId : null" [disabled]="isDisabled()"
|
|
81
|
+
(click)="toggle()" (keydown)="onKeydown($event)">
|
|
82
|
+
<span class="good-select-font-current" [style.font-family]="selectedCss()">{{ selected()?.label ?? 'Choose font' }}</span>
|
|
83
|
+
<svg [lucideIcon]="chevronIcon" [size]="16" aria-hidden="true"></svg>
|
|
84
|
+
</button>
|
|
85
|
+
@if (open()) {
|
|
86
|
+
<div class="good-select-font-popup" [style.left.px]="position().left" [style.top.px]="position().top">
|
|
87
|
+
<div class="good-select-font-list" role="listbox" [id]="listId" [attr.aria-label]="label()"
|
|
88
|
+
[attr.aria-activedescendant]="optionId(activeIndex())" tabindex="0" (keydown)="onKeydown($event)">
|
|
89
|
+
@for (font of availableFonts(); track font.value; let index = $index) {
|
|
90
|
+
<div class="good-select-font-option" role="option" [id]="optionId(index)"
|
|
91
|
+
[attr.aria-selected]="value() === font.value" [attr.data-active]="activeIndex() === index"
|
|
92
|
+
(pointerenter)="activeIndex.set(index)" (click)="choose(font)">
|
|
93
|
+
<span class="good-select-font-preview" [style.font-family]="fontCss(font)">{{ font.label }}</span>
|
|
94
|
+
@if (value() === font.value) { <svg [lucideIcon]="checkIcon" [size]="16" aria-hidden="true"></svg> }
|
|
95
|
+
</div>
|
|
96
|
+
}
|
|
97
|
+
</div>
|
|
98
|
+
</div>
|
|
99
|
+
}
|
|
100
|
+
`,
|
|
101
|
+
})
|
|
102
|
+
export class GoodSelectFontComponent implements ControlValueAccessor {
|
|
103
|
+
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
|
104
|
+
private readonly browser = isPlatformBrowser(inject(PLATFORM_ID));
|
|
105
|
+
private readonly trigger = viewChild<ElementRef<HTMLButtonElement>>('trigger');
|
|
106
|
+
private readonly formDisabled = signal(false);
|
|
107
|
+
private onChange: (value: string) => void = () => {};
|
|
108
|
+
private onTouched: () => void = () => {};
|
|
109
|
+
readonly options = input<readonly GoodFontOption[]>(GOOD_FONT_OPTIONS);
|
|
110
|
+
readonly value = model('sans-serif');
|
|
111
|
+
readonly label = input('Font family');
|
|
112
|
+
readonly size = input<GoodButtonSize>('default');
|
|
113
|
+
readonly disabled = input(false);
|
|
114
|
+
readonly fontSelected = output<string>();
|
|
115
|
+
readonly isDisabled = computed(() => this.disabled() || this.formDisabled());
|
|
116
|
+
readonly availableFonts = signal<readonly GoodFontOption[]>(GOOD_FONT_OPTIONS.filter(font => font.generic));
|
|
117
|
+
readonly selected = computed(() => this.availableFonts().find(font => font.value === this.value()));
|
|
118
|
+
readonly selectedCss = computed(() => this.selected() ? this.fontCss(this.selected()!) : 'sans-serif');
|
|
119
|
+
readonly open = signal(false);
|
|
120
|
+
readonly activeIndex = signal(0);
|
|
121
|
+
readonly position = signal({ left: 0, top: 0 });
|
|
122
|
+
readonly listId = `good-select-font-${++nextFontSelectId}-list`;
|
|
123
|
+
readonly chevronIcon = LucideChevronDown;
|
|
124
|
+
readonly checkIcon = LucideCheck;
|
|
125
|
+
|
|
126
|
+
constructor() {
|
|
127
|
+
effect(onCleanup => {
|
|
128
|
+
const options = this.options();
|
|
129
|
+
this.availableFonts.set(options.filter(font => font.generic));
|
|
130
|
+
if (!this.browser) return;
|
|
131
|
+
let active = true;
|
|
132
|
+
void detectAvailableFonts(options).then(fonts => { if (active) this.availableFonts.set(fonts); });
|
|
133
|
+
onCleanup(() => { active = false; });
|
|
134
|
+
});
|
|
135
|
+
effect(() => { if (this.isDisabled()) this.open.set(false); });
|
|
136
|
+
}
|
|
137
|
+
fontCss(font: GoodFontOption): string { return goodFontFamilyCss(font.value, this.options()) ?? font.fallback; }
|
|
138
|
+
optionId(index: number): string { return `${this.listId}-${index}`; }
|
|
139
|
+
toggle(): void {
|
|
140
|
+
if (this.isDisabled()) return;
|
|
141
|
+
if (this.open()) { this.close(); return; }
|
|
142
|
+
this.positionPopup();
|
|
143
|
+
this.activeIndex.set(Math.max(0, this.availableFonts().findIndex(font => font.value === this.value())));
|
|
144
|
+
this.open.set(true);
|
|
145
|
+
queueMicrotask(() => this.host.nativeElement.querySelector<HTMLElement>('.good-select-font-list')?.focus());
|
|
146
|
+
}
|
|
147
|
+
choose(font: GoodFontOption | undefined): void {
|
|
148
|
+
if (!font || this.isDisabled() || !this.availableFonts().some(available => available.value === font.value)) return;
|
|
149
|
+
this.value.set(font.value);
|
|
150
|
+
this.onChange(font.value);
|
|
151
|
+
this.fontSelected.emit(font.value);
|
|
152
|
+
this.close();
|
|
153
|
+
}
|
|
154
|
+
onKeydown(event: KeyboardEvent): void {
|
|
155
|
+
if (this.isDisabled()) return;
|
|
156
|
+
if (event.key === 'Escape') { if (this.open()) { event.preventDefault(); this.close(); } return; }
|
|
157
|
+
if (!this.open() && ['ArrowDown', 'ArrowUp', 'Enter', ' '].includes(event.key)) { event.preventDefault(); this.toggle(); return; }
|
|
158
|
+
if (!this.open()) return;
|
|
159
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
const length = this.availableFonts().length;
|
|
162
|
+
if (!length) return;
|
|
163
|
+
this.activeIndex.set((this.activeIndex() + (event.key === 'ArrowDown' ? 1 : -1) + length) % length);
|
|
164
|
+
this.host.nativeElement.ownerDocument.getElementById(this.optionId(this.activeIndex()))?.scrollIntoView?.({ block: 'nearest' });
|
|
165
|
+
} else if (event.key === 'Home' || event.key === 'End') {
|
|
166
|
+
event.preventDefault(); this.activeIndex.set(event.key === 'Home' ? 0 : this.availableFonts().length - 1);
|
|
167
|
+
} else if (event.key === 'Enter' || event.key === ' ') {
|
|
168
|
+
event.preventDefault(); this.choose(this.availableFonts()[this.activeIndex()]);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
private close(): void { this.open.set(false); this.onTouched(); this.trigger()?.nativeElement.focus(); }
|
|
172
|
+
private positionPopup(): void {
|
|
173
|
+
const rect = this.trigger()?.nativeElement.getBoundingClientRect();
|
|
174
|
+
if (!rect) return;
|
|
175
|
+
const width = Math.max(192, rect.width), height = Math.min(320, this.availableFonts().length * 38 + 8);
|
|
176
|
+
this.position.set({
|
|
177
|
+
left: Math.max(8, Math.min(rect.left, window.innerWidth - width - 8)),
|
|
178
|
+
top: rect.bottom + height <= window.innerHeight - 8 ? rect.bottom + 4 : Math.max(8, rect.top - height - 4),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
@HostListener('document:pointerdown', ['$event']) onOutside(event: PointerEvent): void {
|
|
182
|
+
if (this.open() && !this.host.nativeElement.contains(event.target as Node)) { this.open.set(false); this.onTouched(); }
|
|
183
|
+
}
|
|
184
|
+
@HostListener('window:resize') onResize(): void { if (this.open()) this.positionPopup(); }
|
|
185
|
+
writeValue(value: string | null): void { this.value.set(value ?? 'sans-serif'); }
|
|
186
|
+
registerOnChange(fn: (value: string) => void): void { this.onChange = fn; }
|
|
187
|
+
registerOnTouched(fn: () => void): void { this.onTouched = fn; }
|
|
188
|
+
setDisabledState(disabled: boolean): void { this.formDisabled.set(disabled); if (disabled) this.open.set(false); }
|
|
189
|
+
}
|