@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,76 @@
|
|
|
1
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export type TimelineVariant = "activity" | "changelog";
|
|
4
|
+
export interface TimelineProps extends React.ComponentProps<"ol"> {
|
|
5
|
+
/**
|
|
6
|
+
* `activity` (default): a dense log — the actor and action on one line, the time at its end,
|
|
7
|
+
* 20px between entries. `changelog`: releases and milestones — the date as an eyebrow, the
|
|
8
|
+
* title in Licht, the body in reading type and 40px between entries.
|
|
9
|
+
*/
|
|
10
|
+
variant?: TimelineVariant;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Timeline — what happened, in order, on a hairline: an activity feed, a deal's history, a
|
|
14
|
+
* changelog, a project's milestones. Each entry is a dot (or a 24px icon key) on the line, a line
|
|
15
|
+
* of Licht Sans saying who did what, a mono time, and optionally a body — a comment, a changed
|
|
16
|
+
* field.
|
|
17
|
+
*
|
|
18
|
+
* The rule people break: colouring every dot. Markers are monochrome; a status colour marks the
|
|
19
|
+
* entries that are a status (a failed deploy, a won deal), and the entry's text says so too.
|
|
20
|
+
*/
|
|
21
|
+
export declare function Timeline({ variant, className, ...props }: TimelineProps): React.JSX.Element;
|
|
22
|
+
declare const dotStatus: {
|
|
23
|
+
readonly default: "bg-muted-foreground";
|
|
24
|
+
readonly success: "bg-success";
|
|
25
|
+
readonly warning: "bg-warning";
|
|
26
|
+
readonly info: "bg-info";
|
|
27
|
+
readonly destructive: "bg-destructive";
|
|
28
|
+
};
|
|
29
|
+
export type TimelineStatus = keyof typeof dotStatus;
|
|
30
|
+
export interface TimelineItemProps extends React.ComponentProps<"li"> {
|
|
31
|
+
/** A 14px lucide icon in a 24px raised key instead of the dot: the kind of event (a call, a commit). */
|
|
32
|
+
icon?: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Colours the dot or icon for an entry that is a status: `success` (shipped, won), `warning`,
|
|
35
|
+
* `info`, `destructive` (failed). Say it in the entry's text too — colour is never the only sign.
|
|
36
|
+
*/
|
|
37
|
+
status?: TimelineStatus;
|
|
38
|
+
/** Not happened yet — a planned milestone: a hollow dot, muted text and a dashed line to it. */
|
|
39
|
+
upcoming?: boolean;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* One entry. The marker sits on the first line; the hairline runs from it to the next entry's
|
|
43
|
+
* marker and stops at the last. Put a `TimelineTitle`, a `TimelineTime` and an optional
|
|
44
|
+
* `TimelineContent` inside.
|
|
45
|
+
*/
|
|
46
|
+
export declare function TimelineItem({ icon, status, upcoming, className, children, ...props }: TimelineItemProps): React.JSX.Element;
|
|
47
|
+
/**
|
|
48
|
+
* Who did what: "**Amara Okafor** moved the deal to Won". Licht Sans 14px in `activity`, with
|
|
49
|
+
* the actor in medium weight (`<strong>`); a Licht headline in `changelog`. A `<p>`; in a
|
|
50
|
+
* changelog pass `render={<h3 />}` so each release is a heading.
|
|
51
|
+
*/
|
|
52
|
+
export declare function TimelineTitle({ render, ref, className, ...props }: useRender.ComponentProps<"p">): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
53
|
+
/**
|
|
54
|
+
* When: "2h ago", "30 Sep", "v2.4 · 12 Aug 2026". Licht Mono 12px, muted, tabular. Give it the
|
|
55
|
+
* machine-readable `dateTime`. At the end of the title line in `activity`; above it, as an
|
|
56
|
+
* eyebrow, in `changelog`.
|
|
57
|
+
*/
|
|
58
|
+
export declare function TimelineTime({ className, ...props }: React.ComponentProps<"time">): React.JSX.Element;
|
|
59
|
+
/** The body under the title: a comment, a changed field, a list of what shipped. */
|
|
60
|
+
export declare function TimelineContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
61
|
+
/**
|
|
62
|
+
* A comment someone left, as a small 20px card under the entry — it could be quoted or moved on
|
|
63
|
+
* its own. Reading type, 12px by 16px padding.
|
|
64
|
+
*/
|
|
65
|
+
export declare function TimelineComment({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
66
|
+
export interface TimelineChangeProps extends Omit<React.ComponentProps<"p">, "children"> {
|
|
67
|
+
/** What changed: "Stage", "Price", "Assignee". */
|
|
68
|
+
field: React.ReactNode;
|
|
69
|
+
/** The old value. A string becomes a muted `Tag`; pass your own element to colour it. */
|
|
70
|
+
from?: React.ReactNode;
|
|
71
|
+
/** The new value. A string becomes a `Tag`; pass `<Tag variant="success">Won</Tag>` for a status. */
|
|
72
|
+
to: React.ReactNode;
|
|
73
|
+
}
|
|
74
|
+
/** A field that changed, as "Stage Proposal → Won": the field muted, the values as tags. */
|
|
75
|
+
export declare function TimelineChange({ field, from, to, className, ...props }: TimelineChangeProps): React.JSX.Element;
|
|
76
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
4
|
+
import { ArrowRightIcon } from "lucide-react";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { Tag } from "./tag.js";
|
|
8
|
+
const TimelineContext = React.createContext("activity");
|
|
9
|
+
/**
|
|
10
|
+
* Timeline — what happened, in order, on a hairline: an activity feed, a deal's history, a
|
|
11
|
+
* changelog, a project's milestones. Each entry is a dot (or a 24px icon key) on the line, a line
|
|
12
|
+
* of Licht Sans saying who did what, a mono time, and optionally a body — a comment, a changed
|
|
13
|
+
* field.
|
|
14
|
+
*
|
|
15
|
+
* The rule people break: colouring every dot. Markers are monochrome; a status colour marks the
|
|
16
|
+
* entries that are a status (a failed deploy, a won deal), and the entry's text says so too.
|
|
17
|
+
*/
|
|
18
|
+
export function Timeline({ variant = "activity", className, ...props }) {
|
|
19
|
+
return (_jsx(TimelineContext.Provider, { value: variant, children: _jsx("ol", { "data-slot": "timeline", "data-variant": variant, className: cn("m-0 flex w-full list-none flex-col p-0 font-body", className), ...props }) }));
|
|
20
|
+
}
|
|
21
|
+
/* Status inks, spelled out so Tailwind sees every class. */
|
|
22
|
+
const dotStatus = {
|
|
23
|
+
default: "bg-muted-foreground",
|
|
24
|
+
success: "bg-success",
|
|
25
|
+
warning: "bg-warning",
|
|
26
|
+
info: "bg-info",
|
|
27
|
+
destructive: "bg-destructive",
|
|
28
|
+
};
|
|
29
|
+
const iconStatus = {
|
|
30
|
+
default: "text-muted-foreground",
|
|
31
|
+
success: "text-success",
|
|
32
|
+
warning: "text-warning",
|
|
33
|
+
info: "text-info",
|
|
34
|
+
destructive: "text-destructive",
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* One entry. The marker sits on the first line; the hairline runs from it to the next entry's
|
|
38
|
+
* marker and stops at the last. Put a `TimelineTitle`, a `TimelineTime` and an optional
|
|
39
|
+
* `TimelineContent` inside.
|
|
40
|
+
*/
|
|
41
|
+
export function TimelineItem({ icon, status = "default", upcoming = false, className, children, ...props }) {
|
|
42
|
+
const variant = React.useContext(TimelineContext);
|
|
43
|
+
return (_jsxs("li", { "data-slot": "timeline-item", "data-status": status === "default" ? undefined : status, "data-upcoming": upcoming ? "" : undefined, className: cn("group/timeline-item relative grid grid-cols-[1.5rem_minmax(0,1fr)] gap-x-3",
|
|
44
|
+
// A line that leads to an upcoming entry is dashed: the future is not drawn solid.
|
|
45
|
+
"[&:has(+[data-upcoming])>[data-slot=timeline-connector]]:border-dashed", className), ...props, children: [_jsx("span", { "data-slot": "timeline-marker", "aria-hidden": true, className: "flex h-6 items-center justify-center", children: icon ? (_jsx("span", { className: cn("flex size-6 items-center justify-center rounded-full border border-transparent bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-key [&_svg]:size-3.5", iconStatus[status], upcoming && "opacity-60"), children: icon })) : (_jsx("span", { className: cn("size-2 rounded-full", upcoming ? "border border-muted-foreground bg-transparent" : dotStatus[status]) })) }), _jsx("span", { "data-slot": "timeline-connector", "aria-hidden": true, className: cn("absolute start-[calc(0.75rem-0.5px)] top-7 bottom-1 border-s border-border group-last/timeline-item:hidden", upcoming && "border-dashed") }), _jsx("div", { "data-slot": "timeline-body", className: cn("grid min-w-0 grid-cols-[minmax(0,1fr)_auto] content-start items-baseline gap-x-3", variant === "activity" ? "pb-5" : "pb-10", "group-last/timeline-item:pb-0", upcoming && "[&_[data-slot=timeline-title]]:text-muted-foreground"), children: children })] }));
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Who did what: "**Amara Okafor** moved the deal to Won". Licht Sans 14px in `activity`, with
|
|
49
|
+
* the actor in medium weight (`<strong>`); a Licht headline in `changelog`. A `<p>`; in a
|
|
50
|
+
* changelog pass `render={<h3 />}` so each release is a heading.
|
|
51
|
+
*/
|
|
52
|
+
export function TimelineTitle({ render, ref, className, ...props }) {
|
|
53
|
+
const variant = React.useContext(TimelineContext);
|
|
54
|
+
return useRender({
|
|
55
|
+
defaultTagName: "p",
|
|
56
|
+
render,
|
|
57
|
+
ref,
|
|
58
|
+
props: {
|
|
59
|
+
"data-slot": "timeline-title",
|
|
60
|
+
...props,
|
|
61
|
+
className: cn(
|
|
62
|
+
// A long word or link wraps in its column instead of running under the time.
|
|
63
|
+
"m-0 min-w-0 break-words", variant === "activity"
|
|
64
|
+
? "col-start-1 row-start-1 text-sm leading-6 text-foreground-soft [&_strong]:font-medium [&_strong]:text-foreground"
|
|
65
|
+
: "col-span-2 row-start-2 mt-1 display text-[22px] leading-[1.2] text-foreground sm:text-[24px]", className),
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* When: "2h ago", "30 Sep", "v2.4 · 12 Aug 2026". Licht Mono 12px, muted, tabular. Give it the
|
|
71
|
+
* machine-readable `dateTime`. At the end of the title line in `activity`; above it, as an
|
|
72
|
+
* eyebrow, in `changelog`.
|
|
73
|
+
*/
|
|
74
|
+
export function TimelineTime({ className, ...props }) {
|
|
75
|
+
const variant = React.useContext(TimelineContext);
|
|
76
|
+
return (_jsx("time", { "data-slot": "timeline-time", className: cn("font-mono text-xs leading-6 whitespace-nowrap text-muted-foreground tabular-nums", variant === "activity"
|
|
77
|
+
? "col-start-2 row-start-1 text-right"
|
|
78
|
+
: "col-span-2 row-start-1 tracking-[0.04em]", className), ...props }));
|
|
79
|
+
}
|
|
80
|
+
/** The body under the title: a comment, a changed field, a list of what shipped. */
|
|
81
|
+
export function TimelineContent({ className, ...props }) {
|
|
82
|
+
const variant = React.useContext(TimelineContext);
|
|
83
|
+
return (_jsx("div", { "data-slot": "timeline-content", className: cn("col-span-2 flex min-w-0 flex-col break-words", variant === "activity"
|
|
84
|
+
? "gap-2 pt-1.5 text-sm text-foreground-soft"
|
|
85
|
+
: "max-w-[68ch] gap-3 pt-3 text-[15px] leading-relaxed text-foreground-soft", className), ...props }));
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A comment someone left, as a small 20px card under the entry — it could be quoted or moved on
|
|
89
|
+
* its own. Reading type, 12px by 16px padding.
|
|
90
|
+
*/
|
|
91
|
+
export function TimelineComment({ className, ...props }) {
|
|
92
|
+
return (_jsx("div", { "data-slot": "timeline-comment", className: cn("surface-card text-sm leading-relaxed text-foreground-soft [--card-padding:12px_16px] [&>p]:m-0", className), ...props }));
|
|
93
|
+
}
|
|
94
|
+
/** A field that changed, as "Stage Proposal → Won": the field muted, the values as tags. */
|
|
95
|
+
export function TimelineChange({ field, from, to, className, ...props }) {
|
|
96
|
+
// A value longer than the line ends in an ellipsis inside its tag; the full text is still read.
|
|
97
|
+
const tag = (value, variant) => typeof value === "string" || typeof value === "number" ? (_jsx(Tag, { variant: variant, className: "max-w-full shrink", children: _jsx("span", { className: "min-w-0 truncate leading-normal", children: value }) })) : (value);
|
|
98
|
+
return (_jsxs("p", { "data-slot": "timeline-change", className: cn("m-0 flex flex-wrap items-center gap-x-2 gap-y-1 text-[13px] text-muted-foreground", className), ...props, children: [_jsx("span", { children: field }), from != null && (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: "from" }), tag(from, "muted"), _jsx(ArrowRightIcon, { "aria-hidden": true, className: "size-3.5 shrink-0 rtl:-scale-x-100" }), _jsx("span", { className: "sr-only", children: "to" })] })), tag(to, "default")] }));
|
|
99
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Toast as BaseToast, type ToastManager, type ToastManagerAddOptions, type ToastManagerPromiseOptions, type ToastManagerUpdateOptions, type ToastObject } from "@base-ui/react/toast";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export type ToastType = "default" | "success" | "warning" | "info" | "error" | "loading";
|
|
4
|
+
/** A button inside the toast: "Undo", "View". */
|
|
5
|
+
export interface ToastActionOptions {
|
|
6
|
+
label: React.ReactNode;
|
|
7
|
+
onClick: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface ToastOptions extends Omit<ToastManagerAddOptions<object>, "type" | "title"> {
|
|
10
|
+
type?: ToastType;
|
|
11
|
+
/** Shorthand for `actionProps: { children: label, onClick }`. */
|
|
12
|
+
action?: ToastActionOptions;
|
|
13
|
+
}
|
|
14
|
+
/** The `toast` API: call it for a default toast, or use a typed shortcut. */
|
|
15
|
+
export interface ToastApi {
|
|
16
|
+
(title: React.ReactNode, options?: ToastOptions): string;
|
|
17
|
+
/** A green check. The surface stays the menu material. */
|
|
18
|
+
success: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
19
|
+
/** An amber triangle: done, but something needs a look ("Saved, 2 images were too large"). */
|
|
20
|
+
warning: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
21
|
+
/** A blue info mark: neutral news ("A new version is available"). */
|
|
22
|
+
info: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
23
|
+
/** The same treatment in `--destructive`, announced urgently. */
|
|
24
|
+
error: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
25
|
+
/** Spinner, no auto-dismiss. Update it with `toast.update(id, { type: "success", … })`. */
|
|
26
|
+
loading: (title: React.ReactNode, options?: ToastOptions) => string;
|
|
27
|
+
/** loading → success / error, following a promise. */
|
|
28
|
+
promise: <Value>(promise: Promise<Value>, options: ToastManagerPromiseOptions<Value, object>) => Promise<Value>;
|
|
29
|
+
update: (id: string, options: Omit<ToastManagerUpdateOptions<object>, "type"> & {
|
|
30
|
+
type?: ToastType;
|
|
31
|
+
}) => void;
|
|
32
|
+
/** Close one toast, or all of them when called without an id. */
|
|
33
|
+
dismiss: (id?: string) => void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* toast — queue a toast from anywhere, including outside React (an API client, a store).
|
|
37
|
+
* Requires one `<Toaster />` mounted in the app; toasts sent before it mounts (from a page's
|
|
38
|
+
* mount effect, say) wait for it.
|
|
39
|
+
*
|
|
40
|
+
* toast.success("Your changes are saved.")
|
|
41
|
+
* toast.error("We couldn't send your message.", { description: "Check your connection and try again." })
|
|
42
|
+
* toast("Integration removed", { action: { label: "Undo", onClick: restore } })
|
|
43
|
+
*/
|
|
44
|
+
export declare const toast: ToastApi;
|
|
45
|
+
/**
|
|
46
|
+
* useToast — the same API as `toast`, bound to the nearest `<Toaster>` (render your tree as its
|
|
47
|
+
* children to use it), plus the live `toasts` array. Outside a Toaster it is the global `toast`,
|
|
48
|
+
* and `toasts` are those the global manager's Toaster shows.
|
|
49
|
+
*/
|
|
50
|
+
export declare function useToast(): ToastApi & {
|
|
51
|
+
toasts: ToastObject<object>[];
|
|
52
|
+
};
|
|
53
|
+
export interface ToasterProps extends Omit<BaseToast.Provider.Props, "toastManager"> {
|
|
54
|
+
/** Defaults to the library-wide manager behind `toast()`. */
|
|
55
|
+
toastManager?: ToastManager<object>;
|
|
56
|
+
/** Classes for the viewport (the fixed stack in the bottom-right corner). */
|
|
57
|
+
className?: string;
|
|
58
|
+
/** Accessible name of each toast's close button. */
|
|
59
|
+
closeLabel?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Toaster — Toast.Provider + Viewport: toasts stack in the bottom-right corner (bottom, full
|
|
63
|
+
* width on mobile), expand on hover or focus, and swipe away down or right. F6 jumps into the stack.
|
|
64
|
+
* Inside a right-to-left `DirectionProvider` they read right to left and the corner mirrors: they
|
|
65
|
+
* stack bottom-left and swipe away down or left.
|
|
66
|
+
*
|
|
67
|
+
* Mount it once near the root (extra Toasters on the same manager render nothing). Render the app
|
|
68
|
+
* as its children if you want `useToast()`.
|
|
69
|
+
* The rule people break: toasting what needs a decision. A toast disappears; anything the person
|
|
70
|
+
* must act on belongs in the page or an `AlertDialog`.
|
|
71
|
+
*/
|
|
72
|
+
export declare function Toaster({ toastManager, limit, className, closeLabel, children, ...props }: ToasterProps): React.JSX.Element;
|
|
@@ -0,0 +1,196 @@
|
|
|
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 { Toast as BaseToast, } from "@base-ui/react/toast";
|
|
5
|
+
import { CircleAlertIcon, CircleCheckIcon, InfoIcon, LoaderCircleIcon, TriangleAlertIcon, XIcon, } from "lucide-react";
|
|
6
|
+
import * as React from "react";
|
|
7
|
+
import { cn } from "../lib/cn.js";
|
|
8
|
+
function toAddOptions(title, { action, ...options } = {}) {
|
|
9
|
+
const add = { title, ...options };
|
|
10
|
+
if (action)
|
|
11
|
+
add.actionProps = { ...options.actionProps, children: action.label, onClick: action.onClick };
|
|
12
|
+
return add;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The toast API over a manager. With `listener` — the manager a `<Toaster>` subscribes to — calls
|
|
16
|
+
* made before any such Toaster has mounted wait for one (see `whenListening`).
|
|
17
|
+
*/
|
|
18
|
+
function createToastApi(manager, listener) {
|
|
19
|
+
let waiting = 0;
|
|
20
|
+
const later = (call) => (listener ? whenListening(listener, call) : call());
|
|
21
|
+
const add = (options) => {
|
|
22
|
+
if (!listener || isListening(listener))
|
|
23
|
+
return manager.add(options);
|
|
24
|
+
// The id is ours, so `update` and `dismiss` can name the toast before it shows.
|
|
25
|
+
const id = options.id ?? `toast-waiting-${++waiting}`;
|
|
26
|
+
later(() => manager.add({ ...options, id }));
|
|
27
|
+
return id;
|
|
28
|
+
};
|
|
29
|
+
const show = (title, options) => add(toAddOptions(title, options));
|
|
30
|
+
return Object.assign(show, {
|
|
31
|
+
success: (title, options) => show(title, { ...options, type: "success" }),
|
|
32
|
+
warning: (title, options) => show(title, { ...options, type: "warning" }),
|
|
33
|
+
info: (title, options) => show(title, { ...options, type: "info" }),
|
|
34
|
+
error: (title, options) => show(title, { priority: "high", ...options, type: "error" }),
|
|
35
|
+
loading: (title, options) => show(title, { timeout: 0, ...options, type: "loading" }),
|
|
36
|
+
promise: (promise, options) => {
|
|
37
|
+
if (!listener || isListening(listener))
|
|
38
|
+
return manager.promise(promise, options);
|
|
39
|
+
// The caller holds the promise itself; the copy the Toaster follows must not reject unheard.
|
|
40
|
+
later(() => void manager.promise(promise, options).catch(() => { }));
|
|
41
|
+
return promise;
|
|
42
|
+
},
|
|
43
|
+
update: (id, options) => later(() => manager.update(id, options)),
|
|
44
|
+
dismiss: (id) => later(() => manager.close(id)),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** The library-wide manager. `<Toaster />` renders it unless you pass your own `toastManager`. */
|
|
48
|
+
const globalToastManager = BaseToast.createToastManager();
|
|
49
|
+
/**
|
|
50
|
+
* toast — queue a toast from anywhere, including outside React (an API client, a store).
|
|
51
|
+
* Requires one `<Toaster />` mounted in the app; toasts sent before it mounts (from a page's
|
|
52
|
+
* mount effect, say) wait for it.
|
|
53
|
+
*
|
|
54
|
+
* toast.success("Your changes are saved.")
|
|
55
|
+
* toast.error("We couldn't send your message.", { description: "Check your connection and try again." })
|
|
56
|
+
* toast("Integration removed", { action: { label: "Undo", onClick: restore } })
|
|
57
|
+
*/
|
|
58
|
+
export const toast = createToastApi(globalToastManager, globalToastManager);
|
|
59
|
+
/** The manager of the nearest `<Toaster>`, so `useToast` adds through it rather than a local store. */
|
|
60
|
+
const ToasterManagerContext = React.createContext(null);
|
|
61
|
+
/**
|
|
62
|
+
* The nearest Toast.Provider's manager, or null outside one, where Base UI's hook throws. A
|
|
63
|
+
* component is inside a provider or not for as long as it is mounted, so its hooks keep their order.
|
|
64
|
+
*/
|
|
65
|
+
function useNearestToastManager() {
|
|
66
|
+
try {
|
|
67
|
+
return BaseToast.useToastManager();
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
const NO_TOASTS = [];
|
|
74
|
+
/**
|
|
75
|
+
* useToast — the same API as `toast`, bound to the nearest `<Toaster>` (render your tree as its
|
|
76
|
+
* children to use it), plus the live `toasts` array. Outside a Toaster it is the global `toast`,
|
|
77
|
+
* and `toasts` are those the global manager's Toaster shows.
|
|
78
|
+
*/
|
|
79
|
+
export function useToast() {
|
|
80
|
+
const shared = React.useContext(ToasterManagerContext);
|
|
81
|
+
const nearest = useNearestToastManager();
|
|
82
|
+
const shown = React.useSyncExternalStore(subscribeRegistry, () => shownToasts.get(globalToastManager) ?? NO_TOASTS, () => NO_TOASTS);
|
|
83
|
+
const { add, close, update, promise } = nearest ?? {};
|
|
84
|
+
const api = React.useMemo(() => shared
|
|
85
|
+
? createToastApi(shared, shared)
|
|
86
|
+
: add && close && update && promise
|
|
87
|
+
? createToastApi({ add, close, update, promise })
|
|
88
|
+
: createToastApi(globalToastManager, globalToastManager), [shared, add, close, update, promise]);
|
|
89
|
+
return Object.assign(api, { toasts: nearest?.toasts ?? shown });
|
|
90
|
+
}
|
|
91
|
+
/*
|
|
92
|
+
* Several <Toaster>s can share one manager (two demos on a page, a layout and a nested route).
|
|
93
|
+
* Only the first one mounted renders the stack, so a toast never appears twice.
|
|
94
|
+
*/
|
|
95
|
+
const toasterRegistry = new WeakMap();
|
|
96
|
+
/** The toasts each manager's primary Toaster shows: `useToast` outside a Toaster reads them. */
|
|
97
|
+
const shownToasts = new WeakMap();
|
|
98
|
+
const registryListeners = new Set();
|
|
99
|
+
const notifyRegistry = () => registryListeners.forEach((listener) => listener());
|
|
100
|
+
const subscribeRegistry = (listener) => {
|
|
101
|
+
registryListeners.add(listener);
|
|
102
|
+
return () => {
|
|
103
|
+
registryListeners.delete(listener);
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
/*
|
|
107
|
+
* A manager hands a toast only to the Toasters subscribed at that moment, so one sent from a page's
|
|
108
|
+
* mount effect — which runs before the effects of a Toaster placed after the page, or around it —
|
|
109
|
+
* would be dropped. Until a Toaster for the manager has mounted, calls wait here (the last 50) and
|
|
110
|
+
* play in order once one has. On the server nothing mounts: there they are dropped, as before.
|
|
111
|
+
*/
|
|
112
|
+
const waitingCalls = new WeakMap();
|
|
113
|
+
/** A Toaster for the manager has mounted and nothing sent earlier is still waiting. */
|
|
114
|
+
function isListening(manager) {
|
|
115
|
+
return (toasterRegistry.get(manager)?.length ?? 0) > 0 && !waitingCalls.has(manager);
|
|
116
|
+
}
|
|
117
|
+
function whenListening(manager, call) {
|
|
118
|
+
if (isListening(manager))
|
|
119
|
+
return call();
|
|
120
|
+
if (typeof window === "undefined")
|
|
121
|
+
return;
|
|
122
|
+
const queue = waitingCalls.get(manager) ?? [];
|
|
123
|
+
queue.push(call);
|
|
124
|
+
if (queue.length > 50)
|
|
125
|
+
queue.shift();
|
|
126
|
+
waitingCalls.set(manager, queue);
|
|
127
|
+
}
|
|
128
|
+
function playWaiting(manager) {
|
|
129
|
+
const queue = waitingCalls.get(manager);
|
|
130
|
+
if (!queue || !toasterRegistry.get(manager)?.length)
|
|
131
|
+
return;
|
|
132
|
+
waitingCalls.delete(manager);
|
|
133
|
+
queue.forEach((call) => call());
|
|
134
|
+
}
|
|
135
|
+
function useIsPrimaryToaster(manager) {
|
|
136
|
+
const [id] = React.useState(() => Symbol("toaster"));
|
|
137
|
+
React.useEffect(() => {
|
|
138
|
+
const list = toasterRegistry.get(manager) ?? [];
|
|
139
|
+
toasterRegistry.set(manager, [...list, id]);
|
|
140
|
+
notifyRegistry();
|
|
141
|
+
// The Provider below has subscribed by now (a child's effects run first). Play what waited a
|
|
142
|
+
// tick later, after StrictMode's check has re-run the effects: its unmount stops the timers.
|
|
143
|
+
queueMicrotask(() => playWaiting(manager));
|
|
144
|
+
return () => {
|
|
145
|
+
toasterRegistry.set(manager, (toasterRegistry.get(manager) ?? []).filter((entry) => entry !== id));
|
|
146
|
+
notifyRegistry();
|
|
147
|
+
};
|
|
148
|
+
}, [manager, id]);
|
|
149
|
+
return React.useSyncExternalStore(subscribeRegistry, () => toasterRegistry.get(manager)?.[0] === id, () => false);
|
|
150
|
+
}
|
|
151
|
+
/* ── Rendering ─────────────────────────────────────────────────────────────── */
|
|
152
|
+
const icons = {
|
|
153
|
+
default: null,
|
|
154
|
+
/* Status colour shows on the icon only: the title says what happened. */
|
|
155
|
+
success: _jsx(CircleCheckIcon, { "aria-hidden": true, className: "size-4 text-success" }),
|
|
156
|
+
warning: _jsx(TriangleAlertIcon, { "aria-hidden": true, className: "size-4 text-warning" }),
|
|
157
|
+
info: _jsx(InfoIcon, { "aria-hidden": true, className: "size-4 text-info" }),
|
|
158
|
+
error: _jsx(CircleAlertIcon, { "aria-hidden": true, className: "size-4 text-destructive" }),
|
|
159
|
+
loading: _jsx(LoaderCircleIcon, { "aria-hidden": true, className: "size-4 text-muted-foreground motion-safe:animate-spin" }),
|
|
160
|
+
};
|
|
161
|
+
function ToastItem({ toast: item, closeLabel, rtl }) {
|
|
162
|
+
const type = (item.type ?? "default");
|
|
163
|
+
const icon = icons[type] ?? null;
|
|
164
|
+
return (_jsx(BaseToast.Root, { toast: item, "data-slot": "toast", "data-type": type,
|
|
165
|
+
// Away from the page, toward the corner's edge: the left one in a right-to-left page.
|
|
166
|
+
swipeDirection: rtl ? ["down", "left"] : ["down", "right"], className: "rounded-button material-menu font-body outline-none", children: _jsxs(BaseToast.Content, { "data-slot": "toast-content", className: "flex items-start gap-3 overflow-hidden p-4 pe-11", children: [icon && _jsx("span", { className: "flex h-5 shrink-0 items-center", children: icon }), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-0.5 break-words", children: [_jsx(BaseToast.Title, { "data-slot": "toast-title", className: "font-body text-sm leading-5 font-medium tracking-normal text-foreground" }), _jsx(BaseToast.Description, { "data-slot": "toast-description", className: "text-[13px] leading-normal text-muted-foreground first:text-sm first:leading-5 first:text-foreground" }), _jsx(BaseToast.Action, { "data-slot": "toast-action", className: "mt-2.5 inline-flex min-h-(--control-h-sm) cursor-pointer items-center self-start rounded-button material-raised px-3 text-[13px] font-medium focus-ring" })] }), _jsx(BaseToast.Close, { "data-slot": "toast-close", "aria-label": closeLabel, className: "absolute end-3 top-3 inline-flex size-6 cursor-pointer items-center justify-center rounded-full material-row text-muted-foreground focus-ring", children: _jsx(XIcon, { "aria-hidden": true, className: "size-3.5" }) })] }) }));
|
|
167
|
+
}
|
|
168
|
+
function ToastList({ manager, closeLabel, rtl }) {
|
|
169
|
+
const { toasts } = BaseToast.useToastManager();
|
|
170
|
+
React.useLayoutEffect(() => {
|
|
171
|
+
shownToasts.set(manager, toasts);
|
|
172
|
+
notifyRegistry();
|
|
173
|
+
}, [manager, toasts]);
|
|
174
|
+
React.useLayoutEffect(() => () => {
|
|
175
|
+
shownToasts.delete(manager);
|
|
176
|
+
notifyRegistry();
|
|
177
|
+
}, [manager]);
|
|
178
|
+
return toasts.map((item) => _jsx(ToastItem, { toast: item, closeLabel: closeLabel, rtl: rtl }, item.id));
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Toaster — Toast.Provider + Viewport: toasts stack in the bottom-right corner (bottom, full
|
|
182
|
+
* width on mobile), expand on hover or focus, and swipe away down or right. F6 jumps into the stack.
|
|
183
|
+
* Inside a right-to-left `DirectionProvider` they read right to left and the corner mirrors: they
|
|
184
|
+
* stack bottom-left and swipe away down or left.
|
|
185
|
+
*
|
|
186
|
+
* Mount it once near the root (extra Toasters on the same manager render nothing). Render the app
|
|
187
|
+
* as its children if you want `useToast()`.
|
|
188
|
+
* The rule people break: toasting what needs a decision. A toast disappears; anything the person
|
|
189
|
+
* must act on belongs in the page or an `AlertDialog`.
|
|
190
|
+
*/
|
|
191
|
+
export function Toaster({ toastManager = globalToastManager, limit = 3, className, closeLabel = "Dismiss", children, ...props }) {
|
|
192
|
+
const primary = useIsPrimaryToaster(toastManager);
|
|
193
|
+
// The stack is portalled out of any `dir` element: it takes the direction from the provider.
|
|
194
|
+
const rtl = useDirection() === "rtl";
|
|
195
|
+
return (_jsxs(BaseToast.Provider, { toastManager: toastManager, limit: limit, ...props, children: [_jsx(ToasterManagerContext.Provider, { value: toastManager, children: children }), primary && (_jsx(BaseToast.Portal, { children: _jsx(BaseToast.Viewport, { "data-slot": "toast-viewport", dir: rtl ? "rtl" : undefined, className: cn("fixed bottom-4 z-[60] mx-auto w-[calc(100vw-2rem)] outline-none sm:bottom-6 sm:w-90", rtl ? "left-4 sm:left-6" : "right-4 sm:right-6", className), children: _jsx(ToastList, { manager: toastManager, closeLabel: closeLabel, rtl: rtl }) }) }))] }));
|
|
196
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Toggle as BaseToggle } from "@base-ui/react/toggle";
|
|
2
|
+
import { ToggleGroup as BaseToggleGroup } from "@base-ui/react/toggle-group";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
export interface ToggleGroupProps<Value extends string = string> extends BaseToggleGroup.Props<Value> {
|
|
5
|
+
/**
|
|
6
|
+
* In single mode (the default) one segment always stays pressed: clicking the current
|
|
7
|
+
* segment again does nothing. Set `allowEmpty` to let it be cleared.
|
|
8
|
+
*/
|
|
9
|
+
allowEmpty?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Segments with an `icon` and a label show only one of them until pressed: `label` keeps the
|
|
12
|
+
* icons and reveals the pressed segment's label; `icon` keeps the labels and reveals its icon.
|
|
13
|
+
* The segment widens as the hidden part slides in, and the raised surface widens with it.
|
|
14
|
+
*/
|
|
15
|
+
reveal?: "label" | "icon";
|
|
16
|
+
ref?: React.Ref<HTMLDivElement>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* ToggleGroup — the segmented control. A recessed 38px track holding 30px segments; the current
|
|
20
|
+
* segment is raised like a secondary button. In single mode one raised indicator glides to the
|
|
21
|
+
* segment you pick; until it has measured (and in `multiple` mode) each pressed segment raises
|
|
22
|
+
* itself.
|
|
23
|
+
*
|
|
24
|
+
* Use it for 2–5 short, mutually exclusive options where seeing them side by side is the point
|
|
25
|
+
* (billing period, view mode, a units switch). Past five options, or with long labels, use
|
|
26
|
+
* `Select`. The rule people break: using it as a row of independent actions — that is a
|
|
27
|
+
* toolbar of `Button`s or `Toggle`s. Give the group an `aria-label` or a visible label.
|
|
28
|
+
*/
|
|
29
|
+
export declare function ToggleGroup<Value extends string = string>({ allowEmpty, reveal, multiple, onValueChange, className, children, ref, ...props }: ToggleGroupProps<Value>): React.JSX.Element;
|
|
30
|
+
export interface ToggleGroupItemProps<Value extends string = string> extends BaseToggle.Props<Value> {
|
|
31
|
+
/**
|
|
32
|
+
* A 16px lucide icon before the label. With the group's `reveal`, one of the two stays hidden
|
|
33
|
+
* until the segment is pressed; the hidden label still names the segment for assistive tech.
|
|
34
|
+
*/
|
|
35
|
+
icon?: React.ReactNode;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* ToggleGroupItem — one segment. Needs a `value`; icon-only segments need an `aria-label`.
|
|
39
|
+
* Keep labels to a word or two so the segments stay comparable.
|
|
40
|
+
*/
|
|
41
|
+
export declare function ToggleGroupItem<Value extends string = string>({ icon, className, children, ...props }: ToggleGroupItemProps<Value>): React.JSX.Element;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Toggle as BaseToggle } from "@base-ui/react/toggle";
|
|
4
|
+
import { ToggleGroup as BaseToggleGroup } from "@base-ui/react/toggle-group";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { cn, sx } from "../lib/cn.js";
|
|
7
|
+
import { glideMotion, glideStyle, useGlide, useMergedRef } from "../lib/glide.js";
|
|
8
|
+
const ITEM = '[data-slot="toggle-group-item"]';
|
|
9
|
+
const findPressed = (root) => root.querySelector(`${ITEM}[data-pressed]`);
|
|
10
|
+
/**
|
|
11
|
+
* Keeps the chosen item in view in a row that scrolls sideways (a narrow screen): when it mounts,
|
|
12
|
+
* when the choice changes, and when the row or an item resizes — web fonts arriving, a hidden row
|
|
13
|
+
* shown — until someone scrolls the row themselves. Only the row scrolls, never the page, and its
|
|
14
|
+
* scroll-padding stays clear. It works from the boxes on screen, so LTR and RTL alike. (TabsList
|
|
15
|
+
* has the same.)
|
|
16
|
+
*/
|
|
17
|
+
function useRevealChosen(list, item, attribute) {
|
|
18
|
+
React.useLayoutEffect(() => {
|
|
19
|
+
const row = list.current;
|
|
20
|
+
if (!row)
|
|
21
|
+
return;
|
|
22
|
+
let held = false;
|
|
23
|
+
// The item chosen last (in `multiple` mode, the one just pressed), else the first chosen one.
|
|
24
|
+
let last = null;
|
|
25
|
+
const reveal = () => {
|
|
26
|
+
if (last && !last.hasAttribute(attribute))
|
|
27
|
+
last = null;
|
|
28
|
+
const chosen = row.scrollWidth > row.clientWidth && (last ?? row.querySelector(`${item}[${attribute}]`));
|
|
29
|
+
if (!chosen)
|
|
30
|
+
return;
|
|
31
|
+
const style = getComputedStyle(row);
|
|
32
|
+
const left = row.getBoundingClientRect().left + row.clientLeft;
|
|
33
|
+
const start = left + (Number.parseFloat(style.scrollPaddingLeft) || 0);
|
|
34
|
+
const end = left + row.clientWidth - (Number.parseFloat(style.scrollPaddingRight) || 0);
|
|
35
|
+
const box = chosen.getBoundingClientRect();
|
|
36
|
+
// Wider than the room: its start shows (its right edge in RTL).
|
|
37
|
+
const delta = box.left < start && box.right > end
|
|
38
|
+
? style.direction === "rtl"
|
|
39
|
+
? box.right - end
|
|
40
|
+
: box.left - start
|
|
41
|
+
: box.left < start
|
|
42
|
+
? box.left - start
|
|
43
|
+
: Math.max(0, box.right - end);
|
|
44
|
+
if (delta)
|
|
45
|
+
row.scrollLeft += delta;
|
|
46
|
+
};
|
|
47
|
+
const resize = new ResizeObserver(() => !held && reveal());
|
|
48
|
+
const observe = () => {
|
|
49
|
+
resize.disconnect();
|
|
50
|
+
resize.observe(row);
|
|
51
|
+
row.querySelectorAll(item).forEach((node) => resize.observe(node));
|
|
52
|
+
};
|
|
53
|
+
const mutations = new MutationObserver((records) => {
|
|
54
|
+
if (records.some((r) => r.type === "childList"))
|
|
55
|
+
observe();
|
|
56
|
+
const chosen = records
|
|
57
|
+
.filter((r) => r.type === "attributes" && r.target.hasAttribute(attribute))
|
|
58
|
+
.at(-1);
|
|
59
|
+
if (chosen) {
|
|
60
|
+
last = chosen.target;
|
|
61
|
+
held = false;
|
|
62
|
+
reveal();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
mutations.observe(row, {
|
|
66
|
+
subtree: true,
|
|
67
|
+
childList: true,
|
|
68
|
+
attributes: true,
|
|
69
|
+
attributeFilter: [attribute],
|
|
70
|
+
});
|
|
71
|
+
// Scrolling the row by hand, or moving through it by keyboard, leaves it where it is.
|
|
72
|
+
const hold = () => {
|
|
73
|
+
held = true;
|
|
74
|
+
};
|
|
75
|
+
const events = ["wheel", "touchstart", "keydown"];
|
|
76
|
+
for (const type of events)
|
|
77
|
+
row.addEventListener(type, hold, { passive: true });
|
|
78
|
+
observe();
|
|
79
|
+
reveal();
|
|
80
|
+
return () => {
|
|
81
|
+
resize.disconnect();
|
|
82
|
+
mutations.disconnect();
|
|
83
|
+
for (const type of events)
|
|
84
|
+
row.removeEventListener(type, hold);
|
|
85
|
+
};
|
|
86
|
+
}, [list, item, attribute]);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* ToggleGroup — the segmented control. A recessed 38px track holding 30px segments; the current
|
|
90
|
+
* segment is raised like a secondary button. In single mode one raised indicator glides to the
|
|
91
|
+
* segment you pick; until it has measured (and in `multiple` mode) each pressed segment raises
|
|
92
|
+
* itself.
|
|
93
|
+
*
|
|
94
|
+
* Use it for 2–5 short, mutually exclusive options where seeing them side by side is the point
|
|
95
|
+
* (billing period, view mode, a units switch). Past five options, or with long labels, use
|
|
96
|
+
* `Select`. The rule people break: using it as a row of independent actions — that is a
|
|
97
|
+
* toolbar of `Button`s or `Toggle`s. Give the group an `aria-label` or a visible label.
|
|
98
|
+
*/
|
|
99
|
+
export function ToggleGroup({ allowEmpty = false, reveal, multiple, onValueChange, className, children, ref, ...props }) {
|
|
100
|
+
const [rootRef, setRef] = useMergedRef(ref);
|
|
101
|
+
const glide = useGlide(rootRef, findPressed, {
|
|
102
|
+
enabled: !multiple,
|
|
103
|
+
attributes: ["data-pressed"],
|
|
104
|
+
items: ITEM,
|
|
105
|
+
});
|
|
106
|
+
// Too many segments for a narrow screen scroll inside the track; the pressed one starts in view.
|
|
107
|
+
useRevealChosen(rootRef, ITEM, "data-pressed");
|
|
108
|
+
return (_jsxs(BaseToggleGroup, { ref: setRef, "data-slot": "toggle-group", "data-indicator": glide.visible ? "" : undefined, "data-reveal": reveal, multiple: multiple, onValueChange: (value, eventDetails) => {
|
|
109
|
+
if (!multiple && !allowEmpty && value.length === 0) {
|
|
110
|
+
eventDetails.cancel();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
onValueChange?.(value, eventDetails);
|
|
114
|
+
}, className: sx([
|
|
115
|
+
"group/toggle-group relative inline-flex min-h-(--control-h) w-fit max-w-full material-field items-stretch gap-0.5 rounded-control p-[3px]",
|
|
116
|
+
// Segments that outgrow the row scroll inside the track (its 3px inset keeps their focus
|
|
117
|
+
// outlines whole) instead of pushing the page wider.
|
|
118
|
+
"scroll-px-[3px] [scrollbar-width:none] data-[orientation=horizontal]:overflow-x-auto data-[orientation=horizontal]:overflow-y-hidden [&::-webkit-scrollbar]:hidden",
|
|
119
|
+
"data-[orientation=vertical]:flex-col",
|
|
120
|
+
"data-disabled:**:data-[slot=toggle-group-item]:opacity-100",
|
|
121
|
+
], className), ...props, children: [!multiple && (_jsx("span", { "aria-hidden": true, "data-slot": "toggle-group-indicator", "data-visible": glide.visible ? "" : undefined, "data-instant": glide.instant ? "" : undefined, className: cn(glideMotion, "rounded-item border border-transparent bg-control-surface bg-linear-to-b from-control-inner-edge to-transparent shadow-raised"), style: glideStyle(glide) })), children] }));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* ToggleGroupItem — one segment. Needs a `value`; icon-only segments need an `aria-label`.
|
|
125
|
+
* Keep labels to a word or two so the segments stay comparable.
|
|
126
|
+
*/
|
|
127
|
+
export function ToggleGroupItem({ icon, className, children, ...props }) {
|
|
128
|
+
return (_jsx(BaseToggle, { "data-slot": "toggle-group-item", className: sx([
|
|
129
|
+
"relative inline-flex min-h-(--control-h-sm) flex-1 cursor-pointer items-center justify-center gap-1.5 rounded-item border border-transparent px-3 font-body text-[13px] leading-none font-medium whitespace-nowrap text-control-muted select-none",
|
|
130
|
+
"[&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
131
|
+
// Hover only brightens the label; the raised material means "selected".
|
|
132
|
+
"hover:not-data-disabled:text-foreground",
|
|
133
|
+
"data-pressed:bg-control-surface data-pressed:bg-linear-to-b data-pressed:from-control-inner-edge data-pressed:to-transparent data-pressed:text-foreground data-pressed:shadow-raised",
|
|
134
|
+
// Once the gliding indicator is placed it carries the raised surface instead.
|
|
135
|
+
"group-data-indicator/toggle-group:data-pressed:bg-transparent group-data-indicator/toggle-group:data-pressed:bg-none group-data-indicator/toggle-group:data-pressed:shadow-none",
|
|
136
|
+
"disabled:pointer-events-none data-disabled:cursor-not-allowed data-disabled:opacity-50",
|
|
137
|
+
// Revealing segments size to their content; the icon–label gap sits inside the part that slides.
|
|
138
|
+
"group-data-[reveal]/toggle-group:flex-none group-data-[reveal]/toggle-group:gap-0",
|
|
139
|
+
], className), ...props, children: icon == null ? (children) : (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "toggle-group-icon", children: _jsx("span", { children: icon }) }), children != null && (_jsx("span", { "data-slot": "toggle-group-label", children: _jsx("span", { children: children }) }))] })) }));
|
|
140
|
+
}
|