@cronus-ui/ui 0.6.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/LICENSE +21 -0
- package/README.md +262 -0
- package/dist/charts/animation.d.ts +11 -0
- package/dist/charts/animation.js +29 -0
- package/dist/charts/area-chart-loading.d.ts +34 -0
- package/dist/charts/area-chart-loading.js +22 -0
- package/dist/charts/area-chart.d.ts +48 -0
- package/dist/charts/area-chart.js +57 -0
- package/dist/charts/area-gradient-defs.d.ts +20 -0
- package/dist/charts/area-gradient-defs.js +15 -0
- package/dist/charts/area.d.ts +76 -0
- package/dist/charts/area.js +104 -0
- package/dist/charts/background.d.ts +27 -0
- package/dist/charts/background.js +68 -0
- package/dist/charts/bar-chart-loading.d.ts +17 -0
- package/dist/charts/bar-chart-loading.js +14 -0
- package/dist/charts/bar-chart.d.ts +55 -0
- package/dist/charts/bar-chart.js +432 -0
- package/dist/charts/bar-depth-geometry.d.ts +33 -0
- package/dist/charts/bar-depth-geometry.js +38 -0
- package/dist/charts/bar-depth.d.ts +157 -0
- package/dist/charts/bar-depth.js +586 -0
- package/dist/charts/bar-squares-layout.d.ts +28 -0
- package/dist/charts/bar-squares-layout.js +47 -0
- package/dist/charts/bar-squares.d.ts +49 -0
- package/dist/charts/bar-squares.js +207 -0
- package/dist/charts/bar-x-axis.d.ts +14 -0
- package/dist/charts/bar-x-axis.js +73 -0
- package/dist/charts/bar-y-axis.d.ts +12 -0
- package/dist/charts/bar-y-axis.js +64 -0
- package/dist/charts/bar.d.ts +41 -0
- package/dist/charts/bar.js +208 -0
- package/dist/charts/candlestick-chart.d.ts +46 -0
- package/dist/charts/candlestick-chart.js +203 -0
- package/dist/charts/candlestick.d.ts +24 -0
- package/dist/charts/candlestick.js +139 -0
- package/dist/charts/chart-brush-handle.d.ts +15 -0
- package/dist/charts/chart-brush-handle.js +47 -0
- package/dist/charts/chart-brush-layout.d.ts +27 -0
- package/dist/charts/chart-brush-layout.js +42 -0
- package/dist/charts/chart-brush-selection-overlay.d.ts +19 -0
- package/dist/charts/chart-brush-selection-overlay.js +44 -0
- package/dist/charts/chart-brush-track-overlay.d.ts +23 -0
- package/dist/charts/chart-brush-track-overlay.js +65 -0
- package/dist/charts/chart-brush.d.ts +32 -0
- package/dist/charts/chart-brush.js +116 -0
- package/dist/charts/chart-center-typography.d.ts +12 -0
- package/dist/charts/chart-center-typography.js +12 -0
- package/dist/charts/chart-child-passthrough.d.ts +17 -0
- package/dist/charts/chart-child-passthrough.js +74 -0
- package/dist/charts/chart-config-context.d.ts +26 -0
- package/dist/charts/chart-config-context.js +47 -0
- package/dist/charts/chart-context.d.ts +199 -0
- package/dist/charts/chart-context.js +201 -0
- package/dist/charts/chart-defs.d.ts +13 -0
- package/dist/charts/chart-defs.js +49 -0
- package/dist/charts/chart-formatters.d.ts +10 -0
- package/dist/charts/chart-formatters.js +28 -0
- package/dist/charts/chart-legend-hover.d.ts +13 -0
- package/dist/charts/chart-legend-hover.js +18 -0
- package/dist/charts/chart-legend.d.ts +55 -0
- package/dist/charts/chart-legend.js +30 -0
- package/dist/charts/chart-loading-label.d.ts +10 -0
- package/dist/charts/chart-loading-label.js +21 -0
- package/dist/charts/chart-phase.d.ts +31 -0
- package/dist/charts/chart-phase.js +21 -0
- package/dist/charts/chart-reveal-clip.d.ts +24 -0
- package/dist/charts/chart-reveal-clip.js +24 -0
- package/dist/charts/chart-scale.d.ts +12 -0
- package/dist/charts/chart-scale.js +17 -0
- package/dist/charts/chart-stat-flow.d.ts +36 -0
- package/dist/charts/chart-stat-flow.js +23 -0
- package/dist/charts/choropleth/choropleth-chart.d.ts +43 -0
- package/dist/charts/choropleth/choropleth-chart.js +218 -0
- package/dist/charts/choropleth/choropleth-context.d.ts +86 -0
- package/dist/charts/choropleth/choropleth-context.js +106 -0
- package/dist/charts/choropleth/choropleth-feature.d.ts +13 -0
- package/dist/charts/choropleth/choropleth-feature.js +125 -0
- package/dist/charts/choropleth/choropleth-graticule.d.ts +11 -0
- package/dist/charts/choropleth/choropleth-graticule.js +12 -0
- package/dist/charts/choropleth/choropleth-tooltip.d.ts +31 -0
- package/dist/charts/choropleth/choropleth-tooltip.js +50 -0
- package/dist/charts/choropleth/index.d.ts +7 -0
- package/dist/charts/choropleth/index.js +6 -0
- package/dist/charts/composed-chart.d.ts +36 -0
- package/dist/charts/composed-chart.js +152 -0
- package/dist/charts/dash-tail-stroke.d.ts +18 -0
- package/dist/charts/dash-tail-stroke.js +13 -0
- package/dist/charts/decimate-time-series.d.ts +10 -0
- package/dist/charts/decimate-time-series.js +112 -0
- package/dist/charts/fade-edges.d.ts +34 -0
- package/dist/charts/fade-edges.js +35 -0
- package/dist/charts/filter-data-by-x-domain.d.ts +5 -0
- package/dist/charts/filter-data-by-x-domain.js +42 -0
- package/dist/charts/funnel-chart.d.ts +91 -0
- package/dist/charts/funnel-chart.js +302 -0
- package/dist/charts/gauge-label-layout.d.ts +22 -0
- package/dist/charts/gauge-label-layout.js +44 -0
- package/dist/charts/gauge.d.ts +56 -0
- package/dist/charts/gauge.js +307 -0
- package/dist/charts/generate-chart-skeleton-data.d.ts +16 -0
- package/dist/charts/generate-chart-skeleton-data.js +25 -0
- package/dist/charts/grid.d.ts +58 -0
- package/dist/charts/grid.js +80 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.d.ts +4 -0
- package/dist/charts/heatmap/generate-heatmap-skeleton-data.js +12 -0
- package/dist/charts/heatmap/heatmap-animation.d.ts +41 -0
- package/dist/charts/heatmap/heatmap-animation.js +85 -0
- package/dist/charts/heatmap/heatmap-cells.d.ts +21 -0
- package/dist/charts/heatmap/heatmap-cells.js +265 -0
- package/dist/charts/heatmap/heatmap-chart-loading.d.ts +21 -0
- package/dist/charts/heatmap/heatmap-chart-loading.js +14 -0
- package/dist/charts/heatmap/heatmap-chart.d.ts +80 -0
- package/dist/charts/heatmap/heatmap-chart.js +275 -0
- package/dist/charts/heatmap/heatmap-colors.d.ts +70 -0
- package/dist/charts/heatmap/heatmap-colors.js +113 -0
- package/dist/charts/heatmap/heatmap-context.d.ts +109 -0
- package/dist/charts/heatmap/heatmap-context.js +69 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.d.ts +20 -0
- package/dist/charts/heatmap/heatmap-legend-gradient.js +44 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.d.ts +8 -0
- package/dist/charts/heatmap/heatmap-legend-swatch.js +26 -0
- package/dist/charts/heatmap/heatmap-legend.d.ts +41 -0
- package/dist/charts/heatmap/heatmap-legend.js +68 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.d.ts +5 -0
- package/dist/charts/heatmap/heatmap-pattern-defs.js +25 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.d.ts +8 -0
- package/dist/charts/heatmap/heatmap-resolve-separator.js +82 -0
- package/dist/charts/heatmap/heatmap-separator.d.ts +63 -0
- package/dist/charts/heatmap/heatmap-separator.js +71 -0
- package/dist/charts/heatmap/heatmap-tooltip.d.ts +30 -0
- package/dist/charts/heatmap/heatmap-tooltip.js +20 -0
- package/dist/charts/heatmap/heatmap-utils.d.ts +175 -0
- package/dist/charts/heatmap/heatmap-utils.js +595 -0
- package/dist/charts/heatmap/heatmap-x-axis.d.ts +7 -0
- package/dist/charts/heatmap/heatmap-x-axis.js +54 -0
- package/dist/charts/heatmap/heatmap-y-axis.d.ts +14 -0
- package/dist/charts/heatmap/heatmap-y-axis.js +37 -0
- package/dist/charts/heatmap/index.d.ts +15 -0
- package/dist/charts/heatmap/index.js +15 -0
- package/dist/charts/heatmap/use-delayed-tooltip-data.d.ts +3 -0
- package/dist/charts/heatmap/use-delayed-tooltip-data.js +53 -0
- package/dist/charts/highlight-segment-bounds.d.ts +18 -0
- package/dist/charts/highlight-segment-bounds.js +36 -0
- package/dist/charts/highlight-segment.d.ts +22 -0
- package/dist/charts/highlight-segment.js +14 -0
- package/dist/charts/index.d.ts +106 -0
- package/dist/charts/index.js +133 -0
- package/dist/charts/indicator-fade.d.ts +15 -0
- package/dist/charts/indicator-fade.js +42 -0
- package/dist/charts/legend/index.d.ts +8 -0
- package/dist/charts/legend/index.js +10 -0
- package/dist/charts/legend/legend-context.d.ts +48 -0
- package/dist/charts/legend/legend-context.js +34 -0
- package/dist/charts/legend/legend-item.d.ts +12 -0
- package/dist/charts/legend/legend-item.js +11 -0
- package/dist/charts/legend/legend-label.d.ts +9 -0
- package/dist/charts/legend/legend-label.js +10 -0
- package/dist/charts/legend/legend-marker.d.ts +9 -0
- package/dist/charts/legend/legend-marker.js +11 -0
- package/dist/charts/legend/legend-progress.d.ts +13 -0
- package/dist/charts/legend/legend-progress.js +15 -0
- package/dist/charts/legend/legend-value.d.ts +17 -0
- package/dist/charts/legend/legend-value.js +11 -0
- package/dist/charts/legend/legend.d.ts +23 -0
- package/dist/charts/legend/legend.js +43 -0
- package/dist/charts/line-chart-loading.d.ts +34 -0
- package/dist/charts/line-chart-loading.js +22 -0
- package/dist/charts/line-chart.d.ts +46 -0
- package/dist/charts/line-chart.js +91 -0
- package/dist/charts/line-loading-pulse.d.ts +20 -0
- package/dist/charts/line-loading-pulse.js +124 -0
- package/dist/charts/line-loading-timing.d.ts +10 -0
- package/dist/charts/line-loading-timing.js +10 -0
- package/dist/charts/line-series-terminal-marker.d.ts +16 -0
- package/dist/charts/line-series-terminal-marker.js +46 -0
- package/dist/charts/line.d.ts +64 -0
- package/dist/charts/line.js +96 -0
- package/dist/charts/live-line-chart.d.ts +35 -0
- package/dist/charts/live-line-chart.js +374 -0
- package/dist/charts/live-line.d.ts +39 -0
- package/dist/charts/live-line.js +78 -0
- package/dist/charts/live-x-axis.d.ts +12 -0
- package/dist/charts/live-x-axis.js +85 -0
- package/dist/charts/live-y-axis.d.ts +16 -0
- package/dist/charts/live-y-axis.js +137 -0
- package/dist/charts/loading-sweep.d.ts +66 -0
- package/dist/charts/loading-sweep.js +174 -0
- package/dist/charts/markers/chart-markers.d.ts +25 -0
- package/dist/charts/markers/chart-markers.js +87 -0
- package/dist/charts/markers/index.d.ts +3 -0
- package/dist/charts/markers/index.js +3 -0
- package/dist/charts/markers/marker-group.d.ts +88 -0
- package/dist/charts/markers/marker-group.js +171 -0
- package/dist/charts/motion-utils.d.ts +9 -0
- package/dist/charts/motion-utils.js +28 -0
- package/dist/charts/notch-gauge-shared.d.ts +49 -0
- package/dist/charts/notch-gauge-shared.js +103 -0
- package/dist/charts/path-stroke-utils.d.ts +20 -0
- package/dist/charts/path-stroke-utils.js +55 -0
- package/dist/charts/pattern-area.d.ts +21 -0
- package/dist/charts/pattern-area.js +19 -0
- package/dist/charts/pattern-preset.d.ts +26 -0
- package/dist/charts/pattern-preset.js +83 -0
- package/dist/charts/pie-center-shell.d.ts +24 -0
- package/dist/charts/pie-center-shell.js +109 -0
- package/dist/charts/pie-center.d.ts +46 -0
- package/dist/charts/pie-center.js +46 -0
- package/dist/charts/pie-chart.d.ts +50 -0
- package/dist/charts/pie-chart.js +248 -0
- package/dist/charts/pie-context.d.ts +74 -0
- package/dist/charts/pie-context.js +95 -0
- package/dist/charts/pie-slice.d.ts +28 -0
- package/dist/charts/pie-slice.js +180 -0
- package/dist/charts/profit-loss-legend-hover.d.ts +11 -0
- package/dist/charts/profit-loss-legend-hover.js +12 -0
- package/dist/charts/profit-loss-legend.d.ts +17 -0
- package/dist/charts/profit-loss-legend.js +18 -0
- package/dist/charts/profit-loss-line.d.ts +27 -0
- package/dist/charts/profit-loss-line.js +77 -0
- package/dist/charts/profit-loss-segments.d.ts +12 -0
- package/dist/charts/profit-loss-segments.js +86 -0
- package/dist/charts/projection-config.d.ts +11 -0
- package/dist/charts/projection-config.js +80 -0
- package/dist/charts/projection-line-end-marker.d.ts +15 -0
- package/dist/charts/projection-line-end-marker.js +27 -0
- package/dist/charts/projection-line.d.ts +40 -0
- package/dist/charts/projection-line.js +79 -0
- package/dist/charts/projection-utils.d.ts +46 -0
- package/dist/charts/projection-utils.js +253 -0
- package/dist/charts/radar-area.d.ts +17 -0
- package/dist/charts/radar-area.js +84 -0
- package/dist/charts/radar-axis.d.ts +14 -0
- package/dist/charts/radar-axis.js +24 -0
- package/dist/charts/radar-chart.d.ts +36 -0
- package/dist/charts/radar-chart.js +89 -0
- package/dist/charts/radar-context.d.ts +68 -0
- package/dist/charts/radar-context.js +87 -0
- package/dist/charts/radar-grid.d.ts +16 -0
- package/dist/charts/radar-grid.js +40 -0
- package/dist/charts/radar-labels.d.ts +16 -0
- package/dist/charts/radar-labels.js +29 -0
- package/dist/charts/reference-area-config.d.ts +10 -0
- package/dist/charts/reference-area-config.js +39 -0
- package/dist/charts/reference-area-geometry.d.ts +23 -0
- package/dist/charts/reference-area-geometry.js +68 -0
- package/dist/charts/reference-area-registration-context.d.ts +8 -0
- package/dist/charts/reference-area-registration-context.js +7 -0
- package/dist/charts/reference-area.d.ts +52 -0
- package/dist/charts/reference-area.js +101 -0
- package/dist/charts/ring-center.d.ts +46 -0
- package/dist/charts/ring-center.js +41 -0
- package/dist/charts/ring-chart.d.ts +41 -0
- package/dist/charts/ring-chart.js +212 -0
- package/dist/charts/ring-context.d.ts +66 -0
- package/dist/charts/ring-context.js +92 -0
- package/dist/charts/ring.d.ts +11 -0
- package/dist/charts/ring.js +104 -0
- package/dist/charts/sankey/index.d.ts +6 -0
- package/dist/charts/sankey/index.js +6 -0
- package/dist/charts/sankey/sankey-chart.d.ts +39 -0
- package/dist/charts/sankey/sankey-chart.js +117 -0
- package/dist/charts/sankey/sankey-context.d.ts +69 -0
- package/dist/charts/sankey/sankey-context.js +23 -0
- package/dist/charts/sankey/sankey-link.d.ts +26 -0
- package/dist/charts/sankey/sankey-link.js +155 -0
- package/dist/charts/sankey/sankey-node.d.ts +29 -0
- package/dist/charts/sankey/sankey-node.js +200 -0
- package/dist/charts/sankey/sankey-tooltip.d.ts +24 -0
- package/dist/charts/sankey/sankey-tooltip.js +70 -0
- package/dist/charts/scatter-chart-shell.d.ts +21 -0
- package/dist/charts/scatter-chart-shell.js +152 -0
- package/dist/charts/scatter-chart.d.ts +32 -0
- package/dist/charts/scatter-chart.js +56 -0
- package/dist/charts/scatter-svg.d.ts +6 -0
- package/dist/charts/scatter-svg.js +16 -0
- package/dist/charts/scatter.d.ts +21 -0
- package/dist/charts/scatter.js +30 -0
- package/dist/charts/segment.d.ts +26 -0
- package/dist/charts/segment.js +42 -0
- package/dist/charts/series-bar-layout.d.ts +18 -0
- package/dist/charts/series-bar-layout.js +31 -0
- package/dist/charts/series-bar.d.ts +20 -0
- package/dist/charts/series-bar.js +120 -0
- package/dist/charts/series-dash-tail-overlay.d.ts +17 -0
- package/dist/charts/series-dash-tail-overlay.js +39 -0
- package/dist/charts/series-highlight-layer.d.ts +23 -0
- package/dist/charts/series-highlight-layer.js +21 -0
- package/dist/charts/series-hover-dim.d.ts +29 -0
- package/dist/charts/series-hover-dim.js +26 -0
- package/dist/charts/series-markers.d.ts +14 -0
- package/dist/charts/series-markers.js +98 -0
- package/dist/charts/series-path-utils.d.ts +19 -0
- package/dist/charts/series-path-utils.js +60 -0
- package/dist/charts/series-point-marker.d.ts +48 -0
- package/dist/charts/series-point-marker.js +48 -0
- package/dist/charts/shimmering-text.d.ts +23 -0
- package/dist/charts/shimmering-text.js +31 -0
- package/dist/charts/static-chart-preview-context.d.ts +7 -0
- package/dist/charts/static-chart-preview-context.js +12 -0
- package/dist/charts/sunburst-breadcrumb.d.ts +16 -0
- package/dist/charts/sunburst-breadcrumb.js +26 -0
- package/dist/charts/sunburst-center.d.ts +5 -0
- package/dist/charts/sunburst-center.js +17 -0
- package/dist/charts/sunburst-chart.d.ts +30 -0
- package/dist/charts/sunburst-chart.js +263 -0
- package/dist/charts/sunburst-context.d.ts +61 -0
- package/dist/charts/sunburst-context.js +112 -0
- package/dist/charts/sunburst-data.d.ts +9 -0
- package/dist/charts/sunburst-data.js +2 -0
- package/dist/charts/sunburst-hint.d.ts +13 -0
- package/dist/charts/sunburst-hint.js +31 -0
- package/dist/charts/sunburst-labels.d.ts +9 -0
- package/dist/charts/sunburst-labels.js +63 -0
- package/dist/charts/sunburst-segment.d.ts +11 -0
- package/dist/charts/sunburst-segment.js +78 -0
- package/dist/charts/sunburst.d.ts +101 -0
- package/dist/charts/sunburst.js +396 -0
- package/dist/charts/time-series-chart-shell.d.ts +47 -0
- package/dist/charts/time-series-chart-shell.js +390 -0
- package/dist/charts/tooltip/chart-tooltip.d.ts +76 -0
- package/dist/charts/tooltip/chart-tooltip.js +150 -0
- package/dist/charts/tooltip/date-ticker.d.ts +11 -0
- package/dist/charts/tooltip/date-ticker.js +77 -0
- package/dist/charts/tooltip/index.d.ts +7 -0
- package/dist/charts/tooltip/index.js +7 -0
- package/dist/charts/tooltip/tooltip-box.d.ts +48 -0
- package/dist/charts/tooltip/tooltip-box.js +114 -0
- package/dist/charts/tooltip/tooltip-content.d.ts +18 -0
- package/dist/charts/tooltip/tooltip-content.js +9 -0
- package/dist/charts/tooltip/tooltip-dot.d.ts +28 -0
- package/dist/charts/tooltip/tooltip-dot.js +54 -0
- package/dist/charts/tooltip/tooltip-indicator.d.ts +45 -0
- package/dist/charts/tooltip/tooltip-indicator.js +65 -0
- package/dist/charts/use-animated-series-path.d.ts +19 -0
- package/dist/charts/use-animated-series-path.js +93 -0
- package/dist/charts/use-animated-y-domains.d.ts +14 -0
- package/dist/charts/use-animated-y-domains.js +150 -0
- package/dist/charts/use-chart-interaction.d.ts +41 -0
- package/dist/charts/use-chart-interaction.js +244 -0
- package/dist/charts/use-chart-phase-orchestrator.d.ts +23 -0
- package/dist/charts/use-chart-phase-orchestrator.js +139 -0
- package/dist/charts/use-enter-complete.d.ts +8 -0
- package/dist/charts/use-enter-complete.js +23 -0
- package/dist/charts/use-grid-shimmer.d.ts +16 -0
- package/dist/charts/use-grid-shimmer.js +63 -0
- package/dist/charts/use-highlight-segment.d.ts +14 -0
- package/dist/charts/use-highlight-segment.js +34 -0
- package/dist/charts/use-mount-progress.d.ts +4 -0
- package/dist/charts/use-mount-progress.js +22 -0
- package/dist/charts/use-scatter-chart-interaction.d.ts +35 -0
- package/dist/charts/use-scatter-chart-interaction.js +228 -0
- package/dist/charts/use-scheduled-tooltip.d.ts +9 -0
- package/dist/charts/use-scheduled-tooltip.js +76 -0
- package/dist/charts/visx-pattern.d.ts +19 -0
- package/dist/charts/visx-pattern.js +20 -0
- package/dist/charts/x-axis.d.ts +27 -0
- package/dist/charts/x-axis.js +415 -0
- package/dist/charts/y-axis-scales.d.ts +26 -0
- package/dist/charts/y-axis-scales.js +72 -0
- package/dist/charts/y-axis-ticks.d.ts +12 -0
- package/dist/charts/y-axis-ticks.js +24 -0
- package/dist/charts/y-axis.d.ts +22 -0
- package/dist/charts/y-axis.js +80 -0
- package/dist/charts/y-domain-utils.d.ts +27 -0
- package/dist/charts/y-domain-utils.js +88 -0
- package/dist/components/accordion.d.ts +6 -0
- package/dist/components/accordion.js +20 -0
- package/dist/components/alert-dialog.d.ts +18 -0
- package/dist/components/alert-dialog.js +41 -0
- package/dist/components/alert.d.ts +24 -0
- package/dist/components/alert.js +46 -0
- package/dist/components/animated-button.d.ts +5 -0
- package/dist/components/animated-button.js +16 -0
- package/dist/components/animated-list.d.ts +26 -0
- package/dist/components/animated-list.js +25 -0
- package/dist/components/animated-number.d.ts +67 -0
- package/dist/components/animated-number.js +131 -0
- package/dist/components/app-shell.d.ts +27 -0
- package/dist/components/app-shell.js +18 -0
- package/dist/components/area-chart.d.ts +11 -0
- package/dist/components/area-chart.js +12 -0
- package/dist/components/aspect-ratio.d.ts +16 -0
- package/dist/components/aspect-ratio.js +14 -0
- package/dist/components/aurora-background.d.ts +3 -0
- package/dist/components/aurora-background.js +8 -0
- package/dist/components/autocomplete.d.ts +55 -0
- package/dist/components/autocomplete.js +279 -0
- package/dist/components/avatar-group.d.ts +39 -0
- package/dist/components/avatar-group.js +50 -0
- package/dist/components/avatar.d.ts +5 -0
- package/dist/components/avatar.js +17 -0
- package/dist/components/badge.d.ts +10 -0
- package/dist/components/badge.js +35 -0
- package/dist/components/banner.d.ts +45 -0
- package/dist/components/banner.js +80 -0
- package/dist/components/bar-chart.d.ts +11 -0
- package/dist/components/bar-chart.js +9 -0
- package/dist/components/border-beam.d.ts +45 -0
- package/dist/components/border-beam.js +48 -0
- package/dist/components/breadcrumb.d.ts +12 -0
- package/dist/components/breadcrumb.js +35 -0
- package/dist/components/button-group.d.ts +7 -0
- package/dist/components/button-group.js +10 -0
- package/dist/components/button.d.ts +12 -0
- package/dist/components/button.js +39 -0
- package/dist/components/calendar.d.ts +7 -0
- package/dist/components/calendar.js +71 -0
- package/dist/components/candlestick-chart.d.ts +13 -0
- package/dist/components/candlestick-chart.js +66 -0
- package/dist/components/card-stack.d.ts +28 -0
- package/dist/components/card-stack.js +47 -0
- package/dist/components/card.d.ts +9 -0
- package/dist/components/card.js +32 -0
- package/dist/components/carousel.d.ts +82 -0
- package/dist/components/carousel.js +310 -0
- package/dist/components/chart.d.ts +100 -0
- package/dist/components/chart.js +210 -0
- package/dist/components/checkbox.d.ts +3 -0
- package/dist/components/checkbox.js +11 -0
- package/dist/components/chip.d.ts +80 -0
- package/dist/components/chip.js +186 -0
- package/dist/components/choropleth-chart.d.ts +12 -0
- package/dist/components/choropleth-chart.js +31 -0
- package/dist/components/click-spark.d.ts +19 -0
- package/dist/components/click-spark.js +51 -0
- package/dist/components/code-block.d.ts +13 -0
- package/dist/components/code-block.js +20 -0
- package/dist/components/code-tabs.d.ts +51 -0
- package/dist/components/code-tabs.js +150 -0
- package/dist/components/collapsible.d.ts +5 -0
- package/dist/components/collapsible.js +12 -0
- package/dist/components/color-picker.d.ts +30 -0
- package/dist/components/color-picker.js +300 -0
- package/dist/components/combobox.d.ts +33 -0
- package/dist/components/combobox.js +32 -0
- package/dist/components/command.d.ts +87 -0
- package/dist/components/command.js +44 -0
- package/dist/components/comparison-slider.d.ts +17 -0
- package/dist/components/comparison-slider.js +81 -0
- package/dist/components/composed-chart.d.ts +13 -0
- package/dist/components/composed-chart.js +22 -0
- package/dist/components/confetti.d.ts +21 -0
- package/dist/components/confetti.js +111 -0
- package/dist/components/confirmation-dialog.d.ts +46 -0
- package/dist/components/confirmation-dialog.js +102 -0
- package/dist/components/context-menu.d.ts +28 -0
- package/dist/components/context-menu.js +52 -0
- package/dist/components/copy-button.d.ts +13 -0
- package/dist/components/copy-button.js +72 -0
- package/dist/components/countdown.d.ts +58 -0
- package/dist/components/countdown.js +106 -0
- package/dist/components/credit-card-input.d.ts +62 -0
- package/dist/components/credit-card-input.js +211 -0
- package/dist/components/currency-input.d.ts +86 -0
- package/dist/components/currency-input.js +215 -0
- package/dist/components/data-table.d.ts +232 -0
- package/dist/components/data-table.js +359 -0
- package/dist/components/date-picker.d.ts +66 -0
- package/dist/components/date-picker.js +55 -0
- package/dist/components/date-range-picker.d.ts +59 -0
- package/dist/components/date-range-picker.js +59 -0
- package/dist/components/description-list.d.ts +84 -0
- package/dist/components/description-list.js +138 -0
- package/dist/components/dialog.d.ts +26 -0
- package/dist/components/dialog.js +35 -0
- package/dist/components/dock.d.ts +34 -0
- package/dist/components/dock.js +61 -0
- package/dist/components/dot-pattern.d.ts +24 -0
- package/dist/components/dot-pattern.js +19 -0
- package/dist/components/drawer.d.ts +22 -0
- package/dist/components/drawer.js +37 -0
- package/dist/components/dropdown-menu.d.ts +32 -0
- package/dist/components/dropdown-menu.js +56 -0
- package/dist/components/dynamic-island.d.ts +26 -0
- package/dist/components/dynamic-island.js +31 -0
- package/dist/components/empty.d.ts +7 -0
- package/dist/components/empty.js +24 -0
- package/dist/components/expandable-tabs.d.ts +24 -0
- package/dist/components/expandable-tabs.js +30 -0
- package/dist/components/fab.d.ts +35 -0
- package/dist/components/fab.js +36 -0
- package/dist/components/field.d.ts +6 -0
- package/dist/components/field.js +22 -0
- package/dist/components/file-dropzone.d.ts +28 -0
- package/dist/components/file-dropzone.js +59 -0
- package/dist/components/flickering-grid.d.ts +25 -0
- package/dist/components/flickering-grid.js +30 -0
- package/dist/components/flip-card.d.ts +70 -0
- package/dist/components/flip-card.js +117 -0
- package/dist/components/floating-label-input.d.ts +34 -0
- package/dist/components/floating-label-input.js +25 -0
- package/dist/components/form.d.ts +25 -0
- package/dist/components/form.js +68 -0
- package/dist/components/frame.d.ts +12 -0
- package/dist/components/frame.js +10 -0
- package/dist/components/funnel-chart.d.ts +11 -0
- package/dist/components/funnel-chart.js +16 -0
- package/dist/components/gauge-chart.d.ts +8 -0
- package/dist/components/gauge-chart.js +10 -0
- package/dist/components/glare-hover.d.ts +15 -0
- package/dist/components/glare-hover.js +64 -0
- package/dist/components/glass-card.d.ts +3 -0
- package/dist/components/glass-card.js +8 -0
- package/dist/components/gradient-border.d.ts +7 -0
- package/dist/components/gradient-border.js +8 -0
- package/dist/components/gradient-text.d.ts +6 -0
- package/dist/components/gradient-text.js +10 -0
- package/dist/components/grid-pattern.d.ts +23 -0
- package/dist/components/grid-pattern.js +18 -0
- package/dist/components/heatmap-chart.d.ts +6 -0
- package/dist/components/heatmap-chart.js +8 -0
- package/dist/components/heatmap.d.ts +28 -0
- package/dist/components/heatmap.js +41 -0
- package/dist/components/highlighter.d.ts +20 -0
- package/dist/components/highlighter.js +19 -0
- package/dist/components/hover-card.d.ts +5 -0
- package/dist/components/hover-card.js +12 -0
- package/dist/components/image-zoom.d.ts +47 -0
- package/dist/components/image-zoom.js +125 -0
- package/dist/components/input-group.d.ts +10 -0
- package/dist/components/input-group.js +12 -0
- package/dist/components/input-otp.d.ts +18 -0
- package/dist/components/input-otp.js +38 -0
- package/dist/components/input.d.ts +6 -0
- package/dist/components/input.js +8 -0
- package/dist/components/json-viewer.d.ts +43 -0
- package/dist/components/json-viewer.js +313 -0
- package/dist/components/kanban.d.ts +31 -0
- package/dist/components/kanban.js +143 -0
- package/dist/components/kbd.d.ts +3 -0
- package/dist/components/kbd.js +8 -0
- package/dist/components/label.d.ts +3 -0
- package/dist/components/label.js +9 -0
- package/dist/components/light-rays.d.ts +19 -0
- package/dist/components/light-rays.js +20 -0
- package/dist/components/lightbox.d.ts +24 -0
- package/dist/components/lightbox.js +68 -0
- package/dist/components/line-chart.d.ts +10 -0
- package/dist/components/line-chart.js +9 -0
- package/dist/components/live-line-chart.d.ts +12 -0
- package/dist/components/live-line-chart.js +42 -0
- package/dist/components/logo-carousel.d.ts +27 -0
- package/dist/components/logo-carousel.js +101 -0
- package/dist/components/magnetic.d.ts +44 -0
- package/dist/components/magnetic.js +172 -0
- package/dist/components/marquee.d.ts +71 -0
- package/dist/components/marquee.js +141 -0
- package/dist/components/masonry.d.ts +16 -0
- package/dist/components/masonry.js +84 -0
- package/dist/components/menubar.d.ts +33 -0
- package/dist/components/menubar.js +56 -0
- package/dist/components/meteors.d.ts +20 -0
- package/dist/components/meteors.js +39 -0
- package/dist/components/metric.d.ts +9 -0
- package/dist/components/metric.js +35 -0
- package/dist/components/mode-toggle.d.ts +32 -0
- package/dist/components/mode-toggle.js +40 -0
- package/dist/components/morphing-popover.d.ts +91 -0
- package/dist/components/morphing-popover.js +194 -0
- package/dist/components/motion-presets.d.ts +9 -0
- package/dist/components/motion-presets.js +20 -0
- package/dist/components/multi-select.d.ts +54 -0
- package/dist/components/multi-select.js +0 -0
- package/dist/components/navigation-menu.d.ts +12 -0
- package/dist/components/navigation-menu.js +42 -0
- package/dist/components/noise.d.ts +19 -0
- package/dist/components/noise.js +18 -0
- package/dist/components/notification-center.d.ts +68 -0
- package/dist/components/notification-center.js +57 -0
- package/dist/components/number-input.d.ts +45 -0
- package/dist/components/number-input.js +148 -0
- package/dist/components/orbit.d.ts +77 -0
- package/dist/components/orbit.js +100 -0
- package/dist/components/pagination.d.ts +16 -0
- package/dist/components/pagination.js +34 -0
- package/dist/components/particles.d.ts +18 -0
- package/dist/components/particles.js +92 -0
- package/dist/components/password-input.d.ts +16 -0
- package/dist/components/password-input.js +49 -0
- package/dist/components/phone-input.d.ts +67 -0
- package/dist/components/phone-input.js +225 -0
- package/dist/components/pie-chart.d.ts +12 -0
- package/dist/components/pie-chart.js +13 -0
- package/dist/components/pill-nav.d.ts +25 -0
- package/dist/components/pill-nav.js +66 -0
- package/dist/components/popover.d.ts +7 -0
- package/dist/components/popover.js +15 -0
- package/dist/components/profit-loss-chart.d.ts +10 -0
- package/dist/components/profit-loss-chart.js +8 -0
- package/dist/components/progress.d.ts +10 -0
- package/dist/components/progress.js +17 -0
- package/dist/components/progressive-blur.d.ts +24 -0
- package/dist/components/progressive-blur.js +43 -0
- package/dist/components/radar-chart.d.ts +9 -0
- package/dist/components/radar-chart.js +9 -0
- package/dist/components/radio-group.d.ts +4 -0
- package/dist/components/radio-group.js +15 -0
- package/dist/components/rating.d.ts +29 -0
- package/dist/components/rating.js +94 -0
- package/dist/components/resizable.d.ts +57 -0
- package/dist/components/resizable.js +73 -0
- package/dist/components/retro-grid.d.ts +25 -0
- package/dist/components/retro-grid.js +26 -0
- package/dist/components/reveal.d.ts +9 -0
- package/dist/components/reveal.js +14 -0
- package/dist/components/rich-text-editor.d.ts +28 -0
- package/dist/components/rich-text-editor.js +83 -0
- package/dist/components/ring-chart.d.ts +13 -0
- package/dist/components/ring-chart.js +16 -0
- package/dist/components/ripple.d.ts +25 -0
- package/dist/components/ripple.js +26 -0
- package/dist/components/sankey-chart.d.ts +16 -0
- package/dist/components/sankey-chart.js +8 -0
- package/dist/components/scatter-chart.d.ts +12 -0
- package/dist/components/scatter-chart.js +9 -0
- package/dist/components/scheduler.d.ts +50 -0
- package/dist/components/scheduler.js +93 -0
- package/dist/components/scramble-text.d.ts +39 -0
- package/dist/components/scramble-text.js +78 -0
- package/dist/components/scroll-area.d.ts +13 -0
- package/dist/components/scroll-area.js +14 -0
- package/dist/components/scroll-progress.d.ts +19 -0
- package/dist/components/scroll-progress.js +67 -0
- package/dist/components/segmented-control.d.ts +48 -0
- package/dist/components/segmented-control.js +222 -0
- package/dist/components/select.d.ts +12 -0
- package/dist/components/select.js +43 -0
- package/dist/components/separator.d.ts +3 -0
- package/dist/components/separator.js +9 -0
- package/dist/components/sheet.d.ts +25 -0
- package/dist/components/sheet.js +47 -0
- package/dist/components/shimmer.d.ts +3 -0
- package/dist/components/shimmer.js +8 -0
- package/dist/components/shiny-text.d.ts +20 -0
- package/dist/components/shiny-text.js +24 -0
- package/dist/components/sidebar.d.ts +92 -0
- package/dist/components/sidebar.js +290 -0
- package/dist/components/signature-pad.d.ts +44 -0
- package/dist/components/signature-pad.js +317 -0
- package/dist/components/skeleton.d.ts +3 -0
- package/dist/components/skeleton.js +8 -0
- package/dist/components/slider.d.ts +10 -0
- package/dist/components/slider.js +27 -0
- package/dist/components/sonner.d.ts +9 -0
- package/dist/components/sonner.js +17 -0
- package/dist/components/sparkles-text.d.ts +19 -0
- package/dist/components/sparkles-text.js +36 -0
- package/dist/components/sparkline.d.ts +22 -0
- package/dist/components/sparkline.js +100 -0
- package/dist/components/spinner.d.ts +10 -0
- package/dist/components/spinner.js +20 -0
- package/dist/components/spinning-text.d.ts +29 -0
- package/dist/components/spinning-text.js +40 -0
- package/dist/components/split-button.d.ts +71 -0
- package/dist/components/split-button.js +30 -0
- package/dist/components/spotlight-card.d.ts +11 -0
- package/dist/components/spotlight-card.js +63 -0
- package/dist/components/star-border.d.ts +19 -0
- package/dist/components/star-border.js +18 -0
- package/dist/components/status-dot.d.ts +60 -0
- package/dist/components/status-dot.js +76 -0
- package/dist/components/stepper.d.ts +98 -0
- package/dist/components/stepper.js +164 -0
- package/dist/components/sunburst-chart.d.ts +11 -0
- package/dist/components/sunburst-chart.js +45 -0
- package/dist/components/switch.d.ts +3 -0
- package/dist/components/switch.js +10 -0
- package/dist/components/table-of-contents.d.ts +64 -0
- package/dist/components/table-of-contents.js +0 -0
- package/dist/components/table.d.ts +10 -0
- package/dist/components/table.js +38 -0
- package/dist/components/tabs.d.ts +6 -0
- package/dist/components/tabs.js +22 -0
- package/dist/components/tags-input.d.ts +39 -0
- package/dist/components/tags-input.js +86 -0
- package/dist/components/terminal.d.ts +86 -0
- package/dist/components/terminal.js +182 -0
- package/dist/components/text-effect.d.ts +71 -0
- package/dist/components/text-effect.js +166 -0
- package/dist/components/textarea.d.ts +6 -0
- package/dist/components/textarea.js +8 -0
- package/dist/components/tilt-card.d.ts +30 -0
- package/dist/components/tilt-card.js +84 -0
- package/dist/components/time-picker.d.ts +58 -0
- package/dist/components/time-picker.js +245 -0
- package/dist/components/timeline.d.ts +81 -0
- package/dist/components/timeline.js +165 -0
- package/dist/components/toggle-group.d.ts +12 -0
- package/dist/components/toggle-group.js +23 -0
- package/dist/components/toggle.d.ts +12 -0
- package/dist/components/toggle.js +25 -0
- package/dist/components/toolbar.d.ts +14 -0
- package/dist/components/toolbar.js +89 -0
- package/dist/components/tooltip.d.ts +29 -0
- package/dist/components/tooltip.js +48 -0
- package/dist/components/tree-view.d.ts +45 -0
- package/dist/components/tree-view.js +197 -0
- package/dist/components/typing-text.d.ts +49 -0
- package/dist/components/typing-text.js +90 -0
- package/dist/components/usage-meter.d.ts +30 -0
- package/dist/components/usage-meter.js +90 -0
- package/dist/components/video-player.d.ts +48 -0
- package/dist/components/video-player.js +216 -0
- package/dist/components/word-rotate.d.ts +40 -0
- package/dist/components/word-rotate.js +34 -0
- package/dist/index.d.ts +306 -0
- package/dist/index.js +179 -0
- package/dist/lib/cn.d.ts +7 -0
- package/dist/lib/cn.js +10 -0
- package/dist/lib/demo-saas.d.ts +171 -0
- package/dist/lib/demo-saas.js +210 -0
- package/dist/lib/demo-store.d.ts +157 -0
- package/dist/lib/demo-store.js +353 -0
- package/dist/testing/index.d.ts +76 -0
- package/dist/testing/index.js +116 -0
- package/package.json +941 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef, useId, useMemo } from "react";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { Badge } from "./badge.js";
|
|
5
|
+
import { CopyButton } from "./copy-button.js";
|
|
6
|
+
export const CodeBlock = forwardRef(({ code, language, filename, showLineNumbers = false, className, ...props }, ref) => {
|
|
7
|
+
const headingId = useId();
|
|
8
|
+
const hasHeader = Boolean(filename || language);
|
|
9
|
+
const lines = useMemo(() => (showLineNumbers ? code.replace(/\n$/, "").split("\n") : null), [code, showLineNumbers]);
|
|
10
|
+
const regionLabel = filename
|
|
11
|
+
? `Code block, ${filename}`
|
|
12
|
+
: language
|
|
13
|
+
? `Code block, ${language}`
|
|
14
|
+
: "Code block";
|
|
15
|
+
return (_jsxs("div", { ref: ref, "data-slot": "code-block", className: cn("overflow-hidden rounded-xl border border-border bg-surface-raised text-fg", className), ...props, children: [hasHeader ? (_jsxs("div", { "data-slot": "code-block-header", className: "flex items-center justify-between gap-3 border-b border-border bg-surface-overlay px-4 py-2", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [filename ? (_jsx("span", { id: headingId, "data-slot": "code-block-filename", className: "truncate font-mono text-xs text-fg-secondary", children: filename })) : null, language ? (_jsx(Badge, { variant: "secondary", "data-slot": "code-block-language", children: language })) : null] }), _jsx(CopyButton, { value: code, size: "icon-sm", className: "-mr-1.5 shrink-0" })] })) : null, _jsxs("div", { className: "relative", children: [!hasHeader ? (_jsx(CopyButton, { value: code, size: "icon-sm", className: "absolute right-2 top-2 z-10 shrink-0 bg-surface-overlay/80 backdrop-blur-sm" })) : null, _jsx("section", { "data-slot": "code-block-scroll",
|
|
16
|
+
// biome-ignore lint/a11y/noNoninteractiveTabindex: a scrollable region is intentionally focusable so keyboard users can scroll it.
|
|
17
|
+
tabIndex: 0, "aria-label": regionLabel, "aria-describedby": filename ? headingId : undefined, className: "overflow-x-auto outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset", children: _jsx("pre", { "data-slot": "code-block-pre", className: "p-4 text-sm leading-relaxed", children: _jsx("code", { "data-slot": "code-block-code", className: "block font-mono", children: lines ? (lines.map((line, index) => (_jsxs("span", { "data-slot": "code-block-line", className: "table-row", children: [_jsx("span", { "aria-hidden": "true", "data-slot": "code-block-line-number", className: "table-cell select-none pr-4 text-right text-fg-muted tabular-nums", children: index + 1 }), _jsx("span", { className: "table-cell whitespace-pre", children: line || " " })] }, index)))) : (_jsx("span", { className: "whitespace-pre", children: code })) }) }) })] })] }));
|
|
18
|
+
});
|
|
19
|
+
CodeBlock.displayName = "CodeBlock";
|
|
20
|
+
//# sourceMappingURL=code-block.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "react";
|
|
2
|
+
export interface CodeTabsItem {
|
|
3
|
+
/** Tab label (e.g. "bun"). Doubles as the tab value, so labels must be unique. */
|
|
4
|
+
label: string;
|
|
5
|
+
/** Raw source rendered in the panel and written to the clipboard on copy. */
|
|
6
|
+
code: string;
|
|
7
|
+
/** Optional language hint shown at the far end of the header (e.g. "bash"). */
|
|
8
|
+
language?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CodeTabsProps extends Omit<HTMLAttributes<HTMLDivElement>, "children" | "defaultValue" | "dir" | "onChange"> {
|
|
11
|
+
/** The snippets to switch between — one tab + one panel per item. */
|
|
12
|
+
items: CodeTabsItem[];
|
|
13
|
+
/**
|
|
14
|
+
* Label selected on first render. Falls back to the first item when omitted
|
|
15
|
+
* or unknown. When {@link CodeTabsProps.storageKey} is set, a stored choice
|
|
16
|
+
* (applied after mount) wins over this.
|
|
17
|
+
*/
|
|
18
|
+
defaultLabel?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Persist the chosen label to `localStorage` under this key and keep every
|
|
21
|
+
* `CodeTabs` sharing the key in sync — across the page *and* across browser
|
|
22
|
+
* tabs. The stored value is only read after mount, so server-rendered HTML
|
|
23
|
+
* and the first client render always agree (no hydration mismatch).
|
|
24
|
+
*/
|
|
25
|
+
storageKey?: string;
|
|
26
|
+
/** Called with the newly selected label on user-initiated changes. */
|
|
27
|
+
onLabelChange?: (label: string) => void;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A code-snippet switcher — the classic bun/npm/pnpm/yarn installer tabs, or
|
|
31
|
+
* any set of labelled snippets. Built on the Radix-powered `Tabs` primitives,
|
|
32
|
+
* so the tablist gets roving focus, arrow-key activation and correct
|
|
33
|
+
* tab/tabpanel semantics for free. Two mechanisms are worth calling out:
|
|
34
|
+
*
|
|
35
|
+
* - **Shared persistence.** Pass a `storageKey` and the chosen label is
|
|
36
|
+
* written to `localStorage` and broadcast on a window event, so every
|
|
37
|
+
* `CodeTabs` with the same key flips together — pick pnpm once, see pnpm
|
|
38
|
+
* everywhere, including on the next visit. Reads happen after mount only,
|
|
39
|
+
* keeping server and client HTML identical (SSR-safe).
|
|
40
|
+
* - **Sliding indicator.** The active-tab underline is a single absolutely
|
|
41
|
+
* positioned element. On selection (and on resize) the active trigger is
|
|
42
|
+
* measured inside a `requestAnimationFrame` and the result is written to
|
|
43
|
+
* CSS custom properties on the tablist — React never re-renders to move
|
|
44
|
+
* it, and the travel transition is disabled under
|
|
45
|
+
* `prefers-reduced-motion: reduce` (the underline still jumps into place).
|
|
46
|
+
*
|
|
47
|
+
* Each panel renders its code in `font-mono` inside a focusable, horizontally
|
|
48
|
+
* scrollable tabpanel, with a per-tab copy button that never scrolls away.
|
|
49
|
+
*/
|
|
50
|
+
export declare const CodeTabs: import("react").ForwardRefExoticComponent<CodeTabsProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
51
|
+
//# sourceMappingURL=code-tabs.d.ts.map
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useRef, useState } from "react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { CopyButton } from "./copy-button.js";
|
|
6
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./tabs.js";
|
|
7
|
+
/**
|
|
8
|
+
* Same-page instances broadcast tab changes over this window event, because
|
|
9
|
+
* the native `storage` event only fires in *other* documents. Cross-tab sync
|
|
10
|
+
* still rides the native event; this one covers siblings in the same page.
|
|
11
|
+
*/
|
|
12
|
+
const SYNC_EVENT = "cronus-ui:code-tabs";
|
|
13
|
+
/** Separator used to derive a stable dependency key from the item labels. */
|
|
14
|
+
const LABEL_SEPARATOR = "\u0000";
|
|
15
|
+
/** Read a persisted label, tolerating blocked storage (private mode, iframes). */
|
|
16
|
+
function readStoredLabel(key) {
|
|
17
|
+
try {
|
|
18
|
+
return window.localStorage.getItem(key);
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/** Persist a label, silently ignoring quota/permission failures. */
|
|
25
|
+
function writeStoredLabel(key, label) {
|
|
26
|
+
try {
|
|
27
|
+
window.localStorage.setItem(key, label);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Storage may be unavailable — the in-memory state still works.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* A code-snippet switcher — the classic bun/npm/pnpm/yarn installer tabs, or
|
|
35
|
+
* any set of labelled snippets. Built on the Radix-powered `Tabs` primitives,
|
|
36
|
+
* so the tablist gets roving focus, arrow-key activation and correct
|
|
37
|
+
* tab/tabpanel semantics for free. Two mechanisms are worth calling out:
|
|
38
|
+
*
|
|
39
|
+
* - **Shared persistence.** Pass a `storageKey` and the chosen label is
|
|
40
|
+
* written to `localStorage` and broadcast on a window event, so every
|
|
41
|
+
* `CodeTabs` with the same key flips together — pick pnpm once, see pnpm
|
|
42
|
+
* everywhere, including on the next visit. Reads happen after mount only,
|
|
43
|
+
* keeping server and client HTML identical (SSR-safe).
|
|
44
|
+
* - **Sliding indicator.** The active-tab underline is a single absolutely
|
|
45
|
+
* positioned element. On selection (and on resize) the active trigger is
|
|
46
|
+
* measured inside a `requestAnimationFrame` and the result is written to
|
|
47
|
+
* CSS custom properties on the tablist — React never re-renders to move
|
|
48
|
+
* it, and the travel transition is disabled under
|
|
49
|
+
* `prefers-reduced-motion: reduce` (the underline still jumps into place).
|
|
50
|
+
*
|
|
51
|
+
* Each panel renders its code in `font-mono` inside a focusable, horizontally
|
|
52
|
+
* scrollable tabpanel, with a per-tab copy button that never scrolls away.
|
|
53
|
+
*/
|
|
54
|
+
export const CodeTabs = forwardRef(({ items, defaultLabel, storageKey, onLabelChange, className, ...props }, ref) => {
|
|
55
|
+
const listRef = useRef(null);
|
|
56
|
+
const fallbackLabel = defaultLabel && items.some((item) => item.label === defaultLabel)
|
|
57
|
+
? defaultLabel
|
|
58
|
+
: items[0]?.label;
|
|
59
|
+
const [active, setActive] = useState(fallbackLabel);
|
|
60
|
+
// Guard against stale state when `items` change under us.
|
|
61
|
+
const resolvedActive = items.some((item) => item.label === active) ? active : fallbackLabel;
|
|
62
|
+
const activeItem = items.find((item) => item.label === resolvedActive);
|
|
63
|
+
const labelsKey = items.map((item) => item.label).join(LABEL_SEPARATOR);
|
|
64
|
+
// Adopt the persisted choice after mount and follow later changes from
|
|
65
|
+
// sibling instances (custom event) and other browser tabs (storage event).
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (!storageKey)
|
|
68
|
+
return;
|
|
69
|
+
const labels = labelsKey.split(LABEL_SEPARATOR);
|
|
70
|
+
const adopt = (label) => {
|
|
71
|
+
if (label && labels.includes(label))
|
|
72
|
+
setActive(label);
|
|
73
|
+
};
|
|
74
|
+
adopt(readStoredLabel(storageKey));
|
|
75
|
+
const handleSync = (event) => {
|
|
76
|
+
const detail = event.detail;
|
|
77
|
+
if (detail?.key === storageKey)
|
|
78
|
+
adopt(detail.label);
|
|
79
|
+
};
|
|
80
|
+
const handleStorage = (event) => {
|
|
81
|
+
if (event.key === storageKey)
|
|
82
|
+
adopt(event.newValue);
|
|
83
|
+
};
|
|
84
|
+
window.addEventListener(SYNC_EVENT, handleSync);
|
|
85
|
+
window.addEventListener("storage", handleStorage);
|
|
86
|
+
return () => {
|
|
87
|
+
window.removeEventListener(SYNC_EVENT, handleSync);
|
|
88
|
+
window.removeEventListener("storage", handleStorage);
|
|
89
|
+
};
|
|
90
|
+
}, [storageKey, labelsKey]);
|
|
91
|
+
// Position the sliding underline. The measurement is written straight to
|
|
92
|
+
// the DOM as CSS custom properties inside a requestAnimationFrame — no
|
|
93
|
+
// React re-render is involved in moving the indicator. `--code-tabs-ready`
|
|
94
|
+
// keeps it invisible until the first real measurement lands, so it never
|
|
95
|
+
// animates in from a zero-width flash.
|
|
96
|
+
useEffect(() => {
|
|
97
|
+
const list = listRef.current;
|
|
98
|
+
// `labelsKey` participates so relabelled items re-measure even when the
|
|
99
|
+
// active label itself is unchanged.
|
|
100
|
+
if (!list || !resolvedActive || !labelsKey)
|
|
101
|
+
return;
|
|
102
|
+
let frame = null;
|
|
103
|
+
const measure = () => {
|
|
104
|
+
if (frame !== null)
|
|
105
|
+
cancelAnimationFrame(frame);
|
|
106
|
+
frame = requestAnimationFrame(() => {
|
|
107
|
+
frame = null;
|
|
108
|
+
const current = listRef.current;
|
|
109
|
+
const trigger = current?.querySelector('[data-state="active"]');
|
|
110
|
+
if (!current || !trigger)
|
|
111
|
+
return;
|
|
112
|
+
current.style.setProperty("--code-tabs-x", `${trigger.offsetLeft}px`);
|
|
113
|
+
current.style.setProperty("--code-tabs-w", `${trigger.offsetWidth}px`);
|
|
114
|
+
current.style.setProperty("--code-tabs-ready", "1");
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
measure();
|
|
118
|
+
if (typeof ResizeObserver === "undefined")
|
|
119
|
+
return;
|
|
120
|
+
const observer = new ResizeObserver(measure);
|
|
121
|
+
observer.observe(list);
|
|
122
|
+
return () => {
|
|
123
|
+
if (frame !== null)
|
|
124
|
+
cancelAnimationFrame(frame);
|
|
125
|
+
observer.disconnect();
|
|
126
|
+
};
|
|
127
|
+
}, [resolvedActive, labelsKey]);
|
|
128
|
+
const handleValueChange = useCallback((label) => {
|
|
129
|
+
setActive(label);
|
|
130
|
+
onLabelChange?.(label);
|
|
131
|
+
if (!storageKey)
|
|
132
|
+
return;
|
|
133
|
+
writeStoredLabel(storageKey, label);
|
|
134
|
+
window.dispatchEvent(new CustomEvent(SYNC_EVENT, {
|
|
135
|
+
detail: { key: storageKey, label },
|
|
136
|
+
}));
|
|
137
|
+
}, [onLabelChange, storageKey]);
|
|
138
|
+
if (items.length === 0)
|
|
139
|
+
return null;
|
|
140
|
+
return (_jsxs(Tabs, { ref: ref, value: resolvedActive, onValueChange: handleValueChange, "data-slot": "code-tabs", className: cn("gap-0 overflow-hidden rounded-xl border border-border bg-surface-raised text-fg", className), ...props, children: [_jsxs("div", { "data-slot": "code-tabs-header", className: "flex items-center justify-between gap-3 border-b border-border bg-surface-overlay pr-3", children: [_jsxs(TabsList, { ref: listRef, "data-slot": "code-tabs-list", className: "relative h-auto gap-0 rounded-none bg-transparent p-0", children: [items.map((item) => (_jsx(TabsTrigger, { value: item.label, "data-slot": "code-tabs-trigger", className: "rounded-none px-3.5 py-2.5 text-fg-tertiary hover:text-fg-secondary focus-visible:ring-inset focus-visible:ring-offset-0 data-[state=active]:bg-transparent data-[state=active]:text-fg data-[state=active]:shadow-none", children: item.label }, item.label))), _jsx("span", { "aria-hidden": "true", "data-slot": "code-tabs-indicator", className: "pointer-events-none absolute bottom-0 left-0 h-0.5 rounded-full bg-primary transition-[transform,width] duration-300 ease-out motion-reduce:transition-none", style: {
|
|
141
|
+
opacity: "var(--code-tabs-ready, 0)",
|
|
142
|
+
width: "var(--code-tabs-w, 0px)",
|
|
143
|
+
transform: "translateX(var(--code-tabs-x, 0px))",
|
|
144
|
+
} })] }), activeItem?.language ? (_jsx("span", { "data-slot": "code-tabs-language",
|
|
145
|
+
// Information-bearing label — `fg-muted` fails AA on the header
|
|
146
|
+
// surface, so it uses `fg-tertiary` (the next step up, which passes).
|
|
147
|
+
className: "shrink-0 font-mono text-fg-tertiary text-xs", children: activeItem.language })) : null] }), _jsxs("div", { "data-slot": "code-tabs-panels", className: "relative", children: [activeItem ? (_jsx(CopyButton, { value: activeItem.code, size: "icon-sm", "aria-label": `Copy ${activeItem.label} snippet`, className: "absolute top-2 right-2 z-10 shrink-0 bg-surface-overlay/80 backdrop-blur-sm" }, activeItem.label)) : null, items.map((item) => (_jsx(TabsContent, { value: item.label, "data-slot": "code-tabs-panel", className: "overflow-x-auto outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset", children: _jsx("pre", { "data-slot": "code-tabs-pre", className: "p-4 pr-14 text-sm leading-relaxed", children: _jsx("code", { "data-slot": "code-tabs-code", className: "block whitespace-pre font-mono", children: item.code }) }) }, item.label)))] })] }));
|
|
148
|
+
});
|
|
149
|
+
CodeTabs.displayName = "CodeTabs";
|
|
150
|
+
//# sourceMappingURL=code-tabs.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
2
|
+
export declare const Collapsible: import("react").ForwardRefExoticComponent<CollapsiblePrimitive.CollapsibleProps & import("react").RefAttributes<HTMLDivElement>>;
|
|
3
|
+
export declare const CollapsibleTrigger: import("react").ForwardRefExoticComponent<CollapsiblePrimitive.CollapsibleTriggerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
4
|
+
export declare const CollapsibleContent: import("react").ForwardRefExoticComponent<Omit<CollapsiblePrimitive.CollapsibleContentProps & import("react").RefAttributes<HTMLDivElement>, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
|
|
5
|
+
//# sourceMappingURL=collapsible.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
4
|
+
import { forwardRef } from "react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
export const Collapsible = CollapsiblePrimitive.Root;
|
|
7
|
+
export const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger;
|
|
8
|
+
export const CollapsibleContent = forwardRef(({ className, children, ...props }, ref) => {
|
|
9
|
+
return (_jsx(CollapsiblePrimitive.CollapsibleContent, { ref: ref, "data-slot": "collapsible-content", className: cn("overflow-hidden text-sm text-fg-secondary data-[state=open]:animate-[cronus-collapsible-down_220ms_var(--ease-out-quart)] data-[state=closed]:animate-[cronus-collapsible-up_180ms_var(--ease-out-quart)]", className), ...props, children: children }));
|
|
10
|
+
});
|
|
11
|
+
CollapsibleContent.displayName = "CollapsibleContent";
|
|
12
|
+
//# sourceMappingURL=collapsible.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export interface OklchColor {
|
|
2
|
+
/** Perceptual lightness, 0..1. */
|
|
3
|
+
l: number;
|
|
4
|
+
/** Chroma, 0..~0.37. */
|
|
5
|
+
c: number;
|
|
6
|
+
/** Hue angle in degrees, 0..360. */
|
|
7
|
+
h: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ColorPickerProps {
|
|
10
|
+
/** Controlled color as a CSS color string (ideally `oklch(l c h)`). */
|
|
11
|
+
value?: string;
|
|
12
|
+
/** Initial color for uncontrolled usage. Defaults to a brand-ish oklch. */
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
/** Called with the new color, serialized as `oklch(l c h)`, on every change. */
|
|
15
|
+
onValueChange?: (value: string) => void;
|
|
16
|
+
/** Preset swatches shown as a row; clicking one selects it. */
|
|
17
|
+
swatches?: string[];
|
|
18
|
+
/** Disables the trigger and all panel controls. */
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
/** Accessible name for the trigger when there is no visible label. */
|
|
21
|
+
"aria-label"?: string;
|
|
22
|
+
/** Extra classes for the trigger button. */
|
|
23
|
+
className?: string;
|
|
24
|
+
/** Extra classes for the popover panel. */
|
|
25
|
+
contentClassName?: string;
|
|
26
|
+
/** Native id for the trigger. */
|
|
27
|
+
id?: string;
|
|
28
|
+
}
|
|
29
|
+
export declare const ColorPicker: import("react").ForwardRefExoticComponent<ColorPickerProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
30
|
+
//# sourceMappingURL=color-picker.d.ts.map
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useId, useMemo, useRef, useState, } from "react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { Button } from "./button.js";
|
|
6
|
+
import { Input } from "./input.js";
|
|
7
|
+
import { Label } from "./label.js";
|
|
8
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
9
|
+
/**
|
|
10
|
+
* OKLCH channel bounds. Lightness is perceptual 0..1; chroma is unbounded in
|
|
11
|
+
* theory but display-P3/sRGB tops out near 0.37, so we clamp there for sane
|
|
12
|
+
* sliders; hue is the usual 0..360 wheel.
|
|
13
|
+
*/
|
|
14
|
+
const L_MIN = 0;
|
|
15
|
+
const L_MAX = 1;
|
|
16
|
+
const C_MIN = 0;
|
|
17
|
+
const C_MAX = 0.37;
|
|
18
|
+
const H_MIN = 0;
|
|
19
|
+
const H_MAX = 360;
|
|
20
|
+
/** A tasteful default palette, authored natively in oklch. */
|
|
21
|
+
const DEFAULT_SWATCHES = [
|
|
22
|
+
"oklch(0.62 0.21 256)", // blue
|
|
23
|
+
"oklch(0.65 0.24 24)", // red
|
|
24
|
+
"oklch(0.72 0.19 145)", // green
|
|
25
|
+
"oklch(0.8 0.16 86)", // amber
|
|
26
|
+
"oklch(0.62 0.25 304)", // violet
|
|
27
|
+
"oklch(0.7 0.17 196)", // cyan
|
|
28
|
+
"oklch(0.68 0.2 35)", // orange
|
|
29
|
+
"oklch(0.5 0 0)", // neutral gray
|
|
30
|
+
];
|
|
31
|
+
const DEFAULT_VALUE = "oklch(0.62 0.21 256)";
|
|
32
|
+
function clamp(value, min, max) {
|
|
33
|
+
return Math.min(max, Math.max(min, value));
|
|
34
|
+
}
|
|
35
|
+
/** Trim trailing zeros so serialized strings stay tidy (0.6200 -> 0.62). */
|
|
36
|
+
function trim(value, digits) {
|
|
37
|
+
const fixed = value.toFixed(digits);
|
|
38
|
+
return fixed.replace(/\.?0+$/, "") || "0";
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Parse an `oklch(l c h)` string into channels. Supports space- or
|
|
42
|
+
* comma-separated values, an optional `/ alpha` (ignored), and percentage
|
|
43
|
+
* lightness (`62%` -> 0.62). Returns `null` for anything that isn't oklch so
|
|
44
|
+
* callers can fall back gracefully.
|
|
45
|
+
*/
|
|
46
|
+
function parseOklch(input) {
|
|
47
|
+
const match = /^oklch\(\s*([^)]+?)\s*\)$/i.exec(input.trim());
|
|
48
|
+
const body = match?.[1];
|
|
49
|
+
if (body === undefined)
|
|
50
|
+
return null;
|
|
51
|
+
// Drop any alpha component after a slash, then split on commas/whitespace.
|
|
52
|
+
const parts = (body.split("/")[0] ?? "")
|
|
53
|
+
.trim()
|
|
54
|
+
.split(/[\s,]+/)
|
|
55
|
+
.filter(Boolean);
|
|
56
|
+
const [rawL, rawC, rawH] = parts;
|
|
57
|
+
if (rawL === undefined || rawC === undefined || rawH === undefined)
|
|
58
|
+
return null;
|
|
59
|
+
const parseChannel = (raw, scaleForPercent) => {
|
|
60
|
+
const isPercent = raw.endsWith("%");
|
|
61
|
+
const num = Number.parseFloat(raw);
|
|
62
|
+
if (Number.isNaN(num))
|
|
63
|
+
return null;
|
|
64
|
+
return isPercent ? (num / 100) * scaleForPercent : num;
|
|
65
|
+
};
|
|
66
|
+
const l = parseChannel(rawL, 1);
|
|
67
|
+
const c = parseChannel(rawC, C_MAX);
|
|
68
|
+
const h = parseChannel(rawH, 1);
|
|
69
|
+
if (l === null || c === null || h === null)
|
|
70
|
+
return null;
|
|
71
|
+
return {
|
|
72
|
+
l: clamp(l, L_MIN, L_MAX),
|
|
73
|
+
c: clamp(c, C_MIN, C_MAX),
|
|
74
|
+
h: clamp(((h % 360) + 360) % 360, H_MIN, H_MAX),
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** Serialize channels back to a canonical `oklch(l c h)` string. */
|
|
78
|
+
function serializeOklch({ l, c, h }) {
|
|
79
|
+
return `oklch(${trim(l, 4)} ${trim(c, 4)} ${trim(h, 2)})`;
|
|
80
|
+
}
|
|
81
|
+
/** A CSS color usable as a background tile for an arbitrary (maybe non-oklch) value. */
|
|
82
|
+
function tileColor(parsed, raw) {
|
|
83
|
+
return parsed ? serializeOklch(parsed) : raw;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Translate a pointer event into a 0..1 fraction within an element along one
|
|
87
|
+
* axis. Used by the 2D area; mirrors the math Radix Slider does internally but
|
|
88
|
+
* stays dependency-free so the gradients can render in native oklch.
|
|
89
|
+
*/
|
|
90
|
+
function fractionFromPointer(element, clientX, clientY) {
|
|
91
|
+
const rect = element.getBoundingClientRect();
|
|
92
|
+
const x = rect.width === 0 ? 0 : clamp((clientX - rect.left) / rect.width, 0, 1);
|
|
93
|
+
const y = rect.height === 0 ? 0 : clamp((clientY - rect.top) / rect.height, 0, 1);
|
|
94
|
+
return { x, y };
|
|
95
|
+
}
|
|
96
|
+
/** A small labelled numeric input for one OKLCH channel. */
|
|
97
|
+
function ChannelField({ label, value, min, max, step, precision, disabled, onCommit, }) {
|
|
98
|
+
const id = useId();
|
|
99
|
+
// Mirror keystrokes locally so partial entries stay editable, syncing back
|
|
100
|
+
// from the committed value whenever it changes from outside.
|
|
101
|
+
const [text, setText] = useState(() => trim(value, precision));
|
|
102
|
+
const [focused, setFocused] = useState(false);
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (!focused)
|
|
105
|
+
setText(trim(value, precision));
|
|
106
|
+
}, [value, precision, focused]);
|
|
107
|
+
const handleChange = (event) => {
|
|
108
|
+
const raw = event.target.value;
|
|
109
|
+
setText(raw);
|
|
110
|
+
const parsed = Number.parseFloat(raw);
|
|
111
|
+
if (!Number.isNaN(parsed))
|
|
112
|
+
onCommit(clamp(parsed, min, max));
|
|
113
|
+
};
|
|
114
|
+
const handleBlur = () => {
|
|
115
|
+
setFocused(false);
|
|
116
|
+
const parsed = Number.parseFloat(text);
|
|
117
|
+
if (Number.isNaN(parsed)) {
|
|
118
|
+
setText(trim(value, precision));
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const next = clamp(parsed, min, max);
|
|
122
|
+
setText(trim(next, precision));
|
|
123
|
+
onCommit(next);
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
return (_jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Label, { htmlFor: id, className: "text-xs text-fg-secondary", children: label }), _jsx(Input, { id: id, type: "number", inputMode: "decimal", min: min, max: max, step: step, disabled: disabled, value: text, onChange: handleChange, onFocus: () => setFocused(true), onBlur: handleBlur, "data-slot": "color-picker-channel", className: "h-8 px-2 text-xs" })] }));
|
|
127
|
+
}
|
|
128
|
+
export const ColorPicker = forwardRef(({ value: valueProp, defaultValue = DEFAULT_VALUE, onValueChange, swatches = DEFAULT_SWATCHES, disabled = false, "aria-label": ariaLabel, className, contentClassName, id, }, ref) => {
|
|
129
|
+
const isControlled = valueProp !== undefined;
|
|
130
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
131
|
+
const value = isControlled ? valueProp : uncontrolledValue;
|
|
132
|
+
// The string is the source of truth; the channels are derived. When the
|
|
133
|
+
// string isn't oklch we keep `parsed === null` and fall back (tile shows the
|
|
134
|
+
// raw color, sliders default) — but channel edits always produce oklch.
|
|
135
|
+
const parsed = useMemo(() => parseOklch(value), [value]);
|
|
136
|
+
const channels = parsed ?? parseOklch(DEFAULT_VALUE) ?? { l: 0.62, c: 0.21, h: 256 };
|
|
137
|
+
const areaRef = useRef(null);
|
|
138
|
+
const hueRef = useRef(null);
|
|
139
|
+
const commit = useCallback((next) => {
|
|
140
|
+
if (!isControlled)
|
|
141
|
+
setUncontrolledValue(next);
|
|
142
|
+
onValueChange?.(next);
|
|
143
|
+
}, [isControlled, onValueChange]);
|
|
144
|
+
const commitChannels = useCallback((next) => {
|
|
145
|
+
commit(serializeOklch({
|
|
146
|
+
l: clamp(next.l, L_MIN, L_MAX),
|
|
147
|
+
c: clamp(next.c, C_MIN, C_MAX),
|
|
148
|
+
h: clamp(((next.h % 360) + 360) % 360, H_MIN, H_MAX),
|
|
149
|
+
}));
|
|
150
|
+
}, [commit]);
|
|
151
|
+
// --- 2D area (x = chroma, y = lightness inverted) -----------------------
|
|
152
|
+
const updateAreaFromPointer = useCallback((clientX, clientY) => {
|
|
153
|
+
const node = areaRef.current;
|
|
154
|
+
if (!node)
|
|
155
|
+
return;
|
|
156
|
+
const { x, y } = fractionFromPointer(node, clientX, clientY);
|
|
157
|
+
commitChannels({
|
|
158
|
+
...channels,
|
|
159
|
+
c: x * C_MAX,
|
|
160
|
+
l: (1 - y) * L_MAX,
|
|
161
|
+
});
|
|
162
|
+
}, [channels, commitChannels]);
|
|
163
|
+
const handleAreaPointerDown = (event) => {
|
|
164
|
+
if (disabled)
|
|
165
|
+
return;
|
|
166
|
+
event.preventDefault();
|
|
167
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
168
|
+
updateAreaFromPointer(event.clientX, event.clientY);
|
|
169
|
+
};
|
|
170
|
+
const handleAreaPointerMove = (event) => {
|
|
171
|
+
if (disabled)
|
|
172
|
+
return;
|
|
173
|
+
// Only drag while the pointer is captured (i.e. a button is held).
|
|
174
|
+
if (!event.currentTarget.hasPointerCapture?.(event.pointerId))
|
|
175
|
+
return;
|
|
176
|
+
updateAreaFromPointer(event.clientX, event.clientY);
|
|
177
|
+
};
|
|
178
|
+
const handleAreaKeyDown = (event) => {
|
|
179
|
+
if (disabled)
|
|
180
|
+
return;
|
|
181
|
+
const lStep = event.shiftKey ? 0.1 : 0.02;
|
|
182
|
+
const cStep = event.shiftKey ? 0.05 : 0.01;
|
|
183
|
+
let handled = true;
|
|
184
|
+
const next = { ...channels };
|
|
185
|
+
switch (event.key) {
|
|
186
|
+
case "ArrowUp":
|
|
187
|
+
next.l = channels.l + lStep;
|
|
188
|
+
break;
|
|
189
|
+
case "ArrowDown":
|
|
190
|
+
next.l = channels.l - lStep;
|
|
191
|
+
break;
|
|
192
|
+
case "ArrowRight":
|
|
193
|
+
next.c = channels.c + cStep;
|
|
194
|
+
break;
|
|
195
|
+
case "ArrowLeft":
|
|
196
|
+
next.c = channels.c - cStep;
|
|
197
|
+
break;
|
|
198
|
+
case "Home":
|
|
199
|
+
next.c = C_MIN;
|
|
200
|
+
break;
|
|
201
|
+
case "End":
|
|
202
|
+
next.c = C_MAX;
|
|
203
|
+
break;
|
|
204
|
+
default:
|
|
205
|
+
handled = false;
|
|
206
|
+
}
|
|
207
|
+
if (handled) {
|
|
208
|
+
event.preventDefault();
|
|
209
|
+
commitChannels(next);
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
// --- Hue slider ----------------------------------------------------------
|
|
213
|
+
const updateHueFromPointer = useCallback((clientX, clientY) => {
|
|
214
|
+
const node = hueRef.current;
|
|
215
|
+
if (!node)
|
|
216
|
+
return;
|
|
217
|
+
const { x } = fractionFromPointer(node, clientX, clientY);
|
|
218
|
+
commitChannels({ ...channels, h: x * H_MAX });
|
|
219
|
+
}, [channels, commitChannels]);
|
|
220
|
+
const handleHuePointerDown = (event) => {
|
|
221
|
+
if (disabled)
|
|
222
|
+
return;
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
225
|
+
updateHueFromPointer(event.clientX, event.clientY);
|
|
226
|
+
};
|
|
227
|
+
const handleHuePointerMove = (event) => {
|
|
228
|
+
if (disabled)
|
|
229
|
+
return;
|
|
230
|
+
if (!event.currentTarget.hasPointerCapture?.(event.pointerId))
|
|
231
|
+
return;
|
|
232
|
+
updateHueFromPointer(event.clientX, event.clientY);
|
|
233
|
+
};
|
|
234
|
+
const handleHueKeyDown = (event) => {
|
|
235
|
+
if (disabled)
|
|
236
|
+
return;
|
|
237
|
+
const step = event.shiftKey ? 15 : 3;
|
|
238
|
+
let next = null;
|
|
239
|
+
switch (event.key) {
|
|
240
|
+
case "ArrowRight":
|
|
241
|
+
case "ArrowUp":
|
|
242
|
+
next = channels.h + step;
|
|
243
|
+
break;
|
|
244
|
+
case "ArrowLeft":
|
|
245
|
+
case "ArrowDown":
|
|
246
|
+
next = channels.h - step;
|
|
247
|
+
break;
|
|
248
|
+
case "Home":
|
|
249
|
+
next = H_MIN;
|
|
250
|
+
break;
|
|
251
|
+
case "End":
|
|
252
|
+
next = H_MAX;
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
if (next !== null) {
|
|
256
|
+
event.preventDefault();
|
|
257
|
+
commitChannels({ ...channels, h: next });
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
// --- Derived presentation ------------------------------------------------
|
|
261
|
+
const swatchBackground = tileColor(parsed, value);
|
|
262
|
+
// 2D area gradient: a lightness ramp (top=white-ish, bottom=black) layered
|
|
263
|
+
// over a chroma ramp (left=gray, right=saturated) at the current hue. Both
|
|
264
|
+
// built from native oklch() stops — no conversion.
|
|
265
|
+
const areaBackground = useMemo(() => {
|
|
266
|
+
const h = channels.h;
|
|
267
|
+
const lightnessLayer = `linear-gradient(to bottom, oklch(1 0 ${h}) 0%, oklch(0 0 ${h}) 100%)`;
|
|
268
|
+
const chromaLayer = `linear-gradient(to right, oklch(0.65 0 ${h}) 0%, oklch(0.65 ${C_MAX} ${h}) 100%)`;
|
|
269
|
+
// Multiply so the chroma ramp tints the lightness ramp.
|
|
270
|
+
return `${chromaLayer}, ${lightnessLayer}`;
|
|
271
|
+
}, [channels.h]);
|
|
272
|
+
const hueBackground = useMemo(() => {
|
|
273
|
+
const stops = [];
|
|
274
|
+
for (let deg = 0; deg <= 360; deg += 30) {
|
|
275
|
+
stops.push(`oklch(0.7 0.2 ${deg}) ${(deg / 360) * 100}%`);
|
|
276
|
+
}
|
|
277
|
+
return `linear-gradient(to right, ${stops.join(", ")})`;
|
|
278
|
+
}, []);
|
|
279
|
+
// Thumb positions as percentages.
|
|
280
|
+
const areaThumbX = (channels.c / C_MAX) * 100;
|
|
281
|
+
const areaThumbY = (1 - channels.l / L_MAX) * 100;
|
|
282
|
+
const hueThumbX = (channels.h / H_MAX) * 100;
|
|
283
|
+
const triggerLabel = serializeOklch(channels);
|
|
284
|
+
const handleTextChange = (event) => {
|
|
285
|
+
commit(event.target.value);
|
|
286
|
+
};
|
|
287
|
+
return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { ref: ref, id: id, type: "button", variant: "outline", disabled: disabled, "aria-label": ariaLabel ? `${ariaLabel}: ${value}` : `Color: ${value}`, "aria-haspopup": "dialog", "data-slot": "color-picker-trigger", className: cn("h-10 w-full justify-start gap-2 font-normal", className), children: [_jsx("span", { "aria-hidden": "true", "data-slot": "color-picker-swatch", className: "size-5 shrink-0 rounded-md border border-border", style: { background: swatchBackground } }), _jsx("span", { className: "truncate text-sm tabular-nums", children: value })] }) }), _jsxs(PopoverContent, { align: "start", "aria-label": ariaLabel ?? "Color picker", "data-slot": "color-picker-content", className: cn("w-64 space-y-3", contentClassName), children: [_jsx("div", { ref: areaRef, role: "slider", tabIndex: disabled ? -1 : 0, "aria-label": "Saturation and lightness", "aria-valuetext": `Chroma ${trim(channels.c, 3)}, lightness ${trim(channels.l, 3)}`, "aria-valuemin": 0, "aria-valuemax": 100, "aria-valuenow": Math.round((channels.l / L_MAX) * 100), "aria-disabled": disabled || undefined, "data-slot": "color-picker-area", onPointerDown: handleAreaPointerDown, onPointerMove: handleAreaPointerMove, onKeyDown: handleAreaKeyDown, className: "relative h-36 w-full cursor-crosshair touch-none overflow-hidden rounded-lg border border-border outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-floating data-[disabled]:opacity-50", style: { background: areaBackground }, children: _jsx("span", { "aria-hidden": "true", "data-slot": "color-picker-area-thumb", className: "pointer-events-none absolute size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(0,0,0,0.4)]", style: {
|
|
288
|
+
left: `${areaThumbX}%`,
|
|
289
|
+
top: `${areaThumbY}%`,
|
|
290
|
+
background: triggerLabel,
|
|
291
|
+
} }) }), _jsx("div", { ref: hueRef, role: "slider", tabIndex: disabled ? -1 : 0, "aria-label": "Hue", "aria-valuemin": H_MIN, "aria-valuemax": H_MAX, "aria-valuenow": Math.round(channels.h), "aria-disabled": disabled || undefined, "data-slot": "color-picker-hue", onPointerDown: handleHuePointerDown, onPointerMove: handleHuePointerMove, onKeyDown: handleHueKeyDown, className: "relative h-4 w-full cursor-ew-resize touch-none rounded-full border border-border outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-floating data-[disabled]:opacity-50", style: { background: hueBackground }, children: _jsx("span", { "aria-hidden": "true", "data-slot": "color-picker-hue-thumb", className: "pointer-events-none absolute top-1/2 size-4 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-white shadow-[0_0_0_1px_rgba(0,0,0,0.4)]", style: {
|
|
292
|
+
left: `${hueThumbX}%`,
|
|
293
|
+
background: `oklch(0.7 0.2 ${channels.h})`,
|
|
294
|
+
} }) }), _jsxs("div", { className: "grid grid-cols-3 gap-2", children: [_jsx(ChannelField, { label: "L", value: channels.l, min: L_MIN, max: L_MAX, step: 0.01, precision: 4, disabled: disabled, onCommit: (l) => commitChannels({ ...channels, l }) }), _jsx(ChannelField, { label: "C", value: channels.c, min: C_MIN, max: C_MAX, step: 0.01, precision: 4, disabled: disabled, onCommit: (c) => commitChannels({ ...channels, c }) }), _jsx(ChannelField, { label: "H", value: channels.h, min: H_MIN, max: H_MAX, step: 1, precision: 2, disabled: disabled, onCommit: (h) => commitChannels({ ...channels, h }) })] }), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(Label, { htmlFor: `${id ?? "color-picker"}-oklch`, className: "text-xs text-fg-secondary", children: "Value" }), _jsx(Input, { id: `${id ?? "color-picker"}-oklch`, type: "text", spellCheck: false, autoComplete: "off", disabled: disabled, value: value, onChange: handleTextChange, "data-slot": "color-picker-value", className: "h-8 px-2 font-mono text-xs" })] }), swatches.length > 0 ? (_jsx("div", { role: "group", "aria-label": "Preset colors", "data-slot": "color-picker-swatches", className: "flex flex-wrap gap-1.5", children: swatches.map((swatch) => {
|
|
295
|
+
const isActive = swatch === value;
|
|
296
|
+
return (_jsx("button", { type: "button", disabled: disabled, "aria-label": swatch, "aria-pressed": isActive, "data-slot": "color-picker-swatch-button", onClick: () => commit(swatch), className: cn("size-6 rounded-md border border-border transition-transform", "outline-none hover:scale-110 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-floating", "disabled:pointer-events-none disabled:opacity-50", isActive && "ring-2 ring-ring ring-offset-2 ring-offset-surface-floating"), style: { background: swatch } }, swatch));
|
|
297
|
+
}) })) : null] })] }));
|
|
298
|
+
});
|
|
299
|
+
ColorPicker.displayName = "ColorPicker";
|
|
300
|
+
//# sourceMappingURL=color-picker.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface ComboboxOption {
|
|
2
|
+
label: string;
|
|
3
|
+
value: string;
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface ComboboxProps {
|
|
7
|
+
/** The list of selectable options. */
|
|
8
|
+
options: ComboboxOption[];
|
|
9
|
+
/** Controlled selected value. Pair with `onValueChange`. */
|
|
10
|
+
value?: string;
|
|
11
|
+
/** Initial value for uncontrolled usage. */
|
|
12
|
+
defaultValue?: string;
|
|
13
|
+
/** Called with the new value when the selection changes. */
|
|
14
|
+
onValueChange?: (value: string) => void;
|
|
15
|
+
/** Text shown on the trigger when nothing is selected. */
|
|
16
|
+
placeholder?: string;
|
|
17
|
+
/** Placeholder for the search input inside the popover. */
|
|
18
|
+
searchPlaceholder?: string;
|
|
19
|
+
/** Message rendered when no option matches the search. */
|
|
20
|
+
emptyText?: string;
|
|
21
|
+
/** Disables the trigger entirely. */
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
/** Extra classes for the trigger button. */
|
|
24
|
+
className?: string;
|
|
25
|
+
/** Extra classes for the popover content. */
|
|
26
|
+
contentClassName?: string;
|
|
27
|
+
/** Accessible name for the trigger when there is no visible label. */
|
|
28
|
+
"aria-label"?: string;
|
|
29
|
+
/** ID of an element labelling the trigger. */
|
|
30
|
+
"aria-labelledby"?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare const Combobox: import("react").ForwardRefExoticComponent<ComboboxProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
33
|
+
//# sourceMappingURL=combobox.d.ts.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Check, ChevronsUpDown } from "lucide-react";
|
|
4
|
+
import { forwardRef, useCallback, useMemo, useState } from "react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { Command, CommandEmpty, CommandInput, CommandItem, CommandList } from "./command.js";
|
|
8
|
+
import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
|
|
9
|
+
export const Combobox = forwardRef(({ options, value: valueProp, defaultValue, onValueChange, placeholder = "Select an option…", searchPlaceholder = "Search…", emptyText = "No results found.", disabled = false, className, contentClassName, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, ...props }, ref) => {
|
|
10
|
+
const [open, setOpen] = useState(false);
|
|
11
|
+
const [uncontrolledValue, setUncontrolledValue] = useState(defaultValue);
|
|
12
|
+
const isControlled = valueProp !== undefined;
|
|
13
|
+
const value = isControlled ? valueProp : uncontrolledValue;
|
|
14
|
+
const selectedOption = useMemo(() => options.find((option) => option.value === value), [options, value]);
|
|
15
|
+
const handleSelect = useCallback((nextValue) => {
|
|
16
|
+
if (!isControlled) {
|
|
17
|
+
setUncontrolledValue(nextValue);
|
|
18
|
+
}
|
|
19
|
+
onValueChange?.(nextValue);
|
|
20
|
+
setOpen(false);
|
|
21
|
+
}, [isControlled, onValueChange]);
|
|
22
|
+
return (_jsxs(Popover, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverTrigger, { asChild: true, children: _jsxs(Button, { ref: ref, variant: "outline", role: "combobox", "aria-expanded": open, "aria-haspopup": "listbox", "aria-label": ariaLabel, "aria-labelledby": ariaLabelledby, disabled: disabled, "data-slot": "combobox-trigger", className: cn("w-full justify-between font-normal", "aria-invalid:border-error aria-invalid:ring-2 aria-invalid:ring-error/30", !selectedOption && "text-fg-muted", className), ...props, children: [_jsx("span", { className: "truncate", children: selectedOption?.label ?? placeholder }), _jsx(ChevronsUpDown, { className: "ml-2 size-4 shrink-0 opacity-60", "aria-hidden": "true" })] }) }), _jsx(PopoverContent, { align: "start", "data-slot": "combobox-content", className: cn("w-[var(--radix-popover-trigger-width)] min-w-[8rem] p-0", contentClassName), children: _jsxs(Command, { children: [_jsx(CommandInput, { placeholder: searchPlaceholder }), _jsxs(CommandList, { children: [_jsx(CommandEmpty, { children: emptyText }), options.map((option) => {
|
|
23
|
+
const isSelected = option.value === value;
|
|
24
|
+
return (_jsxs(CommandItem
|
|
25
|
+
// cmdk indexes/highlights by `value`; duplicate labels would
|
|
26
|
+
// collide, so include the stable value to keep it unique while
|
|
27
|
+
// still matching the visible label for text search.
|
|
28
|
+
, { value: `${option.label} ${option.value}`, disabled: option.disabled, onSelect: () => handleSelect(option.value), children: [_jsx(Check, { className: cn("size-4 shrink-0", isSelected ? "opacity-100" : "opacity-0"), "aria-hidden": "true" }), _jsx("span", { className: "truncate", children: option.label }), isSelected ? _jsx("span", { className: "sr-only", children: ", selected" }) : null] }, option.value));
|
|
29
|
+
})] })] }) })] }));
|
|
30
|
+
});
|
|
31
|
+
Combobox.displayName = "Combobox";
|
|
32
|
+
//# sourceMappingURL=combobox.js.map
|