@glyphui/ui 0.3.0 → 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 +68 -12
- package/dist/chart.d.ts +14 -202
- package/dist/chart.js +14 -456
- package/dist/components/accordion/accordion.d.ts +15 -0
- package/dist/components/accordion/accordion.js +69 -0
- package/dist/components/accordion/accordion.styles.d.ts +65 -0
- package/dist/components/accordion/accordion.styles.js +30 -0
- package/dist/components/accordion/index.d.ts +3 -0
- package/dist/components/alert/alert-icons.js +62 -0
- package/dist/components/alert/alert.d.ts +19 -0
- package/dist/components/alert/alert.js +64 -0
- package/dist/components/alert/alert.styles.d.ts +107 -0
- package/dist/components/alert/alert.styles.js +86 -0
- package/dist/components/alert/index.d.ts +3 -0
- package/dist/components/alert-dialog/alert-dialog.d.ts +29 -0
- package/dist/components/alert-dialog/alert-dialog.js +89 -0
- package/dist/components/alert-dialog/alert-dialog.styles.d.ts +63 -0
- package/dist/components/alert-dialog/alert-dialog.styles.js +19 -0
- package/dist/components/alert-dialog/confirm-dialog.js +22 -0
- package/dist/components/alert-dialog/confirm.d.ts +30 -0
- package/dist/components/alert-dialog/confirm.js +62 -0
- package/dist/components/alert-dialog/index.d.ts +4 -0
- package/dist/components/aspect-ratio/aspect-ratio.d.ts +55 -0
- package/dist/components/aspect-ratio/aspect-ratio.js +28 -0
- package/dist/components/aspect-ratio/index.d.ts +2 -0
- package/dist/components/avatar/avatar.d.ts +13 -0
- package/dist/components/avatar/avatar.js +50 -0
- package/dist/components/avatar/avatar.styles.d.ts +77 -0
- package/dist/components/avatar/avatar.styles.js +32 -0
- package/dist/components/avatar/index.d.ts +3 -0
- package/dist/components/badge/badge.d.ts +10 -0
- package/dist/components/badge/badge.js +28 -0
- package/dist/components/badge/badge.styles.d.ts +62 -0
- package/dist/components/badge/badge.styles.js +72 -0
- package/dist/components/badge/index.d.ts +3 -0
- package/dist/components/banner/banner.d.ts +17 -0
- package/dist/components/banner/banner.js +71 -0
- package/dist/components/banner/banner.styles.d.ts +98 -0
- package/dist/components/banner/banner.styles.js +27 -0
- package/dist/components/banner/index.d.ts +3 -0
- package/dist/components/blockquote/blockquote.d.ts +72 -0
- package/dist/components/blockquote/blockquote.js +47 -0
- package/dist/components/blockquote/index.d.ts +2 -0
- package/dist/components/breadcrumb/breadcrumb.d.ts +28 -0
- package/dist/components/breadcrumb/breadcrumb.js +85 -0
- package/dist/components/breadcrumb/breadcrumb.styles.d.ts +63 -0
- package/dist/components/breadcrumb/breadcrumb.styles.js +18 -0
- package/dist/components/breadcrumb/index.d.ts +3 -0
- package/dist/components/button/button.d.ts +20 -0
- package/dist/components/button/button.js +52 -0
- package/dist/components/button/button.styles.d.ts +146 -0
- package/dist/components/button/button.styles.js +64 -0
- package/dist/components/button/index.d.ts +3 -0
- package/dist/components/calendar/calendar.d.ts +9 -0
- package/dist/components/calendar/calendar.js +75 -0
- package/dist/components/calendar/calendar.styles.d.ts +171 -0
- package/dist/components/calendar/calendar.styles.js +42 -0
- package/dist/components/calendar/index.d.ts +4 -0
- package/dist/components/card/card.d.ts +17 -0
- package/dist/components/card/card.js +79 -0
- package/dist/components/card/card.styles.d.ts +113 -0
- package/dist/components/card/card.styles.js +38 -0
- package/dist/components/card/index.d.ts +3 -0
- package/dist/components/carousel/carousel.d.ts +37 -0
- package/dist/components/carousel/carousel.js +190 -0
- package/dist/components/carousel/carousel.styles.d.ts +74 -0
- package/dist/components/carousel/carousel.styles.js +35 -0
- package/dist/components/carousel/index.d.ts +3 -0
- package/dist/components/checkbox/checkbox.d.ts +37 -0
- package/dist/components/checkbox/checkbox.js +44 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/code/code.d.ts +18 -0
- package/dist/components/code/code.js +75 -0
- package/dist/components/code/code.styles.d.ts +76 -0
- package/dist/components/code/code.styles.js +18 -0
- package/dist/components/code/index.d.ts +3 -0
- package/dist/components/collapsible/collapsible.d.ts +56 -0
- package/dist/components/collapsible/collapsible.js +43 -0
- package/dist/components/collapsible/index.d.ts +2 -0
- package/dist/components/combobox/combobox.d.ts +50 -0
- package/dist/components/combobox/combobox.js +141 -0
- package/dist/components/combobox/combobox.styles.d.ts +110 -0
- package/dist/components/combobox/combobox.styles.js +42 -0
- package/dist/components/combobox/index.d.ts +3 -0
- package/dist/components/command-menu/command-menu.d.ts +40 -0
- package/dist/components/command-menu/command-menu.js +148 -0
- package/dist/components/command-menu/command-menu.styles.d.ts +105 -0
- package/dist/components/command-menu/command-menu.styles.js +30 -0
- package/dist/components/command-menu/index.d.ts +3 -0
- package/dist/components/container/container.d.ts +34 -0
- package/dist/components/container/container.js +30 -0
- package/dist/components/container/index.d.ts +2 -0
- package/dist/components/context-menu/context-menu.d.ts +34 -0
- package/dist/components/context-menu/context-menu.js +157 -0
- package/dist/components/context-menu/context-menu.styles.d.ts +135 -0
- package/dist/components/context-menu/context-menu.styles.js +14 -0
- package/dist/components/context-menu/index.d.ts +3 -0
- package/dist/components/copy-button/copy-button.d.ts +61 -0
- package/dist/components/copy-button/copy-button.js +79 -0
- package/dist/components/copy-button/index.d.ts +2 -0
- package/dist/components/date-picker/date-picker.d.ts +51 -0
- package/dist/components/date-picker/date-picker.js +235 -0
- package/dist/components/date-picker/date-picker.styles.d.ts +77 -0
- package/dist/components/date-picker/date-picker.styles.js +31 -0
- package/dist/components/date-picker/index.d.ts +3 -0
- package/dist/components/description-list/description-list.d.ts +15 -0
- package/dist/components/description-list/description-list.js +51 -0
- package/dist/components/description-list/description-list.styles.d.ts +74 -0
- package/dist/components/description-list/description-list.styles.js +35 -0
- package/dist/components/description-list/index.d.ts +3 -0
- package/dist/components/dialog/close-icon.js +22 -0
- package/dist/components/dialog/dialog.d.ts +21 -0
- package/dist/components/dialog/dialog.js +79 -0
- package/dist/components/dialog/dialog.styles.d.ts +83 -0
- package/dist/components/dialog/dialog.styles.js +34 -0
- package/dist/components/dialog/index.d.ts +3 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +34 -0
- package/dist/components/dropdown-menu/dropdown-menu.js +160 -0
- package/dist/components/dropdown-menu/dropdown-menu.styles.d.ts +83 -0
- package/dist/components/dropdown-menu/dropdown-menu.styles.js +38 -0
- package/dist/components/dropdown-menu/index.d.ts +3 -0
- package/dist/components/eyebrow/eyebrow.d.ts +9 -0
- package/dist/components/eyebrow/eyebrow.js +20 -0
- package/dist/components/eyebrow/eyebrow.styles.d.ts +38 -0
- package/dist/components/eyebrow/eyebrow.styles.js +13 -0
- package/dist/components/eyebrow/index.d.ts +3 -0
- package/dist/components/field/field-context.d.ts +25 -0
- package/dist/components/field/field-context.js +27 -0
- package/dist/components/field/field.d.ts +28 -0
- package/dist/{field-CWZ_FdkD.js → components/field/field.js} +20 -34
- package/dist/components/field/field.styles.d.ts +53 -0
- package/dist/components/field/field.styles.js +22 -0
- package/dist/components/field/index.d.ts +4 -0
- package/dist/components/file-upload/file-upload.d.ts +52 -0
- package/dist/components/file-upload/file-upload.js +266 -0
- package/dist/components/file-upload/file-upload.styles.d.ts +123 -0
- package/dist/components/file-upload/file-upload.styles.js +32 -0
- package/dist/components/file-upload/index.d.ts +3 -0
- package/dist/components/grid/grid.d.ts +168 -0
- package/dist/components/grid/grid.js +126 -0
- package/dist/components/grid/index.d.ts +2 -0
- package/dist/components/heading/heading.d.ts +12 -0
- package/dist/components/heading/heading.js +28 -0
- package/dist/components/heading/heading.styles.d.ts +65 -0
- package/dist/components/heading/heading.styles.js +15 -0
- package/dist/components/heading/index.d.ts +3 -0
- package/dist/components/hover-card/hover-card.d.ts +43 -0
- package/dist/components/hover-card/hover-card.js +27 -0
- package/dist/components/hover-card/index.d.ts +2 -0
- package/dist/components/input/index.d.ts +3 -0
- package/dist/components/input/input.d.ts +13 -0
- package/dist/components/input/input.js +33 -0
- package/dist/components/input/input.styles.d.ts +55 -0
- package/dist/components/input/input.styles.js +33 -0
- package/dist/components/input-otp/index.d.ts +4 -0
- package/dist/components/input-otp/index.js +5 -0
- package/dist/components/input-otp/input-otp.d.ts +23 -0
- package/dist/components/input-otp/input-otp.js +86 -0
- package/dist/components/input-otp/input-otp.styles.d.ts +71 -0
- package/dist/components/input-otp/input-otp.styles.js +30 -0
- package/dist/components/kbd/index.d.ts +2 -0
- package/dist/components/kbd/kbd.d.ts +30 -0
- package/dist/components/kbd/kbd.js +17 -0
- package/dist/components/label/index.d.ts +2 -0
- package/dist/components/label/label.d.ts +31 -0
- package/dist/components/label/label.js +17 -0
- package/dist/components/link/index.d.ts +3 -0
- package/dist/components/link/link.d.ts +14 -0
- package/dist/components/link/link.js +57 -0
- package/dist/components/link/link.styles.d.ts +89 -0
- package/dist/components/link/link.styles.js +33 -0
- package/dist/components/modal/index.d.ts +3 -0
- package/dist/components/modal/modal.d.ts +33 -0
- package/dist/components/modal/modal.js +56 -0
- package/dist/components/modal/modal.styles.d.ts +61 -0
- package/dist/components/modal/modal.styles.js +14 -0
- package/dist/components/navigation-menu/index.d.ts +3 -0
- package/dist/components/navigation-menu/navigation-menu.d.ts +37 -0
- package/dist/components/navigation-menu/navigation-menu.js +138 -0
- package/dist/components/navigation-menu/navigation-menu.styles.d.ts +111 -0
- package/dist/components/navigation-menu/navigation-menu.styles.js +39 -0
- package/dist/components/number-input/index.d.ts +3 -0
- package/dist/components/number-input/number-input.d.ts +30 -0
- package/dist/components/number-input/number-input.js +151 -0
- package/dist/components/number-input/number-input.styles.d.ts +68 -0
- package/dist/components/number-input/number-input.styles.js +35 -0
- package/dist/components/pagination/index.d.ts +4 -0
- package/dist/components/pagination/pagination-range.d.ts +11 -0
- package/dist/components/pagination/pagination-range.js +42 -0
- package/dist/components/pagination/pagination.d.ts +18 -0
- package/dist/components/pagination/pagination.js +94 -0
- package/dist/components/pagination/pagination.styles.d.ts +65 -0
- package/dist/components/pagination/pagination.styles.js +35 -0
- package/dist/components/password-input/index.d.ts +3 -0
- package/dist/components/password-input/password-input.d.ts +20 -0
- package/dist/components/password-input/password-input.js +106 -0
- package/dist/components/password-input/password-input.styles.d.ts +66 -0
- package/dist/components/password-input/password-input.styles.js +21 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/popover.d.ts +52 -0
- package/dist/components/popover/popover.js +35 -0
- package/dist/components/progress/index.d.ts +3 -0
- package/dist/components/progress/progress.d.ts +29 -0
- package/dist/components/progress/progress.js +108 -0
- package/dist/components/progress/progress.styles.d.ts +236 -0
- package/dist/components/progress/progress.styles.js +69 -0
- package/dist/components/prose/index.d.ts +2 -0
- package/dist/components/prose/prose.d.ts +90 -0
- package/dist/components/prose/prose.js +67 -0
- package/dist/components/radio-group/index.d.ts +3 -0
- package/dist/components/radio-group/radio-group.d.ts +26 -0
- package/dist/components/radio-group/radio-group.js +102 -0
- package/dist/components/radio-group/radio-group.styles.d.ts +80 -0
- package/dist/components/radio-group/radio-group.styles.js +56 -0
- package/dist/components/resizable/index.d.ts +3 -0
- package/dist/components/resizable/resizable.d.ts +17 -0
- package/dist/components/resizable/resizable.js +81 -0
- package/dist/components/resizable/resizable.styles.d.ts +53 -0
- package/dist/components/resizable/resizable.styles.js +19 -0
- package/dist/components/scroll-area/index.d.ts +2 -0
- package/dist/components/scroll-area/scroll-area.d.ts +70 -0
- package/dist/components/scroll-area/scroll-area.js +70 -0
- package/dist/components/section/index.d.ts +2 -0
- package/dist/components/section/section.d.ts +52 -0
- package/dist/components/section/section.js +41 -0
- package/dist/components/segmented-control/index.d.ts +2 -0
- package/dist/components/segmented-control/segmented-control.d.ts +92 -0
- package/dist/components/segmented-control/segmented-control.js +86 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/select.d.ts +85 -0
- package/dist/components/select/select.js +81 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/separator/separator.d.ts +40 -0
- package/dist/components/separator/separator.js +27 -0
- package/dist/components/sheet/index.d.ts +3 -0
- package/dist/components/sheet/sheet.d.ts +20 -0
- package/dist/components/sheet/sheet.js +83 -0
- package/dist/components/sheet/sheet.styles.d.ts +101 -0
- package/dist/components/sheet/sheet.styles.js +62 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/skeleton.d.ts +30 -0
- package/dist/components/skeleton/skeleton.js +18 -0
- package/dist/components/slider/index.d.ts +3 -0
- package/dist/components/slider/slider.d.ts +38 -0
- package/dist/components/slider/slider.js +68 -0
- package/dist/components/slider/slider.styles.d.ts +56 -0
- package/dist/components/slider/slider.styles.js +23 -0
- package/dist/components/spinner/index.d.ts +3 -0
- package/dist/components/spinner/spinner.d.ts +9 -0
- package/dist/components/spinner/spinner.js +36 -0
- package/dist/components/spinner/spinner.styles.d.ts +53 -0
- package/dist/components/spinner/spinner.styles.js +18 -0
- package/dist/components/stack/index.d.ts +2 -0
- package/dist/components/stack/stack.d.ts +109 -0
- package/dist/components/stack/stack.js +62 -0
- package/dist/components/stat-card/index.d.ts +3 -0
- package/dist/components/stat-card/stat-card.d.ts +22 -0
- package/dist/components/stat-card/stat-card.js +82 -0
- package/dist/components/stat-card/stat-card.styles.d.ts +83 -0
- package/dist/components/stat-card/stat-card.styles.js +16 -0
- package/dist/components/stepper/index.d.ts +3 -0
- package/dist/components/stepper/stepper.d.ts +20 -0
- package/dist/components/stepper/stepper.js +100 -0
- package/dist/components/stepper/stepper.styles.d.ts +170 -0
- package/dist/components/stepper/stepper.styles.js +67 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/switch.d.ts +51 -0
- package/dist/components/switch/switch.js +43 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/table.d.ts +78 -0
- package/dist/components/table/table.js +82 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/tabs.d.ts +73 -0
- package/dist/components/tabs/tabs.js +103 -0
- package/dist/components/tag-input/index.d.ts +3 -0
- package/dist/components/tag-input/tag-input.d.ts +30 -0
- package/dist/components/tag-input/tag-input.js +149 -0
- package/dist/components/tag-input/tag-input.styles.d.ts +71 -0
- package/dist/components/tag-input/tag-input.styles.js +29 -0
- package/dist/components/text/index.d.ts +3 -0
- package/dist/components/text/text.d.ts +9 -0
- package/dist/components/text/text.js +25 -0
- package/dist/components/text/text.styles.d.ts +188 -0
- package/dist/components/text/text.styles.js +36 -0
- package/dist/components/textarea/index.d.ts +2 -0
- package/dist/components/textarea/textarea.d.ts +29 -0
- package/dist/components/textarea/textarea.js +23 -0
- package/dist/components/timeline/index.d.ts +3 -0
- package/dist/components/timeline/timeline.d.ts +28 -0
- package/dist/components/timeline/timeline.js +61 -0
- package/dist/components/timeline/timeline.styles.d.ts +110 -0
- package/dist/components/timeline/timeline.styles.js +30 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/toast.d.ts +119 -0
- package/dist/components/toast/toast.js +75 -0
- package/dist/components/toggle/index.d.ts +3 -0
- package/dist/components/toggle/toggle.d.ts +20 -0
- package/dist/components/toggle/toggle.js +58 -0
- package/dist/components/toggle/toggle.styles.d.ts +80 -0
- package/dist/components/toggle/toggle.styles.js +34 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/tooltip.d.ts +39 -0
- package/dist/components/tooltip/tooltip.js +29 -0
- package/dist/components/tree-view/index.d.ts +3 -0
- package/dist/components/tree-view/tree-view.d.ts +31 -0
- package/dist/components/tree-view/tree-view.js +192 -0
- package/dist/components/tree-view/tree-view.styles.d.ts +59 -0
- package/dist/components/tree-view/tree-view.styles.js +32 -0
- package/dist/components/visually-hidden/index.d.ts +2 -0
- package/dist/components/visually-hidden/visually-hidden.d.ts +10 -0
- package/dist/components/visually-hidden/visually-hidden.js +16 -0
- package/dist/data-table.d.ts +3 -110
- package/dist/data-table.js +2 -224
- package/dist/form.d.ts +2 -79
- package/dist/form.js +1 -83
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/use-component-config.d.ts +13 -0
- package/dist/hooks/use-component-config.js +22 -0
- package/dist/hooks/use-controllable-state.d.ts +9 -0
- package/dist/hooks/use-controllable-state.js +18 -0
- package/dist/hooks/use-media-query.d.ts +4 -0
- package/dist/hooks/use-media-query.js +13 -0
- package/dist/hooks/use-scrolled.d.ts +4 -0
- package/dist/hooks/use-scrolled.js +17 -0
- package/dist/index.d.ts +223 -6849
- package/dist/index.js +148 -6718
- package/dist/internal/dev.js +12 -0
- package/dist/internal/icons.js +91 -0
- package/dist/motion/active-indicator.d.ts +12 -0
- package/dist/motion/active-indicator.js +26 -0
- package/dist/motion/animated-number.d.ts +21 -0
- package/dist/motion/animated-number.js +88 -0
- package/dist/motion/features.js +10 -0
- package/dist/motion/index.d.ts +10 -0
- package/dist/motion/index.js +10 -0
- package/dist/motion/motion-root.js +48 -0
- package/dist/motion/page-transition.d.ts +16 -0
- package/dist/motion/page-transition.js +23 -0
- package/dist/motion/presence-list.js +46 -0
- package/dist/motion/presence.d.ts +11 -0
- package/dist/motion/presence.js +17 -0
- package/dist/motion/reveal.d.ts +18 -0
- package/dist/motion/reveal.js +37 -0
- package/dist/motion/stagger.d.ts +29 -0
- package/dist/motion/stagger.js +52 -0
- package/dist/motion/use-motion-settings.d.ts +25 -0
- package/dist/motion/use-motion-settings.js +47 -0
- package/dist/motion/use-reveal.d.ts +11 -0
- package/dist/motion/use-reveal.js +41 -0
- package/dist/patterns/app-shell/app-shell-context.d.ts +14 -0
- package/dist/patterns/app-shell/app-shell-context.js +16 -0
- package/dist/patterns/app-shell/app-shell.d.ts +21 -0
- package/dist/patterns/app-shell/app-shell.js +82 -0
- package/dist/patterns/app-shell/app-shell.styles.d.ts +302 -0
- package/dist/patterns/app-shell/app-shell.styles.js +106 -0
- package/dist/patterns/app-shell/index.d.ts +7 -0
- package/dist/patterns/app-shell/navbar.d.ts +29 -0
- package/dist/patterns/app-shell/navbar.js +116 -0
- package/dist/patterns/app-shell/page-header.d.ts +12 -0
- package/dist/patterns/app-shell/page-header.js +38 -0
- package/dist/patterns/app-shell/sidebar.d.ts +31 -0
- package/dist/patterns/app-shell/sidebar.js +141 -0
- package/dist/patterns/async/async.d.ts +40 -0
- package/dist/patterns/async/async.js +61 -0
- package/dist/patterns/async/index.d.ts +3 -0
- package/dist/patterns/async/states.d.ts +68 -0
- package/dist/patterns/async/states.js +116 -0
- package/dist/patterns/chart/cartesian.d.ts +128 -0
- package/dist/patterns/chart/cartesian.js +552 -0
- package/dist/patterns/chart/chart-card.d.ts +39 -0
- package/dist/patterns/chart/chart-card.js +103 -0
- package/dist/patterns/chart/chart-parts.d.ts +53 -0
- package/dist/patterns/chart/chart-parts.js +282 -0
- package/dist/patterns/chart/chart.styles.d.ts +200 -0
- package/dist/patterns/chart/chart.styles.js +43 -0
- package/dist/patterns/chart/export.d.ts +45 -0
- package/dist/patterns/chart/export.js +293 -0
- package/dist/patterns/chart/funnel.d.ts +23 -0
- package/dist/patterns/chart/funnel.js +129 -0
- package/dist/patterns/chart/heatmap.d.ts +37 -0
- package/dist/patterns/chart/heatmap.js +258 -0
- package/dist/patterns/chart/icons.js +39 -0
- package/dist/patterns/chart/pie.d.ts +36 -0
- package/dist/patterns/chart/pie.js +120 -0
- package/dist/patterns/chart/radial.d.ts +75 -0
- package/dist/patterns/chart/radial.js +282 -0
- package/dist/patterns/chart/sankey.d.ts +29 -0
- package/dist/patterns/chart/sankey.js +136 -0
- package/dist/patterns/chart/scatter.d.ts +42 -0
- package/dist/patterns/chart/scatter.js +203 -0
- package/dist/patterns/chart/sparkline.d.ts +20 -0
- package/dist/patterns/chart/sparkline.js +102 -0
- package/dist/patterns/chart/treemap.d.ts +25 -0
- package/dist/patterns/chart/treemap.js +128 -0
- package/dist/patterns/chart/use-element-width.js +23 -0
- package/dist/patterns/data-table/data-table.d.ts +109 -0
- package/dist/patterns/data-table/data-table.js +233 -0
- package/dist/patterns/form/form.d.ts +89 -0
- package/dist/patterns/form/form.js +111 -0
- package/dist/provider/color-mode-script.d.ts +15 -0
- package/dist/provider/color-mode-script.js +13 -0
- package/dist/provider/color-mode.d.ts +24 -0
- package/dist/provider/color-mode.js +87 -0
- package/dist/provider/glyph-context.d.ts +51 -0
- package/dist/provider/glyph-context.js +28 -0
- package/dist/provider/glyph-provider.d.ts +37 -0
- package/dist/provider/glyph-provider.js +48 -0
- package/dist/provider/index.d.ts +6 -0
- package/dist/provider/theme-scope.d.ts +12 -0
- package/dist/provider/theme-scope.js +42 -0
- package/dist/provider/theme-style.js +15 -0
- package/dist/react-router.d.ts +18 -0
- package/dist/react-router.js +44 -0
- package/dist/register.d.ts +57 -0
- package/dist/themes.d.ts +22 -0
- package/dist/themes.js +49 -0
- package/dist/utils/cn.d.ts +6 -0
- package/dist/utils/cn.js +12 -0
- package/dist/utils/compose-refs.js +11 -0
- package/dist/{registry-BGSJoiLq.d.ts → utils/registry.d.ts} +2 -3
- package/dist/utils/styles.js +20 -0
- package/dist/{tv-DuMh7UH2.d.ts → utils/tv.d.ts} +2 -2
- package/dist/utils/tv.js +8 -0
- package/dist/utils/tw-merge-config.js +13 -0
- package/dist/vite.d.ts +27 -0
- package/dist/vite.js +29 -0
- package/fonts.css +10 -0
- package/package.json +33 -5
- package/src/components/accordion/accordion.styles.ts +1 -1
- package/src/components/alert/alert.styles.ts +1 -1
- package/src/components/alert-dialog/alert-dialog.styles.ts +5 -4
- package/src/components/alert-dialog/confirm-dialog.tsx +42 -0
- package/src/components/alert-dialog/confirm.tsx +12 -31
- package/src/components/aspect-ratio/aspect-ratio.tsx +1 -1
- package/src/components/avatar/avatar.styles.ts +1 -1
- package/src/components/badge/badge.styles.ts +12 -17
- package/src/components/banner/banner.styles.ts +5 -5
- package/src/components/blockquote/blockquote.tsx +1 -1
- package/src/components/breadcrumb/breadcrumb.styles.ts +1 -1
- package/src/components/button/button.styles.ts +6 -2
- package/src/components/calendar/calendar.styles.ts +4 -3
- package/src/components/card/card.styles.ts +1 -1
- package/src/components/carousel/carousel.styles.ts +1 -1
- package/src/components/checkbox/checkbox.tsx +20 -5
- package/src/components/code/code.styles.ts +2 -2
- package/src/components/collapsible/collapsible.tsx +1 -1
- package/src/components/combobox/combobox.styles.ts +5 -2
- package/src/components/command-menu/command-menu.styles.ts +6 -4
- package/src/components/container/container.tsx +1 -1
- package/src/components/context-menu/context-menu.styles.ts +4 -2
- package/src/components/copy-button/copy-button.tsx +1 -1
- package/src/components/date-picker/date-picker.styles.ts +2 -2
- package/src/components/description-list/description-list.styles.ts +1 -1
- package/src/components/dialog/dialog.styles.ts +11 -4
- package/src/components/dropdown-menu/dropdown-menu.styles.ts +5 -5
- package/src/components/eyebrow/eyebrow.styles.ts +2 -2
- package/src/components/field/field-context.ts +2 -0
- package/src/components/field/field.styles.ts +5 -3
- package/src/components/field/field.tsx +25 -4
- package/src/components/file-upload/file-upload.styles.ts +4 -4
- package/src/components/file-upload/file-upload.tsx +51 -48
- package/src/components/grid/grid.tsx +1 -1
- package/src/components/heading/heading.styles.ts +1 -1
- package/src/components/hover-card/hover-card.tsx +5 -2
- package/src/components/input/input.styles.ts +1 -1
- package/src/components/input-otp/input-otp.styles.ts +1 -1
- package/src/components/kbd/kbd.tsx +1 -1
- package/src/components/label/label.tsx +1 -1
- package/src/components/link/link.styles.ts +2 -2
- package/src/components/modal/modal.styles.ts +3 -1
- package/src/components/modal/modal.tsx +30 -5
- package/src/components/navigation-menu/navigation-menu.styles.ts +2 -2
- package/src/components/navigation-menu/navigation-menu.tsx +14 -4
- package/src/components/number-input/number-input.styles.ts +1 -1
- package/src/components/pagination/pagination.styles.ts +6 -4
- package/src/components/pagination/pagination.tsx +14 -1
- package/src/components/password-input/password-input.styles.ts +4 -4
- package/src/components/popover/popover.tsx +1 -1
- package/src/components/progress/progress.styles.ts +2 -2
- package/src/components/prose/prose.tsx +2 -2
- package/src/components/radio-group/radio-group.styles.ts +1 -1
- package/src/components/resizable/resizable.styles.ts +1 -1
- package/src/components/scroll-area/scroll-area.tsx +24 -2
- package/src/components/section/section.tsx +1 -1
- package/src/components/segmented-control/segmented-control.tsx +40 -9
- package/src/components/select/select.tsx +2 -2
- package/src/components/separator/separator.tsx +1 -1
- package/src/components/sheet/sheet.styles.ts +1 -1
- package/src/components/skeleton/skeleton.tsx +1 -1
- package/src/components/slider/slider.styles.ts +1 -1
- package/src/components/slider/slider.tsx +9 -2
- package/src/components/spinner/spinner.styles.ts +1 -1
- package/src/components/stack/stack.tsx +1 -1
- package/src/components/stat-card/stat-card.styles.ts +1 -1
- package/src/components/stepper/stepper.styles.ts +3 -3
- package/src/components/switch/switch.tsx +2 -2
- package/src/components/table/table.tsx +1 -1
- package/src/components/tabs/tabs.tsx +46 -15
- package/src/components/tag-input/tag-input.styles.ts +2 -2
- package/src/components/tag-input/tag-input.tsx +27 -18
- package/src/components/text/text.styles.ts +5 -5
- package/src/components/textarea/textarea.tsx +1 -1
- package/src/components/timeline/timeline.styles.ts +1 -1
- package/src/components/toast/toast.tsx +1 -1
- package/src/components/toggle/toggle.styles.ts +1 -1
- package/src/components/tooltip/tooltip.tsx +6 -3
- package/src/components/tree-view/tree-view.styles.ts +1 -1
- package/src/index.ts +3 -0
- package/src/integrations/react-router.tsx +39 -0
- package/src/integrations/vite.test-d.ts +6 -0
- package/src/integrations/vite.test.ts +28 -0
- package/src/integrations/vite.ts +33 -0
- package/src/internal/dev.ts +12 -0
- package/src/motion/active-indicator.tsx +26 -0
- package/src/motion/animated-number.tsx +113 -0
- package/src/motion/features.ts +7 -0
- package/src/motion/index.ts +9 -0
- package/src/motion/motion-root.tsx +46 -0
- package/src/motion/page-transition.tsx +30 -0
- package/src/motion/presence-list.tsx +42 -0
- package/src/motion/presence.tsx +13 -0
- package/src/motion/reveal.tsx +50 -0
- package/src/motion/stagger.tsx +81 -0
- package/src/motion/use-motion-settings.ts +52 -0
- package/src/motion/use-reveal.ts +54 -0
- package/src/patterns/app-shell/app-shell.styles.ts +19 -12
- package/src/patterns/app-shell/navbar.tsx +34 -16
- package/src/patterns/app-shell/sidebar.tsx +35 -9
- package/src/patterns/async/states.tsx +1 -1
- package/src/patterns/chart/cartesian.tsx +755 -0
- package/src/patterns/chart/chart-card.tsx +148 -0
- package/src/patterns/chart/chart-parts.tsx +330 -57
- package/src/patterns/chart/chart.styles.ts +29 -3
- package/src/patterns/chart/export.ts +334 -0
- package/src/patterns/chart/funnel.tsx +171 -0
- package/src/patterns/chart/heatmap.tsx +339 -0
- package/src/patterns/chart/icons.tsx +44 -0
- package/src/patterns/chart/index.ts +52 -7
- package/src/patterns/chart/pie.tsx +169 -0
- package/src/patterns/chart/radial.tsx +361 -0
- package/src/patterns/chart/sankey.tsx +197 -0
- package/src/patterns/chart/scatter.tsx +254 -0
- package/src/patterns/chart/sparkline.tsx +111 -0
- package/src/patterns/chart/test-utils.tsx +35 -0
- package/src/patterns/chart/treemap.tsx +198 -0
- package/src/patterns/chart/use-element-width.ts +20 -0
- package/src/patterns/data-table/data-table.tsx +1 -1
- package/src/patterns/form/form.tsx +49 -7
- package/src/patterns/form/index.ts +1 -0
- package/src/provider/color-mode-script.ts +28 -0
- package/src/provider/color-mode.tsx +14 -20
- package/src/provider/glyph-context.ts +41 -1
- package/src/provider/glyph-provider.tsx +45 -14
- package/src/provider/index.ts +4 -0
- package/src/provider/theme-scope.tsx +20 -11
- package/src/themes.ts +3 -3
- package/src/utils/styles.ts +17 -3
- package/styles.css +194 -3
- package/dist/field-context-anGPYXbW.js +0 -267
- package/dist/index-BWK4czIG.d.ts +0 -233
- package/dist/states-DR-OoDT-.js +0 -288
- package/dist/tv-DBAGlgXJ.js +0 -58
- package/src/patterns/chart/chart.tsx +0 -369
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ChartColorValue, ChartStateProps, Key } from "./chart-parts.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/patterns/chart/cartesian.d.ts
|
|
4
|
+
export interface ChartSeries<T> {
|
|
5
|
+
/** Field of each data row holding this series' value. */
|
|
6
|
+
key: Key<T>;
|
|
7
|
+
/** Name shown in the legend, tooltip and accessible table. Defaults to `key`. */
|
|
8
|
+
label?: string;
|
|
9
|
+
/** A theme color name (`chart-2`, `primary`, ...) or any CSS color. Defaults follow the theme palette. */
|
|
10
|
+
color?: ChartColorValue;
|
|
11
|
+
}
|
|
12
|
+
type AxisBound = number | 'auto' | 'dataMin' | 'dataMax';
|
|
13
|
+
export interface ChartAxisOptions {
|
|
14
|
+
hide?: boolean;
|
|
15
|
+
/** Formats tick labels. The y axis defaults to `valueFormatter`. */
|
|
16
|
+
formatter?: (value: never) => string;
|
|
17
|
+
/** Axis title. */
|
|
18
|
+
label?: string;
|
|
19
|
+
/** Y axis only: width reserved for tick labels, in pixels. Default 48. */
|
|
20
|
+
width?: number;
|
|
21
|
+
/** Y axis only: fixed range, e.g. `[0, 100]` or `[0, 'auto']`. */
|
|
22
|
+
domain?: readonly [AxisBound, AxisBound];
|
|
23
|
+
allowDecimals?: boolean;
|
|
24
|
+
tickCount?: number;
|
|
25
|
+
}
|
|
26
|
+
export interface ChartReferenceLine {
|
|
27
|
+
/** Horizontal line at this value. */
|
|
28
|
+
y?: number;
|
|
29
|
+
/** Vertical line at this category (x value). */
|
|
30
|
+
x?: string | number;
|
|
31
|
+
label?: string;
|
|
32
|
+
color?: ChartColorValue;
|
|
33
|
+
/** Default true. */
|
|
34
|
+
dashed?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export interface ChartReferenceArea {
|
|
37
|
+
x1?: string | number;
|
|
38
|
+
x2?: string | number;
|
|
39
|
+
y1?: number;
|
|
40
|
+
y2?: number;
|
|
41
|
+
label?: string;
|
|
42
|
+
color?: ChartColorValue;
|
|
43
|
+
}
|
|
44
|
+
export interface ChartBrushOptions {
|
|
45
|
+
/** First and last visible row when the chart mounts. */
|
|
46
|
+
startIndex?: number;
|
|
47
|
+
endIndex?: number;
|
|
48
|
+
/** Height of the brush in pixels. Default 28. */
|
|
49
|
+
height?: number;
|
|
50
|
+
}
|
|
51
|
+
export interface CartesianChartProps<T extends object> extends ChartStateProps {
|
|
52
|
+
data: readonly T[];
|
|
53
|
+
/** Field used for the x axis, e.g. `"month"`. */
|
|
54
|
+
index: Key<T>;
|
|
55
|
+
series: readonly ChartSeries<T>[];
|
|
56
|
+
/** Accessible name; also shown as the caption unless `hideTitle` is set. */
|
|
57
|
+
title: string;
|
|
58
|
+
description?: ReactNode;
|
|
59
|
+
hideTitle?: boolean;
|
|
60
|
+
/** Formats values on the y axis, in tooltips and in the accessible table. */
|
|
61
|
+
valueFormatter?: (value: number) => string;
|
|
62
|
+
/** Formats the x value at the top of the tooltip. */
|
|
63
|
+
labelFormatter?: (label: ReactNode) => ReactNode;
|
|
64
|
+
/** Plot height in pixels. Default 240. */
|
|
65
|
+
height?: number;
|
|
66
|
+
showGrid?: boolean;
|
|
67
|
+
/** Defaults to true when there is more than one series. */
|
|
68
|
+
showLegend?: boolean;
|
|
69
|
+
/** Shorthand for `yAxis={{ hide: !showYAxis }}`. */
|
|
70
|
+
showYAxis?: boolean;
|
|
71
|
+
xAxis?: ChartAxisOptions;
|
|
72
|
+
yAxis?: ChartAxisOptions;
|
|
73
|
+
/** Adds a range slider under the plot to zoom into part of the data. */
|
|
74
|
+
brush?: boolean | ChartBrushOptions;
|
|
75
|
+
/** Targets, limits, averages... drawn across the plot. */
|
|
76
|
+
referenceLines?: readonly ChartReferenceLine[];
|
|
77
|
+
/** Shaded ranges, e.g. a launch window or an incident. */
|
|
78
|
+
referenceAreas?: readonly ChartReferenceArea[];
|
|
79
|
+
/** Series hidden through the legend (controlled). */
|
|
80
|
+
hiddenSeries?: readonly Key<T>[];
|
|
81
|
+
defaultHiddenSeries?: readonly Key<T>[];
|
|
82
|
+
onHiddenSeriesChange?: (hidden: Key<T>[]) => void;
|
|
83
|
+
/** Charts with the same `syncId` share their tooltip and brush position. */
|
|
84
|
+
syncId?: string;
|
|
85
|
+
/** Called with the row (and series, when known) the user clicked. */
|
|
86
|
+
onPointClick?: (row: T, seriesKey?: Key<T>) => void;
|
|
87
|
+
className?: string;
|
|
88
|
+
}
|
|
89
|
+
/** Trends over time, one line per series. */
|
|
90
|
+
export declare function LineChart<T extends object>(props: CartesianChartProps<T> & {
|
|
91
|
+
curve?: 'monotone' | 'linear' | 'step';
|
|
92
|
+
/** Show a dot on every data point. Default false. */
|
|
93
|
+
dots?: boolean;
|
|
94
|
+
}): import("react").JSX.Element;
|
|
95
|
+
/** Trends with filled areas. `stacked` shows how series add up to a total. */
|
|
96
|
+
export declare function AreaChart<T extends object>(props: CartesianChartProps<T> & {
|
|
97
|
+
stacked?: boolean;
|
|
98
|
+
/** Stack to 100% to compare shares over time. */
|
|
99
|
+
expand?: boolean;
|
|
100
|
+
curve?: 'monotone' | 'linear' | 'step';
|
|
101
|
+
}): import("react").JSX.Element;
|
|
102
|
+
/** Compare values across categories. `stacked` puts series on top of each other. */
|
|
103
|
+
export declare function BarChart<T extends object>(props: CartesianChartProps<T> & {
|
|
104
|
+
stacked?: boolean;
|
|
105
|
+
/** Bars run left to right, categories down the side. Good for long labels. */
|
|
106
|
+
layout?: 'vertical' | 'horizontal';
|
|
107
|
+
/** Corner radius of bar ends. Default 4. */
|
|
108
|
+
barRadius?: number;
|
|
109
|
+
}): import("react").JSX.Element;
|
|
110
|
+
export interface ComposedSeries<T> extends ChartSeries<T> {
|
|
111
|
+
/** How this series is drawn. Default `bar`. */
|
|
112
|
+
type?: 'bar' | 'line' | 'area';
|
|
113
|
+
/**
|
|
114
|
+
* Which y axis this series uses. Use the right axis sparingly: two scales on one plot
|
|
115
|
+
* are easy to misread. Prefer two charts with a shared `syncId` when you can.
|
|
116
|
+
*/
|
|
117
|
+
axis?: 'left' | 'right';
|
|
118
|
+
}
|
|
119
|
+
export interface ComposedChartProps<T extends object> extends Omit<CartesianChartProps<T>, 'series'> {
|
|
120
|
+
series: readonly ComposedSeries<T>[];
|
|
121
|
+
/** Options for the right y axis, used by series with `axis: "right"`. */
|
|
122
|
+
rightAxis?: ChartAxisOptions;
|
|
123
|
+
/** Stack the bar series. */
|
|
124
|
+
stacked?: boolean;
|
|
125
|
+
}
|
|
126
|
+
/** Bars, lines and areas on one plot, e.g. revenue bars with a target line. */
|
|
127
|
+
export declare function ComposedChart<T extends object>(props: ComposedChartProps<T>): import("react").JSX.Element;
|
|
128
|
+
//#endregion
|
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useControllableState } from "../../hooks/use-controllable-state.js";
|
|
3
|
+
import { ChartFrame, ChartTooltipCard, defaultFormatter, resolveColor, toggleIn, useChartAnimation } from "./chart-parts.js";
|
|
4
|
+
import { useId, useMemo } from "react";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
import * as R from "recharts";
|
|
7
|
+
//#region src/patterns/chart/cartesian.tsx
|
|
8
|
+
const axisTick = {
|
|
9
|
+
fill: "var(--glyph-muted-foreground)",
|
|
10
|
+
fontSize: 12
|
|
11
|
+
};
|
|
12
|
+
const margin = {
|
|
13
|
+
top: 8,
|
|
14
|
+
right: 8,
|
|
15
|
+
bottom: 0,
|
|
16
|
+
left: 0
|
|
17
|
+
};
|
|
18
|
+
/** Reference labels sit on top of data: a surface-colored halo keeps them readable. */
|
|
19
|
+
const halo = {
|
|
20
|
+
stroke: "var(--glyph-surface)",
|
|
21
|
+
strokeWidth: 3,
|
|
22
|
+
strokeLinejoin: "round",
|
|
23
|
+
paintOrder: "stroke"
|
|
24
|
+
};
|
|
25
|
+
/** Shared setup for every cartesian chart: colors, legend, table, hidden series. */
|
|
26
|
+
function useCartesian(props) {
|
|
27
|
+
const { data, index, series, valueFormatter = defaultFormatter } = props;
|
|
28
|
+
const [hidden, setHidden] = useControllableState({
|
|
29
|
+
value: props.hiddenSeries,
|
|
30
|
+
defaultValue: props.defaultHiddenSeries ?? [],
|
|
31
|
+
onChange: props.onHiddenSeriesChange
|
|
32
|
+
});
|
|
33
|
+
const resolved = useMemo(() => series.map((item, i) => ({
|
|
34
|
+
...item,
|
|
35
|
+
label: item.label ?? item.key,
|
|
36
|
+
stroke: resolveColor(item.color, i),
|
|
37
|
+
hidden: hidden.includes(item.key)
|
|
38
|
+
})), [series, hidden]);
|
|
39
|
+
return {
|
|
40
|
+
resolved,
|
|
41
|
+
table: {
|
|
42
|
+
columns: [String(index), ...resolved.map((item) => item.label)],
|
|
43
|
+
rows: data.map((row) => [String(row[index]), ...resolved.map((item) => valueFormatter(Number(row[item.key])))])
|
|
44
|
+
},
|
|
45
|
+
legend: props.showLegend ?? series.length > 1 ? resolved.map((item) => ({
|
|
46
|
+
key: item.key,
|
|
47
|
+
label: item.label,
|
|
48
|
+
color: item.stroke,
|
|
49
|
+
hidden: item.hidden
|
|
50
|
+
})) : void 0,
|
|
51
|
+
onLegendToggle: series.length > 1 ? (key) => setHidden(toggleIn(hidden, key, series.length)) : void 0,
|
|
52
|
+
valueFormatter
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function frameProps(props) {
|
|
56
|
+
return {
|
|
57
|
+
title: props.title,
|
|
58
|
+
description: props.description,
|
|
59
|
+
hideTitle: props.hideTitle,
|
|
60
|
+
className: props.className,
|
|
61
|
+
loading: props.loading,
|
|
62
|
+
error: props.error,
|
|
63
|
+
onRetry: props.onRetry,
|
|
64
|
+
empty: props.empty,
|
|
65
|
+
height: props.height ?? 240,
|
|
66
|
+
isEmpty: props.data.length === 0
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/** recharts props that every cartesian chart root shares. */
|
|
70
|
+
function rootProps(props) {
|
|
71
|
+
const { onPointClick, data, syncId } = props;
|
|
72
|
+
return {
|
|
73
|
+
accessibilityLayer: false,
|
|
74
|
+
data,
|
|
75
|
+
margin,
|
|
76
|
+
...syncId && { syncId },
|
|
77
|
+
...onPointClick && {
|
|
78
|
+
style: { cursor: "pointer" },
|
|
79
|
+
onClick: (state) => {
|
|
80
|
+
const i = Number(state?.activeTooltipIndex);
|
|
81
|
+
const row = Number.isInteger(i) ? data[i] : void 0;
|
|
82
|
+
if (!row) return;
|
|
83
|
+
const key = typeof state?.activeDataKey === "string" ? state.activeDataKey : void 0;
|
|
84
|
+
onPointClick(row, key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Width that fits the longest y tick label, estimated from the formatted data range, so
|
|
91
|
+
* labels like "340 ms" or "$1.2M" never wrap.
|
|
92
|
+
*/
|
|
93
|
+
function axisWidth(data, keys, formatter, extra = 0) {
|
|
94
|
+
let min = 0;
|
|
95
|
+
let max = 0;
|
|
96
|
+
let stacked = 0;
|
|
97
|
+
for (const row of data) {
|
|
98
|
+
let sum = 0;
|
|
99
|
+
for (const key of keys) {
|
|
100
|
+
const value = Number(row[key]);
|
|
101
|
+
if (!Number.isFinite(value)) continue;
|
|
102
|
+
min = Math.min(min, value);
|
|
103
|
+
max = Math.max(max, value);
|
|
104
|
+
sum += Math.max(value, 0);
|
|
105
|
+
}
|
|
106
|
+
stacked = Math.max(stacked, sum);
|
|
107
|
+
}
|
|
108
|
+
const candidates = [
|
|
109
|
+
min,
|
|
110
|
+
max * 1.2,
|
|
111
|
+
stacked * 1.2
|
|
112
|
+
].map((value) => {
|
|
113
|
+
const magnitude = 10 ** Math.max(Math.floor(Math.log10(Math.abs(value) || 1)) - 1, 0);
|
|
114
|
+
return formatter(Math.ceil(value / magnitude) * magnitude);
|
|
115
|
+
});
|
|
116
|
+
const widest = Math.max(...candidates.map((label) => textWidth(String(label))));
|
|
117
|
+
return Math.min(Math.max(Math.ceil(widest) + 16 + extra, 36), 128);
|
|
118
|
+
}
|
|
119
|
+
let measureContext;
|
|
120
|
+
/** Width of a 12px tick label in the page's font; an estimate where canvas is unavailable. */
|
|
121
|
+
function textWidth(text) {
|
|
122
|
+
if (measureContext === void 0) measureContext = typeof document !== "undefined" && typeof CanvasRenderingContext2D !== "undefined" ? document.createElement("canvas").getContext("2d") : null;
|
|
123
|
+
if (!measureContext) return text.length * 7;
|
|
124
|
+
measureContext.font = `12px ${getComputedStyle(document.body).fontFamily}`;
|
|
125
|
+
return measureContext.measureText(text).width;
|
|
126
|
+
}
|
|
127
|
+
/** Grid and axes. Rendered as an array so recharts sees its own components as direct children. */
|
|
128
|
+
function axes(props, valueFormatter, { rightAxis } = {}) {
|
|
129
|
+
const { xAxis = {}, yAxis = {} } = props;
|
|
130
|
+
const hideY = yAxis.hide ?? props.showYAxis === false;
|
|
131
|
+
const nodes = [];
|
|
132
|
+
if (props.showGrid ?? true) nodes.push(/* @__PURE__ */ jsx(R.CartesianGrid, {
|
|
133
|
+
vertical: false,
|
|
134
|
+
stroke: "var(--glyph-border)",
|
|
135
|
+
strokeDasharray: "3 3",
|
|
136
|
+
yAxisId: "left"
|
|
137
|
+
}, "grid"));
|
|
138
|
+
nodes.push(/* @__PURE__ */ jsx(R.XAxis, {
|
|
139
|
+
dataKey: props.index,
|
|
140
|
+
hide: xAxis.hide,
|
|
141
|
+
tick: axisTick,
|
|
142
|
+
tickLine: false,
|
|
143
|
+
axisLine: false,
|
|
144
|
+
tickMargin: 8,
|
|
145
|
+
minTickGap: 16,
|
|
146
|
+
...xAxis.formatter && { tickFormatter: xAxis.formatter },
|
|
147
|
+
...xAxis.label && {
|
|
148
|
+
label: {
|
|
149
|
+
value: xAxis.label,
|
|
150
|
+
position: "insideBottom",
|
|
151
|
+
offset: -4,
|
|
152
|
+
...axisTick
|
|
153
|
+
},
|
|
154
|
+
height: 44
|
|
155
|
+
}
|
|
156
|
+
}, "x"), /* @__PURE__ */ jsx(R.YAxis, {
|
|
157
|
+
yAxisId: "left",
|
|
158
|
+
hide: hideY,
|
|
159
|
+
tick: axisTick,
|
|
160
|
+
tickLine: false,
|
|
161
|
+
axisLine: false,
|
|
162
|
+
width: yAxis.width ?? axisWidth(props.data, props.series.filter((item) => item.axis !== "right").map((item) => item.key), yAxis.formatter ?? valueFormatter, yAxis.label ? 18 : 0),
|
|
163
|
+
tickFormatter: yAxis.formatter ?? valueFormatter,
|
|
164
|
+
...yAxis.domain && { domain: yAxis.domain },
|
|
165
|
+
...yAxis.allowDecimals !== void 0 && { allowDecimals: yAxis.allowDecimals },
|
|
166
|
+
...yAxis.tickCount !== void 0 && { tickCount: yAxis.tickCount },
|
|
167
|
+
...yAxis.label && { label: {
|
|
168
|
+
value: yAxis.label,
|
|
169
|
+
angle: -90,
|
|
170
|
+
position: "insideLeft",
|
|
171
|
+
...axisTick
|
|
172
|
+
} }
|
|
173
|
+
}, "y"));
|
|
174
|
+
if (rightAxis) nodes.push(/* @__PURE__ */ jsx(R.YAxis, {
|
|
175
|
+
yAxisId: "right",
|
|
176
|
+
orientation: "right",
|
|
177
|
+
hide: rightAxis.hide,
|
|
178
|
+
tick: axisTick,
|
|
179
|
+
tickLine: false,
|
|
180
|
+
axisLine: false,
|
|
181
|
+
width: rightAxis.width ?? axisWidth(props.data, props.series.filter((item) => item.axis === "right").map((item) => item.key), rightAxis.formatter ?? valueFormatter, rightAxis.label ? 18 : 0),
|
|
182
|
+
tickFormatter: rightAxis.formatter ?? valueFormatter,
|
|
183
|
+
...rightAxis.domain && { domain: rightAxis.domain },
|
|
184
|
+
...rightAxis.label && { label: {
|
|
185
|
+
value: rightAxis.label,
|
|
186
|
+
angle: 90,
|
|
187
|
+
position: "insideRight",
|
|
188
|
+
...axisTick
|
|
189
|
+
} }
|
|
190
|
+
}, "y-right"));
|
|
191
|
+
return nodes;
|
|
192
|
+
}
|
|
193
|
+
/** Reference lines, areas and the brush. */
|
|
194
|
+
function overlays(props) {
|
|
195
|
+
const nodes = [];
|
|
196
|
+
props.referenceAreas?.forEach((area, i) => {
|
|
197
|
+
const color = resolveColor(area.color ?? "muted-foreground", 0);
|
|
198
|
+
nodes.push(/* @__PURE__ */ jsx(R.ReferenceArea, {
|
|
199
|
+
yAxisId: "left",
|
|
200
|
+
...area.x1 !== void 0 && { x1: area.x1 },
|
|
201
|
+
...area.x2 !== void 0 && { x2: area.x2 },
|
|
202
|
+
...area.y1 !== void 0 && { y1: area.y1 },
|
|
203
|
+
...area.y2 !== void 0 && { y2: area.y2 },
|
|
204
|
+
fill: color,
|
|
205
|
+
fillOpacity: .08,
|
|
206
|
+
stroke: "none",
|
|
207
|
+
ifOverflow: "extendDomain",
|
|
208
|
+
...area.label && { label: {
|
|
209
|
+
value: area.label,
|
|
210
|
+
position: "insideTop",
|
|
211
|
+
...axisTick,
|
|
212
|
+
fontSize: 11,
|
|
213
|
+
...halo
|
|
214
|
+
} }
|
|
215
|
+
}, `area-${i}`));
|
|
216
|
+
});
|
|
217
|
+
props.referenceLines?.forEach((line, i) => {
|
|
218
|
+
const color = resolveColor(line.color ?? "muted-foreground", 0);
|
|
219
|
+
nodes.push(/* @__PURE__ */ jsx(R.ReferenceLine, {
|
|
220
|
+
yAxisId: "left",
|
|
221
|
+
...line.y !== void 0 && { y: line.y },
|
|
222
|
+
...line.x !== void 0 && { x: line.x },
|
|
223
|
+
stroke: color,
|
|
224
|
+
strokeWidth: 1.25,
|
|
225
|
+
strokeDasharray: line.dashed === false ? void 0 : "4 4",
|
|
226
|
+
ifOverflow: "extendDomain",
|
|
227
|
+
...line.label && { label: {
|
|
228
|
+
value: line.label,
|
|
229
|
+
position: line.y !== void 0 ? "insideTopRight" : "insideTopLeft",
|
|
230
|
+
fill: "var(--glyph-muted-foreground)",
|
|
231
|
+
fontSize: 11,
|
|
232
|
+
...halo
|
|
233
|
+
} }
|
|
234
|
+
}, `line-${i}`));
|
|
235
|
+
});
|
|
236
|
+
if (props.brush) {
|
|
237
|
+
const options = props.brush === true ? {} : props.brush;
|
|
238
|
+
nodes.push(/* @__PURE__ */ jsx(R.Brush, {
|
|
239
|
+
dataKey: props.index,
|
|
240
|
+
height: options.height ?? 28,
|
|
241
|
+
stroke: "var(--glyph-border-strong)",
|
|
242
|
+
fill: "var(--glyph-subtle)",
|
|
243
|
+
travellerWidth: 8,
|
|
244
|
+
tickFormatter: () => "",
|
|
245
|
+
...options.startIndex !== void 0 && { startIndex: options.startIndex },
|
|
246
|
+
...options.endIndex !== void 0 && { endIndex: options.endIndex }
|
|
247
|
+
}, "brush"));
|
|
248
|
+
}
|
|
249
|
+
return nodes;
|
|
250
|
+
}
|
|
251
|
+
function chartTooltip(valueFormatter, cursor, options = {}) {
|
|
252
|
+
return /* @__PURE__ */ jsx(R.Tooltip, {
|
|
253
|
+
cursor,
|
|
254
|
+
isAnimationActive: false,
|
|
255
|
+
content: (p) => /* @__PURE__ */ jsx(ChartTooltipCard, {
|
|
256
|
+
active: p.active,
|
|
257
|
+
payload: p.payload,
|
|
258
|
+
label: p.label,
|
|
259
|
+
formatter: valueFormatter,
|
|
260
|
+
labelFormatter: options.labelFormatter,
|
|
261
|
+
total: options.total
|
|
262
|
+
})
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
const lineCursor = { stroke: "var(--glyph-border-strong)" };
|
|
266
|
+
const barCursor = {
|
|
267
|
+
fill: "var(--glyph-muted)",
|
|
268
|
+
opacity: .6
|
|
269
|
+
};
|
|
270
|
+
/** Trends over time, one line per series. */
|
|
271
|
+
function LineChart(props) {
|
|
272
|
+
const { resolved, table, legend, onLegendToggle, valueFormatter } = useCartesian(props);
|
|
273
|
+
const animation = useChartAnimation();
|
|
274
|
+
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
275
|
+
...frameProps(props),
|
|
276
|
+
legend,
|
|
277
|
+
onLegendToggle,
|
|
278
|
+
table,
|
|
279
|
+
children: /* @__PURE__ */ jsx(R.ResponsiveContainer, {
|
|
280
|
+
width: "100%",
|
|
281
|
+
height: props.height ?? 240,
|
|
282
|
+
children: /* @__PURE__ */ jsxs(R.LineChart, {
|
|
283
|
+
...rootProps(props),
|
|
284
|
+
children: [
|
|
285
|
+
axes(props, valueFormatter),
|
|
286
|
+
chartTooltip(valueFormatter, lineCursor, { labelFormatter: props.labelFormatter }),
|
|
287
|
+
overlays(props),
|
|
288
|
+
resolved.map((item) => /* @__PURE__ */ jsx(R.Line, {
|
|
289
|
+
yAxisId: "left",
|
|
290
|
+
dataKey: item.key,
|
|
291
|
+
name: item.label,
|
|
292
|
+
hide: item.hidden,
|
|
293
|
+
type: props.curve === "step" ? "stepAfter" : props.curve ?? "monotone",
|
|
294
|
+
stroke: item.stroke,
|
|
295
|
+
strokeWidth: 2,
|
|
296
|
+
dot: props.dots ? {
|
|
297
|
+
r: 3,
|
|
298
|
+
strokeWidth: 0,
|
|
299
|
+
fill: item.stroke
|
|
300
|
+
} : false,
|
|
301
|
+
activeDot: {
|
|
302
|
+
r: 4,
|
|
303
|
+
strokeWidth: 2,
|
|
304
|
+
stroke: "var(--glyph-surface)"
|
|
305
|
+
},
|
|
306
|
+
...animation
|
|
307
|
+
}, item.key))
|
|
308
|
+
]
|
|
309
|
+
})
|
|
310
|
+
})
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
/** Trends with filled areas. `stacked` shows how series add up to a total. */
|
|
314
|
+
function AreaChart(props) {
|
|
315
|
+
const { resolved, table, legend, onLegendToggle, valueFormatter } = useCartesian(props);
|
|
316
|
+
const animation = useChartAnimation();
|
|
317
|
+
const id = useId().replace(/:/g, "");
|
|
318
|
+
const stacked = props.stacked || props.expand;
|
|
319
|
+
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
320
|
+
...frameProps(props),
|
|
321
|
+
legend,
|
|
322
|
+
onLegendToggle,
|
|
323
|
+
table,
|
|
324
|
+
children: /* @__PURE__ */ jsx(R.ResponsiveContainer, {
|
|
325
|
+
width: "100%",
|
|
326
|
+
height: props.height ?? 240,
|
|
327
|
+
children: /* @__PURE__ */ jsxs(R.AreaChart, {
|
|
328
|
+
...rootProps(props),
|
|
329
|
+
...props.expand && { stackOffset: "expand" },
|
|
330
|
+
children: [
|
|
331
|
+
/* @__PURE__ */ jsx("defs", { children: resolved.map((item, i) => /* @__PURE__ */ jsxs("linearGradient", {
|
|
332
|
+
id: `${id}-${i}`,
|
|
333
|
+
x1: "0",
|
|
334
|
+
x2: "0",
|
|
335
|
+
y1: "0",
|
|
336
|
+
y2: "1",
|
|
337
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
338
|
+
offset: "0%",
|
|
339
|
+
stopColor: item.stroke,
|
|
340
|
+
stopOpacity: stacked ? .45 : .3
|
|
341
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
342
|
+
offset: "100%",
|
|
343
|
+
stopColor: item.stroke,
|
|
344
|
+
stopOpacity: stacked ? .12 : 0
|
|
345
|
+
})]
|
|
346
|
+
}, item.key)) }),
|
|
347
|
+
axes(props.expand ? {
|
|
348
|
+
...props,
|
|
349
|
+
yAxis: {
|
|
350
|
+
formatter: (v) => `${Math.round(v * 100)}%`,
|
|
351
|
+
...props.yAxis
|
|
352
|
+
}
|
|
353
|
+
} : props, valueFormatter),
|
|
354
|
+
chartTooltip(valueFormatter, lineCursor, {
|
|
355
|
+
total: stacked && !props.expand,
|
|
356
|
+
labelFormatter: props.labelFormatter
|
|
357
|
+
}),
|
|
358
|
+
overlays(props),
|
|
359
|
+
resolved.map((item, i) => /* @__PURE__ */ jsx(R.Area, {
|
|
360
|
+
yAxisId: "left",
|
|
361
|
+
dataKey: item.key,
|
|
362
|
+
name: item.label,
|
|
363
|
+
hide: item.hidden,
|
|
364
|
+
type: props.curve === "step" ? "stepAfter" : props.curve ?? "monotone",
|
|
365
|
+
stroke: item.stroke,
|
|
366
|
+
strokeWidth: 2,
|
|
367
|
+
fill: `url(#${id}-${i})`,
|
|
368
|
+
activeDot: {
|
|
369
|
+
r: 4,
|
|
370
|
+
strokeWidth: 2,
|
|
371
|
+
stroke: "var(--glyph-surface)"
|
|
372
|
+
},
|
|
373
|
+
...stacked && { stackId: "stack" },
|
|
374
|
+
...animation
|
|
375
|
+
}, item.key))
|
|
376
|
+
]
|
|
377
|
+
})
|
|
378
|
+
})
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
/** Compare values across categories. `stacked` puts series on top of each other. */
|
|
382
|
+
function BarChart(props) {
|
|
383
|
+
const { resolved, table, legend, onLegendToggle, valueFormatter } = useCartesian(props);
|
|
384
|
+
const animation = useChartAnimation();
|
|
385
|
+
const radius = props.barRadius ?? 4;
|
|
386
|
+
const horizontal = props.layout === "vertical";
|
|
387
|
+
const visible = resolved.filter((item) => !item.hidden);
|
|
388
|
+
const top = visible[visible.length - 1]?.key;
|
|
389
|
+
const endRadius = (key) => {
|
|
390
|
+
if (props.stacked && key !== top) return 0;
|
|
391
|
+
return horizontal ? [
|
|
392
|
+
0,
|
|
393
|
+
radius,
|
|
394
|
+
radius,
|
|
395
|
+
0
|
|
396
|
+
] : [
|
|
397
|
+
radius,
|
|
398
|
+
radius,
|
|
399
|
+
0,
|
|
400
|
+
0
|
|
401
|
+
];
|
|
402
|
+
};
|
|
403
|
+
const { xAxis = {}, yAxis = {} } = props;
|
|
404
|
+
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
405
|
+
...frameProps(props),
|
|
406
|
+
legend,
|
|
407
|
+
onLegendToggle,
|
|
408
|
+
table,
|
|
409
|
+
children: /* @__PURE__ */ jsx(R.ResponsiveContainer, {
|
|
410
|
+
width: "100%",
|
|
411
|
+
height: props.height ?? 240,
|
|
412
|
+
children: /* @__PURE__ */ jsxs(R.BarChart, {
|
|
413
|
+
...rootProps(props),
|
|
414
|
+
layout: horizontal ? "vertical" : "horizontal",
|
|
415
|
+
barGap: 2,
|
|
416
|
+
barCategoryGap: "24%",
|
|
417
|
+
children: [
|
|
418
|
+
horizontal ? [
|
|
419
|
+
(props.showGrid ?? true) && /* @__PURE__ */ jsx(R.CartesianGrid, {
|
|
420
|
+
horizontal: false,
|
|
421
|
+
stroke: "var(--glyph-border)",
|
|
422
|
+
strokeDasharray: "3 3",
|
|
423
|
+
yAxisId: "left"
|
|
424
|
+
}, "grid"),
|
|
425
|
+
/* @__PURE__ */ jsx(R.XAxis, {
|
|
426
|
+
type: "number",
|
|
427
|
+
hide: yAxis.hide ?? props.showYAxis === false,
|
|
428
|
+
tick: axisTick,
|
|
429
|
+
tickLine: false,
|
|
430
|
+
axisLine: false,
|
|
431
|
+
tickFormatter: yAxis.formatter ?? valueFormatter,
|
|
432
|
+
...yAxis.domain && { domain: yAxis.domain }
|
|
433
|
+
}, "x"),
|
|
434
|
+
/* @__PURE__ */ jsx(R.YAxis, {
|
|
435
|
+
yAxisId: "left",
|
|
436
|
+
type: "category",
|
|
437
|
+
dataKey: props.index,
|
|
438
|
+
hide: xAxis.hide,
|
|
439
|
+
tick: axisTick,
|
|
440
|
+
tickLine: false,
|
|
441
|
+
axisLine: false,
|
|
442
|
+
width: xAxis.width ?? yAxis.width ?? 96,
|
|
443
|
+
...xAxis.formatter && { tickFormatter: xAxis.formatter }
|
|
444
|
+
}, "y")
|
|
445
|
+
] : axes(props, valueFormatter),
|
|
446
|
+
chartTooltip(valueFormatter, barCursor, {
|
|
447
|
+
total: props.stacked,
|
|
448
|
+
labelFormatter: props.labelFormatter
|
|
449
|
+
}),
|
|
450
|
+
overlays(props),
|
|
451
|
+
resolved.map((item) => /* @__PURE__ */ jsx(R.Bar, {
|
|
452
|
+
yAxisId: "left",
|
|
453
|
+
dataKey: item.key,
|
|
454
|
+
name: item.label,
|
|
455
|
+
hide: item.hidden,
|
|
456
|
+
fill: item.stroke,
|
|
457
|
+
radius: endRadius(item.key),
|
|
458
|
+
maxBarSize: 48,
|
|
459
|
+
...props.stacked && { stackId: "stack" },
|
|
460
|
+
...animation
|
|
461
|
+
}, item.key))
|
|
462
|
+
]
|
|
463
|
+
})
|
|
464
|
+
})
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
/** Bars, lines and areas on one plot, e.g. revenue bars with a target line. */
|
|
468
|
+
function ComposedChart(props) {
|
|
469
|
+
const { resolved, table, legend, onLegendToggle, valueFormatter } = useCartesian(props);
|
|
470
|
+
const animation = useChartAnimation();
|
|
471
|
+
const id = useId().replace(/:/g, "");
|
|
472
|
+
const hasRight = props.series.some((item) => item.axis === "right");
|
|
473
|
+
const cartesian = props;
|
|
474
|
+
return /* @__PURE__ */ jsx(ChartFrame, {
|
|
475
|
+
...frameProps(props),
|
|
476
|
+
legend,
|
|
477
|
+
onLegendToggle,
|
|
478
|
+
table,
|
|
479
|
+
children: /* @__PURE__ */ jsx(R.ResponsiveContainer, {
|
|
480
|
+
width: "100%",
|
|
481
|
+
height: props.height ?? 240,
|
|
482
|
+
children: /* @__PURE__ */ jsxs(R.ComposedChart, {
|
|
483
|
+
...rootProps(cartesian),
|
|
484
|
+
barGap: 2,
|
|
485
|
+
barCategoryGap: "24%",
|
|
486
|
+
children: [
|
|
487
|
+
/* @__PURE__ */ jsx("defs", { children: resolved.map((item, i) => /* @__PURE__ */ jsxs("linearGradient", {
|
|
488
|
+
id: `${id}-${i}`,
|
|
489
|
+
x1: "0",
|
|
490
|
+
x2: "0",
|
|
491
|
+
y1: "0",
|
|
492
|
+
y2: "1",
|
|
493
|
+
children: [/* @__PURE__ */ jsx("stop", {
|
|
494
|
+
offset: "0%",
|
|
495
|
+
stopColor: item.stroke,
|
|
496
|
+
stopOpacity: .3
|
|
497
|
+
}), /* @__PURE__ */ jsx("stop", {
|
|
498
|
+
offset: "100%",
|
|
499
|
+
stopColor: item.stroke,
|
|
500
|
+
stopOpacity: 0
|
|
501
|
+
})]
|
|
502
|
+
}, item.key)) }),
|
|
503
|
+
axes(cartesian, valueFormatter, { rightAxis: hasRight ? props.rightAxis ?? {} : void 0 }),
|
|
504
|
+
chartTooltip(valueFormatter, barCursor, { labelFormatter: props.labelFormatter }),
|
|
505
|
+
overlays(cartesian),
|
|
506
|
+
resolved.map((item, i) => {
|
|
507
|
+
const common = {
|
|
508
|
+
yAxisId: item.axis === "right" ? "right" : "left",
|
|
509
|
+
dataKey: item.key,
|
|
510
|
+
name: item.label,
|
|
511
|
+
hide: item.hidden,
|
|
512
|
+
...animation
|
|
513
|
+
};
|
|
514
|
+
if (item.type === "line") return /* @__PURE__ */ jsx(R.Line, {
|
|
515
|
+
...common,
|
|
516
|
+
type: "monotone",
|
|
517
|
+
stroke: item.stroke,
|
|
518
|
+
strokeWidth: 2,
|
|
519
|
+
dot: false,
|
|
520
|
+
activeDot: {
|
|
521
|
+
r: 4,
|
|
522
|
+
strokeWidth: 2,
|
|
523
|
+
stroke: "var(--glyph-surface)"
|
|
524
|
+
}
|
|
525
|
+
}, item.key);
|
|
526
|
+
if (item.type === "area") return /* @__PURE__ */ jsx(R.Area, {
|
|
527
|
+
...common,
|
|
528
|
+
type: "monotone",
|
|
529
|
+
stroke: item.stroke,
|
|
530
|
+
strokeWidth: 2,
|
|
531
|
+
fill: `url(#${id}-${i})`
|
|
532
|
+
}, item.key);
|
|
533
|
+
return /* @__PURE__ */ jsx(R.Bar, {
|
|
534
|
+
...common,
|
|
535
|
+
fill: item.stroke,
|
|
536
|
+
radius: props.stacked ? 0 : [
|
|
537
|
+
4,
|
|
538
|
+
4,
|
|
539
|
+
0,
|
|
540
|
+
0
|
|
541
|
+
],
|
|
542
|
+
maxBarSize: 48,
|
|
543
|
+
...props.stacked && { stackId: "bars" }
|
|
544
|
+
}, item.key);
|
|
545
|
+
})
|
|
546
|
+
]
|
|
547
|
+
})
|
|
548
|
+
})
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
//#endregion
|
|
552
|
+
export { AreaChart, BarChart, ComposedChart, LineChart, axes, axisTick, axisWidth, chartTooltip, frameProps, overlays, rootProps, useCartesian };
|