@zonsh/ui 0.0.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +75 -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/breadcrumb.d.ts +22 -0
- package/dist/components/breadcrumb.js +32 -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 +164 -0
- package/dist/components/card.d.ts +42 -0
- package/dist/components/card.js +76 -0
- package/dist/components/carousel.d.ts +90 -0
- package/dist/components/carousel.js +213 -0
- package/dist/components/chart.d.ts +180 -0
- package/dist/components/chart.js +286 -0
- package/dist/components/checkbox.d.ts +23 -0
- package/dist/components/checkbox.js +43 -0
- package/dist/components/code-block.d.ts +45 -0
- package/dist/components/code-block.js +58 -0
- package/dist/components/code-highlight.d.ts +13 -0
- package/dist/components/code-highlight.js +107 -0
- package/dist/components/collapsible.d.ts +20 -0
- package/dist/components/collapsible.js +32 -0
- package/dist/components/color-picker.d.ts +85 -0
- package/dist/components/color-picker.js +407 -0
- package/dist/components/combobox.d.ts +81 -0
- package/dist/components/combobox.js +100 -0
- package/dist/components/command.d.ts +112 -0
- package/dist/components/command.js +212 -0
- package/dist/components/context-menu.d.ts +29 -0
- package/dist/components/context-menu.js +35 -0
- package/dist/components/conversation.d.ts +27 -0
- package/dist/components/conversation.js +293 -0
- package/dist/components/copy-button.d.ts +46 -0
- package/dist/components/copy-button.js +118 -0
- package/dist/components/data-table.d.ts +175 -0
- package/dist/components/data-table.js +302 -0
- package/dist/components/date-picker.d.ts +91 -0
- package/dist/components/date-picker.js +207 -0
- package/dist/components/dialog.d.ts +48 -0
- package/dist/components/dialog.js +92 -0
- package/dist/components/direction.d.ts +16 -0
- package/dist/components/direction.js +18 -0
- package/dist/components/drawer.d.ts +60 -0
- package/dist/components/drawer.js +76 -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 +15 -0
- package/dist/components/field.js +36 -0
- package/dist/components/file-drop.d.ts +55 -0
- package/dist/components/file-drop.js +197 -0
- package/dist/components/filter-bar.d.ts +106 -0
- package/dist/components/filter-bar.js +296 -0
- package/dist/components/form.d.ts +33 -0
- package/dist/components/form.js +34 -0
- package/dist/components/graph.d.ts +105 -0
- package/dist/components/graph.js +786 -0
- package/dist/components/illustration.d.ts +85 -0
- package/dist/components/illustration.js +165 -0
- package/dist/components/input-group.d.ts +127 -0
- package/dist/components/input-group.js +292 -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 +33 -0
- package/dist/components/kbd.js +38 -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/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 +138 -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 +56 -0
- package/dist/components/meter.d.ts +31 -0
- package/dist/components/meter.js +25 -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 +36 -0
- package/dist/components/number-field.js +153 -0
- package/dist/components/otp-field.d.ts +35 -0
- package/dist/components/otp-field.js +94 -0
- package/dist/components/pagination.d.ts +31 -0
- package/dist/components/pagination.js +70 -0
- package/dist/components/pdf-viewer.d.ts +69 -0
- package/dist/components/pdf-viewer.js +929 -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 +23 -0
- package/dist/components/prompt-input.d.ts +131 -0
- package/dist/components/prompt-input.js +403 -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/reasoning.d.ts +31 -0
- package/dist/components/reasoning.js +70 -0
- package/dist/components/resizable.d.ts +38 -0
- package/dist/components/resizable.js +41 -0
- package/dist/components/response.d.ts +30 -0
- package/dist/components/response.js +538 -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 +60 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +17 -0
- package/dist/components/sidebar.d.ts +147 -0
- package/dist/components/sidebar.js +489 -0
- package/dist/components/site-header.d.ts +59 -0
- package/dist/components/site-header.js +67 -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 +129 -0
- package/dist/components/sources.d.ts +25 -0
- package/dist/components/sources.js +35 -0
- package/dist/components/spinner.d.ts +36 -0
- package/dist/components/spinner.js +72 -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 +162 -0
- package/dist/components/table.js +758 -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 +40 -0
- package/dist/components/tags-input.js +239 -0
- package/dist/components/textarea.d.ts +13 -0
- package/dist/components/textarea.js +16 -0
- package/dist/components/theme.d.ts +41 -0
- package/dist/components/theme.js +112 -0
- package/dist/components/time-field.d.ts +51 -0
- package/dist/components/time-field.js +437 -0
- package/dist/components/timeline.d.ts +76 -0
- package/dist/components/timeline.js +99 -0
- package/dist/components/toast.d.ts +72 -0
- package/dist/components/toast.js +196 -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 +52 -0
- package/dist/components/tool-call.js +57 -0
- package/dist/components/toolbar.d.ts +17 -0
- package/dist/components/toolbar.js +34 -0
- package/dist/components/tooltip.d.ts +42 -0
- package/dist/components/tooltip.js +47 -0
- package/dist/components/tree.d.ts +75 -0
- package/dist/components/tree.js +636 -0
- package/dist/components/typography.d.ts +134 -0
- package/dist/components/typography.js +176 -0
- package/dist/components/video-player.d.ts +276 -0
- package/dist/components/video-player.js +1352 -0
- package/dist/components/whiteboard.d.ts +80 -0
- package/dist/components/whiteboard.js +389 -0
- package/dist/index.d.ts +85 -0
- package/dist/index.js +86 -0
- package/dist/lib/cn.d.ts +20 -0
- package/dist/lib/cn.js +38 -0
- package/dist/lib/code-highlight.d.ts +31 -0
- package/dist/lib/code-highlight.js +24 -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/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 +200 -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/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/platform.d.ts +33 -0
- package/dist/lib/platform.js +68 -0
- package/dist/lib/room.d.ts +25 -0
- package/dist/lib/room.js +46 -0
- package/dist/lib/table-fit.d.ts +143 -0
- package/dist/lib/table-fit.js +577 -0
- package/dist/lib/theme-script.d.ts +18 -0
- package/dist/lib/theme-script.js +29 -0
- package/dist/styles/expressive.css +188 -0
- package/dist/styles/fonts.css +145 -0
- package/dist/styles/index.css +206 -0
- package/dist/styles/material.css +313 -0
- package/dist/styles/parts/ai.css +360 -0
- package/dist/styles/parts/brand.css +75 -0
- package/dist/styles/parts/controls.css +725 -0
- package/dist/styles/parts/data.css +222 -0
- package/dist/styles/parts/editorial.css +120 -0
- package/dist/styles/parts/feedback.css +273 -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 +232 -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/parts/whiteboard.css +855 -0
- package/dist/styles/tokens.css +290 -0
- package/dist/vite.d.ts +116 -0
- package/dist/vite.js +129 -0
- package/package.json +188 -5
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Menu as BaseMenu } from "@base-ui/react/menu";
|
|
4
|
+
import { CheckIcon, ChevronRightIcon } from "lucide-react";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { cn, sx, triggerSlot } from "../lib/cn.js";
|
|
7
|
+
import { mergeRefs } from "../lib/merge-refs.js";
|
|
8
|
+
import { formatShortcut, useShortcutKeys } from "../lib/platform.js";
|
|
9
|
+
import { TriggerRoomContext, useTriggerRoom } from "../lib/room.js";
|
|
10
|
+
import { MenuFrame } from "./_overlay.js";
|
|
11
|
+
/**
|
|
12
|
+
* Menu — a list of actions opened from a button: "Rename", "Duplicate", "Delete project".
|
|
13
|
+
* Menu material at 12px, items at 7px and 38px tall, the highlighted item raised like `SelectItem`.
|
|
14
|
+
*
|
|
15
|
+
* The rule people break: using a menu to pick a value. A menu *does* things; to choose a value
|
|
16
|
+
* use `Select` (or `MenuRadioGroup` when the choice is a view setting next to other actions).
|
|
17
|
+
*/
|
|
18
|
+
export function Menu(props) {
|
|
19
|
+
// The trigger registers here, so the menu and its submenus keep inside the trigger's room.
|
|
20
|
+
const room = useTriggerRoom();
|
|
21
|
+
return (_jsx(TriggerRoomContext.Provider, { value: room, children: _jsx(BaseMenu.Root, { ...props }) }));
|
|
22
|
+
}
|
|
23
|
+
/** Opens the menu. Compose with a button: `render={<Button variant="secondary" />}`. */
|
|
24
|
+
export function MenuTrigger({ ref, ...props }) {
|
|
25
|
+
const setTrigger = React.useContext(TriggerRoomContext)?.setTrigger;
|
|
26
|
+
const refs = React.useMemo(() => mergeRefs(setTrigger, ref), [setTrigger, ref]);
|
|
27
|
+
return _jsx(BaseMenu.Trigger, { ref: refs, ...triggerSlot("menu-trigger", props.render), ...props });
|
|
28
|
+
}
|
|
29
|
+
/** Portal + Positioner + Popup. Opens below the trigger, aligned to its start edge. */
|
|
30
|
+
export function MenuContent({ align = "start", sideOffset = 6, ...props }) {
|
|
31
|
+
return _jsx(MenuFrame, { slot: "menu-content", align: align, sideOffset: sideOffset, ...props });
|
|
32
|
+
}
|
|
33
|
+
/* ── Items ─────────────────────────────────────────────────────────────────── */
|
|
34
|
+
/**
|
|
35
|
+
* Shared item geometry: 38px min height, 7px radius, raised fill + inner edge when highlighted. A
|
|
36
|
+
* word too long for the menu (a URL, a file name) breaks instead of running under the check.
|
|
37
|
+
*/
|
|
38
|
+
const menuItemClass = cn("relative flex min-h-(--control-h) cursor-pointer items-center gap-2.5 rounded-item border border-transparent px-2.5 text-sm [overflow-wrap:anywhere] text-foreground-soft outline-none select-none", "data-highlighted:border-control-inner-edge data-highlighted:bg-control-hover data-highlighted:text-foreground data-highlighted:shadow-highlight", "data-disabled:pointer-events-none data-disabled:opacity-50", "[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&>svg]:text-muted-foreground data-highlighted:[&>svg]:text-foreground");
|
|
39
|
+
const itemVariants = {
|
|
40
|
+
default: "",
|
|
41
|
+
/** Destructive ink for irreversible actions. Stays monochrome on the surface. */
|
|
42
|
+
destructive: "text-destructive data-highlighted:text-destructive [&>svg]:text-destructive data-highlighted:[&>svg]:text-destructive",
|
|
43
|
+
};
|
|
44
|
+
/** One action. Put a 16px lucide icon first and a `MenuShortcut` last if it has one. */
|
|
45
|
+
export function MenuItem({ variant = "default", className, ...props }) {
|
|
46
|
+
return (_jsx(BaseMenu.Item, { "data-slot": "menu-item", "data-variant": variant, className: sx([menuItemClass, itemVariants[variant]], className), ...props }));
|
|
47
|
+
}
|
|
48
|
+
/** A menu item that is a link. Use for navigation so middle-click and "open in new tab" work. */
|
|
49
|
+
export function MenuLinkItem({ className, ...props }) {
|
|
50
|
+
return _jsx(BaseMenu.LinkItem, { "data-slot": "menu-link-item", className: sx(menuItemClass, className), ...props });
|
|
51
|
+
}
|
|
52
|
+
/** A toggle inside a menu ("Show grid"). The check sits at the trailing edge, like `SelectItem`. */
|
|
53
|
+
export function MenuCheckboxItem({ className, children, ...props }) {
|
|
54
|
+
return (_jsxs(BaseMenu.CheckboxItem, { "data-slot": "menu-checkbox-item", className: sx([menuItemClass, "pe-2"], className), ...props, children: [_jsx("span", { className: "flex min-w-0 flex-1 items-center gap-2.5", children: children }), _jsx(BaseMenu.CheckboxItemIndicator, { "data-slot": "menu-checkbox-indicator", className: "flex text-foreground", children: _jsx(CheckIcon, { className: "size-4" }) })] }));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Groups `MenuRadioItem`s that share one value (`value` / `onValueChange`). The group draws one
|
|
58
|
+
* dot, which glides up or down to the option picked; it appears in place when the menu opens.
|
|
59
|
+
*/
|
|
60
|
+
export function MenuRadioGroup({ className, children, ref, ...props }) {
|
|
61
|
+
const own = React.useRef(null);
|
|
62
|
+
const refs = React.useMemo(() => mergeRefs(own, ref), [ref]);
|
|
63
|
+
const [dot, setDot] = React.useState(null);
|
|
64
|
+
React.useLayoutEffect(() => {
|
|
65
|
+
const group = own.current;
|
|
66
|
+
if (!group)
|
|
67
|
+
return;
|
|
68
|
+
const place = () => {
|
|
69
|
+
// Any checked option: a menubar re-slots its items, the mark stays the same.
|
|
70
|
+
const mark = group.querySelector('[data-checked] > [data-slot="menu-radio-mark"]');
|
|
71
|
+
// A kept-mounted menu that is closed has nothing to measure: no dot until it shows, and then
|
|
72
|
+
// the dot lands in place.
|
|
73
|
+
if (!mark || !group.offsetParent)
|
|
74
|
+
return setDot(null);
|
|
75
|
+
// Layout offsets, not client rects: the popup opens with a scale (popup-motion), and a rect
|
|
76
|
+
// measured mid-open would put the dot off sideways. Offsets ignore transforms, so x stays put
|
|
77
|
+
// and only y moves between options.
|
|
78
|
+
let x = mark.offsetWidth / 2;
|
|
79
|
+
let y = mark.offsetHeight / 2;
|
|
80
|
+
for (let el = mark; el && el !== group; el = el.offsetParent) {
|
|
81
|
+
x += el.offsetLeft;
|
|
82
|
+
y += el.offsetTop;
|
|
83
|
+
}
|
|
84
|
+
// The first placement lands in place; later ones glide.
|
|
85
|
+
setDot((prev) => (prev && prev.x === x && prev.y === y ? prev : { x, y, glide: prev != null }));
|
|
86
|
+
};
|
|
87
|
+
place();
|
|
88
|
+
// A pick changes the items' data-checked; uncontrolled groups re-render only inside Base UI.
|
|
89
|
+
const observer = new MutationObserver(place);
|
|
90
|
+
observer.observe(group, { subtree: true, attributeFilter: ["data-checked"] });
|
|
91
|
+
// The menu showing, or options added or removed, resizes the group.
|
|
92
|
+
const resize = new ResizeObserver(place);
|
|
93
|
+
resize.observe(group);
|
|
94
|
+
return () => {
|
|
95
|
+
observer.disconnect();
|
|
96
|
+
resize.disconnect();
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
99
|
+
return (_jsxs(BaseMenu.RadioGroup, { ref: refs, "data-slot": "menu-radio-group", className: sx("relative", className), ...props, children: [children, dot && (_jsx("span", { "aria-hidden": true, "data-slot": "menu-radio-dot", className: cn("pointer-events-none absolute top-0 left-0 -mt-[3px] -ml-[3px] size-1.5 rounded-full bg-foreground", dot.glide && "transition-transform duration-[calc(var(--duration)*1.6)] ease-(--ease)"), style: { transform: `translate(${dot.x}px, ${dot.y}px)` } }))] }));
|
|
100
|
+
}
|
|
101
|
+
/** One option of a `MenuRadioGroup`. The group's dot sits at the current option's trailing edge. */
|
|
102
|
+
export function MenuRadioItem({ className, children, ...props }) {
|
|
103
|
+
return (_jsxs(BaseMenu.RadioItem, { "data-slot": "menu-radio-item", className: sx([menuItemClass, "pe-2"], className), ...props, children: [_jsx("span", { className: "flex min-w-0 flex-1 items-center gap-2.5", children: children }), _jsx("span", { "data-slot": "menu-radio-mark", "aria-hidden": true, className: "flex size-4 shrink-0" })] }));
|
|
104
|
+
}
|
|
105
|
+
/** Groups related items so assistive tech announces them together. Label it with `MenuGroupLabel`. */
|
|
106
|
+
export function MenuGroup(props) {
|
|
107
|
+
return _jsx(BaseMenu.Group, { "data-slot": "menu-group", ...props });
|
|
108
|
+
}
|
|
109
|
+
/** An eyebrow above a group: 11px mono, uppercase, tracked. */
|
|
110
|
+
export function MenuGroupLabel({ className, ...props }) {
|
|
111
|
+
return (_jsx(BaseMenu.GroupLabel, { "data-slot": "menu-group-label", className: sx("px-2.5 pt-2.5 pb-1.5 eyebrow text-[11px] [overflow-wrap:anywhere] select-none", className), ...props }));
|
|
112
|
+
}
|
|
113
|
+
/** A hairline between groups of items. */
|
|
114
|
+
export function MenuSeparator({ className, ...props }) {
|
|
115
|
+
return (_jsx(BaseMenu.Separator, { "data-slot": "menu-separator", className: sx("-mx-1 my-1 h-px bg-border", className), ...props }));
|
|
116
|
+
}
|
|
117
|
+
export function MenuShortcut({ keys, className, children, ...props }) {
|
|
118
|
+
const { mod, hasKeyboard } = useShortcutKeys();
|
|
119
|
+
if (keys && !hasKeyboard)
|
|
120
|
+
return null;
|
|
121
|
+
return (_jsx("span", { "data-slot": "menu-shortcut", "aria-hidden": true, className: cn(
|
|
122
|
+
// Its own text decides its direction: ⌘D stays ⌘D in a right-to-left menu.
|
|
123
|
+
"ms-auto ps-4 font-mono text-xs tracking-normal whitespace-nowrap text-muted-foreground [unicode-bidi:plaintext]", className), ...props, children: keys ? formatShortcut(keys, mod) : children }));
|
|
124
|
+
}
|
|
125
|
+
/* ── Submenus ──────────────────────────────────────────────────────────────── */
|
|
126
|
+
/** A nested menu. Holds a `MenuSubTrigger` and a `MenuSubContent`. */
|
|
127
|
+
export const MenuSub = BaseMenu.SubmenuRoot;
|
|
128
|
+
/** The item that opens a submenu; shows a chevron and stays raised while its submenu is open. */
|
|
129
|
+
export function MenuSubTrigger({ className, children, ...props }) {
|
|
130
|
+
return (_jsxs(BaseMenu.SubmenuTrigger, { "data-slot": "menu-sub-trigger", className: sx([
|
|
131
|
+
menuItemClass,
|
|
132
|
+
"pe-2 data-popup-open:border-control-inner-edge data-popup-open:bg-control-hover data-popup-open:text-foreground",
|
|
133
|
+
], className), ...props, children: [children, _jsx(ChevronRightIcon, { "aria-hidden": true, className: "ms-auto size-4 text-muted-foreground rtl:rotate-180" })] }));
|
|
134
|
+
}
|
|
135
|
+
/** The submenu popup. Opens to the inline end, its first item level with the trigger. */
|
|
136
|
+
export function MenuSubContent({ sideOffset = 2, alignOffset = -5, ...props }) {
|
|
137
|
+
return _jsx(MenuFrame, { slot: "menu-sub-content", sideOffset: sideOffset, alignOffset: alignOffset, ...props });
|
|
138
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Menu as BaseMenu } from "@base-ui/react/menu";
|
|
2
|
+
import { Menubar as BaseMenubar } from "@base-ui/react/menubar";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Menu, type MenuContentProps, type MenuItemProps, type MenuShortcutProps } from "./menu.js";
|
|
5
|
+
/**
|
|
6
|
+
* Menubar — the application menu bar of a desktop-style tool: "File", "Edit", "View".
|
|
7
|
+
*
|
|
8
|
+
* A dense 38px bar on the region material (12px corners) holding 30px triggers that are flat at
|
|
9
|
+
* rest; hover brightens a label. The open menu's trigger is raised by one highlight that glides
|
|
10
|
+
* along the bar as you move between menus. Once one menu is open, moving the pointer or the arrow keys across the bar opens its
|
|
11
|
+
* neighbours, and one shared menu surface glides and resizes from the old menu to the new one
|
|
12
|
+
* while the new items fade in — the way `NavigationMenu` moves between panels. The menus are the
|
|
13
|
+
* `Menu` popup and items, unchanged.
|
|
14
|
+
*
|
|
15
|
+
* The rule people break: putting a menubar on a marketing or content page. It belongs to
|
|
16
|
+
* editors and dashboards; site navigation is `SiteHeader` or `NavigationMenu`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function Menubar({ className, children, ref, ...props }: MenubarProps): React.JSX.Element;
|
|
19
|
+
export interface MenubarProps extends BaseMenubar.Props {
|
|
20
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* One menu in the bar. Holds a `MenubarTrigger` and a `MenubarContent`. The `Menu` root, so its
|
|
24
|
+
* popup and submenus keep inside the trigger's room.
|
|
25
|
+
*/
|
|
26
|
+
export declare const MenubarMenu: typeof Menu;
|
|
27
|
+
/**
|
|
28
|
+
* The bar button that opens a menu: 30px, 13px Licht Sans, 7px corners. Flat at rest and hover only
|
|
29
|
+
* brightens its label; while its menu is open the bar's gliding highlight raises it, so the open
|
|
30
|
+
* menu always points back to its trigger.
|
|
31
|
+
*/
|
|
32
|
+
export declare function MenubarTrigger({ className, ref, ...props }: BaseMenu.Trigger.Props): React.JSX.Element;
|
|
33
|
+
export type MenubarContentProps = MenuContentProps;
|
|
34
|
+
/**
|
|
35
|
+
* Portal + Positioner + Popup: the `Menu` popup, opening below the bar (to the inline end in a
|
|
36
|
+
* vertical bar), aligned to the trigger's start edge.
|
|
37
|
+
*/
|
|
38
|
+
export declare function MenubarContent({ align, sideOffset, ...props }: MenubarContentProps): React.JSX.Element;
|
|
39
|
+
/** One action. Same as `MenuItem`: a 16px icon first, a `MenubarShortcut` last. */
|
|
40
|
+
export declare function MenubarItem(props: MenuItemProps): React.JSX.Element;
|
|
41
|
+
/** An item that is a real link. Same as `MenuLinkItem`. */
|
|
42
|
+
export declare function MenubarLinkItem(props: BaseMenu.LinkItem.Props): React.JSX.Element;
|
|
43
|
+
/** A toggle ("Show rulers") with its check at the trailing edge. Same as `MenuCheckboxItem`. */
|
|
44
|
+
export declare function MenubarCheckboxItem(props: BaseMenu.CheckboxItem.Props): React.JSX.Element;
|
|
45
|
+
/** Groups `MenubarRadioItem`s that share one value. Same as `MenuRadioGroup`. */
|
|
46
|
+
export declare function MenubarRadioGroup(props: BaseMenu.RadioGroup.Props): React.JSX.Element;
|
|
47
|
+
/** One option of a `MenubarRadioGroup`. Same as `MenuRadioItem`. */
|
|
48
|
+
export declare function MenubarRadioItem(props: BaseMenu.RadioItem.Props): React.JSX.Element;
|
|
49
|
+
/** Groups related items. Label it with `MenubarGroupLabel`. */
|
|
50
|
+
export declare function MenubarGroup(props: BaseMenu.Group.Props): React.JSX.Element;
|
|
51
|
+
/** The mono eyebrow above a group. Same as `MenuGroupLabel`. */
|
|
52
|
+
export declare function MenubarGroupLabel(props: BaseMenu.GroupLabel.Props): React.JSX.Element;
|
|
53
|
+
/** A hairline between groups of items. */
|
|
54
|
+
export declare function MenubarSeparator(props: BaseMenu.Separator.Props): React.JSX.Element;
|
|
55
|
+
/** A mono keyboard hint at the trailing edge of an item. Decorative — wire the keys yourself. */
|
|
56
|
+
export declare function MenubarShortcut(props: MenuShortcutProps): React.JSX.Element;
|
|
57
|
+
/** A nested menu inside a menubar menu. Holds a `MenubarSubTrigger` and a `MenubarSubContent`. */
|
|
58
|
+
export declare const MenubarSub: typeof BaseMenu.SubmenuRoot;
|
|
59
|
+
/** The item that opens a submenu. Same as `MenuSubTrigger`. */
|
|
60
|
+
export declare function MenubarSubTrigger(props: BaseMenu.SubmenuTrigger.Props): React.JSX.Element;
|
|
61
|
+
/** The submenu popup. Same as `MenuSubContent`. */
|
|
62
|
+
export declare function MenubarSubContent(props: MenuContentProps): React.JSX.Element;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Menu as BaseMenu } from "@base-ui/react/menu";
|
|
4
|
+
import { Menubar as BaseMenubar } from "@base-ui/react/menubar";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { createPortal } from "react-dom";
|
|
7
|
+
import { cn, sx, triggerSlot } from "../lib/cn.js";
|
|
8
|
+
import { cssDuration } from "../lib/motion.js";
|
|
9
|
+
import { glideMotion, glideStyle, useGlide, useMergedRef } from "../lib/glide.js";
|
|
10
|
+
import { mergeRefs } from "../lib/merge-refs.js";
|
|
11
|
+
import { TriggerRoomContext } from "../lib/room.js";
|
|
12
|
+
import { MenuFrame } from "./_overlay.js";
|
|
13
|
+
import { Menu, MenuCheckboxItem, MenuGroup, MenuGroupLabel, MenuItem, MenuLinkItem, MenuRadioGroup, MenuRadioItem, MenuSeparator, MenuShortcut, MenuSubContent, MenuSubTrigger, } from "./menu.js";
|
|
14
|
+
/**
|
|
15
|
+
* Menubar — the application menu bar of a desktop-style tool: "File", "Edit", "View".
|
|
16
|
+
*
|
|
17
|
+
* A dense 38px bar on the region material (12px corners) holding 30px triggers that are flat at
|
|
18
|
+
* rest; hover brightens a label. The open menu's trigger is raised by one highlight that glides
|
|
19
|
+
* along the bar as you move between menus. Once one menu is open, moving the pointer or the arrow keys across the bar opens its
|
|
20
|
+
* neighbours, and one shared menu surface glides and resizes from the old menu to the new one
|
|
21
|
+
* while the new items fade in — the way `NavigationMenu` moves between panels. The menus are the
|
|
22
|
+
* `Menu` popup and items, unchanged.
|
|
23
|
+
*
|
|
24
|
+
* The rule people break: putting a menubar on a marketing or content page. It belongs to
|
|
25
|
+
* editors and dashboards; site navigation is `SiteHeader` or `NavigationMenu`.
|
|
26
|
+
*/
|
|
27
|
+
export function Menubar({ className, children, ref, ...props }) {
|
|
28
|
+
const [rootRef, setRootRef] = useMergedRef(ref);
|
|
29
|
+
const glide = useGlide(rootRef, findOpen, {
|
|
30
|
+
attributes: ["data-popup-open"],
|
|
31
|
+
items: TRIGGER,
|
|
32
|
+
linger: 140,
|
|
33
|
+
});
|
|
34
|
+
const [surfaceRef, surface] = useMenuSurface();
|
|
35
|
+
const [mounted, setMounted] = React.useState(false);
|
|
36
|
+
React.useEffect(() => setMounted(true), []);
|
|
37
|
+
return (_jsxs(MenubarSurfaceContext.Provider, { value: surface, children: [_jsxs(BaseMenubar, { ref: setRootRef, "data-slot": "menubar", "data-glide": glide.visible ? "" : undefined, className: sx("group/menubar relative inline-flex w-fit items-center gap-0.5 rounded-button p-[3px] surface-container data-[orientation=vertical]:flex-col data-[orientation=vertical]:items-stretch", className), ...props, children: [_jsx("span", { "aria-hidden": true, "data-slot": "menubar-indicator", "data-visible": glide.visible ? "" : undefined, "data-instant": glide.instant ? "" : undefined, className: cn(glideMotion, "rounded-item border border-transparent bg-control-hover bg-linear-to-b from-control-inner-edge to-transparent shadow-raised"), style: glideStyle(glide) }), children] }), mounted &&
|
|
38
|
+
createPortal(_jsx("div", { ref: surfaceRef, "aria-hidden": true, "data-slot": "menubar-surface", className: "pointer-events-none fixed top-0 left-0 z-49 rounded-button material-menu opacity-0 transition-opacity duration-(--duration) ease-brand data-switching:transition-[opacity,translate,width,height] data-switching:duration-[var(--duration),calc(var(--duration)*2),calc(var(--duration)*2),calc(var(--duration)*2)] data-visible:opacity-100" }), document.body)] }));
|
|
39
|
+
}
|
|
40
|
+
const TRIGGER = '[data-slot="menubar-trigger"]';
|
|
41
|
+
/** The highlight marks the open menu only; hover alone just brightens a trigger's label. */
|
|
42
|
+
const findOpen = (root) => root.querySelector(`${TRIGGER}[data-popup-open]`);
|
|
43
|
+
/** How long the surface waits for the next menu before it fades (ms). */
|
|
44
|
+
const HOLD = 90;
|
|
45
|
+
const MenubarSurfaceContext = React.createContext(null);
|
|
46
|
+
/**
|
|
47
|
+
* The bar's menus share one surface, like NavigationMenu's viewport. Each menubar popup drops its
|
|
48
|
+
* own material (`data-surface`) and this fixed element, carrying the menu material, follows the
|
|
49
|
+
* open popup every frame. Opening and closing it simply tracks the popup's own motion; moving to a
|
|
50
|
+
* neighbouring menu turns on `data-switching`, so position and size glide over 2 × --duration —
|
|
51
|
+
* CSS transitions start from wherever they are, which keeps quick back-and-forth smooth — while
|
|
52
|
+
* the new items fade in. Reduced motion sets --duration to 0, so it jumps.
|
|
53
|
+
*/
|
|
54
|
+
function useMenuSurface() {
|
|
55
|
+
const surfaceRef = React.useRef(null);
|
|
56
|
+
const controller = React.useMemo(() => {
|
|
57
|
+
let active = null;
|
|
58
|
+
const popups = new Set();
|
|
59
|
+
let lostAt = 0;
|
|
60
|
+
let frame = 0;
|
|
61
|
+
let settle = 0;
|
|
62
|
+
const follow = () => {
|
|
63
|
+
frame = 0;
|
|
64
|
+
const surface = surfaceRef.current;
|
|
65
|
+
if (!surface)
|
|
66
|
+
return;
|
|
67
|
+
if (!active || !active.isConnected || active.hasAttribute("data-ending-style")) {
|
|
68
|
+
// Moving fast, the old menu can leave a frame or two before the next arrives: hold the
|
|
69
|
+
// surface briefly so the next menu glides from here instead of snapping in.
|
|
70
|
+
if (active && surface.hasAttribute("data-visible")) {
|
|
71
|
+
lostAt ||= performance.now();
|
|
72
|
+
if (performance.now() - lostAt < HOLD) {
|
|
73
|
+
frame = requestAnimationFrame(follow);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
lostAt = 0;
|
|
78
|
+
surface.removeAttribute("data-visible");
|
|
79
|
+
if (active?.isConnected)
|
|
80
|
+
frame = requestAnimationFrame(follow);
|
|
81
|
+
else
|
|
82
|
+
active = null;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
lostAt = 0;
|
|
86
|
+
const r = active.getBoundingClientRect();
|
|
87
|
+
surface.style.translate = `${r.left}px ${r.top}px`;
|
|
88
|
+
surface.style.width = `${r.width}px`;
|
|
89
|
+
surface.style.height = `${r.height}px`;
|
|
90
|
+
surface.setAttribute("data-visible", "");
|
|
91
|
+
frame = requestAnimationFrame(follow);
|
|
92
|
+
};
|
|
93
|
+
return {
|
|
94
|
+
open(popup) {
|
|
95
|
+
const surface = surfaceRef.current;
|
|
96
|
+
popup.setAttribute("data-surface", "");
|
|
97
|
+
// Refs re-attach on re-render: the same popup again changes nothing.
|
|
98
|
+
if (popup === active) {
|
|
99
|
+
if (!frame)
|
|
100
|
+
frame = requestAnimationFrame(follow);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const switching = !!surface?.hasAttribute("data-visible") && !!active && active !== popup;
|
|
104
|
+
// Only the newest menu shows its items. The others may still be fading out on the
|
|
105
|
+
// transparent surface; moving fast, their text would overlap the new menu's.
|
|
106
|
+
for (const other of popups) {
|
|
107
|
+
if (!other.isConnected)
|
|
108
|
+
popups.delete(other);
|
|
109
|
+
else if (other !== popup)
|
|
110
|
+
other.style.visibility = "hidden";
|
|
111
|
+
}
|
|
112
|
+
popups.add(popup);
|
|
113
|
+
popup.style.visibility = "";
|
|
114
|
+
active = popup;
|
|
115
|
+
lostAt = 0;
|
|
116
|
+
if (surface && switching) {
|
|
117
|
+
const duration = cssDuration(surface) * 2;
|
|
118
|
+
surface.setAttribute("data-switching", "");
|
|
119
|
+
clearTimeout(settle);
|
|
120
|
+
settle = window.setTimeout(() => surface.removeAttribute("data-switching"), duration + 60);
|
|
121
|
+
if (duration > 0) {
|
|
122
|
+
popup.animate([{ opacity: 0 }, { opacity: 1 }], {
|
|
123
|
+
duration: duration * 0.6,
|
|
124
|
+
delay: duration * 0.15,
|
|
125
|
+
easing: "ease-out",
|
|
126
|
+
fill: "backwards",
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// Base UI positions the popup in a layout effect after it mounts: measure from the next frame.
|
|
131
|
+
if (!frame)
|
|
132
|
+
frame = requestAnimationFrame(follow);
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}, []);
|
|
136
|
+
return [surfaceRef, controller];
|
|
137
|
+
}
|
|
138
|
+
/** Hands a menubar popup to the bar's shared surface while it is mounted. */
|
|
139
|
+
function useSurfacePopup() {
|
|
140
|
+
const surface = React.useContext(MenubarSurfaceContext);
|
|
141
|
+
return React.useCallback((node) => {
|
|
142
|
+
if (surface && node)
|
|
143
|
+
surface.open(node);
|
|
144
|
+
}, [surface]);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* One menu in the bar. Holds a `MenubarTrigger` and a `MenubarContent`. The `Menu` root, so its
|
|
148
|
+
* popup and submenus keep inside the trigger's room.
|
|
149
|
+
*/
|
|
150
|
+
export const MenubarMenu = Menu;
|
|
151
|
+
/**
|
|
152
|
+
* The bar button that opens a menu: 30px, 13px Licht Sans, 7px corners. Flat at rest and hover only
|
|
153
|
+
* brightens its label; while its menu is open the bar's gliding highlight raises it, so the open
|
|
154
|
+
* menu always points back to its trigger.
|
|
155
|
+
*/
|
|
156
|
+
export function MenubarTrigger({ className, ref, ...props }) {
|
|
157
|
+
const setTrigger = React.useContext(TriggerRoomContext)?.setTrigger;
|
|
158
|
+
const refs = React.useMemo(() => mergeRefs(setTrigger, ref), [setTrigger, ref]);
|
|
159
|
+
return (_jsx(BaseMenu.Trigger, { ref: refs, "data-slot": "menubar-trigger", className: sx([
|
|
160
|
+
"relative inline-flex min-h-(--control-h-sm) shrink-0 cursor-pointer items-center gap-1.5 rounded-item border border-transparent px-3 font-body text-[13px] leading-none whitespace-nowrap text-foreground-soft focus-ring transition-colors duration-(--duration) ease-brand select-none",
|
|
161
|
+
"hover:text-foreground data-popup-open:text-foreground",
|
|
162
|
+
// Until the bar's highlight has measured, the open trigger raises itself.
|
|
163
|
+
"data-popup-open:bg-control-hover data-popup-open:bg-linear-to-b data-popup-open:from-control-inner-edge data-popup-open:to-transparent data-popup-open:shadow-raised",
|
|
164
|
+
"group-data-glide/menubar:data-popup-open:bg-transparent group-data-glide/menubar:data-popup-open:bg-none group-data-glide/menubar:data-popup-open:shadow-none",
|
|
165
|
+
"data-disabled:pointer-events-none data-disabled:opacity-50",
|
|
166
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
167
|
+
], className), ...props }));
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Portal + Positioner + Popup: the `Menu` popup, opening below the bar (to the inline end in a
|
|
171
|
+
* vertical bar), aligned to the trigger's start edge.
|
|
172
|
+
*/
|
|
173
|
+
export function MenubarContent({ align = "start", sideOffset = 8, ...props }) {
|
|
174
|
+
const surfaceRef = useSurfacePopup();
|
|
175
|
+
return (_jsx(MenuFrame, { ref: surfaceRef, slot: "menubar-content", align: align, sideOffset: sideOffset, ...props }));
|
|
176
|
+
}
|
|
177
|
+
/* ── Items: the Menu items, re-slotted so a menubar is addressable on its own ── */
|
|
178
|
+
/** One action. Same as `MenuItem`: a 16px icon first, a `MenubarShortcut` last. */
|
|
179
|
+
export function MenubarItem(props) {
|
|
180
|
+
return _jsx(MenuItem, { "data-slot": "menubar-item", ...props });
|
|
181
|
+
}
|
|
182
|
+
/** An item that is a real link. Same as `MenuLinkItem`. */
|
|
183
|
+
export function MenubarLinkItem(props) {
|
|
184
|
+
return _jsx(MenuLinkItem, { "data-slot": "menubar-link-item", ...props });
|
|
185
|
+
}
|
|
186
|
+
/** A toggle ("Show rulers") with its check at the trailing edge. Same as `MenuCheckboxItem`. */
|
|
187
|
+
export function MenubarCheckboxItem(props) {
|
|
188
|
+
return _jsx(MenuCheckboxItem, { "data-slot": "menubar-checkbox-item", ...props });
|
|
189
|
+
}
|
|
190
|
+
/** Groups `MenubarRadioItem`s that share one value. Same as `MenuRadioGroup`. */
|
|
191
|
+
export function MenubarRadioGroup(props) {
|
|
192
|
+
return _jsx(MenuRadioGroup, { "data-slot": "menubar-radio-group", ...props });
|
|
193
|
+
}
|
|
194
|
+
/** One option of a `MenubarRadioGroup`. Same as `MenuRadioItem`. */
|
|
195
|
+
export function MenubarRadioItem(props) {
|
|
196
|
+
return _jsx(MenuRadioItem, { "data-slot": "menubar-radio-item", ...props });
|
|
197
|
+
}
|
|
198
|
+
/** Groups related items. Label it with `MenubarGroupLabel`. */
|
|
199
|
+
export function MenubarGroup(props) {
|
|
200
|
+
return _jsx(MenuGroup, { "data-slot": "menubar-group", ...props });
|
|
201
|
+
}
|
|
202
|
+
/** The mono eyebrow above a group. Same as `MenuGroupLabel`. */
|
|
203
|
+
export function MenubarGroupLabel(props) {
|
|
204
|
+
return _jsx(MenuGroupLabel, { "data-slot": "menubar-group-label", ...props });
|
|
205
|
+
}
|
|
206
|
+
/** A hairline between groups of items. */
|
|
207
|
+
export function MenubarSeparator(props) {
|
|
208
|
+
return _jsx(MenuSeparator, { "data-slot": "menubar-separator", ...props });
|
|
209
|
+
}
|
|
210
|
+
/** A mono keyboard hint at the trailing edge of an item. Decorative — wire the keys yourself. */
|
|
211
|
+
export function MenubarShortcut(props) {
|
|
212
|
+
return _jsx(MenuShortcut, { "data-slot": "menubar-shortcut", ...props });
|
|
213
|
+
}
|
|
214
|
+
/** A nested menu inside a menubar menu. Holds a `MenubarSubTrigger` and a `MenubarSubContent`. */
|
|
215
|
+
export const MenubarSub = BaseMenu.SubmenuRoot;
|
|
216
|
+
/** The item that opens a submenu. Same as `MenuSubTrigger`. */
|
|
217
|
+
export function MenubarSubTrigger(props) {
|
|
218
|
+
return _jsx(MenuSubTrigger, { ...triggerSlot("menubar-sub-trigger", props.render), ...props });
|
|
219
|
+
}
|
|
220
|
+
/** The submenu popup. Same as `MenuSubContent`. */
|
|
221
|
+
export function MenubarSubContent(props) {
|
|
222
|
+
return _jsx(MenuSubContent, { "data-slot": "menubar-sub-content", ...props });
|
|
223
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { type AvatarProps } from "./avatar.js";
|
|
3
|
+
import { type ButtonProps } from "./button.js";
|
|
4
|
+
/** Who wrote a message. */
|
|
5
|
+
export type MessageFrom = "user" | "assistant";
|
|
6
|
+
export interface MessageProps extends React.ComponentProps<"div"> {
|
|
7
|
+
from: MessageFrom;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Message — one turn in an AI conversation. A **user** message sits on the right in a 20px
|
|
11
|
+
* card, sized to its text; an **assistant** message runs full width on the page, with no
|
|
12
|
+
* bubble, so long answers read like a document.
|
|
13
|
+
*
|
|
14
|
+
* Compose `MessageAvatar` (optional), `MessageContent` and `MessageActions`. The rule people
|
|
15
|
+
* break: putting the assistant in a bubble too — the reply is the content, not a quote.
|
|
16
|
+
*/
|
|
17
|
+
export declare function Message({ from, className, ...props }: MessageProps): React.JSX.Element;
|
|
18
|
+
/**
|
|
19
|
+
* The author's picture: an `Avatar` (a name gives mono initials), or any 32px mark as children —
|
|
20
|
+
* the assistant is often a `LogoMark` on a raised key.
|
|
21
|
+
*/
|
|
22
|
+
export declare function MessageAvatar({ className, children, ...props }: AvatarProps & {
|
|
23
|
+
children?: React.ReactNode;
|
|
24
|
+
}): React.JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* The message body and, below it, its actions. User text sits in a card at most 80% wide;
|
|
27
|
+
* assistant content takes the full width (put a `Response` in it for markdown).
|
|
28
|
+
*/
|
|
29
|
+
export declare function MessageContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
30
|
+
/**
|
|
31
|
+
* Plain message text, kept as written: line breaks stay, long words wrap. In a user message it
|
|
32
|
+
* is the card; in an assistant message it is a paragraph.
|
|
33
|
+
*/
|
|
34
|
+
export declare function MessageText({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
35
|
+
/** A row of `MessageAction`s under the content: copy, retry, rate. */
|
|
36
|
+
export declare function MessageActions({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
37
|
+
export interface MessageActionProps extends Omit<ButtonProps, "variant" | "size"> {
|
|
38
|
+
/** The action's name: the tooltip and the accessible name. */
|
|
39
|
+
label: string;
|
|
40
|
+
}
|
|
41
|
+
/** One action under a message: a 30px ghost icon button with a tooltip. */
|
|
42
|
+
export declare function MessageAction({ label, className, children, ...props }: MessageActionProps): React.JSX.Element;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { Avatar } from "./avatar.js";
|
|
6
|
+
import { Button } from "./button.js";
|
|
7
|
+
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
8
|
+
const MessageContext = React.createContext("assistant");
|
|
9
|
+
/**
|
|
10
|
+
* Message — one turn in an AI conversation. A **user** message sits on the right in a 20px
|
|
11
|
+
* card, sized to its text; an **assistant** message runs full width on the page, with no
|
|
12
|
+
* bubble, so long answers read like a document.
|
|
13
|
+
*
|
|
14
|
+
* Compose `MessageAvatar` (optional), `MessageContent` and `MessageActions`. The rule people
|
|
15
|
+
* break: putting the assistant in a bubble too — the reply is the content, not a quote.
|
|
16
|
+
*/
|
|
17
|
+
export function Message({ from, className, ...props }) {
|
|
18
|
+
return (_jsx(MessageContext.Provider, { value: from, children: _jsx("div", { "data-slot": "message", "data-from": from, className: cn("group/message flex w-full min-w-0 gap-3", from === "user" ? "flex-row-reverse" : "flex-row", className), ...props }) }));
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The author's picture: an `Avatar` (a name gives mono initials), or any 32px mark as children —
|
|
22
|
+
* the assistant is often a `LogoMark` on a raised key.
|
|
23
|
+
*/
|
|
24
|
+
export function MessageAvatar({ className, children, ...props }) {
|
|
25
|
+
if (children != null)
|
|
26
|
+
return (_jsx("span", { "data-slot": "message-avatar", "aria-hidden": true, className: cn("inline-flex size-8 shrink-0 items-center justify-center rounded-full bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent text-foreground shadow-key", className), children: children }));
|
|
27
|
+
return _jsx(Avatar, { "data-slot": "message-avatar", className: cn("shrink-0", className), ...props });
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The message body and, below it, its actions. User text sits in a card at most 80% wide;
|
|
31
|
+
* assistant content takes the full width (put a `Response` in it for markdown).
|
|
32
|
+
*/
|
|
33
|
+
export function MessageContent({ className, ...props }) {
|
|
34
|
+
const from = React.useContext(MessageContext);
|
|
35
|
+
return (_jsx("div", { "data-slot": "message-content", className: cn("flex min-w-0 flex-col gap-2 text-[15px] leading-relaxed", from === "user" ? "max-w-[80%] items-end" : "flex-1 text-foreground-soft", className), ...props }));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Plain message text, kept as written: line breaks stay, long words wrap. In a user message it
|
|
39
|
+
* is the card; in an assistant message it is a paragraph.
|
|
40
|
+
*/
|
|
41
|
+
export function MessageText({ className, ...props }) {
|
|
42
|
+
const from = React.useContext(MessageContext);
|
|
43
|
+
return (_jsx("div", { "data-slot": "message-text", className: cn("[overflow-wrap:anywhere] whitespace-pre-wrap text-foreground", from === "user" && "surface-card [--card-padding:10px_16px]", className), ...props }));
|
|
44
|
+
}
|
|
45
|
+
/** A row of `MessageAction`s under the content: copy, retry, rate. */
|
|
46
|
+
export function MessageActions({ className, ...props }) {
|
|
47
|
+
const from = React.useContext(MessageContext);
|
|
48
|
+
return (_jsx("div", { "data-slot": "message-actions", className: cn("-ml-1.5 flex items-center gap-0.5",
|
|
49
|
+
// User actions appear on hover or focus, so a long thread stays quiet.
|
|
50
|
+
from === "user" &&
|
|
51
|
+
"-mr-1.5 ml-0 opacity-0 transition-opacity duration-(--duration) ease-(--ease) group-focus-within/message:opacity-100 group-hover/message:opacity-100", className), ...props }));
|
|
52
|
+
}
|
|
53
|
+
/** One action under a message: a 30px ghost icon button with a tooltip. */
|
|
54
|
+
export function MessageAction({ label, className, children, ...props }) {
|
|
55
|
+
return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { render: _jsx(Button, { "data-slot": "message-action", variant: "ghost", size: "icon-sm", "aria-label": label, className: cn("text-muted-foreground [&_svg:not([class*='size-'])]:size-3.5", className), ...props }), children: children }), _jsx(TooltipContent, { children: label })] }));
|
|
56
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Meter as BaseMeter } from "@base-ui/react/meter";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
declare const toneFill: {
|
|
4
|
+
readonly default: "bg-foreground";
|
|
5
|
+
readonly success: "bg-success";
|
|
6
|
+
readonly warning: "bg-warning";
|
|
7
|
+
readonly info: "bg-info";
|
|
8
|
+
readonly destructive: "bg-destructive";
|
|
9
|
+
};
|
|
10
|
+
export type MeterTone = keyof typeof toneFill;
|
|
11
|
+
export interface MeterProps extends BaseMeter.Root.Props {
|
|
12
|
+
/** A visible mono label above the track. Without one, pass `aria-label`. */
|
|
13
|
+
label?: React.ReactNode;
|
|
14
|
+
/** Show the formatted value (e.g. `64%`) at the end of the label row. */
|
|
15
|
+
showValue?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The indicator's colour. A status, or a function of the value that returns one — a disk that
|
|
18
|
+
* turns amber past 75% and red past 90%. Say the state in the label or value too.
|
|
19
|
+
*/
|
|
20
|
+
tone?: MeterTone | ((value: number) => MeterTone);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Meter — a static quantity within a known range: capacity used, a completeness score.
|
|
24
|
+
*
|
|
25
|
+
* The same recessed 6px track and `--foreground` indicator as `Progress`, with an optional
|
|
26
|
+
* mono label and value. The rule people break: using it for work in progress. Something that
|
|
27
|
+
* will finish is a `Progress`. Red is not a "high" colour: give the meter a `tone` only when the
|
|
28
|
+
* value crosses a line that matters (nearly full, over budget), and say so in words as well.
|
|
29
|
+
*/
|
|
30
|
+
export declare function Meter({ label, showValue, tone, className, children, ...props }: MeterProps): React.JSX.Element;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Meter as BaseMeter } from "@base-ui/react/meter";
|
|
4
|
+
import { sx } from "../lib/cn.js";
|
|
5
|
+
const toneFill = {
|
|
6
|
+
default: "bg-foreground",
|
|
7
|
+
success: "bg-success",
|
|
8
|
+
warning: "bg-warning",
|
|
9
|
+
info: "bg-info",
|
|
10
|
+
destructive: "bg-destructive",
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Meter — a static quantity within a known range: capacity used, a completeness score.
|
|
14
|
+
*
|
|
15
|
+
* The same recessed 6px track and `--foreground` indicator as `Progress`, with an optional
|
|
16
|
+
* mono label and value. The rule people break: using it for work in progress. Something that
|
|
17
|
+
* will finish is a `Progress`. Red is not a "high" colour: give the meter a `tone` only when the
|
|
18
|
+
* value crosses a line that matters (nearly full, over budget), and say so in words as well.
|
|
19
|
+
*/
|
|
20
|
+
export function Meter({ label, showValue = false, tone = "default", className, children, ...props }) {
|
|
21
|
+
const resolved = typeof tone === "function" ? tone(props.value) : tone;
|
|
22
|
+
return (_jsxs(BaseMeter.Root, { "data-slot": "meter", "data-tone": resolved, className: sx("grid w-full grid-cols-[minmax(0,1fr)_auto] items-baseline gap-x-3 gap-y-2", className), ...props, children: [label != null && (_jsx(BaseMeter.Label, { "data-slot": "meter-label",
|
|
23
|
+
// A long name (a file, a URL) wraps instead of pushing the track wider than its column.
|
|
24
|
+
className: "col-start-1 font-mono text-[12px] [overflow-wrap:anywhere] text-foreground-soft", children: label })), showValue && (_jsx(BaseMeter.Value, { "data-slot": "meter-value", className: "col-start-2 text-end font-mono text-[12px] text-muted-foreground tabular-nums" })), _jsx(BaseMeter.Track, { "data-slot": "meter-track", className: "relative col-span-2 h-1.5 overflow-hidden rounded-full border border-field-edge bg-field-surface shadow-field", children: _jsx(BaseMeter.Indicator, { "data-slot": "meter-indicator", className: sx("block h-full rounded-full transition-[width,background-color] duration-(--duration) ease-(--ease)", toneFill[resolved]) }) }), children] }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
declare const sizes: {
|
|
3
|
+
readonly sm: "min-h-(--control-h-sm) pe-8 ps-2.5 text-[13px]";
|
|
4
|
+
readonly default: "min-h-(--control-h) pe-10 ps-3.5 text-base sm:text-[15px]";
|
|
5
|
+
};
|
|
6
|
+
export interface NativeSelectProps extends Omit<React.ComponentProps<"select">, "size"> {
|
|
7
|
+
/** `sm` (30px) for dense surfaces; `default` (38px) everywhere else. */
|
|
8
|
+
size?: keyof typeof sizes;
|
|
9
|
+
/** Classes for the wrapper that positions the chevron (width, margins, grid placement). */
|
|
10
|
+
wrapperClassName?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* NativeSelect — a real `<select>` in the field material: recessed, 10px corners, 38px (30px
|
|
14
|
+
* dense), with the same two-way chevron as `Select`. The browser draws the option list, so it
|
|
15
|
+
* is the platform's own picker on phones and works before JavaScript loads.
|
|
16
|
+
*
|
|
17
|
+
* Prefer it for plain forms, long lists (countries, years) and mobile-first screens. Reach for
|
|
18
|
+
* `Select` when the options need custom rendering, groups with rich labels or a styled popup.
|
|
19
|
+
* The rule people break: styling `<option>` — browsers ignore most of it; keep options as text.
|
|
20
|
+
*/
|
|
21
|
+
export declare function NativeSelect({ size, className, wrapperClassName, children, ...props }: NativeSelectProps): React.JSX.Element;
|
|
22
|
+
/** One `<option>`. Plain text only: browsers ignore most styling on options. */
|
|
23
|
+
export declare function NativeSelectOption(props: React.ComponentProps<"option">): React.JSX.Element;
|
|
24
|
+
/** A labelled group of options (`<optgroup>`). */
|
|
25
|
+
export declare function NativeSelectOptGroup(props: React.ComponentProps<"optgroup">): React.JSX.Element;
|
|
26
|
+
export {};
|