@zonsh/ui 0.0.0-stage → 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 +76 -2
- 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 +189 -3
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Button as BaseButton } from "@base-ui/react/button";
|
|
4
|
+
import { Field as BaseField } from "@base-ui/react/field";
|
|
5
|
+
import { Input as BaseInput } from "@base-ui/react/input";
|
|
6
|
+
import { XIcon } from "lucide-react";
|
|
7
|
+
import * as React from "react";
|
|
8
|
+
import { cn, sx } from "../lib/cn.js";
|
|
9
|
+
import { mergeRefs } from "../lib/merge-refs.js";
|
|
10
|
+
import { cssDuration } from "../lib/motion.js";
|
|
11
|
+
const groupSizes = {
|
|
12
|
+
sm: "min-h-(--control-h-sm) text-[13px]",
|
|
13
|
+
default: "min-h-(--control-h) text-base sm:text-[15px]",
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* InputGroup — one recessed field that holds an input (or textarea) together with addons:
|
|
17
|
+
* an icon, a prefix like `https://`, a keyboard hint, a small button, or a toolbar under a
|
|
18
|
+
* textarea. The group wears the field material (10px corners, 38px or 30px dense); the control
|
|
19
|
+
* inside is borderless, and like any text field the group takes a softer edge on focus, no ring.
|
|
20
|
+
*
|
|
21
|
+
* Use it when the extra part belongs to the value: a search icon, a unit, a copy button. The
|
|
22
|
+
* rule people break: putting a separate action (Submit, Save) inside — that is a `Button`
|
|
23
|
+
* beside the field, or a `ButtonGroup`.
|
|
24
|
+
*/
|
|
25
|
+
export function InputGroup({ size = "default", className, ...props }) {
|
|
26
|
+
return (_jsx("div", { role: "group", "data-slot": "input-group", "data-size": size, className: cn("group/input-group relative flex w-full min-w-0 material-field items-center rounded-control font-body", groupSizes[size],
|
|
27
|
+
// Validation and disabled state come from the control (Field sets them there).
|
|
28
|
+
"has-[[data-slot=input-group-control][aria-invalid=true]]:border-destructive has-[[data-slot=input-group-control][data-invalid]]:border-destructive", "has-[[data-slot=input-group-control][aria-invalid=true]]:shadow-invalid has-[[data-slot=input-group-control][data-invalid]]:shadow-invalid", "has-[[data-slot=input-group-control]:disabled]:cursor-not-allowed has-[[data-slot=input-group-control]:disabled]:opacity-55",
|
|
29
|
+
// Block addons and textareas stack the group vertically.
|
|
30
|
+
"has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:flex-col has-[>textarea]:flex-col", "has-[>[data-align=block-end]]:items-stretch has-[>[data-align=block-start]]:items-stretch has-[>textarea]:items-stretch", "has-[>textarea]:min-h-[140px]", className), ...props }));
|
|
31
|
+
}
|
|
32
|
+
const controlBase = "min-w-0 flex-1 border-0 bg-transparent font-body text-foreground shadow-none outline-none placeholder:text-control-muted focus-visible:outline-none disabled:cursor-not-allowed";
|
|
33
|
+
/**
|
|
34
|
+
* The borderless input inside an `InputGroup`. Works inside `<Field>` like `Input`: the label,
|
|
35
|
+
* description and validation attach to it, and the group shows the state.
|
|
36
|
+
*/
|
|
37
|
+
export function InputGroupInput({ className, ...props }) {
|
|
38
|
+
return (_jsx(BaseInput, { "data-slot": "input-group-control", className: sx([
|
|
39
|
+
controlBase,
|
|
40
|
+
// Stretch to the group's height. No h-full: the group only has a min-height, and a
|
|
41
|
+
// percentage height there both resolves to the text's height and blocks the stretch,
|
|
42
|
+
// which left the text sitting at the top of the field.
|
|
43
|
+
"self-stretch px-3.5 group-data-[size=sm]/input-group:px-2.5",
|
|
44
|
+
// Tighten the padding next to an inline addon, which brings its own.
|
|
45
|
+
"group-has-[>[data-align=inline-end]]/input-group:pe-2 group-has-[>[data-align=inline-start]]/input-group:ps-2",
|
|
46
|
+
], className), ...props }));
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The borderless textarea inside an `InputGroup`. It has no resize handle: the handle would sit
|
|
50
|
+
* on the toolbar's edge inside the group. Instead it grows with its content (`field-sizing:
|
|
51
|
+
* content`, where supported) up to 240px, then scrolls. The group (with its toolbar) is at
|
|
52
|
+
* least 140px tall, like `Textarea`.
|
|
53
|
+
*/
|
|
54
|
+
export function InputGroupTextarea({ className, ...props }) {
|
|
55
|
+
return (_jsx(BaseField.Control, { "data-slot": "input-group-control", render: _jsx("textarea", {}), className: sx([
|
|
56
|
+
controlBase,
|
|
57
|
+
"field-sizing-content max-h-60 min-h-24 w-full resize-none px-3.5 py-3 text-base sm:text-[15px]",
|
|
58
|
+
"group-has-[>[data-align=block-end]]/input-group:pb-1.5 group-has-[>[data-align=block-start]]/input-group:pt-1.5",
|
|
59
|
+
], className), ...props }));
|
|
60
|
+
}
|
|
61
|
+
/* Inline addons pad the field's own edge: the start or end, so the sides swap in a right-to-left page. */
|
|
62
|
+
const addonAlign = {
|
|
63
|
+
"inline-start": "order-first ps-3.5 group-data-[size=sm]/input-group:ps-2.5 has-[>[data-slot=input-group-button]]:ps-[3px] group-data-[size=sm]/input-group:has-[>[data-slot=input-group-button]]:ps-0.5",
|
|
64
|
+
"inline-end": "order-last pe-3.5 group-data-[size=sm]/input-group:pe-2.5 has-[>[data-slot=input-group-button]]:pe-[3px] group-data-[size=sm]/input-group:has-[>[data-slot=input-group-button]]:pe-0.5",
|
|
65
|
+
"block-start": "order-first w-full justify-start px-3.5 pt-2.5 pb-1",
|
|
66
|
+
"block-end": "order-last w-full justify-start px-2 pt-1 pb-2",
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* An addon inside an `InputGroup`: an icon, `InputGroupText`, a `Kbd`, or `InputGroupButton`s.
|
|
70
|
+
* Clicking the addon's empty space focuses the control.
|
|
71
|
+
*/
|
|
72
|
+
export function InputGroupAddon({ align = "inline-start", className, onMouseDown, ...props }) {
|
|
73
|
+
return (_jsx("div", { "data-slot": "input-group-addon", "data-align": align, className: cn("flex h-auto shrink-0 cursor-text items-center gap-2 text-muted-foreground select-none", "[&>svg]:shrink-0 [&>svg:not([class*='size-'])]:size-4", "group-has-[[data-slot=input-group-control]:disabled]/input-group:cursor-not-allowed", addonAlign[align], className), onMouseDown: (event) => {
|
|
74
|
+
onMouseDown?.(event);
|
|
75
|
+
if (event.defaultPrevented)
|
|
76
|
+
return;
|
|
77
|
+
// Clicks on the addon's padding or icon focus the control, as on a native field — not
|
|
78
|
+
// clicks inside a popup it opened, which reach here through React's portal.
|
|
79
|
+
if (!event.currentTarget.contains(event.target))
|
|
80
|
+
return;
|
|
81
|
+
if (event.target.closest("button, a, input, select, textarea"))
|
|
82
|
+
return;
|
|
83
|
+
const control = event.currentTarget.parentElement?.querySelector("[data-slot=input-group-control]");
|
|
84
|
+
if (control) {
|
|
85
|
+
event.preventDefault();
|
|
86
|
+
control.focus();
|
|
87
|
+
}
|
|
88
|
+
}, ...props }));
|
|
89
|
+
}
|
|
90
|
+
/** Plain text inside an addon: a prefix, a suffix or a count. Licht Mono, muted, tabular. */
|
|
91
|
+
export function InputGroupText({ className, ...props }) {
|
|
92
|
+
return (_jsx("span", { "data-slot": "input-group-text", className: cn("flex items-center gap-1.5 font-mono text-[13px] whitespace-nowrap text-muted-foreground tabular-nums", "group-data-[size=sm]/input-group:text-xs [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-3.5", className), ...props }));
|
|
93
|
+
}
|
|
94
|
+
const buttonVariants = {
|
|
95
|
+
secondary: "material-raised",
|
|
96
|
+
ghost: "material-row text-muted-foreground",
|
|
97
|
+
primary: "material-primary",
|
|
98
|
+
};
|
|
99
|
+
const buttonSizes = {
|
|
100
|
+
/** 24px — fits the dense group, or a quiet action in the default one. */
|
|
101
|
+
sm: "min-h-(--control-inset-sm) gap-1 rounded-(--input-group-button-radius) px-2 text-xs",
|
|
102
|
+
/** 30px — fits the 38px group with a 3px inset, like a segment. */
|
|
103
|
+
default: "min-h-(--control-inset) gap-1.5 rounded-(--input-group-button-radius) px-2.5 text-[13px]",
|
|
104
|
+
"icon-sm": "size-(--control-inset-sm) rounded-full p-0 [&_svg:not([class*='size-'])]:size-3.5",
|
|
105
|
+
icon: "size-(--control-inset) rounded-full p-0",
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* A small button sized to sit inside the group: 30px in the 38px field (a 3px inset, like the
|
|
109
|
+
* NumberField steppers), 24px in the dense one. Its corners are concentric with the field's:
|
|
110
|
+
* outer radius − inset = inner radius, so 7px in the default group and 8px in the dense one
|
|
111
|
+
* (see `--input-group-button-radius` in controls.css). Icon-only sizes are round and need
|
|
112
|
+
* `aria-label`.
|
|
113
|
+
*/
|
|
114
|
+
export function InputGroupButton({ variant = "secondary", size = "default", className, ...props }) {
|
|
115
|
+
return (_jsx(BaseButton, { "data-slot": "input-group-button", "data-variant": variant, "data-size": size, className: sx([
|
|
116
|
+
"inline-flex shrink-0 cursor-pointer items-center justify-center font-body leading-none font-medium whitespace-nowrap focus-ring select-none",
|
|
117
|
+
"data-disabled:pointer-events-none data-disabled:opacity-50",
|
|
118
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
119
|
+
buttonVariants[variant],
|
|
120
|
+
buttonSizes[size],
|
|
121
|
+
], className), ...props }));
|
|
122
|
+
}
|
|
123
|
+
/*
|
|
124
|
+
* The reveal sweeps: on a press, the field's new text — or its dots — is uncovered left to right
|
|
125
|
+
* behind a soft 32px edge, across the text itself rather than the whole field, on 2.2 × --duration
|
|
126
|
+
* with the press's ease-out (the brand ease spends most of its way in a frame or two, too soon to
|
|
127
|
+
* see). The value is there at once and the field stays usable, so revealing a password many times
|
|
128
|
+
* a day never means waiting. Only a press of the toggle plays it; reduced motion skips it.
|
|
129
|
+
*/
|
|
130
|
+
let measurer = null;
|
|
131
|
+
/** Where the field's text runs, in the input's own pixels: from its left padding to its end. */
|
|
132
|
+
function textSpan(input) {
|
|
133
|
+
const style = getComputedStyle(input);
|
|
134
|
+
measurer ??= document.createElement("canvas").getContext("2d");
|
|
135
|
+
const text = input.type === "password" ? "•".repeat(input.value.length) : input.value;
|
|
136
|
+
let width = 0;
|
|
137
|
+
if (measurer) {
|
|
138
|
+
measurer.font = style.font;
|
|
139
|
+
measurer.letterSpacing = style.letterSpacing;
|
|
140
|
+
width = measurer.measureText(text).width;
|
|
141
|
+
}
|
|
142
|
+
const left = parseFloat(style.paddingLeft) - input.scrollLeft;
|
|
143
|
+
return { left, right: Math.min(input.clientWidth, left + width), width: input.clientWidth };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* A mask twice the field's width with a soft edge at its middle, slid so the edge travels from
|
|
147
|
+
* just before the text's start to just past its end — or back, to erase it (`out`).
|
|
148
|
+
*/
|
|
149
|
+
function sweepFrames(input, out = false) {
|
|
150
|
+
const { left, right, width } = textSpan(input);
|
|
151
|
+
const soft = 16;
|
|
152
|
+
const mask = {
|
|
153
|
+
maskImage: `linear-gradient(90deg, #000 calc(50% - ${soft}px), transparent calc(50% + ${soft}px))`,
|
|
154
|
+
maskSize: `${width * 2}px 100%`,
|
|
155
|
+
maskRepeat: "no-repeat",
|
|
156
|
+
};
|
|
157
|
+
const frames = [
|
|
158
|
+
{ ...mask, maskPosition: `${left - soft - width}px 0` },
|
|
159
|
+
{ ...mask, maskPosition: `${right + soft - width}px 0` },
|
|
160
|
+
];
|
|
161
|
+
return out ? frames.reverse() : frames;
|
|
162
|
+
}
|
|
163
|
+
/** The input this part shares an InputGroup with. */
|
|
164
|
+
const groupInput = (el) => el
|
|
165
|
+
?.closest('[data-slot="input-group"]')
|
|
166
|
+
?.querySelector('input[data-slot="input-group-control"]') ?? null;
|
|
167
|
+
/**
|
|
168
|
+
* InputGroupPasswordToggle — the show/hide button for a password: a ghost icon button with an
|
|
169
|
+
* eye whose slash draws across it when the password is shown and draws back when it is hidden,
|
|
170
|
+
* the eye opening a gap along the slash as it passes, while the field's text sweeps into its
|
|
171
|
+
* new form behind a soft edge. It is a toggle button: one name, "Show password", and
|
|
172
|
+
* `aria-pressed` while the password is shown — a toggle's name never changes with its state.
|
|
173
|
+
* Switch the input's `type` with `visible`.
|
|
174
|
+
*/
|
|
175
|
+
export function InputGroupPasswordToggle({ visible, onVisibleChange, label, labels, ref, onClick, ...props }) {
|
|
176
|
+
const own = React.useRef(null);
|
|
177
|
+
const pressed = React.useRef(false);
|
|
178
|
+
const refs = React.useMemo(() => mergeRefs(own, ref), [ref]);
|
|
179
|
+
// After the press re-renders the input with its new type — and before that is painted, so the
|
|
180
|
+
// first frame seen is the animation's first frame, not the finished text — its text arrives.
|
|
181
|
+
React.useLayoutEffect(() => {
|
|
182
|
+
if (!pressed.current)
|
|
183
|
+
return;
|
|
184
|
+
pressed.current = false;
|
|
185
|
+
const input = groupInput(own.current);
|
|
186
|
+
if (!input)
|
|
187
|
+
return;
|
|
188
|
+
const duration = cssDuration(input) * 2.2;
|
|
189
|
+
if (!duration)
|
|
190
|
+
return;
|
|
191
|
+
input.animate(sweepFrames(input), { duration, easing: "cubic-bezier(0.33, 1, 0.68, 1)" });
|
|
192
|
+
}, [visible]);
|
|
193
|
+
return (_jsx(InputGroupButton, { ref: refs, "data-password-toggle": "", variant: "ghost", size: "icon", "aria-label": label ?? labels?.show ?? "Show password", "aria-pressed": visible, onClick: (event) => {
|
|
194
|
+
pressed.current = true;
|
|
195
|
+
onVisibleChange(!visible);
|
|
196
|
+
onClick?.(event);
|
|
197
|
+
}, ...props, children: _jsx(EyeSlashIcon, { slashed: visible }) }));
|
|
198
|
+
}
|
|
199
|
+
/*
|
|
200
|
+
* The eye from lucide, with its slash drawn rather than swapped: the slash and the gap it cuts in
|
|
201
|
+
* the eye (a mask stroke along the same line) share one dash, from just past 1 (not drawn) to 0
|
|
202
|
+
* (drawn), on 1.4 × --duration like the text's settle — instant under reduced motion.
|
|
203
|
+
*/
|
|
204
|
+
const slash = "m2 2 20 20";
|
|
205
|
+
const drawn = "transition-[stroke-dashoffset] duration-[calc(var(--duration)*1.4)] ease-(--ease)";
|
|
206
|
+
function EyeSlashIcon({ slashed }) {
|
|
207
|
+
const mask = React.useId().replace(/[^a-zA-Z0-9]/g, "");
|
|
208
|
+
// Hidden, the dash sits just before the line's start, so not even a round cap shows.
|
|
209
|
+
const offset = slashed ? 0 : 1.02;
|
|
210
|
+
return (_jsxs("svg", { "aria-hidden": true, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", "data-slashed": slashed ? "" : undefined, children: [_jsxs("mask", { id: mask, maskUnits: "userSpaceOnUse", x: "0", y: "0", width: "24", height: "24", children: [_jsx("rect", { width: "24", height: "24", fill: "white" }), _jsx("path", { d: slash, stroke: "black", strokeWidth: 5, pathLength: 1, strokeDasharray: "1 2", strokeDashoffset: offset, className: drawn })] }), _jsxs("g", { mask: `url(#${mask})`, children: [_jsx("path", { d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" }), _jsx("circle", { cx: "12", cy: "12", r: "3" })] }), _jsx("path", { d: slash, pathLength: 1, strokeDasharray: "1 2", strokeDashoffset: offset, className: drawn })] }));
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* InputGroupClearButton — empties the field it sits in, smoothly: the text is erased right to
|
|
214
|
+
* left behind a soft edge, as if typed away, then the value clears and focus returns to the
|
|
215
|
+
* field. The button fades out while the field is empty and back in when there is text, instead of
|
|
216
|
+
* popping in and out. Reduced motion clears at once.
|
|
217
|
+
*/
|
|
218
|
+
export function InputGroupClearButton({ onClear, label = "Clear", ref, className, ...props }) {
|
|
219
|
+
const own = React.useRef(null);
|
|
220
|
+
const refs = React.useMemo(() => mergeRefs(own, ref), [ref]);
|
|
221
|
+
const [empty, setEmpty] = React.useState(true);
|
|
222
|
+
const clearing = React.useRef(false);
|
|
223
|
+
// Whether there is anything to clear: after every render (a controlled value) and on input.
|
|
224
|
+
React.useLayoutEffect(() => {
|
|
225
|
+
const input = groupInput(own.current);
|
|
226
|
+
if (input && !clearing.current)
|
|
227
|
+
setEmpty(input.value === "");
|
|
228
|
+
});
|
|
229
|
+
React.useEffect(() => {
|
|
230
|
+
const input = groupInput(own.current);
|
|
231
|
+
if (!input)
|
|
232
|
+
return;
|
|
233
|
+
const sync = () => {
|
|
234
|
+
if (!clearing.current)
|
|
235
|
+
setEmpty(input.value === "");
|
|
236
|
+
};
|
|
237
|
+
// A form's reset changes the value without an input event, once its own event has passed.
|
|
238
|
+
let later = 0;
|
|
239
|
+
const reset = () => {
|
|
240
|
+
later = window.setTimeout(sync);
|
|
241
|
+
};
|
|
242
|
+
input.addEventListener("input", sync);
|
|
243
|
+
input.form?.addEventListener("reset", reset);
|
|
244
|
+
return () => {
|
|
245
|
+
clearTimeout(later);
|
|
246
|
+
input.removeEventListener("input", sync);
|
|
247
|
+
input.form?.removeEventListener("reset", reset);
|
|
248
|
+
};
|
|
249
|
+
}, []);
|
|
250
|
+
const clear = () => {
|
|
251
|
+
const input = groupInput(own.current);
|
|
252
|
+
if (!input || clearing.current)
|
|
253
|
+
return;
|
|
254
|
+
const done = () => {
|
|
255
|
+
if (onClear)
|
|
256
|
+
onClear();
|
|
257
|
+
else {
|
|
258
|
+
// An uncontrolled input: set its value as a person would, so React and Base UI hear it.
|
|
259
|
+
Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value")?.set?.call(input, "");
|
|
260
|
+
input.dispatchEvent(new Event("input", { bubbles: true }));
|
|
261
|
+
}
|
|
262
|
+
input.focus();
|
|
263
|
+
};
|
|
264
|
+
const duration = cssDuration(input) * 1.6;
|
|
265
|
+
if (!duration || input.value === "") {
|
|
266
|
+
done();
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
clearing.current = true;
|
|
270
|
+
setEmpty(true);
|
|
271
|
+
// Held at its end until the value is really gone, so the text never flashes back.
|
|
272
|
+
const erase = input.animate(sweepFrames(input, true), {
|
|
273
|
+
duration,
|
|
274
|
+
easing: "cubic-bezier(0.33, 1, 0.68, 1)",
|
|
275
|
+
fill: "forwards",
|
|
276
|
+
});
|
|
277
|
+
erase.onfinish = () => {
|
|
278
|
+
done();
|
|
279
|
+
const release = () => {
|
|
280
|
+
if (input.value !== "" && input.isConnected)
|
|
281
|
+
return void requestAnimationFrame(release);
|
|
282
|
+
erase.cancel();
|
|
283
|
+
clearing.current = false;
|
|
284
|
+
};
|
|
285
|
+
release();
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
return (_jsx(InputGroupButton, { ref: refs, "data-clear-button": "", "data-empty": empty ? "" : undefined, variant: "ghost", size: "icon", "aria-label": label, "aria-hidden": empty || undefined, tabIndex: empty ? -1 : undefined, onClick: clear, className: cn(
|
|
289
|
+
// The fade rides the material's own transition list (--material-motion), which a transition
|
|
290
|
+
// utility would replace.
|
|
291
|
+
"[--material-motion:opacity_var(--duration)_var(--ease),scale_var(--duration)_var(--ease)] data-empty:pointer-events-none data-empty:scale-75 data-empty:opacity-0", className), ...props, children: _jsx(XIcon, {}) }));
|
|
292
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Input as BaseInput } from "@base-ui/react/input";
|
|
2
|
+
declare const sizes: {
|
|
3
|
+
readonly sm: "min-h-(--control-h-sm) px-2.5 text-[13px] [&[type=file]]:p-0.5 file:h-6";
|
|
4
|
+
readonly default: "min-h-(--control-h) px-3.5 text-base sm:text-[15px] [&[type=file]]:p-[3px] file:h-(--control-h-sm)";
|
|
5
|
+
};
|
|
6
|
+
export interface InputProps extends Omit<BaseInput.Props, "size"> {
|
|
7
|
+
/** `sm` (30px) for dense surfaces; `default` (38px) everywhere else. */
|
|
8
|
+
size?: keyof typeof sizes;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Input — a recessed single-line field. 10px radius, 38px default, 30px dense, full width of
|
|
12
|
+
* its column. Text stays ≥16px on mobile to avoid iOS zoom. Place inside `<Field>` for label +
|
|
13
|
+
* validation. For more than a sentence, use `Textarea`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function Input({ size, className, ...props }: InputProps): import("react").JSX.Element;
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Input as BaseInput } from "@base-ui/react/input";
|
|
4
|
+
import { sx } from "../lib/cn.js";
|
|
5
|
+
const sizes = {
|
|
6
|
+
sm: "min-h-(--control-h-sm) px-2.5 text-[13px] [&[type=file]]:p-0.5 file:h-6",
|
|
7
|
+
default: "min-h-(--control-h) px-3.5 text-base sm:text-[15px] [&[type=file]]:p-[3px] file:h-(--control-h-sm)",
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Input — a recessed single-line field. 10px radius, 38px default, 30px dense, full width of
|
|
11
|
+
* its column. Text stays ≥16px on mobile to avoid iOS zoom. Place inside `<Field>` for label +
|
|
12
|
+
* validation. For more than a sentence, use `Textarea`.
|
|
13
|
+
*/
|
|
14
|
+
export function Input({ size = "default", className, ...props }) {
|
|
15
|
+
return (_jsx(BaseInput, { "data-slot": "input", "data-size": size, className: sx([
|
|
16
|
+
"w-full min-w-0 material-field rounded-control font-body outline-none",
|
|
17
|
+
// A file input's "Choose file" is a small raised button inside the field, inset like an
|
|
18
|
+
// InputGroup button (30px in 38, 24px in 30, 7px corners); the file name stays quiet.
|
|
19
|
+
"[&[type=file]]:cursor-pointer [&[type=file]]:text-muted-foreground",
|
|
20
|
+
"file:mr-3 file:cursor-pointer file:rounded-item file:border-0 file:bg-control-surface file:bg-linear-to-b file:from-control-inner-edge file:to-transparent file:px-3 file:font-body file:text-[13px] file:font-medium file:text-foreground file:shadow-raised file:hover:bg-control-hover",
|
|
21
|
+
// The search field's clear button (×) is a button: it takes the pointer.
|
|
22
|
+
"[&::-webkit-search-cancel-button]:cursor-pointer",
|
|
23
|
+
sizes[size],
|
|
24
|
+
], className), ...props }));
|
|
25
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { type SeparatorProps } from "./separator.js";
|
|
4
|
+
declare const itemVariants: {
|
|
5
|
+
/** Flat, no edge. Group with `ItemSeparator` hairlines. Lifts into the raised material on hover when it is a link. */
|
|
6
|
+
readonly default: "bg-transparent [&:is(a[href],button,[role=button],[role=link])]:hover:text-foreground [&:is(a[href],button,[role=button],[role=link])]:hover:shadow-raised";
|
|
7
|
+
/** A `--field-edge` border at 12px — a row that stands on its own. */
|
|
8
|
+
readonly outline: "border-field-edge bg-transparent [&:is(a[href],button,[role=button],[role=link])]:hover:shadow-highlight";
|
|
9
|
+
/** The raised key surface — a row that reads as a thing you can act on. Presses inward. */
|
|
10
|
+
readonly raised: "bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-raised [&:is(a[href],button,[role=button],[role=link])]:active:shadow-raised-pressed";
|
|
11
|
+
};
|
|
12
|
+
declare const itemSizes: {
|
|
13
|
+
/** 46px minimum: title + description. */
|
|
14
|
+
readonly default: "min-h-(--control-h-lg) gap-4 px-4 py-3";
|
|
15
|
+
/** 38px minimum: dense lists, settings rows. */
|
|
16
|
+
readonly sm: "min-h-(--control-h) gap-3 px-3 py-2";
|
|
17
|
+
};
|
|
18
|
+
export type ItemVariant = keyof typeof itemVariants;
|
|
19
|
+
export type ItemSize = keyof typeof itemSizes;
|
|
20
|
+
export interface ItemProps extends useRender.ComponentProps<"div"> {
|
|
21
|
+
variant?: ItemVariant;
|
|
22
|
+
size?: ItemSize;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Item — a flexible row: media, a title and description, and actions. For people, files,
|
|
26
|
+
* integrations, settings and search results.
|
|
27
|
+
*
|
|
28
|
+
* `default` is flat and grouped by hairlines; `outline` takes a `--field-edge` border at 12px;
|
|
29
|
+
* `raised` sits on the key surface. Rendered as a link or button (`render={<a href="…" />}`),
|
|
30
|
+
* any variant lifts on hover like a nav row; a static item never responds to the pointer.
|
|
31
|
+
* The rule people break: putting a button inside an item that is itself a link — make the
|
|
32
|
+
* row the link, or keep the row static and give it actions.
|
|
33
|
+
*/
|
|
34
|
+
export declare function Item({ variant, size, render, ref, className, ...props }: ItemProps): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
35
|
+
declare const itemMediaVariants: {
|
|
36
|
+
/** The child as is — an `Avatar`, a lucide icon at 20px. */
|
|
37
|
+
readonly default: "[&_svg:not([class*='size-'])]:size-5";
|
|
38
|
+
/** A raised 32px key with 7px corners holding a 16px icon. */
|
|
39
|
+
readonly icon: "size-8 rounded-item text-foreground [&_svg:not([class*='size-'])]:size-4 bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-raised";
|
|
40
|
+
/** A 40px thumbnail with 7px corners; the image covers it. */
|
|
41
|
+
readonly image: "size-10 overflow-hidden rounded-item ring-1 ring-field-edge [&_img]:size-full [&_img]:object-cover";
|
|
42
|
+
};
|
|
43
|
+
export type ItemMediaVariant = keyof typeof itemMediaVariants;
|
|
44
|
+
export interface ItemMediaProps extends React.ComponentProps<"div"> {
|
|
45
|
+
variant?: ItemMediaVariant;
|
|
46
|
+
}
|
|
47
|
+
/** The leading visual: an avatar or icon (`default`), a raised icon key (`icon`) or a thumbnail (`image`). */
|
|
48
|
+
export declare function ItemMedia({ variant, className, ...props }: ItemMediaProps): React.JSX.Element;
|
|
49
|
+
/** The text column: title and description. Takes the remaining width. */
|
|
50
|
+
export declare function ItemContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
51
|
+
/** The row's name. Licht Sans 14px medium; a `Tag` can sit beside it. */
|
|
52
|
+
export declare function ItemTitle({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
53
|
+
/** One or two lines of muted detail; clamped at two. */
|
|
54
|
+
export declare function ItemDescription({ className, ...props }: React.ComponentProps<"p">): React.JSX.Element;
|
|
55
|
+
/** Trailing actions or meta: small buttons, a `Switch`, a `Tag`, a mono value. */
|
|
56
|
+
export declare function ItemActions({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
57
|
+
export declare function ItemGroup({ render, ref, className, ...props }: useRender.ComponentProps<"div">): React.JSX.Element;
|
|
58
|
+
/**
|
|
59
|
+
* The hairline between items in a group — `Separator`, with the group's rhythm.
|
|
60
|
+
* In a list group (`render={<ul />}`) it becomes an `aria-hidden` `<li>` wrapping the rule: a
|
|
61
|
+
* `<ul>` may only hold list items, and a divider between them is noise to a screen reader.
|
|
62
|
+
*/
|
|
63
|
+
export declare function ItemSeparator({ className, ...props }: SeparatorProps): React.JSX.Element;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
import { Separator } from "./separator.js";
|
|
7
|
+
/** The static raised key surface, shared by the `raised` variant and the `icon` media well. */
|
|
8
|
+
const raised = "bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-raised";
|
|
9
|
+
/*
|
|
10
|
+
* Interactive items — rendered as a link or a button — lift on hover like a nav row. The
|
|
11
|
+
* arbitrary variant keeps a static item (a div, an li, a label) from reacting to the pointer.
|
|
12
|
+
*/
|
|
13
|
+
const interactive = [
|
|
14
|
+
"[&:is(a[href],button,[role=button],[role=link])]:cursor-pointer",
|
|
15
|
+
"[&:is(a[href],button,[role=button],[role=link])]:hover:bg-control-hover",
|
|
16
|
+
"[&:is(a[href],button,[role=button],[role=link])]:hover:bg-linear-to-b",
|
|
17
|
+
"[&:is(a[href],button,[role=button],[role=link])]:hover:from-control-inner-edge",
|
|
18
|
+
"[&:is(a[href],button,[role=button],[role=link])]:hover:to-transparent",
|
|
19
|
+
"aria-disabled:pointer-events-none aria-disabled:opacity-55 data-disabled:pointer-events-none data-disabled:opacity-55",
|
|
20
|
+
].join(" ");
|
|
21
|
+
const itemVariants = {
|
|
22
|
+
/** Flat, no edge. Group with `ItemSeparator` hairlines. Lifts into the raised material on hover when it is a link. */
|
|
23
|
+
default: "bg-transparent [&:is(a[href],button,[role=button],[role=link])]:hover:text-foreground [&:is(a[href],button,[role=button],[role=link])]:hover:shadow-raised",
|
|
24
|
+
/** A `--field-edge` border at 12px — a row that stands on its own. */
|
|
25
|
+
outline: "border-field-edge bg-transparent [&:is(a[href],button,[role=button],[role=link])]:hover:shadow-highlight",
|
|
26
|
+
/** The raised key surface — a row that reads as a thing you can act on. Presses inward. */
|
|
27
|
+
raised: `${raised} [&:is(a[href],button,[role=button],[role=link])]:active:shadow-raised-pressed`,
|
|
28
|
+
};
|
|
29
|
+
const itemSizes = {
|
|
30
|
+
/** 46px minimum: title + description. */
|
|
31
|
+
default: "min-h-(--control-h-lg) gap-4 px-4 py-3",
|
|
32
|
+
/** 38px minimum: dense lists, settings rows. */
|
|
33
|
+
sm: "min-h-(--control-h) gap-3 px-3 py-2",
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Item — a flexible row: media, a title and description, and actions. For people, files,
|
|
37
|
+
* integrations, settings and search results.
|
|
38
|
+
*
|
|
39
|
+
* `default` is flat and grouped by hairlines; `outline` takes a `--field-edge` border at 12px;
|
|
40
|
+
* `raised` sits on the key surface. Rendered as a link or button (`render={<a href="…" />}`),
|
|
41
|
+
* any variant lifts on hover like a nav row; a static item never responds to the pointer.
|
|
42
|
+
* The rule people break: putting a button inside an item that is itself a link — make the
|
|
43
|
+
* row the link, or keep the row static and give it actions.
|
|
44
|
+
*/
|
|
45
|
+
export function Item({ variant = "default", size = "default", render, ref, className, ...props }) {
|
|
46
|
+
return useRender({
|
|
47
|
+
defaultTagName: "div",
|
|
48
|
+
render,
|
|
49
|
+
ref,
|
|
50
|
+
props: {
|
|
51
|
+
"data-slot": "item",
|
|
52
|
+
"data-variant": variant,
|
|
53
|
+
"data-size": size,
|
|
54
|
+
...props,
|
|
55
|
+
className: cn("group/item flex w-full flex-wrap items-center rounded-button border border-transparent text-start text-sm text-foreground no-underline focus-ring sm:flex-nowrap", "transition-[background-color,color,box-shadow] duration-(--duration) ease-(--ease)", interactive, itemSizes[size], itemVariants[variant], className),
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const itemMediaVariants = {
|
|
60
|
+
/** The child as is — an `Avatar`, a lucide icon at 20px. */
|
|
61
|
+
default: "[&_svg:not([class*='size-'])]:size-5",
|
|
62
|
+
/** A raised 32px key with 7px corners holding a 16px icon. */
|
|
63
|
+
icon: `size-8 rounded-item text-foreground [&_svg:not([class*='size-'])]:size-4 ${raised}`,
|
|
64
|
+
/** A 40px thumbnail with 7px corners; the image covers it. */
|
|
65
|
+
image: "size-10 overflow-hidden rounded-item ring-1 ring-field-edge [&_img]:size-full [&_img]:object-cover",
|
|
66
|
+
};
|
|
67
|
+
/** The leading visual: an avatar or icon (`default`), a raised icon key (`icon`) or a thumbnail (`image`). */
|
|
68
|
+
export function ItemMedia({ variant = "default", className, ...props }) {
|
|
69
|
+
return (_jsx("div", { "data-slot": "item-media", "data-variant": variant, className: cn("flex shrink-0 items-center justify-center self-center text-foreground-soft [&_svg]:pointer-events-none [&_svg]:shrink-0", "group-has-data-[slot=item-description]/item:translate-y-0.5 group-has-data-[slot=item-description]/item:self-start", itemMediaVariants[variant], className), ...props }));
|
|
70
|
+
}
|
|
71
|
+
/** The text column: title and description. Takes the remaining width. */
|
|
72
|
+
export function ItemContent({ className, ...props }) {
|
|
73
|
+
return (_jsx("div", { "data-slot": "item-content", className: cn("flex min-w-0 flex-1 flex-col gap-1", className), ...props }));
|
|
74
|
+
}
|
|
75
|
+
/** The row's name. Licht Sans 14px medium; a `Tag` can sit beside it. */
|
|
76
|
+
export function ItemTitle({ className, ...props }) {
|
|
77
|
+
return (_jsx("div", { "data-slot": "item-title", className: cn("flex w-fit items-center gap-2 leading-snug font-medium [overflow-wrap:anywhere] text-foreground", className), ...props }));
|
|
78
|
+
}
|
|
79
|
+
/** One or two lines of muted detail; clamped at two. */
|
|
80
|
+
export function ItemDescription({ className, ...props }) {
|
|
81
|
+
return (_jsx("p", { "data-slot": "item-description", className: cn("m-0 line-clamp-2 text-[13px] leading-normal [overflow-wrap:anywhere] text-muted-foreground [&_a]:link", className), ...props }));
|
|
82
|
+
}
|
|
83
|
+
/** Trailing actions or meta: small buttons, a `Switch`, a `Tag`, a mono value. */
|
|
84
|
+
export function ItemActions({ className, ...props }) {
|
|
85
|
+
return (_jsx("div", { "data-slot": "item-actions", className: cn("flex shrink-0 items-center gap-2", className), ...props }));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A stack of items. For a semantic list, render it as a list and each item as a list item:
|
|
89
|
+
* `<ItemGroup render={<ul />}>` with `<Item render={<li />}>`.
|
|
90
|
+
*/
|
|
91
|
+
const ItemListContext = React.createContext(false);
|
|
92
|
+
export function ItemGroup({ render, ref, className, ...props }) {
|
|
93
|
+
// Rendered as <ul>/<ol>, separators become <li role="separator"> so the list stays valid.
|
|
94
|
+
const isList = React.isValidElement(render) && (render.type === "ul" || render.type === "ol");
|
|
95
|
+
const element = useRender({
|
|
96
|
+
defaultTagName: "div",
|
|
97
|
+
render,
|
|
98
|
+
ref,
|
|
99
|
+
props: {
|
|
100
|
+
"data-slot": "item-group",
|
|
101
|
+
...props,
|
|
102
|
+
className: cn("m-0 flex w-full list-none flex-col gap-1 p-0", className),
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
return _jsx(ItemListContext.Provider, { value: isList, children: element });
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The hairline between items in a group — `Separator`, with the group's rhythm.
|
|
109
|
+
* In a list group (`render={<ul />}`) it becomes an `aria-hidden` `<li>` wrapping the rule: a
|
|
110
|
+
* `<ul>` may only hold list items, and a divider between them is noise to a screen reader.
|
|
111
|
+
*/
|
|
112
|
+
export function ItemSeparator({ className, ...props }) {
|
|
113
|
+
const inList = React.useContext(ItemListContext);
|
|
114
|
+
const rule = _jsx(Separator, { "data-slot": "item-separator", className: className, ...props });
|
|
115
|
+
return inList ? (_jsx("li", { "aria-hidden": "true", "data-slot": "item-separator-item", className: "list-none", children: rule })) : (rule);
|
|
116
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
import { formatShortcut, useShortcutKeys } from "../lib/platform.js";
|
|
3
|
+
export { formatShortcut, useShortcutKeys };
|
|
4
|
+
/**
|
|
5
|
+
* The key-cap look as a class string, for elements that must not be a `<kbd>` — e.g. an
|
|
6
|
+
* "Esc" hint that is really a close button: `<button className={kbdClassName}>Esc</button>`.
|
|
7
|
+
*/
|
|
8
|
+
export declare const kbdClassName: string;
|
|
9
|
+
/**
|
|
10
|
+
* Kbd — a keyboard key, as a raised mini key: Licht Mono 11px, 20px tall, 5px radius.
|
|
11
|
+
*
|
|
12
|
+
* Use it for shortcuts in menus, tooltips and docs ("Press ⌘ K"). One key per `Kbd`; group a
|
|
13
|
+
* chord with `KbdGroup`. The rule people break: using it for code or for labels — inline code
|
|
14
|
+
* is `<code>`, a label is a `Tag`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function Kbd({ className, ...props }: React.ComponentProps<"kbd">): React.JSX.Element;
|
|
17
|
+
/** A chord of keys, e.g. ⌘ + K. Renders a `<kbd>` wrapping one `Kbd` per key. */
|
|
18
|
+
export declare function KbdGroup({ className, ...props }: React.ComponentProps<"kbd">): React.JSX.Element;
|
|
19
|
+
export interface KbdShortcutProps extends Omit<React.ComponentProps<"kbd">, "children"> {
|
|
20
|
+
/**
|
|
21
|
+
* The chord, one key per item. `mod` is ⌘ on Apple devices and Ctrl elsewhere; `shift`,
|
|
22
|
+
* `alt`, `ctrl` and `enter` are written the way each keyboard prints them; anything else as
|
|
23
|
+
* given: `["mod", "K"]` is ⌘ K on a Mac, Ctrl K on Windows.
|
|
24
|
+
*/
|
|
25
|
+
keys: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* KbdShortcut — a shortcut written for the device it is on: ⌘ K on a Mac, iPhone or iPad,
|
|
29
|
+
* Ctrl K elsewhere, as a `KbdGroup` of `Kbd` keys. On a touch-only phone or tablet, where no
|
|
30
|
+
* key can be pressed, it renders nothing. Handle the keys the hint shows: `metaKey` on Apple
|
|
31
|
+
* devices, `ctrlKey` elsewhere — not either, since a Mac's Ctrl+B and Ctrl+K move the caret.
|
|
32
|
+
*/
|
|
33
|
+
export declare function KbdShortcut({ keys, ...props }: KbdShortcutProps): React.JSX.Element | null;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { formatShortcut, keyNames, useShortcutKeys } from "../lib/platform.js";
|
|
5
|
+
export { formatShortcut, useShortcutKeys };
|
|
6
|
+
/**
|
|
7
|
+
* The key-cap look as a class string, for elements that must not be a `<kbd>` — e.g. an
|
|
8
|
+
* "Esc" hint that is really a close button: `<button className={kbdClassName}>Esc</button>`.
|
|
9
|
+
*/
|
|
10
|
+
export const kbdClassName = cn(
|
|
11
|
+
// A key keeps its size in a tight row: squeezed, its label would spill over the next key.
|
|
12
|
+
"inline-flex min-h-5 min-w-5 shrink-0 items-center justify-center rounded-checkbox px-1.5 font-mono text-[11px] leading-none font-normal text-foreground-soft select-none", "bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-key", "[&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-3");
|
|
13
|
+
/**
|
|
14
|
+
* Kbd — a keyboard key, as a raised mini key: Licht Mono 11px, 20px tall, 5px radius.
|
|
15
|
+
*
|
|
16
|
+
* Use it for shortcuts in menus, tooltips and docs ("Press ⌘ K"). One key per `Kbd`; group a
|
|
17
|
+
* chord with `KbdGroup`. The rule people break: using it for code or for labels — inline code
|
|
18
|
+
* is `<code>`, a label is a `Tag`.
|
|
19
|
+
*/
|
|
20
|
+
export function Kbd({ className, ...props }) {
|
|
21
|
+
return _jsx("kbd", { "data-slot": "kbd", className: cn(kbdClassName, className), ...props });
|
|
22
|
+
}
|
|
23
|
+
/** A chord of keys, e.g. ⌘ + K. Renders a `<kbd>` wrapping one `Kbd` per key. */
|
|
24
|
+
export function KbdGroup({ className, ...props }) {
|
|
25
|
+
return _jsx("kbd", { "data-slot": "kbd-group", className: cn("inline-flex items-center gap-1", className), ...props });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* KbdShortcut — a shortcut written for the device it is on: ⌘ K on a Mac, iPhone or iPad,
|
|
29
|
+
* Ctrl K elsewhere, as a `KbdGroup` of `Kbd` keys. On a touch-only phone or tablet, where no
|
|
30
|
+
* key can be pressed, it renders nothing. Handle the keys the hint shows: `metaKey` on Apple
|
|
31
|
+
* devices, `ctrlKey` elsewhere — not either, since a Mac's Ctrl+B and Ctrl+K move the caret.
|
|
32
|
+
*/
|
|
33
|
+
export function KbdShortcut({ keys, ...props }) {
|
|
34
|
+
const { mod, hasKeyboard } = useShortcutKeys();
|
|
35
|
+
if (!hasKeyboard)
|
|
36
|
+
return null;
|
|
37
|
+
return (_jsx(KbdGroup, { ...props, children: keyNames(keys, mod).map((key, i) => (_jsx(Kbd, { children: key }, i))) }));
|
|
38
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
export type LabelProps = useRender.ComponentProps<"label">;
|
|
3
|
+
/**
|
|
4
|
+
* Label — a standalone `<label>` for a control that lives outside a `Field`: a switch in a
|
|
5
|
+
* toolbar, a checkbox in a table header, a native input in a third-party widget.
|
|
6
|
+
*
|
|
7
|
+
* Licht Sans 14px medium in foreground. It dims to 55% when the control it labels is disabled —
|
|
8
|
+
* either a following `peer` control, a control nested inside it, or a `group` marked
|
|
9
|
+
* `data-disabled`. The rule people break: using it inside a form. There, use `FieldLabel`,
|
|
10
|
+
* which wires the label, description and error to the control for you.
|
|
11
|
+
*/
|
|
12
|
+
export declare function Label({ render, ref, className, ...props }: LabelProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
/**
|
|
5
|
+
* Label — a standalone `<label>` for a control that lives outside a `Field`: a switch in a
|
|
6
|
+
* toolbar, a checkbox in a table header, a native input in a third-party widget.
|
|
7
|
+
*
|
|
8
|
+
* Licht Sans 14px medium in foreground. It dims to 55% when the control it labels is disabled —
|
|
9
|
+
* either a following `peer` control, a control nested inside it, or a `group` marked
|
|
10
|
+
* `data-disabled`. The rule people break: using it inside a form. There, use `FieldLabel`,
|
|
11
|
+
* which wires the label, description and error to the control for you.
|
|
12
|
+
*/
|
|
13
|
+
export function Label({ render, ref, className, ...props }) {
|
|
14
|
+
return useRender({
|
|
15
|
+
defaultTagName: "label",
|
|
16
|
+
render,
|
|
17
|
+
ref,
|
|
18
|
+
props: {
|
|
19
|
+
"data-slot": "label",
|
|
20
|
+
...props,
|
|
21
|
+
className: cn("inline-flex items-center gap-2.5 text-sm leading-snug font-medium text-foreground select-none", "peer-disabled:cursor-not-allowed peer-disabled:opacity-55 peer-data-disabled:cursor-not-allowed peer-data-disabled:opacity-55", "group-data-disabled:pointer-events-none group-data-disabled:opacity-55", "has-disabled:cursor-not-allowed has-disabled:opacity-55 has-data-disabled:cursor-not-allowed has-data-disabled:opacity-55", className),
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
}
|