@tulipfarm/sprout 0.3.1 → 0.5.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/README.md +75 -68
- package/dist/components/accordion.d.ts +2 -2
- package/dist/components/accordion.js +9 -9
- package/dist/components/agent-avatar.d.ts +27 -0
- package/dist/components/agent-avatar.js +67 -0
- package/dist/components/agent-fanout.d.ts +2 -2
- package/dist/components/agent-fanout.js +65 -87
- package/dist/components/alert-dialog.d.ts +8 -8
- package/dist/components/alert-dialog.js +21 -21
- package/dist/components/alert.d.ts +6 -6
- package/dist/components/alert.js +13 -13
- package/dist/components/aspect-ratio.d.ts +2 -2
- package/dist/components/aspect-ratio.js +2 -2
- package/dist/components/attachment.d.ts +18 -18
- package/dist/components/attachment.js +82 -115
- package/dist/components/avatar.d.ts +9 -17
- package/dist/components/avatar.js +14 -51
- package/dist/components/badge.d.ts +4 -4
- package/dist/components/badge.js +18 -18
- package/dist/components/board.d.ts +107 -0
- package/dist/components/board.js +640 -0
- package/dist/components/brand-icon.d.ts +6 -6
- package/dist/components/brand-icon.js +55 -63
- package/dist/components/breadcrumb.d.ts +11 -11
- package/dist/components/breadcrumb.js +16 -18
- package/dist/components/button-group.d.ts +6 -6
- package/dist/components/button-group.js +14 -14
- package/dist/components/button.d.ts +13 -13
- package/dist/components/button.js +31 -57
- package/dist/components/calendar.d.ts +5 -5
- package/dist/components/calendar.js +44 -53
- package/dist/components/canvas.d.ts +4 -4
- package/dist/components/canvas.js +39 -46
- package/dist/components/card.d.ts +7 -7
- package/dist/components/card.js +17 -17
- package/dist/components/carousel.d.ts +7 -7
- package/dist/components/carousel.js +57 -75
- package/dist/components/chart.d.ts +5 -112
- package/dist/components/chart.js +5 -172
- package/dist/components/chat-confirmation.d.ts +10 -10
- package/dist/components/chat-confirmation.js +32 -38
- package/dist/components/chat-input.d.ts +4 -4
- package/dist/components/chat-input.js +74 -81
- package/dist/components/chat-plan.d.ts +2 -2
- package/dist/components/chat-plan.js +15 -20
- package/dist/components/chat-sources.d.ts +8 -8
- package/dist/components/chat-sources.js +18 -27
- package/dist/components/checkbox.d.ts +1 -1
- package/dist/components/checkbox.js +9 -9
- package/dist/components/choice-list.d.ts +2 -2
- package/dist/components/choice-list.js +16 -18
- package/dist/components/code-block.d.ts +5 -5
- package/dist/components/code-block.js +26 -26
- package/dist/components/collapsible.d.ts +1 -1
- package/dist/components/collapsible.js +7 -11
- package/dist/components/combobox.d.ts +12 -6
- package/dist/components/combobox.js +27 -26
- package/dist/components/command.d.ts +13 -13
- package/dist/components/command.js +61 -73
- package/dist/components/context-menu.d.ts +5 -5
- package/dist/components/context-menu.js +22 -22
- package/dist/components/dialog.d.ts +6 -6
- package/dist/components/dialog.js +23 -28
- package/dist/components/direction.d.ts +1 -1
- package/dist/components/direction.js +1 -1
- package/dist/components/dropdown-menu.d.ts +5 -5
- package/dist/components/dropdown-menu.js +20 -20
- package/dist/components/field.d.ts +11 -11
- package/dist/components/field.js +41 -61
- package/dist/components/file-explorer.d.ts +2 -2
- package/dist/components/file-explorer.js +89 -105
- package/dist/components/file-viewer.d.ts +10 -10
- package/dist/components/file-viewer.js +112 -140
- package/dist/components/form.d.ts +7 -7
- package/dist/components/form.js +24 -28
- package/dist/components/glass-banner.d.ts +3 -3
- package/dist/components/glass-banner.js +21 -24
- package/dist/components/gradient-banner.d.ts +7 -7
- package/dist/components/gradient-banner.js +13 -22
- package/dist/components/hover-card.d.ts +4 -4
- package/dist/components/hover-card.js +6 -6
- package/dist/components/input-group.d.ts +18 -18
- package/dist/components/input-group.js +25 -39
- package/dist/components/input-otp.d.ts +14 -10
- package/dist/components/input-otp.js +15 -15
- package/dist/components/input.d.ts +3 -3
- package/dist/components/input.js +7 -7
- package/dist/components/kbd.d.ts +3 -3
- package/dist/components/kbd.js +5 -5
- package/dist/components/label.d.ts +2 -2
- package/dist/components/label.js +2 -2
- package/dist/components/mention-list.d.ts +3 -3
- package/dist/components/mention-list.js +10 -10
- package/dist/components/menubar.d.ts +6 -6
- package/dist/components/menubar.js +22 -22
- package/dist/components/message-actions.d.ts +2 -2
- package/dist/components/message-actions.js +29 -31
- package/dist/components/message-response.d.ts +3 -3
- package/dist/components/message-response.js +18 -18
- package/dist/components/message-scroller.d.ts +12 -12
- package/dist/components/message-scroller.js +44 -56
- package/dist/components/message.d.ts +11 -11
- package/dist/components/message.js +25 -25
- package/dist/components/navigation-menu.d.ts +2 -2
- package/dist/components/navigation-menu.js +15 -15
- package/dist/components/notice-banner.d.ts +2 -2
- package/dist/components/notice-banner.js +2 -2
- package/dist/components/page-content.d.ts +2 -2
- package/dist/components/page-content.js +2 -2
- package/dist/components/page-header.d.ts +1 -1
- package/dist/components/page-header.js +17 -17
- package/dist/components/pagination.d.ts +9 -9
- package/dist/components/pagination.js +17 -17
- package/dist/components/plan-outline.d.ts +2 -2
- package/dist/components/plan-outline.js +43 -60
- package/dist/components/popover.d.ts +6 -6
- package/dist/components/popover.js +15 -15
- package/dist/components/presence-cursor.d.ts +2 -2
- package/dist/components/presence-cursor.js +3 -3
- package/dist/components/progress.d.ts +1 -1
- package/dist/components/progress.js +8 -8
- package/dist/components/prompt-list.d.ts +3 -3
- package/dist/components/prompt-list.js +6 -6
- package/dist/components/questionnaire.d.ts +19 -19
- package/dist/components/questionnaire.js +183 -242
- package/dist/components/radio-group.d.ts +2 -2
- package/dist/components/radio-group.js +6 -6
- package/dist/components/reasoning-effort.d.ts +3 -3
- package/dist/components/reasoning-effort.js +9 -12
- package/dist/components/record-list.d.ts +66 -0
- package/dist/components/record-list.js +151 -0
- package/dist/components/resizable.d.ts +5 -5
- package/dist/components/resizable.js +76 -102
- package/dist/components/result-card.d.ts +4 -4
- package/dist/components/result-card.js +42 -53
- package/dist/components/result-notice.d.ts +18 -0
- package/dist/components/result-notice.js +29 -0
- package/dist/components/review-card.d.ts +6 -6
- package/dist/components/review-card.js +18 -18
- package/dist/components/rich-text-editor.d.ts +5 -5
- package/dist/components/rich-text-editor.js +56 -72
- package/dist/components/schema-diagram.d.ts +3 -3
- package/dist/components/schema-diagram.js +39 -53
- package/dist/components/scroll-area.d.ts +3 -3
- package/dist/components/scroll-area.js +10 -14
- package/dist/components/search-dialog.d.ts +6 -6
- package/dist/components/search-dialog.js +16 -16
- package/dist/components/search-field.d.ts +1 -1
- package/dist/components/search-field.js +11 -11
- package/dist/components/select.d.ts +5 -9
- package/dist/components/select.js +20 -20
- package/dist/components/selection-slot.d.ts +2 -2
- package/dist/components/selection-slot.js +6 -9
- package/dist/components/separator.d.ts +15 -15
- package/dist/components/separator.js +22 -27
- package/dist/components/settings-list.d.ts +3 -3
- package/dist/components/settings-list.js +5 -5
- package/dist/components/sheet.d.ts +6 -6
- package/dist/components/sheet.js +27 -27
- package/dist/components/sidebar.d.ts +22 -22
- package/dist/components/sidebar.js +57 -58
- package/dist/components/skeleton.d.ts +5 -5
- package/dist/components/skeleton.js +14 -21
- package/dist/components/slider.d.ts +2 -2
- package/dist/components/slider.js +6 -6
- package/dist/components/spinner.d.ts +7 -7
- package/dist/components/spinner.js +22 -26
- package/dist/components/sql-viewer.d.ts +14 -14
- package/dist/components/sql-viewer.js +99 -128
- package/dist/components/state-panel-samples.d.ts +2 -2
- package/dist/components/state-panel-samples.js +209 -245
- package/dist/components/state-panel.d.ts +2 -35
- package/dist/components/state-panel.js +2 -29
- package/dist/components/state-sample.d.ts +8 -8
- package/dist/components/state-sample.js +18 -31
- package/dist/components/switch.d.ts +3 -3
- package/dist/components/switch.js +7 -7
- package/dist/components/table-nuqs.d.ts +2 -2
- package/dist/components/table-nuqs.js +11 -12
- package/dist/components/table.d.ts +4 -4
- package/dist/components/table.js +166 -235
- package/dist/components/tabs.d.ts +2 -2
- package/dist/components/tabs.js +12 -12
- package/dist/components/textarea.d.ts +2 -2
- package/dist/components/textarea.js +6 -8
- package/dist/components/timeline.d.ts +3 -0
- package/dist/components/timeline.js +3 -0
- package/dist/components/toast.d.ts +2 -2
- package/dist/components/toast.js +19 -25
- package/dist/components/toggle-group.d.ts +4 -4
- package/dist/components/toggle-group.js +18 -20
- package/dist/components/toggle.d.ts +4 -4
- package/dist/components/toggle.js +8 -8
- package/dist/components/tool-activity.d.ts +1 -1
- package/dist/components/tool-activity.js +83 -110
- package/dist/components/toolbar-status.d.ts +2 -2
- package/dist/components/toolbar-status.js +7 -7
- package/dist/components/tooltip.d.ts +5 -5
- package/dist/components/tooltip.js +12 -11
- package/dist/components/typed-text.d.ts +2 -2
- package/dist/components/typed-text.js +10 -12
- package/dist/components/view-switcher.d.ts +51 -0
- package/dist/components/view-switcher.js +114 -0
- package/dist/index.d.ts +99 -93
- package/dist/index.js +99 -93
- package/dist/internal/agent-avatar-artwork.d.ts +4 -0
- package/dist/internal/agent-avatar-artwork.js +219 -0
- package/dist/internal/chart-kit.d.ts +142 -0
- package/dist/internal/chart-kit.js +200 -0
- package/dist/internal/charts/bars.d.ts +61 -0
- package/dist/internal/charts/bars.js +86 -0
- package/dist/internal/charts/lines.d.ts +67 -0
- package/dist/internal/charts/lines.js +70 -0
- package/dist/internal/charts/more.d.ts +77 -0
- package/dist/internal/charts/more.js +68 -0
- package/dist/internal/charts/parts.d.ts +54 -0
- package/dist/internal/charts/parts.js +82 -0
- package/dist/internal/charts/timeline-dates.d.ts +38 -0
- package/dist/internal/charts/timeline-dates.js +113 -0
- package/dist/internal/charts/timeline-window.d.ts +31 -0
- package/dist/internal/charts/timeline-window.js +26 -0
- package/dist/internal/charts/timeline.d.ts +72 -0
- package/dist/internal/charts/timeline.js +287 -0
- package/dist/internal/classes.d.ts +1 -1
- package/dist/internal/classes.js +7 -9
- package/dist/internal/code-tokens.d.ts +2 -2
- package/dist/internal/code-tokens.js +12 -12
- package/dist/internal/fieldset.d.ts +1 -1
- package/dist/internal/fieldset.js +6 -6
- package/dist/internal/file-kind.d.ts +1 -1
- package/dist/internal/file-kind.js +43 -51
- package/dist/internal/flow.d.ts +4 -4
- package/dist/internal/flow.js +20 -23
- package/dist/internal/hash.d.ts +1 -0
- package/dist/internal/hash.js +9 -0
- package/dist/internal/languages.js +999 -999
- package/dist/internal/message-scroller.d.ts +3 -3
- package/dist/internal/message-scroller.js +64 -112
- package/dist/internal/pressable.d.ts +1 -1
- package/dist/internal/pressable.js +7 -7
- package/dist/internal/state-panel.d.ts +35 -0
- package/dist/internal/state-panel.js +22 -0
- package/dist/internal/syntax.d.ts +2 -2
- package/dist/internal/syntax.js +36 -47
- package/dist/styles/accordion.css +3 -5
- package/dist/styles/agent-fanout.css +64 -60
- package/dist/styles/alert-dialog.css +12 -26
- package/dist/styles/alert.css +10 -15
- package/dist/styles/attachment.css +56 -98
- package/dist/styles/avatar.css +14 -33
- package/dist/styles/badge.css +11 -36
- package/dist/styles/board.css +571 -0
- package/dist/styles/brand-icon.css +7 -8
- package/dist/styles/breadcrumb.css +4 -7
- package/dist/styles/button-group.css +9 -15
- package/dist/styles/button.css +45 -175
- package/dist/styles/calendar.css +24 -36
- package/dist/styles/canvas.css +2 -3
- package/dist/styles/card.css +7 -23
- package/dist/styles/carousel.css +11 -12
- package/dist/styles/chart.css +215 -31
- package/dist/styles/chat-input.css +15 -39
- package/dist/styles/chat-plan.css +3 -4
- package/dist/styles/chat-sources.css +4 -6
- package/dist/styles/checkbox.css +11 -25
- package/dist/styles/choice-list.css +17 -31
- package/dist/styles/code-block.css +11 -25
- package/dist/styles/collapsible.css +10 -15
- package/dist/styles/combobox.css +24 -17
- package/dist/styles/command.css +8 -9
- package/dist/styles/context-menu.css +4 -2
- package/dist/styles/dialog.css +5 -16
- package/dist/styles/dropdown-menu.css +4 -2
- package/dist/styles/field.css +15 -21
- package/dist/styles/file-explorer.css +19 -33
- package/dist/styles/file-viewer.css +13 -17
- package/dist/styles/form.css +3 -3
- package/dist/styles/glass-banner.css +12 -47
- package/dist/styles/gradient-banner.css +16 -39
- package/dist/styles/hover-card.css +9 -15
- package/dist/styles/index.css +121 -112
- package/dist/styles/input-group.css +61 -69
- package/dist/styles/input-otp.css +18 -9
- package/dist/styles/input.css +19 -11
- package/dist/styles/kbd.css +1 -1
- package/dist/styles/label.css +9 -30
- package/dist/styles/mention-list.css +6 -8
- package/dist/styles/menubar.css +9 -8
- package/dist/styles/message-actions.css +1 -1
- package/dist/styles/message-response.css +3 -5
- package/dist/styles/message-scroller.css +14 -21
- package/dist/styles/message.css +23 -60
- package/dist/styles/navigation-menu.css +15 -30
- package/dist/styles/notice-banner.css +1 -2
- package/dist/styles/page-header.css +11 -10
- package/dist/styles/pagination.css +12 -6
- package/dist/styles/plan-outline.css +20 -37
- package/dist/styles/popover.css +10 -19
- package/dist/styles/presence-cursor.css +1 -2
- package/dist/styles/progress.css +2 -4
- package/dist/styles/prompt-list.css +6 -17
- package/dist/styles/questionnaire.css +16 -40
- package/dist/styles/radio-group.css +12 -23
- package/dist/styles/reasoning-effort.css +8 -15
- package/dist/styles/record-list.css +243 -0
- package/dist/styles/resizable.css +10 -11
- package/dist/styles/result-card.css +4 -4
- package/dist/styles/result-notice.css +80 -0
- package/dist/styles/review-card.css +2 -3
- package/dist/styles/rich-text-editor.css +4 -5
- package/dist/styles/schema-diagram.css +12 -17
- package/dist/styles/scroll-area.css +8 -10
- package/dist/styles/search-dialog.css +1 -5
- package/dist/styles/search-field.css +1 -2
- package/dist/styles/select.css +15 -19
- package/dist/styles/selection-slot.css +1 -2
- package/dist/styles/separator.css +7 -8
- package/dist/styles/settings-list.css +1 -2
- package/dist/styles/sheet.css +40 -73
- package/dist/styles/sidebar.css +32 -34
- package/dist/styles/skeleton.css +9 -11
- package/dist/styles/slider.css +11 -21
- package/dist/styles/spinner.css +2 -2
- package/dist/styles/sql-viewer.css +29 -29
- package/dist/styles/state-panel.css +8 -9
- package/dist/styles/state-sample.css +20 -33
- package/dist/styles/switch.css +11 -18
- package/dist/styles/table.css +62 -81
- package/dist/styles/tabs.css +13 -19
- package/dist/styles/textarea.css +3 -3
- package/dist/styles/themes/chatgpt.css +11 -23
- package/dist/styles/themes/claude.css +12 -24
- package/dist/styles/themes/cloudflare.css +11 -23
- package/dist/styles/themes/discord.css +11 -23
- package/dist/styles/themes/github.css +11 -23
- package/dist/styles/themes/grok.css +11 -23
- package/dist/styles/themes/linear.css +12 -25
- package/dist/styles/themes/neutral.css +11 -23
- package/dist/styles/themes/notion.css +11 -23
- package/dist/styles/themes/perplexity.css +11 -23
- package/dist/styles/themes/raycast.css +11 -23
- package/dist/styles/themes/spotify.css +11 -23
- package/dist/styles/themes/stripe.css +11 -23
- package/dist/styles/themes/supabase.css +11 -23
- package/dist/styles/themes/tulipfarm.css +9 -10
- package/dist/styles/themes/vercel.css +12 -25
- package/dist/styles/timeline.css +276 -0
- package/dist/styles/toast.css +13 -20
- package/dist/styles/toggle-group.css +23 -29
- package/dist/styles/toggle.css +14 -14
- package/dist/styles/tool-activity.css +7 -13
- package/dist/styles/toolbar-status.css +2 -7
- package/dist/styles/tooltip.css +15 -21
- package/dist/styles/view-switcher.css +297 -0
- package/package.json +25 -1
|
@@ -1,58 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { BaseEdge, EdgeLabelRenderer, Handle, Position, ReactFlow, } from
|
|
4
|
-
import { useLayoutEffect, useRef, useState
|
|
5
|
-
import { Check } from
|
|
6
|
-
import { ChevronDown } from
|
|
7
|
-
import { Danger } from
|
|
8
|
-
import { MinusCircle } from
|
|
9
|
-
import { RotateLeft } from
|
|
10
|
-
import { Sparkle } from
|
|
11
|
-
import { cn } from
|
|
12
|
-
import { Button } from
|
|
13
|
-
import { Collapsible, CollapsibleContent, CollapsibleTrigger
|
|
14
|
-
export const agentFanoutStatusNames = [
|
|
15
|
-
|
|
16
|
-
"working",
|
|
17
|
-
"done",
|
|
18
|
-
"failed",
|
|
19
|
-
"stopped",
|
|
20
|
-
];
|
|
21
|
-
export const agentFanoutStateNames = ["running", "done", "stopped"];
|
|
3
|
+
import { BaseEdge, EdgeLabelRenderer, Handle, Position, ReactFlow, } from '@xyflow/react';
|
|
4
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
5
|
+
import { Check } from 'reicon-react/icons/Check';
|
|
6
|
+
import { ChevronDown } from 'reicon-react/icons/ChevronDown';
|
|
7
|
+
import { Danger } from 'reicon-react/icons/Danger';
|
|
8
|
+
import { MinusCircle } from 'reicon-react/icons/MinusCircle';
|
|
9
|
+
import { RotateLeft } from 'reicon-react/icons/RotateLeft';
|
|
10
|
+
import { Sparkle } from 'reicon-react/icons/Sparkle';
|
|
11
|
+
import { cn } from '../internal/classes.js';
|
|
12
|
+
import { Button } from './button.js';
|
|
13
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from './collapsible.js';
|
|
14
|
+
export const agentFanoutStatusNames = ['queued', 'working', 'done', 'failed', 'stopped'];
|
|
15
|
+
export const agentFanoutStateNames = ['running', 'done', 'stopped'];
|
|
22
16
|
const rootTop = 12;
|
|
23
17
|
const rootSize = 44;
|
|
24
18
|
const levelTop = 120;
|
|
25
19
|
const levelGap = 108;
|
|
26
20
|
const nodeLabel = 22;
|
|
27
21
|
const bottomGap = 36;
|
|
28
|
-
const colorCount =
|
|
22
|
+
const colorCount = 10;
|
|
29
23
|
const statusText = {
|
|
30
|
-
queued:
|
|
31
|
-
working:
|
|
32
|
-
done:
|
|
33
|
-
failed:
|
|
34
|
-
stopped:
|
|
24
|
+
queued: 'Queued',
|
|
25
|
+
working: 'Working',
|
|
26
|
+
done: 'Done',
|
|
27
|
+
failed: 'Failed',
|
|
28
|
+
stopped: 'Stopped',
|
|
35
29
|
};
|
|
36
30
|
const seconds = (ms) => `${(ms / 1000).toFixed(1)}s`;
|
|
37
31
|
function phaseText(agents, state, elapsed) {
|
|
38
|
-
const time = elapsed === undefined ?
|
|
39
|
-
if (state ===
|
|
40
|
-
const merged = agents.filter(
|
|
32
|
+
const time = elapsed === undefined ? '' : seconds(elapsed);
|
|
33
|
+
if (state === 'done') {
|
|
34
|
+
const merged = agents.filter(agent => agent.status === 'done').length;
|
|
41
35
|
return {
|
|
42
|
-
text: `Merged ${merged} ${merged === 1 ?
|
|
43
|
-
time:
|
|
36
|
+
text: `Merged ${merged} ${merged === 1 ? 'result' : 'results'}${time && ` in ${time}`}`,
|
|
37
|
+
time: '',
|
|
44
38
|
};
|
|
45
39
|
}
|
|
46
|
-
if (state ===
|
|
47
|
-
return { text: time ? `Stopped after ${time}` :
|
|
48
|
-
const settled = agents.filter(
|
|
49
|
-
const text = agents.every(
|
|
50
|
-
?
|
|
40
|
+
if (state === 'stopped')
|
|
41
|
+
return { text: time ? `Stopped after ${time}` : 'Stopped', time: '' };
|
|
42
|
+
const settled = agents.filter(agent => agent.status === 'done' || agent.status === 'failed').length;
|
|
43
|
+
const text = agents.every(agent => agent.status === 'queued')
|
|
44
|
+
? 'Delegating work'
|
|
51
45
|
: settled === agents.length
|
|
52
|
-
?
|
|
46
|
+
? 'Composing answer'
|
|
53
47
|
: settled > 0
|
|
54
|
-
?
|
|
55
|
-
:
|
|
48
|
+
? 'Merging results'
|
|
49
|
+
: 'Specialists working';
|
|
56
50
|
return { text, time };
|
|
57
51
|
}
|
|
58
52
|
function useWidth() {
|
|
@@ -79,31 +73,22 @@ function flatten(agents, initial, parent = rootId, depth = 1, color) {
|
|
|
79
73
|
parent,
|
|
80
74
|
depth,
|
|
81
75
|
changed: changed || undefined,
|
|
82
|
-
trip: !changed
|
|
83
|
-
? null
|
|
84
|
-
: agent.status === "working"
|
|
85
|
-
? "out"
|
|
86
|
-
: agent.status === "done"
|
|
87
|
-
? "back"
|
|
88
|
-
: null,
|
|
76
|
+
trip: !changed ? null : agent.status === 'working' ? 'out' : agent.status === 'done' ? 'back' : null,
|
|
89
77
|
style: {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
78
|
+
'--sprout-agent-fanout-color': own,
|
|
79
|
+
'--sprout-agent-fanout-index': index,
|
|
80
|
+
'--sprout-agent-fanout-depth': depth - 1,
|
|
93
81
|
},
|
|
94
82
|
};
|
|
95
|
-
return [
|
|
96
|
-
line,
|
|
97
|
-
...flatten(agent.agents ?? [], initial, agent.id, depth + 1, own),
|
|
98
|
-
];
|
|
83
|
+
return [line, ...flatten(agent.agents ?? [], initial, agent.id, depth + 1, own)];
|
|
99
84
|
});
|
|
100
85
|
}
|
|
101
|
-
const rootId =
|
|
86
|
+
const rootId = 'agent-fanout-root';
|
|
102
87
|
// Fresh node objects every render drop React Flow's measured handles, which
|
|
103
88
|
// unmounts the edges and restarts their pulses. Declared handles survive.
|
|
104
89
|
const handle = (type, x, y) => ({
|
|
105
90
|
type,
|
|
106
|
-
position: type ===
|
|
91
|
+
position: type === 'source' ? Position.Bottom : Position.Top,
|
|
107
92
|
x,
|
|
108
93
|
y,
|
|
109
94
|
width: 0,
|
|
@@ -114,49 +99,46 @@ function layout(lines, width, state, rootChanged) {
|
|
|
114
99
|
const children = new Map();
|
|
115
100
|
for (const line of lines)
|
|
116
101
|
children.set(line.parent, [...(children.get(line.parent) ?? []), line]);
|
|
117
|
-
const leaves = lines.filter(
|
|
102
|
+
const leaves = lines.filter(line => !children.has(line.agent.id)).length;
|
|
118
103
|
const column = width / Math.max(leaves, 1);
|
|
119
104
|
const centers = new Map();
|
|
120
105
|
let leaf = 0;
|
|
121
106
|
const place = (id) => {
|
|
122
107
|
const kids = children.get(id);
|
|
123
|
-
const xs = kids?.map(
|
|
108
|
+
const xs = kids?.map(kid => place(kid.agent.id));
|
|
124
109
|
const x = xs ? (xs[0] + xs.at(-1)) / 2 : (leaf++ + 0.5) * column;
|
|
125
110
|
centers.set(id, x);
|
|
126
111
|
return x;
|
|
127
112
|
};
|
|
128
113
|
place(rootId);
|
|
129
|
-
const depth = Math.max(0, ...lines.map(
|
|
114
|
+
const depth = Math.max(0, ...lines.map(line => line.depth));
|
|
130
115
|
const dot = width ? Math.min(40, Math.max(28, column - 12)) : 40;
|
|
131
116
|
const nodes = [
|
|
132
117
|
{
|
|
133
118
|
id: rootId,
|
|
134
|
-
type:
|
|
119
|
+
type: 'root',
|
|
135
120
|
position: { x: width / 2 - rootSize / 2, y: rootTop },
|
|
136
121
|
width: rootSize,
|
|
137
122
|
height: rootSize,
|
|
138
|
-
handles: [handle(
|
|
123
|
+
handles: [handle('source', rootSize / 2, rootSize)],
|
|
139
124
|
data: { state, changed: rootChanged },
|
|
140
125
|
},
|
|
141
126
|
...lines.map((line) => ({
|
|
142
127
|
id: line.agent.id,
|
|
143
|
-
type:
|
|
128
|
+
type: 'agent',
|
|
144
129
|
position: {
|
|
145
130
|
x: centers.get(line.agent.id) - column / 2,
|
|
146
131
|
y: levelTop + (line.depth - 1) * levelGap,
|
|
147
132
|
},
|
|
148
133
|
width: column,
|
|
149
134
|
height: dot + nodeLabel,
|
|
150
|
-
handles: [
|
|
151
|
-
handle("target", column / 2, 0),
|
|
152
|
-
handle("source", column / 2, dot),
|
|
153
|
-
],
|
|
135
|
+
handles: [handle('target', column / 2, 0), handle('source', column / 2, dot)],
|
|
154
136
|
data: line,
|
|
155
137
|
})),
|
|
156
138
|
];
|
|
157
|
-
const edges = lines.map(
|
|
139
|
+
const edges = lines.map(line => ({
|
|
158
140
|
id: `${line.parent}-${line.agent.id}`,
|
|
159
|
-
type:
|
|
141
|
+
type: 'trip',
|
|
160
142
|
source: line.parent,
|
|
161
143
|
target: line.agent.id,
|
|
162
144
|
data: { trip: line.trip, style: line.style },
|
|
@@ -165,20 +147,16 @@ function layout(lines, width, state, rootChanged) {
|
|
|
165
147
|
nodes,
|
|
166
148
|
edges,
|
|
167
149
|
dot,
|
|
168
|
-
height: levelTop +
|
|
169
|
-
Math.max(depth - 1, 0) * levelGap +
|
|
170
|
-
dot +
|
|
171
|
-
nodeLabel +
|
|
172
|
-
bottomGap,
|
|
150
|
+
height: levelTop + Math.max(depth - 1, 0) * levelGap + dot + nodeLabel + bottomGap,
|
|
173
151
|
};
|
|
174
152
|
}
|
|
175
153
|
function RootMark({ data: { state, changed } }) {
|
|
176
|
-
return (_jsxs("span", { "data-slot": "agent-fanout-root", "data-state": state, "data-changed": changed, className: "sprout-agent-fanout-root", children: [state ===
|
|
154
|
+
return (_jsxs("span", { "data-slot": "agent-fanout-root", "data-state": state, "data-changed": changed, className: "sprout-agent-fanout-root", children: [state === 'done' ? _jsx(Check, { size: 18 }) : state === 'stopped' ? _jsx(MinusCircle, { size: 18 }) : _jsx(Sparkle, { size: 18 }), _jsx(Handle, { type: "source", position: Position.Bottom, isConnectable: false, className: "sprout-agent-fanout-handle" })] }));
|
|
177
155
|
}
|
|
178
156
|
function AgentMark({ data: { agent, changed, style } }) {
|
|
179
157
|
return (_jsxs("div", { "data-slot": "agent-fanout-node", "data-status": agent.status, "data-changed": changed, className: "sprout-agent-fanout-node", style: style, children: [_jsxs("span", { className: "sprout-agent-fanout-dot", children: [_jsx(NodeMark, { agent: agent }), _jsx(Handle, { type: "target", position: Position.Top, isConnectable: false, className: "sprout-agent-fanout-handle" }), agent.agents && agent.agents.length > 0 && (_jsx(Handle, { type: "source", position: Position.Bottom, isConnectable: false, className: "sprout-agent-fanout-handle" }))] }), _jsx("span", { className: "sprout-agent-fanout-node-name", children: agent.name })] }));
|
|
180
158
|
}
|
|
181
|
-
function TripLine({ id, sourceX, sourceY, targetX, targetY, data
|
|
159
|
+
function TripLine({ id, sourceX, sourceY, targetX, targetY, data }) {
|
|
182
160
|
const drop = targetY - sourceY;
|
|
183
161
|
const d = `M ${sourceX} ${sourceY} C ${sourceX} ${sourceY + drop * 0.5}, ${targetX} ${sourceY + drop * 0.2}, ${targetX} ${targetY}`;
|
|
184
162
|
const trip = data?.trip;
|
|
@@ -188,16 +166,16 @@ const nodeTypes = { root: RootMark, agent: AgentMark };
|
|
|
188
166
|
const edgeTypes = { trip: TripLine };
|
|
189
167
|
const viewport = { x: 0, y: 0, zoom: 1 };
|
|
190
168
|
function NodeMark({ agent }) {
|
|
191
|
-
if (agent.status ===
|
|
192
|
-
return _jsx(Check, { size: 16, "aria-hidden": "true" });
|
|
193
|
-
if (agent.status ===
|
|
169
|
+
if (agent.status === 'done')
|
|
170
|
+
return _jsx(Check, { size: 16, strokeWidth: 2.5, "aria-hidden": "true" });
|
|
171
|
+
if (agent.status === 'failed')
|
|
194
172
|
return _jsx(Danger, { size: 16, "aria-hidden": "true" });
|
|
195
173
|
return _jsx("span", { "aria-hidden": "true", children: agent.icon });
|
|
196
174
|
}
|
|
197
175
|
function StatusMark({ agent }) {
|
|
198
|
-
if (agent.status ===
|
|
199
|
-
return (_jsxs(_Fragment, { children: [_jsx(Check, { size: 12, "aria-hidden": "true" }), agent.duration === undefined ?
|
|
200
|
-
if (agent.status ===
|
|
176
|
+
if (agent.status === 'done')
|
|
177
|
+
return (_jsxs(_Fragment, { children: [_jsx(Check, { size: 12, "aria-hidden": "true" }), agent.duration === undefined ? 'Done' : seconds(agent.duration)] }));
|
|
178
|
+
if (agent.status === 'working')
|
|
201
179
|
return (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", className: "sprout-agent-fanout-pulse" }), "Working"] }));
|
|
202
180
|
return _jsx(_Fragment, { children: statusText[agent.status] });
|
|
203
181
|
}
|
|
@@ -206,7 +184,7 @@ function StatusMark({ agent }) {
|
|
|
206
184
|
* they find. Each status change sends a pulse along the subagent's line:
|
|
207
185
|
* down when it starts, back up when it finishes.
|
|
208
186
|
*/
|
|
209
|
-
export function AgentFanout({ task, agents, state =
|
|
187
|
+
export function AgentFanout({ task, agents, state = 'running', elapsed, label, defaultOpen = false, onStop, onRestart, className, }) {
|
|
210
188
|
const [graphRef, width] = useWidth();
|
|
211
189
|
// Only changes after the first render animate, so a finished fanout
|
|
212
190
|
// renders still instead of replaying every pulse.
|
|
@@ -217,12 +195,12 @@ export function AgentFanout({ task, agents, state = "running", elapsed, label, d
|
|
|
217
195
|
const phase = phaseText(agents, state, elapsed);
|
|
218
196
|
const lines = flatten(agents, initial.statuses);
|
|
219
197
|
const graph = layout(lines, width, state, initial.state !== state || undefined);
|
|
220
|
-
const finished = lines.filter(({ agent }) => agent.status ===
|
|
221
|
-
return (_jsxs("section", { "data-slot": "agent-fanout", "data-state": state, "aria-label": "Subagents", className: cn(
|
|
198
|
+
const finished = lines.filter(({ agent }) => agent.status === 'done' || agent.status === 'failed').length;
|
|
199
|
+
return (_jsxs("section", { "data-slot": "agent-fanout", "data-state": state, "aria-label": "Subagents", className: cn('sprout-agent-fanout', className), children: [_jsxs("div", { className: "sprout-agent-fanout-panel", children: [_jsx("div", { className: "sprout-agent-fanout-task", children: _jsx("span", { className: "sprout-agent-fanout-task-text", children: task }) }), _jsx("div", { ref: graphRef, "aria-hidden": "true", "data-slot": "agent-fanout-graph", className: "sprout-agent-fanout-graph", style: {
|
|
222
200
|
height: graph.height,
|
|
223
|
-
|
|
201
|
+
'--sprout-agent-fanout-dot': `${graph.dot}px`,
|
|
224
202
|
}, children: width > 0 && (_jsx(ReactFlow, { className: "sprout-agent-fanout-flow", nodes: graph.nodes, edges: graph.edges, nodeTypes: nodeTypes, edgeTypes: edgeTypes, defaultViewport: viewport, minZoom: 1, maxZoom: 1, panOnDrag: false, panOnScroll: false, zoomOnScroll: false, zoomOnPinch: false, zoomOnDoubleClick: false, preventScrolling: false, nodesDraggable: false, nodesConnectable: false, nodesFocusable: false, edgesFocusable: false, elementsSelectable: false, proOptions: { hideAttribution: true } })) }), _jsxs(Collapsible, { defaultOpen: defaultOpen, className: "sprout-agent-fanout-details", children: [_jsxs(CollapsibleTrigger, { className: "sprout-agent-fanout-trigger", children: [_jsx("span", { className: "sprout-agent-fanout-trigger-label", children: "Details" }), _jsx("span", { className: "sprout-agent-fanout-trigger-count", children: `${finished} of ${lines.length} finished` }), _jsx(ChevronDown, { size: 14, "aria-hidden": "true", "data-slot": "collapsible-indicator" })] }), _jsx(CollapsibleContent, { keepMounted: true, children: _jsx("ul", { "aria-label": "Subagent status", className: "sprout-agent-fanout-rows", children: lines.map(({ agent, changed, style }) => {
|
|
225
|
-
const settled = agent.status ===
|
|
226
|
-
return (_jsxs("li", { "data-slot": "agent-fanout-row", "data-status": agent.status, className: "sprout-agent-fanout-row", style: style, children: [_jsx("span", { className: "sprout-agent-fanout-row-name", children: agent.name }), _jsx("span", { "data-changed": changed, className: "sprout-agent-fanout-row-detail", children: settled && agent.result ? agent.result : agent.task }, settled && agent.result ?
|
|
227
|
-
}) }) })] })] }), _jsxs("div", { className: "sprout-agent-fanout-footer", children: [_jsxs("p", { className: "sprout-agent-fanout-phase", children: [_jsx("span", { role: "status", children: label ?? phase.text }), !label && phase.time &&
|
|
203
|
+
const settled = agent.status === 'done' || agent.status === 'failed';
|
|
204
|
+
return (_jsxs("li", { "data-slot": "agent-fanout-row", "data-status": agent.status, className: "sprout-agent-fanout-row", style: style, children: [_jsx("span", { className: "sprout-agent-fanout-row-name", children: agent.name }), _jsx("span", { "data-changed": changed, className: "sprout-agent-fanout-row-detail", children: settled && agent.result ? agent.result : agent.task }, settled && agent.result ? 'result' : 'task'), _jsx("span", { "data-changed": changed, className: "sprout-agent-fanout-row-status", children: _jsx(StatusMark, { agent: agent }) }, agent.status)] }, agent.id));
|
|
205
|
+
}) }) })] })] }), _jsxs("div", { className: "sprout-agent-fanout-footer", children: [_jsxs("p", { className: "sprout-agent-fanout-phase", children: [_jsx("span", { role: "status", children: label ?? phase.text }), !label && phase.time && _jsx("span", { className: "sprout-agent-fanout-time", children: phase.time })] }), state === 'running' && onStop && (_jsxs(Button, { variant: "outline", size: "sm", onClick: onStop, className: "sprout-agent-fanout-action", children: [_jsx(MinusCircle, { size: 14, "aria-hidden": "true" }), "Stop"] })), state !== 'running' && onRestart && (_jsxs(Button, { variant: "outline", size: "sm", onClick: onRestart, className: "sprout-agent-fanout-action", children: [_jsx(RotateLeft, { size: 14, "aria-hidden": "true" }), "Run again"] }))] })] }));
|
|
228
206
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AlertDialog as AlertDialogPrimitive } from
|
|
2
|
-
import { useRender } from
|
|
3
|
-
import { type ButtonProps, type ButtonSize, type ButtonVariant } from
|
|
4
|
-
export declare const alertDialogSizeNames: readonly ["
|
|
1
|
+
import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import { type ButtonProps, type ButtonSize, type ButtonVariant } from './button.js';
|
|
4
|
+
export declare const alertDialogSizeNames: readonly ["md", "sm"];
|
|
5
5
|
export type AlertDialogSize = (typeof alertDialogSizeNames)[number];
|
|
6
6
|
export type AlertDialogProps = AlertDialogPrimitive.Root.Props;
|
|
7
7
|
export declare function AlertDialog(props: AlertDialogProps): import("react").JSX.Element;
|
|
@@ -15,21 +15,21 @@ export interface AlertDialogContentProps extends AlertDialogPrimitive.Popup.Prop
|
|
|
15
15
|
/** `sm` centers the header and splits the footer into two equal buttons. */
|
|
16
16
|
size?: AlertDialogSize;
|
|
17
17
|
/** Where the portal renders. Defaults to `document.body`. */
|
|
18
|
-
container?: AlertDialogPrimitive.Portal.Props[
|
|
18
|
+
container?: AlertDialogPrimitive.Portal.Props['container'];
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* The alert dialog surface. It renders its own portal and overlay, so place
|
|
22
22
|
* it directly inside `AlertDialog`.
|
|
23
23
|
*/
|
|
24
24
|
export declare function AlertDialogContent({ className, size, container, ...props }: AlertDialogContentProps): import("react").JSX.Element;
|
|
25
|
-
type PartSlot =
|
|
25
|
+
type PartSlot = 'alert-dialog-header' | 'alert-dialog-footer' | 'alert-dialog-media';
|
|
26
26
|
export interface AlertDialogPartState extends Record<string, unknown> {
|
|
27
27
|
slot: PartSlot;
|
|
28
28
|
}
|
|
29
|
-
export type AlertDialogPartProps = useRender.ComponentProps<
|
|
29
|
+
export type AlertDialogPartProps = useRender.ComponentProps<'div', AlertDialogPartState>;
|
|
30
30
|
/**
|
|
31
31
|
* Groups media, title, and description. Centered on narrow screens and in
|
|
32
|
-
* `sm` dialogs; from 640px
|
|
32
|
+
* `sm` dialogs; from 640px an `md` dialog aligns it to the start with the
|
|
33
33
|
* media beside the text.
|
|
34
34
|
*/
|
|
35
35
|
export declare const AlertDialogHeader: ({ className, render, ref, ...props }: AlertDialogPartProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { AlertDialog as AlertDialogPrimitive } from
|
|
4
|
-
import { mergeProps } from
|
|
5
|
-
import { useRender } from
|
|
6
|
-
import { cn, stateClassName } from
|
|
7
|
-
import { Button
|
|
8
|
-
export const alertDialogSizeNames = [
|
|
3
|
+
import { AlertDialog as AlertDialogPrimitive } from '@base-ui/react/alert-dialog';
|
|
4
|
+
import { mergeProps } from '@base-ui/react/merge-props';
|
|
5
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
6
|
+
import { cn, stateClassName } from '../internal/classes.js';
|
|
7
|
+
import { Button } from './button.js';
|
|
8
|
+
export const alertDialogSizeNames = ['md', 'sm'];
|
|
9
9
|
export function AlertDialog(props) {
|
|
10
10
|
return _jsx(AlertDialogPrimitive.Root, { "data-slot": "alert-dialog", ...props });
|
|
11
11
|
}
|
|
12
12
|
export function AlertDialogTrigger(props) {
|
|
13
|
-
return
|
|
13
|
+
return _jsx(AlertDialogPrimitive.Trigger, { "data-slot": "alert-dialog-trigger", ...props });
|
|
14
14
|
}
|
|
15
15
|
export function AlertDialogPortal(props) {
|
|
16
|
-
return
|
|
16
|
+
return _jsx(AlertDialogPrimitive.Portal, { "data-slot": "alert-dialog-portal", ...props });
|
|
17
17
|
}
|
|
18
18
|
export function AlertDialogOverlay({ className, ...props }) {
|
|
19
|
-
return (_jsx(AlertDialogPrimitive.Backdrop, { "data-slot": "alert-dialog-overlay", ...props, className: stateClassName(
|
|
19
|
+
return (_jsx(AlertDialogPrimitive.Backdrop, { "data-slot": "alert-dialog-overlay", ...props, className: stateClassName('sprout-alert-dialog-overlay', className) }));
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* The alert dialog surface. It renders its own portal and overlay, so place
|
|
23
23
|
* it directly inside `AlertDialog`.
|
|
24
24
|
*/
|
|
25
|
-
export function AlertDialogContent({ className, size =
|
|
26
|
-
return (_jsxs(AlertDialogPortal, { container: container, children: [_jsx(AlertDialogOverlay, {}), _jsx(AlertDialogPrimitive.Popup, { "data-slot": "alert-dialog-content", "data-size": size, ...props, className: stateClassName(
|
|
25
|
+
export function AlertDialogContent({ className, size = 'md', container, ...props }) {
|
|
26
|
+
return (_jsxs(AlertDialogPortal, { container: container, children: [_jsx(AlertDialogOverlay, {}), _jsx(AlertDialogPrimitive.Popup, { "data-slot": "alert-dialog-content", "data-size": size, ...props, className: stateClassName('sprout-alert-dialog-content', className) })] }));
|
|
27
27
|
}
|
|
28
28
|
function part(slot, base) {
|
|
29
29
|
return function AlertDialogPart({ className, render, ref, ...props }) {
|
|
30
30
|
return useRender({
|
|
31
|
-
defaultTagName:
|
|
31
|
+
defaultTagName: 'div',
|
|
32
32
|
ref,
|
|
33
33
|
render,
|
|
34
|
-
props: mergeProps({
|
|
34
|
+
props: mergeProps({ 'data-slot': slot, className: cn(base, className) }, props),
|
|
35
35
|
state: { slot },
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Groups media, title, and description. Centered on narrow screens and in
|
|
41
|
-
* `sm` dialogs; from 640px
|
|
41
|
+
* `sm` dialogs; from 640px an `md` dialog aligns it to the start with the
|
|
42
42
|
* media beside the text.
|
|
43
43
|
*/
|
|
44
|
-
export const AlertDialogHeader = part(
|
|
44
|
+
export const AlertDialogHeader = part('alert-dialog-header', 'sprout-alert-dialog-header');
|
|
45
45
|
/**
|
|
46
46
|
* A tinted action bar pinned to the bottom edge. Actions stack in reverse
|
|
47
47
|
* order on narrow screens and align right from 640px; `sm` dialogs always
|
|
48
48
|
* split it into two equal columns.
|
|
49
49
|
*/
|
|
50
|
-
export const AlertDialogFooter = part(
|
|
50
|
+
export const AlertDialogFooter = part('alert-dialog-footer', 'sprout-alert-dialog-footer');
|
|
51
51
|
/** A 40px tile for an icon above or beside the title. */
|
|
52
|
-
export const AlertDialogMedia = part(
|
|
52
|
+
export const AlertDialogMedia = part('alert-dialog-media', 'sprout-alert-dialog-media');
|
|
53
53
|
export function AlertDialogTitle({ className, ...props }) {
|
|
54
|
-
return (_jsx(AlertDialogPrimitive.Title, { "data-slot": "alert-dialog-title", ...props, className: stateClassName(
|
|
54
|
+
return (_jsx(AlertDialogPrimitive.Title, { "data-slot": "alert-dialog-title", ...props, className: stateClassName('sprout-alert-dialog-title', className) }));
|
|
55
55
|
}
|
|
56
56
|
export function AlertDialogDescription({ className, ...props }) {
|
|
57
|
-
return (_jsx(AlertDialogPrimitive.Description, { "data-slot": "alert-dialog-description", ...props, className: stateClassName(
|
|
57
|
+
return (_jsx(AlertDialogPrimitive.Description, { "data-slot": "alert-dialog-description", ...props, className: stateClassName('sprout-alert-dialog-description', className) }));
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* The confirming button. It does not close the dialog by itself, so the
|
|
@@ -64,6 +64,6 @@ export function AlertDialogAction(props) {
|
|
|
64
64
|
return _jsx(Button, { "data-slot": "alert-dialog-action", ...props });
|
|
65
65
|
}
|
|
66
66
|
/** Closes the dialog. An outline button unless `variant` says otherwise. */
|
|
67
|
-
export function AlertDialogCancel({ variant =
|
|
67
|
+
export function AlertDialogCancel({ variant = 'outline', size = 'md', ...props }) {
|
|
68
68
|
return (_jsx(AlertDialogPrimitive.Close, { "data-slot": "alert-dialog-cancel", render: _jsx(Button, { variant: variant, size: size }), ...props }));
|
|
69
69
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { useRender } from
|
|
1
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
2
2
|
export declare const alertVariantNames: readonly ["default", "destructive"];
|
|
3
3
|
export type AlertVariant = (typeof alertVariantNames)[number];
|
|
4
4
|
export interface AlertVariantOptions {
|
|
5
5
|
variant?: AlertVariant | null;
|
|
6
6
|
className?: string;
|
|
7
7
|
}
|
|
8
|
-
export declare function alertVariants({ variant, className
|
|
8
|
+
export declare function alertVariants({ variant, className }?: AlertVariantOptions): string;
|
|
9
9
|
export interface AlertState extends Record<string, unknown> {
|
|
10
|
-
slot:
|
|
10
|
+
slot: 'alert';
|
|
11
11
|
variant: AlertVariant;
|
|
12
12
|
}
|
|
13
|
-
export interface AlertProps extends useRender.ComponentProps<
|
|
13
|
+
export interface AlertProps extends useRender.ComponentProps<'div', AlertState> {
|
|
14
14
|
variant?: AlertVariant;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
@@ -18,11 +18,11 @@ export interface AlertProps extends useRender.ComponentProps<"div", AlertState>
|
|
|
18
18
|
* pass `role="status"` or `role="note"` for messages that should not interrupt.
|
|
19
19
|
*/
|
|
20
20
|
export declare function Alert({ className, variant, render, ref, role, ...props }: AlertProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
21
|
-
type PartSlot =
|
|
21
|
+
type PartSlot = 'alert-title' | 'alert-description' | 'alert-action';
|
|
22
22
|
export interface AlertPartState extends Record<string, unknown> {
|
|
23
23
|
slot: PartSlot;
|
|
24
24
|
}
|
|
25
|
-
export type AlertPartProps = useRender.ComponentProps<
|
|
25
|
+
export type AlertPartProps = useRender.ComponentProps<'div', AlertPartState>;
|
|
26
26
|
export declare const AlertTitle: ({ className, render, ref, ...props }: AlertPartProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
27
27
|
export declare const AlertDescription: ({ className, render, ref, ...props }: AlertPartProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
28
28
|
/** Pins a compact control, such as an Undo button, to the top-right corner. */
|
package/dist/components/alert.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { mergeProps } from
|
|
2
|
-
import { useRender } from
|
|
3
|
-
import { cn } from
|
|
4
|
-
export const alertVariantNames = [
|
|
5
|
-
export function alertVariants({ variant, className
|
|
6
|
-
return cn(
|
|
1
|
+
import { mergeProps } from '@base-ui/react/merge-props';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import { cn } from '../internal/classes.js';
|
|
4
|
+
export const alertVariantNames = ['default', 'destructive'];
|
|
5
|
+
export function alertVariants({ variant, className } = {}) {
|
|
6
|
+
return cn('sprout-alert', `sprout-alert-${variant ?? 'default'}`, className);
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
9
|
* A static message block. It announces itself with `role="alert"` by default;
|
|
10
10
|
* pass `role="status"` or `role="note"` for messages that should not interrupt.
|
|
11
11
|
*/
|
|
12
|
-
export function Alert({ className, variant =
|
|
12
|
+
export function Alert({ className, variant = 'default', render, ref, role = 'alert', ...props }) {
|
|
13
13
|
return useRender({
|
|
14
|
-
defaultTagName:
|
|
14
|
+
defaultTagName: 'div',
|
|
15
15
|
ref,
|
|
16
16
|
render,
|
|
17
17
|
props: mergeProps({ role, className: alertVariants({ variant, className }) }, props),
|
|
18
|
-
state: { slot:
|
|
18
|
+
state: { slot: 'alert', variant },
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
21
|
function part(slot, base) {
|
|
22
22
|
return function AlertPart({ className, render, ref, ...props }) {
|
|
23
23
|
return useRender({
|
|
24
|
-
defaultTagName:
|
|
24
|
+
defaultTagName: 'div',
|
|
25
25
|
ref,
|
|
26
26
|
render,
|
|
27
27
|
props: mergeProps({ className: cn(base, className) }, props),
|
|
@@ -29,7 +29,7 @@ function part(slot, base) {
|
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
export const AlertTitle = part(
|
|
33
|
-
export const AlertDescription = part(
|
|
32
|
+
export const AlertTitle = part('alert-title', 'sprout-alert-title');
|
|
33
|
+
export const AlertDescription = part('alert-description', 'sprout-alert-description');
|
|
34
34
|
/** Pins a compact control, such as an Undo button, to the top-right corner. */
|
|
35
|
-
export const AlertAction = part(
|
|
35
|
+
export const AlertAction = part('alert-action', 'sprout-alert-action');
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ComponentProps } from
|
|
2
|
-
export interface AspectRatioProps extends ComponentProps<
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
export interface AspectRatioProps extends ComponentProps<'div'> {
|
|
3
3
|
/** Width divided by height, such as `16 / 9`, `4 / 3`, or `1`. */
|
|
4
4
|
ratio: number;
|
|
5
5
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from
|
|
2
|
+
import { cn } from '../internal/classes.js';
|
|
3
3
|
/** Keeps its content at a fixed width-to-height ratio as its width changes. */
|
|
4
4
|
export function AspectRatio({ ratio, className, style, ...props }) {
|
|
5
|
-
return (_jsx("div", { "data-slot": "aspect-ratio", className: cn(
|
|
5
|
+
return (_jsx("div", { "data-slot": "aspect-ratio", className: cn('sprout-aspect-ratio', className), style: { ...style, '--sprout-aspect-ratio': ratio }, ...props }));
|
|
6
6
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type ComponentProps, type ReactElement } from
|
|
2
|
-
import { useRender } from
|
|
3
|
-
import { type FileKind } from
|
|
4
|
-
import { type ButtonProps } from
|
|
1
|
+
import { type ComponentProps, type ReactElement } from 'react';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
|
+
import { type FileKind } from '../internal/file-kind.js';
|
|
4
|
+
import { type ButtonProps } from './button.js';
|
|
5
5
|
export declare const attachmentStateNames: readonly ["idle", "uploading", "processing", "error", "done"];
|
|
6
|
-
export declare const attachmentSizeNames: readonly ["
|
|
6
|
+
export declare const attachmentSizeNames: readonly ["lg", "md", "sm"];
|
|
7
7
|
export declare const attachmentOrientationNames: readonly ["horizontal", "vertical"];
|
|
8
8
|
export declare const attachmentMediaVariantNames: readonly ["icon", "image"];
|
|
9
9
|
export declare const attachmentGroupVariantNames: readonly ["carousel", "grid", "inline", "list"];
|
|
@@ -19,7 +19,7 @@ export type FileAttachmentVariant = (typeof fileAttachmentVariantNames)[number];
|
|
|
19
19
|
export type FileAttachmentState = (typeof fileAttachmentStateNames)[number];
|
|
20
20
|
export type FileTypeIconSize = (typeof fileTypeIconSizeNames)[number];
|
|
21
21
|
export type { FileKind };
|
|
22
|
-
export interface AttachmentProps extends ComponentProps<
|
|
22
|
+
export interface AttachmentProps extends ComponentProps<'div'> {
|
|
23
23
|
/** `idle` dashes the border, `uploading` and `processing` shimmer the title and dim image media, `error` turns it red. */
|
|
24
24
|
state?: AttachmentState | undefined;
|
|
25
25
|
size?: AttachmentSize | undefined;
|
|
@@ -27,23 +27,23 @@ export interface AttachmentProps extends ComponentProps<"div"> {
|
|
|
27
27
|
}
|
|
28
28
|
/** A file card built from media, content, and actions. */
|
|
29
29
|
export declare function Attachment({ className, state, size, orientation, ...props }: AttachmentProps): import("react").JSX.Element;
|
|
30
|
-
export interface AttachmentMediaProps extends ComponentProps<
|
|
30
|
+
export interface AttachmentMediaProps extends ComponentProps<'div'> {
|
|
31
31
|
/** `icon` centers an icon or spinner; `image` crops an `img` to the square. */
|
|
32
32
|
variant?: AttachmentMediaVariant | undefined;
|
|
33
33
|
}
|
|
34
34
|
export declare function AttachmentMedia({ className, variant, ...props }: AttachmentMediaProps): import("react").JSX.Element;
|
|
35
|
-
export declare function AttachmentContent({ className, ...props }: ComponentProps<
|
|
35
|
+
export declare function AttachmentContent({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
36
36
|
/** A single-line name. It shimmers while the attachment uploads or processes. */
|
|
37
|
-
export declare function AttachmentTitle({ className, ...props }: ComponentProps<
|
|
38
|
-
export declare function AttachmentDescription({ className, ...props }: ComponentProps<
|
|
37
|
+
export declare function AttachmentTitle({ className, ...props }: ComponentProps<'span'>): import("react").JSX.Element;
|
|
38
|
+
export declare function AttachmentDescription({ className, ...props }: ComponentProps<'span'>): import("react").JSX.Element;
|
|
39
39
|
/** Sits above the trigger. Vertical attachments float it over the media corner. */
|
|
40
|
-
export declare function AttachmentActions({ className, ...props }: ComponentProps<
|
|
40
|
+
export declare function AttachmentActions({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
41
41
|
/** A ghost `icon-xs` Button. Give icon-only actions an `aria-label`. */
|
|
42
42
|
export declare function AttachmentAction({ variant, size, ...props }: ButtonProps): import("react").JSX.Element;
|
|
43
|
-
export type AttachmentTriggerProps = useRender.ComponentProps<
|
|
43
|
+
export type AttachmentTriggerProps = useRender.ComponentProps<'button'>;
|
|
44
44
|
/** Stretches over the whole attachment so a click anywhere opens it. Name it with `aria-label`. */
|
|
45
45
|
export declare function AttachmentTrigger({ className, render, type, ...props }: AttachmentTriggerProps): ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
46
|
-
export interface AttachmentGroupProps extends ComponentProps<
|
|
46
|
+
export interface AttachmentGroupProps extends ComponentProps<'div'> {
|
|
47
47
|
/**
|
|
48
48
|
* `carousel` scrolls one row sideways with edge arrows, `grid` makes two
|
|
49
49
|
* columns (three from 640px), `inline` wraps, and `list` stacks.
|
|
@@ -51,7 +51,7 @@ export interface AttachmentGroupProps extends ComponentProps<"div"> {
|
|
|
51
51
|
variant?: AttachmentGroupVariant | undefined;
|
|
52
52
|
}
|
|
53
53
|
export declare function AttachmentGroup(props: AttachmentGroupProps): import("react").JSX.Element;
|
|
54
|
-
export interface FileTypeIconProps extends Omit<ComponentProps<
|
|
54
|
+
export interface FileTypeIconProps extends Omit<ComponentProps<'svg'>, 'children'> {
|
|
55
55
|
name: string;
|
|
56
56
|
mediaType: string;
|
|
57
57
|
/** `sm` is 20 × 24px for rows and chips; `lg` is 30 × 36px for grid previews. */
|
|
@@ -60,10 +60,10 @@ export interface FileTypeIconProps extends Omit<ComponentProps<"svg">, "children
|
|
|
60
60
|
/** A paper glyph with a colored extension badge, such as PDF or XLSX. Decorative. */
|
|
61
61
|
export declare function FileTypeIcon({ name, mediaType, size, className, ...props }: FileTypeIconProps): import("react").JSX.Element;
|
|
62
62
|
export type AttachmentFileSource = {
|
|
63
|
-
kind:
|
|
63
|
+
kind: 'local';
|
|
64
64
|
file: File;
|
|
65
65
|
} | {
|
|
66
|
-
kind:
|
|
66
|
+
kind: 'remote';
|
|
67
67
|
url: string;
|
|
68
68
|
};
|
|
69
69
|
export interface AttachmentFile {
|
|
@@ -93,7 +93,7 @@ export interface FileAttachmentProps {
|
|
|
93
93
|
/** Peeks at images, text, code, JSON, and Markdown in a card on hover or focus. Needs a `source` or `url`. */
|
|
94
94
|
preview?: boolean | undefined;
|
|
95
95
|
/** The verb in the open button's name, such as “Download report.pdf”. */
|
|
96
|
-
actionLabel?:
|
|
96
|
+
actionLabel?: 'Inspect' | 'Download' | undefined;
|
|
97
97
|
className?: string | undefined;
|
|
98
98
|
}
|
|
99
99
|
/** A ready-made file row, card, inline mention, or chip with upload states, retry, and remove. */
|
|
@@ -115,4 +115,4 @@ export interface LocalFileAttachmentProps {
|
|
|
115
115
|
preview?: boolean | undefined;
|
|
116
116
|
}
|
|
117
117
|
/** A chip for a `File` still in browser memory, with a live image preview. */
|
|
118
|
-
export declare function LocalFileAttachment({ file, onRemove, onOpen, viewable, preview
|
|
118
|
+
export declare function LocalFileAttachment({ file, onRemove, onOpen, viewable, preview }: LocalFileAttachmentProps): import("react").JSX.Element;
|