@sentry/junior-dashboard 0.264.0 → 0.265.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 +201 -0
- package/README.md +2 -5
- package/dist/app.js +119 -35
- package/dist/client.js +145 -136
- package/dist/index.d.ts +0 -1
- package/dist/index.js +119 -35
- package/dist/tailwind.css +1 -1
- package/package.json +5 -4
- package/src/api/schema.ts +0 -1
- package/src/app.ts +5 -20
- package/src/client/App.tsx +29 -31
- package/src/client/api.ts +7 -0
- package/src/client/components/BottomSheet.tsx +12 -2
- package/src/client/components/CopyButton.tsx +83 -0
- package/src/client/components/DetailsPanel.tsx +133 -0
- package/src/client/components/Drawer.tsx +15 -24
- package/src/client/components/FilterBar.tsx +16 -31
- package/src/client/components/Metric.tsx +33 -23
- package/src/client/components/PageContentSkeleton.tsx +1 -1
- package/src/client/components/Pagination.tsx +1 -1
- package/src/client/components/ParticipantAvatarStack.tsx +40 -36
- package/src/client/components/ProfileMenu.tsx +27 -93
- package/src/client/components/README.md +86 -77
- package/src/client/components/SegmentedNav.tsx +1 -1
- package/src/client/components/ShimmerText.tsx +2 -6
- package/src/client/components/ThemeSwitcher.tsx +19 -15
- package/src/client/components/charts/ActivityChart.tsx +173 -288
- package/src/client/components/charts/CacheWrites.tsx +63 -50
- package/src/client/components/charts/InputCacheChart.tsx +137 -131
- package/src/client/components/charts/README.md +4 -4
- package/src/client/components/charts/SystemMetricCharts.tsx +68 -95
- package/src/client/components/charts/WorkspaceUsageChart.tsx +42 -62
- package/src/client/components/controls/DirectorySortSelect.tsx +3 -3
- package/src/client/components/controls/TimeRangeSelector.tsx +10 -15
- package/src/client/components/layout/DashboardHeader.tsx +44 -90
- package/src/client/components/layout/SecondaryNavigation.tsx +2 -1
- package/src/client/components/layout/VisualViewportShell.tsx +2 -2
- package/src/client/components/ui/accordion.tsx +77 -0
- package/src/client/components/ui/alert-dialog.tsx +89 -0
- package/src/client/components/ui/button.tsx +85 -0
- package/src/client/components/ui/chart.tsx +74 -0
- package/src/client/components/ui/checkbox.tsx +26 -0
- package/src/client/components/ui/collapsible.tsx +22 -0
- package/src/client/components/ui/field.tsx +49 -0
- package/src/client/components/ui/input.tsx +35 -0
- package/src/client/components/ui/native-select.tsx +57 -0
- package/src/client/components/ui/popover.tsx +67 -0
- package/src/client/components/ui/radio-group.tsx +32 -0
- package/src/client/components/ui/sheet.tsx +13 -3
- package/src/client/components/ui/skeleton.tsx +19 -0
- package/src/client/components/ui/table.tsx +80 -0
- package/src/client/components/ui/tabs.tsx +75 -0
- package/src/client/components/ui/textarea.tsx +17 -0
- package/src/client/components/ui/toast.tsx +215 -0
- package/src/client/components/ui/toggle-group.tsx +36 -0
- package/src/client/components/ui/toggle.tsx +37 -0
- package/src/client/components/ui/tooltip.tsx +168 -0
- package/src/client/components/ui/trace.tsx +96 -0
- package/src/client/conversations/ChatLayout.tsx +7 -3
- package/src/client/conversations/ConversationBrief.tsx +17 -6
- package/src/client/conversations/ConversationComposer.tsx +26 -12
- package/src/client/conversations/ConversationDetails.tsx +147 -62
- package/src/client/conversations/ConversationEventDetails.tsx +141 -0
- package/src/client/conversations/ConversationEventLog.tsx +150 -129
- package/src/client/conversations/ConversationHeader.tsx +8 -3
- package/src/client/conversations/ConversationHeaderActions.tsx +90 -82
- package/src/client/conversations/ConversationHomeList.tsx +1 -1
- package/src/client/conversations/ConversationLinkedWork.tsx +118 -0
- package/src/client/conversations/ConversationMeta.tsx +55 -88
- package/src/client/conversations/ConversationPage.tsx +220 -101
- package/src/client/conversations/ConversationSidebar.tsx +48 -29
- package/src/client/conversations/ConversationWatches.tsx +165 -0
- package/src/client/conversations/ConversationWorkspace.tsx +12 -22
- package/src/client/conversations/ConversationWorkspaceLoading.tsx +1 -1
- package/src/client/conversations/DetailsList.tsx +124 -0
- package/src/client/conversations/EventDetails.tsx +42 -8
- package/src/client/conversations/ForkConversationButton.tsx +27 -16
- package/src/client/conversations/ObjectCard.tsx +20 -8
- package/src/client/conversations/PendingMailboxStack.tsx +52 -33
- package/src/client/conversations/README.md +86 -13
- package/src/client/conversations/ShareConversationButton.tsx +25 -13
- package/src/client/conversations/SubagentTranscriptDrawer.tsx +21 -15
- package/src/client/conversations/ToolFrame.tsx +36 -52
- package/src/client/conversations/TranscriptActivityGroup.tsx +13 -4
- package/src/client/conversations/TranscriptAutomationTriggerView.tsx +5 -4
- package/src/client/conversations/TranscriptContextEventView.tsx +25 -11
- package/src/client/conversations/TranscriptHeadingRow.tsx +7 -7
- package/src/client/conversations/TranscriptLoading.tsx +1 -1
- package/src/client/conversations/TranscriptMarkdown.tsx +25 -20
- package/src/client/conversations/TranscriptMessageContextView.tsx +8 -2
- package/src/client/conversations/TranscriptMessageView.tsx +6 -1
- package/src/client/conversations/TranscriptReasoningView.tsx +54 -68
- package/src/client/conversations/TranscriptTimestamp.tsx +9 -7
- package/src/client/conversations/TranscriptToolView.tsx +1 -1
- package/src/client/conversations/TranscriptTurnContextView.tsx +99 -27
- package/src/client/conversations/TranscriptView.tsx +63 -27
- package/src/client/conversations/eventLog.ts +57 -0
- package/src/client/conversations/eventTime.ts +60 -0
- package/src/client/conversations/queries.ts +29 -0
- package/src/client/conversations/transcriptBottomPinning.ts +34 -0
- package/src/client/format.ts +5 -0
- package/src/client/pages/ConnectionsPage.tsx +2 -2
- package/src/client/pages/PersonalTokensPage.tsx +4 -4
- package/src/client/pages/SettingsPage.tsx +9 -10
- package/src/client/pages/admin/ServiceAccountsSection.tsx +2 -2
- package/src/client/pages/automations/AutomationCostChart.tsx +50 -71
- package/src/client/pages/automations/AutomationDeleteDialog.tsx +87 -0
- package/src/client/pages/automations/AutomationDetails.tsx +193 -0
- package/src/client/pages/automations/AutomationEditPage.tsx +7 -8
- package/src/client/pages/automations/AutomationEditor.tsx +41 -29
- package/src/client/pages/automations/AutomationEditorLoading.tsx +1 -1
- package/src/client/pages/automations/AutomationEventFields.tsx +202 -119
- package/src/client/pages/automations/AutomationExecutionChart.tsx +51 -64
- package/src/client/pages/automations/AutomationExecutionStatusChart.tsx +47 -70
- package/src/client/pages/automations/AutomationExecutionsPage.tsx +150 -126
- package/src/client/pages/automations/AutomationFilters.tsx +189 -74
- package/src/client/pages/automations/AutomationLifecycle.tsx +109 -78
- package/src/client/pages/automations/AutomationOutcomeFields.tsx +26 -24
- package/src/client/pages/automations/AutomationRecentRuns.tsx +143 -0
- package/src/client/pages/automations/AutomationRow.tsx +12 -138
- package/src/client/pages/automations/AutomationRunDetails.tsx +307 -0
- package/src/client/pages/automations/AutomationRunsPage.tsx +119 -94
- package/src/client/pages/automations/AutomationScheduleFields.tsx +51 -51
- package/src/client/pages/automations/AutomationStatus.tsx +201 -0
- package/src/client/pages/automations/AutomationVersionsPage.tsx +65 -28
- package/src/client/pages/automations/AutomationsPage.tsx +80 -68
- package/src/client/pages/automations/AutomationsPageLayout.tsx +46 -14
- package/src/client/pages/automations/README.md +57 -0
- package/src/client/pages/automations/TriggerFilters.tsx +22 -0
- package/src/client/pages/automations/automationFormat.ts +37 -23
- package/src/client/pages/code/CodeActivityChart.tsx +59 -101
- package/src/client/pages/code/CodePage.tsx +52 -55
- package/src/client/pages/code/RepositoryPage.tsx +6 -8
- package/src/client/pages/locations/LocationActivityChart.tsx +53 -70
- package/src/client/pages/locations/LocationDirectoryActivityChart.tsx +60 -80
- package/src/client/pages/memory/MemoryCostChart.tsx +79 -103
- package/src/client/pages/memory/MemoryDetails.tsx +218 -0
- package/src/client/pages/memory/MemoryPage.tsx +168 -112
- package/src/client/pages/memory/MemoryPageLayout.tsx +33 -9
- package/src/client/pages/memory/MemoryTimeline.tsx +46 -69
- package/src/client/pages/memory/memoryRecord.ts +1 -1
- package/src/client/pages/people/ContributionGrid.tsx +23 -16
- package/src/client/pages/people/PeopleActivityChart.tsx +68 -107
- package/src/client/pages/people/ProfileCodeChanges.tsx +5 -5
- package/src/client/pages/system/BaseSandboxCard.tsx +1 -1
- package/src/client/pages/system/ConversationActivityChart.tsx +49 -67
- package/src/client/pages/system/GuardianActivity.tsx +1 -2
- package/src/client/pages/system/PluginBarChart.tsx +106 -87
- package/src/client/pages/system/PluginReportRecordSet.tsx +25 -24
- package/src/client/pages/system/README.md +23 -0
- package/src/client/pages/system/SystemNavigation.tsx +5 -1
- package/src/client/pages/system/WorkspaceDeleteDialog.tsx +111 -0
- package/src/client/pages/system/WorkspaceDetails.tsx +200 -43
- package/src/client/pages/system/WorkspaceEditor.tsx +59 -61
- package/src/client/pages/system/WorkspaceFormPage.tsx +23 -47
- package/src/client/pages/system/WorkspaceList.tsx +20 -30
- package/src/client/pages/system/WorkspacesPage.tsx +117 -119
- package/src/client/pages/system/sandboxSize.ts +8 -0
- package/src/client/pages/system/workspaceQueries.ts +53 -0
- package/src/client/pages/user/PluginUserPage.tsx +51 -2
- package/src/client/pages/user/pluginUserPageData.ts +1 -6
- package/src/client/styles.ts +4 -0
- package/src/client.tsx +7 -1
- package/src/mock-reporting/automation-collection.ts +4 -2
- package/src/mock-reporting/fixtures.ts +23 -7
- package/src/mock-reporting/routes.ts +12 -0
- package/src/mock-reporting/watches.ts +94 -0
- package/src/shell.ts +4 -9
- package/src/tailwind.css +0 -10
- package/src/client/components/Button.tsx +0 -118
- package/src/client/components/Field.tsx +0 -53
- package/src/client/components/SegmentedTabs.tsx +0 -119
- package/src/client/components/Select.tsx +0 -52
- package/src/client/components/Skeleton.tsx +0 -17
- package/src/client/components/TextInput.tsx +0 -58
- package/src/client/components/Tooltip.tsx +0 -216
- package/src/client/components/charts/useChartLayout.ts +0 -27
- package/src/client/components/ui/sheet.LICENSE +0 -21
- package/src/client/conversations/ConversationDetailsFrame.tsx +0 -119
- package/src/client/conversations/CopyMarkdownButton.tsx +0 -65
- package/src/client/pages/automations/AutomationDetailsDrawer.tsx +0 -219
- package/src/client/pages/dev/ChartFixtures.tsx +0 -325
- package/src/client/pages/dev/ComponentsPage.tsx +0 -899
- package/src/client/pages/dev/ConversationFixture.tsx +0 -231
- package/src/client/pages/dev/ObjectFixtures.tsx +0 -138
- package/src/client/pages/dev/SegmentedFixtures.tsx +0 -59
- package/src/client/pages/dev/SelectFixtures.tsx +0 -62
- package/src/client/pages/dev/TranscriptActivityFixtures.tsx +0 -206
- package/src/client/pages/memory/MemoryDetailsDrawer.tsx +0 -167
- package/src/client/pages/system/SandboxSizeSummary.tsx +0 -47
- package/src/client/pages/system/SnapshotSummary.tsx +0 -78
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { cn } from "@dashboard/lib/utils";
|
|
3
|
+
|
|
4
|
+
/** Render a data table that scrolls sideways when it is wider than its box. */
|
|
5
|
+
function Table({ className, ...props }: ComponentProps<"table">) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
data-slot="table-container"
|
|
9
|
+
className="relative w-full overflow-x-auto"
|
|
10
|
+
>
|
|
11
|
+
<table
|
|
12
|
+
data-slot="table"
|
|
13
|
+
className={cn("w-full border-collapse text-left text-sm", className)}
|
|
14
|
+
{...props}
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function TableHeader({ className, ...props }: ComponentProps<"thead">) {
|
|
21
|
+
return (
|
|
22
|
+
<thead
|
|
23
|
+
data-slot="table-header"
|
|
24
|
+
className={cn("[&_tr]:hover:bg-transparent", className)}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function TableBody({ className, ...props }: ComponentProps<"tbody">) {
|
|
31
|
+
return (
|
|
32
|
+
<tbody
|
|
33
|
+
data-slot="table-body"
|
|
34
|
+
className={cn("[&_tr:last-child]:border-0", className)}
|
|
35
|
+
{...props}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function TableRow({ className, ...props }: ComponentProps<"tr">) {
|
|
41
|
+
return (
|
|
42
|
+
<tr
|
|
43
|
+
data-slot="table-row"
|
|
44
|
+
className={cn(
|
|
45
|
+
"border-b border-dashboard-border-subtle transition-colors hover:bg-dashboard-fill-soft has-aria-expanded:bg-dashboard-fill-soft data-[state=selected]:bg-dashboard-surface-active",
|
|
46
|
+
className,
|
|
47
|
+
)}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Render a column header in the dashboard label style. */
|
|
54
|
+
function TableHead({ className, ...props }: ComponentProps<"th">) {
|
|
55
|
+
return (
|
|
56
|
+
<th
|
|
57
|
+
data-slot="table-head"
|
|
58
|
+
className={cn(
|
|
59
|
+
"px-2 py-2.5 text-left align-middle font-sans text-xs font-medium whitespace-nowrap text-dashboard-text-muted [&:has([role=checkbox])]:pr-0",
|
|
60
|
+
className,
|
|
61
|
+
)}
|
|
62
|
+
{...props}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function TableCell({ className, ...props }: ComponentProps<"td">) {
|
|
68
|
+
return (
|
|
69
|
+
<td
|
|
70
|
+
data-slot="table-cell"
|
|
71
|
+
className={cn(
|
|
72
|
+
"p-2 align-middle whitespace-nowrap text-dashboard-text [&:has([role=checkbox])]:pr-0",
|
|
73
|
+
className,
|
|
74
|
+
)}
|
|
75
|
+
{...props}
|
|
76
|
+
/>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export { Table, TableHeader, TableBody, TableHead, TableRow, TableCell };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Tabs as TabsPrimitive } from "@base-ui/react/tabs";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@dashboard/lib/utils";
|
|
4
|
+
|
|
5
|
+
/** Own the selected panel and link each tab to its panel. */
|
|
6
|
+
function Tabs({ className, ...props }: TabsPrimitive.Root.Props) {
|
|
7
|
+
return (
|
|
8
|
+
<TabsPrimitive.Root
|
|
9
|
+
data-slot="tabs"
|
|
10
|
+
className={cn("grid min-w-0 gap-4", className)}
|
|
11
|
+
{...props}
|
|
12
|
+
/>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const tabsListVariants = cva("group/tabs-list flex min-w-0", {
|
|
17
|
+
variants: {
|
|
18
|
+
variant: {
|
|
19
|
+
/** A pill track. Tabs share the row equally on wide screens. */
|
|
20
|
+
default:
|
|
21
|
+
"gap-1 rounded-lg border border-dashboard-border bg-dashboard-surface-panel p-1",
|
|
22
|
+
/** Underlined tabs on a bottom border, for collection filters. */
|
|
23
|
+
line: "gap-1 border-b border-dashboard-border-subtle",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: { variant: "default" },
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
/** Hold the tabs. `variant` sets the look of the row and its tabs. */
|
|
30
|
+
function TabsList({
|
|
31
|
+
className,
|
|
32
|
+
variant = "default",
|
|
33
|
+
...props
|
|
34
|
+
}: TabsPrimitive.List.Props & VariantProps<typeof tabsListVariants>) {
|
|
35
|
+
return (
|
|
36
|
+
<TabsPrimitive.List
|
|
37
|
+
data-slot="tabs-list"
|
|
38
|
+
data-variant={variant}
|
|
39
|
+
className={cn(tabsListVariants({ variant }), className)}
|
|
40
|
+
{...props}
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Select one panel. The active tab uses the strong fill or the accent line. */
|
|
46
|
+
function TabsTrigger({ className, ...props }: TabsPrimitive.Tab.Props) {
|
|
47
|
+
return (
|
|
48
|
+
<TabsPrimitive.Tab
|
|
49
|
+
data-slot="tabs-trigger"
|
|
50
|
+
className={cn(
|
|
51
|
+
"inline-flex min-w-0 cursor-pointer items-center gap-1.5 border-0 bg-transparent font-sans text-xs font-medium text-dashboard-text-muted transition-colors hover:text-dashboard-text focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",
|
|
52
|
+
"group-data-[variant=default]/tabs-list:min-h-9 group-data-[variant=default]/tabs-list:flex-auto group-data-[variant=default]/tabs-list:justify-center group-data-[variant=default]/tabs-list:rounded-md group-data-[variant=default]/tabs-list:px-1.5 group-data-[variant=default]/tabs-list:py-2 group-data-[variant=default]/tabs-list:hover:bg-dashboard-fill-faint group-data-[variant=default]/tabs-list:data-active:bg-dashboard-fill-strong group-data-[variant=default]/tabs-list:data-active:text-dashboard-text group-data-[variant=default]/tabs-list:sm:flex-1",
|
|
53
|
+
"group-data-[variant=line]/tabs-list:relative group-data-[variant=line]/tabs-list:gap-2 group-data-[variant=line]/tabs-list:px-3 group-data-[variant=line]/tabs-list:py-2.5 group-data-[variant=line]/tabs-list:after:absolute group-data-[variant=line]/tabs-list:after:inset-x-2 group-data-[variant=line]/tabs-list:after:bottom-0 group-data-[variant=line]/tabs-list:after:h-px group-data-[variant=line]/tabs-list:data-active:text-dashboard-accent-text group-data-[variant=line]/tabs-list:data-active:after:bg-dashboard-accent",
|
|
54
|
+
className,
|
|
55
|
+
)}
|
|
56
|
+
{...props}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Show the content for the selected tab. */
|
|
62
|
+
function TabsContent({ className, ...props }: TabsPrimitive.Panel.Props) {
|
|
63
|
+
return (
|
|
64
|
+
<TabsPrimitive.Panel
|
|
65
|
+
data-slot="tabs-content"
|
|
66
|
+
className={cn(
|
|
67
|
+
"min-w-0 rounded-md focus-visible:outline focus-visible:outline-2 focus-visible:outline-dashboard-focus",
|
|
68
|
+
className,
|
|
69
|
+
)}
|
|
70
|
+
{...props}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
import { cn } from "@dashboard/lib/utils";
|
|
3
|
+
|
|
4
|
+
import { textControlClass } from "./input";
|
|
5
|
+
|
|
6
|
+
/** Render a text area with the dashboard text control surface. */
|
|
7
|
+
function Textarea({ className, ...props }: ComponentProps<"textarea">) {
|
|
8
|
+
return (
|
|
9
|
+
<textarea
|
|
10
|
+
data-slot="textarea"
|
|
11
|
+
className={cn(textControlClass, "min-h-36", className)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { Textarea };
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Toast as ToastPrimitive } from "@base-ui/react/toast";
|
|
3
|
+
import { cn } from "@dashboard/lib/utils";
|
|
4
|
+
|
|
5
|
+
import { Button } from "./button";
|
|
6
|
+
import {
|
|
7
|
+
XIcon,
|
|
8
|
+
CircleCheckIcon,
|
|
9
|
+
InfoIcon,
|
|
10
|
+
TriangleAlertIcon,
|
|
11
|
+
OctagonXIcon,
|
|
12
|
+
Loader2Icon,
|
|
13
|
+
} from "lucide-react";
|
|
14
|
+
|
|
15
|
+
function ToastProvider({ ...props }: ToastPrimitive.Provider.Props) {
|
|
16
|
+
return <ToastPrimitive.Provider {...props} />;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function ToastPortal({ ...props }: ToastPrimitive.Portal.Props) {
|
|
20
|
+
return <ToastPrimitive.Portal data-slot="toast-portal" {...props} />;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function ToastViewport({ className, ...props }: ToastPrimitive.Viewport.Props) {
|
|
24
|
+
return (
|
|
25
|
+
<ToastPrimitive.Viewport
|
|
26
|
+
data-slot="toast-viewport"
|
|
27
|
+
className={cn(
|
|
28
|
+
"pointer-events-none fixed inset-x-4 bottom-[max(5.25rem,env(safe-area-inset-bottom))] z-[60] mx-auto w-auto max-w-sm outline-none sm:right-4 sm:left-auto sm:mx-0 sm:w-full",
|
|
29
|
+
className,
|
|
30
|
+
)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function Toast({ className, ...props }: ToastPrimitive.Root.Props) {
|
|
37
|
+
return (
|
|
38
|
+
<ToastPrimitive.Root
|
|
39
|
+
data-slot="toast"
|
|
40
|
+
className={cn(
|
|
41
|
+
"group/toast pointer-events-auto absolute right-0 bottom-0 z-[calc(1000-var(--toast-index))] w-full origin-bottom rounded-lg border border-dashboard-border-emphasis bg-dashboard-surface-raised text-dashboard-text shadow-lg will-change-transform outline-none select-none focus-visible:outline-2 focus-visible:outline-dashboard-focus",
|
|
42
|
+
"[--gap:0.75rem] [--height:var(--toast-frontmost-height,var(--toast-height))] [--offset-y:calc(var(--toast-offset-y)*-1+calc(var(--toast-index)*var(--gap)*-1)+var(--toast-swipe-movement-y))] [--peek:0.75rem] [--scale:calc(max(0,1-(var(--toast-index)*0.1)))] [--shrink:calc(1-var(--scale))]",
|
|
43
|
+
"h-(--height) [transform:translateX(var(--toast-swipe-movement-x))_translateY(calc(var(--toast-swipe-movement-y)-(var(--toast-index)*var(--peek))-(var(--shrink)*var(--height))))_scale(var(--scale))] [transition:transform_180ms_ease-out,opacity_180ms,height_180ms] motion-reduce:transition-none",
|
|
44
|
+
"after:absolute after:top-full after:left-0 after:h-[calc(var(--gap)+1px)] after:w-full after:content-['']",
|
|
45
|
+
"data-expanded:h-(--toast-height) data-expanded:[transform:translateX(var(--toast-swipe-movement-x))_translateY(var(--offset-y))]",
|
|
46
|
+
"data-limited:opacity-0 data-starting-style:[transform:translateY(150%)]",
|
|
47
|
+
"[&[data-ending-style]:not([data-limited]):not([data-swipe-direction])]:[transform:translateY(150%)]",
|
|
48
|
+
"data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
|
|
49
|
+
"data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
|
|
50
|
+
"data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]",
|
|
51
|
+
"data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
|
|
52
|
+
"data-expanded:data-ending-style:data-[swipe-direction=down]:[transform:translateY(calc(var(--toast-swipe-movement-y)+150%))]",
|
|
53
|
+
"data-expanded:data-ending-style:data-[swipe-direction=left]:[transform:translateX(calc(var(--toast-swipe-movement-x)-150%))_translateY(var(--offset-y))]",
|
|
54
|
+
"data-expanded:data-ending-style:data-[swipe-direction=right]:[transform:translateX(calc(var(--toast-swipe-movement-x)+150%))_translateY(var(--offset-y))]",
|
|
55
|
+
"data-expanded:data-ending-style:data-[swipe-direction=up]:[transform:translateY(calc(var(--toast-swipe-movement-y)-150%))]",
|
|
56
|
+
className,
|
|
57
|
+
)}
|
|
58
|
+
{...props}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function ToastContent({ className, ...props }: ToastPrimitive.Content.Props) {
|
|
64
|
+
return (
|
|
65
|
+
<ToastPrimitive.Content
|
|
66
|
+
data-slot="toast-content"
|
|
67
|
+
className={cn(
|
|
68
|
+
"flex h-full items-center gap-3 overflow-hidden p-4 transition-opacity duration-180 motion-reduce:transition-none ease-[cubic-bezier(0.22,1,0.36,1)] data-behind:opacity-0 data-expanded:opacity-100",
|
|
69
|
+
className,
|
|
70
|
+
)}
|
|
71
|
+
{...props}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function ToastTitle({ className, ...props }: ToastPrimitive.Title.Props) {
|
|
77
|
+
return (
|
|
78
|
+
<ToastPrimitive.Title
|
|
79
|
+
data-slot="toast-title"
|
|
80
|
+
className={cn("break-words text-sm font-medium", className)}
|
|
81
|
+
{...props}
|
|
82
|
+
/>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function ToastDescription({
|
|
87
|
+
className,
|
|
88
|
+
...props
|
|
89
|
+
}: ToastPrimitive.Description.Props) {
|
|
90
|
+
return (
|
|
91
|
+
<ToastPrimitive.Description
|
|
92
|
+
data-slot="toast-description"
|
|
93
|
+
className={cn("break-words text-sm text-dashboard-text-muted", className)}
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function ToastAction({
|
|
100
|
+
className,
|
|
101
|
+
render = <Button />,
|
|
102
|
+
...props
|
|
103
|
+
}: ToastPrimitive.Action.Props) {
|
|
104
|
+
return (
|
|
105
|
+
<ToastPrimitive.Action
|
|
106
|
+
data-slot="toast-action"
|
|
107
|
+
render={render}
|
|
108
|
+
className={cn("shrink-0", className)}
|
|
109
|
+
{...props}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function ToastClose({
|
|
115
|
+
className,
|
|
116
|
+
children,
|
|
117
|
+
render = <Button size="icon" />,
|
|
118
|
+
...props
|
|
119
|
+
}: ToastPrimitive.Close.Props) {
|
|
120
|
+
return (
|
|
121
|
+
<ToastPrimitive.Close
|
|
122
|
+
data-slot="toast-close"
|
|
123
|
+
aria-label="Close toast"
|
|
124
|
+
render={render}
|
|
125
|
+
className={cn(
|
|
126
|
+
"relative shrink-0 text-dashboard-text-muted after:absolute after:-inset-2 after:content-[''] hover:text-dashboard-text",
|
|
127
|
+
className,
|
|
128
|
+
)}
|
|
129
|
+
{...props}
|
|
130
|
+
>
|
|
131
|
+
{children ?? <XIcon aria-hidden="true" />}
|
|
132
|
+
</ToastPrimitive.Close>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function ToastIcon({ type }: { type: string | undefined }) {
|
|
137
|
+
let icon: React.ReactNode = null;
|
|
138
|
+
|
|
139
|
+
if (type === "success") {
|
|
140
|
+
icon = <CircleCheckIcon aria-hidden="true" />;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (type === "info") {
|
|
144
|
+
icon = <InfoIcon aria-hidden="true" />;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (type === "warning") {
|
|
148
|
+
icon = <TriangleAlertIcon aria-hidden="true" />;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (type === "error") {
|
|
152
|
+
icon = <OctagonXIcon className="text-rose-300" aria-hidden="true" />;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
if (type === "loading") {
|
|
156
|
+
icon = (
|
|
157
|
+
<Loader2Icon
|
|
158
|
+
className="animate-spin motion-reduce:animate-none"
|
|
159
|
+
aria-hidden="true"
|
|
160
|
+
/>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
if (!icon) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<span
|
|
170
|
+
data-slot="toast-icon"
|
|
171
|
+
className="shrink-0 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4"
|
|
172
|
+
>
|
|
173
|
+
{icon}
|
|
174
|
+
</span>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function ToastList() {
|
|
179
|
+
const { toasts } = ToastPrimitive.useToastManager();
|
|
180
|
+
|
|
181
|
+
return toasts.map((toastItem) => (
|
|
182
|
+
<Toast key={toastItem.id} toast={toastItem}>
|
|
183
|
+
<ToastContent>
|
|
184
|
+
<ToastIcon type={toastItem.type} />
|
|
185
|
+
<div className="flex min-w-0 flex-1 flex-col gap-1">
|
|
186
|
+
<ToastTitle />
|
|
187
|
+
<ToastDescription />
|
|
188
|
+
</div>
|
|
189
|
+
{toastItem.actionProps ? (
|
|
190
|
+
<ToastAction {...toastItem.actionProps} />
|
|
191
|
+
) : null}
|
|
192
|
+
<ToastClose />
|
|
193
|
+
</ToastContent>
|
|
194
|
+
</Toast>
|
|
195
|
+
));
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Own notification state for one mounted dashboard and render its toast stack. */
|
|
199
|
+
function Toaster({ children, ...props }: ToastPrimitive.Provider.Props) {
|
|
200
|
+
return (
|
|
201
|
+
<ToastProvider limit={3} timeout={4000} {...props}>
|
|
202
|
+
{children}
|
|
203
|
+
<ToastPortal>
|
|
204
|
+
<ToastViewport>
|
|
205
|
+
<ToastList />
|
|
206
|
+
</ToastViewport>
|
|
207
|
+
</ToastPortal>
|
|
208
|
+
</ToastProvider>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** Show short notifications through the nearest mounted Toaster. */
|
|
213
|
+
const useToastManager = ToastPrimitive.useToastManager;
|
|
214
|
+
|
|
215
|
+
export { Toaster, useToastManager };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
2
|
+
import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group";
|
|
3
|
+
import type { VariantProps } from "class-variance-authority";
|
|
4
|
+
import { cn } from "@dashboard/lib/utils";
|
|
5
|
+
import { toggleVariants } from "./toggle";
|
|
6
|
+
|
|
7
|
+
/** Own the pressed values and arrow-key focus across a row of items. */
|
|
8
|
+
function ToggleGroup<Value extends string>({
|
|
9
|
+
className,
|
|
10
|
+
...props
|
|
11
|
+
}: ToggleGroupPrimitive.Props<Value>) {
|
|
12
|
+
return (
|
|
13
|
+
<ToggleGroupPrimitive
|
|
14
|
+
data-slot="toggle-group"
|
|
15
|
+
className={cn("flex items-center gap-1", className)}
|
|
16
|
+
{...props}
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Render one item with a `ui/toggle` look. */
|
|
22
|
+
function ToggleGroupItem<Value extends string>({
|
|
23
|
+
className,
|
|
24
|
+
variant,
|
|
25
|
+
...props
|
|
26
|
+
}: TogglePrimitive.Props<Value> & VariantProps<typeof toggleVariants>) {
|
|
27
|
+
return (
|
|
28
|
+
<TogglePrimitive
|
|
29
|
+
data-slot="toggle-group-item"
|
|
30
|
+
className={cn(toggleVariants({ variant }), className)}
|
|
31
|
+
{...props}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export { ToggleGroup, ToggleGroupItem };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Toggle as TogglePrimitive } from "@base-ui/react/toggle";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "@dashboard/lib/utils";
|
|
4
|
+
|
|
5
|
+
/** Pressed-state looks shared by `Toggle` and `ToggleGroupItem`. */
|
|
6
|
+
const toggleVariants = cva(
|
|
7
|
+
"inline-flex cursor-pointer items-center justify-center font-sans text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-dashboard-focus",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
/** Quiet when off. The pressed state uses the active surface. */
|
|
12
|
+
default:
|
|
13
|
+
"h-7 min-w-10 rounded-md border border-transparent bg-transparent px-2 text-dashboard-text-muted hover:bg-dashboard-fill-hover hover:text-dashboard-text data-pressed:border-dashboard-border-interactive data-pressed:bg-dashboard-surface-active data-pressed:text-dashboard-text",
|
|
14
|
+
/** A bordered filter chip. The pressed state fills solid. */
|
|
15
|
+
pill: "rounded-md border border-dashboard-border-strong bg-dashboard-surface-raised px-2 py-1 leading-tight text-dashboard-text-muted hover:border-dashboard-border-interactive hover:bg-dashboard-surface-hover hover:text-dashboard-text data-pressed:border-dashboard-border-heavy data-pressed:bg-dashboard-text-solid data-pressed:text-dashboard-text-inverse",
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
defaultVariants: { variant: "default" },
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
/** Turn one setting on or off. */
|
|
23
|
+
function Toggle<Value extends string>({
|
|
24
|
+
className,
|
|
25
|
+
variant,
|
|
26
|
+
...props
|
|
27
|
+
}: TogglePrimitive.Props<Value> & VariantProps<typeof toggleVariants>) {
|
|
28
|
+
return (
|
|
29
|
+
<TogglePrimitive
|
|
30
|
+
data-slot="toggle"
|
|
31
|
+
className={cn(toggleVariants({ variant }), className)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { Toggle, toggleVariants };
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Tooltip as TooltipPrimitive } from "@base-ui/react/tooltip";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useContext,
|
|
6
|
+
useId,
|
|
7
|
+
useState,
|
|
8
|
+
useSyncExternalStore,
|
|
9
|
+
type ComponentProps,
|
|
10
|
+
} from "react";
|
|
11
|
+
import { cn } from "@dashboard/lib/utils";
|
|
12
|
+
|
|
13
|
+
/** Open dashboard tooltips at once and keep them open briefly for the pointer to reach them. */
|
|
14
|
+
function TooltipProvider({
|
|
15
|
+
delay = 0,
|
|
16
|
+
closeDelay = 150,
|
|
17
|
+
...props
|
|
18
|
+
}: TooltipPrimitive.Provider.Props) {
|
|
19
|
+
return (
|
|
20
|
+
<TooltipPrimitive.Provider
|
|
21
|
+
data-slot="tooltip-provider"
|
|
22
|
+
delay={delay}
|
|
23
|
+
closeDelay={closeDelay}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Link the open popup to its trigger. Base UI leaves this to the app. */
|
|
30
|
+
const TooltipDescriptionContext = createContext<string | undefined>(undefined);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Wide screens with a fine hover pointer show tooltips. On smaller or touch
|
|
34
|
+
* screens, a tooltip can cover the menu that its trigger opens.
|
|
35
|
+
*/
|
|
36
|
+
const TOOLTIP_MEDIA_QUERY =
|
|
37
|
+
"(min-width: 768px) and (hover: hover) and (pointer: fine)";
|
|
38
|
+
|
|
39
|
+
function subscribeToTooltipMedia(onChange: () => void) {
|
|
40
|
+
const media = window.matchMedia(TOOLTIP_MEDIA_QUERY);
|
|
41
|
+
media.addEventListener("change", onChange);
|
|
42
|
+
return () => media.removeEventListener("change", onChange);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function tooltipMediaMatches() {
|
|
46
|
+
return window.matchMedia(TOOLTIP_MEDIA_QUERY).matches;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Own one tooltip's open state. It stays off where tooltips are not shown. */
|
|
50
|
+
function Tooltip({
|
|
51
|
+
disabled,
|
|
52
|
+
onOpenChange,
|
|
53
|
+
open: openProp,
|
|
54
|
+
...props
|
|
55
|
+
}: TooltipPrimitive.Root.Props) {
|
|
56
|
+
const available = useSyncExternalStore(
|
|
57
|
+
subscribeToTooltipMedia,
|
|
58
|
+
tooltipMediaMatches,
|
|
59
|
+
() => false,
|
|
60
|
+
);
|
|
61
|
+
const id = useId();
|
|
62
|
+
const [openState, setOpenState] = useState(props.defaultOpen ?? false);
|
|
63
|
+
const open = available && (openProp ?? openState);
|
|
64
|
+
return (
|
|
65
|
+
<TooltipDescriptionContext.Provider value={open ? id : undefined}>
|
|
66
|
+
<TooltipPrimitive.Root
|
|
67
|
+
data-slot="tooltip"
|
|
68
|
+
disabled={disabled || !available}
|
|
69
|
+
onOpenChange={(next, details) => {
|
|
70
|
+
setOpenState(next);
|
|
71
|
+
onOpenChange?.(next, details);
|
|
72
|
+
}}
|
|
73
|
+
open={openProp}
|
|
74
|
+
{...props}
|
|
75
|
+
/>
|
|
76
|
+
</TooltipDescriptionContext.Provider>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Show the tooltip on mouse hover or keyboard focus. Touch does not open it.
|
|
82
|
+
* A click keeps it open, so copy and share feedback stays visible.
|
|
83
|
+
*/
|
|
84
|
+
function TooltipTrigger({
|
|
85
|
+
closeOnClick = false,
|
|
86
|
+
...props
|
|
87
|
+
}: TooltipPrimitive.Trigger.Props) {
|
|
88
|
+
const describedBy = useContext(TooltipDescriptionContext);
|
|
89
|
+
return (
|
|
90
|
+
<TooltipPrimitive.Trigger
|
|
91
|
+
aria-describedby={describedBy}
|
|
92
|
+
closeOnClick={closeOnClick}
|
|
93
|
+
data-slot="tooltip-trigger"
|
|
94
|
+
{...props}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
const tooltipContentVariants = cva(
|
|
100
|
+
"z-50 select-text rounded-md border border-dashboard-border-emphasis bg-dashboard-surface-raised font-sans text-xs shadow-2xl shadow-black/70 outline-none",
|
|
101
|
+
{
|
|
102
|
+
variants: {
|
|
103
|
+
size: {
|
|
104
|
+
/** Selectable detail cards, such as chart buckets and metric breakdowns. */
|
|
105
|
+
default:
|
|
106
|
+
"min-w-36 max-w-lg px-3 py-2 leading-relaxed text-dashboard-text-muted",
|
|
107
|
+
/** One short label for an icon-only control. */
|
|
108
|
+
compact: "px-2.5 py-1.5 leading-none text-dashboard-text",
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
defaultVariants: { size: "default" },
|
|
112
|
+
},
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
/** Show tooltip text beside its trigger and keep it inside the viewport. */
|
|
116
|
+
function TooltipContent({
|
|
117
|
+
className,
|
|
118
|
+
side = "top",
|
|
119
|
+
sideOffset = 10,
|
|
120
|
+
align = "center",
|
|
121
|
+
size,
|
|
122
|
+
children,
|
|
123
|
+
...props
|
|
124
|
+
}: TooltipPrimitive.Popup.Props &
|
|
125
|
+
Pick<TooltipPrimitive.Positioner.Props, "align" | "side" | "sideOffset"> &
|
|
126
|
+
VariantProps<typeof tooltipContentVariants>) {
|
|
127
|
+
const id = useContext(TooltipDescriptionContext);
|
|
128
|
+
return (
|
|
129
|
+
<TooltipPrimitive.Portal>
|
|
130
|
+
<TooltipPrimitive.Positioner
|
|
131
|
+
align={align}
|
|
132
|
+
collisionPadding={8}
|
|
133
|
+
side={side}
|
|
134
|
+
sideOffset={sideOffset}
|
|
135
|
+
className="isolate z-50 data-anchor-hidden:hidden"
|
|
136
|
+
>
|
|
137
|
+
<TooltipPrimitive.Popup
|
|
138
|
+
data-slot="tooltip-content"
|
|
139
|
+
id={id}
|
|
140
|
+
role="tooltip"
|
|
141
|
+
className={cn(tooltipContentVariants({ size }), className)}
|
|
142
|
+
{...props}
|
|
143
|
+
>
|
|
144
|
+
{children}
|
|
145
|
+
</TooltipPrimitive.Popup>
|
|
146
|
+
</TooltipPrimitive.Positioner>
|
|
147
|
+
</TooltipPrimitive.Portal>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Name what a detail tooltip describes, such as a chart bucket date. */
|
|
152
|
+
function TooltipTitle({ className, ...props }: ComponentProps<"div">) {
|
|
153
|
+
return (
|
|
154
|
+
<div
|
|
155
|
+
className={cn("mb-1 font-semibold text-dashboard-text-muted", className)}
|
|
156
|
+
{...props}
|
|
157
|
+
/>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export {
|
|
162
|
+
Tooltip,
|
|
163
|
+
TooltipTrigger,
|
|
164
|
+
TooltipContent,
|
|
165
|
+
TooltipTitle,
|
|
166
|
+
TooltipProvider,
|
|
167
|
+
tooltipContentVariants,
|
|
168
|
+
};
|