@tulipfarm/sprout 0.3.0 → 0.4.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 +45 -40
- package/dist/components/accordion.d.ts +2 -2
- package/dist/components/accordion.js +9 -9
- package/dist/components/agent-fanout.d.ts +2 -2
- package/dist/components/agent-fanout.js +65 -87
- package/dist/components/alert-dialog.d.ts +6 -6
- package/dist/components/alert-dialog.js +20 -20
- 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 +17 -17
- package/dist/components/attachment.js +82 -115
- package/dist/components/avatar.d.ts +10 -10
- package/dist/components/avatar.js +14 -14
- 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 +11 -11
- package/dist/components/button.js +46 -56
- 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 +6 -6
- 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 +13 -11
- 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 +3 -3
- package/dist/components/combobox.js +24 -24
- 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 +5 -5
- 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 +11 -11
- package/dist/components/input-group.js +22 -36
- package/dist/components/input-otp.d.ts +10 -10
- package/dist/components/input-otp.js +13 -15
- package/dist/components/input.d.ts +1 -1
- 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 +16 -16
- 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 +10 -5
- 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 +2 -2
- 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 +1 -1
- 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 +3 -3
- 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 +5 -5
- 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 +7 -7
- package/dist/components/state-sample.js +18 -31
- package/dist/components/switch.d.ts +1 -1
- 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 +2 -2
- package/dist/components/toggle-group.js +18 -20
- package/dist/components/toggle.d.ts +2 -2
- 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 +98 -93
- package/dist/index.js +98 -93
- 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/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 +51 -93
- package/dist/styles/avatar.css +17 -24
- 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 +8 -14
- package/dist/styles/button.css +22 -27
- 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 +3 -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 +11 -15
- package/dist/styles/command.css +5 -8
- package/dist/styles/context-menu.css +2 -2
- package/dist/styles/dialog.css +5 -16
- package/dist/styles/dropdown-menu.css +2 -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 +17 -35
- package/dist/styles/hover-card.css +9 -15
- package/dist/styles/index.css +116 -108
- package/dist/styles/input-group.css +25 -41
- package/dist/styles/input-otp.css +5 -6
- package/dist/styles/input.css +5 -5
- 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 +5 -6
- 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 +14 -29
- package/dist/styles/notice-banner.css +1 -2
- package/dist/styles/page-header.css +7 -10
- package/dist/styles/pagination.css +1 -4
- 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 +17 -3
- package/dist/styles/result-notice.css +80 -0
- package/dist/styles/review-card.css +2 -3
- package/dist/styles/rich-text-editor.css +1 -2
- 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 +7 -7
- 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 +17 -21
- 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 +51 -77
- package/dist/styles/tabs.css +12 -16
- 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 +17 -23
- package/dist/styles/toggle.css +8 -8
- 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 +279 -0
- package/package.json +21 -1
|
@@ -1,90 +1,65 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Children, createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, } from
|
|
4
|
-
import { mergeProps } from
|
|
5
|
-
import { useRender } from
|
|
6
|
-
import { ChevronLeft } from
|
|
7
|
-
import { ChevronRight } from
|
|
8
|
-
import { Image } from
|
|
9
|
-
import { Upload } from
|
|
10
|
-
import { X } from
|
|
11
|
-
import { cn } from
|
|
12
|
-
import { defaultFileAccept, fileKind, formatFileSize
|
|
13
|
-
import { Button } from
|
|
14
|
-
import { FilePreview, FileViewer, isPreviewableFile
|
|
15
|
-
import { HoverCard, HoverCardContent, HoverCardTrigger } from
|
|
16
|
-
import { Spinner } from
|
|
17
|
-
export const attachmentStateNames = [
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
];
|
|
24
|
-
export const
|
|
25
|
-
export const attachmentOrientationNames = ["horizontal", "vertical"];
|
|
26
|
-
export const attachmentMediaVariantNames = ["icon", "image"];
|
|
27
|
-
export const attachmentGroupVariantNames = [
|
|
28
|
-
"carousel",
|
|
29
|
-
"grid",
|
|
30
|
-
"inline",
|
|
31
|
-
"list",
|
|
32
|
-
];
|
|
33
|
-
export const fileAttachmentVariantNames = [
|
|
34
|
-
"list",
|
|
35
|
-
"grid",
|
|
36
|
-
"inline",
|
|
37
|
-
"chip",
|
|
38
|
-
];
|
|
39
|
-
export const fileAttachmentStateNames = [
|
|
40
|
-
"ready",
|
|
41
|
-
"uploading",
|
|
42
|
-
"processing",
|
|
43
|
-
"error",
|
|
44
|
-
];
|
|
45
|
-
export const fileTypeIconSizeNames = ["sm", "lg"];
|
|
3
|
+
import { Children, createContext, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, } from 'react';
|
|
4
|
+
import { mergeProps } from '@base-ui/react/merge-props';
|
|
5
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
6
|
+
import { ChevronLeft } from 'reicon-react/icons/ChevronLeft';
|
|
7
|
+
import { ChevronRight } from 'reicon-react/icons/ChevronRight';
|
|
8
|
+
import { Image } from 'reicon-react/icons/Image';
|
|
9
|
+
import { Upload } from 'reicon-react/icons/Upload';
|
|
10
|
+
import { X } from 'reicon-react/icons/X';
|
|
11
|
+
import { cn } from '../internal/classes.js';
|
|
12
|
+
import { defaultFileAccept, fileKind, formatFileSize } from '../internal/file-kind.js';
|
|
13
|
+
import { Button } from './button.js';
|
|
14
|
+
import { FilePreview, FileViewer, isPreviewableFile } from './file-viewer.js';
|
|
15
|
+
import { HoverCard, HoverCardContent, HoverCardTrigger } from './hover-card.js';
|
|
16
|
+
import { Spinner } from './spinner.js';
|
|
17
|
+
export const attachmentStateNames = ['idle', 'uploading', 'processing', 'error', 'done'];
|
|
18
|
+
export const attachmentSizeNames = ['default', 'sm', 'xs'];
|
|
19
|
+
export const attachmentOrientationNames = ['horizontal', 'vertical'];
|
|
20
|
+
export const attachmentMediaVariantNames = ['icon', 'image'];
|
|
21
|
+
export const attachmentGroupVariantNames = ['carousel', 'grid', 'inline', 'list'];
|
|
22
|
+
export const fileAttachmentVariantNames = ['list', 'grid', 'inline', 'chip'];
|
|
23
|
+
export const fileAttachmentStateNames = ['ready', 'uploading', 'processing', 'error'];
|
|
24
|
+
export const fileTypeIconSizeNames = ['sm', 'lg'];
|
|
46
25
|
/** A file card built from media, content, and actions. */
|
|
47
|
-
export function Attachment({ className, state =
|
|
48
|
-
return (_jsx("div", { "data-slot": "attachment", "data-state": state, "data-size": size, "data-orientation": orientation, className: cn(
|
|
26
|
+
export function Attachment({ className, state = 'done', size = 'default', orientation = 'horizontal', ...props }) {
|
|
27
|
+
return (_jsx("div", { "data-slot": "attachment", "data-state": state, "data-size": size, "data-orientation": orientation, className: cn('sprout-attachment', `sprout-attachment-size-${size}`, `sprout-attachment-${orientation}`, className), ...props }));
|
|
49
28
|
}
|
|
50
|
-
export function AttachmentMedia({ className, variant =
|
|
51
|
-
return (_jsx("div", { "data-slot": "attachment-media", "data-variant": variant, className: cn(
|
|
29
|
+
export function AttachmentMedia({ className, variant = 'icon', ...props }) {
|
|
30
|
+
return (_jsx("div", { "data-slot": "attachment-media", "data-variant": variant, className: cn('sprout-attachment-media', className), ...props }));
|
|
52
31
|
}
|
|
53
32
|
export function AttachmentContent({ className, ...props }) {
|
|
54
|
-
return
|
|
33
|
+
return _jsx("div", { "data-slot": "attachment-content", className: cn('sprout-attachment-content', className), ...props });
|
|
55
34
|
}
|
|
56
35
|
/** A single-line name. It shimmers while the attachment uploads or processes. */
|
|
57
36
|
export function AttachmentTitle({ className, ...props }) {
|
|
58
|
-
return
|
|
37
|
+
return _jsx("span", { "data-slot": "attachment-title", className: cn('sprout-attachment-title', className), ...props });
|
|
59
38
|
}
|
|
60
39
|
export function AttachmentDescription({ className, ...props }) {
|
|
61
|
-
return (_jsx("span", { "data-slot": "attachment-description", className: cn(
|
|
40
|
+
return (_jsx("span", { "data-slot": "attachment-description", className: cn('sprout-attachment-description', className), ...props }));
|
|
62
41
|
}
|
|
63
42
|
/** Sits above the trigger. Vertical attachments float it over the media corner. */
|
|
64
43
|
export function AttachmentActions({ className, ...props }) {
|
|
65
|
-
return
|
|
44
|
+
return _jsx("div", { "data-slot": "attachment-actions", className: cn('sprout-attachment-actions', className), ...props });
|
|
66
45
|
}
|
|
67
46
|
/** A ghost `icon-xs` Button. Give icon-only actions an `aria-label`. */
|
|
68
|
-
export function AttachmentAction({ variant, size =
|
|
69
|
-
return
|
|
47
|
+
export function AttachmentAction({ variant, size = 'icon-xs', ...props }) {
|
|
48
|
+
return _jsx(Button, { "data-slot": "attachment-action", variant: variant ?? 'ghost', size: size, ...props });
|
|
70
49
|
}
|
|
71
50
|
/** Stretches over the whole attachment so a click anywhere opens it. Name it with `aria-label`. */
|
|
72
51
|
export function AttachmentTrigger({ className, render, type, ...props }) {
|
|
73
52
|
return useRender({
|
|
74
|
-
defaultTagName:
|
|
53
|
+
defaultTagName: 'button',
|
|
75
54
|
render,
|
|
76
55
|
props: mergeProps({
|
|
77
|
-
type: render ? type : (type ??
|
|
78
|
-
className: cn(
|
|
79
|
-
}, {
|
|
56
|
+
type: render ? type : (type ?? 'button'),
|
|
57
|
+
className: cn('sprout-attachment-trigger', className),
|
|
58
|
+
}, { 'data-slot': 'attachment-trigger' }, props),
|
|
80
59
|
});
|
|
81
60
|
}
|
|
82
61
|
const SharedViewerContext = createContext(null);
|
|
83
|
-
const byDocumentOrder = (a, b) => a.node &&
|
|
84
|
-
b.node &&
|
|
85
|
-
a.node.compareDocumentPosition(b.node) & Node.DOCUMENT_POSITION_PRECEDING
|
|
86
|
-
? 1
|
|
87
|
-
: -1;
|
|
62
|
+
const byDocumentOrder = (a, b) => a.node && b.node && a.node.compareDocumentPosition(b.node) & Node.DOCUMENT_POSITION_PRECEDING ? 1 : -1;
|
|
88
63
|
/** One FileViewer for every viewable attachment in a group, stepping through them in page order. */
|
|
89
64
|
function SharedFileViewer({ children }) {
|
|
90
65
|
const entries = useRef(new Map());
|
|
@@ -104,29 +79,27 @@ function SharedFileViewer({ children }) {
|
|
|
104
79
|
}))
|
|
105
80
|
.filter((item) => item.file !== null)
|
|
106
81
|
.sort(byDocumentOrder);
|
|
107
|
-
const index = ordered.findIndex(
|
|
82
|
+
const index = ordered.findIndex(item => item.id === id);
|
|
108
83
|
if (index < 0)
|
|
109
84
|
return;
|
|
110
85
|
setSet({
|
|
111
|
-
ids: ordered.map(
|
|
112
|
-
files: ordered.map(
|
|
86
|
+
ids: ordered.map(item => item.id),
|
|
87
|
+
files: ordered.map(item => item.file),
|
|
113
88
|
index,
|
|
114
89
|
});
|
|
115
90
|
setOpen(true);
|
|
116
91
|
},
|
|
117
92
|
}), []);
|
|
118
|
-
const current = set && entries.current.get(set.ids[set.index] ??
|
|
119
|
-
return (_jsxs(SharedViewerContext.Provider, { value: shared, children: [children, set && (_jsx(FileViewer, { files: set.files, index: set.index, onIndexChange:
|
|
120
|
-
?.node()
|
|
121
|
-
?.querySelector("button.sprout-file-attachment-open") ?? true }))] }));
|
|
93
|
+
const current = set && entries.current.get(set.ids[set.index] ?? '');
|
|
94
|
+
return (_jsxs(SharedViewerContext.Provider, { value: shared, children: [children, set && (_jsx(FileViewer, { files: set.files, index: set.index, onIndexChange: index => setSet({ ...set, index }), open: open, onOpenChange: setOpen, finalFocus: () => current?.node()?.querySelector('button.sprout-file-attachment-open') ?? true }))] }));
|
|
122
95
|
}
|
|
123
96
|
export function AttachmentGroup(props) {
|
|
124
97
|
return (_jsx(SharedFileViewer, { children: _jsx(AttachmentGroupFrame, { ...props }) }));
|
|
125
98
|
}
|
|
126
|
-
function AttachmentGroupFrame({ className, variant =
|
|
127
|
-
if (variant ===
|
|
99
|
+
function AttachmentGroupFrame({ className, variant = 'carousel', children, ...props }) {
|
|
100
|
+
if (variant === 'carousel')
|
|
128
101
|
return (_jsx(AttachmentCarousel, { className: className, ...props, children: children }));
|
|
129
|
-
return (_jsx("div", { "data-slot": "attachment-group", "data-variant": variant, role: props[
|
|
102
|
+
return (_jsx("div", { "data-slot": "attachment-group", "data-variant": variant, role: props['aria-label'] || props['aria-labelledby'] ? 'group' : undefined, className: cn('sprout-attachment-group', `sprout-attachment-group-${variant}`, className), ...props, children: children }));
|
|
130
103
|
}
|
|
131
104
|
const typing = 'input, textarea, select, [contenteditable="true"]';
|
|
132
105
|
function AttachmentCarousel({ className, children, onKeyDownCapture, ...props }) {
|
|
@@ -139,7 +112,7 @@ function AttachmentCarousel({ className, children, onKeyDownCapture, ...props })
|
|
|
139
112
|
const max = node.scrollWidth - node.clientWidth;
|
|
140
113
|
const start = node.scrollLeft > 1;
|
|
141
114
|
const end = node.scrollLeft < max - 1;
|
|
142
|
-
setEdges(
|
|
115
|
+
setEdges(current => (current.start === start && current.end === end ? current : { start, end }));
|
|
143
116
|
}, []);
|
|
144
117
|
useEffect(() => {
|
|
145
118
|
const node = viewport.current;
|
|
@@ -163,55 +136,49 @@ function AttachmentCarousel({ className, children, onKeyDownCapture, ...props })
|
|
|
163
136
|
return;
|
|
164
137
|
if (event.target.closest(typing))
|
|
165
138
|
return;
|
|
166
|
-
if (event.key ===
|
|
139
|
+
if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
|
|
167
140
|
event.preventDefault();
|
|
168
|
-
scroll(event.key ===
|
|
141
|
+
scroll(event.key === 'ArrowLeft' ? -1 : 1);
|
|
169
142
|
}
|
|
170
143
|
};
|
|
171
|
-
return (_jsxs("div", { "data-slot": "attachment-group", "data-variant": "carousel", role: "region", "aria-roledescription": "carousel", className: cn(
|
|
144
|
+
return (_jsxs("div", { "data-slot": "attachment-group", "data-variant": "carousel", role: "region", "aria-roledescription": "carousel", className: cn('sprout-attachment-group', 'sprout-attachment-group-carousel', className), onKeyDownCapture: handleKeyDown, ...props, children: [_jsx("div", { ref: viewport, className: "sprout-attachment-carousel-viewport", onScroll: measure, children: _jsx("div", { className: "sprout-attachment-carousel-track", children: Children.map(children, child => child == null || child === false ? null : (_jsx("div", { role: "group", "aria-roledescription": "slide", className: "sprout-attachment-carousel-item", children: child }))) }) }), edges.start && (_jsx("span", { className: "sprout-attachment-carousel-edge", "data-side": "start", children: _jsx(Button, { variant: "outline", size: "icon-xs", "aria-label": "Previous attachments", tabIndex: -1, className: "sprout-attachment-carousel-arrow", onClick: () => scroll(-1), children: _jsx(ChevronLeft, { "aria-hidden": "true" }) }) })), edges.end && (_jsx("span", { className: "sprout-attachment-carousel-edge", "data-side": "end", children: _jsx(Button, { variant: "outline", size: "icon-xs", "aria-label": "Next attachments", tabIndex: -1, className: "sprout-attachment-carousel-arrow", onClick: () => scroll(1), children: _jsx(ChevronRight, { "aria-hidden": "true" }) }) }))] }));
|
|
172
145
|
}
|
|
173
146
|
/** A paper glyph with a colored extension badge, such as PDF or XLSX. Decorative. */
|
|
174
|
-
export function FileTypeIcon({ name, mediaType, size =
|
|
175
|
-
const label = name.includes(
|
|
176
|
-
? (name.split(".").at(-1) ?? "").toUpperCase().slice(0, 4)
|
|
177
|
-
: "";
|
|
147
|
+
export function FileTypeIcon({ name, mediaType, size = 'sm', className, ...props }) {
|
|
148
|
+
const label = name.includes('.') ? (name.split('.').at(-1) ?? '').toUpperCase().slice(0, 4) : '';
|
|
178
149
|
const badgeWidth = label.length > 3 ? 13 : 11;
|
|
179
|
-
return (_jsxs("svg", { viewBox: "0 0 20 24", "aria-hidden": "true", focusable: "false", "data-slot": "file-type-icon", "data-size": size, "data-kind": fileKind(name, mediaType), className: cn(
|
|
150
|
+
return (_jsxs("svg", { viewBox: "0 0 20 24", "aria-hidden": "true", focusable: "false", "data-slot": "file-type-icon", "data-size": size, "data-kind": fileKind(name, mediaType), className: cn('sprout-file-type-icon', `sprout-file-type-icon-size-${size}`, className), ...props, children: [_jsx("path", { d: "M3.5 1.5h9l4.5 4.5v16a.5.5 0 0 1-.5.5h-13a.5.5 0 0 1-.5-.5v-20a.5.5 0 0 1 .5-.5Z", className: "sprout-file-type-icon-paper", strokeLinejoin: "round" }), _jsx("path", { d: "M12.5 1.5v4a.5.5 0 0 0 .5.5h4", className: "sprout-file-type-icon-fold", strokeLinejoin: "round" }), _jsx("path", { d: "M6 15h8M6 17.5h8M6 20h5", className: "sprout-file-type-icon-lines", strokeLinecap: "round" }), label && (_jsxs(_Fragment, { children: [_jsx("rect", { x: "1", y: "6", width: badgeWidth, height: "6", rx: "1.5", className: "sprout-file-type-icon-badge" }), _jsx("text", { x: 1 + badgeWidth / 2, y: "10.4", textAnchor: "middle", fontSize: "4.2", fontWeight: "700", className: "sprout-file-type-icon-label", children: label })] }))] }));
|
|
180
151
|
}
|
|
181
152
|
function AttachmentImage({ src, name }) {
|
|
182
153
|
const [failed, setFailed] = useState(false);
|
|
183
154
|
return failed ? (_jsxs("span", { className: "sprout-attachment-image-failed", children: [_jsx(Image, { size: 16, "aria-hidden": "true" }), "Image unavailable"] })) : (_jsx("img", { src: src, alt: name, onError: () => setFailed(true), className: "sprout-attachment-image" }));
|
|
184
155
|
}
|
|
185
156
|
function viewableFile(file) {
|
|
186
|
-
const source = file.source ??
|
|
187
|
-
(file.url ? { kind: "remote", url: file.url } : null);
|
|
157
|
+
const source = file.source ?? (file.url ? { kind: 'remote', url: file.url } : null);
|
|
188
158
|
return source && { name: file.name, mediaType: file.mediaType, source };
|
|
189
159
|
}
|
|
190
160
|
function stateLabelFor(file) {
|
|
191
|
-
return file.state ===
|
|
161
|
+
return file.state === 'ready'
|
|
192
162
|
? file.size
|
|
193
|
-
: file.state ===
|
|
194
|
-
?
|
|
195
|
-
: file.state ===
|
|
196
|
-
?
|
|
197
|
-
:
|
|
163
|
+
: file.state === 'error'
|
|
164
|
+
? 'Upload failed'
|
|
165
|
+
: file.state === 'uploading'
|
|
166
|
+
? 'Uploading…'
|
|
167
|
+
: 'Processing…';
|
|
198
168
|
}
|
|
199
169
|
/** A ready-made file row, card, inline mention, or chip with upload states, retry, and remove. */
|
|
200
|
-
export function FileAttachment({ file, variant =
|
|
170
|
+
export function FileAttachment({ file, variant = 'list', onRemove, onRetry, onOpen, viewable = false, preview = false, actionLabel = 'Inspect', className, }) {
|
|
201
171
|
const [open, setOpen] = useState(false);
|
|
202
172
|
const shared = useContext(SharedViewerContext);
|
|
203
173
|
const id = useId();
|
|
204
174
|
const root = useRef(null);
|
|
205
|
-
const image = fileKind(file.name, file.mediaType) ===
|
|
206
|
-
const busy = file.state ===
|
|
175
|
+
const image = fileKind(file.name, file.mediaType) === 'image';
|
|
176
|
+
const busy = file.state === 'uploading' || file.state === 'processing';
|
|
207
177
|
const stateLabel = stateLabelFor(file);
|
|
208
178
|
const target = viewable || preview ? viewableFile(file) : null;
|
|
209
179
|
const inViewer = !onOpen && viewable && target !== null;
|
|
210
180
|
const openable = !!onOpen || inViewer;
|
|
211
|
-
const peek = preview &&
|
|
212
|
-
target !== null &&
|
|
213
|
-
file.state !== "error" &&
|
|
214
|
-
isPreviewableFile(target);
|
|
181
|
+
const peek = preview && target !== null && file.state !== 'error' && isPreviewableFile(target);
|
|
215
182
|
const latest = useRef(target);
|
|
216
183
|
latest.current = inViewer ? target : null;
|
|
217
184
|
useEffect(() => shared && inViewer
|
|
@@ -223,21 +190,21 @@ export function FileAttachment({ file, variant = "list", onRemove, onRetry, onOp
|
|
|
223
190
|
const withPreview = (trigger) => peek ? (_jsxs(HoverCard, { children: [_jsx(HoverCardTrigger, { delay: 400, closeDelay: 150, render: trigger }), _jsx(HoverCardContent, { side: "top", align: "start", className: "sprout-file-attachment-peek", children: _jsx(FilePreview, { file: target }) })] })) : (trigger);
|
|
224
191
|
const openLabel = `${actionLabel} ${file.name}`;
|
|
225
192
|
const openProps = {
|
|
226
|
-
type:
|
|
193
|
+
type: 'button',
|
|
227
194
|
disabled: !!onOpen && busy,
|
|
228
|
-
onClick: () => onOpen ? onOpen() : shared ? shared.open(id) : setOpen(true),
|
|
195
|
+
onClick: () => (onOpen ? onOpen() : shared ? shared.open(id) : setOpen(true)),
|
|
229
196
|
};
|
|
230
|
-
const retry = file.state ===
|
|
197
|
+
const retry = file.state === 'error' && onRetry && (_jsx(Button, { variant: "ghost", size: "sm", onClick: onRetry, "aria-label": `Retry ${file.name}`, children: "Retry" }));
|
|
231
198
|
const remove = (size) => onRemove && (_jsx(Button, { variant: "ghost", size: size, "aria-label": `Remove ${file.name}`, onClick: onRemove, children: _jsx(X, { size: 14, "aria-hidden": "true" }) }));
|
|
232
|
-
const viewer = inViewer && !shared &&
|
|
233
|
-
if (variant ===
|
|
199
|
+
const viewer = inViewer && !shared && _jsx(FileViewer, { file: target, open: open, onOpenChange: setOpen });
|
|
200
|
+
if (variant === 'chip') {
|
|
234
201
|
const inner = (_jsxs(_Fragment, { children: [image && file.url ? (_jsx("span", { className: "sprout-file-attachment-thumb", children: _jsx(AttachmentImage, { src: file.url, name: file.name }, file.url) })) : (_jsx(FileTypeIcon, { name: file.name, mediaType: file.mediaType })), _jsx("span", { className: "sprout-file-attachment-name", children: file.name })] }));
|
|
235
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: root, "data-slot": "file-attachment", "data-variant": "chip", "data-state": file.state, "data-removable": onRemove ?
|
|
202
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: root, "data-slot": "file-attachment", "data-variant": "chip", "data-state": file.state, "data-removable": onRemove ? '' : undefined, className: cn('sprout-file-attachment', className), title: openable ? undefined : `${file.name} · ${stateLabel}`, children: [withPreview(openable ? (_jsx("button", { ...openProps, "aria-label": openLabel, title: peek ? undefined : `${file.name} · ${stateLabel}`, className: "sprout-file-attachment-open", children: inner })) : (_jsx("span", { className: "sprout-file-attachment-open", children: inner }))), busy && _jsx(Spinner, { "aria-label": stateLabel }), retry, remove('icon-xs')] }), viewer] }));
|
|
236
203
|
}
|
|
237
|
-
const name = (_jsxs(_Fragment, { children: [_jsx("span", { className: "sprout-file-attachment-name", title: file.name, children: file.name }), variant !==
|
|
204
|
+
const name = (_jsxs(_Fragment, { children: [_jsx("span", { className: "sprout-file-attachment-name", title: file.name, children: file.name }), variant !== 'inline' && (_jsxs("span", { className: "sprout-file-attachment-status", children: [busy && _jsx(Spinner, { size: "sm", "aria-hidden": "true" }), stateLabel] }))] }));
|
|
238
205
|
const thumbnail = image && file.url ? (_jsx(AttachmentImage, { src: file.url, name: file.name }, file.url)) : (_jsx(FileTypeIcon, { name: file.name, mediaType: file.mediaType, size: "lg" }));
|
|
239
|
-
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: root, "data-slot": "file-attachment", "data-variant": variant, "data-state": file.state, className: cn(
|
|
240
|
-
(openable ? (_jsx("button", { ...openProps, tabIndex: -1, "aria-hidden": "true", className: "sprout-file-attachment-preview", children: thumbnail })) : (_jsx("span", { className: "sprout-file-attachment-preview", children: thumbnail }))), variant !==
|
|
206
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { ref: root, "data-slot": "file-attachment", "data-variant": variant, "data-state": file.state, className: cn('sprout-file-attachment', className), children: [variant === 'grid' &&
|
|
207
|
+
(openable ? (_jsx("button", { ...openProps, tabIndex: -1, "aria-hidden": "true", className: "sprout-file-attachment-preview", children: thumbnail })) : (_jsx("span", { className: "sprout-file-attachment-preview", children: thumbnail }))), variant !== 'grid' && (_jsx("span", { className: "sprout-file-attachment-media", children: image && file.url && variant === 'list' ? (_jsx(AttachmentImage, { src: file.url, name: file.name }, file.url)) : (_jsx(FileTypeIcon, { name: file.name, mediaType: file.mediaType })) })), withPreview(openable ? (_jsx("button", { ...openProps, "aria-label": openLabel, className: "sprout-file-attachment-open", children: name })) : (_jsx("span", { className: "sprout-file-attachment-open", children: name }))), variant === 'inline' && busy && _jsx(Spinner, { "aria-label": stateLabel }), variant === 'inline' && file.state === 'error' && (_jsx("span", { className: "sprout-file-attachment-failed", children: "Failed" })), (retry || onRemove) && (_jsxs("div", { className: "sprout-file-attachment-actions", children: [retry, remove('icon-sm')] }))] }), viewer] }));
|
|
241
208
|
}
|
|
242
209
|
/** A dashed drop target with a “Choose files” button. Files are handed to `onFiles`; nothing is uploaded. */
|
|
243
210
|
export function AttachmentDropzone({ onFiles, disabled = false, accept = defaultFileAccept, className, }) {
|
|
@@ -245,29 +212,29 @@ export function AttachmentDropzone({ onFiles, disabled = false, accept = default
|
|
|
245
212
|
const input = useRef(null);
|
|
246
213
|
const over = (event) => {
|
|
247
214
|
event.preventDefault();
|
|
248
|
-
event.dataTransfer.dropEffect = disabled ?
|
|
215
|
+
event.dataTransfer.dropEffect = disabled ? 'none' : 'copy';
|
|
249
216
|
if (!disabled)
|
|
250
217
|
setDragging(true);
|
|
251
218
|
};
|
|
252
|
-
return (_jsxs("div", { "data-slot": "attachment-dropzone", "data-dragging": dragging ?
|
|
219
|
+
return (_jsxs("div", { "data-slot": "attachment-dropzone", "data-dragging": dragging ? '' : undefined, "data-disabled": disabled ? '' : undefined, className: cn('sprout-attachment-dropzone', className), onDragEnter: over, onDragOver: over, onDragLeave: event => {
|
|
253
220
|
if (!event.currentTarget.contains(event.relatedTarget))
|
|
254
221
|
setDragging(false);
|
|
255
|
-
}, onDrop:
|
|
222
|
+
}, onDrop: event => {
|
|
256
223
|
event.preventDefault();
|
|
257
224
|
setDragging(false);
|
|
258
225
|
if (!disabled)
|
|
259
226
|
onFiles(Array.from(event.dataTransfer.files));
|
|
260
|
-
}, children: [_jsx("input", { ref: input, type: "file", accept: accept, multiple: true, hidden: true, disabled: disabled, onChange:
|
|
227
|
+
}, children: [_jsx("input", { ref: input, type: "file", accept: accept, multiple: true, hidden: true, disabled: disabled, onChange: event => {
|
|
261
228
|
onFiles(Array.from(event.target.files ?? []));
|
|
262
|
-
event.target.value =
|
|
229
|
+
event.target.value = '';
|
|
263
230
|
} }), _jsx(Upload, { size: 20, "aria-hidden": "true", className: "sprout-attachment-dropzone-icon" }), _jsx("p", { className: "sprout-attachment-dropzone-text", children: "Drop files here, or choose them from your device." }), _jsx(Button, { variant: "outline", disabled: disabled, onClick: () => input.current?.click(), children: "Choose files" })] }));
|
|
264
231
|
}
|
|
265
232
|
/** A chip for a `File` still in browser memory, with a live image preview. */
|
|
266
|
-
export function LocalFileAttachment({ file, onRemove, onOpen, viewable, preview
|
|
233
|
+
export function LocalFileAttachment({ file, onRemove, onOpen, viewable, preview }) {
|
|
267
234
|
const [url, setUrl] = useState();
|
|
268
|
-
const source = useMemo(() => ({ kind:
|
|
235
|
+
const source = useMemo(() => ({ kind: 'local', file }), [file]);
|
|
269
236
|
useEffect(() => {
|
|
270
|
-
if (fileKind(file.name, file.type) !==
|
|
237
|
+
if (fileKind(file.name, file.type) !== 'image')
|
|
271
238
|
return;
|
|
272
239
|
const next = URL.createObjectURL(file);
|
|
273
240
|
setUrl(next);
|
|
@@ -278,7 +245,7 @@ export function LocalFileAttachment({ file, onRemove, onOpen, viewable, preview,
|
|
|
278
245
|
name: file.name,
|
|
279
246
|
mediaType: file.type,
|
|
280
247
|
size: formatFileSize(file.size),
|
|
281
|
-
state:
|
|
248
|
+
state: 'ready',
|
|
282
249
|
source,
|
|
283
250
|
url,
|
|
284
251
|
}, onRemove: onRemove, onOpen: onOpen, viewable: viewable, preview: preview }));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { ComponentProps } from
|
|
2
|
-
import { Avatar as AvatarPrimitive } from
|
|
3
|
-
export type AvatarSize =
|
|
4
|
-
export type EntityAvatarSize = AvatarSize |
|
|
5
|
-
export type EntityAvatarShape =
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { Avatar as AvatarPrimitive } from '@base-ui/react/avatar';
|
|
3
|
+
export type AvatarSize = 'xs' | 'sm' | 'default' | 'lg';
|
|
4
|
+
export type EntityAvatarSize = AvatarSize | 'xl';
|
|
5
|
+
export type EntityAvatarShape = 'circle' | 'square';
|
|
6
6
|
export interface AvatarProps extends AvatarPrimitive.Root.Props {
|
|
7
7
|
size?: AvatarSize;
|
|
8
8
|
}
|
|
@@ -11,18 +11,18 @@ export type AvatarImageProps = AvatarPrimitive.Image.Props;
|
|
|
11
11
|
export declare function AvatarImage({ className, ...props }: AvatarImageProps): import("react").JSX.Element;
|
|
12
12
|
export type AvatarFallbackProps = AvatarPrimitive.Fallback.Props;
|
|
13
13
|
export declare function AvatarFallback({ className, ...props }: AvatarFallbackProps): import("react").JSX.Element;
|
|
14
|
-
export declare function AvatarBadge({ className, ...props }: ComponentProps<
|
|
15
|
-
export declare function AvatarGroup({ className, ...props }: ComponentProps<
|
|
16
|
-
export declare function AvatarGroupCount({ className, ...props }: ComponentProps<
|
|
14
|
+
export declare function AvatarBadge({ className, ...props }: ComponentProps<'span'>): import("react").JSX.Element;
|
|
15
|
+
export declare function AvatarGroup({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
16
|
+
export declare function AvatarGroupCount({ className, ...props }: ComponentProps<'div'>): import("react").JSX.Element;
|
|
17
17
|
export declare function agentAvatarSrc(agentId: string, baseUrl?: string): string;
|
|
18
|
-
export interface AgentAvatarProps extends Omit<AvatarProps,
|
|
18
|
+
export interface AgentAvatarProps extends Omit<AvatarProps, 'children'> {
|
|
19
19
|
agentId: string;
|
|
20
20
|
name: string;
|
|
21
21
|
/** Overrides the artwork derived from `agentId`. */
|
|
22
22
|
src?: string | undefined;
|
|
23
23
|
}
|
|
24
24
|
export declare function AgentAvatar({ agentId, name, src, ...props }: AgentAvatarProps): import("react").JSX.Element;
|
|
25
|
-
export interface EntityAvatarProps extends Omit<AvatarPrimitive.Root.Props,
|
|
25
|
+
export interface EntityAvatarProps extends Omit<AvatarPrimitive.Root.Props, 'children'> {
|
|
26
26
|
seed: string;
|
|
27
27
|
name: string;
|
|
28
28
|
image?: string | null | undefined;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Avatar as AvatarPrimitive } from
|
|
4
|
-
import { cn, stateClassName } from
|
|
5
|
-
export function Avatar({ className, size =
|
|
6
|
-
return (_jsx(AvatarPrimitive.Root, { "data-slot": "avatar", "data-size": size, ...props, className: stateClassName(
|
|
3
|
+
import { Avatar as AvatarPrimitive } from '@base-ui/react/avatar';
|
|
4
|
+
import { cn, stateClassName } from '../internal/classes.js';
|
|
5
|
+
export function Avatar({ className, size = 'default', ...props }) {
|
|
6
|
+
return (_jsx(AvatarPrimitive.Root, { "data-slot": "avatar", "data-size": size, ...props, className: stateClassName('sprout-avatar', className) }));
|
|
7
7
|
}
|
|
8
8
|
export function AvatarImage({ className, ...props }) {
|
|
9
|
-
return (_jsx(AvatarPrimitive.Image, { "data-slot": "avatar-image", ...props, className: stateClassName(
|
|
9
|
+
return (_jsx(AvatarPrimitive.Image, { "data-slot": "avatar-image", ...props, className: stateClassName('sprout-avatar-image', className) }));
|
|
10
10
|
}
|
|
11
11
|
export function AvatarFallback({ className, ...props }) {
|
|
12
|
-
return (_jsx(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", ...props, className: stateClassName(
|
|
12
|
+
return (_jsx(AvatarPrimitive.Fallback, { "data-slot": "avatar-fallback", ...props, className: stateClassName('sprout-avatar-fallback', className) }));
|
|
13
13
|
}
|
|
14
14
|
export function AvatarBadge({ className, ...props }) {
|
|
15
|
-
return
|
|
15
|
+
return _jsx("span", { "data-slot": "avatar-badge", ...props, className: cn('sprout-avatar-badge', className) });
|
|
16
16
|
}
|
|
17
17
|
export function AvatarGroup({ className, ...props }) {
|
|
18
|
-
return
|
|
18
|
+
return _jsx("div", { "data-slot": "avatar-group", ...props, className: cn('sprout-avatar-group', className) });
|
|
19
19
|
}
|
|
20
20
|
export function AvatarGroupCount({ className, ...props }) {
|
|
21
|
-
return
|
|
21
|
+
return _jsx("div", { "data-slot": "avatar-group-count", ...props, className: cn('sprout-avatar-group-count', className) });
|
|
22
22
|
}
|
|
23
23
|
// FNV-1a: small, stable, and spreads similar ids apart.
|
|
24
24
|
function hash(value) {
|
|
@@ -49,14 +49,14 @@ const agentObjects = [
|
|
|
49
49
|
];
|
|
50
50
|
// prettier-ignore
|
|
51
51
|
const agentColors = ["pink", "coral", "orange", "yellow", "green", "teal", "blue", "purple"];
|
|
52
|
-
export function agentAvatarSrc(agentId, baseUrl =
|
|
52
|
+
export function agentAvatarSrc(agentId, baseUrl = 'https://avatars.tulipfarm.ai/avatar') {
|
|
53
53
|
const h = hash(agentId);
|
|
54
54
|
const object = agentObjects[h % agentObjects.length];
|
|
55
55
|
const color = agentColors[(h >>> 16) % agentColors.length];
|
|
56
56
|
return `${baseUrl}/${object}/${color}.svg`;
|
|
57
57
|
}
|
|
58
58
|
function initial(name) {
|
|
59
|
-
return name.trim().charAt(0).toUpperCase() ||
|
|
59
|
+
return name.trim().charAt(0).toUpperCase() || '?';
|
|
60
60
|
}
|
|
61
61
|
export function AgentAvatar({ agentId, name, src, ...props }) {
|
|
62
62
|
return (_jsxs(Avatar, { "data-agent-avatar": "", ...props, children: [_jsx(AvatarImage, { src: src ?? agentAvatarSrc(agentId), alt: "" }), _jsx(AvatarFallback, { children: initial(name) })] }));
|
|
@@ -68,6 +68,6 @@ function gradientFor(seed) {
|
|
|
68
68
|
const to = (from + 40 + ((h >>> 9) % 60)) % 360;
|
|
69
69
|
return `linear-gradient(135deg, oklch(0.62 0.15 ${from}), oklch(0.5 0.15 ${to}))`;
|
|
70
70
|
}
|
|
71
|
-
export function EntityAvatar({ seed, name, image, size =
|
|
72
|
-
return (_jsxs(AvatarPrimitive.Root, { "data-slot": "entity-avatar", "data-size": size, "data-shape": shape, ...props, className: stateClassName(
|
|
71
|
+
export function EntityAvatar({ seed, name, image, size = 'default', shape = 'circle', className, ...props }) {
|
|
72
|
+
return (_jsxs(AvatarPrimitive.Root, { "data-slot": "entity-avatar", "data-size": size, "data-shape": shape, ...props, className: stateClassName('sprout-entity-avatar', className), children: [image && (_jsx(AvatarPrimitive.Image, { src: image, alt: "", referrerPolicy: "no-referrer", className: "sprout-avatar-image" })), _jsx(AvatarPrimitive.Fallback, { className: "sprout-entity-avatar-fallback", style: { backgroundImage: gradientFor(seed) }, children: initial(name) })] }));
|
|
73
73
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRender } from
|
|
1
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
2
2
|
export declare const badgeVariantNames: readonly ["default", "success", "warning", "info", "secondary", "destructive", "outline", "ghost", "link"];
|
|
3
3
|
export declare const badgeSizeNames: readonly ["default", "chip"];
|
|
4
4
|
export type BadgeVariant = (typeof badgeVariantNames)[number];
|
|
@@ -8,13 +8,13 @@ export interface BadgeVariantOptions {
|
|
|
8
8
|
size?: BadgeSize | null;
|
|
9
9
|
className?: string;
|
|
10
10
|
}
|
|
11
|
-
export declare function badgeVariants({ variant, size, className
|
|
11
|
+
export declare function badgeVariants({ variant, size, className }?: BadgeVariantOptions): string;
|
|
12
12
|
export interface BadgeState extends Record<string, unknown> {
|
|
13
|
-
slot:
|
|
13
|
+
slot: 'badge';
|
|
14
14
|
variant: BadgeVariant;
|
|
15
15
|
size: BadgeSize;
|
|
16
16
|
}
|
|
17
|
-
export interface BadgeProps extends useRender.ComponentProps<
|
|
17
|
+
export interface BadgeProps extends useRender.ComponentProps<'span', BadgeState> {
|
|
18
18
|
variant?: BadgeVariant;
|
|
19
19
|
size?: BadgeSize;
|
|
20
20
|
}
|
package/dist/components/badge.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { mergeProps } from
|
|
2
|
-
import { useRender } from
|
|
3
|
-
import { cn } from
|
|
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
4
|
export const badgeVariantNames = [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
'default',
|
|
6
|
+
'success',
|
|
7
|
+
'warning',
|
|
8
|
+
'info',
|
|
9
|
+
'secondary',
|
|
10
|
+
'destructive',
|
|
11
|
+
'outline',
|
|
12
|
+
'ghost',
|
|
13
|
+
'link',
|
|
14
14
|
];
|
|
15
|
-
export const badgeSizeNames = [
|
|
16
|
-
export function badgeVariants({ variant, size, className
|
|
17
|
-
return cn(
|
|
15
|
+
export const badgeSizeNames = ['default', 'chip'];
|
|
16
|
+
export function badgeVariants({ variant, size, className } = {}) {
|
|
17
|
+
return cn('sprout-badge', `sprout-badge-${variant ?? 'default'}`, size === 'chip' && 'sprout-badge-chip', className);
|
|
18
18
|
}
|
|
19
|
-
export function Badge({ className, variant =
|
|
19
|
+
export function Badge({ className, variant = 'default', size = 'default', render, ref, ...props }) {
|
|
20
20
|
return useRender({
|
|
21
|
-
defaultTagName:
|
|
21
|
+
defaultTagName: 'span',
|
|
22
22
|
ref,
|
|
23
23
|
render,
|
|
24
24
|
props: mergeProps({ className: badgeVariants({ variant, size, className }) }, props),
|
|
25
|
-
state: { slot:
|
|
25
|
+
state: { slot: 'badge', variant, size },
|
|
26
26
|
});
|
|
27
27
|
}
|