@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,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
const badgeVariants = {
|
|
5
|
+
/** The primary fill: dark in light mode, light in dark mode. Counts that need attention. */
|
|
6
|
+
default: "bg-(--primary-fill) text-(--primary-text) shadow-checked",
|
|
7
|
+
/** The raised key surface with foreground ink. Quiet counts and "New" markers. */
|
|
8
|
+
secondary: "bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent text-foreground shadow-key",
|
|
9
|
+
/** Status only: done, connected, online. Never decoration. */
|
|
10
|
+
success: "bg-success text-background shadow-checked",
|
|
11
|
+
/** Status only: away, expiring, a count of things that need attention soon. Never decoration. */
|
|
12
|
+
warning: "bg-warning text-background shadow-checked",
|
|
13
|
+
/** Status only: new, syncing, an unread count of neutral news. Never decoration. */
|
|
14
|
+
info: "bg-info text-background shadow-checked",
|
|
15
|
+
/** Status only: failed, offline, an error count. Never decoration. */
|
|
16
|
+
destructive: "bg-destructive text-background shadow-checked",
|
|
17
|
+
};
|
|
18
|
+
const badgeSizes = {
|
|
19
|
+
/** 16px — on 30px controls, 24px avatars and inline in dense rows. */
|
|
20
|
+
sm: "h-4 min-w-4 px-1 text-[10px]",
|
|
21
|
+
/** 20px — on 36–46px controls and 32–40px avatars. */
|
|
22
|
+
default: "h-5 min-w-5 px-1.5 text-[11px]",
|
|
23
|
+
};
|
|
24
|
+
const dotSizes = {
|
|
25
|
+
sm: "size-2",
|
|
26
|
+
default: "size-2.5",
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Badge — a small count or status mark: a notification count on an icon button or avatar,
|
|
30
|
+
* a "New" marker beside a nav item, or a status dot. Mono, tabular numerals; 16 or 20px tall,
|
|
31
|
+
* fully round. Monochrome by default; `success`, `warning`, `info` and `destructive` are status only.
|
|
32
|
+
*
|
|
33
|
+
* Wrap the thing it marks in `BadgeAnchor` to pin it to the corner. Not the same as `Tag`:
|
|
34
|
+
* a tag is metadata that names something ("TypeScript", "Draft"); a badge counts or flags
|
|
35
|
+
* something about the object it sits on. The rule people break: colour as decoration — a
|
|
36
|
+
* green "New" or a red count that is not an error.
|
|
37
|
+
*/
|
|
38
|
+
export function Badge({ variant = "default", size = "default", count, max = 99, dot = false, label, className, children, ...props }) {
|
|
39
|
+
// Not above zero — or not a number yet (NaN while a count loads) — renders nothing.
|
|
40
|
+
if (count !== undefined && !(count > 0) && !dot)
|
|
41
|
+
return null;
|
|
42
|
+
const content = count !== undefined ? (count > max ? `${max}+` : String(count)) : children;
|
|
43
|
+
return (_jsxs("span", { "data-slot": "badge", "data-variant": variant, "data-size": size, "data-dot": dot || undefined, className: cn("inline-flex shrink-0 items-center justify-center rounded-full leading-none whitespace-nowrap select-none", badgeVariants[variant], dot
|
|
44
|
+
? dotSizes[size]
|
|
45
|
+
: [
|
|
46
|
+
"font-mono font-medium tracking-[0.02em] tabular-nums",
|
|
47
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-3",
|
|
48
|
+
badgeSizes[size],
|
|
49
|
+
], className), ...props, children: [!dot && content, label && _jsx("span", { className: "sr-only", children: label })] }));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* BadgeAnchor — wraps an icon button, avatar or other object and pins a direct child `Badge`
|
|
53
|
+
* to its corner, with a 2px cut-out in the page colour (`--badge-cutout`, default
|
|
54
|
+
* `--background`; set it on a card). The badge ignores the pointer, so the control underneath
|
|
55
|
+
* still receives every click.
|
|
56
|
+
*/
|
|
57
|
+
export function BadgeAnchor({ shape = "circle", placement = "top-end", className, ...props }) {
|
|
58
|
+
return (_jsx("span", { "data-slot": "badge-anchor", "data-shape": shape, "data-placement": placement,
|
|
59
|
+
// Never wider than its container, so a labelled button inside ends its label in "…" with
|
|
60
|
+
// the badge still on its corner.
|
|
61
|
+
className: cn("relative inline-flex w-fit max-w-full shrink-0 align-middle", className), ...props }));
|
|
62
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface BreadcrumbItem {
|
|
3
|
+
label: React.ReactNode;
|
|
4
|
+
/** Omit on the current page. */
|
|
5
|
+
href?: string;
|
|
6
|
+
/** Replace the `<a>` (e.g. a router `Link`). Receives the href, className and children. */
|
|
7
|
+
render?: React.ReactElement<Record<string, unknown>>;
|
|
8
|
+
}
|
|
9
|
+
export interface BreadcrumbProps extends Omit<React.ComponentProps<"nav">, "children"> {
|
|
10
|
+
/** Trail from the root to the current page. The last item is the current page. */
|
|
11
|
+
items: BreadcrumbItem[];
|
|
12
|
+
/** Separator glyph. Defaults to `/`. */
|
|
13
|
+
separator?: React.ReactNode;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Breadcrumb — where this page sits, as a mono trail: `Shop / Outerwear / Waxed cotton jacket`.
|
|
17
|
+
*
|
|
18
|
+
* 12px Licht Mono, muted, with `/` separators; the current page is foreground and not a link.
|
|
19
|
+
* The rule people break: using it as the primary navigation or on a flat site. If the page is
|
|
20
|
+
* one level deep, a breadcrumb only repeats the header.
|
|
21
|
+
*/
|
|
22
|
+
export declare function Breadcrumb({ items, separator, className, ...props }: BreadcrumbProps): React.JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
/**
|
|
6
|
+
* Breadcrumb — where this page sits, as a mono trail: `Shop / Outerwear / Waxed cotton jacket`.
|
|
7
|
+
*
|
|
8
|
+
* 12px Licht Mono, muted, with `/` separators; the current page is foreground and not a link.
|
|
9
|
+
* The rule people break: using it as the primary navigation or on a flat site. If the page is
|
|
10
|
+
* one level deep, a breadcrumb only repeats the header.
|
|
11
|
+
*/
|
|
12
|
+
export function Breadcrumb({ items, separator = "/", className, ...props }) {
|
|
13
|
+
return (_jsx("nav", { "aria-label": "Breadcrumb", "data-slot": "breadcrumb", className: cn("min-w-0", className), ...props, children: _jsx("ol", { className: "m-0 flex list-none flex-wrap items-center gap-x-2 gap-y-3 p-0 font-mono text-[12px] leading-none [overflow-wrap:anywhere] text-muted-foreground", children: items.map((item, i) => {
|
|
14
|
+
const current = i === items.length - 1;
|
|
15
|
+
const linkClass = "text-muted-foreground no-underline transition-colors duration-(--duration) ease-(--ease) hover:text-foreground focus-ring";
|
|
16
|
+
let content;
|
|
17
|
+
if (current || (!item.href && !item.render)) {
|
|
18
|
+
content = (_jsx("span", { "data-slot": "breadcrumb-page", "aria-current": current ? "page" : undefined, className: current ? "text-foreground" : undefined, children: item.label }));
|
|
19
|
+
}
|
|
20
|
+
else if (item.render) {
|
|
21
|
+
content = React.cloneElement(item.render, {
|
|
22
|
+
href: item.href,
|
|
23
|
+
className: cn(linkClass, item.render.props.className),
|
|
24
|
+
children: item.label,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
content = (_jsx("a", { "data-slot": "breadcrumb-link", href: item.href, className: linkClass, children: item.label }));
|
|
29
|
+
}
|
|
30
|
+
return (_jsxs(React.Fragment, { children: [i > 0 && (_jsx("li", { role: "presentation", "aria-hidden": true, "data-slot": "breadcrumb-separator", className: "text-control-muted", children: separator })), _jsx("li", { "data-slot": "breadcrumb-item", className: "inline-flex min-w-0 items-center", children: content })] }, i));
|
|
31
|
+
}) }) }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
declare const orientations: {
|
|
3
|
+
readonly horizontal: readonly ["flex-row", "[&>*:not(:nth-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-l-none", "[&>*:not(:nth-last-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-r-none"];
|
|
4
|
+
readonly vertical: readonly ["flex-col", "[&>*:not(:nth-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-t-none", "[&>*:not(:nth-last-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-b-none"];
|
|
5
|
+
};
|
|
6
|
+
export interface ButtonGroupProps extends React.ComponentProps<"div"> {
|
|
7
|
+
/** Lay the controls out in a row (default) or a column. */
|
|
8
|
+
orientation?: keyof typeof orientations;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* ButtonGroup — joins related controls edge to edge: the inner corners collapse to 0, the
|
|
12
|
+
* outer corners keep 12px (10px for fields), and neighbouring edges merge into one line.
|
|
13
|
+
* Works with `Button` variants, `SelectTrigger`, `Input` and `InputGroup` side by side.
|
|
14
|
+
*
|
|
15
|
+
* Use it for a split button, a pager, or a field with the action that belongs to it. The rule
|
|
16
|
+
* people break: joining unrelated actions to save space — separate actions stay separate
|
|
17
|
+
* buttons with a gap. Give the group an `aria-label` that names what the controls act on.
|
|
18
|
+
*/
|
|
19
|
+
export declare function ButtonGroup({ orientation, className, ...props }: ButtonGroupProps): React.JSX.Element;
|
|
20
|
+
export interface ButtonGroupSeparatorProps extends React.ComponentProps<"div"> {
|
|
21
|
+
/** Match the group: a vertical rule in a horizontal group (default), and vice versa. */
|
|
22
|
+
orientation?: "vertical" | "horizontal";
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* No longer needed: joined buttons draw one thin seam between them themselves (a soft line on a
|
|
26
|
+
* split primary, the edge colour on raised buttons). Kept so existing markup keeps working; it
|
|
27
|
+
* renders nothing visible.
|
|
28
|
+
*/
|
|
29
|
+
export declare function ButtonGroupSeparator({ orientation, className, ...props }: ButtonGroupSeparatorProps): React.JSX.Element;
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
/*
|
|
5
|
+
* First and last are counted among the joined controls only. While a menu or popover is open,
|
|
6
|
+
* Base UI renders invisible helper spans (focus guards, an aria-owns span) beside its trigger,
|
|
7
|
+
* and a CopyButton keeps its live region beside itself; with plain :first-child / :last-child
|
|
8
|
+
* the control would stop being last and lose its outer corners — the "blocky" open split button.
|
|
9
|
+
* How neighbours meet (merged field borders, one seam between buttons) lives in
|
|
10
|
+
* parts/controls.css.
|
|
11
|
+
*/
|
|
12
|
+
const orientations = {
|
|
13
|
+
horizontal: [
|
|
14
|
+
"flex-row",
|
|
15
|
+
// Inner corners collapse; the outer corners keep each control's own radius.
|
|
16
|
+
"[&>*:not(:nth-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-l-none",
|
|
17
|
+
"[&>*:not(:nth-last-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-r-none",
|
|
18
|
+
],
|
|
19
|
+
vertical: [
|
|
20
|
+
"flex-col",
|
|
21
|
+
"[&>*:not(:nth-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-t-none",
|
|
22
|
+
"[&>*:not(:nth-last-child(1_of_:not([data-base-ui-focus-guard],span[aria-owns],[data-slot=copy-button-status])))]:rounded-b-none",
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* ButtonGroup — joins related controls edge to edge: the inner corners collapse to 0, the
|
|
27
|
+
* outer corners keep 12px (10px for fields), and neighbouring edges merge into one line.
|
|
28
|
+
* Works with `Button` variants, `SelectTrigger`, `Input` and `InputGroup` side by side.
|
|
29
|
+
*
|
|
30
|
+
* Use it for a split button, a pager, or a field with the action that belongs to it. The rule
|
|
31
|
+
* people break: joining unrelated actions to save space — separate actions stay separate
|
|
32
|
+
* buttons with a gap. Give the group an `aria-label` that names what the controls act on.
|
|
33
|
+
*/
|
|
34
|
+
export function ButtonGroup({ orientation = "horizontal", className, ...props }) {
|
|
35
|
+
return (_jsx("div", { role: "group", "data-slot": "button-group", "data-orientation": orientation, className: cn("flex w-fit items-stretch",
|
|
36
|
+
// The control being used rises above its neighbours so its focus outline is never covered.
|
|
37
|
+
// (A CopyButton's live region stays out of the row, visually hidden.)
|
|
38
|
+
"[&>*:focus-visible]:z-10 [&>*:has(:focus-visible)]:z-10 [&>*:not([data-slot=copy-button-status])]:relative [&>*[data-popup-open]]:z-10", orientations[orientation], className), ...props }));
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* No longer needed: joined buttons draw one thin seam between them themselves (a soft line on a
|
|
42
|
+
* split primary, the edge colour on raised buttons). Kept so existing markup keeps working; it
|
|
43
|
+
* renders nothing visible.
|
|
44
|
+
*/
|
|
45
|
+
export function ButtonGroupSeparator({ orientation = "vertical", className, ...props }) {
|
|
46
|
+
return (_jsx("div", { role: "separator", "aria-orientation": orientation, "data-slot": "button-group-separator", "data-orientation": orientation, className: cn("hidden", className), ...props }));
|
|
47
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Button as BaseButton } from "@base-ui/react/button";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
declare const variants: {
|
|
4
|
+
/** The layered primary. One per view — the action that carries the page. */
|
|
5
|
+
readonly primary: "material-primary";
|
|
6
|
+
/** Raised quiet surface. Every other action. */
|
|
7
|
+
readonly secondary: "material-raised data-disabled:data-popup-open:bg-control-surface";
|
|
8
|
+
/** Flat until hovered, then raised. Toolbars and dense rows. */
|
|
9
|
+
readonly ghost: "material-row";
|
|
10
|
+
/** Inline text action with the brand underline. */
|
|
11
|
+
readonly link: "link h-auto min-h-0 rounded-none px-0 font-normal";
|
|
12
|
+
/** Raised surface with destructive ink. Use only for irreversible actions. */
|
|
13
|
+
readonly destructive: "material-raised text-destructive data-disabled:data-popup-open:bg-control-surface";
|
|
14
|
+
};
|
|
15
|
+
declare const sizes: {
|
|
16
|
+
readonly sm: "min-h-(--control-h-sm) gap-1.5 px-3 text-[13px]";
|
|
17
|
+
readonly default: "min-h-(--control-h) gap-2 px-4 text-sm";
|
|
18
|
+
readonly lg: "min-h-(--control-h-lg) gap-2 px-5 text-[15px]";
|
|
19
|
+
readonly icon: "size-(--icon-button) rounded-full p-0";
|
|
20
|
+
readonly "icon-sm": "size-(--control-h-sm) rounded-full p-0";
|
|
21
|
+
};
|
|
22
|
+
export type ButtonVariant = keyof typeof variants;
|
|
23
|
+
export type ButtonSize = keyof typeof sizes;
|
|
24
|
+
export interface ButtonProps extends BaseButton.Props {
|
|
25
|
+
variant?: ButtonVariant;
|
|
26
|
+
size?: ButtonSize;
|
|
27
|
+
/**
|
|
28
|
+
* Fold the label away to leave only the icon when the button's row runs out of room, and
|
|
29
|
+
* unfold it when there is room again — animated, the last collapsible button in the row
|
|
30
|
+
* first. The row is the nearest ancestor with `data-collapse-row`, or the button's parent.
|
|
31
|
+
* Give it an icon and a text label; the label stays its accessible name. Not for icon sizes.
|
|
32
|
+
*/
|
|
33
|
+
collapsible?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The opposite of `collapsible`, played by the pointer: what opens on hover or keyboard focus.
|
|
36
|
+
* `"label"` (or `true`) rests as a round icon button and shows the label beside the icon;
|
|
37
|
+
* `"icon"` rests as text and slides the icon in — before the text or after it, as you place it.
|
|
38
|
+
* On a touch screen it stays as it rests; the label is always its accessible name. It takes
|
|
39
|
+
* room as it opens, so give it some: the end of a row. Not for icon sizes.
|
|
40
|
+
*/
|
|
41
|
+
expandable?: boolean | "label" | "icon";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Button — Base UI `Button` in the zon material.
|
|
45
|
+
*
|
|
46
|
+
* Heights come from `min-height`, never padding: 30 dense · 38 default · 46 prominent.
|
|
47
|
+
* Icon sizes are circular and must have an `aria-label`. `collapsible` lets a button with an
|
|
48
|
+
* icon and a label fold to a round icon button when its row is too tight; `expandable` rests
|
|
49
|
+
* as that icon button and unfolds on hover or focus.
|
|
50
|
+
* Use `render={<a href="…" />}` with `nativeButton={false}` for links styled as buttons.
|
|
51
|
+
*/
|
|
52
|
+
export declare function Button({ variant, size, collapsible, expandable, className, children, ref, ...props }: ButtonProps): React.JSX.Element;
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Button as BaseButton } from "@base-ui/react/button";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { sx } from "../lib/cn.js";
|
|
6
|
+
import { useCollapsible } from "../lib/collapse-row.js";
|
|
7
|
+
import { mergeRefs } from "../lib/merge-refs.js";
|
|
8
|
+
/* The raised material fills a trigger whose popup is open; a disabled button explaining itself with
|
|
9
|
+
a tooltip stays at rest instead. */
|
|
10
|
+
const variants = {
|
|
11
|
+
/** The layered primary. One per view — the action that carries the page. */
|
|
12
|
+
primary: "material-primary",
|
|
13
|
+
/** Raised quiet surface. Every other action. */
|
|
14
|
+
secondary: "material-raised data-disabled:data-popup-open:bg-control-surface",
|
|
15
|
+
/** Flat until hovered, then raised. Toolbars and dense rows. */
|
|
16
|
+
ghost: "material-row",
|
|
17
|
+
/** Inline text action with the brand underline. */
|
|
18
|
+
link: "link h-auto min-h-0 rounded-none px-0 font-normal",
|
|
19
|
+
/** Raised surface with destructive ink. Use only for irreversible actions. */
|
|
20
|
+
destructive: "material-raised text-destructive data-disabled:data-popup-open:bg-control-surface",
|
|
21
|
+
};
|
|
22
|
+
const sizes = {
|
|
23
|
+
sm: "min-h-(--control-h-sm) gap-1.5 px-3 text-[13px]",
|
|
24
|
+
default: "min-h-(--control-h) gap-2 px-4 text-sm",
|
|
25
|
+
lg: "min-h-(--control-h-lg) gap-2 px-5 text-[15px]",
|
|
26
|
+
icon: "size-(--icon-button) rounded-full p-0",
|
|
27
|
+
"icon-sm": "size-(--control-h-sm) rounded-full p-0",
|
|
28
|
+
};
|
|
29
|
+
/*
|
|
30
|
+
* A collapsible button carries the icon–label gap inside its label (--button-gap), so nothing
|
|
31
|
+
* of it is left once the label folds away. Folded, its padding and corners make a circle as
|
|
32
|
+
* tall as the button (parts/controls.css), moving on the material's --material-motion slot.
|
|
33
|
+
*/
|
|
34
|
+
const collapsibleGaps = {
|
|
35
|
+
sm: "[--button-gap:--spacing(1.5)]",
|
|
36
|
+
default: "[--button-gap:--spacing(2)]",
|
|
37
|
+
lg: "[--button-gap:--spacing(2)]",
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* For `expandable="icon"`: icons (and other elements) go into a column that opens on hover; the
|
|
41
|
+
* text stays as it is.
|
|
42
|
+
*/
|
|
43
|
+
function withIcon(children) {
|
|
44
|
+
const parts = React.Children.toArray(children);
|
|
45
|
+
const firstText = parts.findIndex((part) => typeof part === "string" || typeof part === "number");
|
|
46
|
+
return parts.map((part, index) => typeof part === "string" || typeof part === "number" ? (part) : (_jsx("span", { "data-slot": "button-icon", "data-before-label": firstText === -1 || index < firstText ? "" : undefined, children: _jsx("span", { children: part }) }, index)));
|
|
47
|
+
}
|
|
48
|
+
const isText = (part) => typeof part === "string" || typeof part === "number";
|
|
49
|
+
/**
|
|
50
|
+
* Text children (a run of them, as `Save {count} items`) become one label that ends in "…" when
|
|
51
|
+
* the button is narrower than it; it stays the accessible name in full. Icons, a Kbd and other
|
|
52
|
+
* elements stay as they are, at their size. White space between elements is left out, as a flex
|
|
53
|
+
* row leaves it out.
|
|
54
|
+
*/
|
|
55
|
+
function withText(children) {
|
|
56
|
+
const parts = React.Children.toArray(children);
|
|
57
|
+
if (!parts.some(isText))
|
|
58
|
+
return children;
|
|
59
|
+
const out = [];
|
|
60
|
+
let run = "";
|
|
61
|
+
const flush = () => {
|
|
62
|
+
if (run.trim())
|
|
63
|
+
out.push(_jsx("span", { "data-slot": "button-text", className: "min-w-0 overflow-x-clip text-ellipsis", children: run }, `text-${out.length}`));
|
|
64
|
+
run = "";
|
|
65
|
+
};
|
|
66
|
+
for (const part of parts) {
|
|
67
|
+
if (isText(part))
|
|
68
|
+
run += part;
|
|
69
|
+
else {
|
|
70
|
+
flush();
|
|
71
|
+
out.push(part);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
flush();
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
/** Text children become the label that folds away; icons and other elements stay as they are. */
|
|
78
|
+
function withLabel(children) {
|
|
79
|
+
const parts = React.Children.toArray(children);
|
|
80
|
+
const iconFirst = parts.findIndex((part) => React.isValidElement(part)) <
|
|
81
|
+
parts.findIndex((part) => typeof part === "string" || typeof part === "number");
|
|
82
|
+
return parts.map((part, index) => typeof part === "string" || typeof part === "number" ? (_jsx("span", { "data-slot": "button-label", "data-after-icon": iconFirst ? "" : undefined, children: _jsx("span", { children: part }) }, index)) : (part));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Button — Base UI `Button` in the zon material.
|
|
86
|
+
*
|
|
87
|
+
* Heights come from `min-height`, never padding: 30 dense · 38 default · 46 prominent.
|
|
88
|
+
* Icon sizes are circular and must have an `aria-label`. `collapsible` lets a button with an
|
|
89
|
+
* icon and a label fold to a round icon button when its row is too tight; `expandable` rests
|
|
90
|
+
* as that icon button and unfolds on hover or focus.
|
|
91
|
+
* Use `render={<a href="…" />}` with `nativeButton={false}` for links styled as buttons.
|
|
92
|
+
*/
|
|
93
|
+
export function Button({ variant = "primary", size = "default", collapsible = false, expandable = false, className, children, ref, ...props }) {
|
|
94
|
+
const own = React.useRef(null);
|
|
95
|
+
const foldable = size !== "icon" && size !== "icon-sm";
|
|
96
|
+
const expands = !foldable || !expandable ? null : expandable === "icon" ? "icon" : "label";
|
|
97
|
+
const canExpand = expands === "label";
|
|
98
|
+
const canCollapse = collapsible && foldable && !expands;
|
|
99
|
+
const { collapsed, ready } = useCollapsible(own, canCollapse);
|
|
100
|
+
// An expandable button rests folded; hover and focus unfold it in CSS (parts/controls.css).
|
|
101
|
+
const folds = canCollapse || canExpand || expands === "icon";
|
|
102
|
+
const labelled = foldable && !folds && React.Children.toArray(children).some(isText);
|
|
103
|
+
const refs = React.useMemo(() => mergeRefs(own, ref), [ref]);
|
|
104
|
+
// A link drawn as a button stays a link: Base UI gives every non-<button> element
|
|
105
|
+
// role="button", which would announce navigation as an action.
|
|
106
|
+
const link = React.isValidElement(props.render) && props.render.type === "a" && !("role" in props);
|
|
107
|
+
return (_jsx(BaseButton, { ...(link ? { role: undefined } : {}), "data-slot": "button", "data-variant": variant, "data-size": size, "data-collapsible": canCollapse ? "" : undefined, "data-collapsed": collapsed || canExpand ? "" : undefined, "data-expandable": expands ?? undefined, "data-collapse-instant": canCollapse && !ready ? "" : undefined, ref: refs, className: sx([
|
|
108
|
+
"inline-flex cursor-pointer items-center justify-center rounded-button font-body leading-none font-medium whitespace-nowrap focus-ring select-none",
|
|
109
|
+
// Only a natively disabled button ignores the pointer. One that stays focusable while
|
|
110
|
+
// disabled (`focusableWhenDisabled`, a link) still takes hover, so a tooltip can say
|
|
111
|
+
// why; Base UI keeps its clicks inert.
|
|
112
|
+
"disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
113
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
114
|
+
// A button with a text label never grows past its container: the text ends in "…"
|
|
115
|
+
// instead (withText). In a row it keeps its full width while a neighbour can give way —
|
|
116
|
+
// a title that wraps, a field — and is cut only when its label alone is wider than the
|
|
117
|
+
// row; add `min-w-0` to let it shrink with its neighbours. An icon button (or a square
|
|
118
|
+
// segment holding only an icon) keeps its size, and a folding one its width, since it
|
|
119
|
+
// folds instead (lib/collapse-row).
|
|
120
|
+
labelled ? "max-w-full" : "shrink-0",
|
|
121
|
+
sizes[size],
|
|
122
|
+
folds && [
|
|
123
|
+
"gap-0 data-collapse-instant:transition-none!",
|
|
124
|
+
// The fold's padding and corners; an expandable button waits out its hover intent first.
|
|
125
|
+
"[--material-motion:padding_calc(var(--duration)*2)_var(--ease)_var(--expand-delay,0s),border-radius_calc(var(--duration)*2)_var(--ease)_var(--expand-delay,0s)]",
|
|
126
|
+
collapsibleGaps[size],
|
|
127
|
+
],
|
|
128
|
+
variants[variant],
|
|
129
|
+
], className), ...props, children: expands === "icon" ? withIcon(children) : folds ? withLabel(children) : withText(children) }));
|
|
130
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { DayPicker } from "react-day-picker";
|
|
3
|
+
export type { DateRange, DayPickerLocale as CalendarLocale, Matcher as CalendarMatcher, } from "react-day-picker";
|
|
4
|
+
export type CalendarProps = React.ComponentProps<typeof DayPicker> & {
|
|
5
|
+
/**
|
|
6
|
+
* How the month and year dropdowns of `captionLayout="dropdown"` are drawn. `native` (the
|
|
7
|
+
* default) is a dense `NativeSelect`: the platform's own picker, best on phones. `custom` is
|
|
8
|
+
* our `Select`: a menu-material popup that opens on the current value, matching the page.
|
|
9
|
+
*/
|
|
10
|
+
dropdown?: "native" | "custom";
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Calendar — react-day-picker v10 in the zon material. The month caption is set in Licht,
|
|
14
|
+
* weekdays are 11px mono eyebrows and days are 38px cells with 7px corners and Licht Sans tabular
|
|
15
|
+
* figures. Hovering a day lifts it like a row; the selected day takes the layered primary
|
|
16
|
+
* fill; a range's middle days sit on the hover fill with their inner corners collapsed.
|
|
17
|
+
*
|
|
18
|
+
* Supports `mode="single" | "multiple" | "range"`, `captionLayout="dropdown"` (with
|
|
19
|
+
* `dropdown="native" | "custom"` for a `NativeSelect` or our `Select`), `locale`
|
|
20
|
+
* (pass a locale from `react-day-picker/locale` for translated labels) and `weekStartsOn`.
|
|
21
|
+
* Inside a right-to-left `DirectionProvider` it runs right to left — the grid, the arrows and the
|
|
22
|
+
* arrow keys — also in a DatePicker's popover, which is rendered outside the page's `dir`.
|
|
23
|
+
* The rule people break: using a calendar to enter a date of birth — type it in an `Input`,
|
|
24
|
+
* or at least use `captionLayout="dropdown"` so nobody clicks back forty years.
|
|
25
|
+
*/
|
|
26
|
+
export declare function Calendar({ showOutsideDays, className, classNames, components, dropdown, dir, formatters, ...props }: CalendarProps): React.JSX.Element;
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useDirection } from "@base-ui/react/direction-provider";
|
|
4
|
+
import { Field as BaseField } from "@base-ui/react/field";
|
|
5
|
+
import { ChevronDownIcon, ChevronLeftIcon, ChevronRightIcon, ChevronUpIcon } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { DateLib, DayPicker, getDefaultClassNames, } from "react-day-picker";
|
|
8
|
+
import { cn } from "../lib/cn.js";
|
|
9
|
+
import { NativeSelect } from "./native-select.js";
|
|
10
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
|
|
11
|
+
/** The root's classes go through `className`, so a consumer's `className` can override them. */
|
|
12
|
+
const rootClassName = "relative w-fit p-3 font-body text-foreground";
|
|
13
|
+
/** Our classes per DayPicker part. Day and day-button states live in `styles/parts/inputs.css`. */
|
|
14
|
+
const calendarClassNames = {
|
|
15
|
+
// Months sit side by side while they fit the room the calendar has, and stack top-down when
|
|
16
|
+
// they do not — in a phone, a side panel or a narrow column alike, not only on narrow screens.
|
|
17
|
+
months: "relative flex flex-wrap justify-center gap-6",
|
|
18
|
+
month: "relative flex flex-col gap-2",
|
|
19
|
+
nav: "pointer-events-none absolute inset-x-0 top-0 z-10 flex h-(--control-h) items-center justify-between",
|
|
20
|
+
// The arrows travel with their months (navLayout "around"): previous on the first month's
|
|
21
|
+
// caption, next on the last one's, so stacked months keep each arrow beside its month.
|
|
22
|
+
button_previous: "pointer-events-auto absolute start-0 top-1 z-10 inline-flex size-(--control-h-sm) cursor-pointer items-center justify-center rounded-full material-row text-muted-foreground focus-ring aria-disabled:pointer-events-none aria-disabled:opacity-40",
|
|
23
|
+
button_next: "pointer-events-auto absolute end-0 top-1 z-10 inline-flex size-(--control-h-sm) cursor-pointer items-center justify-center rounded-full material-row text-muted-foreground focus-ring aria-disabled:pointer-events-none aria-disabled:opacity-40",
|
|
24
|
+
chevron: "size-4",
|
|
25
|
+
month_caption: "flex h-(--control-h) items-center justify-center px-8",
|
|
26
|
+
caption_label: "font-heading text-xl leading-none font-light tracking-[-0.02em] text-foreground select-none",
|
|
27
|
+
dropdowns: "flex items-center justify-center gap-1.5",
|
|
28
|
+
month_grid: "border-separate border-spacing-x-0 border-spacing-y-0.5",
|
|
29
|
+
weekdays: "",
|
|
30
|
+
// Tracked capitals suit scripts with letter case. The others (Arabic, Hebrew, Persian, CJK …)
|
|
31
|
+
// keep their own letters, untracked: tracking pulls joined letters apart.
|
|
32
|
+
weekday: "h-8 w-(--control-h) p-0 text-center align-middle font-mono text-[11px] leading-none font-normal tracking-[0.12em] text-muted-foreground uppercase select-none data-caseless:tracking-normal data-caseless:normal-case",
|
|
33
|
+
week_number_header: "h-8 w-8 p-0",
|
|
34
|
+
week_number: "w-8 p-0 text-center align-middle font-mono text-[11px] text-muted-foreground tabular-nums select-none",
|
|
35
|
+
week: "",
|
|
36
|
+
day: "",
|
|
37
|
+
day_button: "",
|
|
38
|
+
footer: "pt-3 text-[13px] leading-normal text-muted-foreground",
|
|
39
|
+
};
|
|
40
|
+
function mergeClassNames(custom) {
|
|
41
|
+
const defaults = getDefaultClassNames();
|
|
42
|
+
const merged = {};
|
|
43
|
+
for (const key of Object.keys(defaults)) {
|
|
44
|
+
merged[key] = key === "root" ? defaults.root : cn(defaults[key], calendarClassNames[key], custom?.[key]);
|
|
45
|
+
}
|
|
46
|
+
return merged;
|
|
47
|
+
}
|
|
48
|
+
function CalendarRoot({ rootRef, className, ...props }) {
|
|
49
|
+
return _jsx("div", { ref: rootRef, "data-slot": "calendar", className: className, ...props });
|
|
50
|
+
}
|
|
51
|
+
function CalendarChevron({ orientation = "left", className, size: _size, disabled: _disabled, ...props }) {
|
|
52
|
+
const Icon = orientation === "left"
|
|
53
|
+
? ChevronLeftIcon
|
|
54
|
+
: orientation === "right"
|
|
55
|
+
? ChevronRightIcon
|
|
56
|
+
: orientation === "up"
|
|
57
|
+
? ChevronUpIcon
|
|
58
|
+
: ChevronDownIcon;
|
|
59
|
+
return _jsx(Icon, { "aria-hidden": true, className: cn("size-4", className), ...props });
|
|
60
|
+
}
|
|
61
|
+
/** Weekday names in a script with letter case: Latin, Greek, Cyrillic, Armenian. */
|
|
62
|
+
const CASED_SCRIPT = /[\p{Script=Latin}\p{Script=Greek}\p{Script=Cyrillic}\p{Script=Armenian}]/u;
|
|
63
|
+
/** A weekday header tells the calendar that its name doesn't fit the column. */
|
|
64
|
+
const WeekdayTooWideContext = React.createContext(null);
|
|
65
|
+
/** The narrow weekday names ("S", "ح"): for a column too narrow for the short ones ("Su", "أحد"). */
|
|
66
|
+
function formatNarrowWeekday(weekday, options, dateLib) {
|
|
67
|
+
return (dateLib ?? new DateLib(options)).format(weekday, "ccccc");
|
|
68
|
+
}
|
|
69
|
+
function CalendarWeekday({ children, ...props }) {
|
|
70
|
+
const ref = React.useRef(null);
|
|
71
|
+
const tooWide = React.useContext(WeekdayTooWideContext);
|
|
72
|
+
const text = typeof children === "string" ? children : "";
|
|
73
|
+
React.useLayoutEffect(() => {
|
|
74
|
+
const th = ref.current;
|
|
75
|
+
if (!th || !tooWide || !text)
|
|
76
|
+
return;
|
|
77
|
+
const measure = () => {
|
|
78
|
+
const column = th.getBoundingClientRect().width;
|
|
79
|
+
// Not laid out yet (a hidden tab, a closed popover kept mounted): measured once it is.
|
|
80
|
+
if (!column)
|
|
81
|
+
return false;
|
|
82
|
+
const range = document.createRange();
|
|
83
|
+
range.selectNodeContents(th);
|
|
84
|
+
// A name wider than its column widens it: it fits when it leaves 2px or more either side.
|
|
85
|
+
if (range.getBoundingClientRect().width > column - 4)
|
|
86
|
+
tooWide();
|
|
87
|
+
return true;
|
|
88
|
+
};
|
|
89
|
+
if (measure())
|
|
90
|
+
return;
|
|
91
|
+
const observer = new ResizeObserver(() => {
|
|
92
|
+
if (measure())
|
|
93
|
+
observer.disconnect();
|
|
94
|
+
});
|
|
95
|
+
observer.observe(th);
|
|
96
|
+
return () => observer.disconnect();
|
|
97
|
+
}, [text, tooWide]);
|
|
98
|
+
return (_jsx("th", { ref: ref, "data-caseless": (text && !CASED_SCRIPT.test(text)) || undefined, ...props, children: children }));
|
|
99
|
+
}
|
|
100
|
+
function CalendarDay({ day: _day, modifiers, className, ...props }) {
|
|
101
|
+
return (_jsx("td", { "data-slot": "calendar-day", "data-range-start": modifiers.range_start || undefined, "data-range-middle": modifiers.range_middle || undefined, "data-range-end": modifiers.range_end || undefined, className: className, ...props }));
|
|
102
|
+
}
|
|
103
|
+
function CalendarDayButton({ day: _day, modifiers, className, ...props }) {
|
|
104
|
+
const ref = React.useRef(null);
|
|
105
|
+
React.useEffect(() => {
|
|
106
|
+
if (modifiers.focused)
|
|
107
|
+
ref.current?.focus();
|
|
108
|
+
}, [modifiers.focused]);
|
|
109
|
+
const inRange = modifiers.range_start || modifiers.range_middle || modifiers.range_end;
|
|
110
|
+
return (_jsx("button", { ref: ref, "data-slot": "calendar-day-button", "data-selected-single": (modifiers.selected && !inRange) || undefined, "data-range-start": modifiers.range_start || undefined, "data-range-middle": modifiers.range_middle || undefined, "data-range-end": modifiers.range_end || undefined, "data-today": modifiers.today || undefined, "data-outside": modifiers.outside || undefined, "data-disabled": modifiers.disabled || undefined, className: className, ...props }));
|
|
111
|
+
}
|
|
112
|
+
/** Month and year dropdowns: our `NativeSelect` at 30px, isolated from any surrounding `Field`. */
|
|
113
|
+
function CalendarNativeDropdown({ options, className, size: _size, ...props }) {
|
|
114
|
+
return (_jsx(BaseField.Root, { "data-slot": "calendar-dropdown", className: "flex", children: _jsx(NativeSelect, { size: "sm", wrapperClassName: "w-auto", className: className, ...props, children: options?.map((option) => (_jsx("option", { value: option.value, disabled: option.disabled, children: option.label }, option.value))) }) }));
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Month and year dropdowns as our `Select` at 30px, isolated from any surrounding `Field`.
|
|
118
|
+
* DayPicker hands us a `<select>` change handler, so a picked value is passed back in the
|
|
119
|
+
* shape it reads (`event.target.value`).
|
|
120
|
+
*/
|
|
121
|
+
function CalendarSelectDropdown({ options = [], value, onChange, disabled, className, "aria-label": ariaLabel, }) {
|
|
122
|
+
const items = React.useMemo(() => options.map((option) => ({ value: String(option.value), label: option.label })), [options]);
|
|
123
|
+
return (_jsx(BaseField.Root, { "data-slot": "calendar-dropdown", className: "flex", children: _jsxs(Select, { items: items, value: value === undefined ? null : String(value), disabled: disabled, onValueChange: (next) => {
|
|
124
|
+
if (next == null)
|
|
125
|
+
return;
|
|
126
|
+
onChange?.({ target: { value: next } });
|
|
127
|
+
}, children: [_jsx(SelectTrigger, { size: "sm", "aria-label": ariaLabel, className: cn("w-auto min-w-0 tabular-nums", className), children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { positioner: { alignItemWithTrigger: true }, children: options.map((option) => (_jsx(SelectItem, { value: String(option.value), disabled: option.disabled, className: "tabular-nums", children: option.label }, option.value))) })] }) }));
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Calendar — react-day-picker v10 in the zon material. The month caption is set in Licht,
|
|
131
|
+
* weekdays are 11px mono eyebrows and days are 38px cells with 7px corners and Licht Sans tabular
|
|
132
|
+
* figures. Hovering a day lifts it like a row; the selected day takes the layered primary
|
|
133
|
+
* fill; a range's middle days sit on the hover fill with their inner corners collapsed.
|
|
134
|
+
*
|
|
135
|
+
* Supports `mode="single" | "multiple" | "range"`, `captionLayout="dropdown"` (with
|
|
136
|
+
* `dropdown="native" | "custom"` for a `NativeSelect` or our `Select`), `locale`
|
|
137
|
+
* (pass a locale from `react-day-picker/locale` for translated labels) and `weekStartsOn`.
|
|
138
|
+
* Inside a right-to-left `DirectionProvider` it runs right to left — the grid, the arrows and the
|
|
139
|
+
* arrow keys — also in a DatePicker's popover, which is rendered outside the page's `dir`.
|
|
140
|
+
* The rule people break: using a calendar to enter a date of birth — type it in an `Input`,
|
|
141
|
+
* or at least use `captionLayout="dropdown"` so nobody clicks back forty years.
|
|
142
|
+
*/
|
|
143
|
+
export function Calendar({ showOutsideDays = true, className, classNames, components, dropdown = "native", dir, formatters, ...props }) {
|
|
144
|
+
const direction = useDirection();
|
|
145
|
+
/*
|
|
146
|
+
* Weekday names too wide for their column — Arabic's short names are whole words — give way to
|
|
147
|
+
* the narrow ones, per locale. Measured before the first paint; your own weekday formatter is
|
|
148
|
+
* left alone.
|
|
149
|
+
*/
|
|
150
|
+
const localeCode = props.locale?.code ?? "";
|
|
151
|
+
const [narrowFor, setNarrowFor] = React.useState(null);
|
|
152
|
+
const ownFormatter = !!formatters?.formatWeekdayName;
|
|
153
|
+
const tooWide = React.useCallback(() => setNarrowFor(localeCode), [localeCode]);
|
|
154
|
+
const narrow = narrowFor === localeCode && !ownFormatter;
|
|
155
|
+
return (_jsx(WeekdayTooWideContext.Provider, { value: ownFormatter ? null : tooWide, children: _jsx(DayPicker, { navLayout: "around", dir: dir ?? (direction === "rtl" ? "rtl" : undefined), showOutsideDays: showOutsideDays, className: cn(rootClassName, classNames?.root, className), classNames: mergeClassNames(classNames), formatters: narrow ? { ...formatters, formatWeekdayName: formatNarrowWeekday } : formatters, components: {
|
|
156
|
+
Root: CalendarRoot,
|
|
157
|
+
Chevron: CalendarChevron,
|
|
158
|
+
Day: CalendarDay,
|
|
159
|
+
DayButton: CalendarDayButton,
|
|
160
|
+
Weekday: CalendarWeekday,
|
|
161
|
+
Dropdown: dropdown === "custom" ? CalendarSelectDropdown : CalendarNativeDropdown,
|
|
162
|
+
...components,
|
|
163
|
+
}, ...props }) }));
|
|
164
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
declare const cardVariants: {
|
|
4
|
+
/** An object on the page: the card material, 20px corners, the system's only drop shadow. */
|
|
5
|
+
readonly default: "surface-card";
|
|
6
|
+
/** A part of the page: the same material, square, no shadow, the card's padding. */
|
|
7
|
+
readonly square: "rounded-none surface-container p-[var(--card-padding,24px)] sm:p-[var(--card-padding,32px)] md:p-[var(--card-padding,40px)]";
|
|
8
|
+
/** No box: no border, no ground, no shadow — a top hairline and whitespace. */
|
|
9
|
+
readonly plain: "border-t border-border/60 pt-6 pb-8";
|
|
10
|
+
};
|
|
11
|
+
export type CardVariant = keyof typeof cardVariants;
|
|
12
|
+
export interface CardProps extends useRender.ComponentProps<"div"> {
|
|
13
|
+
/**
|
|
14
|
+
* `default`: an object, a 20px card with the soft shadow. `square`: a part of the page, the same
|
|
15
|
+
* material with square corners and no shadow. `plain`: no box at all, a top hairline and space.
|
|
16
|
+
*/
|
|
17
|
+
variant?: CardVariant;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Card — a group of content in one of three kinds. `default` is an **object** sitting *on* the
|
|
21
|
+
* page (a quote, a pricing option, a form panel): `surface-card` material, 20px radius, the
|
|
22
|
+
* system's only drop shadow, and responsive 24/32/40px padding that belongs to the card — never
|
|
23
|
+
* pad it at the call site. `square` is a **part of** the page (a section panel, a specimen sheet,
|
|
24
|
+
* a cover): the same material, square, no shadow. `plain` is **no box**: a top hairline and
|
|
25
|
+
* whitespace, for features, steps and principles laid out in a grid.
|
|
26
|
+
*
|
|
27
|
+
* Could it be picked up and moved somewhere else on its own? Yes → `default`. No → `square`.
|
|
28
|
+
* Would a rule and whitespace do? → `plain`, before either. The rule people break: wrapping
|
|
29
|
+
* content in a card because it feels tidier, or rounding a part of the page.
|
|
30
|
+
*/
|
|
31
|
+
export declare function Card({ variant, render, ref, className, ...props }: CardProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
32
|
+
/** Title + description stack at the top of a card. */
|
|
33
|
+
export declare function CardHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
34
|
+
/** The card's heading, in Licht. Renders an `<h3>`; use `render` for another level. */
|
|
35
|
+
export declare function CardTitle({ render, ref, className, ...props }: useRender.ComponentProps<"h3">): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
36
|
+
/** Supporting copy under the title. */
|
|
37
|
+
export declare function CardDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
38
|
+
/** The card's body. */
|
|
39
|
+
export declare function CardContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
40
|
+
/** Actions or meta at the bottom of a card. One primary at most. */
|
|
41
|
+
export declare function CardFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
42
|
+
export {};
|