neba 1.5.0 → 1.7.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 +36 -5
- package/dist/components/accordion/Accordion.d.ts +1 -1
- package/dist/components/accordion/Accordion.js +1 -1
- package/dist/components/accordion/index.d.ts +2 -2
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/alert/Alert.d.ts +1 -1
- package/dist/components/alert/Alert.js +1 -1
- package/dist/components/alert/index.d.ts +2 -2
- package/dist/components/alert/index.js +1 -1
- package/dist/components/animate-appear/AnimateAppear.d.ts +1 -1
- package/dist/components/animate-appear/AnimateAppear.js +1 -1
- package/dist/components/animate-appear/index.d.ts +2 -2
- package/dist/components/animate-appear/index.js +1 -1
- package/dist/components/animate-blink/AnimateBlink.d.ts +1 -1
- package/dist/components/animate-blink/AnimateBlink.js +1 -1
- package/dist/components/animate-blink/index.d.ts +2 -2
- package/dist/components/animate-blink/index.js +1 -1
- package/dist/components/animate-fade/AnimateFade.d.ts +1 -1
- package/dist/components/animate-fade/AnimateFade.js +1 -1
- package/dist/components/animate-fade/index.d.ts +2 -2
- package/dist/components/animate-fade/index.js +1 -1
- package/dist/components/animate-grow/AnimateGrow.d.ts +1 -1
- package/dist/components/animate-grow/AnimateGrow.js +1 -1
- package/dist/components/animate-grow/index.d.ts +2 -2
- package/dist/components/animate-grow/index.js +1 -1
- package/dist/components/animate-headline/AnimateHeadline.d.ts +1 -1
- package/dist/components/animate-headline/AnimateHeadline.js +1 -1
- package/dist/components/animate-headline/index.d.ts +2 -2
- package/dist/components/animate-headline/index.js +1 -1
- package/dist/components/animate-lighting/AnimateLighting.d.ts +1 -1
- package/dist/components/animate-lighting/AnimateLighting.js +1 -1
- package/dist/components/animate-lighting/index.d.ts +2 -2
- package/dist/components/animate-lighting/index.js +1 -1
- package/dist/components/animate-marquee/AnimateMarquee.d.ts +1 -1
- package/dist/components/animate-marquee/AnimateMarquee.js +1 -1
- package/dist/components/animate-marquee/index.d.ts +2 -2
- package/dist/components/animate-marquee/index.js +1 -1
- package/dist/components/animate-rotate/AnimateRotate.d.ts +1 -1
- package/dist/components/animate-rotate/AnimateRotate.js +1 -1
- package/dist/components/animate-rotate/index.d.ts +2 -2
- package/dist/components/animate-rotate/index.js +1 -1
- package/dist/components/animate-slide/AnimateSlide.d.ts +1 -1
- package/dist/components/animate-slide/AnimateSlide.js +1 -1
- package/dist/components/animate-slide/index.d.ts +2 -2
- package/dist/components/animate-slide/index.js +1 -1
- package/dist/components/animate-typing/AnimateTyping.d.ts +1 -1
- package/dist/components/animate-typing/AnimateTyping.js +1 -1
- package/dist/components/animate-typing/index.d.ts +2 -2
- package/dist/components/animate-typing/index.js +1 -1
- package/dist/components/animate-zoom/AnimateZoom.d.ts +1 -1
- package/dist/components/animate-zoom/AnimateZoom.js +1 -1
- package/dist/components/animate-zoom/index.d.ts +2 -2
- package/dist/components/animate-zoom/index.js +1 -1
- package/dist/components/area-chart/AreaChart.d.ts +3 -3
- package/dist/components/area-chart/AreaChart.js +1 -1
- package/dist/components/area-chart/index.d.ts +2 -2
- package/dist/components/area-chart/index.js +1 -1
- package/dist/components/aspect-ratio/AspectRatio.d.ts +1 -1
- package/dist/components/aspect-ratio/AspectRatio.js +1 -1
- package/dist/components/aspect-ratio/index.d.ts +2 -2
- package/dist/components/aspect-ratio/index.js +1 -1
- package/dist/components/avatar/Avatar.d.ts +1 -1
- package/dist/components/avatar/Avatar.js +1 -1
- package/dist/components/avatar/index.d.ts +2 -2
- package/dist/components/avatar/index.js +1 -1
- package/dist/components/badge/Badge.d.ts +1 -1
- package/dist/components/badge/Badge.js +1 -1
- package/dist/components/badge/index.d.ts +2 -2
- package/dist/components/badge/index.js +1 -1
- package/dist/components/bar-chart/BarChart.d.ts +2 -2
- package/dist/components/bar-chart/BarChart.js +1 -1
- package/dist/components/bar-chart/index.d.ts +2 -2
- package/dist/components/bar-chart/index.js +1 -1
- package/dist/components/blockquote/Blockquote.d.ts +1 -1
- package/dist/components/blockquote/Blockquote.js +1 -1
- package/dist/components/blockquote/index.d.ts +2 -2
- package/dist/components/blockquote/index.js +1 -1
- package/dist/components/bottom-navigation/BottomNavigation.d.ts +3 -15
- package/dist/components/bottom-navigation/BottomNavigation.js +1 -1
- package/dist/components/bottom-navigation/index.d.ts +1 -1
- package/dist/components/bottom-navigation/index.js +1 -1
- package/dist/components/box/Box.d.ts +1 -1
- package/dist/components/box/Box.js +1 -1
- package/dist/components/box/index.d.ts +2 -2
- package/dist/components/box/index.js +1 -1
- package/dist/components/breadcrumb/Breadcrumb.d.ts +1 -1
- package/dist/components/breadcrumb/Breadcrumb.js +1 -1
- package/dist/components/breadcrumb/index.d.ts +2 -2
- package/dist/components/breadcrumb/index.js +1 -1
- package/dist/components/button/Button.d.ts +1 -1
- package/dist/components/button/Button.js +1 -1
- package/dist/components/button/index.d.ts +2 -2
- package/dist/components/button/index.js +1 -1
- package/dist/components/button-group/ButtonGroup.d.ts +1 -1
- package/dist/components/button-group/ButtonGroup.js +1 -1
- package/dist/components/button-group/index.d.ts +2 -2
- package/dist/components/button-group/index.js +1 -1
- package/dist/components/card/Card.d.ts +1 -1
- package/dist/components/card/Card.js +1 -1
- package/dist/components/card/index.d.ts +2 -2
- package/dist/components/card/index.js +1 -1
- package/dist/components/carousel/Carousel.d.ts +1 -1
- package/dist/components/carousel/Carousel.js +1 -1
- package/dist/components/carousel/index.d.ts +2 -2
- package/dist/components/carousel/index.js +1 -1
- package/dist/components/chat-bubble/ChatBubble.d.ts +1 -1
- package/dist/components/chat-bubble/ChatBubble.js +1 -1
- package/dist/components/chat-bubble/index.d.ts +2 -2
- package/dist/components/chat-bubble/index.js +1 -1
- package/dist/components/checkbox/Checkbox.d.ts +1 -1
- package/dist/components/checkbox/Checkbox.js +1 -1
- package/dist/components/checkbox/index.d.ts +2 -2
- package/dist/components/checkbox/index.js +1 -1
- package/dist/components/chip/Chip.d.ts +1 -1
- package/dist/components/chip/Chip.js +1 -1
- package/dist/components/chip/index.d.ts +2 -2
- package/dist/components/chip/index.js +1 -1
- package/dist/components/collapsible/Collapsible.d.ts +1 -1
- package/dist/components/collapsible/Collapsible.js +1 -1
- package/dist/components/collapsible/index.d.ts +1 -1
- package/dist/components/collapsible/index.js +1 -1
- package/dist/components/color-picker/ColorPicker.d.ts +2 -2
- package/dist/components/color-picker/ColorPicker.js +1 -1
- package/dist/components/color-picker/index.d.ts +2 -2
- package/dist/components/color-picker/index.js +1 -1
- package/dist/components/combobox/Combobox.d.ts +1 -1
- package/dist/components/combobox/Combobox.js +1 -1
- package/dist/components/combobox/index.d.ts +2 -2
- package/dist/components/combobox/index.js +1 -1
- package/dist/components/container/Container.d.ts +1 -1
- package/dist/components/container/Container.js +1 -1
- package/dist/components/container/index.d.ts +2 -2
- package/dist/components/container/index.js +1 -1
- package/dist/components/data-table/DataTable.d.ts +1 -1
- package/dist/components/data-table/DataTable.js +1 -1
- package/dist/components/data-table/index.d.ts +2 -2
- package/dist/components/data-table/index.js +1 -1
- package/dist/components/date-picker/DatePicker.d.ts +3 -3
- package/dist/components/date-picker/DatePicker.js +1 -1
- package/dist/components/date-picker/index.d.ts +2 -2
- package/dist/components/date-picker/index.js +1 -1
- package/dist/components/date-range-picker/DateRangePicker.d.ts +3 -3
- package/dist/components/date-range-picker/DateRangePicker.js +1 -1
- package/dist/components/date-range-picker/index.d.ts +2 -2
- package/dist/components/date-range-picker/index.js +1 -1
- package/dist/components/date-time-picker/DateTimePicker.d.ts +4 -4
- package/dist/components/date-time-picker/DateTimePicker.js +1 -1
- package/dist/components/date-time-picker/index.d.ts +2 -2
- package/dist/components/date-time-picker/index.js +1 -1
- package/dist/components/dialog/Dialog.d.ts +1 -1
- package/dist/components/dialog/Dialog.js +1 -1
- package/dist/components/dialog/index.d.ts +2 -2
- package/dist/components/dialog/index.js +1 -1
- package/dist/components/divider/Divider.d.ts +1 -1
- package/dist/components/divider/Divider.js +1 -1
- package/dist/components/divider/index.d.ts +2 -2
- package/dist/components/divider/index.js +1 -1
- package/dist/components/drawer/Drawer.d.ts +1 -1
- package/dist/components/drawer/Drawer.js +1 -1
- package/dist/components/drawer/index.d.ts +2 -2
- package/dist/components/drawer/index.js +1 -1
- package/dist/components/empty/Empty.d.ts +1 -1
- package/dist/components/empty/Empty.js +1 -1
- package/dist/components/empty/index.d.ts +2 -2
- package/dist/components/empty/index.js +1 -1
- package/dist/components/file-picker/FilePicker.d.ts +1 -1
- package/dist/components/file-picker/FilePicker.js +1 -1
- package/dist/components/file-picker/index.d.ts +2 -2
- package/dist/components/file-picker/index.js +1 -1
- package/dist/components/floating-action-button/FloatingActionButton.d.ts +1 -1
- package/dist/components/floating-action-button/FloatingActionButton.js +1 -1
- package/dist/components/floating-action-button/index.d.ts +1 -1
- package/dist/components/floating-action-button/index.js +1 -1
- package/dist/components/floating-bottom-navigation/FloatingBottomNavigation.d.ts +91 -0
- package/dist/components/floating-bottom-navigation/FloatingBottomNavigation.js +1 -0
- package/dist/components/floating-bottom-navigation/index.d.ts +2 -0
- package/dist/components/floating-bottom-navigation/index.js +1 -0
- package/dist/components/grid/Grid.d.ts +1 -1
- package/dist/components/grid/Grid.js +1 -1
- package/dist/components/grid/index.d.ts +2 -2
- package/dist/components/grid/index.js +1 -1
- package/dist/components/grid-container/GridContainer.d.ts +1 -1
- package/dist/components/grid-container/GridContainer.js +1 -1
- package/dist/components/grid-container/index.d.ts +2 -2
- package/dist/components/grid-container/index.js +1 -1
- package/dist/components/heatmap-chart/HeatmapChart.d.ts +3 -3
- package/dist/components/heatmap-chart/HeatmapChart.js +1 -1
- package/dist/components/heatmap-chart/index.d.ts +2 -2
- package/dist/components/heatmap-chart/index.js +1 -1
- package/dist/components/highlight/Highlight.d.ts +2 -2
- package/dist/components/highlight/Highlight.js +1 -1
- package/dist/components/highlight/index.d.ts +2 -2
- package/dist/components/highlight/index.js +1 -1
- package/dist/components/icon/Icon.d.ts +1 -1
- package/dist/components/icon/Icon.js +1 -1
- package/dist/components/icon/index.d.ts +2 -2
- package/dist/components/icon/index.js +1 -1
- package/dist/components/icon-button/IconButton.d.ts +1 -1
- package/dist/components/icon-button/IconButton.js +1 -1
- package/dist/components/icon-button/index.d.ts +2 -2
- package/dist/components/icon-button/index.js +1 -1
- package/dist/components/line-chart/LineChart.d.ts +3 -3
- package/dist/components/line-chart/LineChart.js +1 -1
- package/dist/components/line-chart/index.d.ts +2 -2
- package/dist/components/line-chart/index.js +1 -1
- package/dist/components/list/List.d.ts +1 -1
- package/dist/components/list/List.js +1 -1
- package/dist/components/list/index.d.ts +2 -2
- package/dist/components/list/index.js +1 -1
- package/dist/components/menu/Menu.d.ts +1 -1
- package/dist/components/menu/Menu.js +1 -1
- package/dist/components/menu/index.d.ts +2 -2
- package/dist/components/menu/index.js +1 -1
- package/dist/components/mockup/Mockup.d.ts +3 -3
- package/dist/components/mockup/Mockup.js +1 -1
- package/dist/components/mockup/index.d.ts +2 -2
- package/dist/components/mockup/index.js +1 -1
- package/dist/components/number-field/NumberField.d.ts +1 -1
- package/dist/components/number-field/NumberField.js +1 -1
- package/dist/components/number-field/index.d.ts +2 -2
- package/dist/components/number-field/index.js +1 -1
- package/dist/components/otp-field/OtpField.d.ts +1 -1
- package/dist/components/otp-field/OtpField.js +1 -1
- package/dist/components/otp-field/index.d.ts +2 -2
- package/dist/components/otp-field/index.js +1 -1
- package/dist/components/overlay/Overlay.d.ts +1 -1
- package/dist/components/overlay/Overlay.js +1 -1
- package/dist/components/overlay/index.d.ts +2 -2
- package/dist/components/overlay/index.js +1 -1
- package/dist/components/pagination/Pagination.d.ts +1 -1
- package/dist/components/pagination/Pagination.js +1 -1
- package/dist/components/pagination/index.d.ts +2 -2
- package/dist/components/pagination/index.js +1 -1
- package/dist/components/panes/Panes.d.ts +1 -1
- package/dist/components/panes/Panes.js +1 -1
- package/dist/components/panes/index.d.ts +2 -2
- package/dist/components/panes/index.js +1 -1
- package/dist/components/pie-chart/PieChart.d.ts +2 -2
- package/dist/components/pie-chart/PieChart.js +1 -1
- package/dist/components/pie-chart/index.d.ts +2 -2
- package/dist/components/pie-chart/index.js +1 -1
- package/dist/components/pill/Pill.d.ts +1 -1
- package/dist/components/pill/Pill.js +1 -1
- package/dist/components/pill/index.d.ts +2 -2
- package/dist/components/pill/index.js +1 -1
- package/dist/components/popover/Popover.d.ts +1 -1
- package/dist/components/popover/Popover.js +1 -1
- package/dist/components/popover/index.d.ts +2 -2
- package/dist/components/popover/index.js +1 -1
- package/dist/components/progress-box/ProgressBox.d.ts +2 -2
- package/dist/components/progress-box/ProgressBox.js +1 -1
- package/dist/components/progress-box/index.d.ts +2 -2
- package/dist/components/progress-box/index.js +1 -1
- package/dist/components/progress-circular/ProgressCircular.d.ts +2 -2
- package/dist/components/progress-circular/ProgressCircular.js +1 -1
- package/dist/components/progress-circular/index.d.ts +2 -2
- package/dist/components/progress-circular/index.js +1 -1
- package/dist/components/progress-linear/ProgressLinear.d.ts +2 -2
- package/dist/components/progress-linear/ProgressLinear.js +1 -1
- package/dist/components/progress-linear/index.d.ts +2 -2
- package/dist/components/progress-linear/index.js +1 -1
- package/dist/components/radio-group/RadioGroup.d.ts +1 -1
- package/dist/components/radio-group/RadioGroup.js +1 -1
- package/dist/components/radio-group/index.d.ts +2 -2
- package/dist/components/radio-group/index.js +1 -1
- package/dist/components/rating/Rating.d.ts +1 -1
- package/dist/components/rating/Rating.js +1 -1
- package/dist/components/rating/index.d.ts +1 -1
- package/dist/components/rating/index.js +1 -1
- package/dist/components/scatter-chart/ScatterChart.d.ts +2 -2
- package/dist/components/scatter-chart/ScatterChart.js +1 -1
- package/dist/components/scatter-chart/index.d.ts +2 -2
- package/dist/components/scatter-chart/index.js +1 -1
- package/dist/components/scroll-zone/ScrollZone.d.ts +126 -0
- package/dist/components/scroll-zone/ScrollZone.js +1 -0
- package/dist/components/scroll-zone/index.d.ts +2 -0
- package/dist/components/scroll-zone/index.js +1 -0
- package/dist/components/segmented-button/SegmentedButton.d.ts +1 -1
- package/dist/components/segmented-button/SegmentedButton.js +1 -1
- package/dist/components/segmented-button/index.d.ts +2 -2
- package/dist/components/segmented-button/index.js +1 -1
- package/dist/components/select/Select.d.ts +1 -1
- package/dist/components/select/Select.js +1 -1
- package/dist/components/select/index.d.ts +2 -2
- package/dist/components/select/index.js +1 -1
- package/dist/components/shortcut/Shortcut.d.ts +1 -1
- package/dist/components/shortcut/Shortcut.js +1 -1
- package/dist/components/shortcut/index.d.ts +2 -2
- package/dist/components/shortcut/index.js +1 -1
- package/dist/components/skeleton/Skeleton.d.ts +1 -1
- package/dist/components/skeleton/Skeleton.js +1 -1
- package/dist/components/skeleton/index.d.ts +2 -2
- package/dist/components/skeleton/index.js +1 -1
- package/dist/components/slider/Slider.d.ts +1 -1
- package/dist/components/slider/Slider.js +1 -1
- package/dist/components/slider/index.d.ts +2 -2
- package/dist/components/slider/index.js +1 -1
- package/dist/components/sparkline/Sparkline.d.ts +1 -1
- package/dist/components/sparkline/Sparkline.js +1 -1
- package/dist/components/sparkline/index.d.ts +2 -2
- package/dist/components/sparkline/index.js +1 -1
- package/dist/components/spoiler/Spoiler.d.ts +1 -1
- package/dist/components/spoiler/Spoiler.js +1 -1
- package/dist/components/spoiler/index.d.ts +2 -2
- package/dist/components/spoiler/index.js +1 -1
- package/dist/components/statistic/Statistic.d.ts +2 -2
- package/dist/components/statistic/Statistic.js +1 -1
- package/dist/components/statistic/index.d.ts +2 -2
- package/dist/components/statistic/index.js +1 -1
- package/dist/components/switch/Switch.d.ts +1 -1
- package/dist/components/switch/Switch.js +1 -1
- package/dist/components/switch/index.d.ts +2 -2
- package/dist/components/switch/index.js +1 -1
- package/dist/components/table/Table.d.ts +2 -2
- package/dist/components/table/Table.js +1 -1
- package/dist/components/table/index.d.ts +2 -2
- package/dist/components/table/index.js +1 -1
- package/dist/components/tabs/Tabs.d.ts +1 -1
- package/dist/components/tabs/Tabs.js +1 -1
- package/dist/components/tabs/index.d.ts +2 -2
- package/dist/components/tabs/index.js +1 -1
- package/dist/components/text-field/TextField.d.ts +1 -1
- package/dist/components/text-field/TextField.js +1 -1
- package/dist/components/text-field/index.d.ts +2 -2
- package/dist/components/text-field/index.js +1 -1
- package/dist/components/text-link/TextLink.d.ts +1 -1
- package/dist/components/text-link/TextLink.js +1 -1
- package/dist/components/text-link/index.d.ts +2 -2
- package/dist/components/text-link/index.js +1 -1
- package/dist/components/time-picker/TimePicker.d.ts +2 -2
- package/dist/components/time-picker/TimePicker.js +1 -1
- package/dist/components/time-picker/index.d.ts +2 -2
- package/dist/components/time-picker/index.js +1 -1
- package/dist/components/timeline/Timeline.d.ts +1 -1
- package/dist/components/timeline/Timeline.js +1 -1
- package/dist/components/timeline/index.d.ts +2 -2
- package/dist/components/timeline/index.js +1 -1
- package/dist/components/timeline-chart/TimelineChart.d.ts +2 -2
- package/dist/components/timeline-chart/TimelineChart.js +1 -1
- package/dist/components/timeline-chart/index.d.ts +2 -2
- package/dist/components/timeline-chart/index.js +1 -1
- package/dist/components/toast/Toast.d.ts +1 -1
- package/dist/components/toast/Toast.js +1 -1
- package/dist/components/toast/index.d.ts +2 -2
- package/dist/components/toast/index.js +1 -1
- package/dist/components/toolbar/Toolbar.d.ts +1 -1
- package/dist/components/toolbar/Toolbar.js +1 -1
- package/dist/components/toolbar/index.d.ts +2 -2
- package/dist/components/toolbar/index.js +1 -1
- package/dist/components/tooltip/Tooltip.d.ts +1 -1
- package/dist/components/tooltip/Tooltip.js +1 -1
- package/dist/components/tooltip/index.d.ts +2 -2
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/tree-view/TreeView.d.ts +1 -1
- package/dist/components/tree-view/TreeView.js +1 -1
- package/dist/components/tree-view/index.d.ts +2 -2
- package/dist/components/tree-view/index.js +1 -1
- package/dist/components/typography/Typography.d.ts +1 -1
- package/dist/components/typography/Typography.js +1 -1
- package/dist/components/typography/index.d.ts +2 -2
- package/dist/components/typography/index.js +1 -1
- package/dist/components/window-pane/WindowPane.d.ts +178 -0
- package/dist/components/window-pane/WindowPane.js +1 -0
- package/dist/components/window-pane/index.d.ts +2 -0
- package/dist/components/window-pane/index.js +1 -0
- package/dist/index.d.ts +92 -89
- package/dist/index.js +1 -1
- package/dist/internal/animate.d.ts +1 -1
- package/dist/internal/bottom-navigation.d.ts +57 -0
- package/dist/internal/bottom-navigation.js +1 -0
- package/dist/internal/button-group.d.ts +1 -1
- package/dist/internal/button-group.js +1 -1
- package/dist/internal/calendar.d.ts +2 -2
- package/dist/internal/calendar.js +1 -1
- package/dist/internal/chart-frame.d.ts +3 -3
- package/dist/internal/chart-frame.js +1 -1
- package/dist/internal/chart-line.d.ts +2 -2
- package/dist/internal/chart-line.js +1 -1
- package/dist/internal/chart.d.ts +1 -1
- package/dist/internal/chart.js +1 -1
- package/dist/internal/data-table.d.ts +1 -1
- package/dist/internal/date.d.ts +1 -1
- package/dist/internal/date.js +1 -1
- package/dist/internal/grid.d.ts +1 -1
- package/dist/internal/i18n.d.ts +346 -205
- package/dist/internal/i18n.js +1 -1
- package/dist/internal/icons.d.ts +18 -2
- package/dist/internal/icons.js +1 -1
- package/dist/internal/menu.d.ts +1 -1
- package/dist/internal/menu.js +1 -1
- package/dist/internal/mockup.d.ts +1 -1
- package/dist/internal/picker.d.ts +2 -2
- package/dist/internal/picker.js +1 -1
- package/dist/internal/progress.d.ts +1 -1
- package/dist/internal/styles.d.ts +1 -1
- package/dist/internal/window.d.ts +201 -0
- package/dist/internal/window.js +1 -0
- package/dist/locales/ar.d.ts +14 -0
- package/dist/locales/ar.js +1 -0
- package/dist/locales/de.d.ts +14 -0
- package/dist/locales/de.js +1 -0
- package/dist/locales/es.d.ts +14 -0
- package/dist/locales/es.js +1 -0
- package/dist/locales/fr.d.ts +14 -0
- package/dist/locales/fr.js +1 -0
- package/dist/locales/hi.d.ts +14 -0
- package/dist/locales/hi.js +1 -0
- package/dist/locales/id.d.ts +14 -0
- package/dist/locales/id.js +1 -0
- package/dist/locales/index.d.ts +45 -0
- package/dist/locales/index.js +1 -0
- package/dist/locales/it.d.ts +14 -0
- package/dist/locales/it.js +1 -0
- package/dist/locales/ja.d.ts +14 -0
- package/dist/locales/ja.js +1 -0
- package/dist/locales/ko.d.ts +14 -0
- package/dist/locales/ko.js +1 -0
- package/dist/locales/nl.d.ts +14 -0
- package/dist/locales/nl.js +1 -0
- package/dist/locales/pl.d.ts +14 -0
- package/dist/locales/pl.js +1 -0
- package/dist/locales/pt.d.ts +14 -0
- package/dist/locales/pt.js +1 -0
- package/dist/locales/ru.d.ts +14 -0
- package/dist/locales/ru.js +1 -0
- package/dist/locales/th.d.ts +14 -0
- package/dist/locales/th.js +1 -0
- package/dist/locales/tr.d.ts +14 -0
- package/dist/locales/tr.js +1 -0
- package/dist/locales/vi.d.ts +14 -0
- package/dist/locales/vi.js +1 -0
- package/dist/locales/zh-hans.d.ts +17 -0
- package/dist/locales/zh-hans.js +1 -0
- package/dist/locales/zh-hant.d.ts +17 -0
- package/dist/locales/zh-hant.js +1 -0
- package/dist/styles.css +1 -1
- package/dist/tailwind.css +6 -0
- package/package.json +41 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import*as a from"react";import{Box as l}from"../components/box/Box";import{bandScale as i,categoryAt as r,categoryCount as s,categoryExtent as o,chartFontSizes as c,compactNumber as d,extentOf as u,fitsLast as h,formatCategory as m,markerRadii as f,plotHeights as x,seriesColor as p,showsTick as g,textWidth as b,tickStride as v,toValues as y,truncate as k,valueScale as w}from"./chart";import{numberFormatter as M}from"./format";import{useMessages as N}from"./i18n";import{cx as z,metaTextClasses as S,srOnlyClasses as C,transitionClasses as A}from"./styles";const P="undefined"==typeof document?a.useEffect:a.useLayoutEffect,W=[];function B(e){const[t,n]=a.useState(0);return P(()=>{const t=e.current;if(!t)return;const a=()=>n(t.clientWidth);if(a(),"undefined"==typeof ResizeObserver)return;const l=new ResizeObserver(a);return l.observe(t),()=>l.disconnect()},[e]),t}function R(e){const[t,n]=a.useState(()=>{const t=new Set;return e.forEach((e,n)=>{e.hidden&&t.add(n)}),t}),[l,i]=a.useState(null),r=a.useCallback(e=>{n(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return{visible:e.map((e,n)=>!t.has(n)),hovered:l,toggle:r,setHovered:i}}const j={top:"flex-col-reverse",bottom:"flex-col",left:"flex-row-reverse",right:"flex-row"},F={start:"justify-start",center:"justify-center",end:"justify-end"};function E({series:a,colors:l,options:i,visibility:r,size:s,values:o,swatch:c}){const d=!1!==i.interactive,u="left"===i.side||"right"===i.side;return e("ul",{className:z("flex list-none flex-wrap items-center gap-x-3 gap-y-1 p-0",u?"min-w-0 flex-col items-start":"",F[i.align??"center"],S[s]),children:a.map((a,i)=>{const s=r.visible[i],u=null!==r.hovered&&r.hovered!==i,h=a.name??`${i+1}`,m=s?l[i]:"var(--neba-disabled-fg)",f=n(t,{children:[e("span",c?{"aria-hidden":"true",className:"flex size-2.5 shrink-0 items-center justify-center",children:c(i,m)}:{"aria-hidden":"true",className:"size-2.5 shrink-0 rounded-[0.1875rem]",style:{backgroundColor:m}}),e("span",{className:"min-w-0 truncate",children:h}),o?.[i]?e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:o[i]}):null]});return e("li",{className:"min-w-0",children:d?e("button",{type:"button","aria-pressed":s,onClick:()=>r.toggle(i),onPointerEnter:()=>r.setHovered(i),onPointerLeave:()=>r.setHovered(null),onFocus:()=>r.setHovered(i),onBlur:()=>r.setHovered(null),className:z("flex min-w-0 cursor-pointer items-center gap-1.5 rounded-(--neba-radius-xs)","px-1 py-0.5 text-(--neba-fg)",A,"hover:bg-(--n-soft)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1",s?"":"text-(--neba-disabled-fg)",u?"opacity-55":""),children:f}):e("span",{className:z("flex min-w-0 items-center gap-1.5 px-1 py-0.5 text-(--neba-fg)",s?"":"text-(--neba-disabled-fg)"),children:f})},a.name??i)})})}function H({steps:a,from:l,to:i,middle:r,align:s,vertical:o,size:c}){return e("div",{className:z("flex",o?"":F[s]),children:n("div",{className:z("grid grid-cols-[auto_auto_auto] items-center gap-x-2",S[c]),children:[e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:l}),e("span",{"aria-hidden":"true",className:z("flex h-2.5 overflow-hidden rounded-[0.1875rem]",o?"w-20":"w-24"),children:a.map(t=>e("span",{className:"h-full flex-1",style:{backgroundColor:t}},t))}),e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:i}),r?n(t,{children:[e("span",{}),e("span",{className:"text-center tabular-nums text-(--neba-muted-fg)",children:r}),e("span",{})]}):null]})})}function I({heading:t,items:a,x:l,y:i,flip:r,size:s}){return n("div",{role:"status","aria-live":"polite",className:z("pointer-events-none absolute z-10 max-w-56 min-w-24","rounded-(--neba-radius-sm) border p-2","[background-image:var(--neba-grain),var(--neba-sheen)]","[background-blend-mode:overlay,normal] [backdrop-filter:var(--neba-blur)]","bg-(--neba-panel-press) [border-color:var(--n-line)]","[box-shadow:var(--neba-shadow-2),var(--neba-plate-glass)]",S[s]),style:r?{right:`calc(100% - ${l}px + 10px)`,top:i}:{left:l+10,top:i},children:[e("div",{className:"mb-1 font-medium text-(--neba-fg)",children:t}),e("ul",{className:"flex list-none flex-col gap-0.5 p-0",children:a.map(t=>n("li",{className:"flex items-center gap-1.5",children:[e("span",{"aria-hidden":"true",className:"size-2 shrink-0 rounded-[0.125rem]",style:{backgroundColor:t.color}}),t.name?e("span",{className:"min-w-0 flex-1 truncate text-(--neba-muted-fg)",children:t.name}):null,e("span",{className:"ms-auto shrink-0 font-medium tabular-nums text-(--neba-fg)",children:t.label??t.formatted})]},t.seriesIndex))})]})}function _({id:t,caption:a,corner:l,categories:i,series:r,values:s,format:o,locale:c}){return n("table",{id:t,className:C,children:[a?e("caption",{children:a}):null,e("thead",{children:n("tr",{children:[e("th",{scope:"col",children:l??""}),r.map((t,n)=>e("th",{scope:"col",children:t.name??n+1},t.name??n))]})}),e("tbody",{children:i.map((t,a)=>n("tr",{children:[e("th",{scope:"row",children:m(t,c)}),r.map((t,n)=>{const l=s[n]?.[a];return e("td",void 0!==l?.label?{children:l.label}:{children:null==l?.value?"":o(l.value)},t.name??n)})]},a))})]})}function T({legend:t,legendSide:a,children:i,table:r,className:s,...o}){return n(l,{...o,className:z("relative flex gap-3",j[a],s??void 0),children:[e("div",{className:"relative min-w-0 flex-1",children:i}),t,r]})}export function CartesianChart({series:t,categories:l,xAxis:h,yAxis:g,horizontal:v=!1,stacked:C=!1,includeZero:A=!0,bandRatio:P=1,inset:j=!1,headroom:F=0,markInset:H=0,xScale:L="band",marks:V,markRadius:D=24,table:X,swatch:Y,scale:Z,markTooltip:O,height:K,format:U,locale:q,label:G,legend:J,tooltip:Q,empty:ee,size:te="md",variant:ne="text",padded:ae=!1,className:le,children:ie,...re}){const se=a.useRef(null),oe=B(se),ce=N(q),de=a.useId(),ue=R(t),[he,me]=a.useState(null),[fe,xe]=a.useState(null),[pe,ge]=a.useState(null),be=a.useCallback(e=>U?M(q,U).format(e):d(e,q),[U,q]),ve=a.useMemo(()=>y(t),[t]),ye=a.useMemo(()=>t.map((e,t)=>p(e,t)),[t]),ke=s(t),we=a.useMemo(()=>Array.from({length:ke},(e,t)=>r(t,l,ve)),[ke,l,ve]),Me=ve.filter((e,t)=>ue.visible[t]),Ne=u(Me,C),ze="number"==typeof K?K:void 0===K?x[te]:null,Se=c[te],Ce=g,Ae=h,Pe=Z??w(Ne,{min:Ce?.min,max:Ce?.max,tickCount:Ce?.tickCount,includeZero:A}),We="value"===L?o(Me,l):null,Be="value"===L?w(We,{min:Ae?.min,max:Ae?.max,tickCount:Ae?.tickCount,includeZero:!1}):null,Re=Pe.ticks.map((e,t)=>Ce?.tickFormat?String(Ce.tickFormat(e,t)):be(e)),je=Be?Be.ticks.map((e,t)=>Ae?.tickFormat?String(Ae.tickFormat(e,t)):d(e,q)):we.map((e,t)=>Ae?.tickFormat?String(Ae.tickFormat(e,t)):m(e,q)),Fe=Re.reduce((e,t)=>Math.max(e,b(t,Se)),0),Ee=Se+6,He=Ce?.hidden?0:Fe+10+(Ce?.label?Ee:0),Ie=(oe-(v?0:He)-16)/Math.max(1,ke),_e=Be?je:v||Ie-6>=2.4*Se?je.map(e=>k(e,v?150:Ie-6,Se)):je,Te=_e.reduce((e,t)=>Math.max(e,b(t,Se)),0),$e=v?Ae?.hidden?0:Te+10+(Ae?.label?Ee:0):He,Le=v?Ce?.hidden?0:Se+12+(Ce?.label?Ee:0):Ae?.hidden?0:Se+12+(Ae?.label?Ee:0),Ve=(v?Ae:Ce)?.thickness??$e,De=(v?Ce:Ae)?.thickness??Le,Xe=(v||Be?12:Math.max(8,_e.length?Te/2:8))+H,Ye=f[te]+4+F+H,Ze=ze??0,Oe={left:Ve+H,top:Ye,width:Math.max(0,oe-Ve-H-Xe),height:Math.max(0,Ze-Ye-De-H)},Ke=v?Oe.height:Oe.width,Ue=i(j?Math.max(1,ke-1):ke,Ke,P),qe=a.useCallback(e=>j?ke<=1?Ke/2:Ke*e/(ke-1):Ue.centre(e),[j,ke,Ke,Ue]),Ge=a.useCallback(e=>v?Oe.left+Pe.fraction(e)*Oe.width:Oe.top+(1-Pe.fraction(e))*Oe.height,[v,Oe.left,Oe.top,Oe.width,Oe.height,Pe]),Je=a.useCallback((e,t)=>v?{x:Ge(t),y:Oe.top+qe(e)}:{x:Oe.left+qe(e),y:Ge(t)},[v,Ge,qe,Oe.left,Oe.top]),Qe=a.useCallback(e=>v?Oe.top+(1-(Be?.fraction(e)??0))*Oe.height:Oe.left+(Be?.fraction(e)??0)*Oe.width,[v,Oe.left,Oe.top,Oe.width,Oe.height,Be]),et=Ge(Math.min(Math.max(0,Pe.min),Pe.max)),tt={plot:Oe,values:ve,visible:ue.visible,colors:ye,scale:Pe,band:Ue,horizontal:v,valuePx:Ge,categoryPx:qe,point:Je,categoryScale:Be,categoryValuePx:Qe,zeroPx:et,categories:we,format:be,size:te},nt=V?V(tt):W,at=!1===Q?{mode:"none"}:!0===Q||void 0===Q?{}:Q,lt=at.mode??(V?"item":"index"),it=null===fe?null:nt[fe]??null,rt=V?it?it.index:null:he,st=V?nt.length:ke,ot=()=>{me(null),xe(null),ge(null)},ct=e=>{const t=null===e?null:Math.min(st-1,Math.max(0,e));V?xe(t):me(t)},dt=e=>{ge(null);ct(((V?fe:he)??(e>0?-1:st))+e)},ut=null===rt?[]:t.flatMap((e,t)=>{if(!ue.visible[t]||it&&it.series!==t)return[];const n=ve[t]?.[rt];return n&&null!==n.value?[{seriesIndex:t,name:e.name,color:n.color??ye[t],value:n.value,formatted:be(n.value),label:n.label}]:[]}),ht=it&&O?O(it):null,mt=ht?ht.items:"item"===lt&&ut.length>1&&null!==pe?[ut.reduce((e,t)=>Math.abs(Ge(t.value??0)-pe)<Math.abs(Ge(e.value??0)-pe)?t:e)]:ut,ft=it?ve[it.series]?.[it.index]?.x??l?.[it.index]??it.index:void 0,xt=it?it.x:v?Ge(mt[0]?.value??0):Oe.left+qe(rt??0),pt=it?it.y:v?Oe.top+qe(rt??0):Oe.top,gt=it?(it.x-Oe.left)/Math.max(1,Oe.width)>.6:(v?Pe.fraction(mt[0]?.value??0):qe(rt??0)/Math.max(1,Ke))>.6,bt=!1===J?{interactive:!1}:!0===J||void 0===J?{}:J,vt=!0===J||!1!==J&&t.length>1,yt=bt.side??"bottom",kt={...tt,hovered:ue.hovered,activeIndex:rt,marks:nt,activeMark:it},wt=0===ke||null===Ne||"value"===L&&null===We;return e(T,{...re,size:te,variant:ne,padded:ae,className:le,legendSide:yt,legend:vt?e(E,{series:t,colors:ye,options:bt,visibility:ue,size:te,swatch:Y,values:bt.showValue&&null!==rt?t.map((e,t)=>{const n=ve[t]?.[rt]?.value;return null==n?void 0:be(n)}):void 0}):null,table:wt?null:X?.(de)??e(_,{id:de,caption:G,corner:Ae?.label,categories:we,series:t,values:ve,format:be,locale:q}),children:n("div",{ref:se,role:"img",tabIndex:wt?void 0:0,"aria-label":G,"aria-describedby":wt?void 0:de,onPointerMove:e=>{"none"!==lt&&(V?xe(((e,t)=>{const n=se.current;if(!n||0===nt.length)return null;const a=n.getBoundingClientRect(),l=e-a.left,i=t-a.top;let r=null,s=1/0,o=1/0;return nt.forEach((e,t)=>{const n=Math.hypot(e.x-l,e.y-i),a=void 0===e.rx?Math.max(0,n-e.r):Math.hypot(Math.max(0,Math.abs(e.x-l)-e.rx),Math.max(0,Math.abs(e.y-i)-(e.ry??e.rx)));a<=D&&(a<s||a===s&&n<o)&&(s=a,o=n,r=t)}),r})(e.clientX,e.clientY)):me(((e,t)=>{const n=se.current;if(!n||0===ke)return null;const a=n.getBoundingClientRect(),l=v?t-a.top-Oe.top:e-a.left-Oe.left;if(l<-Ue.step||l>Ke+Ue.step)return null;const i=j?ke<=1?0:Math.round(l/Ke*(ke-1)):Math.floor(l/Ue.step);return Math.min(ke-1,Math.max(0,i))})(e.clientX,e.clientY)),"item"===lt&&ge(((e,t)=>{const n=se.current;if(!n)return null;const a=n.getBoundingClientRect();return v?e-a.left:t-a.top})(e.clientX,e.clientY)))},onPointerLeave:ot,onKeyDown:"none"===lt?void 0:e=>{const t=v?"ArrowDown":"ArrowRight",n=v?"ArrowUp":"ArrowLeft";if(e.key===t)dt(1);else if(e.key===n)dt(-1);else if("Home"===e.key)ct(0);else if("End"===e.key)ct(st-1);else{if("Escape"!==e.key)return;ot()}e.preventDefault()},onBlur:ot,className:z("relative w-full","rounded-(--neba-radius-xs)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"),style:{height:ze??K},children:[wt?e("div",{className:z("flex h-full items-center justify-center text-(--neba-muted-fg)",S[te]),children:ee??ce.empty.title}):oe>0?n("svg",{width:oe,height:Ze||"100%",viewBox:`0 0 ${oe} ${Ze}`,"aria-hidden":"true",className:"block overflow-visible",children:[e($,{plot:Oe,scale:Pe,band:Ue,horizontal:v,inset:j,categoryPx:qe,valuePx:Ge,tickTexts:Re,categoryTexts:_e,categoryScale:Be,categoryValuePx:Qe,valueAxis:Ce,categoryAxis:Ae,fontSize:Se,zeroPx:et}),null===rt||V||"index"!==lt||!1===at.crosshair?null:(()=>{const t=qe(rt);return e("line",v?{x1:Oe.left,x2:Oe.left+Oe.width,y1:Oe.top+t,y2:Oe.top+t,stroke:"var(--neba-chart-baseline)",strokeWidth:1}:{x1:Oe.left+t,x2:Oe.left+t,y1:Oe.top,y2:Oe.top+Oe.height,stroke:"var(--neba-chart-baseline)",strokeWidth:1})})(),ie(kt)]}):null,null!==rt&&mt.length>0&&"none"!==lt?at.render?e("div",{className:"pointer-events-none absolute z-10",style:gt?{right:`calc(100% - ${xt}px + 10px)`,top:pt}:{left:xt+10,top:pt},children:at.render({index:rt,category:ft??we[rt],items:mt})}):e(I,{heading:ht?ht.heading:m(ft??we[rt],q),items:mt,x:xt,y:pt,flip:gt,size:te}):null]})})}function $({plot:a,scale:l,horizontal:i,categoryPx:r,valuePx:s,tickTexts:o,categoryTexts:c,categoryScale:d,categoryValuePx:u,valueAxis:m,categoryAxis:f,fontSize:x,zeroPx:p}){const y=!1!==m?.grid&&!m?.hidden,k=!f?.hidden&&(f?.grid??null!==d),w=e=>d?u(d.ticks[e]):(i?a.top:a.left)+r(e),M=v(c.length,i?a.height:a.width,i?1.8*x:Math.max(...c.map(e=>b(e,x)),1)+12),N=v(l.ticks.length,i?a.width:a.height,i?Math.max(...o.map(e=>b(e,x)),1)+16:2*x),z=c.length>1?Math.abs(w(1)-w(0)):a.width,S=l.ticks.length>1?Math.abs(s(l.ticks[1])-s(l.ticks[0])):a.height,C=h(c.length,M,z,i?1.8*x:b(c[c.length-1]??"",x)),A=h(l.ticks.length,N,S,i?b(o[o.length-1]??"",x):1.6*x);return n("g",{children:[l.ticks.map((t,r)=>{const c=s(t),d=Math.abs(t)<1e-9;return n("g",{children:[y?e("line",i?{x1:c,x2:c,y1:a.top,y2:a.top+a.height,stroke:d?"var(--neba-chart-baseline)":"var(--neba-chart-grid)",strokeWidth:1}:{x1:a.left,x2:a.left+a.width,y1:c,y2:c,stroke:d?"var(--neba-chart-baseline)":"var(--neba-chart-grid)",strokeWidth:1}):null,m?.hidden||!g(r,l.ticks.length,N,A)?null:e("text",i?{x:c,y:a.top+a.height+x+6,textAnchor:0===r?"start":r===l.ticks.length-1?"end":"middle",fontSize:x,fill:"var(--neba-muted-fg)",className:"tabular-nums",children:o[r]}:{x:a.left-8,y:c,textAnchor:"end",dominantBaseline:"central",fontSize:x,fill:"var(--neba-muted-fg)",className:"tabular-nums",children:o[r]})]},t)}),f?.hidden?null:n(t,{children:[e("line",i?{x1:p,x2:p,y1:a.top,y2:a.top+a.height,stroke:"var(--neba-chart-axis)",strokeWidth:1}:{x1:a.left,x2:a.left+a.width,y1:p,y2:p,stroke:"var(--neba-chart-axis)",strokeWidth:1}),c.map((t,l)=>{const r=w(l),s=g(l,c.length,M,C);return i?s?e("text",{x:a.left-8,y:r,textAnchor:"end",dominantBaseline:"central",fontSize:x,fill:"var(--neba-muted-fg)",className:d?"tabular-nums":void 0,children:t},l):null:n("g",{children:[k?e("line",{x1:r,x2:r,y1:a.top,y2:a.top+a.height,stroke:"var(--neba-chart-grid)",strokeWidth:1}):null,s?e("text",{x:r,y:a.top+a.height+x+6,textAnchor:d?0===l?"start":l===c.length-1?"end":"middle":"middle",fontSize:x,fill:"var(--neba-muted-fg)",className:d?"tabular-nums":void 0,children:t}):null]},l)})]}),m?.label?e("text",{x:i?a.left+a.width:a.left,y:i?a.top+a.height+2*x+12:a.top-8,textAnchor:i?"end":"start",fontSize:x,fill:"var(--neba-muted-fg)",fontWeight:500,children:m.label}):null,f?.label&&!i?e("text",{x:a.left+a.width,y:a.top+a.height+2*x+12,textAnchor:"end",fontSize:x,fill:"var(--neba-muted-fg)",fontWeight:500,children:f.label}):null]})}export{_ as ChartDataTable,E as ChartLegendBar,H as ChartScaleLegend,T as ChartSurface,I as ChartTooltipPanel,B as useMeasuredWidth,R as useVisibility};
|
|
1
|
+
import{jsx as e,Fragment as t,jsxs as n}from"react/jsx-runtime";import*as a from"react";import{Box as l}from"../components/box/Box.js";import{bandScale as i,categoryAt as r,categoryCount as s,categoryExtent as o,chartFontSizes as c,compactNumber as d,extentOf as u,fitsLast as h,formatCategory as m,markerRadii as f,plotHeights as x,seriesColor as p,showsTick as g,textWidth as b,tickStride as v,toValues as y,truncate as k,valueScale as w}from"./chart.js";import{numberFormatter as M}from"./format.js";import{emptyMessages as N,useMessages as z}from"./i18n.js";import{cx as S,metaTextClasses as C,srOnlyClasses as A,transitionClasses as P}from"./styles.js";const j="undefined"==typeof document?a.useEffect:a.useLayoutEffect,W=[];function B(e){const[t,n]=a.useState(0);return j(()=>{const t=e.current;if(!t)return;const a=()=>n(t.clientWidth);if(a(),"undefined"==typeof ResizeObserver)return;const l=new ResizeObserver(a);return l.observe(t),()=>l.disconnect()},[e]),t}function R(e){const[t,n]=a.useState(()=>{const t=new Set;return e.forEach((e,n)=>{e.hidden&&t.add(n)}),t}),[l,i]=a.useState(null),r=a.useCallback(e=>{n(t=>{const n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]);return{visible:e.map((e,n)=>!t.has(n)),hovered:l,toggle:r,setHovered:i}}const F={top:"flex-col-reverse",bottom:"flex-col",left:"flex-row-reverse",right:"flex-row"},E={start:"justify-start",center:"justify-center",end:"justify-end"};function H({series:a,colors:l,options:i,visibility:r,size:s,values:o,swatch:c}){const d=!1!==i.interactive,u="left"===i.side||"right"===i.side;return e("ul",{className:S("flex list-none flex-wrap items-center gap-x-3 gap-y-1 p-0",u?"min-w-0 flex-col items-start":"",E[i.align??"center"],C[s]),children:a.map((a,i)=>{const s=r.visible[i],u=null!==r.hovered&&r.hovered!==i,h=a.name??`${i+1}`,m=s?l[i]:"var(--neba-disabled-fg)",f=n(t,{children:[e("span",c?{"aria-hidden":"true",className:"flex size-2.5 shrink-0 items-center justify-center",children:c(i,m)}:{"aria-hidden":"true",className:"size-2.5 shrink-0 rounded-[0.1875rem]",style:{backgroundColor:m}}),e("span",{className:"min-w-0 truncate",children:h}),o?.[i]?e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:o[i]}):null]});return e("li",{className:"min-w-0",children:d?e("button",{type:"button","aria-pressed":s,onClick:()=>r.toggle(i),onPointerEnter:()=>r.setHovered(i),onPointerLeave:()=>r.setHovered(null),onFocus:()=>r.setHovered(i),onBlur:()=>r.setHovered(null),className:S("flex min-w-0 cursor-pointer items-center gap-1.5 rounded-(--neba-radius-xs)","px-1 py-0.5 text-(--neba-fg)",P,"hover:bg-(--n-soft)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-1",s?"":"text-(--neba-disabled-fg)",u?"opacity-55":""),children:f}):e("span",{className:S("flex min-w-0 items-center gap-1.5 px-1 py-0.5 text-(--neba-fg)",s?"":"text-(--neba-disabled-fg)"),children:f})},a.name??i)})})}function I({steps:a,from:l,to:i,middle:r,align:s,vertical:o,size:c}){return e("div",{className:S("flex",o?"":E[s]),children:n("div",{className:S("grid grid-cols-[auto_auto_auto] items-center gap-x-2",C[c]),children:[e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:l}),e("span",{"aria-hidden":"true",className:S("flex h-2.5 overflow-hidden rounded-[0.1875rem]",o?"w-20":"w-24"),children:a.map(t=>e("span",{className:"h-full flex-1",style:{backgroundColor:t}},t))}),e("span",{className:"shrink-0 tabular-nums text-(--neba-muted-fg)",children:i}),r?n(t,{children:[e("span",{}),e("span",{className:"text-center tabular-nums text-(--neba-muted-fg)",children:r}),e("span",{})]}):null]})})}function _({heading:t,items:a,x:l,y:i,flip:r,size:s}){return n("div",{role:"status","aria-live":"polite",className:S("pointer-events-none absolute z-10 max-w-56 min-w-24","rounded-(--neba-radius-sm) border p-2","[background-image:var(--neba-grain),var(--neba-sheen)]","[background-blend-mode:overlay,normal] [backdrop-filter:var(--neba-blur)]","bg-(--neba-panel-press) [border-color:var(--n-line)]","[box-shadow:var(--neba-shadow-2),var(--neba-plate-glass)]",C[s]),style:r?{right:`calc(100% - ${l}px + 10px)`,top:i}:{left:l+10,top:i},children:[e("div",{className:"mb-1 font-medium text-(--neba-fg)",children:t}),e("ul",{className:"flex list-none flex-col gap-0.5 p-0",children:a.map(t=>n("li",{className:"flex items-center gap-1.5",children:[e("span",{"aria-hidden":"true",className:"size-2 shrink-0 rounded-[0.125rem]",style:{backgroundColor:t.color}}),t.name?e("span",{className:"min-w-0 flex-1 truncate text-(--neba-muted-fg)",children:t.name}):null,e("span",{className:"ms-auto shrink-0 font-medium tabular-nums text-(--neba-fg)",children:t.label??t.formatted})]},t.seriesIndex))})]})}function T({id:t,caption:a,corner:l,categories:i,series:r,values:s,format:o,locale:c}){return n("table",{id:t,className:A,children:[a?e("caption",{children:a}):null,e("thead",{children:n("tr",{children:[e("th",{scope:"col",children:l??""}),r.map((t,n)=>e("th",{scope:"col",children:t.name??n+1},t.name??n))]})}),e("tbody",{children:i.map((t,a)=>n("tr",{children:[e("th",{scope:"row",children:m(t,c)}),r.map((t,n)=>{const l=s[n]?.[a];return e("td",void 0!==l?.label?{children:l.label}:{children:null==l?.value?"":o(l.value)},t.name??n)})]},a))})]})}function $({legend:t,legendSide:a,children:i,table:r,className:s,...o}){return n(l,{...o,className:S("relative flex gap-3",F[a],s??void 0),children:[e("div",{className:"relative min-w-0 flex-1",children:i}),t,r]})}export function CartesianChart({series:t,categories:l,xAxis:h,yAxis:g,horizontal:v=!1,stacked:A=!1,includeZero:P=!0,bandRatio:j=1,inset:F=!1,headroom:E=0,markInset:I=0,xScale:V="band",marks:D,markRadius:X=24,table:Y,swatch:Z,scale:O,markTooltip:K,height:U,format:q,locale:G,label:J,legend:Q,tooltip:ee,empty:te,size:ne="md",variant:ae="text",padded:le=!1,className:ie,children:re,...se}){const oe=a.useRef(null),ce=B(oe),de=z(N,G),ue=a.useId(),he=R(t),[me,fe]=a.useState(null),[xe,pe]=a.useState(null),[ge,be]=a.useState(null),ve=a.useCallback(e=>q?M(G,q).format(e):d(e,G),[q,G]),ye=a.useMemo(()=>y(t),[t]),ke=a.useMemo(()=>t.map((e,t)=>p(e,t)),[t]),we=s(t),Me=a.useMemo(()=>Array.from({length:we},(e,t)=>r(t,l,ye)),[we,l,ye]),Ne=ye.filter((e,t)=>he.visible[t]),ze=u(Ne,A),Se="number"==typeof U?U:void 0===U?x[ne]:null,Ce=c[ne],Ae=g,Pe=h,je=O??w(ze,{min:Ae?.min,max:Ae?.max,tickCount:Ae?.tickCount,includeZero:P}),We="value"===V?o(Ne,l):null,Be="value"===V?w(We,{min:Pe?.min,max:Pe?.max,tickCount:Pe?.tickCount,includeZero:!1}):null,Re=je.ticks.map((e,t)=>Ae?.tickFormat?String(Ae.tickFormat(e,t)):ve(e)),Fe=Be?Be.ticks.map((e,t)=>Pe?.tickFormat?String(Pe.tickFormat(e,t)):d(e,G)):Me.map((e,t)=>Pe?.tickFormat?String(Pe.tickFormat(e,t)):m(e,G)),Ee=Re.reduce((e,t)=>Math.max(e,b(t,Ce)),0),He=Ce+6,Ie=Ae?.hidden?0:Ee+10+(Ae?.label?He:0),_e=(ce-(v?0:Ie)-16)/Math.max(1,we),Te=Be?Fe:v||_e-6>=2.4*Ce?Fe.map(e=>k(e,v?150:_e-6,Ce)):Fe,$e=Te.reduce((e,t)=>Math.max(e,b(t,Ce)),0),Le=v?Pe?.hidden?0:$e+10+(Pe?.label?He:0):Ie,Ve=v?Ae?.hidden?0:Ce+12+(Ae?.label?He:0):Pe?.hidden?0:Ce+12+(Pe?.label?He:0),De=(v?Pe:Ae)?.thickness??Le,Xe=(v?Ae:Pe)?.thickness??Ve,Ye=(v||Be?12:Math.max(8,Te.length?$e/2:8))+I,Ze=f[ne]+4+E+I,Oe=Se??0,Ke={left:De+I,top:Ze,width:Math.max(0,ce-De-I-Ye),height:Math.max(0,Oe-Ze-Xe-I)},Ue=v?Ke.height:Ke.width,qe=i(F?Math.max(1,we-1):we,Ue,j),Ge=a.useCallback(e=>F?we<=1?Ue/2:Ue*e/(we-1):qe.centre(e),[F,we,Ue,qe]),Je=a.useCallback(e=>v?Ke.left+je.fraction(e)*Ke.width:Ke.top+(1-je.fraction(e))*Ke.height,[v,Ke.left,Ke.top,Ke.width,Ke.height,je]),Qe=a.useCallback((e,t)=>v?{x:Je(t),y:Ke.top+Ge(e)}:{x:Ke.left+Ge(e),y:Je(t)},[v,Je,Ge,Ke.left,Ke.top]),et=a.useCallback(e=>v?Ke.top+(1-(Be?.fraction(e)??0))*Ke.height:Ke.left+(Be?.fraction(e)??0)*Ke.width,[v,Ke.left,Ke.top,Ke.width,Ke.height,Be]),tt=Je(Math.min(Math.max(0,je.min),je.max)),nt={plot:Ke,values:ye,visible:he.visible,colors:ke,scale:je,band:qe,horizontal:v,valuePx:Je,categoryPx:Ge,point:Qe,categoryScale:Be,categoryValuePx:et,zeroPx:tt,categories:Me,format:ve,size:ne},at=D?D(nt):W,lt=!1===ee?{mode:"none"}:!0===ee||void 0===ee?{}:ee,it=lt.mode??(D?"item":"index"),rt=null===xe?null:at[xe]??null,st=D?rt?rt.index:null:me,ot=D?at.length:we,ct=()=>{fe(null),pe(null),be(null)},dt=e=>{const t=null===e?null:Math.min(ot-1,Math.max(0,e));D?pe(t):fe(t)},ut=e=>{be(null);dt(((D?xe:me)??(e>0?-1:ot))+e)},ht=null===st?[]:t.flatMap((e,t)=>{if(!he.visible[t]||rt&&rt.series!==t)return[];const n=ye[t]?.[st];return n&&null!==n.value?[{seriesIndex:t,name:e.name,color:n.color??ke[t],value:n.value,formatted:ve(n.value),label:n.label}]:[]}),mt=rt&&K?K(rt):null,ft=mt?mt.items:"item"===it&&ht.length>1&&null!==ge?[ht.reduce((e,t)=>Math.abs(Je(t.value??0)-ge)<Math.abs(Je(e.value??0)-ge)?t:e)]:ht,xt=rt?ye[rt.series]?.[rt.index]?.x??l?.[rt.index]??rt.index:void 0,pt=rt?rt.x:v?Je(ft[0]?.value??0):Ke.left+Ge(st??0),gt=rt?rt.y:v?Ke.top+Ge(st??0):Ke.top,bt=rt?(rt.x-Ke.left)/Math.max(1,Ke.width)>.6:(v?je.fraction(ft[0]?.value??0):Ge(st??0)/Math.max(1,Ue))>.6,vt=!1===Q?{interactive:!1}:!0===Q||void 0===Q?{}:Q,yt=!0===Q||!1!==Q&&t.length>1,kt=vt.side??"bottom",wt={...nt,hovered:he.hovered,activeIndex:st,marks:at,activeMark:rt},Mt=0===we||null===ze||"value"===V&&null===We;return e($,{...se,size:ne,variant:ae,padded:le,className:ie,legendSide:kt,legend:yt?e(H,{series:t,colors:ke,options:vt,visibility:he,size:ne,swatch:Z,values:vt.showValue&&null!==st?t.map((e,t)=>{const n=ye[t]?.[st]?.value;return null==n?void 0:ve(n)}):void 0}):null,table:Mt?null:Y?.(ue)??e(T,{id:ue,caption:J,corner:Pe?.label,categories:Me,series:t,values:ye,format:ve,locale:G}),children:n("div",{ref:oe,role:"img",tabIndex:Mt?void 0:0,"aria-label":J,"aria-describedby":Mt?void 0:ue,onPointerMove:e=>{"none"!==it&&(D?pe(((e,t)=>{const n=oe.current;if(!n||0===at.length)return null;const a=n.getBoundingClientRect(),l=e-a.left,i=t-a.top;let r=null,s=1/0,o=1/0;return at.forEach((e,t)=>{const n=Math.hypot(e.x-l,e.y-i),a=void 0===e.rx?Math.max(0,n-e.r):Math.hypot(Math.max(0,Math.abs(e.x-l)-e.rx),Math.max(0,Math.abs(e.y-i)-(e.ry??e.rx)));a<=X&&(a<s||a===s&&n<o)&&(s=a,o=n,r=t)}),r})(e.clientX,e.clientY)):fe(((e,t)=>{const n=oe.current;if(!n||0===we)return null;const a=n.getBoundingClientRect(),l=v?t-a.top-Ke.top:e-a.left-Ke.left;if(l<-qe.step||l>Ue+qe.step)return null;const i=F?we<=1?0:Math.round(l/Ue*(we-1)):Math.floor(l/qe.step);return Math.min(we-1,Math.max(0,i))})(e.clientX,e.clientY)),"item"===it&&be(((e,t)=>{const n=oe.current;if(!n)return null;const a=n.getBoundingClientRect();return v?e-a.left:t-a.top})(e.clientX,e.clientY)))},onPointerLeave:ct,onKeyDown:"none"===it?void 0:e=>{const t=v?"ArrowDown":"ArrowRight",n=v?"ArrowUp":"ArrowLeft";if(e.key===t)ut(1);else if(e.key===n)ut(-1);else if("Home"===e.key)dt(0);else if("End"===e.key)dt(ot-1);else{if("Escape"!==e.key)return;ct()}e.preventDefault()},onBlur:ct,className:S("relative w-full","rounded-(--neba-radius-xs)","focus-visible:[outline:2px_solid_var(--n-ring)] focus-visible:outline-offset-2"),style:{height:Se??U},children:[Mt?e("div",{className:S("flex h-full items-center justify-center text-(--neba-muted-fg)",C[ne]),children:te??de.title}):ce>0?n("svg",{width:ce,height:Oe||"100%",viewBox:`0 0 ${ce} ${Oe}`,"aria-hidden":"true",className:"block overflow-visible",children:[e(L,{plot:Ke,scale:je,band:qe,horizontal:v,inset:F,categoryPx:Ge,valuePx:Je,tickTexts:Re,categoryTexts:Te,categoryScale:Be,categoryValuePx:et,valueAxis:Ae,categoryAxis:Pe,fontSize:Ce,zeroPx:tt}),null===st||D||"index"!==it||!1===lt.crosshair?null:(()=>{const t=Ge(st);return e("line",v?{x1:Ke.left,x2:Ke.left+Ke.width,y1:Ke.top+t,y2:Ke.top+t,stroke:"var(--neba-chart-baseline)",strokeWidth:1}:{x1:Ke.left+t,x2:Ke.left+t,y1:Ke.top,y2:Ke.top+Ke.height,stroke:"var(--neba-chart-baseline)",strokeWidth:1})})(),re(wt)]}):null,null!==st&&ft.length>0&&"none"!==it?lt.render?e("div",{className:"pointer-events-none absolute z-10",style:bt?{right:`calc(100% - ${pt}px + 10px)`,top:gt}:{left:pt+10,top:gt},children:lt.render({index:st,category:xt??Me[st],items:ft})}):e(_,{heading:mt?mt.heading:m(xt??Me[st],G),items:ft,x:pt,y:gt,flip:bt,size:ne}):null]})})}function L({plot:a,scale:l,horizontal:i,categoryPx:r,valuePx:s,tickTexts:o,categoryTexts:c,categoryScale:d,categoryValuePx:u,valueAxis:m,categoryAxis:f,fontSize:x,zeroPx:p}){const y=!1!==m?.grid&&!m?.hidden,k=!f?.hidden&&(f?.grid??null!==d),w=e=>d?u(d.ticks[e]):(i?a.top:a.left)+r(e),M=v(c.length,i?a.height:a.width,i?1.8*x:Math.max(...c.map(e=>b(e,x)),1)+12),N=v(l.ticks.length,i?a.width:a.height,i?Math.max(...o.map(e=>b(e,x)),1)+16:2*x),z=c.length>1?Math.abs(w(1)-w(0)):a.width,S=l.ticks.length>1?Math.abs(s(l.ticks[1])-s(l.ticks[0])):a.height,C=h(c.length,M,z,i?1.8*x:b(c[c.length-1]??"",x)),A=h(l.ticks.length,N,S,i?b(o[o.length-1]??"",x):1.6*x);return n("g",{children:[l.ticks.map((t,r)=>{const c=s(t),d=Math.abs(t)<1e-9;return n("g",{children:[y?e("line",i?{x1:c,x2:c,y1:a.top,y2:a.top+a.height,stroke:d?"var(--neba-chart-baseline)":"var(--neba-chart-grid)",strokeWidth:1}:{x1:a.left,x2:a.left+a.width,y1:c,y2:c,stroke:d?"var(--neba-chart-baseline)":"var(--neba-chart-grid)",strokeWidth:1}):null,m?.hidden||!g(r,l.ticks.length,N,A)?null:e("text",i?{x:c,y:a.top+a.height+x+6,textAnchor:0===r?"start":r===l.ticks.length-1?"end":"middle",fontSize:x,fill:"var(--neba-muted-fg)",className:"tabular-nums",children:o[r]}:{x:a.left-8,y:c,textAnchor:"end",dominantBaseline:"central",fontSize:x,fill:"var(--neba-muted-fg)",className:"tabular-nums",children:o[r]})]},t)}),f?.hidden?null:n(t,{children:[e("line",i?{x1:p,x2:p,y1:a.top,y2:a.top+a.height,stroke:"var(--neba-chart-axis)",strokeWidth:1}:{x1:a.left,x2:a.left+a.width,y1:p,y2:p,stroke:"var(--neba-chart-axis)",strokeWidth:1}),c.map((t,l)=>{const r=w(l),s=g(l,c.length,M,C);return i?s?e("text",{x:a.left-8,y:r,textAnchor:"end",dominantBaseline:"central",fontSize:x,fill:"var(--neba-muted-fg)",className:d?"tabular-nums":void 0,children:t},l):null:n("g",{children:[k?e("line",{x1:r,x2:r,y1:a.top,y2:a.top+a.height,stroke:"var(--neba-chart-grid)",strokeWidth:1}):null,s?e("text",{x:r,y:a.top+a.height+x+6,textAnchor:d?0===l?"start":l===c.length-1?"end":"middle":"middle",fontSize:x,fill:"var(--neba-muted-fg)",className:d?"tabular-nums":void 0,children:t}):null]},l)})]}),m?.label?e("text",{x:i?a.left+a.width:a.left,y:i?a.top+a.height+2*x+12:a.top-8,textAnchor:i?"end":"start",fontSize:x,fill:"var(--neba-muted-fg)",fontWeight:500,children:m.label}):null,f?.label&&!i?e("text",{x:a.left+a.width,y:a.top+a.height+2*x+12,textAnchor:"end",fontSize:x,fill:"var(--neba-muted-fg)",fontWeight:500,children:f.label}):null]})}export{T as ChartDataTable,H as ChartLegendBar,I as ChartScaleLegend,$ as ChartSurface,_ as ChartTooltipPanel,B as useMeasuredWidth,R as useVisibility};
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
* the thing that makes it a sparkline.
|
|
14
14
|
*/
|
|
15
15
|
import * as React from 'react';
|
|
16
|
-
import type { CartesianContext } from './chart-frame';
|
|
17
|
-
import type { NebaChartCurve, NebaChartValueLabels } from '../types';
|
|
16
|
+
import type { CartesianContext } from './chart-frame.js';
|
|
17
|
+
import type { NebaChartCurve, NebaChartValueLabels } from '../types.js';
|
|
18
18
|
/** Whether a point gets a dot on it. */
|
|
19
19
|
export type ChartMarkers = 'none' | 'auto' | 'all';
|
|
20
20
|
export interface LineSeriesProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as l,jsxs as e}from"react/jsx-runtime";import{areaPath as t,chartFontSizes as r,linePath as n,lineWidths as o,markerRadii as a,markGap as i}from"./chart";export function LineSeries({context:
|
|
1
|
+
import{jsx as l,jsxs as e}from"react/jsx-runtime";import{areaPath as t,chartFontSizes as r,linePath as n,lineWidths as o,markerRadii as a,markGap as i}from"./chart.js";export function LineSeries({context:s,curve:u,filled:f,stacked:c,markers:p,valueLabels:d,connectNulls:x,gradient:h,idPrefix:m}){const{values:v,visible:k,colors:$,hovered:b,activeIndex:y,plot:g,point:j,zeroPx:C,size:L,format:W}=s,z=o[L],B=a[L],E=k.indexOf(!0),G=[],M=[];return v.forEach((l,e)=>{const t=l.map((l,e)=>M[e]??0);G.push(t),c&&k[e]&&l.forEach((l,e)=>{M[e]=(M[e]??0)+(l.value??0)})}),e("g",{children:[e("defs",{children:[h?$.map((t,r)=>e("linearGradient",{id:`${m}-stroke-${r}`,x1:"0",y1:"0",x2:"1",y2:"0",children:[l("stop",{offset:"0%",stopColor:`color-mix(in oklab, ${t} 45%, transparent)`}),l("stop",{offset:"100%",stopColor:t})]},`stroke-${r}`)):null,f&&!c?$.map((t,r)=>e("linearGradient",{id:`${m}-fill-${r}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[l("stop",{offset:"0%",stopColor:`color-mix(in oklab, ${t} 28%, transparent)`}),l("stop",{offset:"100%",stopColor:`color-mix(in oklab, ${t} 2%, transparent)`})]},`fill-${r}`)):null]}),v.map((o,a)=>{if(!k[a])return null;const s=$[a],v=null!==b&&b!==a,M=o.map((l,e)=>{if(null===l.value)return null;const t=c?G[a][e]+l.value:l.value;return j(e,t)}),N=x?M.filter(Boolean):M,P=o.map((l,e)=>null===l.value?null:c?j(e,G[a][e]):{x:j(e,l.value).x,y:C}),S=f&&c,w=function(l,e){if("all"===e)return()=>!0;if("last"===e){let e=-1;for(let t=l.length-1;t>=0;t--)if(null!==l[t].value){e=t;break}return l=>l===e}let t=1/0,r=-1/0;for(const e of l)null!==e.value&&(t=Math.min(t,e.value),r=Math.max(r,e.value));return e=>{const n=l[e].value;return null!==n&&(n===t||n===r)}}(o,d);return e("g",{opacity:v?.28:1,children:[f?l("path",{d:t(N,x?P.filter(Boolean):P,u),fill:c?`color-mix(in oklab, ${s} 70%, transparent)`:`url(#${m}-fill-${a})`,stroke:"none"}):null,S&&a!==E?l("path",{d:n(x?P.filter(Boolean):P,u),fill:"none",stroke:"var(--neba-chart-gap)",strokeWidth:i}):null,S?null:l("path",{d:n(N,u),fill:"none",stroke:h?`url(#${m}-stroke-${a})`:s,strokeWidth:z,strokeLinecap:"round",strokeLinejoin:"round"}),M.map((e,t)=>{if(!e)return null;return"all"===p||"auto"===p&&o.length<=14||t===y?l("circle",{cx:e.x,cy:e.y,r:t===y?B+1:B,fill:o[t].color??s,stroke:"var(--neba-chart-gap)",strokeWidth:i},t):null}),"none"===d?null:M.map((e,t)=>{const n=o[t].value;return e&&null!==n&&w(t)?l("text",{x:e.x,y:e.y-B-5,textAnchor:e.x>g.left+g.width-24?"end":e.x<g.left+24?"start":"middle",fontSize:r[L],fontWeight:500,fill:"var(--neba-fg)",className:"tabular-nums",children:o[t].label??W(n)},`label-${t}`):null})]},a)})]})}
|
package/dist/internal/chart.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* one runtime dependency, which is the same trade `color.ts` makes.
|
|
16
16
|
*/
|
|
17
17
|
import type * as React from 'react';
|
|
18
|
-
import type { NebaChartCategory, NebaChartDatum, NebaChartSeries, NebaDensity, NebaSize } from '../types';
|
|
18
|
+
import type { NebaChartCategory, NebaChartDatum, NebaChartSeries, NebaDensity, NebaSize } from '../types.js';
|
|
19
19
|
/**
|
|
20
20
|
* How tall a plot is when nobody said, in pixels.
|
|
21
21
|
*
|
package/dist/internal/chart.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dateFormatter as t,numberFormatter as e}from"./format";export const plotHeights={xs:120,sm:160,md:220,lg:280,xl:360};export const sparklineHeights={xs:16,sm:20,md:28,lg:40,xl:56};export const lineWidths={xs:1.5,sm:1.75,md:2,lg:2.25,xl:2.5};export const markerRadii={xs:3,sm:3.5,md:4,lg:4.5,xl:5};export const chartFontSizes={xs:10,sm:11,md:12,lg:13,xl:14};export const barMaxThickness={xs:14,sm:18,md:24,lg:30,xl:36};export const barBandRatio={default:.62,compact:.82};export const markGap=2;export const barRadius=4;export const chartPalette=["var(--neba-chart-1)","var(--neba-chart-2)","var(--neba-chart-3)","var(--neba-chart-4)","var(--neba-chart-5)","var(--neba-chart-6)","var(--neba-chart-7)","var(--neba-chart-8)"];const n=new Set(["primary","secondary","success","warning","danger","info"]);export function resolveColor(t){return n.has(t)?`var(--neba-${t}-accent)`:t}export function seriesColor(t,e,n=chartPalette){return resolveColor(t?.color?t.color:n[e%n.length]??chartPalette[0])}export function toValue(t){return null==t?{value:null}:"number"==typeof t?{value:Number.isFinite(t)?t:null}:(t=>"object"==typeof t&&null!==t)(t)?{value:null!==t.y&&Number.isFinite(t.y)?t.y:null,x:t.x,z:t.z,color:t.color?resolveColor(t.color):void 0,label:t.label}:{value:null}}export function toValues(t){return t.map(t=>t.data.map(toValue))}export function toNumber(t){return t instanceof Date?Number.isFinite(t.getTime())?t.getTime():null:"number"==typeof t&&Number.isFinite(t)?t:null}export function pointX(t,e,n){return toNumber(t.x??n?.[e]??e)}export function categoryExtent(t,e){let n=1/0,r=-1/0,o=!1;return t.forEach(t=>{t.forEach((t,a)=>{if(null===t.value)return;const i=pointX(t,a,e);null!==i&&(o=!0,n=Math.min(n,i),r=Math.max(r,i))})}),o?{min:n,max:r}:null}export function bubbleRadius(t,e,n,r){return e>0&&Number.isFinite(t)&&!(t<=0)?Math.max(r,Math.sqrt(Math.min(t,e)/e)*n):0===t?0:r}export function categoryCount(t){return t.reduce((t,e)=>Math.max(t,e.data.length),0)}export function categoryAt(t,e,n){if(e&&t<e.length)return e[t];for(const e of n){const n=e[t]?.x;if(void 0!==n)return n}return t}export function extentOf(t,e){let n=1/0,r=-1/0,o=!1;if(e){const e=t.reduce((t,e)=>Math.max(t,e.length),0);for(let a=0;a<e;a++){let e=0,i=0;for(const n of t){const t=n[a]?.value;null!=t&&(o=!0,t>=0?e+=t:i+=t)}n=Math.min(n,i),r=Math.max(r,e)}}else for(const e of t)for(const{value:t}of e)null!==t&&(o=!0,n=Math.min(n,t),r=Math.max(r,t));return o?{min:n,max:r}:null}function r(t){const e=10**Math.floor(Math.log10(t)),n=t/e;return n<=1?e:n<=2?2*e:n<=5?5*e:10*e}export function valueScale(t,e={}){const{tickCount:n=5,includeZero:o=!0}=e;let a=e.min??(t?t.min:0),i=e.max??(t?t.max:1);if(o&&void 0===e.min&&(a=Math.min(a,0)),o&&void 0===e.max&&(i=Math.max(i,0)),i===a){const t=Math.abs(i)>0?.5*Math.abs(i):1;a-=t,i+=t}const u=void 0!==e.min&&void 0!==e.max?function(t,e){const n=10**Math.floor(Math.log10(t/Math.max(1,e)));let o=r(t/Math.max(1,e)),a=1/0;for(const r of[.1,1,10])for(const i of[1,2,2.5,5]){const u=i*r*n,s=t/u,c=Math.round(s);if(c<1||Math.abs(s-c)>1e-9)continue;const l=Math.abs(c-e);l<a&&(a=l,o=u)}return o}(i-a,n):r((i-a)/Math.max(1,n)),s=void 0!==e.min?a:Math.floor(a/u)*u,c=void 0!==e.max?i:Math.ceil(i/u)*u,l=c-s||1,h=[];for(let t=s;t<=c+1e-9*u;t+=u)h.push(Number(t.toFixed(12)));return{min:s,max:c,ticks:h,fraction:t=>(t-s)/l}}const o=1e3,a=6e4,i=36e5,u=24*i,s=[{unit:"second",count:1,size:o},{unit:"second",count:5,size:5e3},{unit:"second",count:15,size:15e3},{unit:"second",count:30,size:3e4},{unit:"minute",count:1,size:a},{unit:"minute",count:5,size:3e5},{unit:"minute",count:15,size:9e5},{unit:"minute",count:30,size:18e5},{unit:"hour",count:1,size:i},{unit:"hour",count:3,size:3*i},{unit:"hour",count:6,size:6*i},{unit:"hour",count:12,size:12*i},{unit:"day",count:1,size:u},{unit:"day",count:2,size:2*u},{unit:"week",count:1,size:7*u},{unit:"week",count:2,size:14*u},{unit:"month",count:1,size:30*u},{unit:"quarter",count:1,size:91*u},{unit:"month",count:6,size:182*u},{unit:"year",count:1,size:365*u}];function c(t,e,n){const r=new Date(t);if("year"===e)r.setFullYear(r.getFullYear()+n);else if("quarter"===e)r.setMonth(r.getMonth()+3*n);else if("month"===e)r.setMonth(r.getMonth()+n);else if("week"===e)r.setDate(r.getDate()+7*n);else if("day"===e)r.setDate(r.getDate()+n);else{if("hour"!==e)return t+n*("minute"===e?a:o);r.setHours(r.getHours()+n)}return r.getTime()}const l={second:"minute",minute:"hour",hour:"day",day:"month",week:"week",month:"year",quarter:"year",year:"year"};function h(t,e,n){let r=function(t,e){const n=new Date(t);if("year"===e)return new Date(n.getFullYear(),0,1).getTime();if("quarter"===e)return new Date(n.getFullYear(),3*Math.floor(n.getMonth()/3),1).getTime();if("month"===e)return new Date(n.getFullYear(),n.getMonth(),1).getTime();if("week"===e){const t=new Date(n.getFullYear(),n.getMonth(),n.getDate());return t.setDate(t.getDate()-t.getDay()),t.getTime()}return"day"===e?new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime():"hour"===e?new Date(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours()).getTime():"minute"===e?Math.floor(t/a)*a:Math.floor(t/o)*o}(t,l[e]);if("year"===e&&n>1){const t=new Date(r).getFullYear();r=new Date(t-(t%n+n)%n,0,1).getTime()}for(let o=0;o<500;o++){const o=c(r,e,n);if(o>t)return r;r=o}return r}export function timeScale(t,e={}){const{tickCount:n=6}=e;let o=e.min??t?.min??Date.parse("2000-01-01T00:00:00"),a=e.max??t?.max??o+u;a<=o&&(o-=u/2,a+=u/2);const i=a-o;let l=s[0],m=1/0;for(const t of s){const e=Math.abs(i/t.size-n);e<m&&(m=e,l=t)}const f=l.unit,$="year"===f?Math.max(1,Math.round(r(i/n/(365*u)))):l.count,x=e.min??h(o,f,$),p=[];let M=x;for(let t=0;t<500&&(p.push(M),!(M>a));t++)M=c(M,f,$);const g=e.max??p[p.length-1],d=g-x||1;return{min:x,max:g,ticks:p.filter(t=>t>=x&&t<=g),unit:f,step:$,fraction:t=>(t-x)/d}}function m(t,e){if("second"===t)return{hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"};if("minute"===t||"hour"===t)return{hour:"2-digit",minute:"2-digit",hourCycle:"h23"};if("year"===t)return{year:"numeric"};const n="month"===t||"quarter"===t?{month:"short"}:{month:"short",day:"numeric"};return e?{...n,year:"numeric"}:n}export function formatTimeValue(e,n,r){return t(r,m(n,!0)).format(new Date(e))}export function formatTimeTicks(e,n,r){const o=new Set(e.map(t=>new Date(t).getFullYear())).size>1;return e.map((e,a)=>t(r,m(n,o||0===a)).format(new Date(e)))}export function tickStride(t,e,n){if(t<=1||e<=0)return 1;const r=Math.max(1,Math.floor(e/Math.max(1,n)));return Math.max(1,Math.ceil(t/r))}export function showsTick(t,e,n,r){return t%n===0||r&&t===e-1}export function fitsLast(t,e,n,r){const o=(t-1)%e;return o>0&&o*n>=r+8}export function textWidth(t,e){let n=0;for(const e of t)n+=/[ᄀ-ᇿ⺀-가-豈-︰-﹏]/.test(e)?1:.6;return n*e}export function truncate(t,e,n){if(e<=0||textWidth(t,n)<=e)return t;const r=e-textWidth("…",n);let o="",a=0;for(const e of t){const t=a+textWidth(e,n);if(t>r)break;a=t,o+=e}return o.length>0?`${o.trimEnd()}…`:"…"}export function bandScale(t,e,n){const r=t>0?e/t:e;return{step:r,band:r*n,centre:t=>r*(t+.5)}}export function linePath(t,e){const n=[];let r=[];const o=()=>{if(0!==r.length){if(1===r.length)n.push(`M${r[0].x} ${r[0].y}h0`);else if("step"===e){n.push(`M${r[0].x} ${r[0].y}`);for(let t=1;t<r.length;t++){const e=(r[t-1].x+r[t].x)/2;n.push(`H${e}V${r[t].y}H${r[t].x}`)}}else if("smooth"===e)n.push(`M${r[0].x} ${r[0].y}`),n.push(function(t){const e=t.length,n=[];for(let r=0;r<e-1;r++){const e=t[r+1].x-t[r].x;n.push(0===e?0:(t[r+1].y-t[r].y)/e)}const r=[n[0]??0];for(let t=1;t<e-1;t++){const e=n[t-1],o=n[t];r.push(e*o<=0?0:2*e*o/(e+o))}r.push(n[e-2]??0);const o=[];for(let n=0;n<e-1;n++){const e=(t[n+1].x-t[n].x)/3;o.push(`C${t[n].x+e} ${t[n].y+r[n]*e} ${t[n+1].x-e} ${t[n+1].y-r[n+1]*e} ${t[n+1].x} ${t[n+1].y}`)}return o.join("")}(r));else{n.push(`M${r[0].x} ${r[0].y}`);for(let t=1;t<r.length;t++)n.push(`L${r[t].x} ${r[t].y}`)}r=[]}};for(const e of t)null===e?o():r.push(e);return o(),n.join("")}export function areaPath(t,e,n){const r=[];let o=0;const a=a=>{const i=t.slice(o,a).filter(Boolean);if(0===i.length)return;const u="number"==typeof e?i.map(t=>({x:t.x,y:e})).reverse():e.slice(o,a).filter(Boolean).reverse();if(0===u.length)return;const s=linePath(i,n),c=linePath(u,n).replace(/^M/,"L");r.push(`${s}${c}Z`)};for(let e=0;e<t.length;e++)null===t[e]&&(a(e),o=e+1);return a(t.length),r.join("")}export function barPath(t,e,n,r,o,a){const i=Math.max(0,Math.min(o,n/2,r/2));if(0===i||n<=0||r<=0)return`M${t} ${e}h${n}v${r}h${-n}Z`;const u=(t,e)=>`a${i} ${i} 0 0 1 ${t} ${e}`;return"up"===a?`M${t} ${e+r}V${e+i}${u(i,-i)}H${t+n-i}${u(i,i)}V${e+r}Z`:"down"===a?`M${t} ${e}H${t+n}V${e+r-i}${u(-i,i)}H${t+i}${u(-i,-i)}Z`:"right"===a?`M${t} ${e}H${t+n-i}${u(i,i)}V${e+r-i}${u(-i,i)}H${t}Z`:`M${t+n} ${e+r}H${t+i}${u(-i,-i)}V${e+i}${u(i,-i)}H${t+n}Z`}export const markShapes=["circle","square","triangle","diamond","cross"];const f={circle:1,square:.8862,triangle:1.5551,diamond:1.2533,cross:1.189};export function markPath(t,e,n,r){const o=Math.max(0,r)*f[t];if(0===o)return"";if("circle"===t)return`M${e-o} ${n}a${o} ${o} 0 1 0 ${2*o} 0a${o} ${o} 0 1 0 ${2*-o} 0Z`;if("square"===t)return`M${e-o} ${n-o}h${2*o}v${2*o}h${2*-o}Z`;if("diamond"===t)return`M${e} ${n-o}L${e+o} ${n}L${e} ${n+o}L${e-o} ${n}Z`;if("triangle"===t){return`M${[0,120,240].map(t=>{const r=(t-90)*Math.PI/180;return`${e+o*Math.cos(r)} ${n+o*Math.sin(r)}`}).join("L")}Z`}const a=o/3;return`M${e-a} ${n-o}h${2*a}v${o-a}h${o-a}v${2*a}h${-(o-a)}v${o-a}h${2*-a}v${-(o-a)}h${-(o-a)}v${2*-a}h${o-a}Z`}export function arcPath(t,e,n,r,o,a){const i=(n,r)=>{const o=(r-90)*Math.PI/180;return`${t+n*Math.cos(o)} ${e+n*Math.sin(o)}`};if(Math.abs(a-o)>=360){const t=o+180;return r>0?`M${i(n,o)}A${n} ${n} 0 1 1 ${i(n,t)}A${n} ${n} 0 1 1 ${i(n,o)}ZM${i(r,o)}A${r} ${r} 0 1 0 ${i(r,t)}A${r} ${r} 0 1 0 ${i(r,o)}Z`:`M${i(n,o)}A${n} ${n} 0 1 1 ${i(n,t)}A${n} ${n} 0 1 1 ${i(n,o)}Z`}const u=Math.abs(a-o)>180?1:0;return r<=0?`M${t} ${e}L${i(n,o)}A${n} ${n} 0 ${u} 1 ${i(n,a)}Z`:`M${i(n,o)}A${n} ${n} 0 ${u} 1 ${i(n,a)}L${i(r,a)}A${r} ${r} 0 ${u} 0 ${i(r,o)}Z`}export const rampSteps=5;export function rampStep(t,e,n,r,o=0){if("diverging"===r){const r=Math.max(Math.abs(n-o),Math.abs(o-e));if(!(r>0))return 2;const a=(t-o)/r;return Math.min(4,Math.max(0,2+Math.round(2*a)))}const a=n-e;return a>0?Math.min(4,Math.max(0,Math.floor((t-e)/a*5))):4}export function rampFill(t,e){return`var(--neba-chart-${"diverging"===e?"div":"seq"}-${t+1})`}export function rampInk(t,e){return`var(--neba-chart-${"diverging"===e?"div":"seq"}-on-${t+1})`}export function squarify(t,e,n){const r=t.reduce((t,e)=>t+Math.max(0,e),0);if(!(r>0)||e<=0||n<=0)return[];const o=e*n/r,a=t.map((t,e)=>({index:e,area:Math.max(0,t)*o})).filter(t=>t.area>0).sort((t,e)=>e.area-t.area),i=[];let u=0,s=0,c=e,l=n,h=[];const m=t=>{const e=Math.min(c,l),n=t.reduce((t,e)=>t+e.area,0);if(!(n>0&&e>0))return 1/0;const r=t[0].area,o=t[t.length-1].area;return Math.max(e*e*r/(n*n),n*n/(e*e*o))},f=()=>{const t=h.reduce((t,e)=>t+e.area,0),e=Math.min(c,l),n=e>0?t/e:0,r=c>=l;let o=0;for(const t of h){const e=n>0?t.area/n:0;i.push(r?{index:t.index,x:u,y:s+o,width:n,height:e}:{index:t.index,x:u+o,y:s,width:e,height:n}),o+=e}r?(u+=n,c-=n):(s+=n,l-=n),h=[]};for(const t of a)0===h.length||m([...h,t])<=m(h)||f(),h.push(t);return h.length>0&&f(),i}const $={month:"short",day:"numeric"},x={notation:"compact",maximumFractionDigits:1},p={maximumFractionDigits:2};export function formatCategory(e,n){return e instanceof Date?t(n,$).format(e):String(e)}export function compactNumber(t,n){return Math.abs(t)>=1e4?e(n,x).format(t):e(n,p).format(t)}
|
|
1
|
+
import{dateFormatter as t,numberFormatter as e}from"./format.js";export const plotHeights={xs:120,sm:160,md:220,lg:280,xl:360};export const sparklineHeights={xs:16,sm:20,md:28,lg:40,xl:56};export const lineWidths={xs:1.5,sm:1.75,md:2,lg:2.25,xl:2.5};export const markerRadii={xs:3,sm:3.5,md:4,lg:4.5,xl:5};export const chartFontSizes={xs:10,sm:11,md:12,lg:13,xl:14};export const barMaxThickness={xs:14,sm:18,md:24,lg:30,xl:36};export const barBandRatio={default:.62,compact:.82};export const markGap=2;export const barRadius=4;export const chartPalette=["var(--neba-chart-1)","var(--neba-chart-2)","var(--neba-chart-3)","var(--neba-chart-4)","var(--neba-chart-5)","var(--neba-chart-6)","var(--neba-chart-7)","var(--neba-chart-8)"];const n=new Set(["primary","secondary","success","warning","danger","info"]);export function resolveColor(t){return n.has(t)?`var(--neba-${t}-accent)`:t}export function seriesColor(t,e,n=chartPalette){return resolveColor(t?.color?t.color:n[e%n.length]??chartPalette[0])}export function toValue(t){return null==t?{value:null}:"number"==typeof t?{value:Number.isFinite(t)?t:null}:(t=>"object"==typeof t&&null!==t)(t)?{value:null!==t.y&&Number.isFinite(t.y)?t.y:null,x:t.x,z:t.z,color:t.color?resolveColor(t.color):void 0,label:t.label}:{value:null}}export function toValues(t){return t.map(t=>t.data.map(toValue))}export function toNumber(t){return t instanceof Date?Number.isFinite(t.getTime())?t.getTime():null:"number"==typeof t&&Number.isFinite(t)?t:null}export function pointX(t,e,n){return toNumber(t.x??n?.[e]??e)}export function categoryExtent(t,e){let n=1/0,r=-1/0,o=!1;return t.forEach(t=>{t.forEach((t,a)=>{if(null===t.value)return;const i=pointX(t,a,e);null!==i&&(o=!0,n=Math.min(n,i),r=Math.max(r,i))})}),o?{min:n,max:r}:null}export function bubbleRadius(t,e,n,r){return e>0&&Number.isFinite(t)&&!(t<=0)?Math.max(r,Math.sqrt(Math.min(t,e)/e)*n):0===t?0:r}export function categoryCount(t){return t.reduce((t,e)=>Math.max(t,e.data.length),0)}export function categoryAt(t,e,n){if(e&&t<e.length)return e[t];for(const e of n){const n=e[t]?.x;if(void 0!==n)return n}return t}export function extentOf(t,e){let n=1/0,r=-1/0,o=!1;if(e){const e=t.reduce((t,e)=>Math.max(t,e.length),0);for(let a=0;a<e;a++){let e=0,i=0;for(const n of t){const t=n[a]?.value;null!=t&&(o=!0,t>=0?e+=t:i+=t)}n=Math.min(n,i),r=Math.max(r,e)}}else for(const e of t)for(const{value:t}of e)null!==t&&(o=!0,n=Math.min(n,t),r=Math.max(r,t));return o?{min:n,max:r}:null}function r(t){const e=10**Math.floor(Math.log10(t)),n=t/e;return n<=1?e:n<=2?2*e:n<=5?5*e:10*e}export function valueScale(t,e={}){const{tickCount:n=5,includeZero:o=!0}=e;let a=e.min??(t?t.min:0),i=e.max??(t?t.max:1);if(o&&void 0===e.min&&(a=Math.min(a,0)),o&&void 0===e.max&&(i=Math.max(i,0)),i===a){const t=Math.abs(i)>0?.5*Math.abs(i):1;a-=t,i+=t}const u=void 0!==e.min&&void 0!==e.max?function(t,e){const n=10**Math.floor(Math.log10(t/Math.max(1,e)));let o=r(t/Math.max(1,e)),a=1/0;for(const r of[.1,1,10])for(const i of[1,2,2.5,5]){const u=i*r*n,s=t/u,c=Math.round(s);if(c<1||Math.abs(s-c)>1e-9)continue;const l=Math.abs(c-e);l<a&&(a=l,o=u)}return o}(i-a,n):r((i-a)/Math.max(1,n)),s=void 0!==e.min?a:Math.floor(a/u)*u,c=void 0!==e.max?i:Math.ceil(i/u)*u,l=c-s||1,h=[];for(let t=s;t<=c+1e-9*u;t+=u)h.push(Number(t.toFixed(12)));return{min:s,max:c,ticks:h,fraction:t=>(t-s)/l}}const o=1e3,a=6e4,i=36e5,u=24*i,s=[{unit:"second",count:1,size:o},{unit:"second",count:5,size:5e3},{unit:"second",count:15,size:15e3},{unit:"second",count:30,size:3e4},{unit:"minute",count:1,size:a},{unit:"minute",count:5,size:3e5},{unit:"minute",count:15,size:9e5},{unit:"minute",count:30,size:18e5},{unit:"hour",count:1,size:i},{unit:"hour",count:3,size:3*i},{unit:"hour",count:6,size:6*i},{unit:"hour",count:12,size:12*i},{unit:"day",count:1,size:u},{unit:"day",count:2,size:2*u},{unit:"week",count:1,size:7*u},{unit:"week",count:2,size:14*u},{unit:"month",count:1,size:30*u},{unit:"quarter",count:1,size:91*u},{unit:"month",count:6,size:182*u},{unit:"year",count:1,size:365*u}];function c(t,e,n){const r=new Date(t);if("year"===e)r.setFullYear(r.getFullYear()+n);else if("quarter"===e)r.setMonth(r.getMonth()+3*n);else if("month"===e)r.setMonth(r.getMonth()+n);else if("week"===e)r.setDate(r.getDate()+7*n);else if("day"===e)r.setDate(r.getDate()+n);else{if("hour"!==e)return t+n*("minute"===e?a:o);r.setHours(r.getHours()+n)}return r.getTime()}const l={second:"minute",minute:"hour",hour:"day",day:"month",week:"week",month:"year",quarter:"year",year:"year"};function h(t,e,n){let r=function(t,e){const n=new Date(t);if("year"===e)return new Date(n.getFullYear(),0,1).getTime();if("quarter"===e)return new Date(n.getFullYear(),3*Math.floor(n.getMonth()/3),1).getTime();if("month"===e)return new Date(n.getFullYear(),n.getMonth(),1).getTime();if("week"===e){const t=new Date(n.getFullYear(),n.getMonth(),n.getDate());return t.setDate(t.getDate()-t.getDay()),t.getTime()}return"day"===e?new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime():"hour"===e?new Date(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours()).getTime():"minute"===e?Math.floor(t/a)*a:Math.floor(t/o)*o}(t,l[e]);if("year"===e&&n>1){const t=new Date(r).getFullYear();r=new Date(t-(t%n+n)%n,0,1).getTime()}for(let o=0;o<500;o++){const o=c(r,e,n);if(o>t)return r;r=o}return r}export function timeScale(t,e={}){const{tickCount:n=6}=e;let o=e.min??t?.min??Date.parse("2000-01-01T00:00:00"),a=e.max??t?.max??o+u;a<=o&&(o-=u/2,a+=u/2);const i=a-o;let l=s[0],m=1/0;for(const t of s){const e=Math.abs(i/t.size-n);e<m&&(m=e,l=t)}const f=l.unit,$="year"===f?Math.max(1,Math.round(r(i/n/(365*u)))):l.count,x=e.min??h(o,f,$),p=[];let M=x;for(let t=0;t<500&&(p.push(M),!(M>a));t++)M=c(M,f,$);const g=e.max??p[p.length-1],d=g-x||1;return{min:x,max:g,ticks:p.filter(t=>t>=x&&t<=g),unit:f,step:$,fraction:t=>(t-x)/d}}function m(t,e){if("second"===t)return{hour:"2-digit",minute:"2-digit",second:"2-digit",hourCycle:"h23"};if("minute"===t||"hour"===t)return{hour:"2-digit",minute:"2-digit",hourCycle:"h23"};if("year"===t)return{year:"numeric"};const n="month"===t||"quarter"===t?{month:"short"}:{month:"short",day:"numeric"};return e?{...n,year:"numeric"}:n}export function formatTimeValue(e,n,r){return t(r,m(n,!0)).format(new Date(e))}export function formatTimeTicks(e,n,r){const o=new Set(e.map(t=>new Date(t).getFullYear())).size>1;return e.map((e,a)=>t(r,m(n,o||0===a)).format(new Date(e)))}export function tickStride(t,e,n){if(t<=1||e<=0)return 1;const r=Math.max(1,Math.floor(e/Math.max(1,n)));return Math.max(1,Math.ceil(t/r))}export function showsTick(t,e,n,r){return t%n===0||r&&t===e-1}export function fitsLast(t,e,n,r){const o=(t-1)%e;return o>0&&o*n>=r+8}export function textWidth(t,e){let n=0;for(const e of t)n+=/[ᄀ-ᇿ⺀-가-豈-︰-﹏]/.test(e)?1:.6;return n*e}export function truncate(t,e,n){if(e<=0||textWidth(t,n)<=e)return t;const r=e-textWidth("…",n);let o="",a=0;for(const e of t){const t=a+textWidth(e,n);if(t>r)break;a=t,o+=e}return o.length>0?`${o.trimEnd()}…`:"…"}export function bandScale(t,e,n){const r=t>0?e/t:e;return{step:r,band:r*n,centre:t=>r*(t+.5)}}export function linePath(t,e){const n=[];let r=[];const o=()=>{if(0!==r.length){if(1===r.length)n.push(`M${r[0].x} ${r[0].y}h0`);else if("step"===e){n.push(`M${r[0].x} ${r[0].y}`);for(let t=1;t<r.length;t++){const e=(r[t-1].x+r[t].x)/2;n.push(`H${e}V${r[t].y}H${r[t].x}`)}}else if("smooth"===e)n.push(`M${r[0].x} ${r[0].y}`),n.push(function(t){const e=t.length,n=[];for(let r=0;r<e-1;r++){const e=t[r+1].x-t[r].x;n.push(0===e?0:(t[r+1].y-t[r].y)/e)}const r=[n[0]??0];for(let t=1;t<e-1;t++){const e=n[t-1],o=n[t];r.push(e*o<=0?0:2*e*o/(e+o))}r.push(n[e-2]??0);const o=[];for(let n=0;n<e-1;n++){const e=(t[n+1].x-t[n].x)/3;o.push(`C${t[n].x+e} ${t[n].y+r[n]*e} ${t[n+1].x-e} ${t[n+1].y-r[n+1]*e} ${t[n+1].x} ${t[n+1].y}`)}return o.join("")}(r));else{n.push(`M${r[0].x} ${r[0].y}`);for(let t=1;t<r.length;t++)n.push(`L${r[t].x} ${r[t].y}`)}r=[]}};for(const e of t)null===e?o():r.push(e);return o(),n.join("")}export function areaPath(t,e,n){const r=[];let o=0;const a=a=>{const i=t.slice(o,a).filter(Boolean);if(0===i.length)return;const u="number"==typeof e?i.map(t=>({x:t.x,y:e})).reverse():e.slice(o,a).filter(Boolean).reverse();if(0===u.length)return;const s=linePath(i,n),c=linePath(u,n).replace(/^M/,"L");r.push(`${s}${c}Z`)};for(let e=0;e<t.length;e++)null===t[e]&&(a(e),o=e+1);return a(t.length),r.join("")}export function barPath(t,e,n,r,o,a){const i=Math.max(0,Math.min(o,n/2,r/2));if(0===i||n<=0||r<=0)return`M${t} ${e}h${n}v${r}h${-n}Z`;const u=(t,e)=>`a${i} ${i} 0 0 1 ${t} ${e}`;return"up"===a?`M${t} ${e+r}V${e+i}${u(i,-i)}H${t+n-i}${u(i,i)}V${e+r}Z`:"down"===a?`M${t} ${e}H${t+n}V${e+r-i}${u(-i,i)}H${t+i}${u(-i,-i)}Z`:"right"===a?`M${t} ${e}H${t+n-i}${u(i,i)}V${e+r-i}${u(-i,i)}H${t}Z`:`M${t+n} ${e+r}H${t+i}${u(-i,-i)}V${e+i}${u(i,-i)}H${t+n}Z`}export const markShapes=["circle","square","triangle","diamond","cross"];const f={circle:1,square:.8862,triangle:1.5551,diamond:1.2533,cross:1.189};export function markPath(t,e,n,r){const o=Math.max(0,r)*f[t];if(0===o)return"";if("circle"===t)return`M${e-o} ${n}a${o} ${o} 0 1 0 ${2*o} 0a${o} ${o} 0 1 0 ${2*-o} 0Z`;if("square"===t)return`M${e-o} ${n-o}h${2*o}v${2*o}h${2*-o}Z`;if("diamond"===t)return`M${e} ${n-o}L${e+o} ${n}L${e} ${n+o}L${e-o} ${n}Z`;if("triangle"===t){return`M${[0,120,240].map(t=>{const r=(t-90)*Math.PI/180;return`${e+o*Math.cos(r)} ${n+o*Math.sin(r)}`}).join("L")}Z`}const a=o/3;return`M${e-a} ${n-o}h${2*a}v${o-a}h${o-a}v${2*a}h${-(o-a)}v${o-a}h${2*-a}v${-(o-a)}h${-(o-a)}v${2*-a}h${o-a}Z`}export function arcPath(t,e,n,r,o,a){const i=(n,r)=>{const o=(r-90)*Math.PI/180;return`${t+n*Math.cos(o)} ${e+n*Math.sin(o)}`};if(Math.abs(a-o)>=360){const t=o+180;return r>0?`M${i(n,o)}A${n} ${n} 0 1 1 ${i(n,t)}A${n} ${n} 0 1 1 ${i(n,o)}ZM${i(r,o)}A${r} ${r} 0 1 0 ${i(r,t)}A${r} ${r} 0 1 0 ${i(r,o)}Z`:`M${i(n,o)}A${n} ${n} 0 1 1 ${i(n,t)}A${n} ${n} 0 1 1 ${i(n,o)}Z`}const u=Math.abs(a-o)>180?1:0;return r<=0?`M${t} ${e}L${i(n,o)}A${n} ${n} 0 ${u} 1 ${i(n,a)}Z`:`M${i(n,o)}A${n} ${n} 0 ${u} 1 ${i(n,a)}L${i(r,a)}A${r} ${r} 0 ${u} 0 ${i(r,o)}Z`}export const rampSteps=5;export function rampStep(t,e,n,r,o=0){if("diverging"===r){const r=Math.max(Math.abs(n-o),Math.abs(o-e));if(!(r>0))return 2;const a=(t-o)/r;return Math.min(4,Math.max(0,2+Math.round(2*a)))}const a=n-e;return a>0?Math.min(4,Math.max(0,Math.floor((t-e)/a*5))):4}export function rampFill(t,e){return`var(--neba-chart-${"diverging"===e?"div":"seq"}-${t+1})`}export function rampInk(t,e){return`var(--neba-chart-${"diverging"===e?"div":"seq"}-on-${t+1})`}export function squarify(t,e,n){const r=t.reduce((t,e)=>t+Math.max(0,e),0);if(!(r>0)||e<=0||n<=0)return[];const o=e*n/r,a=t.map((t,e)=>({index:e,area:Math.max(0,t)*o})).filter(t=>t.area>0).sort((t,e)=>e.area-t.area),i=[];let u=0,s=0,c=e,l=n,h=[];const m=t=>{const e=Math.min(c,l),n=t.reduce((t,e)=>t+e.area,0);if(!(n>0&&e>0))return 1/0;const r=t[0].area,o=t[t.length-1].area;return Math.max(e*e*r/(n*n),n*n/(e*e*o))},f=()=>{const t=h.reduce((t,e)=>t+e.area,0),e=Math.min(c,l),n=e>0?t/e:0,r=c>=l;let o=0;for(const t of h){const e=n>0?t.area/n:0;i.push(r?{index:t.index,x:u,y:s+o,width:n,height:e}:{index:t.index,x:u+o,y:s,width:e,height:n}),o+=e}r?(u+=n,c-=n):(s+=n,l-=n),h=[]};for(const t of a)0===h.length||m([...h,t])<=m(h)||f(),h.push(t);return h.length>0&&f(),i}const $={month:"short",day:"numeric"},x={notation:"compact",maximumFractionDigits:1},p={maximumFractionDigits:2};export function formatCategory(e,n){return e instanceof Date?t(n,$).format(e):String(e)}export function compactNumber(t,n){return Math.abs(t)>=1e4?e(n,x).format(t):e(n,p).format(t)}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* function below takes plain values and returns plain values — there is no
|
|
14
14
|
* React in this file, and nothing in it knows what a column is.
|
|
15
15
|
*/
|
|
16
|
-
import type { NebaDensity, NebaSize } from '../types';
|
|
16
|
+
import type { NebaDensity, NebaSize } from '../types.js';
|
|
17
17
|
/**
|
|
18
18
|
* Row height, in **pixels**, and the one number in the library that has to be a
|
|
19
19
|
* number rather than a class.
|
package/dist/internal/date.d.ts
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* like a question is actually a command. Each function here copies first, so a
|
|
20
20
|
* `value` handed in by a caller is never the object that comes back out.
|
|
21
21
|
*/
|
|
22
|
-
import type { NebaWeekday } from '../types';
|
|
22
|
+
import type { NebaWeekday } from '../types.js';
|
|
23
23
|
/** Which unit the calendar is currently letting you pick. */
|
|
24
24
|
export type CalendarView = 'day' | 'month' | 'year';
|
|
25
25
|
/** How many years one page of the year grid holds. Four columns of three. */
|
package/dist/internal/date.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dateFormatter as t}from"./format";export const YEAR_PAGE_SIZE=12;export function makeDate(t,e,n){const r=new Date(0);return r.setFullYear(t,e,n),r.setHours(0,0,0,0),r}export function isValidDate(t){return t instanceof Date&&!Number.isNaN(t.getTime())}export function startOfDay(t){const e=new Date(t.getTime());return e.setHours(0,0,0,0),e}export function startOfMonth(t){return makeDate(t.getFullYear(),t.getMonth(),1)}export function daysInMonth(t,e){return makeDate(t,e+1,0).getDate()}export function today(){return startOfDay(new Date)}export function addDays(t,e){const n=new Date(t.getTime());return n.setDate(n.getDate()+e),n}export function addMonths(t,e){const n=t.getFullYear(),r=t.getMonth()+e,o=new Date(t.getTime()),a=makeDate(n,r,1);return o.setFullYear(a.getFullYear(),a.getMonth(),Math.min(t.getDate(),daysInMonth(a.getFullYear(),a.getMonth()))),o}export function addYears(t,e){return addMonths(t,12*e)}export function compareDay(t,e){return startOfDay(t).getTime()-startOfDay(e).getTime()}export function isSameDay(t,e){return isValidDate(t)&&isValidDate(e)&&0===compareDay(t,e)}export function isSameMonth(t,e){return isValidDate(t)&&isValidDate(e)&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()}export function isDayInRange(t,e,n){return!(!isValidDate(e)||!isValidDate(n))&&(compareDay(t,e)>0&&compareDay(t,n)<0)}export function clampDate(t,e,n){return isValidDate(e)&&t.getTime()<e.getTime()?new Date(e.getTime()):isValidDate(n)&&t.getTime()>n.getTime()?new Date(n.getTime()):t}export function isDayOutside(t,e,n){return!!(isValidDate(e)&&compareDay(t,e)<0)||isValidDate(n)&&compareDay(t,n)>0}export function minutesOfDay(t){return 60*t.getHours()+t.getMinutes()}export function secondsOfDay(t){return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}export function timeUnitSpan(t,e){const n=secondsOfDay(e);if("hour"===t){const t=3600*Math.floor(n/3600);return[t,t+3599]}if("minute"===t){const t=60*Math.floor(n/60);return[t,t+59]}if("second"===t)return[n,n];const r=e.getHours()<12?0:43200;return[r,r+43200-1]}export function withTime(t,e){const n=new Date(t.getTime());return n.setHours(e.hours??n.getHours(),e.minutes??n.getMinutes(),e.seconds??n.getSeconds(),0),n}export function mergeDateAndTime(t,e){return withTime(startOfDay(t),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()})}export function calendarWeeks(t,e){const n=startOfMonth(t),r=(n.getDay()-e+7)%7,o=addDays(n,-r);return Array.from({length:6},(t,e)=>Array.from({length:7},(t,n)=>addDays(o,7*e+n)))}export function yearPageStart(t){return t-(t%12+12)%12}export function formatDate(e,n,r){return isValidDate(e)?t(n,r).format(e):""}const e=Array.from({length:24},(t,e)=>new Date(2027,e%12,21+e%7,e,58,58));export function displaySamples(n,r){const o=t(n,r);return[...new Set(e.map(t=>o.format(t)))]}export function withPlaceholder(t,e){return"string"==typeof e&&""!==e?[...t,e]:t}export function toISODate(t){const e=t=>String(t).padStart(2,"0");return`${String(t.getFullYear()).padStart(4,"0")}-${e(t.getMonth()+1)}-${e(t.getDate())}`}export function toISOTime(t,e=!1){const n=t=>String(t).padStart(2,"0"),r=`${n(t.getHours())}:${n(t.getMinutes())}`;return e?`${r}:${n(t.getSeconds())}`:r}export function toISODateTime(t,e=!1){return`${toISODate(t)}T${toISOTime(t,e)}`}const n=makeDate(2021,7,1);export function weekdayLabels(e,r,o="short"){const a=t(e,{weekday:o});return Array.from({length:7},(t,e)=>a.format(addDays(n,(r+e)%7)))}export function monthLabels(e,n="short"){const r=t(e,{month:n});return Array.from({length:12},(t,e)=>r.format(makeDate(2021,e,1)))}export function isMonthBeforeYear(e){const r=t(e,{year:"numeric",month:"long"}).formatToParts(n);return r.findIndex(t=>"month"===t.type)<r.findIndex(t=>"year"===t.type)}export function isHour12(e){const n=t(e,{hour:"numeric"}).resolvedOptions();return n.hourCycle?"h11"===n.hourCycle||"h12"===n.hourCycle:!0===n.hour12}export function meridiemLabels(e){const r=t(e,{hour:"numeric",hour12:!0}),o=t=>{const e=r.formatToParts(withTime(n,{hours:t})).find(t=>"dayPeriod"===t.type);return e?.value??(t<12?"AM":"PM")};return[o(9),o(21)]}export function localeWeekStart(t){try{const e=t??(new Intl.DateTimeFormat).resolvedOptions().locale,n=new Intl.Locale(e),r="function"==typeof n.getWeekInfo?n.getWeekInfo():n.weekInfo;if("number"==typeof r?.firstDay)return r.firstDay%7}catch{}return 0}
|
|
1
|
+
import{dateFormatter as t}from"./format.js";export const YEAR_PAGE_SIZE=12;export function makeDate(t,e,n){const r=new Date(0);return r.setFullYear(t,e,n),r.setHours(0,0,0,0),r}export function isValidDate(t){return t instanceof Date&&!Number.isNaN(t.getTime())}export function startOfDay(t){const e=new Date(t.getTime());return e.setHours(0,0,0,0),e}export function startOfMonth(t){return makeDate(t.getFullYear(),t.getMonth(),1)}export function daysInMonth(t,e){return makeDate(t,e+1,0).getDate()}export function today(){return startOfDay(new Date)}export function addDays(t,e){const n=new Date(t.getTime());return n.setDate(n.getDate()+e),n}export function addMonths(t,e){const n=t.getFullYear(),r=t.getMonth()+e,o=new Date(t.getTime()),a=makeDate(n,r,1);return o.setFullYear(a.getFullYear(),a.getMonth(),Math.min(t.getDate(),daysInMonth(a.getFullYear(),a.getMonth()))),o}export function addYears(t,e){return addMonths(t,12*e)}export function compareDay(t,e){return startOfDay(t).getTime()-startOfDay(e).getTime()}export function isSameDay(t,e){return isValidDate(t)&&isValidDate(e)&&0===compareDay(t,e)}export function isSameMonth(t,e){return isValidDate(t)&&isValidDate(e)&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()}export function isDayInRange(t,e,n){return!(!isValidDate(e)||!isValidDate(n))&&(compareDay(t,e)>0&&compareDay(t,n)<0)}export function clampDate(t,e,n){return isValidDate(e)&&t.getTime()<e.getTime()?new Date(e.getTime()):isValidDate(n)&&t.getTime()>n.getTime()?new Date(n.getTime()):t}export function isDayOutside(t,e,n){return!!(isValidDate(e)&&compareDay(t,e)<0)||isValidDate(n)&&compareDay(t,n)>0}export function minutesOfDay(t){return 60*t.getHours()+t.getMinutes()}export function secondsOfDay(t){return 3600*t.getHours()+60*t.getMinutes()+t.getSeconds()}export function timeUnitSpan(t,e){const n=secondsOfDay(e);if("hour"===t){const t=3600*Math.floor(n/3600);return[t,t+3599]}if("minute"===t){const t=60*Math.floor(n/60);return[t,t+59]}if("second"===t)return[n,n];const r=e.getHours()<12?0:43200;return[r,r+43200-1]}export function withTime(t,e){const n=new Date(t.getTime());return n.setHours(e.hours??n.getHours(),e.minutes??n.getMinutes(),e.seconds??n.getSeconds(),0),n}export function mergeDateAndTime(t,e){return withTime(startOfDay(t),{hours:e.getHours(),minutes:e.getMinutes(),seconds:e.getSeconds()})}export function calendarWeeks(t,e){const n=startOfMonth(t),r=(n.getDay()-e+7)%7,o=addDays(n,-r);return Array.from({length:6},(t,e)=>Array.from({length:7},(t,n)=>addDays(o,7*e+n)))}export function yearPageStart(t){return t-(t%12+12)%12}export function formatDate(e,n,r){return isValidDate(e)?t(n,r).format(e):""}const e=Array.from({length:24},(t,e)=>new Date(2027,e%12,21+e%7,e,58,58));export function displaySamples(n,r){const o=t(n,r);return[...new Set(e.map(t=>o.format(t)))]}export function withPlaceholder(t,e){return"string"==typeof e&&""!==e?[...t,e]:t}export function toISODate(t){const e=t=>String(t).padStart(2,"0");return`${String(t.getFullYear()).padStart(4,"0")}-${e(t.getMonth()+1)}-${e(t.getDate())}`}export function toISOTime(t,e=!1){const n=t=>String(t).padStart(2,"0"),r=`${n(t.getHours())}:${n(t.getMinutes())}`;return e?`${r}:${n(t.getSeconds())}`:r}export function toISODateTime(t,e=!1){return`${toISODate(t)}T${toISOTime(t,e)}`}const n=makeDate(2021,7,1);export function weekdayLabels(e,r,o="short"){const a=t(e,{weekday:o});return Array.from({length:7},(t,e)=>a.format(addDays(n,(r+e)%7)))}export function monthLabels(e,n="short"){const r=t(e,{month:n});return Array.from({length:12},(t,e)=>r.format(makeDate(2021,e,1)))}export function isMonthBeforeYear(e){const r=t(e,{year:"numeric",month:"long"}).formatToParts(n);return r.findIndex(t=>"month"===t.type)<r.findIndex(t=>"year"===t.type)}export function isHour12(e){const n=t(e,{hour:"numeric"}).resolvedOptions();return n.hourCycle?"h11"===n.hourCycle||"h12"===n.hourCycle:!0===n.hour12}export function meridiemLabels(e){const r=t(e,{hour:"numeric",hour12:!0}),o=t=>{const e=r.formatToParts(withTime(n,{hours:t})).find(t=>"dayPeriod"===t.type);return e?.value??(t<12?"AM":"PM")};return[o(9),o(21)]}export function localeWeekStart(t){try{const e=t??(new Intl.DateTimeFormat).resolvedOptions().locale,n=new Intl.Locale(e),r="function"==typeof n.getWeekInfo?n.getWeekInfo():n.weekInfo;if("number"==typeof r?.firstDay)return r.firstDay%7}catch{}return 0}
|
package/dist/internal/grid.d.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* instance values go in inline custom properties, never in class names.
|
|
17
17
|
*/
|
|
18
18
|
import type * as React from 'react';
|
|
19
|
-
import type { NebaAlignItems, NebaAlignSelf, NebaBreakpoint, NebaJustifyContent, NebaResponsive } from '../types';
|
|
19
|
+
import type { NebaAlignItems, NebaAlignSelf, NebaBreakpoint, NebaJustifyContent, NebaResponsive } from '../types.js';
|
|
20
20
|
/** Smallest first, which is also the order the media queries have to be in. */
|
|
21
21
|
export declare const breakpoints: readonly NebaBreakpoint[];
|
|
22
22
|
/**
|