@zonsh/ui 0.0.0 → 0.4.1
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 +43 -0
- package/README.md +81 -1
- package/assets/illustrations/drawing/bracket-construction-dark.svg +77 -0
- package/assets/illustrations/drawing/bracket-construction-filled-dark.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction-filled.svg +50 -0
- package/assets/illustrations/drawing/bracket-construction.svg +77 -0
- package/assets/illustrations/drawing/crescent-dark.svg +28 -0
- package/assets/illustrations/drawing/crescent-guides-dark.svg +33 -0
- package/assets/illustrations/drawing/crescent-guides.svg +33 -0
- package/assets/illustrations/drawing/crescent.svg +28 -0
- package/assets/illustrations/drawing/eclipse-dark.svg +187 -0
- package/assets/illustrations/drawing/eclipse-guides-dark.svg +191 -0
- package/assets/illustrations/drawing/eclipse-guides.svg +191 -0
- package/assets/illustrations/drawing/eclipse.svg +187 -0
- package/assets/illustrations/drawing/elevation-guides-dark.svg +31 -0
- package/assets/illustrations/drawing/elevation-guides-plain-dark.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides-plain.svg +9 -0
- package/assets/illustrations/drawing/elevation-guides.svg +31 -0
- package/assets/illustrations/drawing/horizon-dark.svg +30 -0
- package/assets/illustrations/drawing/horizon.svg +30 -0
- package/assets/illustrations/drawing/nib-study-dark.svg +107 -0
- package/assets/illustrations/drawing/nib-study-plain-dark.svg +93 -0
- package/assets/illustrations/drawing/nib-study-plain.svg +93 -0
- package/assets/illustrations/drawing/nib-study.svg +107 -0
- package/assets/illustrations/editorial/assistant-640.webp +0 -0
- package/assets/illustrations/editorial/assistant.webp +0 -0
- package/assets/illustrations/editorial/automation-640.webp +0 -0
- package/assets/illustrations/editorial/automation.webp +0 -0
- package/assets/illustrations/editorial/bracket-left-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-left.webp +0 -0
- package/assets/illustrations/editorial/bracket-right-640.webp +0 -0
- package/assets/illustrations/editorial/bracket-right.webp +0 -0
- package/assets/illustrations/editorial/custom-software-640.webp +0 -0
- package/assets/illustrations/editorial/custom-software.webp +0 -0
- package/assets/illustrations/editorial/digitalization-640.webp +0 -0
- package/assets/illustrations/editorial/digitalization.webp +0 -0
- package/assets/illustrations/editorial/integration-640.webp +0 -0
- package/assets/illustrations/editorial/integration.webp +0 -0
- package/assets/illustrations/editorial/problem-640.webp +0 -0
- package/assets/illustrations/editorial/problem.webp +0 -0
- package/assets/illustrations/editorial/process-analysis-640.webp +0 -0
- package/assets/illustrations/editorial/process-analysis.webp +0 -0
- package/assets/illustrations/editorial/process-concept-640.webp +0 -0
- package/assets/illustrations/editorial/process-concept.webp +0 -0
- package/assets/illustrations/editorial/process-development-640.webp +0 -0
- package/assets/illustrations/editorial/process-development.webp +0 -0
- package/assets/illustrations/editorial/process-discovery-640.webp +0 -0
- package/assets/illustrations/editorial/process-discovery.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance-640.webp +0 -0
- package/assets/illustrations/editorial/process-maintenance.webp +0 -0
- package/assets/illustrations/editorial/process-prototype-640.webp +0 -0
- package/assets/illustrations/editorial/process-prototype.webp +0 -0
- package/assets/illustrations/editorial/process-testing-640.webp +0 -0
- package/assets/illustrations/editorial/process-testing.webp +0 -0
- package/assets/illustrations/iso/automation-dark.svg +6 -0
- package/assets/illustrations/iso/automation.svg +6 -0
- package/assets/illustrations/iso/bar-chart-dark.svg +6 -0
- package/assets/illustrations/iso/bar-chart.svg +6 -0
- package/assets/illustrations/iso/brackets-classic-dark.svg +6 -0
- package/assets/illustrations/iso/brackets-classic.svg +6 -0
- package/assets/illustrations/iso/brackets-dark.svg +6 -0
- package/assets/illustrations/iso/brackets.svg +6 -0
- package/assets/illustrations/iso/city-dark.svg +6 -0
- package/assets/illustrations/iso/city.svg +6 -0
- package/assets/illustrations/iso/conveyor-dark.svg +6 -0
- package/assets/illustrations/iso/conveyor.svg +6 -0
- package/assets/illustrations/iso/database-dark.svg +6 -0
- package/assets/illustrations/iso/database.svg +6 -0
- package/assets/illustrations/iso/documents-dark.svg +6 -0
- package/assets/illustrations/iso/documents.svg +6 -0
- package/assets/illustrations/iso/inbox-dark.svg +6 -0
- package/assets/illustrations/iso/inbox.svg +6 -0
- package/assets/illustrations/iso/laptop-dark.svg +6 -0
- package/assets/illustrations/iso/laptop.svg +6 -0
- package/assets/illustrations/iso/monitor-dark.svg +6 -0
- package/assets/illustrations/iso/monitor.svg +6 -0
- package/assets/illustrations/iso/pipeline-dark.svg +6 -0
- package/assets/illustrations/iso/pipeline.svg +6 -0
- package/assets/illustrations/iso/platform-dark.svg +6 -0
- package/assets/illustrations/iso/platform.svg +6 -0
- package/assets/illustrations/iso/server-dark.svg +6 -0
- package/assets/illustrations/iso/server.svg +6 -0
- package/assets/illustrations/iso/spreadsheet-dark.svg +6 -0
- package/assets/illustrations/iso/spreadsheet.svg +6 -0
- package/assets/illustrations/iso/timeline-dark.svg +6 -0
- package/assets/illustrations/iso/timeline.svg +6 -0
- package/assets/illustrations/sheet/construction.svg +115 -0
- package/assets/illustrations/sheet/crescent.svg +40 -0
- package/assets/illustrations/sheet/limb.svg +42 -0
- package/assets/illustrations/sheet/stress-axis.svg +119 -0
- package/assets/illustrations/sheet/totality.svg +215 -0
- package/assets/illustrations/sheet/vertical-metrics.svg +43 -0
- package/assets/logo-left.svg +1 -0
- package/assets/logo-right.svg +1 -0
- package/assets/logo.svg +1 -0
- package/dist/components/_overlay.d.ts +47 -0
- package/dist/components/_overlay.js +59 -0
- package/dist/components/accordion.d.ts +32 -0
- package/dist/components/accordion.js +39 -0
- package/dist/components/alert-dialog.d.ts +45 -0
- package/dist/components/alert-dialog.js +56 -0
- package/dist/components/alert.d.ts +35 -0
- package/dist/components/alert.js +42 -0
- package/dist/components/ascii-field.d.ts +34 -0
- package/dist/components/ascii-field.js +410 -0
- package/dist/components/aspect-ratio.d.ts +14 -0
- package/dist/components/aspect-ratio.js +17 -0
- package/dist/components/avatar.d.ts +42 -0
- package/dist/components/avatar.js +55 -0
- package/dist/components/badge.d.ts +70 -0
- package/dist/components/badge.js +62 -0
- package/dist/components/bottom-nav.d.ts +86 -0
- package/dist/components/bottom-nav.js +175 -0
- package/dist/components/breadcrumb.d.ts +31 -0
- package/dist/components/breadcrumb.js +37 -0
- package/dist/components/button-group.d.ts +30 -0
- package/dist/components/button-group.js +47 -0
- package/dist/components/button.d.ts +53 -0
- package/dist/components/button.js +130 -0
- package/dist/components/calendar.d.ts +26 -0
- package/dist/components/calendar.js +179 -0
- package/dist/components/card.d.ts +42 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +109 -0
- package/dist/components/carousel.js +231 -0
- package/dist/components/chart.d.ts +189 -0
- package/dist/components/chart.js +323 -0
- package/dist/components/checkbox.d.ts +23 -0
- package/dist/components/checkbox.js +43 -0
- package/dist/components/code-block.d.ts +55 -0
- package/dist/components/code-block.js +100 -0
- package/dist/components/collapsible.d.ts +20 -0
- package/dist/components/collapsible.js +32 -0
- package/dist/components/color-picker.d.ts +107 -0
- package/dist/components/color-picker.js +428 -0
- package/dist/components/combobox.d.ts +99 -0
- package/dist/components/combobox.js +172 -0
- package/dist/components/command.d.ts +132 -0
- package/dist/components/command.js +257 -0
- package/dist/components/context-menu.d.ts +29 -0
- package/dist/components/context-menu.js +35 -0
- package/dist/components/conversation.d.ts +36 -0
- package/dist/components/conversation.js +303 -0
- package/dist/components/copy-button.d.ts +55 -0
- package/dist/components/copy-button.js +133 -0
- package/dist/components/data-table.d.ts +235 -0
- package/dist/components/data-table.js +655 -0
- package/dist/components/date-picker.d.ts +160 -0
- package/dist/components/date-picker.js +338 -0
- package/dist/components/dialog.d.ts +57 -0
- package/dist/components/dialog.js +95 -0
- package/dist/components/direction.d.ts +16 -0
- package/dist/components/direction.js +18 -0
- package/dist/components/drawer.d.ts +69 -0
- package/dist/components/drawer.js +79 -0
- package/dist/components/empty.d.ts +31 -0
- package/dist/components/empty.js +50 -0
- package/dist/components/feature-list.d.ts +54 -0
- package/dist/components/feature-list.js +43 -0
- package/dist/components/field.d.ts +34 -0
- package/dist/components/field.js +81 -0
- package/dist/components/file-drop.d.ts +77 -0
- package/dist/components/file-drop.js +258 -0
- package/dist/components/filter-bar.d.ts +153 -0
- package/dist/components/filter-bar.js +334 -0
- package/dist/components/form.d.ts +35 -0
- package/dist/components/form.js +56 -0
- package/dist/components/graph.d.ts +146 -0
- package/dist/components/graph.js +825 -0
- package/dist/components/illustration.d.ts +85 -0
- package/dist/components/illustration.js +165 -0
- package/dist/components/input-group.d.ts +138 -0
- package/dist/components/input-group.js +312 -0
- package/dist/components/input.d.ts +16 -0
- package/dist/components/input.js +25 -0
- package/dist/components/item.d.ts +64 -0
- package/dist/components/item.js +116 -0
- package/dist/components/kbd.d.ts +50 -0
- package/dist/components/kbd.js +45 -0
- package/dist/components/label.d.ts +12 -0
- package/dist/components/label.js +24 -0
- package/dist/components/layout.d.ts +136 -0
- package/dist/components/layout.js +162 -0
- package/dist/components/lightbox.d.ts +100 -0
- package/dist/components/lightbox.js +439 -0
- package/dist/components/locale.d.ts +44 -0
- package/dist/components/locale.js +37 -0
- package/dist/components/logo.d.ts +54 -0
- package/dist/components/logo.js +96 -0
- package/dist/components/menu.d.ts +60 -0
- package/dist/components/menu.js +140 -0
- package/dist/components/menubar.d.ts +62 -0
- package/dist/components/menubar.js +223 -0
- package/dist/components/message.d.ts +42 -0
- package/dist/components/message.js +59 -0
- package/dist/components/meter.d.ts +31 -0
- package/dist/components/meter.js +27 -0
- package/dist/components/money-input.d.ts +80 -0
- package/dist/components/money-input.js +253 -0
- package/dist/components/native-select.d.ts +26 -0
- package/dist/components/native-select.js +35 -0
- package/dist/components/navigation-menu.d.ts +42 -0
- package/dist/components/navigation-menu.js +97 -0
- package/dist/components/number-field.d.ts +55 -0
- package/dist/components/number-field.js +164 -0
- package/dist/components/otp-field.d.ts +48 -0
- package/dist/components/otp-field.js +102 -0
- package/dist/components/pagination.d.ts +37 -0
- package/dist/components/pagination.js +81 -0
- package/dist/components/pdf-viewer.d.ts +134 -0
- package/dist/components/pdf-viewer.js +996 -0
- package/dist/components/phone-input.d.ts +79 -0
- package/dist/components/phone-input.js +282 -0
- package/dist/components/popover.d.ts +33 -0
- package/dist/components/popover.js +48 -0
- package/dist/components/preview-card.d.ts +25 -0
- package/dist/components/preview-card.js +22 -0
- package/dist/components/progress.d.ts +27 -0
- package/dist/components/progress.js +25 -0
- package/dist/components/prompt-input.d.ts +156 -0
- package/dist/components/prompt-input.js +415 -0
- package/dist/components/quote.d.ts +22 -0
- package/dist/components/quote.js +15 -0
- package/dist/components/radio-group.d.ts +18 -0
- package/dist/components/radio-group.js +34 -0
- package/dist/components/rating.d.ts +73 -0
- package/dist/components/rating.js +124 -0
- package/dist/components/reasoning.d.ts +46 -0
- package/dist/components/reasoning.js +73 -0
- package/dist/components/resizable.d.ts +47 -0
- package/dist/components/resizable.js +44 -0
- package/dist/components/response.d.ts +41 -0
- package/dist/components/response.js +566 -0
- package/dist/components/scroll-area.d.ts +33 -0
- package/dist/components/scroll-area.js +31 -0
- package/dist/components/select.d.ts +35 -0
- package/dist/components/select.js +71 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +17 -0
- package/dist/components/sidebar.d.ts +163 -0
- package/dist/components/sidebar.js +505 -0
- package/dist/components/site-header.d.ts +93 -0
- package/dist/components/site-header.js +121 -0
- package/dist/components/skeleton.d.ts +31 -0
- package/dist/components/skeleton.js +29 -0
- package/dist/components/slider.d.ts +24 -0
- package/dist/components/slider.js +131 -0
- package/dist/components/sortable.d.ts +178 -0
- package/dist/components/sortable.js +1258 -0
- package/dist/components/sources.d.ts +40 -0
- package/dist/components/sources.js +42 -0
- package/dist/components/spinner.d.ts +48 -0
- package/dist/components/spinner.js +75 -0
- package/dist/components/stat.d.ts +91 -0
- package/dist/components/stat.js +141 -0
- package/dist/components/stepper.d.ts +71 -0
- package/dist/components/stepper.js +101 -0
- package/dist/components/suggestions.d.ts +20 -0
- package/dist/components/suggestions.js +18 -0
- package/dist/components/switch.d.ts +14 -0
- package/dist/components/switch.js +26 -0
- package/dist/components/table.d.ts +172 -0
- package/dist/components/table.js +895 -0
- package/dist/components/tabs.d.ts +25 -0
- package/dist/components/tabs.js +162 -0
- package/dist/components/tag.d.ts +41 -0
- package/dist/components/tag.js +88 -0
- package/dist/components/tags-input.d.ts +56 -0
- package/dist/components/tags-input.js +271 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +16 -0
- package/dist/components/theme.d.ts +55 -0
- package/dist/components/theme.js +120 -0
- package/dist/components/time-field.d.ts +70 -0
- package/dist/components/time-field.js +450 -0
- package/dist/components/timeline.d.ts +92 -0
- package/dist/components/timeline.js +108 -0
- package/dist/components/tippy.d.ts +48 -0
- package/dist/components/tippy.js +648 -0
- package/dist/components/toast.d.ts +88 -0
- package/dist/components/toast.js +205 -0
- package/dist/components/toggle-group.d.ts +41 -0
- package/dist/components/toggle-group.js +140 -0
- package/dist/components/toggle.d.ts +23 -0
- package/dist/components/toggle.js +35 -0
- package/dist/components/tool-call.d.ts +63 -0
- package/dist/components/tool-call.js +68 -0
- package/dist/components/toolbar.d.ts +17 -0
- package/dist/components/toolbar.js +39 -0
- package/dist/components/tooltip.d.ts +42 -0
- package/dist/components/tooltip.js +47 -0
- package/dist/components/tour.d.ts +127 -0
- package/dist/components/tour.js +648 -0
- package/dist/components/tree.d.ts +75 -0
- package/dist/components/tree.js +649 -0
- package/dist/components/typography.d.ts +134 -0
- package/dist/components/typography.js +176 -0
- package/dist/components/video-player.d.ts +284 -0
- package/dist/components/video-player.js +1392 -0
- package/dist/illustration.d.ts +2 -0
- package/dist/illustration.js +7 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +94 -0
- package/dist/lib/cn.d.ts +20 -0
- package/dist/lib/cn.js +38 -0
- package/dist/lib/code-highlight.d.ts +18 -0
- package/dist/lib/code-highlight.js +174 -0
- package/dist/lib/code-theme.d.ts +19 -0
- package/dist/lib/code-theme.js +140 -0
- package/dist/lib/collapse-row.d.ts +9 -0
- package/dist/lib/collapse-row.js +129 -0
- package/dist/lib/digit-roll.d.ts +21 -0
- package/dist/lib/digit-roll.js +31 -0
- package/dist/lib/editorial-assets.d.ts +16 -0
- package/dist/lib/editorial-assets.js +56 -0
- package/dist/lib/field-errors.d.ts +28 -0
- package/dist/lib/field-errors.js +24 -0
- package/dist/lib/field-value.d.ts +13 -0
- package/dist/lib/field-value.js +44 -0
- package/dist/lib/figure/catalog.d.ts +127 -0
- package/dist/lib/figure/catalog.js +130 -0
- package/dist/lib/figure/figures/automation.d.ts +7 -0
- package/dist/lib/figure/figures/automation.js +143 -0
- package/dist/lib/figure/figures/bar-chart.d.ts +7 -0
- package/dist/lib/figure/figures/bar-chart.js +99 -0
- package/dist/lib/figure/figures/brackets-classic.d.ts +11 -0
- package/dist/lib/figure/figures/brackets-classic.js +170 -0
- package/dist/lib/figure/figures/brackets.d.ts +8 -0
- package/dist/lib/figure/figures/brackets.js +84 -0
- package/dist/lib/figure/figures/city.d.ts +7 -0
- package/dist/lib/figure/figures/city.js +93 -0
- package/dist/lib/figure/figures/conveyor.d.ts +7 -0
- package/dist/lib/figure/figures/conveyor.js +97 -0
- package/dist/lib/figure/figures/database.d.ts +7 -0
- package/dist/lib/figure/figures/database.js +65 -0
- package/dist/lib/figure/figures/documents.d.ts +7 -0
- package/dist/lib/figure/figures/documents.js +83 -0
- package/dist/lib/figure/figures/inbox.d.ts +7 -0
- package/dist/lib/figure/figures/inbox.js +92 -0
- package/dist/lib/figure/figures/laptop.d.ts +7 -0
- package/dist/lib/figure/figures/laptop.js +67 -0
- package/dist/lib/figure/figures/monitor.d.ts +7 -0
- package/dist/lib/figure/figures/monitor.js +59 -0
- package/dist/lib/figure/figures/pipeline.d.ts +8 -0
- package/dist/lib/figure/figures/pipeline.js +117 -0
- package/dist/lib/figure/figures/platform.d.ts +7 -0
- package/dist/lib/figure/figures/platform.js +117 -0
- package/dist/lib/figure/figures/server.d.ts +7 -0
- package/dist/lib/figure/figures/server.js +115 -0
- package/dist/lib/figure/figures/spreadsheet.d.ts +7 -0
- package/dist/lib/figure/figures/spreadsheet.js +87 -0
- package/dist/lib/figure/figures/timeline.d.ts +7 -0
- package/dist/lib/figure/figures/timeline.js +65 -0
- package/dist/lib/figure/kernel.d.ts +152 -0
- package/dist/lib/figure/kernel.js +576 -0
- package/dist/lib/figure/parts.d.ts +42 -0
- package/dist/lib/figure/parts.js +126 -0
- package/dist/lib/form-reset.d.ts +11 -0
- package/dist/lib/form-reset.js +22 -0
- package/dist/lib/glide.d.ts +53 -0
- package/dist/lib/glide.js +138 -0
- package/dist/lib/graph-layout.d.ts +58 -0
- package/dist/lib/graph-layout.js +209 -0
- package/dist/lib/illustration-drawings.d.ts +89 -0
- package/dist/lib/illustration-drawings.js +539 -0
- package/dist/lib/illustration-info.d.ts +37 -0
- package/dist/lib/illustration-info.js +22 -0
- package/dist/lib/illustration-library.d.ts +87 -0
- package/dist/lib/illustration-library.js +352 -0
- package/dist/lib/logo-geometry.d.ts +29 -0
- package/dist/lib/logo-geometry.js +67 -0
- package/dist/lib/markdown-guard.d.ts +16 -0
- package/dist/lib/markdown-guard.js +123 -0
- package/dist/lib/merge-refs.d.ts +10 -0
- package/dist/lib/merge-refs.js +26 -0
- package/dist/lib/money.d.ts +73 -0
- package/dist/lib/money.js +343 -0
- package/dist/lib/motion.d.ts +6 -0
- package/dist/lib/motion.js +12 -0
- package/dist/lib/pdf-worker.d.ts +1 -0
- package/dist/lib/pdf-worker.js +6 -0
- package/dist/lib/pdf.d.ts +19 -0
- package/dist/lib/pdf.js +58 -0
- package/dist/lib/phone-countries.d.ts +1 -0
- package/dist/lib/phone-countries.js +281 -0
- package/dist/lib/phone.d.ts +90 -0
- package/dist/lib/phone.js +286 -0
- package/dist/lib/platform.d.ts +38 -0
- package/dist/lib/platform.js +75 -0
- package/dist/lib/room.d.ts +25 -0
- package/dist/lib/room.js +46 -0
- package/dist/lib/row-index.d.ts +15 -0
- package/dist/lib/row-index.js +136 -0
- package/dist/lib/table-fit.d.ts +143 -0
- package/dist/lib/table-fit.js +596 -0
- package/dist/lib/theme-script.d.ts +31 -0
- package/dist/lib/theme-script.js +49 -0
- package/dist/lib/tippy/pixels.d.ts +47 -0
- package/dist/lib/tippy/pixels.js +187 -0
- package/dist/lib/tippy/sprite.d.ts +86 -0
- package/dist/lib/tippy/sprite.js +753 -0
- package/dist/messages/de.d.ts +12 -0
- package/dist/messages/de.js +326 -0
- package/dist/styles/expressive.css +203 -0
- package/dist/styles/fonts.css +145 -0
- package/dist/styles/index.css +207 -0
- package/dist/styles/material.css +317 -0
- package/dist/styles/parts/ai.css +361 -0
- package/dist/styles/parts/brand.css +75 -0
- package/dist/styles/parts/controls.css +774 -0
- package/dist/styles/parts/data.css +222 -0
- package/dist/styles/parts/editorial.css +120 -0
- package/dist/styles/parts/feedback.css +340 -0
- package/dist/styles/parts/foundations.css +166 -0
- package/dist/styles/parts/graph.css +214 -0
- package/dist/styles/parts/inputs.css +261 -0
- package/dist/styles/parts/isometric.css +124 -0
- package/dist/styles/parts/navigation.css +424 -0
- package/dist/styles/parts/overlays.css +250 -0
- package/dist/styles/parts/pdf.css +154 -0
- package/dist/styles/parts/react-flow.css +519 -0
- package/dist/styles/tokens.css +299 -0
- package/dist/vite.d.ts +66 -0
- package/dist/vite.js +29 -0
- package/package.json +183 -5
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
import { PanelLeftIcon } from "lucide-react";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { modPressed } from "../lib/platform.js";
|
|
8
|
+
import { Button } from "./button.js";
|
|
9
|
+
import { Drawer, DrawerContent, DrawerTitle } from "./drawer.js";
|
|
10
|
+
import { useMessages } from "./locale.js";
|
|
11
|
+
import { ScrollArea } from "./scroll-area.js";
|
|
12
|
+
import { Separator } from "./separator.js";
|
|
13
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip.js";
|
|
14
|
+
const defaultMessages = { navigation: "Navigation", toggle: "Toggle sidebar" };
|
|
15
|
+
const SidebarContext = React.createContext(null);
|
|
16
|
+
/** The sidebar's density: `default` 38px rows, `sm` 30px rows (`Sidebar size`). */
|
|
17
|
+
const SidebarSizeContext = React.createContext("default");
|
|
18
|
+
/** The edge the sidebar is on (`Sidebar side`): its icon rail's tooltips open towards the page. */
|
|
19
|
+
const SidebarSideContext = React.createContext("left");
|
|
20
|
+
/** Where a `Sidebar` is rendered: the desktop panel or the mobile sheet. */
|
|
21
|
+
const SidebarSurfaceContext = React.createContext("panel");
|
|
22
|
+
/**
|
|
23
|
+
* useSidebar — the app shell's state, for building your own trigger or reacting to collapse:
|
|
24
|
+
* `{ state, open, setOpen, openMobile, setOpenMobile, isMobile, toggleSidebar, collapsible }`.
|
|
25
|
+
* Must be used inside a `SidebarProvider`.
|
|
26
|
+
*/
|
|
27
|
+
export function useSidebar() {
|
|
28
|
+
const context = React.useContext(SidebarContext);
|
|
29
|
+
if (!context)
|
|
30
|
+
throw new Error("useSidebar must be used within a <SidebarProvider />");
|
|
31
|
+
return context;
|
|
32
|
+
}
|
|
33
|
+
const MOBILE_QUERY = "(width < 48rem)";
|
|
34
|
+
const subscribeMobile = (onChange) => {
|
|
35
|
+
const mq = window.matchMedia(MOBILE_QUERY);
|
|
36
|
+
mq.addEventListener("change", onChange);
|
|
37
|
+
return () => mq.removeEventListener("change", onChange);
|
|
38
|
+
};
|
|
39
|
+
const useIsMobile = () => React.useSyncExternalStore(subscribeMobile, () => window.matchMedia(MOBILE_QUERY).matches, () => false);
|
|
40
|
+
function readStored(key) {
|
|
41
|
+
try {
|
|
42
|
+
const value = window.localStorage.getItem(key);
|
|
43
|
+
if (value === "true")
|
|
44
|
+
return true;
|
|
45
|
+
if (value === "false")
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// Storage can be unavailable (private mode, blocked site data). The default stands.
|
|
50
|
+
}
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
function writeStored(key, open) {
|
|
54
|
+
try {
|
|
55
|
+
window.localStorage.setItem(key, String(open));
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
// Ignore: persistence is a convenience.
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
// A cookie as well, so a server can read it and render the right state first time.
|
|
62
|
+
document.cookie = `${encodeURIComponent(key)}=${open}; path=/; max-age=${60 * 60 * 24 * 365}; SameSite=Lax`;
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
// Ignore.
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* SidebarProvider — turns a `Sidebar` into an app shell: open state, collapse (`offcanvas`,
|
|
70
|
+
* `icon` or `none`), ⌘B on a Mac and Ctrl+B elsewhere, a sheet on mobile and a remembered state.
|
|
71
|
+
*
|
|
72
|
+
* It renders the shell's flex row; put the `Sidebar` and a `SidebarInset` inside. The shell is
|
|
73
|
+
* at least the viewport tall (`min-h-svh`) — give it a fixed height (`h-[560px] min-h-0`) to
|
|
74
|
+
* embed it in a page. Widths come from `--sidebar-width` (16rem) and `--sidebar-width-icon`.
|
|
75
|
+
*/
|
|
76
|
+
export function SidebarProvider({ defaultOpen = true, open: openProp, onOpenChange, collapsible = "offcanvas", storageKey = "zon-sidebar", keyboardShortcut = "b", className, style, children, ...props }) {
|
|
77
|
+
const isMobile = useIsMobile();
|
|
78
|
+
const [openMobile, setOpenMobile] = React.useState(false);
|
|
79
|
+
const [openState, setOpenState] = React.useState(defaultOpen);
|
|
80
|
+
const open = openProp ?? openState;
|
|
81
|
+
const openRef = React.useRef(open);
|
|
82
|
+
openRef.current = open;
|
|
83
|
+
const setOpen = React.useCallback((value) => {
|
|
84
|
+
if (openProp === undefined)
|
|
85
|
+
setOpenState(value);
|
|
86
|
+
onOpenChange?.(value);
|
|
87
|
+
if (storageKey)
|
|
88
|
+
writeStored(storageKey, value);
|
|
89
|
+
}, [openProp, onOpenChange, storageKey]);
|
|
90
|
+
// Restore the remembered state after hydration (uncontrolled only).
|
|
91
|
+
React.useEffect(() => {
|
|
92
|
+
if (openProp !== undefined || !storageKey)
|
|
93
|
+
return;
|
|
94
|
+
const stored = readStored(storageKey);
|
|
95
|
+
if (stored !== undefined)
|
|
96
|
+
setOpenState(stored);
|
|
97
|
+
}, [openProp, storageKey]);
|
|
98
|
+
const toggleSidebar = React.useCallback(() => {
|
|
99
|
+
if (isMobile)
|
|
100
|
+
setOpenMobile((value) => !value);
|
|
101
|
+
else
|
|
102
|
+
setOpen(!openRef.current);
|
|
103
|
+
}, [isMobile, setOpen]);
|
|
104
|
+
// Leaving the mobile layout closes the sheet: narrowing the window again must not reopen it.
|
|
105
|
+
if (!isMobile && openMobile)
|
|
106
|
+
setOpenMobile(false);
|
|
107
|
+
React.useEffect(() => {
|
|
108
|
+
if (!keyboardShortcut || collapsible === "none")
|
|
109
|
+
return;
|
|
110
|
+
const onKeyDown = (event) => {
|
|
111
|
+
// Autofill sends keydowns without a key. A key something else handled (an editor's bold),
|
|
112
|
+
// composing text, or held down is not the shortcut, nor is ⌘B / Ctrl+B in a contenteditable,
|
|
113
|
+
// where it is bold.
|
|
114
|
+
if (event.key?.toLowerCase() !== keyboardShortcut.toLowerCase())
|
|
115
|
+
return;
|
|
116
|
+
// ⌘ on Apple devices, Ctrl elsewhere, and not both: a Mac's Ctrl+B moves the caret back.
|
|
117
|
+
if (!modPressed(event) || event.altKey || event.shiftKey)
|
|
118
|
+
return;
|
|
119
|
+
if (event.defaultPrevented || event.isComposing || event.repeat)
|
|
120
|
+
return;
|
|
121
|
+
if (event.target instanceof HTMLElement && event.target.isContentEditable)
|
|
122
|
+
return;
|
|
123
|
+
event.preventDefault();
|
|
124
|
+
toggleSidebar();
|
|
125
|
+
};
|
|
126
|
+
window.addEventListener("keydown", onKeyDown);
|
|
127
|
+
return () => window.removeEventListener("keydown", onKeyDown);
|
|
128
|
+
}, [keyboardShortcut, collapsible, toggleSidebar]);
|
|
129
|
+
const value = React.useMemo(() => ({
|
|
130
|
+
state: open || collapsible === "none" ? "expanded" : "collapsed",
|
|
131
|
+
open,
|
|
132
|
+
setOpen,
|
|
133
|
+
openMobile,
|
|
134
|
+
setOpenMobile,
|
|
135
|
+
isMobile,
|
|
136
|
+
toggleSidebar,
|
|
137
|
+
collapsible,
|
|
138
|
+
}), [open, setOpen, openMobile, isMobile, toggleSidebar, collapsible]);
|
|
139
|
+
return (_jsx(SidebarContext.Provider, { value: value, children: _jsx(TooltipProvider, { children: _jsx("div", { "data-slot": "sidebar-wrapper", className: cn("flex min-h-svh w-full", className), style: {
|
|
140
|
+
"--sidebar-width": "16rem",
|
|
141
|
+
"--sidebar-width-icon": "calc(var(--control-h) + 25px)",
|
|
142
|
+
...style,
|
|
143
|
+
}, ...props, children: children }) }) }));
|
|
144
|
+
}
|
|
145
|
+
/* ── The current row glides ──────────────────────────────────────────────── */
|
|
146
|
+
const ROW = '[data-slot="sidebar-item"]';
|
|
147
|
+
const CURRENT_ROW = `${ROW}[aria-current="page"]`;
|
|
148
|
+
/** An element's box relative to the nav's padding box, scrolled and transformed as it is on screen. */
|
|
149
|
+
function boxIn(nav, el) {
|
|
150
|
+
const r = el.getBoundingClientRect();
|
|
151
|
+
const n = nav.getBoundingClientRect();
|
|
152
|
+
return {
|
|
153
|
+
x: r.left - n.left - nav.clientLeft,
|
|
154
|
+
y: r.top - n.top - nav.clientTop,
|
|
155
|
+
w: r.width,
|
|
156
|
+
h: r.height,
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* When the current page changes, its raised row glides from the old row to the new one — across
|
|
161
|
+
* groups, and from the scrolling list to the footer. A copy of the row's material (this span,
|
|
162
|
+
* under the rows in the nav's own stacking context) makes the trip while the two real rows stay
|
|
163
|
+
* flat; on arrival the new row takes its own material again in the same frame. The first
|
|
164
|
+
* placement, a current row that was not on screen, and reduced motion set it in place.
|
|
165
|
+
*/
|
|
166
|
+
function CurrentGlide() {
|
|
167
|
+
const ref = React.useRef(null);
|
|
168
|
+
React.useLayoutEffect(() => {
|
|
169
|
+
const ghost = ref.current;
|
|
170
|
+
const nav = ghost?.parentElement;
|
|
171
|
+
if (!ghost || !nav)
|
|
172
|
+
return;
|
|
173
|
+
let last = nav.querySelector(CURRENT_ROW);
|
|
174
|
+
let running = null;
|
|
175
|
+
const rows = new Set();
|
|
176
|
+
const box = (el) => boxIn(nav, el);
|
|
177
|
+
const shown = (el) => !!el && el.isConnected && el.offsetWidth > 0 && el.offsetHeight > 0;
|
|
178
|
+
const land = () => {
|
|
179
|
+
running = null;
|
|
180
|
+
ghost.style.visibility = "hidden";
|
|
181
|
+
// Back to their own material, without a transition: the copy is gone in the same frame.
|
|
182
|
+
for (const row of rows)
|
|
183
|
+
row.dataset.glide = "landing";
|
|
184
|
+
const landed = [...rows];
|
|
185
|
+
rows.clear();
|
|
186
|
+
requestAnimationFrame(() => requestAnimationFrame(() => landed.forEach((row) => row.dataset.glide === "landing" && delete row.dataset.glide)));
|
|
187
|
+
};
|
|
188
|
+
const move = () => {
|
|
189
|
+
const next = nav.querySelector(CURRENT_ROW);
|
|
190
|
+
if (next === last)
|
|
191
|
+
return;
|
|
192
|
+
const from = running ? box(ghost) : shown(last) ? box(last) : null;
|
|
193
|
+
const prev = last;
|
|
194
|
+
last = next;
|
|
195
|
+
running?.cancel();
|
|
196
|
+
if (!from || !shown(next) || window.matchMedia("(prefers-reduced-motion: reduce)").matches) {
|
|
197
|
+
if (running)
|
|
198
|
+
land();
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
const to = box(next);
|
|
202
|
+
for (const row of [prev, next]) {
|
|
203
|
+
if (row) {
|
|
204
|
+
row.dataset.glide = "hidden";
|
|
205
|
+
rows.add(row);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
ghost.style.visibility = "visible";
|
|
209
|
+
const duration = parseFloat(getComputedStyle(nav).getPropertyValue("--duration")) || 150;
|
|
210
|
+
const at = (b) => ({
|
|
211
|
+
translate: `${b.x}px ${b.y}px`,
|
|
212
|
+
width: `${b.w}px`,
|
|
213
|
+
height: `${b.h}px`,
|
|
214
|
+
});
|
|
215
|
+
running = ghost.animate([at(from), at(to)], {
|
|
216
|
+
duration: duration * 2,
|
|
217
|
+
easing: getComputedStyle(nav).getPropertyValue("--ease").trim() || "ease-out",
|
|
218
|
+
fill: "forwards",
|
|
219
|
+
});
|
|
220
|
+
running.onfinish = land;
|
|
221
|
+
};
|
|
222
|
+
const watch = new MutationObserver(move);
|
|
223
|
+
watch.observe(nav, {
|
|
224
|
+
subtree: true,
|
|
225
|
+
childList: true,
|
|
226
|
+
attributes: true,
|
|
227
|
+
attributeFilter: ["aria-current"],
|
|
228
|
+
});
|
|
229
|
+
return () => {
|
|
230
|
+
watch.disconnect();
|
|
231
|
+
running?.cancel();
|
|
232
|
+
for (const row of rows)
|
|
233
|
+
delete row.dataset.glide;
|
|
234
|
+
};
|
|
235
|
+
}, []);
|
|
236
|
+
return (_jsx("span", { ref: ref, "aria-hidden": true, "data-slot": "sidebar-current-glide", "data-current": "", className: "pointer-events-none invisible absolute top-0 left-0 -z-1 rounded-button material-row" }));
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Hover is one soft fill that follows the pointer up and down the list instead of each row lighting
|
|
240
|
+
* on its own. It appears in place where the pointer comes in, glides from row to row (across the
|
|
241
|
+
* gap between groups too, within a short linger), and fades where it is when the pointer leaves.
|
|
242
|
+
* It sits under the rows and under the current row's material. Touch never shows it.
|
|
243
|
+
*/
|
|
244
|
+
function HoverGlide() {
|
|
245
|
+
const ref = React.useRef(null);
|
|
246
|
+
React.useLayoutEffect(() => {
|
|
247
|
+
const fill = ref.current;
|
|
248
|
+
const nav = fill?.parentElement;
|
|
249
|
+
if (!fill || !nav)
|
|
250
|
+
return;
|
|
251
|
+
let row = null;
|
|
252
|
+
let linger = 0;
|
|
253
|
+
let frame = 0;
|
|
254
|
+
const hide = () => {
|
|
255
|
+
clearTimeout(linger);
|
|
256
|
+
linger = 0;
|
|
257
|
+
row = null;
|
|
258
|
+
// Fades out where it is.
|
|
259
|
+
delete fill.dataset.visible;
|
|
260
|
+
};
|
|
261
|
+
const place = () => {
|
|
262
|
+
if (!row)
|
|
263
|
+
return;
|
|
264
|
+
if (!row.isConnected || row.offsetWidth === 0)
|
|
265
|
+
return hide();
|
|
266
|
+
const b = boxIn(nav, row);
|
|
267
|
+
fill.style.translate = `${b.x}px ${b.y}px`;
|
|
268
|
+
fill.style.width = `${b.w}px`;
|
|
269
|
+
fill.style.height = `${b.h}px`;
|
|
270
|
+
};
|
|
271
|
+
const show = (next) => {
|
|
272
|
+
clearTimeout(linger);
|
|
273
|
+
linger = 0;
|
|
274
|
+
if (next === row)
|
|
275
|
+
return;
|
|
276
|
+
row = next;
|
|
277
|
+
if (fill.dataset.visible !== undefined)
|
|
278
|
+
return place();
|
|
279
|
+
// Coming in: jump to the row with no transition, then fade in there.
|
|
280
|
+
fill.dataset.instant = "";
|
|
281
|
+
place();
|
|
282
|
+
void fill.offsetWidth;
|
|
283
|
+
delete fill.dataset.instant;
|
|
284
|
+
fill.dataset.visible = "";
|
|
285
|
+
};
|
|
286
|
+
const over = (event) => {
|
|
287
|
+
if (event.pointerType === "touch")
|
|
288
|
+
return;
|
|
289
|
+
const next = event.target.closest(ROW);
|
|
290
|
+
if (next && nav.contains(next))
|
|
291
|
+
show(next);
|
|
292
|
+
else if (row && !linger)
|
|
293
|
+
linger = window.setTimeout(hide, 120);
|
|
294
|
+
};
|
|
295
|
+
const follow = () => {
|
|
296
|
+
cancelAnimationFrame(frame);
|
|
297
|
+
frame = requestAnimationFrame(place);
|
|
298
|
+
};
|
|
299
|
+
const resize = new ResizeObserver(follow);
|
|
300
|
+
resize.observe(nav);
|
|
301
|
+
nav.addEventListener("pointerover", over);
|
|
302
|
+
nav.addEventListener("pointerleave", hide);
|
|
303
|
+
// A scrolling list carries the row away; the fill goes with it.
|
|
304
|
+
nav.addEventListener("scroll", follow, true);
|
|
305
|
+
return () => {
|
|
306
|
+
clearTimeout(linger);
|
|
307
|
+
cancelAnimationFrame(frame);
|
|
308
|
+
resize.disconnect();
|
|
309
|
+
nav.removeEventListener("pointerover", over);
|
|
310
|
+
nav.removeEventListener("pointerleave", hide);
|
|
311
|
+
nav.removeEventListener("scroll", follow, true);
|
|
312
|
+
};
|
|
313
|
+
}, []);
|
|
314
|
+
return (_jsx("span", { ref: ref, "aria-hidden": true, "data-slot": "sidebar-hover-glide", className: cn("pointer-events-none absolute top-0 left-0 -z-1 rounded-button bg-(--ink-ghost) opacity-0 data-visible:opacity-100", "transition-[translate,width,height,opacity] duration-[calc(var(--duration)*1.4)] ease-brand data-instant:transition-none") }));
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Sidebar — section navigation for docs, settings and dashboards.
|
|
318
|
+
*
|
|
319
|
+
* A `<nav>` of `SidebarGroup`s, each with an eyebrow `SidebarGroupLabel` and 38px
|
|
320
|
+
* `SidebarItem` rows at 12px radius. Rows are flat at rest, only their label brightens on hover
|
|
321
|
+
* (`hover="glide"` adds one soft fill that follows the pointer), and take the raised material when current. The rule people break: marking the current page with a flat fill or
|
|
322
|
+
* a bold weight. Set `current` (it writes `aria-current="page"`) and let the material show it.
|
|
323
|
+
* A sidebar never shows a scrollbar: a long one goes in `<ScrollArea scrollbar={false}>`.
|
|
324
|
+
*
|
|
325
|
+
* Inside a `SidebarProvider` it becomes the app shell's panel: a full-height column divided from
|
|
326
|
+
* the page by a hairline, holding `SidebarHeader`, `SidebarContent` and `SidebarFooter`. It
|
|
327
|
+
* collapses on desktop and turns into a sheet on mobile.
|
|
328
|
+
*/
|
|
329
|
+
export function Sidebar({ side = "left", variant = "sidebar", size = "default", hover = "text", className, children, ...props }) {
|
|
330
|
+
const shell = React.useContext(SidebarContext);
|
|
331
|
+
const text = useMessages("sidebar", defaultMessages);
|
|
332
|
+
const dense = size === "sm";
|
|
333
|
+
// Dense: every control inside (the rows, a search field, a header button) is 30px.
|
|
334
|
+
const sizeClass = dense ? "[--control-h:var(--control-h-sm)]" : undefined;
|
|
335
|
+
const content = (_jsx(SidebarSizeContext.Provider, { value: size, children: _jsxs(SidebarSideContext.Provider, { value: side, children: [hover === "glide" && _jsx(HoverGlide, {}), _jsx(CurrentGlide, {}), children] }) }));
|
|
336
|
+
if (!shell) {
|
|
337
|
+
return (_jsx("nav", { "data-slot": "sidebar", "data-size": size, className: cn("relative isolate flex w-full flex-col", dense ? "gap-5" : "gap-7", sizeClass, className), ...props, children: content }));
|
|
338
|
+
}
|
|
339
|
+
const { state, collapsible, isMobile, openMobile, setOpenMobile } = shell;
|
|
340
|
+
// No fill beside the page: the page ground (the body's grain) runs under the sidebar too.
|
|
341
|
+
// isolate: the gliding current row paints under the rows but over the panel's own fill.
|
|
342
|
+
const panelClass = "isolate flex h-full flex-col font-body text-foreground";
|
|
343
|
+
if (collapsible === "none") {
|
|
344
|
+
return (_jsx("nav", { "data-slot": "sidebar", "data-side": side, "data-variant": variant, "data-size": size, "data-state": "expanded", className: cn(panelClass, sizeClass, "sticky top-0 h-svh max-h-full w-(--sidebar-width) shrink-0 border-border/60", variant !== "sidebar" ? undefined : side === "left" ? "border-e" : "border-s", className), ...props, children: content }));
|
|
345
|
+
}
|
|
346
|
+
if (isMobile) {
|
|
347
|
+
return (_jsx(Drawer, { side: side, open: openMobile, onOpenChange: setOpenMobile, children: _jsx(DrawerContent, { "data-slot": "sidebar-sheet", className: cn("w-[min(18rem,calc(100vw-3rem))] **:data-[slot=drawer-body]:gap-0 **:data-[slot=drawer-body]:p-0"), children: _jsxs(SidebarSurfaceContext.Provider, { value: "sheet", children: [_jsx(DrawerTitle, { className: "sr-only", children: props["aria-label"] ?? text.navigation }), _jsx("nav", { "data-slot": "sidebar", "data-side": side, "data-size": size, className: cn(panelClass, "relative min-h-0 flex-1 bg-background", sizeClass, className), ...props, children: content })] }) }) }));
|
|
348
|
+
}
|
|
349
|
+
const offcanvas = state === "collapsed" && collapsible === "offcanvas";
|
|
350
|
+
return (_jsx("div", { "data-slot": "sidebar-shell", "data-variant": variant, "data-size": size, style: dense
|
|
351
|
+
? { "--sidebar-width-icon": "calc(var(--control-h-sm) + 25px)" }
|
|
352
|
+
: undefined, "data-state": state, "data-collapsible": state === "collapsed" ? collapsible : undefined, "data-side": side, className: cn("group/sidebar sticky top-0 hidden h-svh max-h-full w-(--sidebar-width) shrink-0 overflow-clip md:block", "transition-[width] duration-(--duration) ease-brand", "data-[collapsible=icon]:w-(--sidebar-width-icon) data-[collapsible=offcanvas]:w-0"), children: _jsx("nav", { "data-slot": "sidebar", "data-side": side, "data-size": size, inert: offcanvas || undefined, className: cn(panelClass, sizeClass, "absolute inset-y-0 w-(--sidebar-width) border-border/60 transition-[width] duration-(--duration) ease-brand", "group-data-[collapsible=icon]/sidebar:w-(--sidebar-width-icon)", side === "left" ? "start-0" : "end-0", variant !== "sidebar" ? undefined : side === "left" ? "border-e" : "border-s", className), ...props, children: content }) }));
|
|
353
|
+
}
|
|
354
|
+
/** The top of an app-shell sidebar: a logo, a workspace switcher, a search row. Never scrolls. */
|
|
355
|
+
export function SidebarHeader({ className, ...props }) {
|
|
356
|
+
const dense = React.useContext(SidebarSizeContext) === "sm";
|
|
357
|
+
return (_jsx("div", { "data-slot": "sidebar-header", className: cn("flex shrink-0 flex-col px-3", dense ? "gap-1.5 pt-3 pb-1.5" : "gap-2 pt-4 pb-2", className), ...props }));
|
|
358
|
+
}
|
|
359
|
+
/** The bottom of an app-shell sidebar: the account, settings, help. Never scrolls. */
|
|
360
|
+
export function SidebarFooter({ className, ...props }) {
|
|
361
|
+
const dense = React.useContext(SidebarSizeContext) === "sm";
|
|
362
|
+
return (_jsx("div", { "data-slot": "sidebar-footer", className: cn("mt-auto flex shrink-0 flex-col px-3", dense ? "gap-1.5 pt-1.5 pb-3" : "gap-2 pt-2 pb-4", className), ...props }));
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* The scrolling middle of an app-shell sidebar, holding the `SidebarGroup`s 28px apart. It is a
|
|
366
|
+
* `ScrollArea` with `scrollbar={false}`: it scrolls, never shows a bar, and fades at the edges.
|
|
367
|
+
*/
|
|
368
|
+
export function SidebarContent({ className, contentClassName, ...props }) {
|
|
369
|
+
const dense = React.useContext(SidebarSizeContext) === "sm";
|
|
370
|
+
return (_jsx(ScrollArea, { "data-slot": "sidebar-content", scrollbar: false, className: cn("min-h-0 flex-1", className), contentClassName: cn("flex flex-col px-3", dense ? "gap-5 py-2" : "gap-7 py-3", contentClassName), ...props }));
|
|
371
|
+
}
|
|
372
|
+
/** A hairline between the header, content and footer, inset 12px to line up with the rows. Inside `SidebarContent` pass `mx-0`. */
|
|
373
|
+
export function SidebarSeparator({ className, ...props }) {
|
|
374
|
+
return (_jsx(Separator, { "data-slot": "sidebar-separator", className: cn("mx-3 my-1 data-[orientation=horizontal]:w-auto", className), ...props }));
|
|
375
|
+
}
|
|
376
|
+
/* ── Groups and rows ───────────────────────────────────────────────────────── */
|
|
377
|
+
/** A labelled group of rows. Pair it with a `SidebarGroupLabel`. */
|
|
378
|
+
export function SidebarGroup({ className, ...props }) {
|
|
379
|
+
return _jsx("div", { "data-slot": "sidebar-group", className: cn("flex flex-col gap-0.5", className), ...props });
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* The eyebrow above a group: 12px mono, uppercase, 0.18em tracking. In the icon rail it fades
|
|
383
|
+
* and folds away with the panel's width (a negative margin of its own fixed height), so the rows
|
|
384
|
+
* glide up instead of jumping; screen readers still hear it.
|
|
385
|
+
*/
|
|
386
|
+
export function SidebarGroupLabel({ className, ...props }) {
|
|
387
|
+
const dense = React.useContext(SidebarSizeContext) === "sm";
|
|
388
|
+
return (_jsx("div", { "data-slot": "sidebar-group-label", className: cn("overflow-hidden eyebrow whitespace-nowrap transition-[margin,opacity] duration-(--duration) ease-brand", "group-data-[collapsible=icon]/sidebar:pointer-events-none group-data-[collapsible=icon]/sidebar:opacity-0",
|
|
389
|
+
// Fixed heights (line + padding) so the fold is exact: 16 + 8 = 24px, dense 14 + 6 = 20px.
|
|
390
|
+
dense
|
|
391
|
+
? "px-2.5 pb-1.5 text-[11px] leading-[14px] group-data-[collapsible=icon]/sidebar:-mt-5"
|
|
392
|
+
: "px-3 pb-2 leading-4 group-data-[collapsible=icon]/sidebar:-mt-6", className), ...props }));
|
|
393
|
+
}
|
|
394
|
+
function textOf(node) {
|
|
395
|
+
if (typeof node === "string" || typeof node === "number")
|
|
396
|
+
return String(node);
|
|
397
|
+
if (Array.isArray(node))
|
|
398
|
+
return node.map(textOf).join("");
|
|
399
|
+
return "";
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* One navigation row. Renders an `<a>`; pass `render={<Link to="…" />}` for router links.
|
|
403
|
+
* Leading icons are 16px; a trailing `Kbd`, `Tag` or `SidebarMenuBadge` is pushed to the end
|
|
404
|
+
* with `ms-auto`. In an icon-collapsed app shell it shrinks to a 38px square with a tooltip.
|
|
405
|
+
*/
|
|
406
|
+
export function SidebarItem({ current, tooltip, render, ref, className, children, onClick, ...props }) {
|
|
407
|
+
const shell = React.useContext(SidebarContext);
|
|
408
|
+
const side = React.useContext(SidebarSideContext);
|
|
409
|
+
const surface = React.useContext(SidebarSurfaceContext);
|
|
410
|
+
const dense = React.useContext(SidebarSizeContext) === "sm";
|
|
411
|
+
const inShell = shell !== null;
|
|
412
|
+
const element = useRender({
|
|
413
|
+
defaultTagName: "a",
|
|
414
|
+
render,
|
|
415
|
+
ref,
|
|
416
|
+
props: {
|
|
417
|
+
"data-slot": "sidebar-item",
|
|
418
|
+
"aria-current": current ? "page" : undefined,
|
|
419
|
+
...props,
|
|
420
|
+
onClick: (event) => {
|
|
421
|
+
onClick?.(event);
|
|
422
|
+
// A link chosen in the mobile sheet closes it — also when its handler prevented the
|
|
423
|
+
// default to route on the client. Another row (a button that opens a menu) keeps the
|
|
424
|
+
// sheet open by preventing the default.
|
|
425
|
+
const link = event.currentTarget instanceof HTMLAnchorElement && event.currentTarget.hasAttribute("href");
|
|
426
|
+
if ((link || !event.defaultPrevented) && surface === "sheet" && shell)
|
|
427
|
+
shell.setOpenMobile(false);
|
|
428
|
+
},
|
|
429
|
+
className: cn(
|
|
430
|
+
// cursor-pointer: rows may render as a <button> (theme switch, account menu), which has no pointer by default.
|
|
431
|
+
"flex min-h-(--control-h) w-full cursor-pointer items-center rounded-button material-row font-body leading-none no-underline focus-ring select-none", dense ? "gap-2 px-2.5 text-[13px]" : "gap-2.5 px-3 text-sm", "aria-disabled:pointer-events-none aria-disabled:opacity-50",
|
|
432
|
+
// Hover is quieter than current: the label brightens (over the gliding fill with hover="glide"),
|
|
433
|
+
// the row itself takes no fill, edge or shadow. The raised row means "you are here".
|
|
434
|
+
"hover:not-aria-[current=page]:bg-transparent! hover:not-aria-[current=page]:bg-none! hover:not-aria-[current=page]:shadow-none!",
|
|
435
|
+
// A row rests in the muted ink, so the hovered one stands out in full: black, or white in dark mode.
|
|
436
|
+
"not-aria-[current=page]:text-muted-foreground hover:not-aria-[current=page]:text-foreground",
|
|
437
|
+
// While the current row glides (CurrentGlide), the old and new rows stay flat.
|
|
438
|
+
"data-glide:transition-none! data-[glide=hidden]:bg-transparent! data-[glide=hidden]:bg-none! data-[glide=hidden]:shadow-none!", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", inShell && "overflow-hidden whitespace-nowrap", inShell &&
|
|
439
|
+
// A square in the icon rail with the 16px icon centred: (row - icon - border) / 2 a side.
|
|
440
|
+
"group-data-[collapsible=icon]/sidebar:size-(--control-h) group-data-[collapsible=icon]/sidebar:px-[calc((var(--control-h)-18px)/2)]", className),
|
|
441
|
+
children,
|
|
442
|
+
},
|
|
443
|
+
});
|
|
444
|
+
if (!shell || tooltip === false)
|
|
445
|
+
return element;
|
|
446
|
+
const iconRail = !shell.isMobile && shell.state === "collapsed" && shell.collapsible === "icon";
|
|
447
|
+
const label = tooltip ?? textOf(children);
|
|
448
|
+
if (!label)
|
|
449
|
+
return element;
|
|
450
|
+
return (_jsxs(Tooltip, { disabled: !iconRail, children: [_jsx(TooltipTrigger, { render: element }), _jsx(TooltipContent, { side: side === "left" ? "inline-end" : "inline-start", align: "center", sideOffset: 10, children: label })] }));
|
|
451
|
+
}
|
|
452
|
+
/** A count at the end of a row ("12"): mono, tabular, muted. Hidden in the icon rail. */
|
|
453
|
+
export function SidebarMenuBadge({ className, ...props }) {
|
|
454
|
+
return (_jsx("span", { "data-slot": "sidebar-menu-badge", className: cn("ms-auto ps-2 font-mono text-xs leading-none text-muted-foreground tabular-nums group-data-[collapsible=icon]/sidebar:hidden", className), ...props }));
|
|
455
|
+
}
|
|
456
|
+
/* ── Controls ──────────────────────────────────────────────────────────────── */
|
|
457
|
+
/**
|
|
458
|
+
* The button that opens and closes the sidebar: a circular ghost icon button, usually first in
|
|
459
|
+
* the inset's toolbar. On mobile it opens the sheet. Shows the ⌘B / Ctrl+B shortcut's action.
|
|
460
|
+
*/
|
|
461
|
+
export function SidebarTrigger({ variant = "ghost", size = "icon", className, children, onClick, ...props }) {
|
|
462
|
+
const { toggleSidebar, isMobile, open, openMobile } = useSidebar();
|
|
463
|
+
const text = useMessages("sidebar", defaultMessages);
|
|
464
|
+
return (_jsx(Button, { "data-slot": "sidebar-trigger", variant: variant, size: size, "aria-label": text.toggle, "aria-expanded": isMobile ? openMobile : open, className: cn("text-muted-foreground",
|
|
465
|
+
// The circle pads its glyph by ~10px; pull what follows in, and give a separator after
|
|
466
|
+
// it a little more room, so the gaps either side of the separator read the same.
|
|
467
|
+
size === "icon" && "-me-1.5 [&+[data-slot=separator]]:me-1", size === "icon-sm" && "-me-1 [&+[data-slot=separator]]:me-0.75", className), onClick: (event) => {
|
|
468
|
+
onClick?.(event);
|
|
469
|
+
if (!event.defaultPrevented)
|
|
470
|
+
toggleSidebar();
|
|
471
|
+
}, ...props, children: children ?? _jsx(PanelLeftIcon, { "aria-hidden": true, className: "rtl:-scale-x-100" }) }));
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* A thin strip along the sidebar's inner edge: hover shows the hairline in `--control-focus`,
|
|
475
|
+
* click toggles the sidebar. A pointer convenience — keyboard users have the trigger and ⌘B.
|
|
476
|
+
*/
|
|
477
|
+
export function SidebarRail({ className, onClick, ...props }) {
|
|
478
|
+
const { toggleSidebar, state, isMobile, collapsible } = useSidebar();
|
|
479
|
+
const surface = React.useContext(SidebarSurfaceContext);
|
|
480
|
+
const text = useMessages("sidebar", defaultMessages);
|
|
481
|
+
if (isMobile || surface === "sheet" || collapsible === "none")
|
|
482
|
+
return null;
|
|
483
|
+
return (_jsx("button", { type: "button", "data-slot": "sidebar-rail", "aria-label": text.toggle, title: text.toggle, tabIndex: -1, onClick: (event) => {
|
|
484
|
+
onClick?.(event);
|
|
485
|
+
if (!event.defaultPrevented)
|
|
486
|
+
toggleSidebar();
|
|
487
|
+
}, className: cn("absolute inset-y-0 z-20 w-2 border-0 bg-transparent p-0 outline-none", "after:absolute after:inset-y-0 after:w-px after:bg-transparent after:transition-[background-color] after:duration-(--duration) after:ease-brand after:content-[''] hover:after:bg-control-focus",
|
|
488
|
+
// On the edge next to the page: the end of a start sidebar, in either direction.
|
|
489
|
+
"group-data-[side=left]/sidebar:end-0 group-data-[side=right]/sidebar:start-0 group-data-[side=left]/sidebar:after:-end-px group-data-[side=right]/sidebar:after:-start-px",
|
|
490
|
+
// The cursor points the way the panel will go: towards its edge to close, away to open.
|
|
491
|
+
state === "expanded"
|
|
492
|
+
? "group-data-[side=left]/sidebar:cursor-w-resize group-data-[side=right]/sidebar:cursor-e-resize rtl:group-data-[side=left]/sidebar:cursor-e-resize rtl:group-data-[side=right]/sidebar:cursor-w-resize"
|
|
493
|
+
: "group-data-[side=left]/sidebar:cursor-e-resize group-data-[side=right]/sidebar:cursor-w-resize rtl:group-data-[side=left]/sidebar:cursor-w-resize rtl:group-data-[side=right]/sidebar:cursor-e-resize", className), ...props }));
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* The main area beside an app-shell sidebar: a `<main>` column that takes the remaining width.
|
|
497
|
+
* Put a toolbar row (with `SidebarTrigger`) first, then the page. Beside a `variant="inset"`
|
|
498
|
+
* sidebar it becomes a raised 20px panel with an 8px margin (styles in parts/navigation.css).
|
|
499
|
+
* Otherwise it has no fill of its own: the page ground shows through.
|
|
500
|
+
*/
|
|
501
|
+
export function SidebarInset({ className, ...props }) {
|
|
502
|
+
return (_jsx("main", { "data-slot": "sidebar-inset",
|
|
503
|
+
// Clear of a BottomNav on a phone: --bottom-nav-h is 0 wherever no bar is shown.
|
|
504
|
+
className: cn("relative flex min-w-0 flex-1 flex-col pb-(--bottom-nav-h)", className), ...props }));
|
|
505
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface SiteHeaderMessages {
|
|
3
|
+
/** The name of the links' `nav` landmark. */
|
|
4
|
+
nav: string;
|
|
5
|
+
/** The phone menu button. */
|
|
6
|
+
openMenu: string;
|
|
7
|
+
/** The phone panel's close button. */
|
|
8
|
+
closeMenu: string;
|
|
9
|
+
/** The phone panel's title. */
|
|
10
|
+
menu: string;
|
|
11
|
+
}
|
|
12
|
+
declare module "./locale" {
|
|
13
|
+
interface Messages {
|
|
14
|
+
siteHeader: SiteHeaderMessages;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** A page inside a `SiteHeaderLink`'s dropdown panel. */
|
|
18
|
+
export interface SiteHeaderLinkItem {
|
|
19
|
+
label: React.ReactNode;
|
|
20
|
+
/** Where the page is. */
|
|
21
|
+
href: string;
|
|
22
|
+
/** One short line under the label in the panel. */
|
|
23
|
+
description?: React.ReactNode;
|
|
24
|
+
/** Marks the current page (`aria-current="page"`). */
|
|
25
|
+
current?: boolean;
|
|
26
|
+
/** A router link element, e.g. `<Link to="/pricing" />`, for client-side navigation. */
|
|
27
|
+
render?: React.ReactElement;
|
|
28
|
+
}
|
|
29
|
+
/** One top-level entry: a link (`href`), or a dropdown panel of pages (`items`). */
|
|
30
|
+
export interface SiteHeaderLink {
|
|
31
|
+
label: React.ReactNode;
|
|
32
|
+
/** Where the entry goes. Required unless the entry opens a panel of `items`. */
|
|
33
|
+
href?: string;
|
|
34
|
+
/** Marks the current page (`aria-current="page"`). */
|
|
35
|
+
current?: boolean;
|
|
36
|
+
/** Pages shown in a `NavigationMenu` panel. The entry becomes a trigger instead of a link. */
|
|
37
|
+
items?: SiteHeaderLinkItem[];
|
|
38
|
+
/** A router link element, e.g. `<Link to="/pricing" />`, for client-side navigation. */
|
|
39
|
+
render?: React.ReactElement;
|
|
40
|
+
}
|
|
41
|
+
export interface SiteHeaderProps extends Omit<React.ComponentProps<"header">, "children"> {
|
|
42
|
+
/** The lockup at the start: left, or right on a right-to-left page. Link it to the home page yourself. */
|
|
43
|
+
logo: React.ReactNode;
|
|
44
|
+
/** Primary navigation, in order, about five links: e.g. "Product", "Docs", "Pricing", "Blog", "About". */
|
|
45
|
+
links: SiteHeaderLink[];
|
|
46
|
+
/** The slot at the end: locale switch, theme toggle, one CTA at most. */
|
|
47
|
+
actions?: React.ReactNode;
|
|
48
|
+
/**
|
|
49
|
+
* Where the links sit. `end` (default): with the actions at the end of the bar, after a hairline
|
|
50
|
+
* divider. `start`: right after the logo, with the actions on their own at the end — for an app
|
|
51
|
+
* whose bar reads logo, sections, then search and account.
|
|
52
|
+
*/
|
|
53
|
+
align?: "start" | "end";
|
|
54
|
+
/**
|
|
55
|
+
* Force the scrolled treatment (the page ground and a hairline), e.g. for a page that scrolls
|
|
56
|
+
* in a container of its own. By default it comes in as the window scrolls past
|
|
57
|
+
* `scrollThreshold`, over the bar's own height.
|
|
58
|
+
*/
|
|
59
|
+
scrolled?: boolean;
|
|
60
|
+
/** Pixels of scroll before the ground starts to come in. Defaults to 8. */
|
|
61
|
+
scrollThreshold?: number;
|
|
62
|
+
/** Accessible name of the `<nav>`. Defaults to "Main", or `messages.siteHeader.nav`. */
|
|
63
|
+
navLabel?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Accessible names for the mobile menu buttons. Default `messages.siteHeader` `openMenu`,
|
|
66
|
+
* `closeMenu` and `menu`.
|
|
67
|
+
*/
|
|
68
|
+
menuLabels?: {
|
|
69
|
+
open?: string;
|
|
70
|
+
close?: string;
|
|
71
|
+
title?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* The phone menu: below 48rem of header the links fold into a menu button that opens a full
|
|
75
|
+
* panel. `false` leaves it out, for an app with navigation of its own on phones (a bottom tab
|
|
76
|
+
* bar): the links show from 48rem up, and the actions stay in the bar at every width.
|
|
77
|
+
* Default `true`.
|
|
78
|
+
*/
|
|
79
|
+
menu?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* SiteHeader — the sticky top bar of an zon site, composed from `NavigationMenu`.
|
|
83
|
+
*
|
|
84
|
+
* `NavigationMenu` is the primitive (links, triggers, the shared dropdown popup); SiteHeader
|
|
85
|
+
* is the pattern around it: logo at the start; the menu, a hairline divider and an actions slot at
|
|
86
|
+
* the end (or the menu beside the logo, with `align="start"`); transparent at the top of the page,
|
|
87
|
+
* and once it scrolls the page ground itself (its colour, grain and faint light, lined up with the
|
|
88
|
+
* page's) fading in over a hairline, so content passes under the bar rather than through a band of
|
|
89
|
+
* another colour; and below 48rem of bar a full-height panel opened by a menu button. Give an
|
|
90
|
+
* entry `items` and it opens a dropdown panel. The rule people break: filling the bar with
|
|
91
|
+
* buttons. One CTA at most — the links are the navigation, the actions slot is for locale and theme.
|
|
92
|
+
*/
|
|
93
|
+
export declare function SiteHeader({ logo, links, actions, align, scrolled: scrolledProp, scrollThreshold, navLabel: navLabelProp, menuLabels, menu, className, style, dir, ...props }: SiteHeaderProps): React.JSX.Element;
|