@misoto22/folio 0.0.0 → 0.16.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/AGENTS.md +88 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +21 -0
- package/README.md +208 -2
- package/bin/folio-design.mjs +277 -0
- package/bin/migrate-legacy.mjs +81 -0
- package/dist/agent/Accordion.md +65 -0
- package/dist/agent/Actions.md +49 -0
- package/dist/agent/Alert.md +65 -0
- package/dist/agent/AppShell.md +69 -0
- package/dist/agent/ArchitectureFigure.md +72 -0
- package/dist/agent/AreaChart.md +94 -0
- package/dist/agent/Article.md +65 -0
- package/dist/agent/AspectRatio.md +58 -0
- package/dist/agent/Avatar.md +53 -0
- package/dist/agent/Badge.md +62 -0
- package/dist/agent/BarChart.md +93 -0
- package/dist/agent/BarList.md +67 -0
- package/dist/agent/BigNumber.md +70 -0
- package/dist/agent/BoxPlot.md +82 -0
- package/dist/agent/Breadcrumb.md +55 -0
- package/dist/agent/BulletChart.md +71 -0
- package/dist/agent/Button.md +81 -0
- package/dist/agent/Calendar.md +77 -0
- package/dist/agent/CalendarHeatmap.md +75 -0
- package/dist/agent/Card.md +72 -0
- package/dist/agent/Checkbox.md +57 -0
- package/dist/agent/Code.md +51 -0
- package/dist/agent/CodeBlock.md +77 -0
- package/dist/agent/Collapsible.md +68 -0
- package/dist/agent/Collection.md +169 -0
- package/dist/agent/ColorPicker.md +76 -0
- package/dist/agent/Combobox.md +77 -0
- package/dist/agent/Command.md +122 -0
- package/dist/agent/ComposedChart.md +82 -0
- package/dist/agent/Contact.md +90 -0
- package/dist/agent/Content.md +70 -0
- package/dist/agent/ContextMenu.md +93 -0
- package/dist/agent/Conversation.md +247 -0
- package/dist/agent/DataflowFigure.md +49 -0
- package/dist/agent/DatePicker.md +104 -0
- package/dist/agent/DescriptionList.md +69 -0
- package/dist/agent/Diagram.md +71 -0
- package/dist/agent/DiagramCanvas.md +71 -0
- package/dist/agent/DiagramExportMenu.md +65 -0
- package/dist/agent/DiagramInspector.md +73 -0
- package/dist/agent/DiagramLegend.md +56 -0
- package/dist/agent/DiagramMinimap.md +69 -0
- package/dist/agent/DiagramToolbar.md +70 -0
- package/dist/agent/Dialog.md +76 -0
- package/dist/agent/DropdownMenu.md +110 -0
- package/dist/agent/EmptyState.md +63 -0
- package/dist/agent/ErrorState.md +67 -0
- package/dist/agent/Evidence.md +165 -0
- package/dist/agent/Facet.md +107 -0
- package/dist/agent/Field.md +79 -0
- package/dist/agent/FigureBand.md +49 -0
- package/dist/agent/FloatingIconButton.md +61 -0
- package/dist/agent/FunnelChart.md +75 -0
- package/dist/agent/Heading.md +65 -0
- package/dist/agent/Heatmap.md +78 -0
- package/dist/agent/Histogram.md +88 -0
- package/dist/agent/Input.md +52 -0
- package/dist/agent/Kbd.md +48 -0
- package/dist/agent/LifecycleFigure.md +50 -0
- package/dist/agent/LineChart.md +85 -0
- package/dist/agent/LinkArrow.md +49 -0
- package/dist/agent/Markdown.md +69 -0
- package/dist/agent/Media.md +261 -0
- package/dist/agent/Metric.md +70 -0
- package/dist/agent/Metrics.md +114 -0
- package/dist/agent/Music.md +86 -0
- package/dist/agent/NativeSelect.md +62 -0
- package/dist/agent/NavItem.md +56 -0
- package/dist/agent/NumberField.md +73 -0
- package/dist/agent/PageHeader.md +69 -0
- package/dist/agent/Pagination.md +70 -0
- package/dist/agent/PieChart.md +80 -0
- package/dist/agent/Popover.md +80 -0
- package/dist/agent/Portfolio.md +93 -0
- package/dist/agent/PortfolioIndex.md +34 -0
- package/dist/agent/Progress.md +58 -0
- package/dist/agent/RadarChart.md +79 -0
- package/dist/agent/RadialChart.md +81 -0
- package/dist/agent/RadioGroup.md +66 -0
- package/dist/agent/Reading.md +233 -0
- package/dist/agent/Recovery.md +72 -0
- package/dist/agent/SankeyChart.md +85 -0
- package/dist/agent/ScatterChart.md +80 -0
- package/dist/agent/ScrollArea.md +62 -0
- package/dist/agent/SearchPalette.md +51 -0
- package/dist/agent/SearchableMenu.md +69 -0
- package/dist/agent/Select.md +102 -0
- package/dist/agent/Separator.md +60 -0
- package/dist/agent/SequenceFigure.md +51 -0
- package/dist/agent/Sheet.md +82 -0
- package/dist/agent/Sidebar.md +194 -0
- package/dist/agent/SiteNavigation.md +62 -0
- package/dist/agent/SiteShell.md +67 -0
- package/dist/agent/Skeleton.md +96 -0
- package/dist/agent/Slider.md +67 -0
- package/dist/agent/Sparkline.md +68 -0
- package/dist/agent/Spinner.md +62 -0
- package/dist/agent/StatusDot.md +56 -0
- package/dist/agent/StatusPill.md +55 -0
- package/dist/agent/Steps.md +68 -0
- package/dist/agent/Switch.md +50 -0
- package/dist/agent/Table.md +111 -0
- package/dist/agent/Tabs.md +71 -0
- package/dist/agent/Tag.md +67 -0
- package/dist/agent/Text.md +66 -0
- package/dist/agent/Textarea.md +46 -0
- package/dist/agent/Timeline.md +114 -0
- package/dist/agent/Timestamp.md +65 -0
- package/dist/agent/Toast.md +51 -0
- package/dist/agent/ToggleGroup.md +67 -0
- package/dist/agent/Toolbar.md +72 -0
- package/dist/agent/Tooltip.md +74 -0
- package/dist/agent/TreemapChart.md +76 -0
- package/dist/agent/WaterfallChart.md +86 -0
- package/dist/agent/WorkflowFigure.md +51 -0
- package/dist/agent/catalog.json +8006 -0
- package/dist/agent/index.md +182 -0
- package/dist/article.css +407 -0
- package/dist/charts/AreaChart/AreaChart.d.ts +198 -0
- package/dist/charts/AreaChart/AreaChart.js +479 -0
- package/dist/charts/AreaChart/AreaChart.js.map +1 -0
- package/dist/charts/BarChart/BarChart.d.ts +190 -0
- package/dist/charts/BarChart/BarChart.js +599 -0
- package/dist/charts/BarChart/BarChart.js.map +1 -0
- package/dist/charts/BarList/BarList.d.ts +65 -0
- package/dist/charts/BarList/BarList.js +79 -0
- package/dist/charts/BarList/BarList.js.map +1 -0
- package/dist/charts/BigNumber/BigNumber.d.ts +72 -0
- package/dist/charts/BigNumber/BigNumber.js +51 -0
- package/dist/charts/BigNumber/BigNumber.js.map +1 -0
- package/dist/charts/BoxPlot/BoxPlot.d.ts +177 -0
- package/dist/charts/BoxPlot/BoxPlot.js +497 -0
- package/dist/charts/BoxPlot/BoxPlot.js.map +1 -0
- package/dist/charts/BulletChart/BulletChart.d.ts +100 -0
- package/dist/charts/BulletChart/BulletChart.js +197 -0
- package/dist/charts/BulletChart/BulletChart.js.map +1 -0
- package/dist/charts/CalendarHeatmap/CalendarHeatmap.d.ts +106 -0
- package/dist/charts/CalendarHeatmap/CalendarHeatmap.js +103 -0
- package/dist/charts/CalendarHeatmap/CalendarHeatmap.js.map +1 -0
- package/dist/charts/ComposedChart/ComposedChart.d.ts +178 -0
- package/dist/charts/ComposedChart/ComposedChart.js +667 -0
- package/dist/charts/ComposedChart/ComposedChart.js.map +1 -0
- package/dist/charts/Facet/Facet.d.ts +240 -0
- package/dist/charts/Facet/Facet.js +133 -0
- package/dist/charts/Facet/Facet.js.map +1 -0
- package/dist/charts/Facet/panels.d.ts +187 -0
- package/dist/charts/Facet/panels.js +203 -0
- package/dist/charts/Facet/panels.js.map +1 -0
- package/dist/charts/FunnelChart/FunnelChart.d.ts +106 -0
- package/dist/charts/FunnelChart/FunnelChart.js +137 -0
- package/dist/charts/FunnelChart/FunnelChart.js.map +1 -0
- package/dist/charts/Heatmap/Heatmap.d.ts +101 -0
- package/dist/charts/Heatmap/Heatmap.js +125 -0
- package/dist/charts/Heatmap/Heatmap.js.map +1 -0
- package/dist/charts/Histogram/Histogram.d.ts +188 -0
- package/dist/charts/Histogram/Histogram.js +382 -0
- package/dist/charts/Histogram/Histogram.js.map +1 -0
- package/dist/charts/LineChart/LineChart.d.ts +174 -0
- package/dist/charts/LineChart/LineChart.js +485 -0
- package/dist/charts/LineChart/LineChart.js.map +1 -0
- package/dist/charts/PieChart/PieChart.d.ts +140 -0
- package/dist/charts/PieChart/PieChart.js +317 -0
- package/dist/charts/PieChart/PieChart.js.map +1 -0
- package/dist/charts/RadarChart/RadarChart.d.ts +135 -0
- package/dist/charts/RadarChart/RadarChart.js +303 -0
- package/dist/charts/RadarChart/RadarChart.js.map +1 -0
- package/dist/charts/RadialChart/RadialChart.d.ts +142 -0
- package/dist/charts/RadialChart/RadialChart.js +279 -0
- package/dist/charts/RadialChart/RadialChart.js.map +1 -0
- package/dist/charts/SankeyChart/SankeyChart.d.ts +149 -0
- package/dist/charts/SankeyChart/SankeyChart.js +509 -0
- package/dist/charts/SankeyChart/SankeyChart.js.map +1 -0
- package/dist/charts/ScatterChart/ScatterChart.d.ts +149 -0
- package/dist/charts/ScatterChart/ScatterChart.js +275 -0
- package/dist/charts/ScatterChart/ScatterChart.js.map +1 -0
- package/dist/charts/Sparkline/Sparkline.d.ts +53 -0
- package/dist/charts/Sparkline/Sparkline.js +95 -0
- package/dist/charts/Sparkline/Sparkline.js.map +1 -0
- package/dist/charts/TreemapChart/TreemapChart.d.ts +98 -0
- package/dist/charts/TreemapChart/TreemapChart.js +127 -0
- package/dist/charts/TreemapChart/TreemapChart.js.map +1 -0
- package/dist/charts/WaterfallChart/WaterfallChart.d.ts +164 -0
- package/dist/charts/WaterfallChart/WaterfallChart.js +321 -0
- package/dist/charts/WaterfallChart/WaterfallChart.js.map +1 -0
- package/dist/charts/index.d.ts +43 -0
- package/dist/charts/index.js +130 -0
- package/dist/charts/index.js.map +1 -0
- package/dist/charts/lib/annotations.d.ts +103 -0
- package/dist/charts/lib/annotations.js +99 -0
- package/dist/charts/lib/annotations.js.map +1 -0
- package/dist/charts/lib/axis.d.ts +18 -0
- package/dist/charts/lib/axis.js +21 -0
- package/dist/charts/lib/axis.js.map +1 -0
- package/dist/charts/lib/background.d.ts +33 -0
- package/dist/charts/lib/background.js +173 -0
- package/dist/charts/lib/background.js.map +1 -0
- package/dist/charts/lib/brush.d.ts +94 -0
- package/dist/charts/lib/brush.js +535 -0
- package/dist/charts/lib/brush.js.map +1 -0
- package/dist/charts/lib/chart.d.ts +94 -0
- package/dist/charts/lib/chart.js +149 -0
- package/dist/charts/lib/chart.js.map +1 -0
- package/dist/charts/lib/dot.d.ts +29 -0
- package/dist/charts/lib/dot.js +78 -0
- package/dist/charts/lib/dot.js.map +1 -0
- package/dist/charts/lib/empty.d.ts +31 -0
- package/dist/charts/lib/empty.js +24 -0
- package/dist/charts/lib/empty.js.map +1 -0
- package/dist/charts/lib/export.d.ts +94 -0
- package/dist/charts/lib/export.js +62 -0
- package/dist/charts/lib/export.js.map +1 -0
- package/dist/charts/lib/figure.d.ts +81 -0
- package/dist/charts/lib/figure.js +62 -0
- package/dist/charts/lib/figure.js.map +1 -0
- package/dist/charts/lib/format.d.ts +46 -0
- package/dist/charts/lib/format.js +56 -0
- package/dist/charts/lib/format.js.map +1 -0
- package/dist/charts/lib/legend.d.ts +45 -0
- package/dist/charts/lib/legend.js +117 -0
- package/dist/charts/lib/legend.js.map +1 -0
- package/dist/charts/lib/loading.d.ts +48 -0
- package/dist/charts/lib/loading.js +105 -0
- package/dist/charts/lib/loading.js.map +1 -0
- package/dist/charts/lib/paint.d.ts +154 -0
- package/dist/charts/lib/paint.js +551 -0
- package/dist/charts/lib/paint.js.map +1 -0
- package/dist/charts/lib/scale.d.ts +23 -0
- package/dist/charts/lib/scale.js +13 -0
- package/dist/charts/lib/scale.js.map +1 -0
- package/dist/charts/lib/selection.d.ts +20 -0
- package/dist/charts/lib/selection.js +18 -0
- package/dist/charts/lib/selection.js.map +1 -0
- package/dist/charts/lib/sonify-control.d.ts +163 -0
- package/dist/charts/lib/sonify-control.js +172 -0
- package/dist/charts/lib/sonify-control.js.map +1 -0
- package/dist/charts/lib/sonify.d.ts +248 -0
- package/dist/charts/lib/sonify.js +262 -0
- package/dist/charts/lib/sonify.js.map +1 -0
- package/dist/charts/lib/toolbar.d.ts +144 -0
- package/dist/charts/lib/toolbar.js +156 -0
- package/dist/charts/lib/toolbar.js.map +1 -0
- package/dist/charts/lib/tooltip.d.ts +59 -0
- package/dist/charts/lib/tooltip.js +135 -0
- package/dist/charts/lib/tooltip.js.map +1 -0
- package/dist/charts/lib/values.d.ts +56 -0
- package/dist/charts/lib/values.js +71 -0
- package/dist/charts/lib/values.js.map +1 -0
- package/dist/charts/lib/zoom.d.ts +139 -0
- package/dist/charts/lib/zoom.js +314 -0
- package/dist/charts/lib/zoom.js.map +1 -0
- package/dist/components/Accordion/Accordion.d.ts +34 -0
- package/dist/components/Accordion/Accordion.js +43 -0
- package/dist/components/Accordion/Accordion.js.map +1 -0
- package/dist/components/Alert/Alert.d.ts +32 -0
- package/dist/components/Alert/Alert.js +49 -0
- package/dist/components/Alert/Alert.js.map +1 -0
- package/dist/components/AppShell/AppShell.d.ts +58 -0
- package/dist/components/AppShell/AppShell.js +126 -0
- package/dist/components/AppShell/AppShell.js.map +1 -0
- package/dist/components/Article/Article.d.ts +58 -0
- package/dist/components/Article/Article.js +34 -0
- package/dist/components/Article/Article.js.map +1 -0
- package/dist/components/AspectRatio/AspectRatio.d.ts +46 -0
- package/dist/components/AspectRatio/AspectRatio.js +33 -0
- package/dist/components/AspectRatio/AspectRatio.js.map +1 -0
- package/dist/components/Avatar/Avatar.d.ts +38 -0
- package/dist/components/Avatar/Avatar.js +44 -0
- package/dist/components/Avatar/Avatar.js.map +1 -0
- package/dist/components/Badge/Badge.d.ts +30 -0
- package/dist/components/Badge/Badge.js +29 -0
- package/dist/components/Badge/Badge.js.map +1 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +37 -0
- package/dist/components/Breadcrumb/Breadcrumb.js +46 -0
- package/dist/components/Breadcrumb/Breadcrumb.js.map +1 -0
- package/dist/components/Button/Button.d.ts +70 -0
- package/dist/components/Button/Button.js +95 -0
- package/dist/components/Button/Button.js.map +1 -0
- package/dist/components/Calendar/Calendar.d.ts +54 -0
- package/dist/components/Calendar/Calendar.js +369 -0
- package/dist/components/Calendar/Calendar.js.map +1 -0
- package/dist/components/Card/Card.d.ts +55 -0
- package/dist/components/Card/Card.js +64 -0
- package/dist/components/Card/Card.js.map +1 -0
- package/dist/components/Checkbox/Checkbox.d.ts +26 -0
- package/dist/components/Checkbox/Checkbox.js +34 -0
- package/dist/components/Checkbox/Checkbox.js.map +1 -0
- package/dist/components/Code/Code.d.ts +30 -0
- package/dist/components/Code/Code.js +21 -0
- package/dist/components/Code/Code.js.map +1 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +145 -0
- package/dist/components/CodeBlock/CodeBlock.js +114 -0
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -0
- package/dist/components/Collapsible/Collapsible.d.ts +45 -0
- package/dist/components/Collapsible/Collapsible.js +60 -0
- package/dist/components/Collapsible/Collapsible.js.map +1 -0
- package/dist/components/ColorPicker/ColorPicker.d.ts +67 -0
- package/dist/components/ColorPicker/ColorPicker.js +334 -0
- package/dist/components/ColorPicker/ColorPicker.js.map +1 -0
- package/dist/components/Combobox/Combobox.d.ts +77 -0
- package/dist/components/Combobox/Combobox.js +170 -0
- package/dist/components/Combobox/Combobox.js.map +1 -0
- package/dist/components/Command/Command.d.ts +125 -0
- package/dist/components/Command/Command.js +204 -0
- package/dist/components/Command/Command.js.map +1 -0
- package/dist/components/ContextMenu/ContextMenu.d.ts +63 -0
- package/dist/components/ContextMenu/ContextMenu.js +109 -0
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -0
- package/dist/components/DatePicker/DatePicker.d.ts +130 -0
- package/dist/components/DatePicker/DatePicker.js +257 -0
- package/dist/components/DatePicker/DatePicker.js.map +1 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts +73 -0
- package/dist/components/DescriptionList/DescriptionList.js +35 -0
- package/dist/components/DescriptionList/DescriptionList.js.map +1 -0
- package/dist/components/Diagram/Diagram.d.ts +86 -0
- package/dist/components/Diagram/Diagram.js +211 -0
- package/dist/components/Diagram/Diagram.js.map +1 -0
- package/dist/components/Dialog/Dialog.d.ts +63 -0
- package/dist/components/Dialog/Dialog.js +90 -0
- package/dist/components/Dialog/Dialog.js.map +1 -0
- package/dist/components/DropdownMenu/DropdownMenu.d.ts +87 -0
- package/dist/components/DropdownMenu/DropdownMenu.js +120 -0
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -0
- package/dist/components/EmptyState/EmptyState.d.ts +55 -0
- package/dist/components/EmptyState/EmptyState.js +32 -0
- package/dist/components/EmptyState/EmptyState.js.map +1 -0
- package/dist/components/ErrorState/ErrorState.d.ts +55 -0
- package/dist/components/ErrorState/ErrorState.js +41 -0
- package/dist/components/ErrorState/ErrorState.js.map +1 -0
- package/dist/components/Field/Field.d.ts +111 -0
- package/dist/components/Field/Field.js +95 -0
- package/dist/components/Field/Field.js.map +1 -0
- package/dist/components/Field/field-control.d.ts +31 -0
- package/dist/components/Field/field-control.js +12 -0
- package/dist/components/Field/field-control.js.map +1 -0
- package/dist/components/FigureBand/FigureBand.d.ts +31 -0
- package/dist/components/FigureBand/FigureBand.js +51 -0
- package/dist/components/FigureBand/FigureBand.js.map +1 -0
- package/dist/components/FloatingIconButton/FloatingIconButton.d.ts +29 -0
- package/dist/components/FloatingIconButton/FloatingIconButton.js +34 -0
- package/dist/components/FloatingIconButton/FloatingIconButton.js.map +1 -0
- package/dist/components/Heading/Heading.d.ts +62 -0
- package/dist/components/Heading/Heading.js +44 -0
- package/dist/components/Heading/Heading.js.map +1 -0
- package/dist/components/Input/Input.d.ts +22 -0
- package/dist/components/Input/Input.js +21 -0
- package/dist/components/Input/Input.js.map +1 -0
- package/dist/components/Kbd/Kbd.d.ts +27 -0
- package/dist/components/Kbd/Kbd.js +21 -0
- package/dist/components/Kbd/Kbd.js.map +1 -0
- package/dist/components/LinkArrow/LinkArrow.d.ts +24 -0
- package/dist/components/LinkArrow/LinkArrow.js +24 -0
- package/dist/components/LinkArrow/LinkArrow.js.map +1 -0
- package/dist/components/Markdown/Markdown.d.ts +139 -0
- package/dist/components/Markdown/Markdown.js +135 -0
- package/dist/components/Markdown/Markdown.js.map +1 -0
- package/dist/components/Markdown/inline.d.ts +29 -0
- package/dist/components/Markdown/inline.js +74 -0
- package/dist/components/Markdown/inline.js.map +1 -0
- package/dist/components/Markdown/nodes.d.ts +65 -0
- package/dist/components/Markdown/nodes.js +1 -0
- package/dist/components/Markdown/nodes.js.map +1 -0
- package/dist/components/Markdown/parse.d.ts +24 -0
- package/dist/components/Markdown/parse.js +110 -0
- package/dist/components/Markdown/parse.js.map +1 -0
- package/dist/components/Markdown/slug.d.ts +15 -0
- package/dist/components/Markdown/slug.js +7 -0
- package/dist/components/Markdown/slug.js.map +1 -0
- package/dist/components/Metric/Metric.d.ts +61 -0
- package/dist/components/Metric/Metric.js +51 -0
- package/dist/components/Metric/Metric.js.map +1 -0
- package/dist/components/NativeSelect/NativeSelect.d.ts +33 -0
- package/dist/components/NativeSelect/NativeSelect.js +44 -0
- package/dist/components/NativeSelect/NativeSelect.js.map +1 -0
- package/dist/components/NavItem/NavItem.d.ts +39 -0
- package/dist/components/NavItem/NavItem.js +31 -0
- package/dist/components/NavItem/NavItem.js.map +1 -0
- package/dist/components/NumberField/NumberField.d.ts +69 -0
- package/dist/components/NumberField/NumberField.js +162 -0
- package/dist/components/NumberField/NumberField.js.map +1 -0
- package/dist/components/PageHeader/PageHeader.d.ts +92 -0
- package/dist/components/PageHeader/PageHeader.js +37 -0
- package/dist/components/PageHeader/PageHeader.js.map +1 -0
- package/dist/components/Pagination/Pagination.d.ts +67 -0
- package/dist/components/Pagination/Pagination.js +112 -0
- package/dist/components/Pagination/Pagination.js.map +1 -0
- package/dist/components/Popover/Popover.d.ts +39 -0
- package/dist/components/Popover/Popover.js +57 -0
- package/dist/components/Popover/Popover.js.map +1 -0
- package/dist/components/Progress/Progress.d.ts +43 -0
- package/dist/components/Progress/Progress.js +57 -0
- package/dist/components/Progress/Progress.js.map +1 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +49 -0
- package/dist/components/RadioGroup/RadioGroup.js +53 -0
- package/dist/components/RadioGroup/RadioGroup.js.map +1 -0
- package/dist/components/ScrollArea/ScrollArea.d.ts +46 -0
- package/dist/components/ScrollArea/ScrollArea.js +54 -0
- package/dist/components/ScrollArea/ScrollArea.js.map +1 -0
- package/dist/components/SearchableMenu/SearchableMenu.d.ts +68 -0
- package/dist/components/SearchableMenu/SearchableMenu.js +101 -0
- package/dist/components/SearchableMenu/SearchableMenu.js.map +1 -0
- package/dist/components/Select/Select.d.ts +87 -0
- package/dist/components/Select/Select.js +130 -0
- package/dist/components/Select/Select.js.map +1 -0
- package/dist/components/Separator/Separator.d.ts +48 -0
- package/dist/components/Separator/Separator.js +43 -0
- package/dist/components/Separator/Separator.js.map +1 -0
- package/dist/components/Sheet/Sheet.d.ts +43 -0
- package/dist/components/Sheet/Sheet.js +79 -0
- package/dist/components/Sheet/Sheet.js.map +1 -0
- package/dist/components/Sidebar/Sidebar.d.ts +357 -0
- package/dist/components/Sidebar/Sidebar.js +447 -0
- package/dist/components/Sidebar/Sidebar.js.map +1 -0
- package/dist/components/Skeleton/Skeleton.d.ts +70 -0
- package/dist/components/Skeleton/Skeleton.js +44 -0
- package/dist/components/Skeleton/Skeleton.js.map +1 -0
- package/dist/components/Slider/Slider.d.ts +74 -0
- package/dist/components/Slider/Slider.js +143 -0
- package/dist/components/Slider/Slider.js.map +1 -0
- package/dist/components/Spinner/Spinner.d.ts +58 -0
- package/dist/components/Spinner/Spinner.js +49 -0
- package/dist/components/Spinner/Spinner.js.map +1 -0
- package/dist/components/StatusDot/StatusDot.d.ts +29 -0
- package/dist/components/StatusDot/StatusDot.js +44 -0
- package/dist/components/StatusDot/StatusDot.js.map +1 -0
- package/dist/components/StatusPill/StatusPill.d.ts +30 -0
- package/dist/components/StatusPill/StatusPill.js +37 -0
- package/dist/components/StatusPill/StatusPill.js.map +1 -0
- package/dist/components/Steps/Steps.d.ts +65 -0
- package/dist/components/Steps/Steps.js +25 -0
- package/dist/components/Steps/Steps.js.map +1 -0
- package/dist/components/Switch/Switch.d.ts +23 -0
- package/dist/components/Switch/Switch.js +23 -0
- package/dist/components/Switch/Switch.js.map +1 -0
- package/dist/components/Table/Table.d.ts +116 -0
- package/dist/components/Table/Table.js +137 -0
- package/dist/components/Table/Table.js.map +1 -0
- package/dist/components/Tabs/Tabs.d.ts +37 -0
- package/dist/components/Tabs/Tabs.js +205 -0
- package/dist/components/Tabs/Tabs.js.map +1 -0
- package/dist/components/Tag/Tag.d.ts +87 -0
- package/dist/components/Tag/Tag.js +62 -0
- package/dist/components/Tag/Tag.js.map +1 -0
- package/dist/components/Text/Text.d.ts +62 -0
- package/dist/components/Text/Text.js +30 -0
- package/dist/components/Text/Text.js.map +1 -0
- package/dist/components/Textarea/Textarea.d.ts +20 -0
- package/dist/components/Textarea/Textarea.js +32 -0
- package/dist/components/Textarea/Textarea.js.map +1 -0
- package/dist/components/Timestamp/Timestamp.d.ts +59 -0
- package/dist/components/Timestamp/Timestamp.js +56 -0
- package/dist/components/Timestamp/Timestamp.js.map +1 -0
- package/dist/components/Toast/Toast.d.ts +32 -0
- package/dist/components/Toast/Toast.js +64 -0
- package/dist/components/Toast/Toast.js.map +1 -0
- package/dist/components/ToggleGroup/ToggleGroup.d.ts +46 -0
- package/dist/components/ToggleGroup/ToggleGroup.js +88 -0
- package/dist/components/ToggleGroup/ToggleGroup.js.map +1 -0
- package/dist/components/Toolbar/Toolbar.d.ts +55 -0
- package/dist/components/Toolbar/Toolbar.js +43 -0
- package/dist/components/Toolbar/Toolbar.js.map +1 -0
- package/dist/components/Tooltip/Tooltip.d.ts +43 -0
- package/dist/components/Tooltip/Tooltip.js +40 -0
- package/dist/components/Tooltip/Tooltip.js.map +1 -0
- package/dist/diagrams/ArchitectureFigure/ArchitectureFigure.d.ts +55 -0
- package/dist/diagrams/ArchitectureFigure/ArchitectureFigure.js +175 -0
- package/dist/diagrams/ArchitectureFigure/ArchitectureFigure.js.map +1 -0
- package/dist/diagrams/DataflowFigure/DataflowFigure.d.ts +28 -0
- package/dist/diagrams/DataflowFigure/DataflowFigure.js +148 -0
- package/dist/diagrams/DataflowFigure/DataflowFigure.js.map +1 -0
- package/dist/diagrams/DiagramCanvas/DiagramCanvas.d.ts +78 -0
- package/dist/diagrams/DiagramCanvas/DiagramCanvas.js +229 -0
- package/dist/diagrams/DiagramCanvas/DiagramCanvas.js.map +1 -0
- package/dist/diagrams/DiagramExportMenu/DiagramExportMenu.d.ts +106 -0
- package/dist/diagrams/DiagramExportMenu/DiagramExportMenu.js +123 -0
- package/dist/diagrams/DiagramExportMenu/DiagramExportMenu.js.map +1 -0
- package/dist/diagrams/DiagramInspector/DiagramInspector.d.ts +70 -0
- package/dist/diagrams/DiagramInspector/DiagramInspector.js +94 -0
- package/dist/diagrams/DiagramInspector/DiagramInspector.js.map +1 -0
- package/dist/diagrams/DiagramLegend/DiagramLegend.d.ts +42 -0
- package/dist/diagrams/DiagramLegend/DiagramLegend.js +35 -0
- package/dist/diagrams/DiagramLegend/DiagramLegend.js.map +1 -0
- package/dist/diagrams/DiagramMinimap/DiagramMinimap.d.ts +77 -0
- package/dist/diagrams/DiagramMinimap/DiagramMinimap.js +106 -0
- package/dist/diagrams/DiagramMinimap/DiagramMinimap.js.map +1 -0
- package/dist/diagrams/DiagramToolbar/DiagramToolbar.d.ts +48 -0
- package/dist/diagrams/DiagramToolbar/DiagramToolbar.js +53 -0
- package/dist/diagrams/DiagramToolbar/DiagramToolbar.js.map +1 -0
- package/dist/diagrams/LifecycleFigure/LifecycleFigure.d.ts +31 -0
- package/dist/diagrams/LifecycleFigure/LifecycleFigure.js +234 -0
- package/dist/diagrams/LifecycleFigure/LifecycleFigure.js.map +1 -0
- package/dist/diagrams/SequenceFigure/SequenceFigure.d.ts +38 -0
- package/dist/diagrams/SequenceFigure/SequenceFigure.js +261 -0
- package/dist/diagrams/SequenceFigure/SequenceFigure.js.map +1 -0
- package/dist/diagrams/WorkflowFigure/WorkflowFigure.d.ts +36 -0
- package/dist/diagrams/WorkflowFigure/WorkflowFigure.js +259 -0
- package/dist/diagrams/WorkflowFigure/WorkflowFigure.js.map +1 -0
- package/dist/diagrams/index.d.ts +17 -0
- package/dist/diagrams/index.js +29 -0
- package/dist/diagrams/index.js.map +1 -0
- package/dist/diagrams/lib/dev.d.ts +61 -0
- package/dist/diagrams/lib/dev.js +96 -0
- package/dist/diagrams/lib/dev.js.map +1 -0
- package/dist/diagrams/lib/frame.d.ts +138 -0
- package/dist/diagrams/lib/frame.js +131 -0
- package/dist/diagrams/lib/frame.js.map +1 -0
- package/dist/diagrams/lib/geometry.d.ts +114 -0
- package/dist/diagrams/lib/geometry.js +113 -0
- package/dist/diagrams/lib/geometry.js.map +1 -0
- package/dist/diagrams/lib/legend.d.ts +32 -0
- package/dist/diagrams/lib/legend.js +84 -0
- package/dist/diagrams/lib/legend.js.map +1 -0
- package/dist/diagrams/lib/marks.d.ts +207 -0
- package/dist/diagrams/lib/marks.js +480 -0
- package/dist/diagrams/lib/marks.js.map +1 -0
- package/dist/diagrams/lib/route.d.ts +106 -0
- package/dist/diagrams/lib/route.js +201 -0
- package/dist/diagrams/lib/route.js.map +1 -0
- package/dist/diagrams/lib/wires.d.ts +59 -0
- package/dist/diagrams/lib/wires.js +94 -0
- package/dist/diagrams/lib/wires.js.map +1 -0
- package/dist/diagrams/spec.d.ts +405 -0
- package/dist/diagrams/spec.js +1 -0
- package/dist/diagrams/spec.js.map +1 -0
- package/dist/fonts/hanken-grotesk-300.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-400.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-500.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-600.woff2 +0 -0
- package/dist/fonts/hanken-grotesk-700.woff2 +0 -0
- package/dist/fonts/ibm-plex-mono-400.woff2 +0 -0
- package/dist/fonts/ibm-plex-mono-500.woff2 +0 -0
- package/dist/fonts/ibm-plex-mono-600.woff2 +0 -0
- package/dist/fonts/newsreader-300.woff2 +0 -0
- package/dist/fonts/newsreader-400.woff2 +0 -0
- package/dist/fonts/newsreader-500.woff2 +0 -0
- package/dist/fonts/newsreader-600.woff2 +0 -0
- package/dist/fonts.css +96 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +80 -0
- package/dist/index.js.map +1 -0
- package/dist/keyframes.css +300 -0
- package/dist/lib/cn.d.ts +21 -0
- package/dist/lib/cn.js +9 -0
- package/dist/lib/cn.js.map +1 -0
- package/dist/lib/color.d.ts +80 -0
- package/dist/lib/color.js +189 -0
- package/dist/lib/color.js.map +1 -0
- package/dist/lib/control.d.ts +32 -0
- package/dist/lib/control.js +14 -0
- package/dist/lib/control.js.map +1 -0
- package/dist/lib/index.d.ts +4 -0
- package/dist/lib/index.js +11 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/numeric.d.ts +35 -0
- package/dist/lib/numeric.js +29 -0
- package/dist/lib/numeric.js.map +1 -0
- package/dist/lib/overlay-container.d.ts +48 -0
- package/dist/lib/overlay-container.js +15 -0
- package/dist/lib/overlay-container.js.map +1 -0
- package/dist/lib/slot-content.d.ts +8 -0
- package/dist/lib/slot-content.js +17 -0
- package/dist/lib/slot-content.js.map +1 -0
- package/dist/lib/step-rail.d.ts +45 -0
- package/dist/lib/step-rail.js +47 -0
- package/dist/lib/step-rail.js.map +1 -0
- package/dist/lib/svg-export.d.ts +138 -0
- package/dist/lib/svg-export.js +198 -0
- package/dist/lib/svg-export.js.map +1 -0
- package/dist/lib/useClipboardCopy.d.ts +30 -0
- package/dist/lib/useClipboardCopy.js +37 -0
- package/dist/lib/useClipboardCopy.js.map +1 -0
- package/dist/lib/useSelectionIndicator.d.ts +29 -0
- package/dist/lib/useSelectionIndicator.js +49 -0
- package/dist/lib/useSelectionIndicator.js.map +1 -0
- package/dist/lib/warn.d.ts +73 -0
- package/dist/lib/warn.js +38 -0
- package/dist/lib/warn.js.map +1 -0
- package/dist/semantic.css +193 -0
- package/dist/styles.css +98 -0
- package/dist/themes.css +514 -0
- package/dist/tokens/brand.d.ts +47 -0
- package/dist/tokens/brand.js +38 -0
- package/dist/tokens/brand.js.map +1 -0
- package/dist/tokens.css +652 -0
- package/dist/tokens.d.ts +198 -0
- package/dist/tokens.js +1020 -0
- package/dist/tokens.json +1019 -0
- package/dist/website/Actions/Actions.d.ts +34 -0
- package/dist/website/Actions/Actions.js +29 -0
- package/dist/website/Actions/Actions.js.map +1 -0
- package/dist/website/Collection/Collection.d.ts +128 -0
- package/dist/website/Collection/Collection.js +162 -0
- package/dist/website/Collection/Collection.js.map +1 -0
- package/dist/website/Contact/Contact.d.ts +87 -0
- package/dist/website/Contact/Contact.js +94 -0
- package/dist/website/Contact/Contact.js.map +1 -0
- package/dist/website/Content/CodePanel.d.ts +27 -0
- package/dist/website/Content/CodePanel.js +30 -0
- package/dist/website/Content/CodePanel.js.map +1 -0
- package/dist/website/Content/Content.d.ts +29 -0
- package/dist/website/Content/Content.js +38 -0
- package/dist/website/Content/Content.js.map +1 -0
- package/dist/website/Conversation/Conversation.d.ts +193 -0
- package/dist/website/Conversation/Conversation.js +252 -0
- package/dist/website/Conversation/Conversation.js.map +1 -0
- package/dist/website/Evidence/Evidence.d.ts +116 -0
- package/dist/website/Evidence/Evidence.js +142 -0
- package/dist/website/Evidence/Evidence.js.map +1 -0
- package/dist/website/Media/Media.d.ts +173 -0
- package/dist/website/Media/Media.js +225 -0
- package/dist/website/Media/Media.js.map +1 -0
- package/dist/website/Media/MediaLightbox.d.ts +18 -0
- package/dist/website/Media/MediaLightbox.js +38 -0
- package/dist/website/Media/MediaLightbox.js.map +1 -0
- package/dist/website/Metrics/Metrics.d.ts +74 -0
- package/dist/website/Metrics/Metrics.js +96 -0
- package/dist/website/Metrics/Metrics.js.map +1 -0
- package/dist/website/Music/Music.d.ts +60 -0
- package/dist/website/Music/Music.js +80 -0
- package/dist/website/Music/Music.js.map +1 -0
- package/dist/website/Portfolio/FrameLayout.d.ts +9 -0
- package/dist/website/Portfolio/FrameLayout.js +42 -0
- package/dist/website/Portfolio/FrameLayout.js.map +1 -0
- package/dist/website/Portfolio/Portfolio.d.ts +49 -0
- package/dist/website/Portfolio/Portfolio.js +66 -0
- package/dist/website/Portfolio/Portfolio.js.map +1 -0
- package/dist/website/Portfolio/QuestionCard.d.ts +22 -0
- package/dist/website/Portfolio/QuestionCard.js +33 -0
- package/dist/website/Portfolio/QuestionCard.js.map +1 -0
- package/dist/website/PortfolioIndex/PortfolioIndex.d.ts +21 -0
- package/dist/website/PortfolioIndex/PortfolioIndex.js +31 -0
- package/dist/website/PortfolioIndex/PortfolioIndex.js.map +1 -0
- package/dist/website/Reading/Reading.d.ts +203 -0
- package/dist/website/Reading/Reading.js +357 -0
- package/dist/website/Reading/Reading.js.map +1 -0
- package/dist/website/Recovery/Recovery.d.ts +39 -0
- package/dist/website/Recovery/Recovery.js +96 -0
- package/dist/website/Recovery/Recovery.js.map +1 -0
- package/dist/website/SearchPalette/SearchPalette.d.ts +59 -0
- package/dist/website/SearchPalette/SearchPalette.js +120 -0
- package/dist/website/SearchPalette/SearchPalette.js.map +1 -0
- package/dist/website/SiteNavigation/SiteNavigation.d.ts +46 -0
- package/dist/website/SiteNavigation/SiteNavigation.js +101 -0
- package/dist/website/SiteNavigation/SiteNavigation.js.map +1 -0
- package/dist/website/SiteShell/SiteShell.d.ts +45 -0
- package/dist/website/SiteShell/SiteShell.js +46 -0
- package/dist/website/SiteShell/SiteShell.js.map +1 -0
- package/dist/website/Timeline/Timeline.d.ts +80 -0
- package/dist/website/Timeline/Timeline.js +99 -0
- package/dist/website/Timeline/Timeline.js.map +1 -0
- package/dist/website/index.d.ts +27 -0
- package/dist/website/index.js +21 -0
- package/dist/website/index.js.map +1 -0
- package/dist/website-actions.css +6 -0
- package/dist/website-base.css +46 -0
- package/dist/website-collection.css +89 -0
- package/dist/website-contact.css +29 -0
- package/dist/website-content.css +17 -0
- package/dist/website-controls.css +91 -0
- package/dist/website-conversation.css +115 -0
- package/dist/website-evidence.css +56 -0
- package/dist/website-media.css +227 -0
- package/dist/website-metrics.css +15 -0
- package/dist/website-music.css +27 -0
- package/dist/website-portfolio.css +94 -0
- package/dist/website-reading.css +159 -0
- package/dist/website-recovery.css +28 -0
- package/dist/website-search.css +26 -0
- package/dist/website-shell.css +89 -0
- package/dist/website-timeline.css +43 -0
- package/dist/website.css +25 -0
- package/llms.txt +35 -0
- package/package.json +163 -5
- package/skills/folio-design/SKILL.md +228 -0
- package/skills/folio-design/evals/claims.json +95 -0
- package/skills/folio-design/evals/evals.json +84 -0
- package/skills/folio-design/rules/a11y.md +167 -0
- package/skills/folio-design/rules/composition.md +108 -0
- package/skills/folio-design/rules/forms.md +135 -0
- package/skills/folio-design/rules/naming.md +155 -0
- package/skills/folio-design/rules/tokens.md +133 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, RefObject, FC } from 'react';
|
|
3
|
+
import { ChartZoom } from './zoom.js';
|
|
4
|
+
import { ChartColumn } from './figure.js';
|
|
5
|
+
import './brush.js';
|
|
6
|
+
import 'recharts';
|
|
7
|
+
import './chart.js';
|
|
8
|
+
import './empty.js';
|
|
9
|
+
|
|
10
|
+
/** Which file a reader can take away. */
|
|
11
|
+
type ChartExportFormat = 'png' | 'csv';
|
|
12
|
+
interface ToolbarProps {
|
|
13
|
+
/**
|
|
14
|
+
* Which files the toolbar offers. `[]` drops the export controls and leaves
|
|
15
|
+
* a zoom-only toolbar.
|
|
16
|
+
*/
|
|
17
|
+
exports?: ChartExportFormat[];
|
|
18
|
+
/**
|
|
19
|
+
* Off leaves only the export controls, and the plot stops responding to the
|
|
20
|
+
* wheel, to a drag and to the keyboard. For a chart whose x axis is a handful
|
|
21
|
+
* of categories, where there is nothing to zoom into.
|
|
22
|
+
*/
|
|
23
|
+
zoom?: boolean;
|
|
24
|
+
/** Base name for a downloaded file. Defaults to the figure's title. */
|
|
25
|
+
filename?: string;
|
|
26
|
+
/** Which end of the plot the row sits at. */
|
|
27
|
+
align?: 'start' | 'end';
|
|
28
|
+
/** Fires after a file has been handed to the browser. */
|
|
29
|
+
onExport?: (format: ChartExportFormat) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Fires when an export fails — a chart that has not been measured yet, or a
|
|
32
|
+
* canvas tainted by a cross-origin image. Without it the error is logged,
|
|
33
|
+
* because a download that silently does nothing is the worst of the three.
|
|
34
|
+
*/
|
|
35
|
+
onExportError?: (error: Error) => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Declares the toolbar above a chart: zoom, reset, and taking the figure away
|
|
39
|
+
* as a PNG or a CSV.
|
|
40
|
+
*
|
|
41
|
+
* Renders nothing itself — its PRESENCE among the chart's children turns the
|
|
42
|
+
* toolbar on, and its props configure it, the same shape `<Chart.Brush>` uses.
|
|
43
|
+
* The toolbar is also what switches the plot's own zoom gestures on, so a chart
|
|
44
|
+
* that composes it becomes wheel-, drag- and keyboard-zoomable at the same
|
|
45
|
+
* time.
|
|
46
|
+
*
|
|
47
|
+
* Reach for `<Chart.Brush>` INSTEAD when the reader needs to see the whole
|
|
48
|
+
* series while choosing a slice of it; reach for both when they need to do that
|
|
49
|
+
* and also step the zoom or take the numbers away. The two drive one window, so
|
|
50
|
+
* they cannot disagree.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* <LineChart title="Visitors per day" config={config} data={data} xDataKey="day">
|
|
54
|
+
* <LineChart.Toolbar exports={['png', 'csv']} />
|
|
55
|
+
* <LineChart.XAxis dataKey="day" />
|
|
56
|
+
* <LineChart.Line dataKey="desktop" />
|
|
57
|
+
* </LineChart>
|
|
58
|
+
*/
|
|
59
|
+
declare const Toolbar: FC<ToolbarProps>;
|
|
60
|
+
interface ChartToolbarProps extends ToolbarProps {
|
|
61
|
+
/** The element the PNG export reads the plot out of. */
|
|
62
|
+
targetRef: RefObject<HTMLElement | null>;
|
|
63
|
+
/** The figure's title: the toolbar's name, the PNG's caption, the filename. */
|
|
64
|
+
title: string;
|
|
65
|
+
/** The rows a CSV export writes. */
|
|
66
|
+
rows: Record<string, unknown>[];
|
|
67
|
+
/** The columns a CSV export writes, in order. */
|
|
68
|
+
columns: ChartColumn[];
|
|
69
|
+
/** The window these controls drive. */
|
|
70
|
+
zoomState: ChartZoom;
|
|
71
|
+
className?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The row of controls above a plot.
|
|
75
|
+
*
|
|
76
|
+
* A `group` rather than a `toolbar`: the toolbar role promises roving
|
|
77
|
+
* tabindex, and a row of five ordinary buttons that each take a tab stop is
|
|
78
|
+
* both simpler and correct. Every control is a real `<button>` with a real
|
|
79
|
+
* accessible name, repeated as a native `title` for sighted pointer users.
|
|
80
|
+
*
|
|
81
|
+
* There are five controls at most and no overflow menu, which is a size
|
|
82
|
+
* decision as much as a design one: a row that can never exceed five 44px
|
|
83
|
+
* targets does not need one, and the menu component it would take is Radix
|
|
84
|
+
* Menu — around 60 kB that every consumer of every cartesian chart would ship
|
|
85
|
+
* whether or not they compose a toolbar, because the chart reaches it
|
|
86
|
+
* statically. A caller with less width drops controls (`zoom={false}`,
|
|
87
|
+
* `exports={['csv']}`) rather than hiding them behind a second gesture. The
|
|
88
|
+
* hover hints come off the native `title` for the same reason.
|
|
89
|
+
*
|
|
90
|
+
* Sized `md`, which is 44px at the default density. An icon button is exactly
|
|
91
|
+
* the control where the pointer-target floor is most often quietly missed.
|
|
92
|
+
*
|
|
93
|
+
* ## What each export contains
|
|
94
|
+
*
|
|
95
|
+
* The PNG is a picture of the plot, so it shows the CURRENT window — zoom in
|
|
96
|
+
* and the export follows. The CSV is the whole dataset, like the figure's
|
|
97
|
+
* hidden data table, because a spreadsheet silently missing the rows the
|
|
98
|
+
* reader had scrolled past is data loss they cannot see.
|
|
99
|
+
*
|
|
100
|
+
* Composed for you by `<ChartControls>`; reach for it directly only when you
|
|
101
|
+
* are building a chart root of your own.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* <ChartToolbar
|
|
105
|
+
* targetRef={plotRef}
|
|
106
|
+
* title="Visitors per day"
|
|
107
|
+
* rows={data}
|
|
108
|
+
* columns={columns}
|
|
109
|
+
* zoomState={zoom}
|
|
110
|
+
* exports={['png', 'csv']}
|
|
111
|
+
* />
|
|
112
|
+
*/
|
|
113
|
+
declare function ChartToolbar({ targetRef, title, rows, columns, zoomState, exports, zoom, filename, align, onExport, onExportError, className, }: ChartToolbarProps): react.JSX.Element | null;
|
|
114
|
+
interface ChartControlsProps {
|
|
115
|
+
/** The composed `<Chart.Toolbar>` props, or null when the chart has none. */
|
|
116
|
+
toolbar: ToolbarProps | null;
|
|
117
|
+
/** The window the toolbar and the plot both drive. */
|
|
118
|
+
zoom: ChartZoom;
|
|
119
|
+
/** The figure's title. */
|
|
120
|
+
title: string;
|
|
121
|
+
/** The whole dataset — what a CSV export writes, zoomed or not. */
|
|
122
|
+
rows: Record<string, unknown>[];
|
|
123
|
+
/** The series columns, in ramp order. */
|
|
124
|
+
columns: ChartColumn[];
|
|
125
|
+
/** The row field naming each row. Written as the CSV's first column. */
|
|
126
|
+
rowKey?: string;
|
|
127
|
+
/** The plot. */
|
|
128
|
+
children: ReactNode;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The toolbar, the plot, and the wiring between them.
|
|
132
|
+
*
|
|
133
|
+
* One component rather than four copies of the same six lines, because every
|
|
134
|
+
* chart that carries a toolbar needs the identical arrangement: the row above,
|
|
135
|
+
* the zoom surface around the plot, and one ref shared between them so the PNG
|
|
136
|
+
* export reads the measured box rather than a guess.
|
|
137
|
+
*
|
|
138
|
+
* With no `<Chart.Toolbar>` composed it renders its children untouched — a
|
|
139
|
+
* chart that did not ask for a toolbar gets no extra element, no extra tab
|
|
140
|
+
* stop, and the layout it had before.
|
|
141
|
+
*/
|
|
142
|
+
declare function ChartControls({ toolbar, zoom, title, rows, columns, rowKey, children, }: ChartControlsProps): react.JSX.Element;
|
|
143
|
+
|
|
144
|
+
export { ChartControls, type ChartControlsProps, type ChartExportFormat, ChartToolbar, type ChartToolbarProps, Toolbar, type ToolbarProps };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { RiFileDownloadLine, RiImageDownloadLine, RiResetLeftLine, RiZoomInLine, RiZoomOutLine } from "@remixicon/react";
|
|
5
|
+
import { cn } from "../../lib/cn.js";
|
|
6
|
+
import { Button } from "../../components/Button/Button.js";
|
|
7
|
+
import { chartToCsv, chartToPng, downloadBlob, exportFilename } from "./export.js";
|
|
8
|
+
import { ChartZoomSurface } from "./zoom.js";
|
|
9
|
+
const Toolbar = () => null;
|
|
10
|
+
function ChartToolbar({
|
|
11
|
+
targetRef,
|
|
12
|
+
title,
|
|
13
|
+
rows,
|
|
14
|
+
columns,
|
|
15
|
+
zoomState,
|
|
16
|
+
exports = ["png", "csv"],
|
|
17
|
+
zoom = true,
|
|
18
|
+
filename,
|
|
19
|
+
align = "end",
|
|
20
|
+
onExport,
|
|
21
|
+
onExportError,
|
|
22
|
+
className
|
|
23
|
+
}) {
|
|
24
|
+
const [busy, setBusy] = useState(null);
|
|
25
|
+
const runExport = async (format) => {
|
|
26
|
+
setBusy(format);
|
|
27
|
+
try {
|
|
28
|
+
if (format === "csv") {
|
|
29
|
+
const csv = chartToCsv(rows, columns);
|
|
30
|
+
const blob = new Blob([csv], { type: "text/csv;charset=utf-8" });
|
|
31
|
+
downloadBlob(blob, exportFilename(filename ?? title, "csv"));
|
|
32
|
+
} else {
|
|
33
|
+
const element = targetRef.current;
|
|
34
|
+
if (!element) throw new Error("chart toolbar: the plot is not on the page yet");
|
|
35
|
+
downloadBlob(
|
|
36
|
+
await chartToPng(element, { title }),
|
|
37
|
+
exportFilename(filename ?? title, "png")
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
onExport?.(format);
|
|
41
|
+
} catch (cause) {
|
|
42
|
+
const error = cause instanceof Error ? cause : new Error(String(cause));
|
|
43
|
+
if (onExportError) onExportError(error);
|
|
44
|
+
else console.error(error);
|
|
45
|
+
} finally {
|
|
46
|
+
setBusy(null);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const controls = [];
|
|
50
|
+
if (zoom) {
|
|
51
|
+
controls.push(
|
|
52
|
+
{
|
|
53
|
+
id: "zoom-in",
|
|
54
|
+
label: "Zoom in",
|
|
55
|
+
icon: RiZoomInLine,
|
|
56
|
+
disabled: !zoomState.canZoomIn,
|
|
57
|
+
run: () => zoomState.zoomIn()
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: "zoom-out",
|
|
61
|
+
label: "Zoom out",
|
|
62
|
+
icon: RiZoomOutLine,
|
|
63
|
+
disabled: !zoomState.canZoomOut,
|
|
64
|
+
run: () => zoomState.zoomOut()
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
id: "reset",
|
|
68
|
+
label: "Reset zoom",
|
|
69
|
+
icon: RiResetLeftLine,
|
|
70
|
+
disabled: !zoomState.isZoomed,
|
|
71
|
+
run: () => zoomState.reset()
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
if (exports.includes("png")) {
|
|
76
|
+
controls.push({
|
|
77
|
+
id: "png",
|
|
78
|
+
label: "Download PNG",
|
|
79
|
+
icon: RiImageDownloadLine,
|
|
80
|
+
busy: busy === "png",
|
|
81
|
+
disabled: busy !== null,
|
|
82
|
+
run: () => void runExport("png")
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
if (exports.includes("csv")) {
|
|
86
|
+
controls.push({
|
|
87
|
+
id: "csv",
|
|
88
|
+
label: "Download CSV",
|
|
89
|
+
icon: RiFileDownloadLine,
|
|
90
|
+
busy: busy === "csv",
|
|
91
|
+
disabled: busy !== null,
|
|
92
|
+
run: () => void runExport("csv")
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if (controls.length === 0) return null;
|
|
96
|
+
return /* @__PURE__ */ jsx(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
role: "group",
|
|
100
|
+
"aria-label": `${title} \u2014 chart controls`,
|
|
101
|
+
className: cn(
|
|
102
|
+
"flex items-center gap-1",
|
|
103
|
+
align === "end" ? "justify-end" : "justify-start",
|
|
104
|
+
className
|
|
105
|
+
),
|
|
106
|
+
children: controls.map((control) => /* @__PURE__ */ jsx(
|
|
107
|
+
Button,
|
|
108
|
+
{
|
|
109
|
+
iconOnly: true,
|
|
110
|
+
variant: "ghost",
|
|
111
|
+
size: "md",
|
|
112
|
+
"aria-label": control.label,
|
|
113
|
+
title: control.label,
|
|
114
|
+
disabled: control.disabled,
|
|
115
|
+
loading: control.busy,
|
|
116
|
+
onClick: control.run,
|
|
117
|
+
children: control.busy ? null : /* @__PURE__ */ jsx(control.icon, { size: 16, "aria-hidden": true })
|
|
118
|
+
},
|
|
119
|
+
control.id
|
|
120
|
+
))
|
|
121
|
+
}
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
function ChartControls({
|
|
125
|
+
toolbar,
|
|
126
|
+
zoom,
|
|
127
|
+
title,
|
|
128
|
+
rows,
|
|
129
|
+
columns,
|
|
130
|
+
rowKey,
|
|
131
|
+
children
|
|
132
|
+
}) {
|
|
133
|
+
const plotRef = useRef(null);
|
|
134
|
+
if (!toolbar) return /* @__PURE__ */ jsx(Fragment, { children });
|
|
135
|
+
const csvColumns = rowKey ? [{ key: rowKey, label: rowKey }, ...columns] : columns;
|
|
136
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 w-full flex-1 flex-col", children: [
|
|
137
|
+
/* @__PURE__ */ jsx(
|
|
138
|
+
ChartToolbar,
|
|
139
|
+
{
|
|
140
|
+
...toolbar,
|
|
141
|
+
targetRef: plotRef,
|
|
142
|
+
title,
|
|
143
|
+
rows,
|
|
144
|
+
columns: csvColumns,
|
|
145
|
+
zoomState: zoom
|
|
146
|
+
}
|
|
147
|
+
),
|
|
148
|
+
/* @__PURE__ */ jsx(ChartZoomSurface, { ref: plotRef, zoom, label: title, enabled: toolbar.zoom !== false, children })
|
|
149
|
+
] });
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
ChartControls,
|
|
153
|
+
ChartToolbar,
|
|
154
|
+
Toolbar
|
|
155
|
+
};
|
|
156
|
+
//# sourceMappingURL=toolbar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/charts/lib/toolbar.tsx"],"sourcesContent":["'use client'\n\nimport { useRef, useState, type FC, type ReactNode, type RefObject } from 'react'\nimport { RiFileDownloadLine, RiImageDownloadLine, RiResetLeftLine, RiZoomInLine, RiZoomOutLine, type RemixiconComponentType } from '@remixicon/react'\nimport { cn } from '../../lib/cn'\nimport { Button } from '../../components/Button/Button'\nimport { chartToCsv, chartToPng, downloadBlob, exportFilename } from './export'\nimport { ChartZoomSurface, type ChartZoom } from './zoom'\nimport type { ChartColumn } from './figure'\n\n/** Which file a reader can take away. */\nexport type ChartExportFormat = 'png' | 'csv'\n\nexport interface ToolbarProps {\n /**\n * Which files the toolbar offers. `[]` drops the export controls and leaves\n * a zoom-only toolbar.\n */\n exports?: ChartExportFormat[]\n /**\n * Off leaves only the export controls, and the plot stops responding to the\n * wheel, to a drag and to the keyboard. For a chart whose x axis is a handful\n * of categories, where there is nothing to zoom into.\n */\n zoom?: boolean\n /** Base name for a downloaded file. Defaults to the figure's title. */\n filename?: string\n /** Which end of the plot the row sits at. */\n align?: 'start' | 'end'\n /** Fires after a file has been handed to the browser. */\n onExport?: (format: ChartExportFormat) => void\n /**\n * Fires when an export fails — a chart that has not been measured yet, or a\n * canvas tainted by a cross-origin image. Without it the error is logged,\n * because a download that silently does nothing is the worst of the three.\n */\n onExportError?: (error: Error) => void\n}\n\n/**\n * Declares the toolbar above a chart: zoom, reset, and taking the figure away\n * as a PNG or a CSV.\n *\n * Renders nothing itself — its PRESENCE among the chart's children turns the\n * toolbar on, and its props configure it, the same shape `<Chart.Brush>` uses.\n * The toolbar is also what switches the plot's own zoom gestures on, so a chart\n * that composes it becomes wheel-, drag- and keyboard-zoomable at the same\n * time.\n *\n * Reach for `<Chart.Brush>` INSTEAD when the reader needs to see the whole\n * series while choosing a slice of it; reach for both when they need to do that\n * and also step the zoom or take the numbers away. The two drive one window, so\n * they cannot disagree.\n *\n * @example\n * <LineChart title=\"Visitors per day\" config={config} data={data} xDataKey=\"day\">\n * <LineChart.Toolbar exports={['png', 'csv']} />\n * <LineChart.XAxis dataKey=\"day\" />\n * <LineChart.Line dataKey=\"desktop\" />\n * </LineChart>\n */\nexport const Toolbar: FC<ToolbarProps> = () => null\n\n/** One button on the row, or one row in the overflow menu. */\ninterface ToolbarControl {\n id: string\n /** The accessible name, the tooltip, and the menu row's text. One string. */\n label: string\n icon: RemixiconComponentType\n disabled?: boolean\n busy?: boolean\n run: () => void\n}\n\nexport interface ChartToolbarProps extends ToolbarProps {\n /** The element the PNG export reads the plot out of. */\n targetRef: RefObject<HTMLElement | null>\n /** The figure's title: the toolbar's name, the PNG's caption, the filename. */\n title: string\n /** The rows a CSV export writes. */\n rows: Record<string, unknown>[]\n /** The columns a CSV export writes, in order. */\n columns: ChartColumn[]\n /** The window these controls drive. */\n zoomState: ChartZoom\n className?: string\n}\n\n/**\n * The row of controls above a plot.\n *\n * A `group` rather than a `toolbar`: the toolbar role promises roving\n * tabindex, and a row of five ordinary buttons that each take a tab stop is\n * both simpler and correct. Every control is a real `<button>` with a real\n * accessible name, repeated as a native `title` for sighted pointer users.\n *\n * There are five controls at most and no overflow menu, which is a size\n * decision as much as a design one: a row that can never exceed five 44px\n * targets does not need one, and the menu component it would take is Radix\n * Menu — around 60 kB that every consumer of every cartesian chart would ship\n * whether or not they compose a toolbar, because the chart reaches it\n * statically. A caller with less width drops controls (`zoom={false}`,\n * `exports={['csv']}`) rather than hiding them behind a second gesture. The\n * hover hints come off the native `title` for the same reason.\n *\n * Sized `md`, which is 44px at the default density. An icon button is exactly\n * the control where the pointer-target floor is most often quietly missed.\n *\n * ## What each export contains\n *\n * The PNG is a picture of the plot, so it shows the CURRENT window — zoom in\n * and the export follows. The CSV is the whole dataset, like the figure's\n * hidden data table, because a spreadsheet silently missing the rows the\n * reader had scrolled past is data loss they cannot see.\n *\n * Composed for you by `<ChartControls>`; reach for it directly only when you\n * are building a chart root of your own.\n *\n * @example\n * <ChartToolbar\n * targetRef={plotRef}\n * title=\"Visitors per day\"\n * rows={data}\n * columns={columns}\n * zoomState={zoom}\n * exports={['png', 'csv']}\n * />\n */\nexport function ChartToolbar({\n targetRef,\n title,\n rows,\n columns,\n zoomState,\n exports = ['png', 'csv'],\n zoom = true,\n filename,\n align = 'end',\n onExport,\n onExportError,\n className,\n}: ChartToolbarProps) {\n const [busy, setBusy] = useState<ChartExportFormat | null>(null)\n\n const runExport = async (format: ChartExportFormat) => {\n setBusy(format)\n try {\n if (format === 'csv') {\n const csv = chartToCsv(rows, columns)\n const blob = new Blob([csv], { type: 'text/csv;charset=utf-8' })\n downloadBlob(blob, exportFilename(filename ?? title, 'csv'))\n } else {\n const element = targetRef.current\n if (!element) throw new Error('chart toolbar: the plot is not on the page yet')\n downloadBlob(\n await chartToPng(element, { title }),\n exportFilename(filename ?? title, 'png'),\n )\n }\n onExport?.(format)\n } catch (cause) {\n const error = cause instanceof Error ? cause : new Error(String(cause))\n // Never swallowed: the reader clicked a download and something has to\n // say it did not arrive.\n if (onExportError) onExportError(error)\n else console.error(error)\n } finally {\n setBusy(null)\n }\n }\n\n const controls: ToolbarControl[] = []\n\n if (zoom) {\n controls.push(\n {\n id: 'zoom-in',\n label: 'Zoom in',\n icon: RiZoomInLine,\n disabled: !zoomState.canZoomIn,\n run: () => zoomState.zoomIn(),\n },\n {\n id: 'zoom-out',\n label: 'Zoom out',\n icon: RiZoomOutLine,\n disabled: !zoomState.canZoomOut,\n run: () => zoomState.zoomOut(),\n },\n {\n id: 'reset',\n label: 'Reset zoom',\n icon: RiResetLeftLine,\n disabled: !zoomState.isZoomed,\n run: () => zoomState.reset(),\n },\n )\n }\n\n if (exports.includes('png')) {\n controls.push({\n id: 'png',\n label: 'Download PNG',\n icon: RiImageDownloadLine,\n busy: busy === 'png',\n disabled: busy !== null,\n run: () => void runExport('png'),\n })\n }\n\n if (exports.includes('csv')) {\n controls.push({\n id: 'csv',\n label: 'Download CSV',\n icon: RiFileDownloadLine,\n busy: busy === 'csv',\n disabled: busy !== null,\n run: () => void runExport('csv'),\n })\n }\n\n if (controls.length === 0) return null\n\n return (\n <div\n role=\"group\"\n aria-label={`${title} — chart controls`}\n className={cn(\n 'flex items-center gap-1',\n align === 'end' ? 'justify-end' : 'justify-start',\n className,\n )}\n >\n {controls.map((control) => (\n <Button\n key={control.id}\n iconOnly\n variant=\"ghost\"\n size=\"md\"\n aria-label={control.label}\n // The same string again as a native hint. `aria-label` is what a\n // screen reader announces and `title` is what a pointer user sees;\n // both read the one label, so they cannot drift apart.\n title={control.label}\n disabled={control.disabled}\n loading={control.busy}\n onClick={control.run}\n >\n {/* Dropped while the spinner is up, so a 44px square never holds\n two glyphs at once. */}\n {control.busy ? null : <control.icon size={16} aria-hidden />}\n </Button>\n ))}\n </div>\n )\n}\n\nexport interface ChartControlsProps {\n /** The composed `<Chart.Toolbar>` props, or null when the chart has none. */\n toolbar: ToolbarProps | null\n /** The window the toolbar and the plot both drive. */\n zoom: ChartZoom\n /** The figure's title. */\n title: string\n /** The whole dataset — what a CSV export writes, zoomed or not. */\n rows: Record<string, unknown>[]\n /** The series columns, in ramp order. */\n columns: ChartColumn[]\n /** The row field naming each row. Written as the CSV's first column. */\n rowKey?: string\n /** The plot. */\n children: ReactNode\n}\n\n/**\n * The toolbar, the plot, and the wiring between them.\n *\n * One component rather than four copies of the same six lines, because every\n * chart that carries a toolbar needs the identical arrangement: the row above,\n * the zoom surface around the plot, and one ref shared between them so the PNG\n * export reads the measured box rather than a guess.\n *\n * With no `<Chart.Toolbar>` composed it renders its children untouched — a\n * chart that did not ask for a toolbar gets no extra element, no extra tab\n * stop, and the layout it had before.\n */\nexport function ChartControls({\n toolbar,\n zoom,\n title,\n rows,\n columns,\n rowKey,\n children,\n}: ChartControlsProps) {\n const plotRef = useRef<HTMLDivElement>(null)\n\n if (!toolbar) return <>{children}</>\n\n // The category column first, matching the hidden data table: a CSV whose\n // rows are unlabelled numbers is a CSV nobody can join anything to.\n const csvColumns = rowKey ? [{ key: rowKey, label: rowKey }, ...columns] : columns\n\n return (\n <div className=\"flex min-h-0 w-full flex-1 flex-col\">\n <ChartToolbar\n {...toolbar}\n targetRef={plotRef}\n title={title}\n rows={rows}\n columns={csvColumns}\n zoomState={zoom}\n />\n <ChartZoomSurface ref={plotRef} zoom={zoom} label={title} enabled={toolbar.zoom !== false}>\n {children}\n </ChartZoomSurface>\n </div>\n )\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ComponentProps, CSSProperties } from 'react';
|
|
3
|
+
import { Tooltip, DefaultTooltipContentProps } from 'recharts';
|
|
4
|
+
import { ValueType, NameType } from 'recharts/types/component/DefaultTooltipContent';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The tooltip's corner, on the system's radius ladder.
|
|
8
|
+
*
|
|
9
|
+
* Three steps, not the four this was ported with: the ladder has four rungs and
|
|
10
|
+
* the fourth is the pill, which is a shape rather than a corner. An `xl` that
|
|
11
|
+
* resolved to "the same as lg, but 4px more" would be a fifth step invented for
|
|
12
|
+
* one component.
|
|
13
|
+
*/
|
|
14
|
+
type ChartTooltipRoundness = 'sm' | 'md' | 'lg';
|
|
15
|
+
/** The tooltip's ground: the page's own, or a translucent plate over the plot. */
|
|
16
|
+
type ChartTooltipVariant = 'solid' | 'frosted';
|
|
17
|
+
/** How a series is marked beside its value. */
|
|
18
|
+
type ChartTooltipIndicator = 'dot' | 'line' | 'dashed';
|
|
19
|
+
interface ChartTooltipContentProps extends Omit<DefaultTooltipContentProps<ValueType, NameType>, 'accessibilityLayer' | 'formatter' | 'labelFormatter'>, Pick<ComponentProps<typeof Tooltip>, 'formatter' | 'labelFormatter' | 'active'> {
|
|
20
|
+
className?: string;
|
|
21
|
+
labelClassName?: string;
|
|
22
|
+
/** Drops the row of series marks, leaving only the label. */
|
|
23
|
+
hideIndicator?: boolean;
|
|
24
|
+
/** Drops the heading row — the date, the category. */
|
|
25
|
+
hideLabel?: boolean;
|
|
26
|
+
indicator?: ChartTooltipIndicator;
|
|
27
|
+
/** The row field holding a series name, when it is not the `dataKey`. */
|
|
28
|
+
nameKey?: string;
|
|
29
|
+
/** The row field holding the heading, when it is not the axis value. */
|
|
30
|
+
labelKey?: string;
|
|
31
|
+
/** The chart's selected series, so the tooltip dims the rest with the plot. */
|
|
32
|
+
selected?: string | null;
|
|
33
|
+
roundness?: ChartTooltipRoundness;
|
|
34
|
+
variant?: ChartTooltipVariant;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* What the hover tooltip prints: a heading, then one row per series.
|
|
38
|
+
*
|
|
39
|
+
* Values are set in the mono face and `tabular-nums` so a column of numbers
|
|
40
|
+
* lines up as the pointer moves along the axis — without it the row width
|
|
41
|
+
* changes under the cursor and the reader chases it.
|
|
42
|
+
*/
|
|
43
|
+
declare function ChartTooltipContent({ active, payload, className, indicator, hideLabel, hideIndicator, label, labelFormatter, labelClassName, formatter, nameKey, labelKey, selected, roundness, variant, }: ChartTooltipContentProps): react.JSX.Element;
|
|
44
|
+
/**
|
|
45
|
+
* The series swatch: one colour, or the same gradient the mark is painted with.
|
|
46
|
+
*
|
|
47
|
+
* A dashed indicator has no fill — it IS its border — so the paint moves to
|
|
48
|
+
* `borderColor`, which cannot take a gradient and takes the first stop instead.
|
|
49
|
+
*/
|
|
50
|
+
declare function swatchStyle(key: string, stops: number, dashed?: boolean): CSSProperties;
|
|
51
|
+
/**
|
|
52
|
+
* The Recharts tooltip, with the system's timing.
|
|
53
|
+
*
|
|
54
|
+
* 200ms is short enough that the panel keeps up with a pointer travelling the
|
|
55
|
+
* axis, which is the whole failure mode a slower fade has.
|
|
56
|
+
*/
|
|
57
|
+
declare function ChartTooltip({ animationDuration, ...rest }: ComponentProps<typeof Tooltip>): react.JSX.Element;
|
|
58
|
+
|
|
59
|
+
export { ChartTooltip, ChartTooltipContent, type ChartTooltipContentProps, type ChartTooltipIndicator, type ChartTooltipRoundness, type ChartTooltipVariant, swatchStyle };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { Tooltip as RechartsTooltip } from "recharts";
|
|
5
|
+
import { cn } from "../../lib/cn.js";
|
|
6
|
+
import { colorStops, cssName, seriesFromPayload, useChart } from "./chart.js";
|
|
7
|
+
const ROUNDNESS = {
|
|
8
|
+
sm: "rounded-(--radius-sm)",
|
|
9
|
+
md: "rounded-(--radius)",
|
|
10
|
+
lg: "rounded-(--radius-lg)"
|
|
11
|
+
};
|
|
12
|
+
const VARIANT = {
|
|
13
|
+
solid: "bg-(--chart-surface)",
|
|
14
|
+
// The one place the system reaches for a backdrop filter. It is not a shadow
|
|
15
|
+
// — law 2 bans blurred DEPTH — it is the plot showing through a plate that
|
|
16
|
+
// sits on it, which is why the plate still needs its hairline to read as one.
|
|
17
|
+
frosted: "bg-(--chart-surface)/75 backdrop-blur-sm"
|
|
18
|
+
};
|
|
19
|
+
function ChartTooltipContent({
|
|
20
|
+
active,
|
|
21
|
+
payload,
|
|
22
|
+
className,
|
|
23
|
+
indicator = "dot",
|
|
24
|
+
hideLabel = false,
|
|
25
|
+
hideIndicator = false,
|
|
26
|
+
label,
|
|
27
|
+
labelFormatter,
|
|
28
|
+
labelClassName,
|
|
29
|
+
formatter,
|
|
30
|
+
nameKey,
|
|
31
|
+
labelKey,
|
|
32
|
+
selected,
|
|
33
|
+
roundness = "lg",
|
|
34
|
+
variant = "solid"
|
|
35
|
+
}) {
|
|
36
|
+
const { config } = useChart();
|
|
37
|
+
const heading = useMemo(() => {
|
|
38
|
+
if (hideLabel || !payload?.length) return null;
|
|
39
|
+
const [item] = payload;
|
|
40
|
+
const key = `${labelKey ?? item?.dataKey ?? item?.name ?? "value"}`;
|
|
41
|
+
const series = seriesFromPayload(config, item, key);
|
|
42
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label ?? label : series?.label;
|
|
43
|
+
if (labelFormatter) {
|
|
44
|
+
return /* @__PURE__ */ jsx("div", { className: cn("font-medium text-(--ink)", labelClassName), children: labelFormatter(value, payload) });
|
|
45
|
+
}
|
|
46
|
+
if (!value) return null;
|
|
47
|
+
return /* @__PURE__ */ jsx("div", { className: cn("font-medium text-(--ink)", labelClassName), children: value });
|
|
48
|
+
}, [config, hideLabel, label, labelClassName, labelFormatter, labelKey, payload]);
|
|
49
|
+
if (!active || !payload?.length) return /* @__PURE__ */ jsx("span", { className: "p-4" });
|
|
50
|
+
const nested = payload.length === 1 && indicator !== "dot";
|
|
51
|
+
return /* @__PURE__ */ jsxs(
|
|
52
|
+
"div",
|
|
53
|
+
{
|
|
54
|
+
className: cn(
|
|
55
|
+
"grid min-w-32 items-start gap-1.5 border border-(--rule-2) px-2.5 py-1.5 text-xs",
|
|
56
|
+
ROUNDNESS[roundness],
|
|
57
|
+
VARIANT[variant],
|
|
58
|
+
className
|
|
59
|
+
),
|
|
60
|
+
children: [
|
|
61
|
+
!nested ? heading : null,
|
|
62
|
+
/* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
63
|
+
const named = nameKey && item.payload ? item.payload[nameKey] : void 0;
|
|
64
|
+
const key = `${named ?? item.name ?? item.dataKey ?? "value"}`;
|
|
65
|
+
const series = seriesFromPayload(config, item, key);
|
|
66
|
+
const stops = colorStops(series);
|
|
67
|
+
return /* @__PURE__ */ jsx(
|
|
68
|
+
"div",
|
|
69
|
+
{
|
|
70
|
+
className: cn(
|
|
71
|
+
"flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5 [&>svg]:text-(--ink-3-aa)",
|
|
72
|
+
indicator === "dot" && "items-center",
|
|
73
|
+
selected != null && selected !== item.dataKey && "opacity-30"
|
|
74
|
+
),
|
|
75
|
+
children: formatter && item?.value !== void 0 && item.name ? formatter(item.value, item.name, item, index, payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
76
|
+
series?.icon ? /* @__PURE__ */ jsx(series.icon, { "aria-hidden": true }) : !hideIndicator && /* @__PURE__ */ jsx(
|
|
77
|
+
"span",
|
|
78
|
+
{
|
|
79
|
+
"aria-hidden": true,
|
|
80
|
+
className: cn("shrink-0 rounded-[2px]", {
|
|
81
|
+
"size-2.5": indicator === "dot",
|
|
82
|
+
"w-1": indicator === "line",
|
|
83
|
+
"w-0 border-[1.5px] border-dashed bg-transparent!": indicator === "dashed",
|
|
84
|
+
"my-0.5": nested && indicator === "dashed"
|
|
85
|
+
}),
|
|
86
|
+
style: swatchStyle(key, stops, indicator === "dashed")
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ jsxs(
|
|
90
|
+
"div",
|
|
91
|
+
{
|
|
92
|
+
className: cn(
|
|
93
|
+
"flex flex-1 justify-between gap-4 leading-none",
|
|
94
|
+
nested ? "items-end" : "items-center"
|
|
95
|
+
),
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
|
|
98
|
+
nested ? heading : null,
|
|
99
|
+
/* @__PURE__ */ jsx("span", { className: "text-(--ink-3-aa)", children: series?.label ?? item.name })
|
|
100
|
+
] }),
|
|
101
|
+
item.value != null && /* @__PURE__ */ jsx("span", { className: "font-mono font-medium tabular-nums text-(--ink)", children: typeof item.value === "number" ? item.value.toLocaleString() : String(item.value) })
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] })
|
|
106
|
+
},
|
|
107
|
+
index
|
|
108
|
+
);
|
|
109
|
+
}) })
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
function swatchStyle(key, stops, dashed = false) {
|
|
115
|
+
const name = cssName(key);
|
|
116
|
+
if (dashed) return { borderColor: `var(--color-${name}-0)` };
|
|
117
|
+
if (stops <= 1) return { background: `var(--color-${name}-0)` };
|
|
118
|
+
const gradient = Array.from({ length: stops }, (_, index) => {
|
|
119
|
+
const offset = index / (stops - 1) * 100;
|
|
120
|
+
return `var(--color-${name}-${index}) ${offset}%`;
|
|
121
|
+
}).join(", ");
|
|
122
|
+
return { background: `linear-gradient(to right, ${gradient})` };
|
|
123
|
+
}
|
|
124
|
+
function ChartTooltip({
|
|
125
|
+
animationDuration = 200,
|
|
126
|
+
...rest
|
|
127
|
+
}) {
|
|
128
|
+
return /* @__PURE__ */ jsx(RechartsTooltip, { animationDuration, ...rest });
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
ChartTooltip,
|
|
132
|
+
ChartTooltipContent,
|
|
133
|
+
swatchStyle
|
|
134
|
+
};
|
|
135
|
+
//# sourceMappingURL=tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/charts/lib/tooltip.tsx"],"sourcesContent":["'use client'\n\nimport { useMemo, type ComponentProps, type CSSProperties } from 'react'\nimport { Tooltip as RechartsTooltip } from 'recharts'\nimport type { NameType, ValueType } from 'recharts/types/component/DefaultTooltipContent'\nimport type { DefaultTooltipContentProps } from 'recharts'\nimport { cn } from '../../lib/cn'\nimport { colorStops, cssName, seriesFromPayload, useChart } from './chart'\n\n/**\n * The tooltip's corner, on the system's radius ladder.\n *\n * Three steps, not the four this was ported with: the ladder has four rungs and\n * the fourth is the pill, which is a shape rather than a corner. An `xl` that\n * resolved to \"the same as lg, but 4px more\" would be a fifth step invented for\n * one component.\n */\nexport type ChartTooltipRoundness = 'sm' | 'md' | 'lg'\n\n/** The tooltip's ground: the page's own, or a translucent plate over the plot. */\nexport type ChartTooltipVariant = 'solid' | 'frosted'\n\n/** How a series is marked beside its value. */\nexport type ChartTooltipIndicator = 'dot' | 'line' | 'dashed'\n\nconst ROUNDNESS: Record<ChartTooltipRoundness, string> = {\n sm: 'rounded-(--radius-sm)',\n md: 'rounded-(--radius)',\n lg: 'rounded-(--radius-lg)',\n}\n\nconst VARIANT: Record<ChartTooltipVariant, string> = {\n solid: 'bg-(--chart-surface)',\n // The one place the system reaches for a backdrop filter. It is not a shadow\n // — law 2 bans blurred DEPTH — it is the plot showing through a plate that\n // sits on it, which is why the plate still needs its hairline to read as one.\n frosted: 'bg-(--chart-surface)/75 backdrop-blur-sm',\n}\n\nexport interface ChartTooltipContentProps\n extends Omit<\n DefaultTooltipContentProps<ValueType, NameType>,\n 'accessibilityLayer' | 'formatter' | 'labelFormatter'\n >,\n Pick<ComponentProps<typeof RechartsTooltip>, 'formatter' | 'labelFormatter' | 'active'> {\n className?: string\n labelClassName?: string\n /** Drops the row of series marks, leaving only the label. */\n hideIndicator?: boolean\n /** Drops the heading row — the date, the category. */\n hideLabel?: boolean\n indicator?: ChartTooltipIndicator\n /** The row field holding a series name, when it is not the `dataKey`. */\n nameKey?: string\n /** The row field holding the heading, when it is not the axis value. */\n labelKey?: string\n /** The chart's selected series, so the tooltip dims the rest with the plot. */\n selected?: string | null\n roundness?: ChartTooltipRoundness\n variant?: ChartTooltipVariant\n}\n\n/**\n * What the hover tooltip prints: a heading, then one row per series.\n *\n * Values are set in the mono face and `tabular-nums` so a column of numbers\n * lines up as the pointer moves along the axis — without it the row width\n * changes under the cursor and the reader chases it.\n */\nexport function ChartTooltipContent({\n active,\n payload,\n className,\n indicator = 'dot',\n hideLabel = false,\n hideIndicator = false,\n label,\n labelFormatter,\n labelClassName,\n formatter,\n nameKey,\n labelKey,\n selected,\n roundness = 'lg',\n variant = 'solid',\n}: ChartTooltipContentProps) {\n const { config } = useChart()\n\n const heading = useMemo(() => {\n if (hideLabel || !payload?.length) return null\n\n const [item] = payload\n const key = `${labelKey ?? item?.dataKey ?? item?.name ?? 'value'}`\n const series = seriesFromPayload(config, item, key)\n const value =\n !labelKey && typeof label === 'string' ? (config[label]?.label ?? label) : series?.label\n\n if (labelFormatter) {\n return (\n <div className={cn('font-medium text-(--ink)', labelClassName)}>\n {labelFormatter(value, payload)}\n </div>\n )\n }\n if (!value) return null\n return <div className={cn('font-medium text-(--ink)', labelClassName)}>{value}</div>\n }, [config, hideLabel, label, labelClassName, labelFormatter, labelKey, payload])\n\n // An empty span rather than null: returning nothing lets Recharts reset the\n // tooltip's position to the origin, so the next hover animates in from the\n // top-left corner of the chart instead of from where the pointer is.\n if (!active || !payload?.length) return <span className=\"p-4\" />\n\n const nested = payload.length === 1 && indicator !== 'dot'\n\n return (\n <div\n className={cn(\n 'grid min-w-32 items-start gap-1.5 border border-(--rule-2) px-2.5 py-1.5 text-xs',\n ROUNDNESS[roundness],\n VARIANT[variant],\n className,\n )}\n >\n {!nested ? heading : null}\n <div className=\"grid gap-1.5\">\n {payload\n .filter((item) => item.type !== 'none')\n .map((item, index) => {\n const named =\n nameKey && item.payload\n ? (item.payload as Record<string, unknown>)[nameKey]\n : undefined\n const key = `${named ?? item.name ?? item.dataKey ?? 'value'}`\n const series = seriesFromPayload(config, item, key)\n const stops = colorStops(series)\n\n return (\n <div\n key={index}\n className={cn(\n 'flex w-full flex-wrap items-stretch gap-2 [&>svg]:size-2.5 [&>svg]:text-(--ink-3-aa)',\n indicator === 'dot' && 'items-center',\n selected != null && selected !== item.dataKey && 'opacity-30',\n )}\n >\n {formatter && item?.value !== undefined && item.name ? (\n formatter(item.value, item.name, item, index, payload)\n ) : (\n <>\n {series?.icon ? (\n <series.icon aria-hidden />\n ) : (\n !hideIndicator && (\n <span\n aria-hidden\n className={cn('shrink-0 rounded-[2px]', {\n 'size-2.5': indicator === 'dot',\n 'w-1': indicator === 'line',\n 'w-0 border-[1.5px] border-dashed bg-transparent!':\n indicator === 'dashed',\n 'my-0.5': nested && indicator === 'dashed',\n })}\n style={swatchStyle(key, stops, indicator === 'dashed')}\n />\n )\n )}\n <div\n className={cn(\n 'flex flex-1 justify-between gap-4 leading-none',\n nested ? 'items-end' : 'items-center',\n )}\n >\n <div className=\"grid gap-1.5\">\n {nested ? heading : null}\n <span className=\"text-(--ink-3-aa)\">{series?.label ?? item.name}</span>\n </div>\n {item.value != null && (\n <span className=\"font-mono font-medium tabular-nums text-(--ink)\">\n {typeof item.value === 'number'\n ? item.value.toLocaleString()\n : String(item.value)}\n </span>\n )}\n </div>\n </>\n )}\n </div>\n )\n })}\n </div>\n </div>\n )\n}\n\n/**\n * The series swatch: one colour, or the same gradient the mark is painted with.\n *\n * A dashed indicator has no fill — it IS its border — so the paint moves to\n * `borderColor`, which cannot take a gradient and takes the first stop instead.\n */\nexport function swatchStyle(key: string, stops: number, dashed = false): CSSProperties {\n const name = cssName(key)\n if (dashed) return { borderColor: `var(--color-${name}-0)` }\n if (stops <= 1) return { background: `var(--color-${name}-0)` }\n\n const gradient = Array.from({ length: stops }, (_, index) => {\n const offset = (index / (stops - 1)) * 100\n return `var(--color-${name}-${index}) ${offset}%`\n }).join(', ')\n\n // `to right` rather than a logical direction: the swatch mirrors the mark's\n // own gradient, and the mark is painted in SVG user space, which does not\n // flip with the document.\n return { background: `linear-gradient(to right, ${gradient})` }\n}\n\n/**\n * The Recharts tooltip, with the system's timing.\n *\n * 200ms is short enough that the panel keeps up with a pointer travelling the\n * axis, which is the whole failure mode a slower fade has.\n */\nexport function ChartTooltip({\n animationDuration = 200,\n ...rest\n}: ComponentProps<typeof RechartsTooltip>) {\n return <RechartsTooltip animationDuration={animationDuration} {...rest} />\n}\n"],"mappings":";AAmGQ,SAkDU,UAlDV,KA0Ec,YA1Ed;AAjGR,SAAS,eAAwD;AACjE,SAAS,WAAW,uBAAuB;AAG3C,SAAS,UAAU;AACnB,SAAS,YAAY,SAAS,mBAAmB,gBAAgB;AAkBjE,MAAM,YAAmD;AAAA,EACvD,IAAI;AAAA,EACJ,IAAI;AAAA,EACJ,IAAI;AACN;AAEA,MAAM,UAA+C;AAAA,EACnD,OAAO;AAAA;AAAA;AAAA;AAAA,EAIP,SAAS;AACX;AAgCO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY;AAAA,EACZ,UAAU;AACZ,GAA6B;AAC3B,QAAM,EAAE,OAAO,IAAI,SAAS;AAE5B,QAAM,UAAU,QAAQ,MAAM;AAC5B,QAAI,aAAa,CAAC,SAAS,OAAQ,QAAO;AAE1C,UAAM,CAAC,IAAI,IAAI;AACf,UAAM,MAAM,GAAG,YAAY,MAAM,WAAW,MAAM,QAAQ,OAAO;AACjE,UAAM,SAAS,kBAAkB,QAAQ,MAAM,GAAG;AAClD,UAAM,QACJ,CAAC,YAAY,OAAO,UAAU,WAAY,OAAO,KAAK,GAAG,SAAS,QAAS,QAAQ;AAErF,QAAI,gBAAgB;AAClB,aACE,oBAAC,SAAI,WAAW,GAAG,4BAA4B,cAAc,GAC1D,yBAAe,OAAO,OAAO,GAChC;AAAA,IAEJ;AACA,QAAI,CAAC,MAAO,QAAO;AACnB,WAAO,oBAAC,SAAI,WAAW,GAAG,4BAA4B,cAAc,GAAI,iBAAM;AAAA,EAChF,GAAG,CAAC,QAAQ,WAAW,OAAO,gBAAgB,gBAAgB,UAAU,OAAO,CAAC;AAKhF,MAAI,CAAC,UAAU,CAAC,SAAS,OAAQ,QAAO,oBAAC,UAAK,WAAU,OAAM;AAE9D,QAAM,SAAS,QAAQ,WAAW,KAAK,cAAc;AAErD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW;AAAA,QACT;AAAA,QACA,UAAU,SAAS;AAAA,QACnB,QAAQ,OAAO;AAAA,QACf;AAAA,MACF;AAAA,MAEC;AAAA,SAAC,SAAS,UAAU;AAAA,QACrB,oBAAC,SAAI,WAAU,gBACZ,kBACE,OAAO,CAAC,SAAS,KAAK,SAAS,MAAM,EACrC,IAAI,CAAC,MAAM,UAAU;AACpB,gBAAM,QACJ,WAAW,KAAK,UACX,KAAK,QAAoC,OAAO,IACjD;AACN,gBAAM,MAAM,GAAG,SAAS,KAAK,QAAQ,KAAK,WAAW,OAAO;AAC5D,gBAAM,SAAS,kBAAkB,QAAQ,MAAM,GAAG;AAClD,gBAAM,QAAQ,WAAW,MAAM;AAE/B,iBACE;AAAA,YAAC;AAAA;AAAA,cAEC,WAAW;AAAA,gBACT;AAAA,gBACA,cAAc,SAAS;AAAA,gBACvB,YAAY,QAAQ,aAAa,KAAK,WAAW;AAAA,cACnD;AAAA,cAEC,uBAAa,MAAM,UAAU,UAAa,KAAK,OAC9C,UAAU,KAAK,OAAO,KAAK,MAAM,MAAM,OAAO,OAAO,IAErD,iCACG;AAAA,wBAAQ,OACP,oBAAC,OAAO,MAAP,EAAY,eAAW,MAAC,IAEzB,CAAC,iBACC;AAAA,kBAAC;AAAA;AAAA,oBACC,eAAW;AAAA,oBACX,WAAW,GAAG,0BAA0B;AAAA,sBACtC,YAAY,cAAc;AAAA,sBAC1B,OAAO,cAAc;AAAA,sBACrB,oDACE,cAAc;AAAA,sBAChB,UAAU,UAAU,cAAc;AAAA,oBACpC,CAAC;AAAA,oBACD,OAAO,YAAY,KAAK,OAAO,cAAc,QAAQ;AAAA;AAAA,gBACvD;AAAA,gBAGJ;AAAA,kBAAC;AAAA;AAAA,oBACC,WAAW;AAAA,sBACT;AAAA,sBACA,SAAS,cAAc;AAAA,oBACzB;AAAA,oBAEA;AAAA,2CAAC,SAAI,WAAU,gBACZ;AAAA,iCAAS,UAAU;AAAA,wBACpB,oBAAC,UAAK,WAAU,qBAAqB,kBAAQ,SAAS,KAAK,MAAK;AAAA,yBAClE;AAAA,sBACC,KAAK,SAAS,QACb,oBAAC,UAAK,WAAU,mDACb,iBAAO,KAAK,UAAU,WACnB,KAAK,MAAM,eAAe,IAC1B,OAAO,KAAK,KAAK,GACvB;AAAA;AAAA;AAAA,gBAEJ;AAAA,iBACF;AAAA;AAAA,YA9CG;AAAA,UAgDP;AAAA,QAEJ,CAAC,GACL;AAAA;AAAA;AAAA,EACF;AAEJ;AAQO,SAAS,YAAY,KAAa,OAAe,SAAS,OAAsB;AACrF,QAAM,OAAO,QAAQ,GAAG;AACxB,MAAI,OAAQ,QAAO,EAAE,aAAa,eAAe,IAAI,MAAM;AAC3D,MAAI,SAAS,EAAG,QAAO,EAAE,YAAY,eAAe,IAAI,MAAM;AAE9D,QAAM,WAAW,MAAM,KAAK,EAAE,QAAQ,MAAM,GAAG,CAAC,GAAG,UAAU;AAC3D,UAAM,SAAU,SAAS,QAAQ,KAAM;AACvC,WAAO,eAAe,IAAI,IAAI,KAAK,KAAK,MAAM;AAAA,EAChD,CAAC,EAAE,KAAK,IAAI;AAKZ,SAAO,EAAE,YAAY,6BAA6B,QAAQ,IAAI;AAChE;AAQO,SAAS,aAAa;AAAA,EAC3B,oBAAoB;AAAA,EACpB,GAAG;AACL,GAA2C;AACzC,SAAO,oBAAC,mBAAgB,mBAAuC,GAAG,MAAM;AAC1E;","names":[]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { FC, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The props of the first child of a given type, or null.
|
|
6
|
+
*
|
|
7
|
+
* Every configuration slot in the package is read this way — a component that
|
|
8
|
+
* renders nothing, whose PROPS are the configuration. It reads better at the
|
|
9
|
+
* call site than a prop bag (`<Chart.Values show="last" />` beside the mark it
|
|
10
|
+
* labels, rather than `valuesShow="last"` on the mark) and it keeps the marks'
|
|
11
|
+
* prop lists from growing a section per optional decoration.
|
|
12
|
+
*/
|
|
13
|
+
declare function findSlot<TProps>(children: ReactNode, type: unknown): TProps | null;
|
|
14
|
+
/**
|
|
15
|
+
* Which points get their number printed.
|
|
16
|
+
*
|
|
17
|
+
* The default is `last`, and the default matters more here than usual: a
|
|
18
|
+
* number on every point is the most common way a chart is spoiled, because the
|
|
19
|
+
* labels then compete with the shape they are annotating and the reader loses
|
|
20
|
+
* both. What a reader almost always wants is the number they would otherwise
|
|
21
|
+
* have to trace back to the axis for — the latest value, or the two ends.
|
|
22
|
+
*
|
|
23
|
+
* `all` exists for the case it is right for: five or six bars, no line, and the
|
|
24
|
+
* exact figures ARE the point. Past that it is a table wearing a chart.
|
|
25
|
+
*/
|
|
26
|
+
type ValueLabelMode = 'all' | 'first' | 'last' | 'first-last' | 'extremes';
|
|
27
|
+
interface ValuesProps {
|
|
28
|
+
/** Which points are labelled. */
|
|
29
|
+
show?: ValueLabelMode;
|
|
30
|
+
/** Formats each number. Defaults to the axis's own compact formatting. */
|
|
31
|
+
formatValue?: (value: number) => string;
|
|
32
|
+
/** Where the label sits relative to its point. */
|
|
33
|
+
position?: 'top' | 'bottom' | 'inside' | 'right';
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Prints the numbers on a series.
|
|
37
|
+
*
|
|
38
|
+
* A slot: it renders nothing itself, and the mark it is composed inside reads
|
|
39
|
+
* its props.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* <BarChart.Bar dataKey="visitors">
|
|
43
|
+
* <BarChart.Values show="all" />
|
|
44
|
+
* </BarChart.Bar>
|
|
45
|
+
*/
|
|
46
|
+
declare const Values: FC<ValuesProps>;
|
|
47
|
+
/**
|
|
48
|
+
* Turns a composed `<Values>` slot into a Recharts label list.
|
|
49
|
+
*
|
|
50
|
+
* `values` is the whole series, needed because `extremes` cannot be decided
|
|
51
|
+
* one point at a time — and Recharts hands a label renderer one point at a
|
|
52
|
+
* time.
|
|
53
|
+
*/
|
|
54
|
+
declare function resolveValues(slot: ValuesProps | null, values: number[], fallbackPosition?: ValuesProps['position']): react.JSX.Element | null;
|
|
55
|
+
|
|
56
|
+
export { type ValueLabelMode, Values, type ValuesProps, findSlot, resolveValues };
|