@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,538 @@
|
|
|
1
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import { AfterViewInit, ChangeDetectionStrategy, Component, DestroyRef, Directive, ElementRef, TemplateRef, booleanAttribute, computed, contentChildren, effect, inject, input, model, output, signal, untracked, viewChild } from '@angular/core';
|
|
3
|
+
import { LucideArrowDown, LucideArrowDownUp, LucideArrowUp, LucideChevronLeft, LucideChevronRight, LucideGripVertical, LucideSearch, LucideSearchX } from '@lucide/angular';
|
|
4
|
+
import { FlexRender, ColumnDef, Column, RowData, SortingState, PaginationState, injectTable, tableFeatures,
|
|
5
|
+
rowSortingFeature, createSortedRowModel, sortFn_alphanumeric, sortFn_text, sortFn_datetime,
|
|
6
|
+
columnFilteringFeature, globalFilteringFeature, createFilteredRowModel, filterFn_includesString,
|
|
7
|
+
rowPaginationFeature, createPaginatedRowModel, columnOrderingFeature, columnVisibilityFeature } from '@tanstack/angular-table';
|
|
8
|
+
import { GoodButtonComponent } from './button';
|
|
9
|
+
import { GoodInputComponent } from './input';
|
|
10
|
+
|
|
11
|
+
const goodTableFeatures = tableFeatures({
|
|
12
|
+
rowSortingFeature,
|
|
13
|
+
sortedRowModel: createSortedRowModel(),
|
|
14
|
+
sortFns: { alphanumeric: sortFn_alphanumeric, text: sortFn_text, datetime: sortFn_datetime },
|
|
15
|
+
columnFilteringFeature,
|
|
16
|
+
globalFilteringFeature,
|
|
17
|
+
filteredRowModel: createFilteredRowModel(),
|
|
18
|
+
filterFns: { includesString: filterFn_includesString },
|
|
19
|
+
rowPaginationFeature,
|
|
20
|
+
paginatedRowModel: createPaginatedRowModel(),
|
|
21
|
+
columnOrderingFeature,
|
|
22
|
+
columnVisibilityFeature,
|
|
23
|
+
columnMeta: {} as GoodTableColumnMeta,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export type GoodTableStyle = 'default' | 'bordered' | 'striped' | 'compact';
|
|
27
|
+
export type GoodTableColumnBreakpoint = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
28
|
+
export type GoodTableColumn<TData extends RowData> = ColumnDef<typeof goodTableFeatures, TData>;
|
|
29
|
+
|
|
30
|
+
export interface GoodTableColumnMeta {
|
|
31
|
+
align?: 'start' | 'center' | 'end';
|
|
32
|
+
noWrap?: boolean;
|
|
33
|
+
/** Minimum table width tier for this column; omitted columns are visible from xs. */
|
|
34
|
+
visibleFrom?: GoodTableColumnBreakpoint;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface GoodTableCellContext<TData> {
|
|
39
|
+
$implicit: TData;
|
|
40
|
+
value: unknown;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Project an Angular template into a column by its stable column ID. */
|
|
44
|
+
@Directive({ selector: 'ng-template[goodTableCell]', standalone: true })
|
|
45
|
+
export class GoodTableCellDirective<TData = any> {
|
|
46
|
+
readonly goodTableCell = input.required<string>();
|
|
47
|
+
readonly template = inject<TemplateRef<GoodTableCellContext<TData>>>(TemplateRef);
|
|
48
|
+
|
|
49
|
+
static ngTemplateContextGuard<TData>(
|
|
50
|
+
_directive: GoodTableCellDirective<TData>, context: unknown,
|
|
51
|
+
): context is GoodTableCellContext<TData> { return true; }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const tableColumnMinWidth: Record<GoodTableColumnBreakpoint, number> = {
|
|
55
|
+
xs: 0, sm: 480, md: 700, lg: 960, xl: 1280,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
interface GoodTablePageBase {
|
|
59
|
+
pageSize: number;
|
|
60
|
+
pageSizeOptions?: readonly number[];
|
|
61
|
+
maxPageSize?: number;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type GoodTablePagination =
|
|
65
|
+
| (GoodTablePageBase & { mode: 'client' })
|
|
66
|
+
| (GoodTablePageBase & { mode: 'pages'; totalRows: number })
|
|
67
|
+
| (GoodTablePageBase & { mode: 'cursor'; nextCursor?: string | null; hasNextPage: boolean; initialCursor?: string | null });
|
|
68
|
+
|
|
69
|
+
export interface GoodTableRequest {
|
|
70
|
+
pagination: { mode: 'none' | 'client' | 'pages' | 'cursor'; pageIndex: number; pageSize: number; cursor?: string | null };
|
|
71
|
+
sorting: SortingState;
|
|
72
|
+
search: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Component({
|
|
76
|
+
selector: 'good-table',
|
|
77
|
+
standalone: true,
|
|
78
|
+
imports: [FlexRender, NgTemplateOutlet, GoodButtonComponent, GoodInputComponent, LucideArrowDown, LucideArrowDownUp,
|
|
79
|
+
LucideArrowUp, LucideChevronLeft, LucideChevronRight, LucideGripVertical, LucideSearchX],
|
|
80
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
81
|
+
host: { class: 'good-table', '[attr.data-column-dragging]': 'dragSourceId() ? "true" : null', '[attr.data-responsive-columns]': 'hasResponsiveColumns() ? "true" : null' },
|
|
82
|
+
template: `
|
|
83
|
+
<ng-content select="ng-template[goodTableCell]" />
|
|
84
|
+
<div #frame class="good-table-frame" [attr.data-style]="tableStyle() ?? style()" [attr.aria-busy]="loading() ? 'true' : null">
|
|
85
|
+
@if (searchable()) {
|
|
86
|
+
<div class="good-table-toolbar">
|
|
87
|
+
<good-input label="Search records" type="search" [startIcon]="searchIcon" [placeholder]="searchPlaceholder()"
|
|
88
|
+
[value]="search()" (valueChange)="setSearch($event)" />
|
|
89
|
+
</div>
|
|
90
|
+
}
|
|
91
|
+
<div class="good-table-scroll" role="region" tabindex="0"
|
|
92
|
+
[attr.aria-label]="label() + ' table. Scroll horizontally for more columns when needed.'">
|
|
93
|
+
<table [attr.aria-label]="label()">
|
|
94
|
+
<thead [attr.data-reorderable]="reorderable()">
|
|
95
|
+
@for (headerGroup of table.getHeaderGroups(); track headerGroup.id) {
|
|
96
|
+
<tr>
|
|
97
|
+
@for (header of headerGroup.headers; track header.id) {
|
|
98
|
+
<th scope="col" [attr.data-align]="columnMeta(header.column).align || null"
|
|
99
|
+
[attr.data-column-id]="header.subHeaders.length ? null : header.column.id"
|
|
100
|
+
[attr.data-drop-target]="dragTargetId() === header.column.id ? 'true' : null"
|
|
101
|
+
[attr.data-drag-source]="dragSourceId() === header.column.id ? 'true' : null"
|
|
102
|
+
[attr.aria-sort]="header.column.getCanSort() ? ariaSort(header.column) : null">
|
|
103
|
+
@if (!header.isPlaceholder) {
|
|
104
|
+
<span class="good-table-header-content">
|
|
105
|
+
@if (header.column.getCanSort()) {
|
|
106
|
+
<button class="good-table-sort" type="button" (click)="header.column.toggleSorting()"
|
|
107
|
+
[attr.aria-label]="sortLabel(header.column)">
|
|
108
|
+
<span *flexRenderHeader="header; let rendered">{{ rendered }}</span>
|
|
109
|
+
@switch (header.column.getIsSorted()) {
|
|
110
|
+
@case ('asc') { <svg lucideArrowUp [size]="14" aria-hidden="true"></svg> }
|
|
111
|
+
@case ('desc') { <svg lucideArrowDown [size]="14" aria-hidden="true"></svg> }
|
|
112
|
+
@default { <svg lucideArrowDownUp [size]="14" aria-hidden="true"></svg> }
|
|
113
|
+
}
|
|
114
|
+
</button>
|
|
115
|
+
} @else {
|
|
116
|
+
<span class="good-table-header-label"><ng-container *flexRenderHeader="header; let rendered">{{ rendered }}</ng-container></span>
|
|
117
|
+
}
|
|
118
|
+
@if (reorderable() && !header.subHeaders.length) {
|
|
119
|
+
<button class="good-table-column-grip" type="button"
|
|
120
|
+
[attr.aria-label]="moveColumnLabel(header.column.id)"
|
|
121
|
+
[attr.title]="moveColumnLabel(header.column.id)"
|
|
122
|
+
(pointerdown)="onColumnPointerDown($event, header.column.id)"
|
|
123
|
+
(pointermove)="onColumnPointerMove($event)"
|
|
124
|
+
(pointerup)="onColumnPointerUp($event)"
|
|
125
|
+
(pointercancel)="cancelColumnDrag()"
|
|
126
|
+
(keydown)="onColumnGripKeydown($event, header.column.id)">
|
|
127
|
+
<svg lucideGripVertical [size]="16" aria-hidden="true"></svg>
|
|
128
|
+
</button>
|
|
129
|
+
}
|
|
130
|
+
</span>
|
|
131
|
+
}
|
|
132
|
+
</th>
|
|
133
|
+
}
|
|
134
|
+
</tr>
|
|
135
|
+
}
|
|
136
|
+
</thead>
|
|
137
|
+
<tbody>
|
|
138
|
+
@for (row of table.getRowModel().rows; track row.id) {
|
|
139
|
+
<tr [attr.data-row-id]="selectable() ? row.id : null"
|
|
140
|
+
[attr.data-selected]="selectable() && row.id === selectedRowId() ? 'true' : null"
|
|
141
|
+
[attr.data-emphasized]="emphasizeRow()(row.original) ? 'true' : null"
|
|
142
|
+
[attr.aria-selected]="selectable() ? row.id === selectedRowId() : null"
|
|
143
|
+
[attr.tabindex]="selectable() ? (row.id === activeRowId() ? 0 : -1) : null"
|
|
144
|
+
(click)="onRowClick($event, row.id, row.original)"
|
|
145
|
+
(focus)="onRowFocus($event, row.id)"
|
|
146
|
+
(keydown)="onRowKeydown($event, row.id, row.original)">
|
|
147
|
+
@for (cell of row.getVisibleCells(); track cell.id; let first = $first) {
|
|
148
|
+
<td [attr.data-align]="columnMeta(cell.column).align || null"
|
|
149
|
+
[attr.data-nowrap]="columnMeta(cell.column).noWrap ? 'true' : null">
|
|
150
|
+
@if (first && emphasisLabel() && emphasizeRow()(row.original)) {
|
|
151
|
+
<span class="good-sr-only">{{ emphasisLabel() }}. </span>
|
|
152
|
+
}
|
|
153
|
+
@if (cellTemplate(cell.column.id); as customCell) {
|
|
154
|
+
<ng-container [ngTemplateOutlet]="customCell.template"
|
|
155
|
+
[ngTemplateOutletContext]="{ $implicit: row.original, value: cell.getValue() }" />
|
|
156
|
+
} @else {
|
|
157
|
+
<ng-container *flexRenderCell="cell; let rendered">{{ rendered }}</ng-container>
|
|
158
|
+
}
|
|
159
|
+
</td>
|
|
160
|
+
}
|
|
161
|
+
</tr>
|
|
162
|
+
} @empty {
|
|
163
|
+
<tr class="good-table-empty-row">
|
|
164
|
+
<td [attr.colspan]="table.getVisibleLeafColumns().length || 1">
|
|
165
|
+
<div class="good-table-empty" role="status">
|
|
166
|
+
@if (loading()) { <span class="good-table-loading-indicator" aria-hidden="true"></span><span>Loading records...</span> }
|
|
167
|
+
@else { <svg lucideSearchX [size]="24" aria-hidden="true"></svg><strong>{{ emptyMessage() }}</strong> }
|
|
168
|
+
</div>
|
|
169
|
+
</td>
|
|
170
|
+
</tr>
|
|
171
|
+
}
|
|
172
|
+
</tbody>
|
|
173
|
+
</table>
|
|
174
|
+
</div>
|
|
175
|
+
<span class="good-sr-only" role="status" aria-live="polite">{{ columnOrderAnnouncement() }}</span>
|
|
176
|
+
@if (pagination(); as config) {
|
|
177
|
+
<div class="good-table-footer">
|
|
178
|
+
<div class="good-table-page-summary" role="status">{{ pageSummary() }}</div>
|
|
179
|
+
<div class="good-table-page-controls">
|
|
180
|
+
<label class="good-table-page-size-label">Rows per page
|
|
181
|
+
<select class="good-table-page-size" [value]="pageState().pageSize" [disabled]="loading()"
|
|
182
|
+
(change)="setPageSize($event)">
|
|
183
|
+
@for (size of pageSizeChoices(); track size) { <option [value]="size">{{ size }}</option> }
|
|
184
|
+
</select>
|
|
185
|
+
</label>
|
|
186
|
+
<div class="good-table-page-buttons" aria-label="Table pages">
|
|
187
|
+
<good-button size="small" variant="outline" [icon]="previousIcon" [iconOnly]="true"
|
|
188
|
+
ariaLabel="Previous page" [disabled]="!canPrevious() || loading()" (click)="previousPage()" />
|
|
189
|
+
@if (config.mode !== 'cursor') {
|
|
190
|
+
@for (page of visiblePages(); track page) {
|
|
191
|
+
<good-button size="small" [variant]="page === pageState().pageIndex ? 'default' : 'outline'"
|
|
192
|
+
[ariaLabel]="'Page ' + (page + 1)" (click)="goToPage(page)" [disabled]="loading()"
|
|
193
|
+
>{{ page + 1 }}</good-button>
|
|
194
|
+
}
|
|
195
|
+
} @else { <span class="good-table-current-page">Page {{ pageState().pageIndex + 1 }}</span> }
|
|
196
|
+
<good-button size="small" variant="outline" [icon]="nextIcon" [iconOnly]="true"
|
|
197
|
+
ariaLabel="Next page" [disabled]="!canNext() || loading()" (click)="nextPage()" />
|
|
198
|
+
</div>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
}
|
|
202
|
+
</div>
|
|
203
|
+
`,
|
|
204
|
+
})
|
|
205
|
+
export class GoodTableComponent<TData extends RowData> implements AfterViewInit {
|
|
206
|
+
readonly cellTemplates = contentChildren(GoodTableCellDirective);
|
|
207
|
+
cellTemplate(columnId: string): GoodTableCellDirective | undefined {
|
|
208
|
+
return this.cellTemplates().find(template => template.goodTableCell() === columnId);
|
|
209
|
+
}
|
|
210
|
+
readonly data = input.required<readonly TData[]>();
|
|
211
|
+
readonly columns = input.required<readonly GoodTableColumn<TData>[]>();
|
|
212
|
+
readonly label = input('Records');
|
|
213
|
+
readonly style = input<GoodTableStyle>('default');
|
|
214
|
+
/** Prefer this name in templates: static style="compact" is interpreted as an HTML style attribute. */
|
|
215
|
+
readonly tableStyle = input<GoodTableStyle | null>(null);
|
|
216
|
+
/** Drag or use the header grips to reorder columns; enabled by default. */
|
|
217
|
+
readonly reorderable = input(true, { transform: booleanAttribute });
|
|
218
|
+
/** Optional controlled order of leaf column IDs; emits changes from user reordering. */
|
|
219
|
+
readonly columnOrder = model<string[]>([]);
|
|
220
|
+
readonly searchable = input(false);
|
|
221
|
+
readonly searchPlaceholder = input('Search records');
|
|
222
|
+
readonly pagination = input<GoodTablePagination | null>(null);
|
|
223
|
+
readonly sortingMode = input<'client' | 'manual'>('client');
|
|
224
|
+
readonly searchMode = input<'client' | 'manual'>('client');
|
|
225
|
+
readonly getRowId = input<(row: TData, index: number) => string>();
|
|
226
|
+
readonly loading = input(false);
|
|
227
|
+
readonly emptyMessage = input('NO records found');
|
|
228
|
+
/** Opt in to single-row selection. Supply getRowId for stable selection across sorting and updates. */
|
|
229
|
+
readonly selectable = input(false, { transform: booleanAttribute });
|
|
230
|
+
/** ID of the selected record; supports [(selectedRowId)] and programmatic changes. */
|
|
231
|
+
readonly selectedRowId = model<string | null>(null);
|
|
232
|
+
/** Visual emphasis for rows selected by application data, independent of row selection. */
|
|
233
|
+
readonly emphasizeRow = input<(row: TData) => boolean>(() => false);
|
|
234
|
+
/** Optional screen reader text for emphasized rows, such as a record state. */
|
|
235
|
+
readonly emphasisLabel = input('');
|
|
236
|
+
/** Emits the selected record only when a user chooses a different row. */
|
|
237
|
+
readonly rowSelected = output<TData>();
|
|
238
|
+
readonly sortingChange = output<SortingState>();
|
|
239
|
+
readonly searchChange = output<string>();
|
|
240
|
+
readonly request = output<GoodTableRequest>();
|
|
241
|
+
readonly search = signal('');
|
|
242
|
+
readonly columnVisibility = signal<Record<string, boolean>>({});
|
|
243
|
+
readonly columnOrderAnnouncement = signal('');
|
|
244
|
+
readonly dragSourceId = signal<string | null>(null);
|
|
245
|
+
readonly dragTargetId = signal<string | null>(null);
|
|
246
|
+
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
|
247
|
+
private readonly frame = viewChild.required<ElementRef<HTMLElement>>('frame');
|
|
248
|
+
private readonly destroyRef = inject(DestroyRef);
|
|
249
|
+
private readonly tableWidth = signal(0);
|
|
250
|
+
private pointerStart: { x: number; y: number; id: string } | null = null;
|
|
251
|
+
private dropAfter = false;
|
|
252
|
+
readonly sorting = signal<SortingState>([]);
|
|
253
|
+
readonly pageState = signal<PaginationState>({ pageIndex: 0, pageSize: 10 });
|
|
254
|
+
readonly cursorHistory = signal<(string | null)[]>([null]);
|
|
255
|
+
private readonly focusedRowId = signal<string | null>(null);
|
|
256
|
+
readonly searchIcon = LucideSearch;
|
|
257
|
+
readonly previousIcon = LucideChevronLeft;
|
|
258
|
+
readonly nextIcon = LucideChevronRight;
|
|
259
|
+
private lastPaginationMode: GoodTablePagination['mode'] | null = null;
|
|
260
|
+
readonly hasResponsiveColumns = computed(() => {
|
|
261
|
+
const hasBreakpoint = (columns: readonly GoodTableColumn<TData>[]): boolean => columns.some(column => {
|
|
262
|
+
const children = 'columns' in column ? column.columns as readonly GoodTableColumn<TData>[] : undefined;
|
|
263
|
+
return (column.meta?.visibleFrom ?? 'xs') !== 'xs' || (!!children?.length && hasBreakpoint(children));
|
|
264
|
+
});
|
|
265
|
+
return hasBreakpoint(this.columns());
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
readonly table = injectTable(() => {
|
|
269
|
+
const config = this.pagination();
|
|
270
|
+
const server = config?.mode === 'pages' || config?.mode === 'cursor';
|
|
271
|
+
return {
|
|
272
|
+
features: goodTableFeatures,
|
|
273
|
+
data: this.data() as TData[],
|
|
274
|
+
columns: this.columns() as GoodTableColumn<TData>[],
|
|
275
|
+
getRowId: this.getRowId(),
|
|
276
|
+
defaultColumn: { enableSorting: false },
|
|
277
|
+
manualSorting: server || this.sortingMode() === 'manual',
|
|
278
|
+
manualFiltering: server || this.searchMode() === 'manual',
|
|
279
|
+
manualPagination: config?.mode !== 'client',
|
|
280
|
+
rowCount: config?.mode === 'pages' ? config.totalRows : undefined,
|
|
281
|
+
pageCount: config?.mode === 'cursor' ? -1 : undefined,
|
|
282
|
+
globalFilterFn: 'includesString' as const,
|
|
283
|
+
state: { sorting: this.sorting(), globalFilter: this.search(), pagination: this.pageState(), columnOrder: this.columnOrder(), columnVisibility: this.columnVisibility() },
|
|
284
|
+
onColumnOrderChange: updater => this.columnOrder.update(old => typeof updater === 'function' ? updater(old) : updater),
|
|
285
|
+
onSortingChange: (updater: SortingState | ((old: SortingState) => SortingState)) => {
|
|
286
|
+
const next = typeof updater === 'function' ? updater(this.sorting()) : updater;
|
|
287
|
+
this.sorting.set(next);
|
|
288
|
+
this.sortingChange.emit(next);
|
|
289
|
+
this.resetPage();
|
|
290
|
+
if (server || this.sortingMode() === 'manual') this.emitRequest();
|
|
291
|
+
},
|
|
292
|
+
onGlobalFilterChange: (updater: string | ((old: string) => string)) => {
|
|
293
|
+
this.setSearch(typeof updater === 'function' ? updater(this.search()) : updater);
|
|
294
|
+
},
|
|
295
|
+
onPaginationChange: (updater: PaginationState | ((old: PaginationState) => PaginationState)) => {
|
|
296
|
+
this.pageState.update(old => typeof updater === 'function' ? updater(old) : updater);
|
|
297
|
+
if (server) this.emitRequest();
|
|
298
|
+
},
|
|
299
|
+
};
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
/** One tab stop for the table body; arrow keys move focus between visible rows. */
|
|
303
|
+
readonly activeRowId = computed(() => {
|
|
304
|
+
const rows = this.table.getRowModel().rows;
|
|
305
|
+
const focused = this.focusedRowId();
|
|
306
|
+
if (focused && rows.some(row => row.id === focused)) return focused;
|
|
307
|
+
const selected = this.selectedRowId();
|
|
308
|
+
return rows.find(row => row.id === selected)?.id ?? rows[0]?.id ?? null;
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
readonly pageSizeChoices = computed(() => {
|
|
312
|
+
const config = this.pagination();
|
|
313
|
+
if (!config) return [];
|
|
314
|
+
const max = config.maxPageSize && config.maxPageSize > 0 ? Math.floor(config.maxPageSize) : Number.MAX_SAFE_INTEGER;
|
|
315
|
+
return [...new Set([...(config.pageSizeOptions ?? [10, 25, 50]), this.pageState().pageSize]
|
|
316
|
+
.map(value => Math.floor(value)).filter(value => value > 0 && value <= max))].sort((left, right) => left - right);
|
|
317
|
+
});
|
|
318
|
+
readonly totalPages = computed(() => {
|
|
319
|
+
const config = this.pagination();
|
|
320
|
+
if (!config || config.mode === 'cursor') return 0;
|
|
321
|
+
const count = config.mode === 'pages' ? config.totalRows : this.table.getPrePaginatedRowModel().rows.length;
|
|
322
|
+
return Math.max(1, Math.ceil(count / this.pageState().pageSize));
|
|
323
|
+
});
|
|
324
|
+
readonly visiblePages = computed(() => {
|
|
325
|
+
const total = this.totalPages(), current = this.pageState().pageIndex;
|
|
326
|
+
const start = Math.max(0, Math.min(current - 2, total - 5));
|
|
327
|
+
return Array.from({ length: Math.min(total, 5) }, (_, index) => start + index);
|
|
328
|
+
});
|
|
329
|
+
readonly canPrevious = computed(() => this.pageState().pageIndex > 0);
|
|
330
|
+
readonly canNext = computed(() => {
|
|
331
|
+
const config = this.pagination();
|
|
332
|
+
return config?.mode === 'cursor' ? !!config.hasNextPage && !!config.nextCursor : !!config && this.pageState().pageIndex + 1 < this.totalPages();
|
|
333
|
+
});
|
|
334
|
+
readonly pageSummary = computed(() => {
|
|
335
|
+
const config = this.pagination();
|
|
336
|
+
const { pageIndex, pageSize } = this.pageState();
|
|
337
|
+
if (config?.mode === 'cursor') return `Page ${pageIndex + 1} · ${this.data().length} records`;
|
|
338
|
+
const total = config?.mode === 'pages' ? config.totalRows : this.table.getPrePaginatedRowModel().rows.length;
|
|
339
|
+
const start = total ? pageIndex * pageSize + 1 : 0;
|
|
340
|
+
const end = Math.min(total, (pageIndex + 1) * pageSize);
|
|
341
|
+
return `${start}–${end} of ${total} records`;
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
constructor() {
|
|
345
|
+
effect(() => {
|
|
346
|
+
this.columns();
|
|
347
|
+
const width = this.tableWidth();
|
|
348
|
+
const visible = Object.fromEntries(untracked(() => this.table.getAllLeafColumns()).map(column => {
|
|
349
|
+
const from = this.columnMeta(column).visibleFrom ?? 'xs';
|
|
350
|
+
return [column.id, width >= tableColumnMinWidth[from]];
|
|
351
|
+
}));
|
|
352
|
+
untracked(() => this.columnVisibility.set(visible));
|
|
353
|
+
});
|
|
354
|
+
effect(() => {
|
|
355
|
+
const config = this.pagination();
|
|
356
|
+
if (!config) { this.lastPaginationMode = null; return; }
|
|
357
|
+
const max = config.maxPageSize && config.maxPageSize > 0 ? Math.floor(config.maxPageSize) : Number.MAX_SAFE_INTEGER;
|
|
358
|
+
const size = Math.max(1, Math.min(Math.floor(config.pageSize) || 10, max));
|
|
359
|
+
const modeChanged = this.lastPaginationMode !== config.mode;
|
|
360
|
+
this.lastPaginationMode = config.mode;
|
|
361
|
+
untracked(() => {
|
|
362
|
+
if (modeChanged || this.pageState().pageSize !== size) {
|
|
363
|
+
this.pageState.set({ pageIndex: 0, pageSize: size });
|
|
364
|
+
this.cursorHistory.set([config.mode === 'cursor' ? config.initialCursor ?? null : null]);
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
ngAfterViewInit(): void {
|
|
371
|
+
const frame = this.frame().nativeElement;
|
|
372
|
+
const measure = () => this.tableWidth.set(frame.getBoundingClientRect().width);
|
|
373
|
+
measure();
|
|
374
|
+
if (typeof ResizeObserver === 'undefined') return;
|
|
375
|
+
const observer = new ResizeObserver(measure);
|
|
376
|
+
observer.observe(frame);
|
|
377
|
+
this.destroyRef.onDestroy(() => observer.disconnect());
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
columnMeta(column: Column<typeof goodTableFeatures, TData, unknown>): GoodTableColumnMeta {
|
|
381
|
+
return column.columnDef.meta ?? {};
|
|
382
|
+
}
|
|
383
|
+
ariaSort(column: Column<typeof goodTableFeatures, TData, unknown>): 'ascending' | 'descending' | 'none' {
|
|
384
|
+
return column.getIsSorted() === 'asc' ? 'ascending' : column.getIsSorted() === 'desc' ? 'descending' : 'none';
|
|
385
|
+
}
|
|
386
|
+
sortLabel(column: Column<typeof goodTableFeatures, TData, unknown>): string {
|
|
387
|
+
const title = typeof column.columnDef.header === 'string' ? column.columnDef.header : column.id;
|
|
388
|
+
return `Sort ${title}${column.getIsSorted() === 'asc' ? ' descending' : ' ascending'}`;
|
|
389
|
+
}
|
|
390
|
+
moveColumnLabel(id: string): string {
|
|
391
|
+
const columns = this.table.getVisibleLeafColumns();
|
|
392
|
+
const column = columns.find(item => item.id === id);
|
|
393
|
+
const title = typeof column?.columnDef.header === 'string' ? column.columnDef.header : id;
|
|
394
|
+
return `Move ${title}, column ${columns.findIndex(item => item.id === id) + 1} of ${columns.length}. Drag or use Left and Right arrow keys.`;
|
|
395
|
+
}
|
|
396
|
+
onColumnPointerDown(event: PointerEvent, id: string): void {
|
|
397
|
+
if (!this.reorderable() || (event.pointerType === 'mouse' && event.button !== 0)) return;
|
|
398
|
+
this.pointerStart = { x: event.clientX, y: event.clientY, id };
|
|
399
|
+
(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId);
|
|
400
|
+
}
|
|
401
|
+
onColumnPointerMove(event: PointerEvent): void {
|
|
402
|
+
if (!this.pointerStart || !this.reorderable()) return;
|
|
403
|
+
const distance = Math.hypot(event.clientX - this.pointerStart.x, event.clientY - this.pointerStart.y);
|
|
404
|
+
if (!this.dragSourceId() && distance < 6) return;
|
|
405
|
+
this.dragSourceId.set(this.pointerStart.id);
|
|
406
|
+
const header = this.host.nativeElement.ownerDocument.elementFromPoint(event.clientX, event.clientY)
|
|
407
|
+
?.closest<HTMLElement>('th[data-column-id]');
|
|
408
|
+
if (!header || !this.host.nativeElement.contains(header)) { this.dragTargetId.set(null); return; }
|
|
409
|
+
this.dragTargetId.set(header.dataset['columnId'] ?? null);
|
|
410
|
+
this.dropAfter = event.clientX >= header.getBoundingClientRect().left + header.getBoundingClientRect().width / 2;
|
|
411
|
+
}
|
|
412
|
+
onColumnPointerUp(event: PointerEvent): void {
|
|
413
|
+
const source = this.dragSourceId(), target = this.dragTargetId();
|
|
414
|
+
if (source && target) this.moveColumn(source, target, this.dropAfter);
|
|
415
|
+
const handle = event.currentTarget as HTMLElement;
|
|
416
|
+
if (handle.hasPointerCapture(event.pointerId)) handle.releasePointerCapture(event.pointerId);
|
|
417
|
+
this.cancelColumnDrag();
|
|
418
|
+
}
|
|
419
|
+
cancelColumnDrag(): void {
|
|
420
|
+
this.pointerStart = null;
|
|
421
|
+
this.dragSourceId.set(null);
|
|
422
|
+
this.dragTargetId.set(null);
|
|
423
|
+
}
|
|
424
|
+
onColumnGripKeydown(event: KeyboardEvent, id: string): void {
|
|
425
|
+
if (!this.reorderable() || !['ArrowLeft', 'ArrowRight', 'Home', 'End'].includes(event.key)) return;
|
|
426
|
+
const columns = this.table.getVisibleLeafColumns().map(column => column.id);
|
|
427
|
+
const index = columns.indexOf(id);
|
|
428
|
+
const targetIndex = event.key === 'Home' ? 0 : event.key === 'End' ? columns.length - 1
|
|
429
|
+
: index + (event.key === 'ArrowLeft' ? -1 : 1);
|
|
430
|
+
if (index < 0 || targetIndex < 0 || targetIndex >= columns.length) return;
|
|
431
|
+
event.preventDefault();
|
|
432
|
+
this.moveColumn(id, columns[targetIndex], targetIndex > index);
|
|
433
|
+
}
|
|
434
|
+
private moveColumn(source: string, target: string, after: boolean): void {
|
|
435
|
+
if (!this.reorderable() || source === target) return;
|
|
436
|
+
const order = this.table.getAllLeafColumns().map(column => column.id);
|
|
437
|
+
if (!order.includes(source) || !order.includes(target)) return;
|
|
438
|
+
order.splice(order.indexOf(source), 1);
|
|
439
|
+
order.splice(order.indexOf(target) + (after ? 1 : 0), 0, source);
|
|
440
|
+
this.table.setColumnOrder(order);
|
|
441
|
+
const visibleIds = new Set(this.table.getVisibleLeafColumns().map(column => column.id));
|
|
442
|
+
const position = order.filter(id => visibleIds.has(id)).indexOf(source) + 1;
|
|
443
|
+
const column = this.table.getColumn(source);
|
|
444
|
+
const label = typeof column?.columnDef.header === 'string' ? column.columnDef.header : source;
|
|
445
|
+
this.columnOrderAnnouncement.set(`${label} moved to column ${position} of ${visibleIds.size}.`);
|
|
446
|
+
requestAnimationFrame(() => this.host.nativeElement.querySelector<HTMLElement>(
|
|
447
|
+
`th[data-column-id="${CSS.escape(source)}"] .good-table-column-grip`)?.focus());
|
|
448
|
+
}
|
|
449
|
+
onRowClick(event: MouseEvent, id: string, record: TData): void {
|
|
450
|
+
if (!this.selectable() || this.isInteractiveTarget(event)) return;
|
|
451
|
+
this.chooseRow(id, record);
|
|
452
|
+
}
|
|
453
|
+
onRowFocus(event: FocusEvent, id: string): void {
|
|
454
|
+
if (event.target === event.currentTarget) this.focusedRowId.set(id);
|
|
455
|
+
}
|
|
456
|
+
onRowKeydown(event: KeyboardEvent, id: string, record: TData): void {
|
|
457
|
+
if (!this.selectable() || event.target !== event.currentTarget) return;
|
|
458
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
459
|
+
event.preventDefault();
|
|
460
|
+
this.chooseRow(id, record);
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
const rows = this.table.getRowModel().rows;
|
|
464
|
+
const index = rows.findIndex(row => row.id === id);
|
|
465
|
+
const next = event.key === 'ArrowDown' ? index + 1 : event.key === 'ArrowUp' ? index - 1
|
|
466
|
+
: event.key === 'Home' ? 0 : event.key === 'End' ? rows.length - 1 : -1;
|
|
467
|
+
if (next < 0 || next >= rows.length || next === index) return;
|
|
468
|
+
event.preventDefault();
|
|
469
|
+
const target = (event.currentTarget as HTMLTableRowElement).parentElement?.children.item(next);
|
|
470
|
+
if (target instanceof HTMLElement) target.focus();
|
|
471
|
+
}
|
|
472
|
+
private chooseRow(id: string, record: TData): void {
|
|
473
|
+
this.focusedRowId.set(id);
|
|
474
|
+
if (this.selectedRowId() === id) return;
|
|
475
|
+
this.selectedRowId.set(id);
|
|
476
|
+
this.rowSelected.emit(record);
|
|
477
|
+
}
|
|
478
|
+
private isInteractiveTarget(event: MouseEvent): boolean {
|
|
479
|
+
const row = event.currentTarget as HTMLElement;
|
|
480
|
+
const target = event.target;
|
|
481
|
+
if (!(target instanceof Element)) return false;
|
|
482
|
+
const interactive = target.closest('a, button, input, select, textarea, summary, [contenteditable="true"], [role="button"], [role="link"], [role="checkbox"], [role="switch"], [tabindex]');
|
|
483
|
+
return !!interactive && interactive !== row && row.contains(interactive);
|
|
484
|
+
}
|
|
485
|
+
setSearch(value: string): void {
|
|
486
|
+
if (this.search() === value) return;
|
|
487
|
+
this.search.set(value);
|
|
488
|
+
this.searchChange.emit(value);
|
|
489
|
+
this.resetPage();
|
|
490
|
+
const mode = this.pagination()?.mode;
|
|
491
|
+
if (mode === 'pages' || mode === 'cursor' || this.searchMode() === 'manual') this.emitRequest();
|
|
492
|
+
}
|
|
493
|
+
setPageSize(event: Event): void {
|
|
494
|
+
const config = this.pagination();
|
|
495
|
+
if (!config) return;
|
|
496
|
+
const next = Number((event.target as HTMLSelectElement).value);
|
|
497
|
+
if (!Number.isFinite(next) || next < 1) return;
|
|
498
|
+
const max = config.maxPageSize && config.maxPageSize > 0 ? Math.floor(config.maxPageSize) : Number.MAX_SAFE_INTEGER;
|
|
499
|
+
this.pageState.set({ pageIndex: 0, pageSize: Math.min(Math.floor(next), max) });
|
|
500
|
+
this.cursorHistory.set([config.mode === 'cursor' ? config.initialCursor ?? null : null]);
|
|
501
|
+
if (config.mode !== 'client') this.emitRequest();
|
|
502
|
+
}
|
|
503
|
+
previousPage(): void { this.goToPage(this.pageState().pageIndex - 1); }
|
|
504
|
+
nextPage(): void { this.goToPage(this.pageState().pageIndex + 1); }
|
|
505
|
+
goToPage(index: number): void {
|
|
506
|
+
const config = this.pagination();
|
|
507
|
+
if (!config || index < 0 || index === this.pageState().pageIndex) return;
|
|
508
|
+
if (config.mode === 'cursor') {
|
|
509
|
+
if (index > this.pageState().pageIndex) {
|
|
510
|
+
if (!this.canNext()) return;
|
|
511
|
+
this.cursorHistory.update(history => [...history.slice(0, index), config.nextCursor ?? null]);
|
|
512
|
+
} else if (!this.cursorHistory()[index] && index !== 0) return;
|
|
513
|
+
} else if (index >= this.totalPages()) return;
|
|
514
|
+
this.pageState.update(state => ({ ...state, pageIndex: index }));
|
|
515
|
+
if (config.mode !== 'client') this.emitRequest();
|
|
516
|
+
}
|
|
517
|
+
reset(): void {
|
|
518
|
+
this.search.set('');
|
|
519
|
+
this.sorting.set([]);
|
|
520
|
+
this.resetPage();
|
|
521
|
+
this.emitRequest();
|
|
522
|
+
}
|
|
523
|
+
private resetPage(): void {
|
|
524
|
+
this.pageState.update(state => ({ ...state, pageIndex: 0 }));
|
|
525
|
+
const config = this.pagination();
|
|
526
|
+
this.cursorHistory.set([config?.mode === 'cursor' ? config.initialCursor ?? null : null]);
|
|
527
|
+
}
|
|
528
|
+
private emitRequest(): void {
|
|
529
|
+
const config = this.pagination();
|
|
530
|
+
const state = this.pageState();
|
|
531
|
+
this.request.emit({
|
|
532
|
+
pagination: { mode: config?.mode ?? 'none', pageIndex: state.pageIndex, pageSize: state.pageSize,
|
|
533
|
+
...(config?.mode === 'cursor' ? { cursor: this.cursorHistory()[state.pageIndex] ?? null } : {}) },
|
|
534
|
+
sorting: this.sorting(),
|
|
535
|
+
search: this.search(),
|
|
536
|
+
});
|
|
537
|
+
}
|
|
538
|
+
}
|