@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,290 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
4
|
+
import { cva } from "class-variance-authority";
|
|
5
|
+
import { createContext, forwardRef, isValidElement, useCallback, useContext, useEffect, useMemo, useState, useSyncExternalStore, } from "react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { Button } from "./button.js";
|
|
8
|
+
import { ScrollArea } from "./scroll-area.js";
|
|
9
|
+
import { Separator } from "./separator.js";
|
|
10
|
+
import { Sheet, SheetContent, SheetDescription, SheetTitle } from "./sheet.js";
|
|
11
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
12
|
+
/* ------------------------------------------------------------------ *
|
|
13
|
+
* Constants
|
|
14
|
+
* ------------------------------------------------------------------ */
|
|
15
|
+
const SIDEBAR_WIDTH = "16rem";
|
|
16
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
17
|
+
const SIDEBAR_WIDTH_ICON = "3.5rem";
|
|
18
|
+
const SIDEBAR_MOBILE_BREAKPOINT = 768;
|
|
19
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
20
|
+
/* ------------------------------------------------------------------ *
|
|
21
|
+
* Mobile-breakpoint store (SSR-safe via useSyncExternalStore)
|
|
22
|
+
* ------------------------------------------------------------------ */
|
|
23
|
+
const MOBILE_MEDIA_QUERY = `(max-width: ${SIDEBAR_MOBILE_BREAKPOINT - 1}px)`;
|
|
24
|
+
function subscribeMobile(callback) {
|
|
25
|
+
if (typeof window === "undefined" || !window.matchMedia) {
|
|
26
|
+
return () => { };
|
|
27
|
+
}
|
|
28
|
+
const query = window.matchMedia(MOBILE_MEDIA_QUERY);
|
|
29
|
+
query.addEventListener("change", callback);
|
|
30
|
+
return () => query.removeEventListener("change", callback);
|
|
31
|
+
}
|
|
32
|
+
function getMobileSnapshot() {
|
|
33
|
+
if (typeof window === "undefined" || !window.matchMedia) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return window.matchMedia(MOBILE_MEDIA_QUERY).matches;
|
|
37
|
+
}
|
|
38
|
+
// Server snapshot must be a stable value to keep SSR markup deterministic;
|
|
39
|
+
// React reconciles the real client value right after hydration without a
|
|
40
|
+
// hydration-mismatch warning (it's a post-mount store read, not render markup).
|
|
41
|
+
function getMobileServerSnapshot() {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const SidebarContext = createContext(null);
|
|
45
|
+
export function useSidebar() {
|
|
46
|
+
const context = useContext(SidebarContext);
|
|
47
|
+
if (!context) {
|
|
48
|
+
throw new Error("useSidebar must be used within a <SidebarProvider>.");
|
|
49
|
+
}
|
|
50
|
+
return context;
|
|
51
|
+
}
|
|
52
|
+
export const SidebarProvider = forwardRef(({ defaultOpen = true, open: openProp, onOpenChange, enableKeyboardShortcut = true, className, style, children, ...props }, ref) => {
|
|
53
|
+
const isMobile = useSyncExternalStore(subscribeMobile, getMobileSnapshot, getMobileServerSnapshot);
|
|
54
|
+
const [openMobile, setOpenMobile] = useState(false);
|
|
55
|
+
// Internal state for the uncontrolled case.
|
|
56
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
57
|
+
const open = openProp ?? internalOpen;
|
|
58
|
+
const setOpen = useCallback((value) => {
|
|
59
|
+
if (openProp === undefined) {
|
|
60
|
+
setInternalOpen(value);
|
|
61
|
+
}
|
|
62
|
+
onOpenChange?.(value);
|
|
63
|
+
}, [openProp, onOpenChange]);
|
|
64
|
+
const toggleSidebar = useCallback(() => {
|
|
65
|
+
if (isMobile) {
|
|
66
|
+
setOpenMobile((value) => !value);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
setOpen(!open);
|
|
70
|
+
}
|
|
71
|
+
}, [isMobile, open, setOpen]);
|
|
72
|
+
// Ctrl/Cmd+B keyboard shortcut.
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (!enableKeyboardShortcut || typeof window === "undefined") {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const onKeyDown = (event) => {
|
|
78
|
+
// Ignore auto-repeat from a held key.
|
|
79
|
+
if (event.repeat) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (event.key.toLowerCase() === SIDEBAR_KEYBOARD_SHORTCUT &&
|
|
83
|
+
(event.metaKey || event.ctrlKey)) {
|
|
84
|
+
// Don't hijack the shortcut while the user is typing in an editable
|
|
85
|
+
// field (input/textarea/select/contenteditable).
|
|
86
|
+
const target = event.target;
|
|
87
|
+
if (target) {
|
|
88
|
+
const tag = target.tagName;
|
|
89
|
+
if (tag === "INPUT" ||
|
|
90
|
+
tag === "TEXTAREA" ||
|
|
91
|
+
tag === "SELECT" ||
|
|
92
|
+
target.isContentEditable) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
event.preventDefault();
|
|
97
|
+
toggleSidebar();
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
window.addEventListener("keydown", onKeyDown);
|
|
101
|
+
return () => window.removeEventListener("keydown", onKeyDown);
|
|
102
|
+
}, [enableKeyboardShortcut, toggleSidebar]);
|
|
103
|
+
const state = open ? "expanded" : "collapsed";
|
|
104
|
+
const contextValue = useMemo(() => ({
|
|
105
|
+
state,
|
|
106
|
+
open,
|
|
107
|
+
setOpen,
|
|
108
|
+
isMobile,
|
|
109
|
+
openMobile,
|
|
110
|
+
setOpenMobile,
|
|
111
|
+
toggleSidebar,
|
|
112
|
+
}), [state, open, setOpen, isMobile, openMobile, toggleSidebar]);
|
|
113
|
+
return (_jsx(SidebarContext.Provider, { value: contextValue, children: _jsx("div", { ref: ref, "data-slot": "sidebar-wrapper", "data-state": state, style: {
|
|
114
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
115
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
116
|
+
...style,
|
|
117
|
+
}, className: cn("flex min-h-svh w-full", className), ...props, children: children }) }));
|
|
118
|
+
});
|
|
119
|
+
SidebarProvider.displayName = "SidebarProvider";
|
|
120
|
+
export const Sidebar = forwardRef(({ side = "left", variant = "sidebar", collapsible = "icon", className, children, "aria-label": ariaLabel = "Sidebar", ...props }, ref) => {
|
|
121
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
122
|
+
const isOffcanvasCollapsed = collapsible === "offcanvas" && state === "collapsed";
|
|
123
|
+
// Mobile: render the sidebar contents inside a Sheet.
|
|
124
|
+
if (isMobile) {
|
|
125
|
+
return (_jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, children: _jsxs(SheetContent, { ref: ref, "data-slot": "sidebar", "data-mobile": "true", side: side, "aria-label": ariaLabel, className: "w-(--sidebar-width-mobile) gap-0 bg-surface-base p-0 [&>button]:hidden", style: { "--sidebar-width-mobile": SIDEBAR_WIDTH_MOBILE }, ...props, children: [_jsx(SheetTitle, { className: "sr-only", children: ariaLabel }), _jsx(SheetDescription, { className: "sr-only", children: "Mobile navigation menu." }), _jsx("nav", { "aria-label": ariaLabel, className: "flex h-full w-full flex-col", children: children })] }) }));
|
|
126
|
+
}
|
|
127
|
+
// Non-collapsible aside: simple fixed-width column.
|
|
128
|
+
if (collapsible === "none") {
|
|
129
|
+
return (_jsx("aside", { ref: ref, "data-slot": "sidebar", "data-variant": variant, "data-side": side, className: cn("flex h-svh w-(--sidebar-width) flex-col bg-surface-base text-fg", side === "left" ? "border-r border-border" : "border-l border-border", className), ...props, children: _jsx("nav", { "aria-label": ariaLabel, className: "flex h-full w-full flex-col", children: children }) }));
|
|
130
|
+
}
|
|
131
|
+
return (_jsx("aside", { ref: ref, "data-slot": "sidebar", "data-state": state, "data-collapsible": state === "collapsed" ? collapsible : "", "data-variant": variant, "data-side": side,
|
|
132
|
+
// When collapsed offcanvas, take the whole aside out of the a11y tree
|
|
133
|
+
// and tab order so the hidden links/buttons aren't focusable or
|
|
134
|
+
// announced. `inert` also implies aria-hidden for the subtree.
|
|
135
|
+
inert: isOffcanvasCollapsed || undefined, className: cn("group/sidebar relative flex h-svh flex-col text-fg",
|
|
136
|
+
// Width: expanded vs icon-collapsed vs offcanvas-collapsed.
|
|
137
|
+
"w-(--sidebar-width)", "data-[collapsible=icon]:w-(--sidebar-width-icon)", "data-[collapsible=offcanvas]:w-0",
|
|
138
|
+
// Smooth width/transform transition (respects prefers-reduced-motion globally).
|
|
139
|
+
"transition-[width] duration-200 ease-[var(--ease-out-quart)] motion-reduce:transition-none",
|
|
140
|
+
// Surface + border by side.
|
|
141
|
+
variant === "floating"
|
|
142
|
+
? "m-2 rounded-xl border border-border bg-surface-base shadow-sm data-[collapsible=offcanvas]:m-0"
|
|
143
|
+
: variant === "inset"
|
|
144
|
+
? "m-2 rounded-xl bg-surface-base"
|
|
145
|
+
: cn("bg-surface-base", side === "left" ? "border-r border-border" : "border-l border-border"),
|
|
146
|
+
// Offcanvas collapse hides content while preserving layout flow.
|
|
147
|
+
"data-[collapsible=offcanvas]:overflow-hidden data-[collapsible=offcanvas]:border-0", className), ...props, children: _jsx("nav", { "aria-label": ariaLabel, className: "flex h-full w-full flex-col", children: children }) }));
|
|
148
|
+
});
|
|
149
|
+
Sidebar.displayName = "Sidebar";
|
|
150
|
+
export const SidebarTrigger = forwardRef(({ className, onClick, children, ...props }, ref) => {
|
|
151
|
+
const { toggleSidebar, state } = useSidebar();
|
|
152
|
+
return (_jsxs(Button, { ref: ref, type: "button", variant: "ghost", size: "icon-sm", "data-slot": "sidebar-trigger", "aria-label": "Toggle sidebar", "aria-expanded": state === "expanded", className: cn(className), onClick: (event) => {
|
|
153
|
+
onClick?.(event);
|
|
154
|
+
if (!event.defaultPrevented) {
|
|
155
|
+
toggleSidebar();
|
|
156
|
+
}
|
|
157
|
+
}, ...props, children: [children ?? _jsx(SidebarTriggerIcon, {}), _jsx("span", { className: "sr-only", children: "Toggle sidebar" })] }));
|
|
158
|
+
});
|
|
159
|
+
SidebarTrigger.displayName = "SidebarTrigger";
|
|
160
|
+
function SidebarTriggerIcon() {
|
|
161
|
+
return (_jsxs("svg", { "aria-hidden": "true", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "2" }), _jsx("path", { d: "M9 4v16" })] }));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* A thin draggable-looking rail rendered along the inner edge of the sidebar
|
|
165
|
+
* that toggles collapse on click. Hidden on mobile (the Sheet handles dismissal).
|
|
166
|
+
*/
|
|
167
|
+
export const SidebarRail = forwardRef(({ className, onClick, ...props }, ref) => {
|
|
168
|
+
const { toggleSidebar, isMobile } = useSidebar();
|
|
169
|
+
if (isMobile) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
return (_jsx("button", { ref: ref, type: "button", "data-slot": "sidebar-rail", "aria-label": "Toggle sidebar", tabIndex: -1, className: cn("absolute inset-y-0 z-20 hidden w-3 -translate-x-1/2 cursor-col-resize transition-colors sm:flex", "after:absolute after:inset-y-0 after:left-1/2 after:w-px after:bg-transparent hover:after:bg-border", "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset", "group-data-[side=left]/sidebar:right-0 group-data-[side=right]/sidebar:left-0", className), onClick: (event) => {
|
|
173
|
+
onClick?.(event);
|
|
174
|
+
if (!event.defaultPrevented) {
|
|
175
|
+
toggleSidebar();
|
|
176
|
+
}
|
|
177
|
+
}, ...props }));
|
|
178
|
+
});
|
|
179
|
+
SidebarRail.displayName = "SidebarRail";
|
|
180
|
+
/**
|
|
181
|
+
* Content region sibling to a `variant="inset"` sidebar. Provides the rounded,
|
|
182
|
+
* inset surface that pairs with the floating/inset sidebar styles. Not a
|
|
183
|
+
* landmark — the consumer owns the `<main>` per route.
|
|
184
|
+
*/
|
|
185
|
+
export const SidebarInset = forwardRef(({ className, ...props }, ref) => {
|
|
186
|
+
return (_jsx("div", { ref: ref, "data-slot": "sidebar-inset", className: cn("relative flex min-h-svh flex-1 flex-col bg-surface-base", "md:m-2 md:ml-0 md:rounded-xl md:border md:border-border md:shadow-sm", className), ...props }));
|
|
187
|
+
});
|
|
188
|
+
SidebarInset.displayName = "SidebarInset";
|
|
189
|
+
/* ------------------------------------------------------------------ *
|
|
190
|
+
* Structural regions
|
|
191
|
+
* ------------------------------------------------------------------ */
|
|
192
|
+
export const SidebarHeader = forwardRef(({ className, ...props }, ref) => {
|
|
193
|
+
return (_jsx("div", { ref: ref, "data-slot": "sidebar-header", className: cn("flex flex-col gap-2 p-2", className), ...props }));
|
|
194
|
+
});
|
|
195
|
+
SidebarHeader.displayName = "SidebarHeader";
|
|
196
|
+
export const SidebarFooter = forwardRef(({ className, ...props }, ref) => {
|
|
197
|
+
return (_jsx("div", { ref: ref, "data-slot": "sidebar-footer", className: cn("flex flex-col gap-2 p-2", className), ...props }));
|
|
198
|
+
});
|
|
199
|
+
SidebarFooter.displayName = "SidebarFooter";
|
|
200
|
+
/**
|
|
201
|
+
* Scrollable middle region. Uses ScrollArea so long nav trees stay accessible
|
|
202
|
+
* without clipping. Collapses its overflow padding in icon mode.
|
|
203
|
+
*/
|
|
204
|
+
export const SidebarContent = forwardRef(({ className, children, ...props }, ref) => {
|
|
205
|
+
return (_jsx("div", { ref: ref, "data-slot": "sidebar-content", className: cn("min-h-0 flex-1 group-data-[collapsible=offcanvas]/sidebar:overflow-hidden", className), ...props, children: _jsx(ScrollArea, { className: "h-full", children: _jsx("div", { className: "flex flex-col gap-2 p-2 group-data-[collapsible=icon]/sidebar:items-center", children: children }) }) }));
|
|
206
|
+
});
|
|
207
|
+
SidebarContent.displayName = "SidebarContent";
|
|
208
|
+
export const SidebarSeparator = forwardRef(({ className, ...props }, ref) => {
|
|
209
|
+
return (_jsx(Separator, { ref: ref, "data-slot": "sidebar-separator", className: cn("mx-2 w-auto bg-border", className), ...props }));
|
|
210
|
+
});
|
|
211
|
+
SidebarSeparator.displayName = "SidebarSeparator";
|
|
212
|
+
/* ------------------------------------------------------------------ *
|
|
213
|
+
* Group
|
|
214
|
+
* ------------------------------------------------------------------ */
|
|
215
|
+
export const SidebarGroup = forwardRef(({ className, ...props }, ref) => {
|
|
216
|
+
return (_jsx("div", { ref: ref, "data-slot": "sidebar-group", role: "group", className: cn("relative flex w-full min-w-0 flex-col gap-1", className), ...props }));
|
|
217
|
+
});
|
|
218
|
+
SidebarGroup.displayName = "SidebarGroup";
|
|
219
|
+
export const SidebarGroupLabel = forwardRef(({ className, asChild = false, ...props }, ref) => {
|
|
220
|
+
const Comp = asChild ? Slot : "div";
|
|
221
|
+
return (_jsx(Comp, { ref: ref, "data-slot": "sidebar-group-label", className: cn("flex h-7 shrink-0 items-center px-2 text-xs font-medium text-fg-tertiary", "transition-[margin,opacity] duration-200 ease-[var(--ease-out-quart)] motion-reduce:transition-none",
|
|
222
|
+
// Hidden when collapsed to icons.
|
|
223
|
+
"group-data-[collapsible=icon]/sidebar:-mt-8 group-data-[collapsible=icon]/sidebar:opacity-0", className), ...props }));
|
|
224
|
+
});
|
|
225
|
+
SidebarGroupLabel.displayName = "SidebarGroupLabel";
|
|
226
|
+
export const SidebarGroupContent = forwardRef(({ className, ...props }, ref) => {
|
|
227
|
+
return (_jsx("div", { ref: ref, "data-slot": "sidebar-group-content", className: cn("w-full text-sm", className), ...props }));
|
|
228
|
+
});
|
|
229
|
+
SidebarGroupContent.displayName = "SidebarGroupContent";
|
|
230
|
+
/* ------------------------------------------------------------------ *
|
|
231
|
+
* Menu
|
|
232
|
+
* ------------------------------------------------------------------ */
|
|
233
|
+
export const SidebarMenu = forwardRef(({ className, ...props }, ref) => {
|
|
234
|
+
return (_jsx("ul", { ref: ref, "data-slot": "sidebar-menu", className: cn("flex w-full min-w-0 flex-col gap-1", className), ...props }));
|
|
235
|
+
});
|
|
236
|
+
SidebarMenu.displayName = "SidebarMenu";
|
|
237
|
+
export const SidebarMenuItem = forwardRef(({ className, ...props }, ref) => {
|
|
238
|
+
return (_jsx("li", { ref: ref, "data-slot": "sidebar-menu-item", className: cn("group/menu-item relative", className), ...props }));
|
|
239
|
+
});
|
|
240
|
+
SidebarMenuItem.displayName = "SidebarMenuItem";
|
|
241
|
+
const sidebarMenuButtonVariants = cva(cn("group/menu-button peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md text-left text-sm", "transition-[background,color,box-shadow] duration-150 ease-[var(--ease-out-quart)] motion-reduce:transition-none", "text-fg-secondary hover:bg-surface-inset hover:text-fg", "outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base", "disabled:opacity-50 disabled:pointer-events-none", "aria-disabled:opacity-50 aria-disabled:pointer-events-none", "data-[active=true]:bg-surface-inset data-[active=true]:font-medium data-[active=true]:text-fg", "[&>svg]:size-4 [&>svg]:shrink-0 [&>span:last-child]:truncate",
|
|
242
|
+
// Icon-collapsed: square button, hide text labels.
|
|
243
|
+
"group-data-[collapsible=icon]/sidebar:size-8 group-data-[collapsible=icon]/sidebar:justify-center group-data-[collapsible=icon]/sidebar:p-0", "group-data-[collapsible=icon]/sidebar:[&>span:last-child]:hidden"), {
|
|
244
|
+
variants: {
|
|
245
|
+
size: {
|
|
246
|
+
sm: "h-7 px-2 text-xs",
|
|
247
|
+
md: "h-8 px-2",
|
|
248
|
+
lg: "h-10 px-2.5",
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
defaultVariants: { size: "md" },
|
|
252
|
+
});
|
|
253
|
+
export const SidebarMenuButton = forwardRef(({ className, asChild = false, isActive = false, size, tooltip, type, ...props }, ref) => {
|
|
254
|
+
const { state, isMobile } = useSidebar();
|
|
255
|
+
const Comp = asChild ? Slot : "button";
|
|
256
|
+
const button = (_jsx(Comp, { ref: ref, type: asChild ? undefined : (type ?? "button"), "data-slot": "sidebar-menu-button", "data-active": isActive, "aria-current": isActive ? "page" : undefined, className: cn(sidebarMenuButtonVariants({ size }), className), ...props }));
|
|
257
|
+
// No tooltip needed when expanded or on mobile (labels are visible).
|
|
258
|
+
if (!tooltip || state !== "collapsed" || isMobile) {
|
|
259
|
+
return button;
|
|
260
|
+
}
|
|
261
|
+
// A plain object with `children` (and not a React element) is treated as
|
|
262
|
+
// full TooltipContent props; anything else is used directly as the label.
|
|
263
|
+
const isPropsForm = typeof tooltip === "object" &&
|
|
264
|
+
tooltip !== null &&
|
|
265
|
+
!isValidElement(tooltip) &&
|
|
266
|
+
"children" in tooltip;
|
|
267
|
+
const tooltipProps = isPropsForm
|
|
268
|
+
? tooltip
|
|
269
|
+
: { children: tooltip };
|
|
270
|
+
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: button }), _jsx(TooltipContent, { side: "right", align: "center", ...tooltipProps })] }));
|
|
271
|
+
});
|
|
272
|
+
SidebarMenuButton.displayName = "SidebarMenuButton";
|
|
273
|
+
/* ------------------------------------------------------------------ *
|
|
274
|
+
* Menu sub
|
|
275
|
+
* ------------------------------------------------------------------ */
|
|
276
|
+
export const SidebarMenuSub = forwardRef(({ className, ...props }, ref) => {
|
|
277
|
+
return (_jsx("ul", { ref: ref, "data-slot": "sidebar-menu-sub", className: cn("ml-3.5 flex min-w-0 flex-col gap-1 border-l border-border pl-2.5 py-0.5", "group-data-[collapsible=icon]/sidebar:hidden", className), ...props }));
|
|
278
|
+
});
|
|
279
|
+
SidebarMenuSub.displayName = "SidebarMenuSub";
|
|
280
|
+
export const SidebarMenuSubItem = forwardRef(({ className, ...props }, ref) => {
|
|
281
|
+
return (_jsx("li", { ref: ref, "data-slot": "sidebar-menu-sub-item", className: cn("group/menu-sub-item relative", className), ...props }));
|
|
282
|
+
});
|
|
283
|
+
SidebarMenuSubItem.displayName = "SidebarMenuSubItem";
|
|
284
|
+
export const SidebarMenuSubButton = forwardRef(({ className, asChild = false, isActive = false, size = "md", type, ...props }, ref) => {
|
|
285
|
+
const Comp = asChild ? Slot : "button";
|
|
286
|
+
return (_jsx(Comp, { ref: ref, type: asChild ? undefined : (type ?? "button"), "data-slot": "sidebar-menu-sub-button", "data-active": isActive, "aria-current": isActive ? "page" : undefined, className: cn("flex min-w-0 items-center gap-2 overflow-hidden rounded-md px-2 text-fg-tertiary", "transition-[background,color,box-shadow] duration-150 ease-[var(--ease-out-quart)] motion-reduce:transition-none", "hover:bg-surface-inset hover:text-fg outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base", "disabled:opacity-50 disabled:pointer-events-none", "aria-disabled:opacity-50 aria-disabled:pointer-events-none", "data-[active=true]:text-fg data-[active=true]:font-medium", "[&>svg]:size-4 [&>svg]:shrink-0 [&>span:last-child]:truncate", size === "sm" ? "h-6 text-xs" : "h-7 text-sm", "group-data-[collapsible=icon]/sidebar:hidden", className), ...props }));
|
|
287
|
+
});
|
|
288
|
+
SidebarMenuSubButton.displayName = "SidebarMenuSubButton";
|
|
289
|
+
export { sidebarMenuButtonVariants };
|
|
290
|
+
//# sourceMappingURL=sidebar.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type HTMLAttributes } from "react";
|
|
2
|
+
/** Imperative surface exposed through the forwarded ref. */
|
|
3
|
+
export interface SignaturePadHandle {
|
|
4
|
+
/** Erase every stroke and notify `onChange` with `null`. */
|
|
5
|
+
clear: () => void;
|
|
6
|
+
/** Remove the most recent stroke and re-notify `onChange`. */
|
|
7
|
+
undo: () => void;
|
|
8
|
+
/** `true` while no ink has been laid down on the pad. */
|
|
9
|
+
isEmpty: () => boolean;
|
|
10
|
+
/** Snapshot the current drawing as a data URL (`null` while the pad is empty). */
|
|
11
|
+
toDataURL: (type?: string, quality?: number) => string | null;
|
|
12
|
+
}
|
|
13
|
+
export interface SignaturePadProps extends Omit<HTMLAttributes<HTMLDivElement>, "onChange"> {
|
|
14
|
+
/**
|
|
15
|
+
* Fired when a stroke is committed, undone, or the pad is cleared. Receives a
|
|
16
|
+
* PNG data URL of the drawing, or `null` once the pad is empty again.
|
|
17
|
+
*/
|
|
18
|
+
onChange?: (dataUrl: string | null) => void;
|
|
19
|
+
/** Freezes the pad: pointer input is ignored and the overlay actions disable. */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A canvas signature input. Pointer events (mouse / touch / pen) are captured
|
|
24
|
+
* on the canvas and rendered as midpoint-smoothed quadratic curves: every raw
|
|
25
|
+
* sample is used as a control point between successive midpoints, so shaky
|
|
26
|
+
* input still produces a fluid line. Pointer moves never touch React state —
|
|
27
|
+
* samples are queued in refs and painted inside a single pending
|
|
28
|
+
* `requestAnimationFrame`, so drawing costs zero re-renders.
|
|
29
|
+
*
|
|
30
|
+
* The bitmap is `devicePixelRatio`-aware: a `ResizeObserver` resizes the
|
|
31
|
+
* backing store to CSS-size × DPR and replays the stroke model (strokes are
|
|
32
|
+
* stored in CSS pixels), so the ink stays crisp on retina displays and
|
|
33
|
+
* survives layout changes. Ink color is resolved from the wrapper's computed
|
|
34
|
+
* CSS `color` at stroke time, so the line follows the `text-fg` token (and
|
|
35
|
+
* re-resolves per stroke after theme switches).
|
|
36
|
+
*
|
|
37
|
+
* The forwarded ref exposes an imperative API — `clear()`, `undo()`,
|
|
38
|
+
* `isEmpty()`, `toDataURL()` — and `onChange` reports a PNG data URL (or
|
|
39
|
+
* `null` when empty) whenever a stroke is committed, undone, or cleared. A
|
|
40
|
+
* dashed "Sign here" baseline fades away once drawing starts
|
|
41
|
+
* (`motion-reduce` disables the fade transition).
|
|
42
|
+
*/
|
|
43
|
+
export declare const SignaturePad: import("react").ForwardRefExoticComponent<SignaturePadProps & import("react").RefAttributes<SignaturePadHandle>>;
|
|
44
|
+
//# sourceMappingURL=signature-pad.d.ts.map
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Eraser, Undo2 } from "lucide-react";
|
|
4
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState, } from "react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
const STROKE_WIDTH = 2;
|
|
8
|
+
function midpoint(a, b) {
|
|
9
|
+
return { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
10
|
+
}
|
|
11
|
+
function pointFromEvent(canvas, event) {
|
|
12
|
+
const rect = canvas.getBoundingClientRect();
|
|
13
|
+
return { x: event.clientX - rect.left, y: event.clientY - rect.top };
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Replays one recorded stroke with the exact same midpoint-quadratic math the
|
|
17
|
+
* live pointer path uses: each raw sample becomes the *control* point of a
|
|
18
|
+
* quadratic segment that runs between successive midpoints, which rounds off
|
|
19
|
+
* the polyline corners jittery pointer input would otherwise leave behind. A
|
|
20
|
+
* lone sample renders as a dot so a tap still leaves a mark. Returns the
|
|
21
|
+
* trailing midpoint so an in-progress stroke can resume from it after a
|
|
22
|
+
* resize-triggered repaint.
|
|
23
|
+
*/
|
|
24
|
+
function traceStroke(ctx, stroke) {
|
|
25
|
+
const first = stroke[0];
|
|
26
|
+
if (!first)
|
|
27
|
+
return null;
|
|
28
|
+
ctx.beginPath();
|
|
29
|
+
ctx.arc(first.x, first.y, STROKE_WIDTH / 2, 0, Math.PI * 2);
|
|
30
|
+
ctx.fill();
|
|
31
|
+
let prev = first;
|
|
32
|
+
let lastMid = first;
|
|
33
|
+
for (let index = 1; index < stroke.length; index += 1) {
|
|
34
|
+
const point = stroke[index];
|
|
35
|
+
if (!point)
|
|
36
|
+
continue;
|
|
37
|
+
const mid = midpoint(prev, point);
|
|
38
|
+
ctx.beginPath();
|
|
39
|
+
ctx.moveTo(lastMid.x, lastMid.y);
|
|
40
|
+
ctx.quadraticCurveTo(prev.x, prev.y, mid.x, mid.y);
|
|
41
|
+
ctx.stroke();
|
|
42
|
+
prev = point;
|
|
43
|
+
lastMid = mid;
|
|
44
|
+
}
|
|
45
|
+
if (stroke.length > 1) {
|
|
46
|
+
// The curve chain stops at the trailing midpoint; cap it to the final sample.
|
|
47
|
+
ctx.beginPath();
|
|
48
|
+
ctx.moveTo(lastMid.x, lastMid.y);
|
|
49
|
+
ctx.lineTo(prev.x, prev.y);
|
|
50
|
+
ctx.stroke();
|
|
51
|
+
}
|
|
52
|
+
return lastMid;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A canvas signature input. Pointer events (mouse / touch / pen) are captured
|
|
56
|
+
* on the canvas and rendered as midpoint-smoothed quadratic curves: every raw
|
|
57
|
+
* sample is used as a control point between successive midpoints, so shaky
|
|
58
|
+
* input still produces a fluid line. Pointer moves never touch React state —
|
|
59
|
+
* samples are queued in refs and painted inside a single pending
|
|
60
|
+
* `requestAnimationFrame`, so drawing costs zero re-renders.
|
|
61
|
+
*
|
|
62
|
+
* The bitmap is `devicePixelRatio`-aware: a `ResizeObserver` resizes the
|
|
63
|
+
* backing store to CSS-size × DPR and replays the stroke model (strokes are
|
|
64
|
+
* stored in CSS pixels), so the ink stays crisp on retina displays and
|
|
65
|
+
* survives layout changes. Ink color is resolved from the wrapper's computed
|
|
66
|
+
* CSS `color` at stroke time, so the line follows the `text-fg` token (and
|
|
67
|
+
* re-resolves per stroke after theme switches).
|
|
68
|
+
*
|
|
69
|
+
* The forwarded ref exposes an imperative API — `clear()`, `undo()`,
|
|
70
|
+
* `isEmpty()`, `toDataURL()` — and `onChange` reports a PNG data URL (or
|
|
71
|
+
* `null` when empty) whenever a stroke is committed, undone, or cleared. A
|
|
72
|
+
* dashed "Sign here" baseline fades away once drawing starts
|
|
73
|
+
* (`motion-reduce` disables the fade transition).
|
|
74
|
+
*/
|
|
75
|
+
export const SignaturePad = forwardRef(({ className, onChange, disabled = false, "aria-label": ariaLabel = "Signature pad", ...props }, ref) => {
|
|
76
|
+
const wrapperRef = useRef(null);
|
|
77
|
+
const canvasRef = useRef(null);
|
|
78
|
+
const ctxRef = useRef(null);
|
|
79
|
+
/** Committed strokes, in CSS-pixel coordinates (the resize replay source). */
|
|
80
|
+
const strokesRef = useRef([]);
|
|
81
|
+
/** The stroke currently being drawn (`null` when the pointer is up). */
|
|
82
|
+
const currentStrokeRef = useRef(null);
|
|
83
|
+
/** Index of the first sample of the current stroke not yet painted. */
|
|
84
|
+
const paintedIndexRef = useRef(0);
|
|
85
|
+
/** Trailing midpoint of the painted curve chain (next segment starts here). */
|
|
86
|
+
const lastMidRef = useRef(null);
|
|
87
|
+
const pointerIdRef = useRef(null);
|
|
88
|
+
const frameRef = useRef(null);
|
|
89
|
+
const [hasInk, setHasInk] = useState(false);
|
|
90
|
+
const onChangeRef = useRef(onChange);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
onChangeRef.current = onChange;
|
|
93
|
+
});
|
|
94
|
+
const getContext = useCallback(() => {
|
|
95
|
+
if (!ctxRef.current && canvasRef.current) {
|
|
96
|
+
ctxRef.current = canvasRef.current.getContext("2d");
|
|
97
|
+
}
|
|
98
|
+
return ctxRef.current;
|
|
99
|
+
}, []);
|
|
100
|
+
/**
|
|
101
|
+
* Configures the brush, resolving the ink color from the wrapper's
|
|
102
|
+
* computed `color` so the stroke follows the surrounding text token.
|
|
103
|
+
*/
|
|
104
|
+
const applyBrush = useCallback((ctx) => {
|
|
105
|
+
const wrapper = wrapperRef.current;
|
|
106
|
+
const color = (wrapper && typeof window !== "undefined" && window.getComputedStyle(wrapper).color) ||
|
|
107
|
+
"currentColor";
|
|
108
|
+
ctx.strokeStyle = color;
|
|
109
|
+
ctx.fillStyle = color;
|
|
110
|
+
ctx.lineWidth = STROKE_WIDTH;
|
|
111
|
+
ctx.lineCap = "round";
|
|
112
|
+
ctx.lineJoin = "round";
|
|
113
|
+
}, []);
|
|
114
|
+
/** Wipes the bitmap and replays the whole stroke model. */
|
|
115
|
+
const repaint = useCallback(() => {
|
|
116
|
+
const canvas = canvasRef.current;
|
|
117
|
+
const ctx = getContext();
|
|
118
|
+
if (!canvas || !ctx)
|
|
119
|
+
return;
|
|
120
|
+
ctx.save();
|
|
121
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
122
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
123
|
+
ctx.restore();
|
|
124
|
+
applyBrush(ctx);
|
|
125
|
+
for (const stroke of strokesRef.current) {
|
|
126
|
+
traceStroke(ctx, stroke);
|
|
127
|
+
}
|
|
128
|
+
const current = currentStrokeRef.current;
|
|
129
|
+
if (current) {
|
|
130
|
+
lastMidRef.current = traceStroke(ctx, current);
|
|
131
|
+
paintedIndexRef.current = current.length;
|
|
132
|
+
}
|
|
133
|
+
}, [applyBrush, getContext]);
|
|
134
|
+
/** Paints every queued-but-unpainted sample of the in-progress stroke. */
|
|
135
|
+
const paintPending = useCallback(() => {
|
|
136
|
+
const ctx = getContext();
|
|
137
|
+
const stroke = currentStrokeRef.current;
|
|
138
|
+
if (!ctx || !stroke)
|
|
139
|
+
return;
|
|
140
|
+
for (let index = Math.max(1, paintedIndexRef.current); index < stroke.length; index += 1) {
|
|
141
|
+
const prev = stroke[index - 1];
|
|
142
|
+
const point = stroke[index];
|
|
143
|
+
if (!prev || !point)
|
|
144
|
+
continue;
|
|
145
|
+
const mid = midpoint(prev, point);
|
|
146
|
+
const from = lastMidRef.current ?? prev;
|
|
147
|
+
ctx.beginPath();
|
|
148
|
+
ctx.moveTo(from.x, from.y);
|
|
149
|
+
ctx.quadraticCurveTo(prev.x, prev.y, mid.x, mid.y);
|
|
150
|
+
ctx.stroke();
|
|
151
|
+
lastMidRef.current = mid;
|
|
152
|
+
}
|
|
153
|
+
paintedIndexRef.current = stroke.length;
|
|
154
|
+
}, [getContext]);
|
|
155
|
+
const scheduleFlush = useCallback(() => {
|
|
156
|
+
if (frameRef.current !== null)
|
|
157
|
+
return;
|
|
158
|
+
frameRef.current = requestAnimationFrame(() => {
|
|
159
|
+
frameRef.current = null;
|
|
160
|
+
paintPending();
|
|
161
|
+
});
|
|
162
|
+
}, [paintPending]);
|
|
163
|
+
const emitChange = useCallback(() => {
|
|
164
|
+
const handler = onChangeRef.current;
|
|
165
|
+
if (!handler)
|
|
166
|
+
return;
|
|
167
|
+
const canvas = canvasRef.current;
|
|
168
|
+
if (strokesRef.current.length === 0 || !canvas) {
|
|
169
|
+
handler(null);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
handler(canvas.toDataURL());
|
|
173
|
+
}, []);
|
|
174
|
+
// Size the backing store to CSS-size × devicePixelRatio (resizing a canvas
|
|
175
|
+
// erases it, so the strokes are replayed from the model afterwards).
|
|
176
|
+
useEffect(() => {
|
|
177
|
+
const wrapper = wrapperRef.current;
|
|
178
|
+
const canvas = canvasRef.current;
|
|
179
|
+
if (!wrapper || !canvas)
|
|
180
|
+
return;
|
|
181
|
+
const resize = () => {
|
|
182
|
+
const rect = wrapper.getBoundingClientRect();
|
|
183
|
+
const dpr = window.devicePixelRatio || 1;
|
|
184
|
+
canvas.width = Math.max(1, Math.round(rect.width * dpr));
|
|
185
|
+
canvas.height = Math.max(1, Math.round(rect.height * dpr));
|
|
186
|
+
// Scale so the drawing code works in CSS pixels at native sharpness.
|
|
187
|
+
getContext()?.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
188
|
+
repaint();
|
|
189
|
+
};
|
|
190
|
+
resize();
|
|
191
|
+
if (typeof ResizeObserver === "undefined")
|
|
192
|
+
return;
|
|
193
|
+
const observer = new ResizeObserver(resize);
|
|
194
|
+
observer.observe(wrapper);
|
|
195
|
+
return () => observer.disconnect();
|
|
196
|
+
}, [getContext, repaint]);
|
|
197
|
+
// Drop any pending paint frame on unmount.
|
|
198
|
+
useEffect(() => () => {
|
|
199
|
+
if (frameRef.current !== null)
|
|
200
|
+
cancelAnimationFrame(frameRef.current);
|
|
201
|
+
}, []);
|
|
202
|
+
const handlePointerDown = useCallback((event) => {
|
|
203
|
+
if (disabled)
|
|
204
|
+
return;
|
|
205
|
+
if (event.pointerType === "mouse" && event.button !== 0)
|
|
206
|
+
return;
|
|
207
|
+
const canvas = event.currentTarget;
|
|
208
|
+
const ctx = getContext();
|
|
209
|
+
if (!ctx)
|
|
210
|
+
return;
|
|
211
|
+
pointerIdRef.current = event.pointerId;
|
|
212
|
+
if (typeof canvas.setPointerCapture === "function") {
|
|
213
|
+
try {
|
|
214
|
+
canvas.setPointerCapture(event.pointerId);
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
// Some environments reject capture for synthetic pointers; the
|
|
218
|
+
// move/up handlers still work for in-bounds drawing without it.
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const point = pointFromEvent(canvas, event);
|
|
222
|
+
currentStrokeRef.current = [point];
|
|
223
|
+
paintedIndexRef.current = 1;
|
|
224
|
+
lastMidRef.current = point;
|
|
225
|
+
applyBrush(ctx);
|
|
226
|
+
// Anchor dot so a tap leaves a mark even without any movement.
|
|
227
|
+
ctx.beginPath();
|
|
228
|
+
ctx.arc(point.x, point.y, STROKE_WIDTH / 2, 0, Math.PI * 2);
|
|
229
|
+
ctx.fill();
|
|
230
|
+
setHasInk(true);
|
|
231
|
+
}, [applyBrush, disabled, getContext]);
|
|
232
|
+
const handlePointerMove = useCallback((event) => {
|
|
233
|
+
const stroke = currentStrokeRef.current;
|
|
234
|
+
if (!stroke || event.pointerId !== pointerIdRef.current)
|
|
235
|
+
return;
|
|
236
|
+
const canvas = event.currentTarget;
|
|
237
|
+
const native = event.nativeEvent;
|
|
238
|
+
// Pens and high-rate mice batch samples between frames; unpack them so
|
|
239
|
+
// fast flourishes keep their curvature instead of turning into chords.
|
|
240
|
+
const coalesced = typeof native.getCoalescedEvents === "function" ? native.getCoalescedEvents() : [];
|
|
241
|
+
const samples = coalesced.length > 0 ? coalesced : [native];
|
|
242
|
+
for (const sample of samples) {
|
|
243
|
+
stroke.push(pointFromEvent(canvas, sample));
|
|
244
|
+
}
|
|
245
|
+
scheduleFlush();
|
|
246
|
+
}, [scheduleFlush]);
|
|
247
|
+
const finishStroke = useCallback((event) => {
|
|
248
|
+
if (event.pointerId !== pointerIdRef.current)
|
|
249
|
+
return;
|
|
250
|
+
const stroke = currentStrokeRef.current;
|
|
251
|
+
if (!stroke)
|
|
252
|
+
return;
|
|
253
|
+
if (frameRef.current !== null) {
|
|
254
|
+
cancelAnimationFrame(frameRef.current);
|
|
255
|
+
frameRef.current = null;
|
|
256
|
+
}
|
|
257
|
+
paintPending();
|
|
258
|
+
const ctx = getContext();
|
|
259
|
+
const last = stroke[stroke.length - 1];
|
|
260
|
+
const lastMid = lastMidRef.current;
|
|
261
|
+
if (ctx && last && lastMid && stroke.length > 1) {
|
|
262
|
+
// Cap the curve chain through to the final sample (mirrors traceStroke).
|
|
263
|
+
ctx.beginPath();
|
|
264
|
+
ctx.moveTo(lastMid.x, lastMid.y);
|
|
265
|
+
ctx.lineTo(last.x, last.y);
|
|
266
|
+
ctx.stroke();
|
|
267
|
+
}
|
|
268
|
+
strokesRef.current.push(stroke);
|
|
269
|
+
currentStrokeRef.current = null;
|
|
270
|
+
pointerIdRef.current = null;
|
|
271
|
+
lastMidRef.current = null;
|
|
272
|
+
const canvas = event.currentTarget;
|
|
273
|
+
if (typeof canvas.releasePointerCapture === "function") {
|
|
274
|
+
try {
|
|
275
|
+
canvas.releasePointerCapture(event.pointerId);
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
// Capture may already be gone (e.g. pointercancel); nothing to undo.
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
emitChange();
|
|
282
|
+
}, [emitChange, getContext, paintPending]);
|
|
283
|
+
const clear = useCallback(() => {
|
|
284
|
+
if (strokesRef.current.length === 0 && !currentStrokeRef.current)
|
|
285
|
+
return;
|
|
286
|
+
strokesRef.current = [];
|
|
287
|
+
currentStrokeRef.current = null;
|
|
288
|
+
pointerIdRef.current = null;
|
|
289
|
+
lastMidRef.current = null;
|
|
290
|
+
repaint();
|
|
291
|
+
setHasInk(false);
|
|
292
|
+
emitChange();
|
|
293
|
+
}, [emitChange, repaint]);
|
|
294
|
+
const undo = useCallback(() => {
|
|
295
|
+
if (strokesRef.current.length === 0)
|
|
296
|
+
return;
|
|
297
|
+
strokesRef.current = strokesRef.current.slice(0, -1);
|
|
298
|
+
repaint();
|
|
299
|
+
setHasInk(strokesRef.current.length > 0 || currentStrokeRef.current !== null);
|
|
300
|
+
emitChange();
|
|
301
|
+
}, [emitChange, repaint]);
|
|
302
|
+
useImperativeHandle(ref, () => ({
|
|
303
|
+
clear,
|
|
304
|
+
undo,
|
|
305
|
+
isEmpty: () => strokesRef.current.length === 0 && currentStrokeRef.current === null,
|
|
306
|
+
toDataURL: (type, quality) => {
|
|
307
|
+
const canvas = canvasRef.current;
|
|
308
|
+
if (!canvas || (strokesRef.current.length === 0 && !currentStrokeRef.current)) {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
return canvas.toDataURL(type, quality);
|
|
312
|
+
},
|
|
313
|
+
}), [clear, undo]);
|
|
314
|
+
return (_jsxs("div", { ref: wrapperRef, "data-slot": "signature-pad", "data-empty": hasInk ? "false" : "true", "data-disabled": disabled ? "true" : undefined, className: cn("relative h-40 w-full touch-none overflow-hidden rounded-xl border border-border bg-surface-inset text-fg shadow-xs", disabled && "opacity-60", className), ...props, children: [_jsx("canvas", { ref: canvasRef, role: "img", "aria-label": ariaLabel, "aria-disabled": disabled || undefined, "data-slot": "signature-pad-canvas", className: cn("absolute inset-0 size-full", disabled ? "cursor-not-allowed" : "cursor-crosshair"), onPointerDown: handlePointerDown, onPointerMove: handlePointerMove, onPointerUp: finishStroke, onPointerCancel: finishStroke }), _jsxs("div", { "aria-hidden": "true", "data-slot": "signature-pad-hint", className: cn("pointer-events-none absolute inset-x-5 bottom-7 select-none transition-opacity duration-300 motion-reduce:transition-none", hasInk ? "opacity-0" : "opacity-100"), children: [_jsx("div", { className: "border-t border-dashed border-border-strong" }), _jsx("span", { className: "mt-1.5 block text-xs text-fg-muted", children: "Sign here" })] }), _jsxs("div", { className: "absolute right-1.5 bottom-1.5 flex gap-1", children: [_jsx(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": "Undo last stroke", disabled: disabled || !hasInk, onClick: undo, children: _jsx(Undo2, { "aria-hidden": "true" }) }), _jsx(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": "Clear signature", disabled: disabled || !hasInk, onClick: clear, children: _jsx(Eraser, { "aria-hidden": "true" }) })] })] }));
|
|
315
|
+
});
|
|
316
|
+
SignaturePad.displayName = "SignaturePad";
|
|
317
|
+
//# sourceMappingURL=signature-pad.js.map
|