@webjsdev/ui 0.3.17 → 0.5.0
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 +67 -8
- package/THIRD_PARTY_NOTICES.md +349 -0
- package/package.json +4 -2
- package/packages/registry/blocks/_shared/placeholder.svg +1 -0
- package/packages/registry/blocks/charts/chart-area-axes.ts +72 -0
- package/packages/registry/blocks/charts/chart-area-default.ts +64 -0
- package/packages/registry/blocks/charts/chart-area-gradient.ts +82 -0
- package/packages/registry/blocks/charts/chart-area-icons.ts +77 -0
- package/packages/registry/blocks/charts/chart-area-interactive.ts +204 -0
- package/packages/registry/blocks/charts/chart-area-legend.ts +72 -0
- package/packages/registry/blocks/charts/chart-area-linear.ts +64 -0
- package/packages/registry/blocks/charts/chart-area-stacked-expand.ts +77 -0
- package/packages/registry/blocks/charts/chart-area-stacked.ts +71 -0
- package/packages/registry/blocks/charts/chart-area-step.ts +68 -0
- package/packages/registry/blocks/charts/chart-bar-active.ts +93 -0
- package/packages/registry/blocks/charts/chart-bar-default.ts +60 -0
- package/packages/registry/blocks/charts/chart-bar-horizontal.ts +62 -0
- package/packages/registry/blocks/charts/chart-bar-interactive.ts +185 -0
- package/packages/registry/blocks/charts/chart-bar-label-custom.ts +78 -0
- package/packages/registry/blocks/charts/chart-bar-label.ts +66 -0
- package/packages/registry/blocks/charts/chart-bar-mixed.ts +87 -0
- package/packages/registry/blocks/charts/chart-bar-multiple.ts +67 -0
- package/packages/registry/blocks/charts/chart-bar-negative.ts +61 -0
- package/packages/registry/blocks/charts/chart-bar-stacked.ts +68 -0
- package/packages/registry/blocks/charts/chart-line-default.ts +61 -0
- package/packages/registry/blocks/charts/chart-line-dots-colors.ts +86 -0
- package/packages/registry/blocks/charts/chart-line-dots-custom.ts +75 -0
- package/packages/registry/blocks/charts/chart-line-dots.ts +65 -0
- package/packages/registry/blocks/charts/chart-line-interactive.ts +185 -0
- package/packages/registry/blocks/charts/chart-line-label-custom.ts +94 -0
- package/packages/registry/blocks/charts/chart-line-label.ts +73 -0
- package/packages/registry/blocks/charts/chart-line-linear.ts +61 -0
- package/packages/registry/blocks/charts/chart-line-multiple.ts +71 -0
- package/packages/registry/blocks/charts/chart-line-step.ts +61 -0
- package/packages/registry/blocks/charts/chart-pie-donut-active.ts +86 -0
- package/packages/registry/blocks/charts/chart-pie-donut-text.ts +89 -0
- package/packages/registry/blocks/charts/chart-pie-donut.ts +77 -0
- package/packages/registry/blocks/charts/chart-pie-interactive.ts +120 -0
- package/packages/registry/blocks/charts/chart-pie-label-custom.ts +82 -0
- package/packages/registry/blocks/charts/chart-pie-label-list.ts +86 -0
- package/packages/registry/blocks/charts/chart-pie-label.ts +77 -0
- package/packages/registry/blocks/charts/chart-pie-legend.ts +79 -0
- package/packages/registry/blocks/charts/chart-pie-separator-none.ts +77 -0
- package/packages/registry/blocks/charts/chart-pie-simple.ts +77 -0
- package/packages/registry/blocks/charts/chart-pie-stacked.ts +99 -0
- package/packages/registry/blocks/charts/chart-radar-default.ts +61 -0
- package/packages/registry/blocks/charts/chart-radar-dots.ts +61 -0
- package/packages/registry/blocks/charts/chart-radar-grid-circle-fill.ts +61 -0
- package/packages/registry/blocks/charts/chart-radar-grid-circle-no-lines.ts +61 -0
- package/packages/registry/blocks/charts/chart-radar-grid-circle.ts +61 -0
- package/packages/registry/blocks/charts/chart-radar-grid-custom.ts +61 -0
- package/packages/registry/blocks/charts/chart-radar-grid-fill.ts +61 -0
- package/packages/registry/blocks/charts/chart-radar-grid-none.ts +60 -0
- package/packages/registry/blocks/charts/chart-radar-icons.ts +76 -0
- package/packages/registry/blocks/charts/chart-radar-label-custom.ts +77 -0
- package/packages/registry/blocks/charts/chart-radar-legend.ts +70 -0
- package/packages/registry/blocks/charts/chart-radar-lines-only.ts +68 -0
- package/packages/registry/blocks/charts/chart-radar-multiple.ts +68 -0
- package/packages/registry/blocks/charts/chart-radar-radius.ts +68 -0
- package/packages/registry/blocks/charts/chart-radial-grid.ts +80 -0
- package/packages/registry/blocks/charts/chart-radial-label.ts +85 -0
- package/packages/registry/blocks/charts/chart-radial-shape.ts +81 -0
- package/packages/registry/blocks/charts/chart-radial-simple.ts +79 -0
- package/packages/registry/blocks/charts/chart-radial-stacked.ts +69 -0
- package/packages/registry/blocks/charts/chart-radial-text.ts +82 -0
- package/packages/registry/blocks/charts/chart-tooltip-advanced.ts +84 -0
- package/packages/registry/blocks/charts/chart-tooltip-default.ts +62 -0
- package/packages/registry/blocks/charts/chart-tooltip-formatter.ts +75 -0
- package/packages/registry/blocks/charts/chart-tooltip-icons.ts +68 -0
- package/packages/registry/blocks/charts/chart-tooltip-indicator-line.ts +62 -0
- package/packages/registry/blocks/charts/chart-tooltip-indicator-none.ts +62 -0
- package/packages/registry/blocks/charts/chart-tooltip-label-custom.ts +65 -0
- package/packages/registry/blocks/charts/chart-tooltip-label-formatter.ts +66 -0
- package/packages/registry/blocks/charts/chart-tooltip-label-none.ts +62 -0
- package/packages/registry/blocks/dashboard-01/components/app-sidebar.ts +108 -0
- package/packages/registry/blocks/dashboard-01/components/chart-area-interactive.ts +276 -0
- package/packages/registry/blocks/dashboard-01/components/dashboard-data.ts +89 -0
- package/packages/registry/blocks/dashboard-01/components/data-table.ts +644 -0
- package/packages/registry/blocks/dashboard-01/components/nav-documents.ts +65 -0
- package/packages/registry/blocks/dashboard-01/components/nav-main.ts +61 -0
- package/packages/registry/blocks/dashboard-01/components/nav-secondary.ts +40 -0
- package/packages/registry/blocks/dashboard-01/components/nav-user.ts +66 -0
- package/packages/registry/blocks/dashboard-01/components/section-cards.ts +59 -0
- package/packages/registry/blocks/dashboard-01/components/site-header.ts +52 -0
- package/packages/registry/blocks/dashboard-01/page.ts +39 -0
- package/packages/registry/blocks/login-01/components/login-form.ts +70 -0
- package/packages/registry/blocks/login-01/page.ts +19 -0
- package/packages/registry/blocks/login-02/components/login-form.ts +68 -0
- package/packages/registry/blocks/login-02/page.ts +36 -0
- package/packages/registry/blocks/login-03/components/login-form.ts +89 -0
- package/packages/registry/blocks/login-03/page.ts +28 -0
- package/packages/registry/blocks/login-04/components/login-form.ts +91 -0
- package/packages/registry/blocks/login-04/page.ts +20 -0
- package/packages/registry/blocks/login-05/components/login-form.ts +75 -0
- package/packages/registry/blocks/login-05/page.ts +19 -0
- package/packages/registry/blocks/preview/cards/activate-agent-dialog.ts +77 -0
- package/packages/registry/blocks/preview/cards/analytics-card.ts +64 -0
- package/packages/registry/blocks/preview/cards/anomaly-alert.ts +35 -0
- package/packages/registry/blocks/preview/cards/bar-chart-card.ts +91 -0
- package/packages/registry/blocks/preview/cards/book-appointment.ts +51 -0
- package/packages/registry/blocks/preview/cards/codespaces-card.ts +172 -0
- package/packages/registry/blocks/preview/cards/contributions-activity.ts +63 -0
- package/packages/registry/blocks/preview/cards/contributors.ts +51 -0
- package/packages/registry/blocks/preview/cards/environment-variables.ts +47 -0
- package/packages/registry/blocks/preview/cards/feedback-form.ts +61 -0
- package/packages/registry/blocks/preview/cards/file-upload.ts +51 -0
- package/packages/registry/blocks/preview/cards/github-profile.ts +66 -0
- package/packages/registry/blocks/preview/cards/icon-preview-grid.ts +47 -0
- package/packages/registry/blocks/preview/cards/invite-team.ts +78 -0
- package/packages/registry/blocks/preview/cards/invoice.ts +91 -0
- package/packages/registry/blocks/preview/cards/live-waveform.ts +330 -0
- package/packages/registry/blocks/preview/cards/no-team-members.ts +61 -0
- package/packages/registry/blocks/preview/cards/not-found.ts +46 -0
- package/packages/registry/blocks/preview/cards/observability-card.ts +44 -0
- package/packages/registry/blocks/preview/cards/pie-chart-card.ts +84 -0
- package/packages/registry/blocks/preview/cards/report-bug.ts +71 -0
- package/packages/registry/blocks/preview/cards/shipping-address.ts +79 -0
- package/packages/registry/blocks/preview/cards/shortcuts.ts +57 -0
- package/packages/registry/blocks/preview/cards/skeleton-loading.ts +37 -0
- package/packages/registry/blocks/preview/cards/sleep-report.ts +85 -0
- package/packages/registry/blocks/preview/cards/style-overview.ts +64 -0
- package/packages/registry/blocks/preview/cards/typography-specimen.ts +107 -0
- package/packages/registry/blocks/preview/cards/ui-elements.ts +164 -0
- package/packages/registry/blocks/preview/cards/usage-card.ts +63 -0
- package/packages/registry/blocks/preview/cards/visitors.ts +71 -0
- package/packages/registry/blocks/preview/cards/weekly-fitness-summary.ts +54 -0
- package/packages/registry/blocks/preview/page.ts +103 -0
- package/packages/registry/blocks/preview-02/cards/account-access.ts +70 -0
- package/packages/registry/blocks/preview-02/cards/card-overview.ts +75 -0
- package/packages/registry/blocks/preview-02/cards/claimable-balance.ts +54 -0
- package/packages/registry/blocks/preview-02/cards/contribution-history.ts +80 -0
- package/packages/registry/blocks/preview-02/cards/cover-art.ts +41 -0
- package/packages/registry/blocks/preview-02/cards/dividend-income.ts +76 -0
- package/packages/registry/blocks/preview-02/cards/empty-connect-bank.ts +38 -0
- package/packages/registry/blocks/preview-02/cards/empty-distribute-track.ts +38 -0
- package/packages/registry/blocks/preview-02/cards/empty-explore-catalog.ts +39 -0
- package/packages/registry/blocks/preview-02/cards/faq.ts +79 -0
- package/packages/registry/blocks/preview-02/cards/front-door.ts +40 -0
- package/packages/registry/blocks/preview-02/cards/index-investing.ts +31 -0
- package/packages/registry/blocks/preview-02/cards/kitchen-island.ts +90 -0
- package/packages/registry/blocks/preview-02/cards/loading-card.ts +34 -0
- package/packages/registry/blocks/preview-02/cards/new-milestone.ts +53 -0
- package/packages/registry/blocks/preview-02/cards/notification-settings.ts +126 -0
- package/packages/registry/blocks/preview-02/cards/payments.ts +88 -0
- package/packages/registry/blocks/preview-02/cards/payout-threshold.ts +92 -0
- package/packages/registry/blocks/preview-02/cards/power-usage.ts +84 -0
- package/packages/registry/blocks/preview-02/cards/preferences.ts +89 -0
- package/packages/registry/blocks/preview-02/cards/qr-connect.ts +54 -0
- package/packages/registry/blocks/preview-02/cards/receiving-method.ts +89 -0
- package/packages/registry/blocks/preview-02/cards/recent-transactions.ts +101 -0
- package/packages/registry/blocks/preview-02/cards/release-catalog.ts +73 -0
- package/packages/registry/blocks/preview-02/cards/roller-shades.ts +110 -0
- package/packages/registry/blocks/preview-02/cards/savings-progress.ts +68 -0
- package/packages/registry/blocks/preview-02/cards/savings-targets.ts +132 -0
- package/packages/registry/blocks/preview-02/cards/sidebar-nav.ts +88 -0
- package/packages/registry/blocks/preview-02/cards/social-links.ts +57 -0
- package/packages/registry/blocks/preview-02/cards/stock-performance.ts +106 -0
- package/packages/registry/blocks/preview-02/cards/syncing-state.ts +37 -0
- package/packages/registry/blocks/preview-02/cards/transfer-funds.ts +111 -0
- package/packages/registry/blocks/preview-02/cards/upcoming-payments.ts +69 -0
- package/packages/registry/blocks/preview-02/page.ts +111 -0
- package/packages/registry/blocks/preview-03/cards/files-chat.ts +75 -0
- package/packages/registry/blocks/preview-03/cards/group-chat.ts +114 -0
- package/packages/registry/blocks/preview-03/cards/reasoning-chat.ts +88 -0
- package/packages/registry/blocks/preview-03/cards/simple-chat.ts +53 -0
- package/packages/registry/blocks/preview-03/components/chat-card.ts +126 -0
- package/packages/registry/blocks/preview-03/components/chat-player.ts +174 -0
- package/packages/registry/blocks/preview-03/components/part-file.ts +77 -0
- package/packages/registry/blocks/preview-03/components/part-reasoning.ts +25 -0
- package/packages/registry/blocks/preview-03/components/part-source.ts +48 -0
- package/packages/registry/blocks/preview-03/components/part-text.ts +69 -0
- package/packages/registry/blocks/preview-03/components/part-tool.ts +71 -0
- package/packages/registry/blocks/preview-03/components/prompt-input.ts +86 -0
- package/packages/registry/blocks/preview-03/page.ts +39 -0
- package/packages/registry/blocks/sidebar-01/components/app-sidebar.ts +113 -0
- package/packages/registry/blocks/sidebar-01/components/search-form.ts +33 -0
- package/packages/registry/blocks/sidebar-01/components/version-switcher.ts +50 -0
- package/packages/registry/blocks/sidebar-01/page.ts +58 -0
- package/packages/registry/blocks/sidebar-02/components/app-sidebar.ts +131 -0
- package/packages/registry/blocks/sidebar-02/components/search-form.ts +33 -0
- package/packages/registry/blocks/sidebar-02/components/version-switcher.ts +50 -0
- package/packages/registry/blocks/sidebar-02/page.ts +53 -0
- package/packages/registry/blocks/sidebar-03/components/app-sidebar.ts +134 -0
- package/packages/registry/blocks/sidebar-03/page.ts +60 -0
- package/packages/registry/blocks/sidebar-04/components/app-sidebar.ts +136 -0
- package/packages/registry/blocks/sidebar-04/page.ts +58 -0
- package/packages/registry/blocks/sidebar-05/components/app-sidebar.ts +147 -0
- package/packages/registry/blocks/sidebar-05/components/search-form.ts +33 -0
- package/packages/registry/blocks/sidebar-05/page.ts +58 -0
- package/packages/registry/blocks/sidebar-06/components/app-sidebar.ts +105 -0
- package/packages/registry/blocks/sidebar-06/components/nav-main.ts +56 -0
- package/packages/registry/blocks/sidebar-06/components/sidebar-opt-in-form.ts +44 -0
- package/packages/registry/blocks/sidebar-06/page.ts +57 -0
- package/packages/registry/blocks/sidebar-07/components/app-sidebar.ts +108 -0
- package/packages/registry/blocks/sidebar-07/components/nav-main.ts +61 -0
- package/packages/registry/blocks/sidebar-07/components/nav-projects.ts +65 -0
- package/packages/registry/blocks/sidebar-07/components/nav-user.ts +70 -0
- package/packages/registry/blocks/sidebar-07/components/team-switcher.ts +66 -0
- package/packages/registry/blocks/sidebar-07/page.ts +59 -0
- package/packages/registry/blocks/sidebar-08/components/app-sidebar.ts +122 -0
- package/packages/registry/blocks/sidebar-08/components/nav-main.ts +68 -0
- package/packages/registry/blocks/sidebar-08/components/nav-projects.ts +65 -0
- package/packages/registry/blocks/sidebar-08/components/nav-secondary.ts +40 -0
- package/packages/registry/blocks/sidebar-08/components/nav-user.ts +70 -0
- package/packages/registry/blocks/sidebar-08/page.ts +59 -0
- package/packages/registry/blocks/sidebar-09/components/app-sidebar.ts +213 -0
- package/packages/registry/blocks/sidebar-09/components/nav-user.ts +70 -0
- package/packages/registry/blocks/sidebar-09/page.ts +52 -0
- package/packages/registry/blocks/sidebar-10/components/app-sidebar.ts +125 -0
- package/packages/registry/blocks/sidebar-10/components/nav-actions.ts +84 -0
- package/packages/registry/blocks/sidebar-10/components/nav-favorites.ts +66 -0
- package/packages/registry/blocks/sidebar-10/components/nav-main.ts +37 -0
- package/packages/registry/blocks/sidebar-10/components/nav-secondary.ts +43 -0
- package/packages/registry/blocks/sidebar-10/components/nav-workspaces.ts +78 -0
- package/packages/registry/blocks/sidebar-10/components/team-switcher.ts +63 -0
- package/packages/registry/blocks/sidebar-10/page.ts +46 -0
- package/packages/registry/blocks/sidebar-11/components/app-sidebar.ts +114 -0
- package/packages/registry/blocks/sidebar-11/page.ts +63 -0
- package/packages/registry/blocks/sidebar-12/components/app-sidebar.ts +63 -0
- package/packages/registry/blocks/sidebar-12/components/calendars.ts +53 -0
- package/packages/registry/blocks/sidebar-12/components/date-picker.ts +26 -0
- package/packages/registry/blocks/sidebar-12/components/nav-user.ts +70 -0
- package/packages/registry/blocks/sidebar-12/page.ts +43 -0
- package/packages/registry/blocks/sidebar-13/components/settings-dialog.ts +114 -0
- package/packages/registry/blocks/sidebar-13/page.ts +21 -0
- package/packages/registry/blocks/sidebar-14/components/app-sidebar.ts +120 -0
- package/packages/registry/blocks/sidebar-14/page.ts +55 -0
- package/packages/registry/blocks/sidebar-15/components/calendars.ts +53 -0
- package/packages/registry/blocks/sidebar-15/components/date-picker.ts +26 -0
- package/packages/registry/blocks/sidebar-15/components/nav-favorites.ts +66 -0
- package/packages/registry/blocks/sidebar-15/components/nav-main.ts +35 -0
- package/packages/registry/blocks/sidebar-15/components/nav-secondary.ts +43 -0
- package/packages/registry/blocks/sidebar-15/components/nav-user.ts +70 -0
- package/packages/registry/blocks/sidebar-15/components/nav-workspaces.ts +75 -0
- package/packages/registry/blocks/sidebar-15/components/sidebar-left.ts +126 -0
- package/packages/registry/blocks/sidebar-15/components/sidebar-right.ts +62 -0
- package/packages/registry/blocks/sidebar-15/components/team-switcher.ts +63 -0
- package/packages/registry/blocks/sidebar-15/page.ts +47 -0
- package/packages/registry/blocks/sidebar-16/components/app-sidebar.ts +124 -0
- package/packages/registry/blocks/sidebar-16/components/nav-main.ts +67 -0
- package/packages/registry/blocks/sidebar-16/components/nav-projects.ts +65 -0
- package/packages/registry/blocks/sidebar-16/components/nav-secondary.ts +40 -0
- package/packages/registry/blocks/sidebar-16/components/nav-user.ts +70 -0
- package/packages/registry/blocks/sidebar-16/components/search-form.ts +27 -0
- package/packages/registry/blocks/sidebar-16/components/site-header.ts +42 -0
- package/packages/registry/blocks/sidebar-16/page.ts +38 -0
- package/packages/registry/blocks/signup-01/components/signup-form.ts +78 -0
- package/packages/registry/blocks/signup-01/page.ts +19 -0
- package/packages/registry/blocks/signup-02/components/signup-form.ts +78 -0
- package/packages/registry/blocks/signup-02/page.ts +36 -0
- package/packages/registry/blocks/signup-03/components/signup-form.ts +79 -0
- package/packages/registry/blocks/signup-03/page.ts +28 -0
- package/packages/registry/blocks/signup-04/components/signup-form.ts +100 -0
- package/packages/registry/blocks/signup-04/page.ts +20 -0
- package/packages/registry/blocks/signup-05/components/signup-form.ts +75 -0
- package/packages/registry/blocks/signup-05/page.ts +20 -0
- package/packages/registry/components/accordion.ts +20 -7
- package/packages/registry/components/alert-dialog.ts +58 -13
- package/packages/registry/components/alert.ts +11 -6
- package/packages/registry/components/attachment.ts +119 -0
- package/packages/registry/components/avatar.ts +17 -8
- package/packages/registry/components/badge.ts +16 -9
- package/packages/registry/components/breadcrumb.ts +6 -6
- package/packages/registry/components/bubble.ts +95 -0
- package/packages/registry/components/button-group.ts +73 -0
- package/packages/registry/components/button.ts +35 -25
- package/packages/registry/components/calendar.ts +566 -0
- package/packages/registry/components/card.ts +8 -8
- package/packages/registry/components/carousel.ts +352 -0
- package/packages/registry/components/chart-element.ts +547 -0
- package/packages/registry/components/chart-geometry.ts +457 -0
- package/packages/registry/components/chart.ts +932 -0
- package/packages/registry/components/checkbox.ts +22 -84
- package/packages/registry/components/code-block.ts +191 -0
- package/packages/registry/components/collapsible.ts +5 -2
- package/packages/registry/components/combobox.ts +802 -0
- package/packages/registry/components/command.ts +618 -0
- package/packages/registry/components/context-menu.ts +302 -0
- package/packages/registry/components/dialog.ts +156 -45
- package/packages/registry/components/direction.ts +43 -0
- package/packages/registry/components/drawer.ts +226 -0
- package/packages/registry/components/dropdown-menu.ts +262 -83
- package/packages/registry/components/empty.ts +8 -8
- package/packages/registry/components/field.ts +20 -18
- package/packages/registry/components/floating.ts +124 -0
- package/packages/registry/components/hover-card.ts +19 -8
- package/packages/registry/components/input-group.ts +118 -0
- package/packages/registry/components/input-otp.ts +365 -0
- package/packages/registry/components/input.ts +3 -3
- package/packages/registry/components/item.ts +134 -0
- package/packages/registry/components/kbd.ts +2 -2
- package/packages/registry/components/label.ts +1 -1
- package/packages/registry/components/marker.ts +63 -0
- package/packages/registry/components/menubar.ts +388 -0
- package/packages/registry/components/message-scroller.ts +470 -0
- package/packages/registry/components/message.ts +69 -0
- package/packages/registry/components/native-select.ts +5 -5
- package/packages/registry/components/navigation-menu.ts +564 -0
- package/packages/registry/components/pagination.ts +5 -5
- package/packages/registry/components/popover.ts +30 -84
- package/packages/registry/components/progress.ts +7 -3
- package/packages/registry/components/questionnaire.ts +840 -0
- package/packages/registry/components/radio-group.ts +18 -73
- package/packages/registry/components/resizable.ts +330 -0
- package/packages/registry/components/scroll-area.ts +46 -0
- package/packages/registry/components/select.ts +650 -0
- package/packages/registry/components/separator.ts +1 -1
- package/packages/registry/components/sheet.ts +128 -0
- package/packages/registry/components/sidebar.ts +457 -0
- package/packages/registry/components/skeleton.ts +1 -1
- package/packages/registry/components/slider.ts +333 -0
- package/packages/registry/components/sonner.ts +74 -7
- package/packages/registry/components/spinner.ts +7 -4
- package/packages/registry/components/switch.ts +117 -9
- package/packages/registry/components/table.ts +11 -9
- package/packages/registry/components/tabs.ts +76 -25
- package/packages/registry/components/textarea.ts +1 -1
- package/packages/registry/components/toggle-group.ts +30 -11
- package/packages/registry/components/toggle.ts +20 -13
- package/packages/registry/components/tooltip.ts +68 -7
- package/packages/registry/components/trace.ts +75 -0
- package/packages/registry/lib/dom.ts +3 -4
- package/packages/registry/lib/icons-hugeicons.ts +955 -0
- package/packages/registry/lib/icons-phosphor.ts +955 -0
- package/packages/registry/lib/icons-remixicon.ts +955 -0
- package/packages/registry/lib/icons-tabler.ts +955 -0
- package/packages/registry/lib/icons.ts +768 -0
- package/packages/registry/lib/utils.ts +52 -8
- package/packages/registry/registry.json +4056 -72
- package/packages/registry/styles/shadcn-tailwind.css +654 -0
- package/packages/registry/styles/style-luma.css +1987 -0
- package/packages/registry/styles/style-lyra.css +1965 -0
- package/packages/registry/styles/style-maia.css +1987 -0
- package/packages/registry/styles/style-mira.css +1992 -0
- package/packages/registry/styles/style-new-york.css +1597 -0
- package/packages/registry/styles/style-nova.css +1990 -0
- package/packages/registry/styles/style-rhea.css +1987 -0
- package/packages/registry/styles/style-sera.css +1977 -0
- package/packages/registry/styles/style-vega.css +1990 -0
- package/packages/registry/styles/supplement.json +54 -0
- package/packages/registry/styles/tw-animate.css +6 -0
- package/packages/registry/themes/base-colors.js +8 -2
- package/packages/registry/themes/fonts.js +120 -0
- package/packages/registry/themes/index.css +2 -0
- package/packages/registry/themes/items.js +61 -0
- package/packages/registry/themes/preset.js +302 -0
- package/packages/registry/themes/themes.js +1193 -0
- package/src/commands/add.js +266 -14
- package/src/commands/diff.js +34 -20
- package/src/commands/info.js +7 -0
- package/src/commands/init.js +127 -10
- package/src/commands/list.js +43 -11
- package/src/commands/view.js +33 -5
- package/src/lint/rules/no-restyle.js +1 -1
- package/src/registry/extract.js +194 -5
- package/src/registry/icons.js +31 -0
- package/src/registry/local.js +15 -1
- package/src/registry/schema.js +13 -0
- package/src/registry/style-bake.js +506 -0
- package/src/utils/theme.js +110 -21
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The chart's geometry: Recharts' maths, ported with no dependency (#1666,
|
|
3
|
+
* D10). Pure functions over numbers and strings, imported by `chart.ts`,
|
|
4
|
+
* which draws with them and re-exports them, so an app reaches them through
|
|
5
|
+
* the chart module.
|
|
6
|
+
*
|
|
7
|
+
* What is here, each matching what Recharts 3 draws for the same input:
|
|
8
|
+
* the nice ticks of a numeric axis (getNiceTickValues), linear, band and
|
|
9
|
+
* point scales, the d3-shape curves (linear, natural, monotone, step), the
|
|
10
|
+
* bar rectangle and pie or radial sector paths with their rounded corners,
|
|
11
|
+
* polar coordinates, stacking (none, sign, expand), the bar slot layout
|
|
12
|
+
* (getBarPositions), and which axis labels fit (getTicks).
|
|
13
|
+
*
|
|
14
|
+
* A11y: none to supply. This module draws nothing; the chart that uses it
|
|
15
|
+
* carries the accessible name and the keyboard access.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** A curve type, Recharts' `type` on a Line or an Area. */
|
|
19
|
+
export type CurveType = 'linear' | 'natural' | 'monotone' | 'monotoneX' | 'step' | 'stepBefore' | 'stepAfter';
|
|
20
|
+
|
|
21
|
+
// --------------------------------------------------------------------------
|
|
22
|
+
// Numbers
|
|
23
|
+
// --------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
export const RADIAN = Math.PI / 180;
|
|
26
|
+
|
|
27
|
+
// Floating point noise off: 0.1 + 0.2 stays 0.3 for tick values.
|
|
28
|
+
function snap(n: number): number {
|
|
29
|
+
return Number(n.toPrecision(12));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A coordinate as Recharts writes one: at most four decimals, no `-0`. */
|
|
33
|
+
export function fmt(n: number, digits = 4): string {
|
|
34
|
+
const k = 10 ** digits;
|
|
35
|
+
const r = Math.round(n * k) / k;
|
|
36
|
+
return String(r === 0 ? 0 : r);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** A number as a tooltip shows one (`toLocaleString`, fixed to en-US so server and client agree). */
|
|
40
|
+
export function formatValue(v: unknown): string {
|
|
41
|
+
return typeof v === 'number' ? v.toLocaleString('en-US') : String(v ?? '');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function num(v: unknown): number {
|
|
45
|
+
return typeof v === 'number' ? v : Number(v) || 0;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A Recharts size: a number, or a percentage of `whole`. */
|
|
49
|
+
export function percent(v: number | string | undefined, whole: number, fallback: number): number {
|
|
50
|
+
if (v == null) return fallback;
|
|
51
|
+
if (typeof v === 'number') return v;
|
|
52
|
+
const s = v.trim();
|
|
53
|
+
if (s.endsWith('%')) return (parseFloat(s) / 100) * whole;
|
|
54
|
+
const n = parseFloat(s);
|
|
55
|
+
return Number.isFinite(n) ? n : fallback;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The width of a label in the chart's 12px font, estimated, since the server
|
|
60
|
+
* cannot measure text. Used only to thin crowded axis labels.
|
|
61
|
+
*/
|
|
62
|
+
export function estimateTextWidth(text: string, fontSize = 12): number {
|
|
63
|
+
let em = 0;
|
|
64
|
+
for (const ch of text) {
|
|
65
|
+
if (/[ilj.,:;'|!]/.test(ch)) em += 0.26;
|
|
66
|
+
else if (/[mwMW]/.test(ch)) em += 0.82;
|
|
67
|
+
else if (ch === ' ') em += 0.28;
|
|
68
|
+
else if (/[0-9]/.test(ch)) em += 0.56;
|
|
69
|
+
else if (/[A-Z]/.test(ch)) em += 0.66;
|
|
70
|
+
else em += 0.52;
|
|
71
|
+
}
|
|
72
|
+
return em * fontSize;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// --------------------------------------------------------------------------
|
|
76
|
+
// Ticks and scales (Recharts' getNiceTickValues, ported)
|
|
77
|
+
// --------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
function digitCount(v: number): number {
|
|
80
|
+
return v === 0 ? 1 : Math.floor(snap(Math.log10(Math.abs(v)))) + 1;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function adaptiveStep(rough: number, allowDecimals: boolean, correction: number): number {
|
|
84
|
+
if (rough <= 0) return 0;
|
|
85
|
+
const dc = digitCount(rough);
|
|
86
|
+
const pow = 10 ** dc;
|
|
87
|
+
const ratio = rough / pow;
|
|
88
|
+
const scale = dc !== 1 ? 0.05 : 0.1;
|
|
89
|
+
const step = snap(snap((Math.ceil(snap(ratio / scale)) + correction) * scale) * pow);
|
|
90
|
+
return allowDecimals ? step : Math.ceil(step);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function calculateStep(min: number, max: number, count: number, allowDecimals: boolean, correction = 0): { step: number; tickMin: number; tickMax: number } {
|
|
94
|
+
if (!Number.isFinite((max - min) / (count - 1))) return { step: 0, tickMin: 0, tickMax: 0 };
|
|
95
|
+
const step = adaptiveStep((max - min) / (count - 1), allowDecimals, correction);
|
|
96
|
+
let middle: number;
|
|
97
|
+
if (min <= 0 && max >= 0) middle = 0;
|
|
98
|
+
else {
|
|
99
|
+
middle = (min + max) / 2;
|
|
100
|
+
middle = snap(middle - (middle % step));
|
|
101
|
+
}
|
|
102
|
+
let below = Math.ceil(snap((middle - min) / step));
|
|
103
|
+
let up = Math.ceil(snap((max - middle) / step));
|
|
104
|
+
const scaleCount = below + up + 1;
|
|
105
|
+
if (scaleCount > count) return calculateStep(min, max, count, allowDecimals, correction + 1);
|
|
106
|
+
if (scaleCount < count) {
|
|
107
|
+
if (max > 0) up += count - scaleCount;
|
|
108
|
+
else below += count - scaleCount;
|
|
109
|
+
}
|
|
110
|
+
return { step, tickMin: snap(middle - below * step), tickMax: snap(middle + up * step) };
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Recharts' nice ticks for a numeric axis: `count` round values covering
|
|
115
|
+
* `[min, max]`, extended past the data where that makes them rounder
|
|
116
|
+
* (`[0, 305]` gives `0, 80, 160, 240, 320`).
|
|
117
|
+
*/
|
|
118
|
+
export function niceTicks(min: number, max: number, count = 5, allowDecimals = true): number[] {
|
|
119
|
+
const n = Math.max(count, 2);
|
|
120
|
+
const [lo, hi] = min > max ? [max, min] : [min, max];
|
|
121
|
+
if (lo === hi) {
|
|
122
|
+
const middleIndex = Math.floor((n - 1) / 2);
|
|
123
|
+
let middle = lo;
|
|
124
|
+
if (lo === 0) middle = middleIndex;
|
|
125
|
+
else if (!allowDecimals || Math.abs(lo) > 1) middle = Math.floor(lo);
|
|
126
|
+
return Array.from({ length: n }, (_, i) => snap(middle + (i - middleIndex)));
|
|
127
|
+
}
|
|
128
|
+
const { step, tickMin, tickMax } = calculateStep(lo, hi, n, allowDecimals);
|
|
129
|
+
const out: number[] = [];
|
|
130
|
+
if (step <= 0) return [tickMin];
|
|
131
|
+
for (let v = tickMin, i = 0; v < tickMax + step * 0.1 && i < 1000; i++, v = snap(tickMin + i * step)) out.push(v);
|
|
132
|
+
return min > max ? out.reverse() : out;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* d3's linear ticks: about `count` round values inside `[start, stop]`,
|
|
137
|
+
* stepping by 1, 2 or 5 times a power of ten. Recharts uses them for an axis
|
|
138
|
+
* with no tick count of its own, a radial bar chart's angle axis.
|
|
139
|
+
*/
|
|
140
|
+
export function linearTicks(start: number, stop: number, count = 10): number[] {
|
|
141
|
+
const raw = Math.abs(stop - start) / count;
|
|
142
|
+
if (!(raw > 0) || !Number.isFinite(raw)) return [start];
|
|
143
|
+
const power = Math.floor(Math.log10(raw));
|
|
144
|
+
const error = raw / 10 ** power;
|
|
145
|
+
const step = (error >= Math.sqrt(50) ? 10 : error >= Math.sqrt(10) ? 5 : error >= Math.sqrt(2) ? 2 : 1) * 10 ** power;
|
|
146
|
+
const out: number[] = [];
|
|
147
|
+
for (let v = Math.ceil(start / step) * step; v <= stop + step * 1e-9; v = snap(v + step)) out.push(snap(v));
|
|
148
|
+
return out;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** A linear scale from a domain onto a range. */
|
|
152
|
+
export function linearScale(domain: [number, number], range: [number, number]): (v: number) => number {
|
|
153
|
+
const [d0, d1] = domain;
|
|
154
|
+
const [r0, r1] = range;
|
|
155
|
+
return (v) => (d1 === d0 ? (r0 + r1) / 2 : r0 + ((v - d0) / (d1 - d0)) * (r1 - r0));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/** A band scale with no padding, Recharts' category axis under bars. */
|
|
159
|
+
export function bandScale(count: number, start: number, end: number): { bandwidth: number; at: (i: number) => number } {
|
|
160
|
+
const bandwidth = count ? (end - start) / count : 0;
|
|
161
|
+
return { bandwidth, at: (i) => start + i * bandwidth };
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** A point scale with no padding, Recharts' category axis under lines and areas. */
|
|
165
|
+
export function pointScale(count: number, start: number, end: number): (i: number) => number {
|
|
166
|
+
return (i) => (count <= 1 ? (start + end) / 2 : start + (i * (end - start)) / (count - 1));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// --------------------------------------------------------------------------
|
|
170
|
+
// Curves (d3-shape's curves, which Recharts draws with)
|
|
171
|
+
// --------------------------------------------------------------------------
|
|
172
|
+
|
|
173
|
+
export type Pt = [number, number];
|
|
174
|
+
|
|
175
|
+
function naturalControls(x: number[]): [number[], number[]] {
|
|
176
|
+
const n = x.length - 1;
|
|
177
|
+
const a = new Array<number>(n);
|
|
178
|
+
const b = new Array<number>(n);
|
|
179
|
+
const r = new Array<number>(n);
|
|
180
|
+
a[0] = 0; b[0] = 2; r[0] = x[0] + 2 * x[1];
|
|
181
|
+
for (let i = 1; i < n - 1; ++i) { a[i] = 1; b[i] = 4; r[i] = 4 * x[i] + 2 * x[i + 1]; }
|
|
182
|
+
a[n - 1] = 2; b[n - 1] = 7; r[n - 1] = 8 * x[n - 1] + x[n];
|
|
183
|
+
for (let i = 1; i < n; ++i) { const m = a[i] / b[i - 1]; b[i] -= m; r[i] -= m * r[i - 1]; }
|
|
184
|
+
a[n - 1] = r[n - 1] / b[n - 1];
|
|
185
|
+
for (let i = n - 2; i >= 0; --i) a[i] = (r[i] - a[i + 1]) / b[i];
|
|
186
|
+
b[n - 1] = (x[n] + a[n - 1]) / 2;
|
|
187
|
+
for (let i = 0; i < n - 1; ++i) b[i] = 2 * x[i + 1] - a[i + 1];
|
|
188
|
+
return [a, b];
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function sgn(x: number): number {
|
|
192
|
+
return x < 0 ? -1 : 1;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* The SVG path of a curve through `points`, as d3-shape draws it (three
|
|
197
|
+
* decimals). `start` is the first command: `M` for a new path, `L` to
|
|
198
|
+
* continue one (an area's baseline).
|
|
199
|
+
*/
|
|
200
|
+
export function curvePath(points: Pt[], type: CurveType = 'linear', start: 'M' | 'L' = 'M'): string {
|
|
201
|
+
const p = (x: number, y: number) => `${fmt(x, 3)},${fmt(y, 3)}`;
|
|
202
|
+
if (!points.length) return '';
|
|
203
|
+
const [x0, y0] = points[0];
|
|
204
|
+
let d = `${start}${p(x0, y0)}`;
|
|
205
|
+
const n = points.length;
|
|
206
|
+
if (n === 1) return d;
|
|
207
|
+
if (type === 'natural') {
|
|
208
|
+
if (n === 2) return `${d}L${p(points[1][0], points[1][1])}`;
|
|
209
|
+
const [ax, bx] = naturalControls(points.map((q) => q[0]));
|
|
210
|
+
const [ay, by] = naturalControls(points.map((q) => q[1]));
|
|
211
|
+
for (let i = 0; i < n - 1; i++) d += `C${p(ax[i], ay[i])},${p(bx[i], by[i])},${p(points[i + 1][0], points[i + 1][1])}`;
|
|
212
|
+
return d;
|
|
213
|
+
}
|
|
214
|
+
if (type === 'monotone' || type === 'monotoneX') {
|
|
215
|
+
// d3's curveMonotoneX: slopes from the neighbours, never overshooting.
|
|
216
|
+
const xs = points.map((q) => q[0]);
|
|
217
|
+
const ys = points.map((q) => q[1]);
|
|
218
|
+
if (n === 2) return `${d}L${p(xs[1], ys[1])}`;
|
|
219
|
+
const slope3 = (i: number): number => {
|
|
220
|
+
const h0 = xs[i] - xs[i - 1];
|
|
221
|
+
const h1 = xs[i + 1] - xs[i];
|
|
222
|
+
const s0 = (ys[i] - ys[i - 1]) / (h0 || (h1 < 0 ? -0 : 0));
|
|
223
|
+
const s1 = (ys[i + 1] - ys[i]) / (h1 || (h0 < 0 ? -0 : 0));
|
|
224
|
+
const q = (s0 * h1 + s1 * h0) / (h0 + h1);
|
|
225
|
+
return (sgn(s0) + sgn(s1)) * Math.min(Math.abs(s0), Math.abs(s1), 0.5 * Math.abs(q)) || 0;
|
|
226
|
+
};
|
|
227
|
+
const slope2 = (i: number, t: number): number => {
|
|
228
|
+
const h = xs[i] - xs[i - 1];
|
|
229
|
+
return h ? (3 * (ys[i] - ys[i - 1]) / h - t) / 2 : t;
|
|
230
|
+
};
|
|
231
|
+
const t = new Array<number>(n);
|
|
232
|
+
for (let i = 1; i < n - 1; i++) t[i] = slope3(i);
|
|
233
|
+
t[0] = slope2(1, t[1]);
|
|
234
|
+
t[n - 1] = slope2(n - 1, t[n - 2]);
|
|
235
|
+
for (let i = 0; i < n - 1; i++) {
|
|
236
|
+
const dx = (xs[i + 1] - xs[i]) / 3;
|
|
237
|
+
d += `C${p(xs[i] + dx, ys[i] + dx * t[i])},${p(xs[i + 1] - dx, ys[i + 1] - dx * t[i + 1])},${p(xs[i + 1], ys[i + 1])}`;
|
|
238
|
+
}
|
|
239
|
+
return d;
|
|
240
|
+
}
|
|
241
|
+
if (type === 'step' || type === 'stepBefore' || type === 'stepAfter') {
|
|
242
|
+
const k = type === 'step' ? 0.5 : type === 'stepBefore' ? 0 : 1;
|
|
243
|
+
for (let i = 1; i < n; i++) {
|
|
244
|
+
const [px, py] = points[i - 1];
|
|
245
|
+
const [x, y] = points[i];
|
|
246
|
+
if (k <= 0) d += `L${p(px, y)}L${p(x, y)}`;
|
|
247
|
+
else { const x1 = px * (1 - k) + x * k; d += `L${p(x1, py)}L${p(x1, y)}`; }
|
|
248
|
+
}
|
|
249
|
+
if (k > 0 && k < 1) d += `L${p(points[n - 1][0], points[n - 1][1])}`;
|
|
250
|
+
return d;
|
|
251
|
+
}
|
|
252
|
+
for (let i = 1; i < n; i++) d += `L${p(points[i][0], points[i][1])}`;
|
|
253
|
+
return d;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
// --------------------------------------------------------------------------
|
|
257
|
+
// Shapes (Recharts' Rectangle and Sector paths)
|
|
258
|
+
// --------------------------------------------------------------------------
|
|
259
|
+
|
|
260
|
+
/** A bar: Recharts' rectangle path, `radius` one number or `[tl, tr, br, bl]`. */
|
|
261
|
+
export function rectanglePath(x: number, y: number, width: number, height: number, radius: number | number[] = 0): string {
|
|
262
|
+
const w = Math.round(width * 1e4) / 1e4;
|
|
263
|
+
const h = Math.round(height * 1e4) / 1e4;
|
|
264
|
+
const maxR = Math.min(Math.abs(w) / 2, Math.abs(h) / 2);
|
|
265
|
+
const ys = h >= 0 ? 1 : -1;
|
|
266
|
+
const xs = w >= 0 ? 1 : -1;
|
|
267
|
+
const cw = (h >= 0 && w >= 0) || (h < 0 && w < 0) ? 1 : 0;
|
|
268
|
+
const r4 = Array.isArray(radius) ? radius : radius > 0 ? [radius, radius, radius, radius] : null;
|
|
269
|
+
if (maxR > 0 && r4) {
|
|
270
|
+
const r = [0, 1, 2, 3].map((i) => Math.min(r4[i] ?? 0, maxR));
|
|
271
|
+
let d = `M${fmt(x)},${fmt(y + ys * r[0])}`;
|
|
272
|
+
if (r[0] > 0) d += `A ${fmt(r[0])},${fmt(r[0])},0,0,${cw},${fmt(x + xs * r[0])},${fmt(y)}`;
|
|
273
|
+
d += `L ${fmt(x + width - xs * r[1])},${fmt(y)}`;
|
|
274
|
+
if (r[1] > 0) d += `A ${fmt(r[1])},${fmt(r[1])},0,0,${cw},${fmt(x + width)},${fmt(y + ys * r[1])}`;
|
|
275
|
+
d += `L ${fmt(x + width)},${fmt(y + height - ys * r[2])}`;
|
|
276
|
+
if (r[2] > 0) d += `A ${fmt(r[2])},${fmt(r[2])},0,0,${cw},${fmt(x + width - xs * r[2])},${fmt(y + height)}`;
|
|
277
|
+
d += `L ${fmt(x + xs * r[3])},${fmt(y + height)}`;
|
|
278
|
+
if (r[3] > 0) d += `A ${fmt(r[3])},${fmt(r[3])},0,0,${cw},${fmt(x)},${fmt(y + height - ys * r[3])}`;
|
|
279
|
+
return `${d}Z`;
|
|
280
|
+
}
|
|
281
|
+
return `M ${fmt(x)},${fmt(y)} h ${fmt(width)} v ${fmt(height)} h ${fmt(-width)} Z`;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Recharts' polar coordinates: degrees counter-clockwise from three o'clock. */
|
|
285
|
+
export function polarToCartesian(cx: number, cy: number, radius: number, angle: number): { x: number; y: number } {
|
|
286
|
+
return { x: cx + Math.cos(-RADIAN * angle) * radius, y: cy + Math.sin(-RADIAN * angle) * radius };
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
export interface SectorGeometry {
|
|
290
|
+
cx: number;
|
|
291
|
+
cy: number;
|
|
292
|
+
innerRadius: number;
|
|
293
|
+
outerRadius: number;
|
|
294
|
+
startAngle: number;
|
|
295
|
+
endAngle: number;
|
|
296
|
+
cornerRadius?: number;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function tangentCircle(cx: number, cy: number, radius: number, angle: number, sign: number, isExternal: boolean, cornerRadius: number) {
|
|
300
|
+
const centerRadius = cornerRadius * (isExternal ? 1 : -1) + radius;
|
|
301
|
+
const theta = Math.asin(cornerRadius / centerRadius) / RADIAN;
|
|
302
|
+
const centerAngle = angle + sign * theta;
|
|
303
|
+
const circleTangency = polarToCartesian(cx, cy, radius, centerAngle);
|
|
304
|
+
const lineTangency = polarToCartesian(cx, cy, centerRadius * Math.cos(theta * RADIAN), angle);
|
|
305
|
+
return { circleTangency, lineTangency, theta };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** A pie slice or radial bar: Recharts' sector path, with rounded corners when asked. */
|
|
309
|
+
export function sectorPath(s: SectorGeometry): string {
|
|
310
|
+
const { cx, cy, innerRadius, outerRadius, startAngle, endAngle } = s;
|
|
311
|
+
if (outerRadius < innerRadius || startAngle === endAngle) return '';
|
|
312
|
+
const cr = Math.min(s.cornerRadius ?? 0, (outerRadius - innerRadius) / 2);
|
|
313
|
+
const sign = Math.sign(endAngle - startAngle) || 1;
|
|
314
|
+
if (cr > 0 && Math.abs(startAngle - endAngle) < 360) {
|
|
315
|
+
const so = tangentCircle(cx, cy, outerRadius, startAngle, sign, false, cr);
|
|
316
|
+
const eo = tangentCircle(cx, cy, outerRadius, endAngle, -sign, false, cr);
|
|
317
|
+
const outerArc = Math.abs(startAngle - endAngle) - so.theta - eo.theta;
|
|
318
|
+
if (outerArc >= 0) {
|
|
319
|
+
const P = (q: { x: number; y: number }) => `${fmt(q.x)},${fmt(q.y)}`;
|
|
320
|
+
let d = `M ${P(so.lineTangency)} A${fmt(cr)},${fmt(cr)},0,0,${+(sign < 0)},${P(so.circleTangency)} A${fmt(outerRadius)},${fmt(outerRadius)},0,${+(outerArc > 180)},${+(sign < 0)},${P(eo.circleTangency)} A${fmt(cr)},${fmt(cr)},0,0,${+(sign < 0)},${P(eo.lineTangency)}`;
|
|
321
|
+
if (innerRadius > 0) {
|
|
322
|
+
const si = tangentCircle(cx, cy, innerRadius, startAngle, sign, true, cr);
|
|
323
|
+
const ei = tangentCircle(cx, cy, innerRadius, endAngle, -sign, true, cr);
|
|
324
|
+
const innerArc = Math.abs(startAngle - endAngle) - si.theta - ei.theta;
|
|
325
|
+
d += `L${P(ei.lineTangency)} A${fmt(cr)},${fmt(cr)},0,0,${+(sign < 0)},${P(ei.circleTangency)} A${fmt(innerRadius)},${fmt(innerRadius)},0,${+(innerArc > 180)},${+(sign > 0)},${P(si.circleTangency)} A${fmt(cr)},${fmt(cr)},0,0,${+(sign < 0)},${P(si.lineTangency)}Z`;
|
|
326
|
+
} else d += `L${fmt(cx)},${fmt(cy)}Z`;
|
|
327
|
+
return d;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
const delta = sign * Math.min(Math.abs(endAngle - startAngle), 359.999);
|
|
331
|
+
const end = startAngle + delta;
|
|
332
|
+
const os = polarToCartesian(cx, cy, outerRadius, startAngle);
|
|
333
|
+
const oe = polarToCartesian(cx, cy, outerRadius, end);
|
|
334
|
+
const large = +(Math.abs(delta) > 180);
|
|
335
|
+
let d = `M ${fmt(os.x)},${fmt(os.y)} A ${fmt(outerRadius)},${fmt(outerRadius)},0,${large},${+(startAngle > end)},${fmt(oe.x)},${fmt(oe.y)}`;
|
|
336
|
+
if (innerRadius > 0) {
|
|
337
|
+
const is = polarToCartesian(cx, cy, innerRadius, startAngle);
|
|
338
|
+
const ie = polarToCartesian(cx, cy, innerRadius, end);
|
|
339
|
+
d += ` L ${fmt(ie.x)},${fmt(ie.y)} A ${fmt(innerRadius)},${fmt(innerRadius)},0,${large},${+(startAngle <= end)},${fmt(is.x)},${fmt(is.y)} Z`;
|
|
340
|
+
} else d += ` L ${fmt(cx)},${fmt(cy)} Z`;
|
|
341
|
+
return d;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** A closed polygon through `points` (a radar's area, a polar grid ring). */
|
|
345
|
+
export function polygonPath(points: { x: number; y: number }[]): string {
|
|
346
|
+
if (!points.length) return '';
|
|
347
|
+
return `${points.map((q, i) => `${i ? 'L' : 'M'}${fmt(q.x)},${fmt(q.y)}`).join('')}L${fmt(points[0].x)},${fmt(points[0].y)}Z`;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// --------------------------------------------------------------------------
|
|
351
|
+
// Stacking
|
|
352
|
+
// --------------------------------------------------------------------------
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Stack `keys` over `data`: for each key, the `[low, high]` band of every
|
|
356
|
+
* row. `expand` normalises each row to 0..1 (Recharts' `stackOffset="expand"`),
|
|
357
|
+
* `sign` stacks negative values downward from zero, as Recharts does for bars.
|
|
358
|
+
*/
|
|
359
|
+
export function stackData(data: Array<Record<string, unknown>>, keys: string[], offset: 'none' | 'expand' | 'sign' = 'none'): Record<string, Array<[number, number]>> {
|
|
360
|
+
const out: Record<string, Array<[number, number]>> = {};
|
|
361
|
+
for (const k of keys) out[k] = [];
|
|
362
|
+
data.forEach((row) => {
|
|
363
|
+
const total = keys.reduce((s, k) => s + Math.abs(num(row[k])), 0) || 1;
|
|
364
|
+
let pos = 0;
|
|
365
|
+
let neg = 0;
|
|
366
|
+
for (const k of keys) {
|
|
367
|
+
let v = num(row[k]);
|
|
368
|
+
if (offset === 'expand') v /= total;
|
|
369
|
+
if (offset === 'sign' && v < 0) { out[k].push([neg + v, neg]); neg += v; }
|
|
370
|
+
else { out[k].push([pos, pos + v]); pos += v; }
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
return out;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// --------------------------------------------------------------------------
|
|
377
|
+
// Axis ticks (Recharts' getTicks: which labels fit)
|
|
378
|
+
// --------------------------------------------------------------------------
|
|
379
|
+
|
|
380
|
+
export interface Tick { value: unknown; label: unknown; coord: number; at?: number }
|
|
381
|
+
|
|
382
|
+
function isVisible(sign: number, pos: number, size: number, start: number, end: number): boolean {
|
|
383
|
+
if (sign * pos < sign * start || sign * pos > sign * end) return false;
|
|
384
|
+
return sign * (pos - (sign * size) / 2 - start) >= 0 && sign * (pos + (sign * size) / 2 - end) <= 0;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* The ticks an axis shows: every one that fits, keeping the last (Recharts'
|
|
389
|
+
* default `preserveEnd`), `minTickGap` apart. A number keeps every nth + 1.
|
|
390
|
+
*/
|
|
391
|
+
export function visibleTicks(ticks: Tick[], sizeOf: (t: Tick) => number, start: number, end: number, minTickGap = 5, interval: number | 'preserveEnd' | 'preserveStart' | 'preserveStartEnd' = 'preserveEnd'): Tick[] {
|
|
392
|
+
if (typeof interval === 'number') return ticks.filter((_, i) => i % (interval + 1) === 0).map((t) => ({ ...t, at: t.coord }));
|
|
393
|
+
const sign = ticks.length >= 2 ? Math.sign(ticks[1].coord - ticks[0].coord) || 1 : 1;
|
|
394
|
+
let [s, e] = sign === 1 ? [start, end] : [end, start];
|
|
395
|
+
const out: Array<Tick & { show?: boolean }> = ticks.map((t) => ({ ...t, at: t.coord }));
|
|
396
|
+
const len = out.length;
|
|
397
|
+
if (interval === 'preserveEnd') {
|
|
398
|
+
for (let i = len - 1; i >= 0; i--) {
|
|
399
|
+
const t = out[i];
|
|
400
|
+
const size = sizeOf(t);
|
|
401
|
+
if (i === len - 1) {
|
|
402
|
+
const gap = sign * (t.coord + (sign * size) / 2 - e);
|
|
403
|
+
t.at = gap > 0 ? t.coord - gap * sign : t.coord;
|
|
404
|
+
}
|
|
405
|
+
if (isVisible(sign, t.at ?? t.coord, size, s, e)) {
|
|
406
|
+
e = (t.at ?? t.coord) - sign * (size / 2 + minTickGap);
|
|
407
|
+
t.show = true;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
} else {
|
|
411
|
+
let count = len;
|
|
412
|
+
if (interval === 'preserveStartEnd' && len) {
|
|
413
|
+
const tail = out[len - 1];
|
|
414
|
+
const size = sizeOf(tail);
|
|
415
|
+
const gap = sign * (tail.coord + (sign * size) / 2 - e);
|
|
416
|
+
tail.at = gap > 0 ? tail.coord - gap * sign : tail.coord;
|
|
417
|
+
if (isVisible(sign, tail.at, size, s, e)) { e = tail.at - sign * (size / 2 + minTickGap); tail.show = true; }
|
|
418
|
+
count = len - 1;
|
|
419
|
+
}
|
|
420
|
+
for (let i = 0; i < count; i++) {
|
|
421
|
+
const t = out[i];
|
|
422
|
+
const size = sizeOf(t);
|
|
423
|
+
if (i === 0) {
|
|
424
|
+
const gap = sign * (t.coord - (sign * size) / 2 - s);
|
|
425
|
+
t.at = gap < 0 ? t.coord - gap * sign : t.coord;
|
|
426
|
+
}
|
|
427
|
+
if (isVisible(sign, t.at ?? t.coord, size, s, e)) { s = (t.at ?? t.coord) + sign * (size / 2 + minTickGap); t.show = true; }
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return out.filter((t) => t.show);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
// --------------------------------------------------------------------------
|
|
434
|
+
// Bar layout
|
|
435
|
+
// --------------------------------------------------------------------------
|
|
436
|
+
|
|
437
|
+
/** Recharts' getBarPositions: each bar slot's offset into its band and its size. */
|
|
438
|
+
export function barPositions(bandSize: number, slots: Array<{ barSize?: number }>, barGap: number | string = 4, barCategoryGap: number | string = '10%', maxBarSize?: number): Array<{ offset: number; size: number }> {
|
|
439
|
+
const len = slots.length;
|
|
440
|
+
if (!len) return [];
|
|
441
|
+
let gap = percent(barGap, bandSize, 0);
|
|
442
|
+
if (slots[0].barSize != null) {
|
|
443
|
+
let useFull = false;
|
|
444
|
+
let full = bandSize / len;
|
|
445
|
+
let sum = slots.reduce((s, x) => s + (x.barSize ?? 0), 0) + (len - 1) * gap;
|
|
446
|
+
if (sum >= bandSize) { sum -= (len - 1) * gap; gap = 0; }
|
|
447
|
+
if (sum >= bandSize && full > 0) { useFull = true; full *= 0.9; sum = len * full; }
|
|
448
|
+
let prev = { offset: Math.trunc((bandSize - sum) / 2) - gap, size: 0 };
|
|
449
|
+
return slots.map((x) => (prev = { offset: prev.offset + prev.size + gap, size: useFull ? full : x.barSize ?? 0 }));
|
|
450
|
+
}
|
|
451
|
+
const offset = percent(barCategoryGap, bandSize, 0);
|
|
452
|
+
if (bandSize - 2 * offset - (len - 1) * gap <= 0) gap = 0;
|
|
453
|
+
let original = (bandSize - 2 * offset - (len - 1) * gap) / len;
|
|
454
|
+
if (original > 1) original = Math.trunc(original);
|
|
455
|
+
const size = maxBarSize != null ? Math.min(original, maxBarSize) : original;
|
|
456
|
+
return slots.map((_, i) => ({ offset: offset + (original + gap) * i + (original - size) / 2, size }));
|
|
457
|
+
}
|