@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,121 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Dialog as BaseDialog } from "@base-ui/react/dialog";
|
|
4
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
5
|
+
import { MenuIcon, XIcon } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { cn } from "../lib/cn.js";
|
|
8
|
+
import { usePopupDir } from "./_overlay.js";
|
|
9
|
+
import { Button } from "./button.js";
|
|
10
|
+
import { useMessages } from "./locale.js";
|
|
11
|
+
import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, } from "./navigation-menu.js";
|
|
12
|
+
const defaultMessages = {
|
|
13
|
+
nav: "Main",
|
|
14
|
+
openMenu: "Open menu",
|
|
15
|
+
closeMenu: "Close menu",
|
|
16
|
+
menu: "Menu",
|
|
17
|
+
};
|
|
18
|
+
/** A link in the mobile panel: a plain `<a>`, or the entry's router link through `render`. */
|
|
19
|
+
function PanelLink({ render, href, ...props }) {
|
|
20
|
+
return useRender({
|
|
21
|
+
defaultTagName: "a",
|
|
22
|
+
render,
|
|
23
|
+
props: { ...props, href: render ? undefined : href },
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether the window has scrolled past `threshold`, and the scrolled ground with it: 0 until
|
|
28
|
+
* `threshold`, then up to 1 over the bar's own height. Where the browser ties animations to the
|
|
29
|
+
* scroll, the stylesheet draws it from the scroll position itself (navigation.css), in the same
|
|
30
|
+
* frame the page moves; this measures the bar's height for it (`--site-header-span`). Elsewhere it
|
|
31
|
+
* writes the ground as `--site-header-ground`, once a frame. Tied to the scroll, the bar is solid
|
|
32
|
+
* by the time content a bar's height down reaches it, however fast the page moves.
|
|
33
|
+
*/
|
|
34
|
+
function useScrollGround(ref, threshold, forced) {
|
|
35
|
+
const [scrolled, setScrolled] = React.useState(false);
|
|
36
|
+
React.useEffect(() => {
|
|
37
|
+
const header = ref.current;
|
|
38
|
+
if (forced !== undefined || !header)
|
|
39
|
+
return;
|
|
40
|
+
const linked = typeof CSS !== "undefined" && CSS.supports("animation-timeline: scroll()");
|
|
41
|
+
let frame = 0;
|
|
42
|
+
let span = 0;
|
|
43
|
+
const update = () => {
|
|
44
|
+
frame = 0;
|
|
45
|
+
const y = window.scrollY;
|
|
46
|
+
// Written only when it changes: a style change while the page scrolls makes work for the
|
|
47
|
+
// browser in the very frames the bar has to keep up in.
|
|
48
|
+
const height = Math.max(header.offsetHeight, 1);
|
|
49
|
+
if (height !== span)
|
|
50
|
+
header.style.setProperty("--site-header-span", `${(span = height)}px`);
|
|
51
|
+
if (!linked)
|
|
52
|
+
header.style.setProperty("--site-header-ground", String(Math.min(1, Math.max(0, (y - threshold) / span))));
|
|
53
|
+
setScrolled(y > threshold);
|
|
54
|
+
};
|
|
55
|
+
const schedule = () => {
|
|
56
|
+
frame ||= requestAnimationFrame(update);
|
|
57
|
+
};
|
|
58
|
+
update();
|
|
59
|
+
window.addEventListener("scroll", schedule, { passive: true });
|
|
60
|
+
window.addEventListener("resize", schedule, { passive: true });
|
|
61
|
+
return () => {
|
|
62
|
+
cancelAnimationFrame(frame);
|
|
63
|
+
window.removeEventListener("scroll", schedule);
|
|
64
|
+
window.removeEventListener("resize", schedule);
|
|
65
|
+
header.style.removeProperty("--site-header-span");
|
|
66
|
+
header.style.removeProperty("--site-header-ground");
|
|
67
|
+
};
|
|
68
|
+
}, [ref, threshold, forced]);
|
|
69
|
+
return forced ?? scrolled;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* SiteHeader — the sticky top bar of an zon site, composed from `NavigationMenu`.
|
|
73
|
+
*
|
|
74
|
+
* `NavigationMenu` is the primitive (links, triggers, the shared dropdown popup); SiteHeader
|
|
75
|
+
* is the pattern around it: logo at the start; the menu, a hairline divider and an actions slot at
|
|
76
|
+
* the end (or the menu beside the logo, with `align="start"`); transparent at the top of the page,
|
|
77
|
+
* and once it scrolls the page ground itself (its colour, grain and faint light, lined up with the
|
|
78
|
+
* page's) fading in over a hairline, so content passes under the bar rather than through a band of
|
|
79
|
+
* another colour; and below 48rem of bar a full-height panel opened by a menu button. Give an
|
|
80
|
+
* entry `items` and it opens a dropdown panel. The rule people break: filling the bar with
|
|
81
|
+
* buttons. One CTA at most — the links are the navigation, the actions slot is for locale and theme.
|
|
82
|
+
*/
|
|
83
|
+
export function SiteHeader({ logo, links, actions, align = "end", scrolled: scrolledProp, scrollThreshold = 8, navLabel: navLabelProp, menuLabels, menu = true, className, style, dir, ...props }) {
|
|
84
|
+
const text = useMessages("siteHeader", defaultMessages);
|
|
85
|
+
const navLabel = navLabelProp ?? text.nav;
|
|
86
|
+
const headerRef = React.useRef(null);
|
|
87
|
+
const menuButtonRef = React.useRef(null);
|
|
88
|
+
const scrolled = useScrollGround(headerRef, scrollThreshold, scrolledProp);
|
|
89
|
+
const [open, setOpen] = React.useState(false);
|
|
90
|
+
// The phone panel is portalled out of the page: it takes the header's direction itself.
|
|
91
|
+
const panelDir = usePopupDir(dir);
|
|
92
|
+
// The header switches by its own width, not the window's: a container query hides the menu
|
|
93
|
+
// button from 48rem of header up. Close the panel once the header grows past that and the
|
|
94
|
+
// button is gone.
|
|
95
|
+
React.useEffect(() => {
|
|
96
|
+
const header = headerRef.current;
|
|
97
|
+
if (!open || !header || typeof ResizeObserver === "undefined")
|
|
98
|
+
return;
|
|
99
|
+
const observer = new ResizeObserver(() => {
|
|
100
|
+
const button = menuButtonRef.current;
|
|
101
|
+
if (button && getComputedStyle(button).display === "none")
|
|
102
|
+
setOpen(false);
|
|
103
|
+
});
|
|
104
|
+
observer.observe(header);
|
|
105
|
+
return () => observer.disconnect();
|
|
106
|
+
}, [open]);
|
|
107
|
+
const nav = (_jsx(NavigationMenu, { "aria-label": navLabel,
|
|
108
|
+
// Beside the logo, or without the phone menu, the links leave the bar below 48rem of it.
|
|
109
|
+
className: cn((align === "start" || !menu) && "hidden @3xl/site-header:block"), children: _jsx(NavigationMenuList, { children: links.map((link, i) => (_jsx(NavigationMenuItem, { children: link.items?.length ? (_jsxs(_Fragment, { children: [_jsx(NavigationMenuTrigger, { children: link.label }), _jsx(NavigationMenuContent, { children: _jsx("ul", { className: "m-0 grid list-none gap-1 p-0 sm:w-[400px]", children: link.items.map((item, j) => (_jsx("li", { children: _jsxs(NavigationMenuLink, { variant: "row", href: item.render ? undefined : item.href, render: item.render, active: item.current, children: [item.label, item.description != null && _jsx("small", { children: item.description })] }) }, j))) }) })] })) : (_jsx(NavigationMenuLink, { href: link.render ? undefined : link.href, render: link.render, active: link.current, children: link.label })) }, i))) }) }));
|
|
110
|
+
const actionsSlot = actions != null && (_jsx("div", { "data-slot": "site-header-actions", className: "flex items-center gap-2", children: actions }));
|
|
111
|
+
return (_jsxs("header", { ref: headerRef, "data-slot": "site-header", "data-scrolled": scrolled ? "" : undefined, "data-forced": scrolledProp === undefined ? undefined : "", dir: dir,
|
|
112
|
+
// The ground and its hairline are drawn in navigation.css, from --site-header-ground.
|
|
113
|
+
className: cn("@container/site-header sticky top-0 z-40 w-full border-b", className), style: {
|
|
114
|
+
...style,
|
|
115
|
+
"--site-header-from": `${scrollThreshold}px`,
|
|
116
|
+
...(scrolledProp !== undefined && { "--site-header-ground": scrolledProp ? 1 : 0 }),
|
|
117
|
+
}, ...props, children: [_jsx("span", { "aria-hidden": true, "data-slot": "site-header-ground" }), _jsxs("div", { className: cn("container-page flex min-h-16 items-center", align === "start" ? "gap-8" : "justify-between gap-6"), children: [_jsx("div", { "data-slot": "site-header-logo", className: "flex shrink-0 items-center", children: logo }), align === "start" ? (_jsxs(_Fragment, { children: [nav, actionsSlot && (_jsx("div", { className: cn("ms-auto items-center", menu ? "hidden @3xl/site-header:flex" : "flex"), children: actionsSlot }))] })) : (_jsxs("div", { className: cn("items-center gap-4", menu ? "hidden @3xl/site-header:flex" : "flex"), children: [nav, actionsSlot && (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": true, className: cn("h-5 w-px bg-border", !menu && "hidden @3xl/site-header:block") }), actionsSlot] }))] })), menu && (_jsxs(BaseDialog.Root, { open: open, onOpenChange: setOpen, children: [_jsx(BaseDialog.Trigger, { ref: menuButtonRef, render: _jsx(Button, { variant: "ghost", size: "icon", className: cn("@3xl/site-header:hidden", align === "start" && "ms-auto") }), "aria-label": menuLabels?.open ?? text.openMenu, children: _jsx(MenuIcon, {}) }), _jsx(BaseDialog.Portal, { children: _jsxs(BaseDialog.Popup, { "data-slot": "site-header-panel", dir: panelDir, className: cn("fixed inset-0 z-50 flex flex-col overflow-y-auto bg-background text-foreground outline-none", "pt-[env(safe-area-inset-top,0px)] pb-[env(safe-area-inset-bottom,0px)]", "transition-[opacity,translate] duration-(--duration) ease-(--ease)", "data-ending-style:-translate-y-2 data-ending-style:opacity-0 data-starting-style:-translate-y-2 data-starting-style:opacity-0"), children: [_jsx(BaseDialog.Title, { className: "sr-only", children: menuLabels?.title ?? text.menu }), _jsxs("div", { className: "container-page flex min-h-16 items-center justify-between gap-6 border-b border-border/60", children: [_jsx("div", { className: "flex shrink-0 items-center", children: logo }), _jsx(BaseDialog.Close, { render: _jsx(Button, { variant: "ghost", size: "icon" }), "aria-label": menuLabels?.close ?? text.closeMenu, children: _jsx(XIcon, {}) })] }), _jsx("nav", { "aria-label": navLabel, className: "container-page flex-1", children: _jsx("ul", { className: "m-0 list-none p-0", children: links.map((link, i) => {
|
|
118
|
+
const index = (_jsx("span", { className: "w-6 shrink-0 font-mono text-[12px] text-muted-foreground tabular-nums", children: String(i + 1).padStart(2, "0") }));
|
|
119
|
+
return (_jsxs("li", { className: "border-b border-border/60", children: [link.href != null || link.render != null ? (_jsxs(PanelLink, { render: link.render, href: link.href, "aria-current": link.current ? "page" : undefined, onClick: () => setOpen(false), className: "flex items-baseline gap-5 py-5 text-foreground no-underline focus-ring", children: [index, _jsx("span", { className: "display text-[32px]", children: link.label })] })) : (_jsxs("div", { className: "flex items-baseline gap-5 pt-5 pb-2 text-foreground", children: [index, _jsx("span", { className: "display text-[32px]", children: link.label })] })), link.items?.length ? (_jsx("ul", { className: "m-0 -mt-1 list-none ps-11 pb-4", children: link.items.map((item, j) => (_jsx("li", { children: _jsx(PanelLink, { render: item.render, href: item.href, "aria-current": item.current ? "page" : undefined, onClick: () => setOpen(false), className: "flex min-h-(--control-h) items-center text-[17px] text-foreground-soft no-underline focus-ring aria-[current=page]:text-foreground", children: item.label }) }, j))) })) : null] }, i));
|
|
120
|
+
}) }) }), actions != null && (_jsx("div", { className: "container-page flex items-center gap-3 py-6", children: actions }))] }) })] }))] })] }));
|
|
121
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
declare const skeletonShapes: {
|
|
3
|
+
/** A line of text: square ends, 1em tall by default. Set the width per line. */
|
|
4
|
+
readonly text: "h-[1em] rounded-none";
|
|
5
|
+
/** Stands in for an input, select trigger or textarea: 10px corners, 38px tall. */
|
|
6
|
+
readonly field: "min-h-(--control-h) w-full rounded-control";
|
|
7
|
+
/** Stands in for a button: 12px corners, 38px tall. */
|
|
8
|
+
readonly button: "min-h-(--control-h) w-28 rounded-button";
|
|
9
|
+
/** Stands in for a tag, a menu item or a thumbnail: 7px corners. */
|
|
10
|
+
readonly item: "rounded-item";
|
|
11
|
+
/** Stands in for an avatar or an icon button. Set the size. */
|
|
12
|
+
readonly circle: "aspect-square rounded-full";
|
|
13
|
+
/** Stands in for a whole card: 20px corners. */
|
|
14
|
+
readonly card: "rounded-card";
|
|
15
|
+
};
|
|
16
|
+
export type SkeletonShape = keyof typeof skeletonShapes;
|
|
17
|
+
export interface SkeletonProps extends React.ComponentProps<"div"> {
|
|
18
|
+
/** Match the radius (and default height) of what the skeleton stands in for. */
|
|
19
|
+
shape?: SkeletonShape;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Skeleton — a placeholder in `--control-surface` that holds the place of content while it
|
|
23
|
+
* loads, with one soft highlight sweeping across it every 1.6s (static under reduced motion).
|
|
24
|
+
*
|
|
25
|
+
* The radius follows what it stands in for: `text` lines are square, `field` is 10px, `button`
|
|
26
|
+
* is 12px, `circle` is round, `card` is 20px. Skeletons are `aria-hidden`; announce loading on
|
|
27
|
+
* the container (`aria-busy`) instead. The rule people break: skeletons that do not match the
|
|
28
|
+
* real layout, so the page jumps when the content arrives.
|
|
29
|
+
*/
|
|
30
|
+
export declare function Skeleton({ shape, className, ...props }: SkeletonProps): React.JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
const skeletonShapes = {
|
|
5
|
+
/** A line of text: square ends, 1em tall by default. Set the width per line. */
|
|
6
|
+
text: "h-[1em] rounded-none",
|
|
7
|
+
/** Stands in for an input, select trigger or textarea: 10px corners, 38px tall. */
|
|
8
|
+
field: "min-h-(--control-h) w-full rounded-control",
|
|
9
|
+
/** Stands in for a button: 12px corners, 38px tall. */
|
|
10
|
+
button: "min-h-(--control-h) w-28 rounded-button",
|
|
11
|
+
/** Stands in for a tag, a menu item or a thumbnail: 7px corners. */
|
|
12
|
+
item: "rounded-item",
|
|
13
|
+
/** Stands in for an avatar or an icon button. Set the size. */
|
|
14
|
+
circle: "aspect-square rounded-full",
|
|
15
|
+
/** Stands in for a whole card: 20px corners. */
|
|
16
|
+
card: "rounded-card",
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Skeleton — a placeholder in `--control-surface` that holds the place of content while it
|
|
20
|
+
* loads, with one soft highlight sweeping across it every 1.6s (static under reduced motion).
|
|
21
|
+
*
|
|
22
|
+
* The radius follows what it stands in for: `text` lines are square, `field` is 10px, `button`
|
|
23
|
+
* is 12px, `circle` is round, `card` is 20px. Skeletons are `aria-hidden`; announce loading on
|
|
24
|
+
* the container (`aria-busy`) instead. The rule people break: skeletons that do not match the
|
|
25
|
+
* real layout, so the page jumps when the content arrives.
|
|
26
|
+
*/
|
|
27
|
+
export function Skeleton({ shape = "text", className, ...props }) {
|
|
28
|
+
return (_jsx("div", { "aria-hidden": true, "data-slot": "skeleton", "data-shape": shape, className: cn("block shrink-0", skeletonShapes[shape], className), ...props }));
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Slider as BaseSlider } from "@base-ui/react/slider";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export interface SliderProps<Value extends number | readonly number[] = number | readonly number[]> extends BaseSlider.Root.Props<Value> {
|
|
4
|
+
/** A visible label above the track, associated with every thumb. */
|
|
5
|
+
label?: React.ReactNode;
|
|
6
|
+
/** Show the current value (or "min – max" for a range) in mono beside the label. */
|
|
7
|
+
showValue?: boolean;
|
|
8
|
+
/** Accessible names per thumb — required for range sliders ("Minimum budget", "Maximum budget"). */
|
|
9
|
+
thumbLabels?: string[];
|
|
10
|
+
/**
|
|
11
|
+
* A dragged thumb squashes and stretches like something soft, and wobbles back round when let
|
|
12
|
+
* go. Off by default: the thumb keeps its shape.
|
|
13
|
+
*/
|
|
14
|
+
squash?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Slider — a recessed 6px track with a soft indicator fill and raised 18px thumbs.
|
|
18
|
+
*
|
|
19
|
+
* Pass an array as `value`/`defaultValue` for a range; one thumb is rendered per value. Use a
|
|
20
|
+
* slider when the rough position matters more than the exact number — for exact values use
|
|
21
|
+
* `NumberField`. The rule people break: a range slider without `thumbLabels`, so both thumbs
|
|
22
|
+
* announce the same name.
|
|
23
|
+
*/
|
|
24
|
+
export declare function Slider<Value extends number | readonly number[] = number | readonly number[]>({ label, showValue, thumbLabels, squash, thumbAlignment, className, children, ref, ...props }: SliderProps<Value>): React.JSX.Element;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Slider as BaseSlider } from "@base-ui/react/slider";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cn, sx } from "../lib/cn.js";
|
|
6
|
+
import { useFormReset } from "../lib/form-reset.js";
|
|
7
|
+
import { mergeRefs } from "../lib/merge-refs.js";
|
|
8
|
+
import { useLocale } from "./locale.js";
|
|
9
|
+
/* ── Squash and stretch ────────────────────────────────────────────────────── */
|
|
10
|
+
/** How far a thumb stretches at most (0.4 = 40% longer along the track). */
|
|
11
|
+
const MAX_STRETCH = 0.4;
|
|
12
|
+
/** The pinch of a held thumb standing still: already a little wider and flatter under the finger. */
|
|
13
|
+
const HELD_STRETCH = 0.12;
|
|
14
|
+
/**
|
|
15
|
+
* How quickly the stretch answers speed (px/s): it rises fast and eases toward the maximum, so an
|
|
16
|
+
* ordinary drag already squashes — about two thirds of the way at this speed.
|
|
17
|
+
*/
|
|
18
|
+
const SPEED_SCALE = 220;
|
|
19
|
+
/** The spring that pulls the stretch toward its target: stiffness and damping, per second. */
|
|
20
|
+
const STIFFNESS = 420;
|
|
21
|
+
const DAMPING = 22;
|
|
22
|
+
/**
|
|
23
|
+
* A dragged thumb behaves like something soft. Held, it is pinched a little wider and flatter;
|
|
24
|
+
* the faster it moves, the longer and flatter it gets along the track (keeping its area). As it
|
|
25
|
+
* slows it eases back to the pinch, and when it is let go a spring pulls it round again with a
|
|
26
|
+
* small wobble. Driven per frame from the thumb's own movement, so it follows
|
|
27
|
+
* pointer drags, and keyboard steps leave it alone. Only with `squash`; off under reduced motion.
|
|
28
|
+
*/
|
|
29
|
+
function useSquash(control, enabled, mount) {
|
|
30
|
+
React.useEffect(() => {
|
|
31
|
+
const root = control.current;
|
|
32
|
+
if (!enabled || !root)
|
|
33
|
+
return;
|
|
34
|
+
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)");
|
|
35
|
+
const bodies = new Map();
|
|
36
|
+
let frame = 0;
|
|
37
|
+
let last = 0;
|
|
38
|
+
const tick = (now) => {
|
|
39
|
+
// A frame's time can be earlier than the pointerdown that started the loop: a step back in
|
|
40
|
+
// time would run the spring backwards until it blows up, so it counts as a frame instead.
|
|
41
|
+
const dt = Math.min(0.05, Math.max(0, (now - last) / 1000)) || 1 / 60;
|
|
42
|
+
last = now;
|
|
43
|
+
let moving = false;
|
|
44
|
+
const thumbs = root.querySelectorAll('[data-slot="slider-thumb"]');
|
|
45
|
+
// Base UI marks every thumb of a range as dragging; the held one is the one it focused.
|
|
46
|
+
const focused = [...thumbs].some((thumb) => thumb.matches(":focus-within"));
|
|
47
|
+
for (const thumb of thumbs) {
|
|
48
|
+
const vertical = thumb.dataset.orientation === "vertical";
|
|
49
|
+
const r = thumb.getBoundingClientRect();
|
|
50
|
+
const pos = vertical ? r.top + r.height / 2 : r.left + r.width / 2;
|
|
51
|
+
let body = bodies.get(thumb);
|
|
52
|
+
if (!body)
|
|
53
|
+
bodies.set(thumb, (body = { pos, speed: 0, stretch: 0, velocity: 0 }));
|
|
54
|
+
const dragging = thumb.hasAttribute("data-dragging") && (!focused || thumb.matches(":focus-within"));
|
|
55
|
+
const raw = dragging ? Math.abs(pos - body.pos) / dt : 0;
|
|
56
|
+
body.pos = pos;
|
|
57
|
+
// Smooth the speed so one uneven pointer event does not jolt the shape.
|
|
58
|
+
body.speed += (raw - body.speed) * 0.35;
|
|
59
|
+
const target = dragging
|
|
60
|
+
? HELD_STRETCH + (MAX_STRETCH - HELD_STRETCH) * (1 - Math.exp(-body.speed / SPEED_SCALE))
|
|
61
|
+
: 0;
|
|
62
|
+
body.velocity += (STIFFNESS * (target - body.stretch) - DAMPING * body.velocity) * dt;
|
|
63
|
+
body.stretch += body.velocity * dt;
|
|
64
|
+
const settled = !dragging && Math.abs(body.stretch) < 0.002 && Math.abs(body.velocity) < 0.02;
|
|
65
|
+
if (settled) {
|
|
66
|
+
body.stretch = body.velocity = body.speed = 0;
|
|
67
|
+
if (thumb.style.scale) {
|
|
68
|
+
thumb.style.removeProperty("scale");
|
|
69
|
+
// Base UI places a thumb at the track's ends (thumbAlignment="edge") from its measured
|
|
70
|
+
// box, scale included, and measures again only when the value or a size changes: let go
|
|
71
|
+
// mid-stretch, it would stay placed for its stretched size, a few px short of the end.
|
|
72
|
+
// A tenth of a pixel of padding, which leaves the box its size, has it measure the thumb
|
|
73
|
+
// at rest. (Less than a layout unit, 1/64px, would change nothing.)
|
|
74
|
+
thumb.style.paddingInlineEnd = "0.1px";
|
|
75
|
+
requestAnimationFrame(() => thumb.style.removeProperty("padding-inline-end"));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
moving = true;
|
|
80
|
+
const along = 1 + body.stretch;
|
|
81
|
+
const across = 1 / along;
|
|
82
|
+
thumb.style.scale = vertical ? `${across} ${along}` : `${along} ${across}`;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
frame = moving ? requestAnimationFrame(tick) : 0;
|
|
86
|
+
};
|
|
87
|
+
const start = () => {
|
|
88
|
+
if (reduce.matches || frame)
|
|
89
|
+
return;
|
|
90
|
+
last = performance.now();
|
|
91
|
+
for (const [thumb, body] of bodies) {
|
|
92
|
+
const r = thumb.getBoundingClientRect();
|
|
93
|
+
body.pos = thumb.dataset.orientation === "vertical" ? r.top + r.height / 2 : r.left + r.width / 2;
|
|
94
|
+
}
|
|
95
|
+
frame = requestAnimationFrame(tick);
|
|
96
|
+
};
|
|
97
|
+
root.addEventListener("pointerdown", start);
|
|
98
|
+
return () => {
|
|
99
|
+
root.removeEventListener("pointerdown", start);
|
|
100
|
+
cancelAnimationFrame(frame);
|
|
101
|
+
for (const thumb of bodies.keys())
|
|
102
|
+
thumb.style.removeProperty("scale");
|
|
103
|
+
};
|
|
104
|
+
// `mount` changes when a form's reset remounts the slider: listen on the new control.
|
|
105
|
+
}, [control, enabled, mount]);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Slider — a recessed 6px track with a soft indicator fill and raised 18px thumbs.
|
|
109
|
+
*
|
|
110
|
+
* Pass an array as `value`/`defaultValue` for a range; one thumb is rendered per value. Use a
|
|
111
|
+
* slider when the rough position matters more than the exact number — for exact values use
|
|
112
|
+
* `NumberField`. The rule people break: a range slider without `thumbLabels`, so both thumbs
|
|
113
|
+
* announce the same name.
|
|
114
|
+
*/
|
|
115
|
+
export function Slider({ label, showValue = false, thumbLabels, squash = false,
|
|
116
|
+
// Thumbs stop at the track's ends instead of hanging half past them, so a box that clips its
|
|
117
|
+
// content (a card, a popover) never cuts one in half.
|
|
118
|
+
thumbAlignment = "edge", className, children, ref, ...props }) {
|
|
119
|
+
const source = props.value ?? props.defaultValue;
|
|
120
|
+
const count = Array.isArray(source) ? source.length : 1;
|
|
121
|
+
const hasHeader = label != null || showValue;
|
|
122
|
+
const control = React.useRef(null);
|
|
123
|
+
// A form's reset remounts it from its defaults (lib/form-reset).
|
|
124
|
+
const [resetKey, formRef] = useFormReset();
|
|
125
|
+
const refs = React.useMemo(() => mergeRefs(formRef, ref), [formRef, ref]);
|
|
126
|
+
useSquash(control, squash, resetKey);
|
|
127
|
+
const locale = useLocale();
|
|
128
|
+
return (_jsxs(BaseSlider.Root, { ref: refs, "data-slot": "slider", thumbAlignment: thumbAlignment, className: sx("group/slider flex w-full flex-col gap-2 data-[orientation=vertical]:h-full data-[orientation=vertical]:w-auto data-disabled:[&>[data-slot=slider-control]]:opacity-55", className), locale: locale, ...props, children: [hasHeader && (_jsxs("div", { "data-slot": "slider-header", className: "flex items-baseline justify-between gap-4", children: [label != null && (_jsx(BaseSlider.Label, { "data-slot": "slider-label", className: "text-sm leading-snug font-medium text-foreground select-none group-data-disabled/slider:text-foreground-soft", children: label })), showValue && (_jsx(BaseSlider.Value, { "data-slot": "slider-value", className: "ms-auto font-mono text-xs text-muted-foreground tabular-nums group-data-disabled/slider:opacity-55", children: (formatted) => formatted.join(" – ") }))] })), _jsx(BaseSlider.Control, { ref: control, "data-slot": "slider-control", className: "flex w-full touch-none items-center py-2 select-none data-disabled:cursor-not-allowed data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-32 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col data-[orientation=vertical]:px-2 data-[orientation=vertical]:py-0", children: _jsxs(BaseSlider.Track, { "data-slot": "slider-track", className: "relative h-1.5 w-full material-field rounded-full select-none data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5", children: [_jsx(BaseSlider.Indicator, { "data-slot": "slider-indicator", className: "rounded-full bg-foreground-soft select-none" }), Array.from({ length: count }, (_, index) => (_jsx(BaseSlider.Thumb, { index: index, "aria-label": thumbLabels?.[index], "data-slot": "slider-thumb", className: cn("size-[18px] cursor-grab rounded-full bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent select-none", "shadow-thumb", "transition-[background-color,box-shadow] duration-(--duration) ease-brand", "hover:not-data-disabled:bg-control-hover data-dragging:cursor-grabbing",
|
|
129
|
+
// Held, it takes the hover fill; with `squash`, dragged, it squashes and stretches (useSquash).
|
|
130
|
+
"active:not-data-disabled:bg-control-hover data-dragging:bg-control-hover", "has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-0 has-[:focus-visible]:outline-control-focus", "data-disabled:cursor-not-allowed") }, index))), children] }) })] }, resetKey));
|
|
131
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { type ButtonProps } from "./button.js";
|
|
4
|
+
/** Where an item is, as it is read out: the list's label (when it has one), and its position. */
|
|
5
|
+
export interface SortableAnnouncedPlace {
|
|
6
|
+
/** The list's `label`, if it has one. */
|
|
7
|
+
list?: string;
|
|
8
|
+
/** 1-based. */
|
|
9
|
+
position: number;
|
|
10
|
+
/** Items in the list. */
|
|
11
|
+
count: number;
|
|
12
|
+
}
|
|
13
|
+
export interface SortableMessages {
|
|
14
|
+
/** The handle's accessible name: "Move Chapter 3". */
|
|
15
|
+
handle: (item: string) => string;
|
|
16
|
+
/** The handle's description: how to move an item with the keyboard. */
|
|
17
|
+
instructions: string;
|
|
18
|
+
/** A pointer drag started. */
|
|
19
|
+
pickedUp: (item: string, place: SortableAnnouncedPlace) => string;
|
|
20
|
+
/** Picked up with the keyboard: also says which keys move it. */
|
|
21
|
+
pickedUpKeyboard: (item: string, place: SortableAnnouncedPlace) => string;
|
|
22
|
+
/** An arrow key moved it within its list. */
|
|
23
|
+
movedWithin: (item: string, place: SortableAnnouncedPlace) => string;
|
|
24
|
+
/** An arrow key moved it into another list. */
|
|
25
|
+
movedTo: (item: string, place: SortableAnnouncedPlace) => string;
|
|
26
|
+
/** Moved by `useSortable().move` — from a menu, say. */
|
|
27
|
+
moved: (item: string, place: SortableAnnouncedPlace) => string;
|
|
28
|
+
dropped: (item: string, place: SortableAnnouncedPlace) => string;
|
|
29
|
+
cancelled: (item: string, place: SortableAnnouncedPlace) => string;
|
|
30
|
+
/** An arrow key at the end of the list, or past the last list. */
|
|
31
|
+
cannotMove: (item: string, place: SortableAnnouncedPlace) => string;
|
|
32
|
+
}
|
|
33
|
+
declare module "./locale" {
|
|
34
|
+
interface Messages {
|
|
35
|
+
sortable: SortableMessages;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** Several lists, by id, each an ordered list of item ids — the columns of a board. */
|
|
39
|
+
export type SortableLists = Record<string, string[]>;
|
|
40
|
+
/** One list (an array of item ids) or several (`SortableLists`). */
|
|
41
|
+
export type SortableValue = string[] | SortableLists;
|
|
42
|
+
/** A place in the lists: the list's id (`""` for a single list) and the index in it. */
|
|
43
|
+
export interface SortablePlace {
|
|
44
|
+
list: string;
|
|
45
|
+
index: number;
|
|
46
|
+
}
|
|
47
|
+
export interface SortableMoveDetails {
|
|
48
|
+
/** The item's id. */
|
|
49
|
+
item: string;
|
|
50
|
+
from: SortablePlace;
|
|
51
|
+
to: SortablePlace;
|
|
52
|
+
/** What moved it: a drag, a key, `useSortable().move`, or putting it back on a cancel. */
|
|
53
|
+
source: "pointer" | "keyboard" | "api" | "cancel";
|
|
54
|
+
}
|
|
55
|
+
export interface SortableMoveEndDetails {
|
|
56
|
+
item: string;
|
|
57
|
+
/** Where it was picked up. */
|
|
58
|
+
from: SortablePlace;
|
|
59
|
+
/** Where it was put down — `from` again when cancelled. */
|
|
60
|
+
to: SortablePlace;
|
|
61
|
+
cancelled: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Takes `item` out of wherever it is and puts it at `to` — the index in the target list without
|
|
65
|
+
* the item. Works on one list (`to.list` is ignored) and on several. The value is not changed; a
|
|
66
|
+
* new one is returned. Every way of moving an item should go through it.
|
|
67
|
+
*/
|
|
68
|
+
export declare function moveSortableItem<V extends SortableValue>(value: V, item: string, to: Partial<SortablePlace>): V;
|
|
69
|
+
interface ItemContextValue {
|
|
70
|
+
value: string;
|
|
71
|
+
label: string;
|
|
72
|
+
disabled: boolean;
|
|
73
|
+
dragging: boolean;
|
|
74
|
+
lifted: boolean;
|
|
75
|
+
overlay: boolean;
|
|
76
|
+
}
|
|
77
|
+
/** The item a part is in: its value, and whether it is being dragged, lifted, or is the copy under the pointer. */
|
|
78
|
+
export declare function useSortableItem(): ItemContextValue;
|
|
79
|
+
export interface UseSortable {
|
|
80
|
+
/**
|
|
81
|
+
* Move an item without a drag — from a "Move to" menu, say — and announce it. `index` defaults
|
|
82
|
+
* to the end of the list. `focus` is a selector inside the item to focus after the move, as the
|
|
83
|
+
* item remounts in another list; by default focus is left alone.
|
|
84
|
+
*/
|
|
85
|
+
move: (item: string, to: Partial<SortablePlace>, options?: {
|
|
86
|
+
focus?: string;
|
|
87
|
+
}) => void;
|
|
88
|
+
/** The item being dragged with the pointer, if any. */
|
|
89
|
+
dragging: string | null;
|
|
90
|
+
/** The item picked up with the keyboard, if any. */
|
|
91
|
+
lifted: string | null;
|
|
92
|
+
}
|
|
93
|
+
/** The Sortable around a part: `move` an item from your own controls, and what is moving now. */
|
|
94
|
+
export declare function useSortable(): UseSortable;
|
|
95
|
+
export interface SortableProps<V extends SortableValue = SortableValue> extends Omit<useRender.ComponentProps<"div">, "defaultValue" | "onChange"> {
|
|
96
|
+
/** The order: an array of item ids for one list, or `{ [listId]: ids }` for several. */
|
|
97
|
+
value?: V;
|
|
98
|
+
/** The order to start from, uncontrolled. */
|
|
99
|
+
defaultValue?: V;
|
|
100
|
+
/**
|
|
101
|
+
* Called with the new order on every move — each arrow key while an item is lifted, a drop, a
|
|
102
|
+
* cancel that puts it back. Save on `onMoveEnd` instead if every step would be a request.
|
|
103
|
+
*/
|
|
104
|
+
onValueChange?: (value: V, details: SortableMoveDetails) => void;
|
|
105
|
+
/** Called once an item is put down, or put back. */
|
|
106
|
+
onMoveEnd?: (details: SortableMoveEndDetails) => void;
|
|
107
|
+
/**
|
|
108
|
+
* The copy that follows the pointer. By default it is a copy of the item's own element; return
|
|
109
|
+
* your own to draw it differently (`useSortableItem().overlay` is true inside it).
|
|
110
|
+
*/
|
|
111
|
+
overlay?: (item: string) => React.ReactNode;
|
|
112
|
+
/** Drag only from a `SortableHandle`, so text in the items can be selected. */
|
|
113
|
+
handleOnly?: boolean;
|
|
114
|
+
/** Announcements and the handle's name; a LocaleProvider sets them for every Sortable. */
|
|
115
|
+
labels?: Partial<SortableMessages>;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Sortable — reorderable lists: one list, a row, a wrapping grid, or several lists that items
|
|
119
|
+
* move between, as the columns of a board.
|
|
120
|
+
*
|
|
121
|
+
* Drag an item with the mouse, a pen or — after a long press, so a swipe still scrolls — a finger:
|
|
122
|
+
* a copy follows the pointer, the other items slide aside to open a gap where it will land (in a
|
|
123
|
+
* grid, slot to slot across the row breaks), and on release the copy glides into the gap (or
|
|
124
|
+
* home, on a cancel), taking the size of its place. Over a list of narrower or wider items the
|
|
125
|
+
* copy takes their width. Edges scroll as it nears them.
|
|
126
|
+
* Every item has a `SortableHandle`: Space or Enter picks the item up, the arrows move it — the
|
|
127
|
+
* items slide into their new order — Space drops it and Escape puts it back. Every move is read
|
|
128
|
+
* out in a polite live region. No drag-and-drop library: measured once, moved by transforms.
|
|
129
|
+
*
|
|
130
|
+
* Compose `Sortable` → `SortableList` → `SortableItem` → `SortableHandle`. The rule people break:
|
|
131
|
+
* leaving out the handle. Without it there is no keyboard way to move an item.
|
|
132
|
+
*/
|
|
133
|
+
export declare function Sortable<V extends SortableValue = SortableValue>({ value: valueProp, defaultValue, onValueChange, onMoveEnd, overlay, handleOnly, labels, render, className, children, ref, ...props }: SortableProps<V>): React.JSX.Element;
|
|
134
|
+
export interface SortableListProps extends useRender.ComponentProps<"ol"> {
|
|
135
|
+
/** The list's key in a `Sortable` of several lists. Leave it out for a single list. */
|
|
136
|
+
id?: string;
|
|
137
|
+
/**
|
|
138
|
+
* `vertical` (default) stacks the items; `horizontal` lines them up in a row; `grid` lays them
|
|
139
|
+
* out in rows that wrap — Left and Right move an item by one, Up and Down by a row. Items that
|
|
140
|
+
* wrap move as a grid, by pointer and by key, whatever the orientation.
|
|
141
|
+
*/
|
|
142
|
+
orientation?: "vertical" | "horizontal" | "grid";
|
|
143
|
+
/**
|
|
144
|
+
* The list's name in announcements ("Moved to Qualified, position 2 of 4"); also its
|
|
145
|
+
* `aria-label` unless it has an `aria-label` or `aria-labelledby` of its own.
|
|
146
|
+
*/
|
|
147
|
+
label?: string;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* One list of items, an `<ol>` by default. Items keep the order of `value`; render them in it.
|
|
151
|
+
* Lay it out yourself (`flex flex-col gap-2`, a row with `flex-row`, a `grid grid-cols-3`). While
|
|
152
|
+
* an item is dragged the others slide aside to open a gap of its size where it will land — in a
|
|
153
|
+
* grid each moves into the slot of its neighbour, across the row breaks.
|
|
154
|
+
*/
|
|
155
|
+
export declare function SortableList({ id, orientation, label, render, className, children, ref, ...props }: SortableListProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
156
|
+
export interface SortableItemProps extends useRender.ComponentProps<"li"> {
|
|
157
|
+
/** The item's id, as it is in `value`. */
|
|
158
|
+
value: string;
|
|
159
|
+
/** Its name in announcements and on its handle ("Move Chapter 3"). Defaults to `value`. */
|
|
160
|
+
label?: string;
|
|
161
|
+
/** Not moved by drag or keyboard; its handle is disabled. */
|
|
162
|
+
disabled?: boolean;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* One item, an `<li>` by default. Dragged, it leaves its place (`data-dragging`, hidden) while a
|
|
166
|
+
* copy follows the pointer and the other items slide around the gap; picked up with the keyboard
|
|
167
|
+
* it has `data-lifted`, and it slides with the others as the arrows move it. Presses on buttons,
|
|
168
|
+
* links and fields inside it keep their own clicks.
|
|
169
|
+
*/
|
|
170
|
+
export declare function SortableItem({ value, label, disabled, render, className, children, onPointerDown, onContextMenu, ref, ...props }: SortableItemProps): React.JSX.Element;
|
|
171
|
+
export type SortableHandleProps = ButtonProps;
|
|
172
|
+
/**
|
|
173
|
+
* The grip that moves an item: drag it — at once, even on touch — or focus it and press Space.
|
|
174
|
+
* A ghost 30px icon button named "Move {label}", described by the keyboard instructions, with
|
|
175
|
+
* `aria-pressed` while the item is lifted. Without children it draws a grip in the list's direction.
|
|
176
|
+
*/
|
|
177
|
+
export declare function SortableHandle({ variant, size, className, children, onKeyDown, onBlur, ref, ...props }: SortableHandleProps): React.JSX.Element;
|
|
178
|
+
export {};
|