@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,43 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useId
|
|
4
|
-
import { OTPField } from
|
|
5
|
-
import { Minus } from
|
|
6
|
-
import { cn, stateClassName } from
|
|
3
|
+
import { createContext, useContext, useId } from 'react';
|
|
4
|
+
import { OTPField } from '@base-ui/react/otp-field';
|
|
5
|
+
import { Minus } from 'reicon-react/icons/Minus';
|
|
6
|
+
import { cn, stateClassName } from '../internal/classes.js';
|
|
7
|
+
export const inputOTPSizeNames = ['md', 'sm', 'lg'];
|
|
7
8
|
const InputOTPContext = createContext(null);
|
|
8
|
-
const isInvalid = (value) => value === true || value ===
|
|
9
|
+
const isInvalid = (value) => value === true || value === 'true';
|
|
9
10
|
/**
|
|
10
11
|
* A one-time code field on Base UI `OTPField`. Each slot is a real input, so
|
|
11
12
|
* typing, paste, autofill (`autoComplete="one-time-code"`), arrow keys, Home,
|
|
12
13
|
* End, Backspace, and Delete all work. `aria-label` names the whole code and
|
|
13
14
|
* its first slot; later slots are announced as "Character 2 of 6".
|
|
14
15
|
*/
|
|
15
|
-
export function InputOTP({ maxLength, onChange, onValueChange, className, children,
|
|
16
|
+
export function InputOTP({ maxLength, size, onChange, onValueChange, className, children, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, validationType = 'numeric', ...props }) {
|
|
16
17
|
const generated = useId();
|
|
17
18
|
const labelId = ariaLabelledBy ?? (ariaLabel ? `${generated}-label` : undefined);
|
|
18
19
|
const invalid = isInvalid(ariaInvalid);
|
|
19
|
-
|
|
20
|
+
const scale = size ?? 'md';
|
|
21
|
+
return (_jsx(InputOTPContext.Provider, { value: { length: maxLength, labelId, invalid }, children: _jsxs(OTPField.Root, { "data-slot": "input-otp", "data-size": scale, "data-invalid": invalid ? '' : undefined, length: maxLength, validationType: validationType, "aria-labelledby": labelId, onValueChange: (value, details) => {
|
|
20
22
|
onValueChange?.(value, details);
|
|
21
23
|
onChange?.(value);
|
|
22
|
-
}, ...props, className: stateClassName(
|
|
24
|
+
}, ...props, className: stateClassName(cn('sprout-input-otp', `sprout-input-otp-size-${scale}`), className), children: [ariaLabel && !ariaLabelledBy ? (_jsx("span", { id: labelId, className: "sprout-input-otp-sr-only", children: ariaLabel })) : null, children] }) }));
|
|
23
25
|
}
|
|
24
26
|
/** Joins adjacent slots into one bordered segment. */
|
|
25
27
|
export function InputOTPGroup({ className, ...props }) {
|
|
26
|
-
return
|
|
28
|
+
return _jsx("div", { "data-slot": "input-otp-group", ...props, className: cn('sprout-input-otp-group', className) });
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
31
|
* One character of the code. Render slots in index order; Base UI tracks
|
|
30
32
|
* focus and value by their DOM order.
|
|
31
33
|
*/
|
|
32
|
-
export function InputOTPSlot({ index, className,
|
|
34
|
+
export function InputOTPSlot({ index, className, 'aria-label': ariaLabel, 'aria-labelledby': ariaLabelledBy, 'aria-invalid': ariaInvalid, ...props }) {
|
|
33
35
|
const context = useContext(InputOTPContext);
|
|
34
36
|
const length = context?.length ?? index + 1;
|
|
35
37
|
const invalid = ariaInvalid === undefined ? context?.invalid : isInvalid(ariaInvalid);
|
|
36
|
-
return (_jsx(OTPField.Input, { "data-slot": "input-otp-slot", "data-index": index, "aria-labelledby": ariaLabelledBy ?? (index === 0 ? context?.labelId : undefined), "aria-label": index === 0
|
|
37
|
-
? undefined
|
|
38
|
-
: (ariaLabel ?? `Character ${index + 1} of ${length}`), "aria-invalid": invalid || undefined, ...props, className: stateClassName("sprout-input-otp-slot", className) }));
|
|
38
|
+
return (_jsx(OTPField.Input, { "data-slot": "input-otp-slot", "data-index": index, "aria-labelledby": ariaLabelledBy ?? (index === 0 ? context?.labelId : undefined), "aria-label": index === 0 ? undefined : (ariaLabel ?? `Character ${index + 1} of ${length}`), "aria-invalid": invalid || undefined, ...props, className: stateClassName('sprout-input-otp-slot', className) }));
|
|
39
39
|
}
|
|
40
40
|
/** A dash between slot groups, such as `123–456`. */
|
|
41
41
|
export function InputOTPSeparator({ className, children, ...props }) {
|
|
42
|
-
return (_jsx(OTPField.Separator, { "data-slot": "input-otp-separator", orientation: "vertical", ...props, className: stateClassName(
|
|
42
|
+
return (_jsx(OTPField.Separator, { "data-slot": "input-otp-separator", orientation: "vertical", ...props, className: stateClassName('sprout-input-otp-separator', className), children: children ?? _jsx(Minus, { "aria-hidden": "true" }) }));
|
|
43
43
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Input as BaseInput } from
|
|
2
|
-
export declare const inputScaleNames: readonly ["
|
|
1
|
+
import { Input as BaseInput } from '@base-ui/react/input';
|
|
2
|
+
export declare const inputScaleNames: readonly ["md", "sm", "lg"];
|
|
3
3
|
export type InputScale = (typeof inputScaleNames)[number];
|
|
4
4
|
export type InputState = BaseInput.State;
|
|
5
5
|
export interface InputProps extends BaseInput.Props {
|
|
6
|
-
/** `
|
|
6
|
+
/** `sm` is 28px, `md` is 32px (`--sprout-control-height`), and `lg` is 36px. */
|
|
7
7
|
scale?: InputScale | null;
|
|
8
8
|
}
|
|
9
9
|
/**
|
package/dist/components/input.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Input as BaseInput } from
|
|
4
|
-
import { cn, stateClassName } from
|
|
5
|
-
import { useFieldControl } from
|
|
6
|
-
export const inputScaleNames = [
|
|
3
|
+
import { Input as BaseInput } from '@base-ui/react/input';
|
|
4
|
+
import { cn, stateClassName } from '../internal/classes.js';
|
|
5
|
+
import { useFieldControl } from './field.js';
|
|
6
|
+
export const inputScaleNames = ['md', 'sm', 'lg'];
|
|
7
7
|
/**
|
|
8
8
|
* A single-line text field on Base UI `Input`. It takes every native input
|
|
9
9
|
* prop, such as `type`, `value`, `required`, and `ref`. Inside a Base UI
|
|
@@ -13,6 +13,6 @@ export const inputScaleNames = ["default", "lg"];
|
|
|
13
13
|
*/
|
|
14
14
|
export function Input({ scale, className, ...rest }) {
|
|
15
15
|
const props = useFieldControl(rest);
|
|
16
|
-
const size = scale ??
|
|
17
|
-
return (_jsx(BaseInput, { "data-slot": "input", "data-scale": size, ...props, className: stateClassName(cn(
|
|
16
|
+
const size = scale ?? 'md';
|
|
17
|
+
return (_jsx(BaseInput, { "data-slot": "input", "data-scale": size, ...props, className: stateClassName(cn('sprout-input', `sprout-input-scale-${size}`), className) }));
|
|
18
18
|
}
|
package/dist/components/kbd.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type { ComponentProps } from
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
2
|
export declare const kbdVariantNames: readonly ["default", "outline"];
|
|
3
3
|
export type KbdVariant = (typeof kbdVariantNames)[number];
|
|
4
|
-
export interface KbdProps extends ComponentProps<
|
|
4
|
+
export interface KbdProps extends ComponentProps<'kbd'> {
|
|
5
5
|
/** `"outline"` adds a border on the surface color, for hints on tinted strips and selected rows. */
|
|
6
6
|
variant?: KbdVariant;
|
|
7
7
|
}
|
|
8
8
|
/** One keyboard key, such as `⌘`, `Enter`, or `Esc`. */
|
|
9
9
|
export declare function Kbd({ variant, className, ...props }: KbdProps): import("react").JSX.Element;
|
|
10
|
-
export type KbdGroupProps = ComponentProps<
|
|
10
|
+
export type KbdGroupProps = ComponentProps<'kbd'>;
|
|
11
11
|
/** Keys pressed together, such as `⌘` `K`. */
|
|
12
12
|
export declare function KbdGroup({ className, ...props }: KbdGroupProps): import("react").JSX.Element;
|
package/dist/components/kbd.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from
|
|
3
|
-
export const kbdVariantNames = [
|
|
2
|
+
import { cn } from '../internal/classes.js';
|
|
3
|
+
export const kbdVariantNames = ['default', 'outline'];
|
|
4
4
|
/** One keyboard key, such as `⌘`, `Enter`, or `Esc`. */
|
|
5
|
-
export function Kbd({ variant =
|
|
6
|
-
return
|
|
5
|
+
export function Kbd({ variant = 'default', className, ...props }) {
|
|
6
|
+
return _jsx("kbd", { "data-slot": "kbd", "data-variant": variant, className: cn('sprout-kbd', className), ...props });
|
|
7
7
|
}
|
|
8
8
|
/** Keys pressed together, such as `⌘` `K`. */
|
|
9
9
|
export function KbdGroup({ className, ...props }) {
|
|
10
|
-
return
|
|
10
|
+
return _jsx("kbd", { "data-slot": "kbd-group", className: cn('sprout-kbd-group', className), ...props });
|
|
11
11
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ComponentProps } from
|
|
2
|
-
export type LabelProps = ComponentProps<
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
export type LabelProps = ComponentProps<'label'>;
|
|
3
3
|
/**
|
|
4
4
|
* Names one form control. Point `htmlFor` at a control's `id`, or wrap a
|
|
5
5
|
* checkbox, switch, or radio with its text. A label wrapping a text control,
|
package/dist/components/label.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from
|
|
2
|
+
import { cn } from '../internal/classes.js';
|
|
3
3
|
/**
|
|
4
4
|
* Names one form control. Point `htmlFor` at a control's `id`, or wrap a
|
|
5
5
|
* checkbox, switch, or radio with its text. A label wrapping a text control,
|
|
6
6
|
* such as a textarea, stacks the text above it.
|
|
7
7
|
*/
|
|
8
8
|
export function Label({ className, ...props }) {
|
|
9
|
-
return
|
|
9
|
+
return _jsx("label", { "data-slot": "label", className: cn('sprout-label', className), ...props });
|
|
10
10
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type ComponentProps, type ReactNode } from
|
|
1
|
+
import { type ComponentProps, type ReactNode } from 'react';
|
|
2
2
|
export declare const mentionStatusToneNames: readonly ["loading", "empty", "error"];
|
|
3
3
|
export type MentionStatusTone = (typeof mentionStatusToneNames)[number];
|
|
4
|
-
export interface MentionListProps extends Omit<ComponentProps<
|
|
4
|
+
export interface MentionListProps extends Omit<ComponentProps<'div'>, 'id' | 'children'> {
|
|
5
5
|
/** The listbox id. Point the text field's `aria-controls` at it. */
|
|
6
6
|
id: string;
|
|
7
7
|
/** Names the listbox, such as “Files you can add”. */
|
|
@@ -21,7 +21,7 @@ export interface MentionListProps extends Omit<ComponentProps<"div">, "id" | "ch
|
|
|
21
21
|
* owns the arrow keys; it points `aria-activedescendant` at the active option.
|
|
22
22
|
*/
|
|
23
23
|
export declare function MentionList({ id, label, status, announcement, children, className, ...props }: MentionListProps): import("react").JSX.Element;
|
|
24
|
-
export interface MentionOptionProps extends Omit<ComponentProps<
|
|
24
|
+
export interface MentionOptionProps extends Omit<ComponentProps<'li'>, 'id' | 'title' | 'children' | 'onSelect'> {
|
|
25
25
|
/** Unique id the text field uses in `aria-activedescendant`. */
|
|
26
26
|
id: string;
|
|
27
27
|
/** The keyboard-highlighted option. It scrolls into view when it becomes active. */
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useEffect, useId, useRef
|
|
3
|
-
import { cn } from
|
|
4
|
-
import { Button } from
|
|
5
|
-
import { Spinner } from
|
|
6
|
-
export const mentionStatusToneNames = [
|
|
2
|
+
import { useEffect, useId, useRef } from 'react';
|
|
3
|
+
import { cn } from '../internal/classes.js';
|
|
4
|
+
import { Button } from './button.js';
|
|
5
|
+
import { Spinner } from './spinner.js';
|
|
6
|
+
export const mentionStatusToneNames = ['loading', 'empty', 'error'];
|
|
7
7
|
/**
|
|
8
8
|
* A suggestion panel for `@` and `/` triggers. The text field keeps focus and
|
|
9
9
|
* owns the arrow keys; it points `aria-activedescendant` at the active option.
|
|
10
10
|
*/
|
|
11
11
|
export function MentionList({ id, label, status, announcement, children, className, ...props }) {
|
|
12
|
-
return (_jsxs("div", { "data-slot": "mention-list", className: cn(
|
|
12
|
+
return (_jsxs("div", { "data-slot": "mention-list", className: cn('sprout-mention-list', className), ...props, children: [_jsx("ul", { id: id, role: "listbox", "aria-label": label, className: "sprout-mention-list-options", children: children }), status, _jsx("p", { role: "status", className: "sprout-mention-list-announcement", children: announcement })] }));
|
|
13
13
|
}
|
|
14
14
|
export function MentionOption({ id, active, onSelect, media, title, description, className, ...props }) {
|
|
15
15
|
const option = useRef(null);
|
|
16
16
|
useEffect(() => {
|
|
17
17
|
if (active)
|
|
18
|
-
option.current?.scrollIntoView?.({ block:
|
|
18
|
+
option.current?.scrollIntoView?.({ block: 'nearest' });
|
|
19
19
|
}, [active]);
|
|
20
|
-
return (_jsxs("li", { ref: option, id: id, role: "option", "aria-selected": active, "data-slot": "mention-option", "data-active": active ?
|
|
20
|
+
return (_jsxs("li", { ref: option, id: id, role: "option", "aria-selected": active, "data-slot": "mention-option", "data-active": active ? '' : undefined, className: cn('sprout-mention-option', className), ...props,
|
|
21
21
|
// Keeps focus (and the caret) in the text field.
|
|
22
|
-
onMouseDown:
|
|
22
|
+
onMouseDown: event => event.preventDefault(), onClick: onSelect, children: [media != null && media !== false && (_jsx("span", { "data-slot": "mention-option-media", className: "sprout-mention-option-media", children: media })), _jsxs("span", { className: "sprout-mention-option-text", children: [_jsx("span", { className: "sprout-mention-option-title", title: title, children: title }), description && _jsx("span", { className: "sprout-mention-option-description", children: description })] })] }));
|
|
23
23
|
}
|
|
24
24
|
/** A labelled run of options inside the same listbox, so arrow keys move across groups. */
|
|
25
25
|
export function MentionGroup({ label, children }) {
|
|
@@ -27,5 +27,5 @@ export function MentionGroup({ label, children }) {
|
|
|
27
27
|
return (_jsxs("li", { role: "presentation", "data-slot": "mention-group", className: "sprout-mention-group", children: [_jsx("span", { id: id, "aria-hidden": "true", className: "sprout-mention-group-label", children: label }), _jsx("ul", { role: "group", "aria-labelledby": id, className: "sprout-mention-group-options", children: children })] }));
|
|
28
28
|
}
|
|
29
29
|
export function MentionStatus({ tone, children, action }) {
|
|
30
|
-
return (_jsxs("div", { "data-slot": "mention-status", "data-tone": tone, role: tone ===
|
|
30
|
+
return (_jsxs("div", { "data-slot": "mention-status", "data-tone": tone, role: tone === 'error' ? 'alert' : 'status', className: "sprout-mention-status", children: [tone === 'loading' && _jsx(Spinner, { "aria-hidden": "true" }), _jsx("span", { className: "sprout-mention-status-text", children: children }), action && (_jsx(Button, { size: "sm", variant: "outline", className: "sprout-mention-status-action", onMouseDown: event => event.preventDefault(), onClick: action.onAction, children: action.label }))] }));
|
|
31
31
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ComponentProps } from
|
|
2
|
-
import { Menu as MenuPrimitive } from
|
|
3
|
-
import { Menubar as MenubarPrimitive } from
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { Menu as MenuPrimitive } from '@base-ui/react/menu';
|
|
3
|
+
import { Menubar as MenubarPrimitive } from '@base-ui/react/menubar';
|
|
4
4
|
export declare const menubarItemVariantNames: readonly ["default", "destructive"];
|
|
5
5
|
export type MenubarItemVariant = (typeof menubarItemVariantNames)[number];
|
|
6
6
|
export type MenubarProps = MenubarPrimitive.Props;
|
|
@@ -16,10 +16,10 @@ export type MenubarPortalProps = MenuPrimitive.Portal.Props;
|
|
|
16
16
|
export declare function MenubarPortal(props: MenubarPortalProps): import("react").JSX.Element;
|
|
17
17
|
export type MenubarTriggerProps = MenuPrimitive.Trigger.Props;
|
|
18
18
|
export declare function MenubarTrigger({ className, ...props }: MenubarTriggerProps): import("react").JSX.Element;
|
|
19
|
-
type PositionerProps = Pick<MenuPrimitive.Positioner.Props,
|
|
19
|
+
type PositionerProps = Pick<MenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'collisionPadding' | 'collisionAvoidance' | 'sticky' | 'positionMethod'>;
|
|
20
20
|
export interface MenubarContentProps extends MenuPrimitive.Popup.Props, PositionerProps {
|
|
21
21
|
/** Where the portal renders. Defaults to `document.body`. */
|
|
22
|
-
container?: MenuPrimitive.Portal.Props[
|
|
22
|
+
container?: MenuPrimitive.Portal.Props['container'];
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* The menu surface. It renders its own portal and positioner, so place it
|
|
@@ -50,7 +50,7 @@ export interface MenubarRadioItemProps extends MenuPrimitive.RadioItem.Props, In
|
|
|
50
50
|
export declare function MenubarRadioItem({ className, inset, children, ...props }: MenubarRadioItemProps): import("react").JSX.Element;
|
|
51
51
|
export type MenubarSeparatorProps = MenuPrimitive.Separator.Props;
|
|
52
52
|
export declare function MenubarSeparator({ className, ...props }: MenubarSeparatorProps): import("react").JSX.Element;
|
|
53
|
-
export type MenubarShortcutProps = ComponentProps<
|
|
53
|
+
export type MenubarShortcutProps = ComponentProps<'span'>;
|
|
54
54
|
/** Right-aligned hint text, such as a keyboard shortcut. It does not bind keys. */
|
|
55
55
|
export declare function MenubarShortcut({ className, ...props }: MenubarShortcutProps): import("react").JSX.Element;
|
|
56
56
|
export type MenubarSubProps = MenuPrimitive.SubmenuRoot.Props;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Menu as MenuPrimitive } from
|
|
4
|
-
import { Menubar as MenubarPrimitive } from
|
|
5
|
-
import { Check } from
|
|
6
|
-
import { ChevronRight } from
|
|
7
|
-
import { cn, stateClassName } from
|
|
8
|
-
export const menubarItemVariantNames = [
|
|
3
|
+
import { Menu as MenuPrimitive } from '@base-ui/react/menu';
|
|
4
|
+
import { Menubar as MenubarPrimitive } from '@base-ui/react/menubar';
|
|
5
|
+
import { Check } from 'reicon-react/icons/Check';
|
|
6
|
+
import { ChevronRight } from 'reicon-react/icons/ChevronRight';
|
|
7
|
+
import { cn, stateClassName } from '../internal/classes.js';
|
|
8
|
+
export const menubarItemVariantNames = ['default', 'destructive'];
|
|
9
9
|
/**
|
|
10
10
|
* A row of menus, like an app's File and View menus. Left and Right move
|
|
11
11
|
* between triggers, and Down opens the focused menu.
|
|
12
12
|
*/
|
|
13
13
|
export function Menubar({ className, ...props }) {
|
|
14
|
-
return (_jsx(MenubarPrimitive, { "data-slot": "menubar", ...props, className: stateClassName(
|
|
14
|
+
return (_jsx(MenubarPrimitive, { "data-slot": "menubar", ...props, className: stateClassName('sprout-menubar', className) }));
|
|
15
15
|
}
|
|
16
16
|
/** One menu in the bar. Place a `MenubarTrigger` and `MenubarContent` inside. */
|
|
17
17
|
export function MenubarMenu(props) {
|
|
@@ -21,48 +21,48 @@ export function MenubarPortal(props) {
|
|
|
21
21
|
return _jsx(MenuPrimitive.Portal, { "data-slot": "menubar-portal", ...props });
|
|
22
22
|
}
|
|
23
23
|
export function MenubarTrigger({ className, ...props }) {
|
|
24
|
-
return (_jsx(MenuPrimitive.Trigger, { "data-slot": "menubar-trigger", ...props, className: stateClassName(
|
|
24
|
+
return (_jsx(MenuPrimitive.Trigger, { "data-slot": "menubar-trigger", ...props, className: stateClassName('sprout-menubar-trigger', className) }));
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* The menu surface. It renders its own portal and positioner, so place it
|
|
28
28
|
* directly inside `MenubarMenu`. It lines up with the bar's inner edge.
|
|
29
29
|
*/
|
|
30
|
-
export function MenubarContent({ align =
|
|
31
|
-
return (_jsx(MenuPrimitive.Portal, { container: container, children: _jsx(MenuPrimitive.Positioner, { className: "sprout-menubar-positioner", align: align, alignOffset: alignOffset, side: side, sideOffset: sideOffset, collisionPadding: collisionPadding, collisionAvoidance: collisionAvoidance, sticky: sticky, positionMethod: positionMethod, children: _jsx(MenuPrimitive.Popup, { "data-slot": "menubar-content", ...props, className: stateClassName(
|
|
30
|
+
export function MenubarContent({ align = 'start', alignOffset = -4, side = 'bottom', sideOffset = 8, collisionPadding = 8, collisionAvoidance, sticky, positionMethod, container, className, ...props }) {
|
|
31
|
+
return (_jsx(MenuPrimitive.Portal, { container: container, children: _jsx(MenuPrimitive.Positioner, { className: "sprout-menubar-positioner", align: align, alignOffset: alignOffset, side: side, sideOffset: sideOffset, collisionPadding: collisionPadding, collisionAvoidance: collisionAvoidance, sticky: sticky, positionMethod: positionMethod, children: _jsx(MenuPrimitive.Popup, { "data-slot": "menubar-content", ...props, className: stateClassName('sprout-menubar-content', className) }) }) }));
|
|
32
32
|
}
|
|
33
33
|
export function MenubarGroup(props) {
|
|
34
34
|
return _jsx(MenuPrimitive.Group, { "data-slot": "menubar-group", ...props });
|
|
35
35
|
}
|
|
36
36
|
export function MenubarLabel({ className, inset, ...props }) {
|
|
37
|
-
return (_jsx(MenuPrimitive.GroupLabel, { "data-slot": "menubar-label", "data-inset": inset || undefined, ...props, className: stateClassName(
|
|
37
|
+
return (_jsx(MenuPrimitive.GroupLabel, { "data-slot": "menubar-label", "data-inset": inset || undefined, ...props, className: stateClassName('sprout-menubar-label', className) }));
|
|
38
38
|
}
|
|
39
|
-
export function MenubarItem({ className, inset, variant =
|
|
40
|
-
return (_jsx(MenuPrimitive.Item, { "data-slot": "menubar-item", "data-inset": inset || undefined, "data-variant": variant, ...props, className: stateClassName(
|
|
39
|
+
export function MenubarItem({ className, inset, variant = 'default', ...props }) {
|
|
40
|
+
return (_jsx(MenuPrimitive.Item, { "data-slot": "menubar-item", "data-inset": inset || undefined, "data-variant": variant, ...props, className: stateClassName('sprout-menubar-item', className) }));
|
|
41
41
|
}
|
|
42
42
|
/** A toggle row. The check sits at the start, so the label lines up with `inset` rows. */
|
|
43
43
|
export function MenubarCheckboxItem({ className, inset, children, ...props }) {
|
|
44
|
-
return (_jsxs(MenuPrimitive.CheckboxItem, { "data-slot": "menubar-checkbox-item", "data-inset": inset || undefined, ...props, className: stateClassName(
|
|
44
|
+
return (_jsxs(MenuPrimitive.CheckboxItem, { "data-slot": "menubar-checkbox-item", "data-inset": inset || undefined, ...props, className: stateClassName('sprout-menubar-item sprout-menubar-choice', className), children: [_jsx("span", { className: "sprout-menubar-indicator", "data-slot": "menubar-checkbox-item-indicator", children: _jsx(MenuPrimitive.CheckboxItemIndicator, { children: _jsx(Check, { size: 16, "aria-hidden": "true" }) }) }), children] }));
|
|
45
45
|
}
|
|
46
46
|
export function MenubarRadioGroup(props) {
|
|
47
|
-
return
|
|
47
|
+
return _jsx(MenuPrimitive.RadioGroup, { "data-slot": "menubar-radio-group", ...props });
|
|
48
48
|
}
|
|
49
49
|
export function MenubarRadioItem({ className, inset, children, ...props }) {
|
|
50
|
-
return (_jsxs(MenuPrimitive.RadioItem, { "data-slot": "menubar-radio-item", "data-inset": inset || undefined, ...props, className: stateClassName(
|
|
50
|
+
return (_jsxs(MenuPrimitive.RadioItem, { "data-slot": "menubar-radio-item", "data-inset": inset || undefined, ...props, className: stateClassName('sprout-menubar-item sprout-menubar-choice', className), children: [_jsx("span", { className: "sprout-menubar-indicator", "data-slot": "menubar-radio-item-indicator", children: _jsx(MenuPrimitive.RadioItemIndicator, { children: _jsx(Check, { size: 16, "aria-hidden": "true" }) }) }), children] }));
|
|
51
51
|
}
|
|
52
52
|
export function MenubarSeparator({ className, ...props }) {
|
|
53
|
-
return (_jsx(MenuPrimitive.Separator, { "data-slot": "menubar-separator", ...props, className: stateClassName(
|
|
53
|
+
return (_jsx(MenuPrimitive.Separator, { "data-slot": "menubar-separator", ...props, className: stateClassName('sprout-menubar-separator', className) }));
|
|
54
54
|
}
|
|
55
55
|
/** Right-aligned hint text, such as a keyboard shortcut. It does not bind keys. */
|
|
56
56
|
export function MenubarShortcut({ className, ...props }) {
|
|
57
|
-
return
|
|
57
|
+
return _jsx("span", { "data-slot": "menubar-shortcut", ...props, className: cn('sprout-menubar-shortcut', className) });
|
|
58
58
|
}
|
|
59
59
|
export function MenubarSub(props) {
|
|
60
60
|
return _jsx(MenuPrimitive.SubmenuRoot, { ...props });
|
|
61
61
|
}
|
|
62
62
|
export function MenubarSubTrigger({ className, inset, children, ...props }) {
|
|
63
|
-
return (_jsxs(MenuPrimitive.SubmenuTrigger, { "data-slot": "menubar-sub-trigger", "data-inset": inset || undefined, ...props, className: stateClassName(
|
|
63
|
+
return (_jsxs(MenuPrimitive.SubmenuTrigger, { "data-slot": "menubar-sub-trigger", "data-inset": inset || undefined, ...props, className: stateClassName('sprout-menubar-item sprout-menubar-sub-trigger', className), children: [children, _jsx(ChevronRight, { size: 16, "aria-hidden": "true", className: "sprout-menubar-sub-chevron" })] }));
|
|
64
64
|
}
|
|
65
65
|
/** A nested menu surface. It opens to the side and sizes to its content. */
|
|
66
|
-
export function MenubarSubContent({ align =
|
|
67
|
-
return (_jsx(MenubarContent, { "data-slot": "menubar-sub-content", align: align, alignOffset: alignOffset, side: side, sideOffset: sideOffset, ...props, className: stateClassName(
|
|
66
|
+
export function MenubarSubContent({ align = 'start', alignOffset = -5, side = 'right', sideOffset = 0, className, ...props }) {
|
|
67
|
+
return (_jsx(MenubarContent, { "data-slot": "menubar-sub-content", align: align, alignOffset: alignOffset, side: side, sideOffset: sideOffset, ...props, className: stateClassName('sprout-menubar-sub-content', className) }));
|
|
68
68
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export declare const messageActionsAuthorNames: readonly ["assistant", "human"];
|
|
2
2
|
export type MessageActionsAuthor = (typeof messageActionsAuthorNames)[number];
|
|
3
|
-
export type MessageFeedback =
|
|
3
|
+
export type MessageFeedback = 'up' | 'down';
|
|
4
4
|
export interface MessageActionsProps {
|
|
5
5
|
/** The Markdown the message was written in. Copy turns links into `label (url)` plain text. */
|
|
6
6
|
text: string;
|
|
@@ -31,4 +31,4 @@ export interface MessageBranchProps {
|
|
|
31
31
|
className?: string | undefined;
|
|
32
32
|
}
|
|
33
33
|
/** Steps between regenerated versions of one response. */
|
|
34
|
-
export declare function MessageBranch({ index, total, onChange, className
|
|
34
|
+
export declare function MessageBranch({ index, total, onChange, className }: MessageBranchProps): import("react").JSX.Element;
|
|
@@ -1,68 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from
|
|
4
|
-
import { Check } from
|
|
5
|
-
import { ChevronLeft } from
|
|
6
|
-
import { ChevronRight } from
|
|
7
|
-
import { Copy } from
|
|
8
|
-
import { ThumbsDown } from
|
|
9
|
-
import { ThumbsUp } from
|
|
10
|
-
import { cn } from
|
|
11
|
-
import { Button } from
|
|
12
|
-
export const messageActionsAuthorNames = [
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { Check } from 'reicon-react/icons/Check';
|
|
5
|
+
import { ChevronLeft } from 'reicon-react/icons/ChevronLeft';
|
|
6
|
+
import { ChevronRight } from 'reicon-react/icons/ChevronRight';
|
|
7
|
+
import { Copy } from 'reicon-react/icons/Copy';
|
|
8
|
+
import { ThumbsDown } from 'reicon-react/icons/ThumbsDown';
|
|
9
|
+
import { ThumbsUp } from 'reicon-react/icons/ThumbsUp';
|
|
10
|
+
import { cn } from '../internal/classes.js';
|
|
11
|
+
import { Button } from './button.js';
|
|
12
|
+
export const messageActionsAuthorNames = ['assistant', 'human'];
|
|
13
13
|
const markdownLink = /\[([^\]]*)\]\(<?([^)\s>]+)>?(?:\s+"[^"]*")?\)/g;
|
|
14
14
|
function plainTextFromMarkdown(markdown) {
|
|
15
15
|
return markdown
|
|
16
|
-
.replace(markdownLink, (_, label, url) => !label || label === url ? url : `${label} (${url})`)
|
|
17
|
-
.replace(/<(https?:\/\/[^>\s]+)>/g,
|
|
16
|
+
.replace(markdownLink, (_, label, url) => (!label || label === url ? url : `${label} (${url})`))
|
|
17
|
+
.replace(/<(https?:\/\/[^>\s]+)>/g, '$1');
|
|
18
18
|
}
|
|
19
19
|
function formatDate(options, date) {
|
|
20
|
-
return Number.isNaN(date.getTime())
|
|
21
|
-
? date.toString()
|
|
22
|
-
: new Intl.DateTimeFormat([], options).format(date);
|
|
20
|
+
return Number.isNaN(date.getTime()) ? date.toString() : new Intl.DateTimeFormat([], options).format(date);
|
|
23
21
|
}
|
|
24
22
|
const startOfDay = (date) => new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime();
|
|
25
23
|
function messageTime(iso, now = new Date()) {
|
|
26
24
|
const date = new Date(iso);
|
|
27
|
-
const time = formatDate({ hour:
|
|
25
|
+
const time = formatDate({ hour: 'numeric', minute: '2-digit' }, date);
|
|
28
26
|
const days = Math.round((startOfDay(now) - startOfDay(date)) / 86_400_000);
|
|
29
27
|
if (days === 0)
|
|
30
28
|
return time;
|
|
31
29
|
if (days === 1)
|
|
32
30
|
return `Yesterday ${time}`;
|
|
33
31
|
const day = formatDate(date.getFullYear() === now.getFullYear()
|
|
34
|
-
? { month:
|
|
35
|
-
: { month:
|
|
32
|
+
? { month: 'short', day: 'numeric' }
|
|
33
|
+
: { month: 'short', day: 'numeric', year: 'numeric' }, date);
|
|
36
34
|
return `${day}, ${time}`;
|
|
37
35
|
}
|
|
38
36
|
/** Copy, send time, feedback, and regenerate for one chat message. */
|
|
39
|
-
export function MessageActions({ text, author =
|
|
40
|
-
const [copy, setCopy] = useState(
|
|
41
|
-
const noun = author ===
|
|
42
|
-
const Noun = author ===
|
|
37
|
+
export function MessageActions({ text, author = 'assistant', createdAt, html, hover = false, feedback, onFeedback, onRetry, disabled = false, className, }) {
|
|
38
|
+
const [copy, setCopy] = useState('idle');
|
|
39
|
+
const noun = author === 'human' ? 'message' : 'response';
|
|
40
|
+
const Noun = author === 'human' ? 'Message' : 'Response';
|
|
43
41
|
const copyText = async () => {
|
|
44
42
|
const plain = plainTextFromMarkdown(text);
|
|
45
43
|
const rich = html?.();
|
|
46
44
|
try {
|
|
47
|
-
if (rich && typeof ClipboardItem !==
|
|
45
|
+
if (rich && typeof ClipboardItem !== 'undefined')
|
|
48
46
|
await navigator.clipboard.write([
|
|
49
47
|
new ClipboardItem({
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
'text/html': new Blob([rich], { type: 'text/html' }),
|
|
49
|
+
'text/plain': new Blob([plain], { type: 'text/plain' }),
|
|
52
50
|
}),
|
|
53
51
|
]);
|
|
54
52
|
else
|
|
55
53
|
await navigator.clipboard.writeText(plain);
|
|
56
|
-
setCopy(
|
|
54
|
+
setCopy('copied');
|
|
57
55
|
}
|
|
58
56
|
catch {
|
|
59
|
-
setCopy(
|
|
57
|
+
setCopy('error');
|
|
60
58
|
}
|
|
61
59
|
};
|
|
62
60
|
const rate = (value) => onFeedback?.(feedback === value ? null : value);
|
|
63
|
-
return (_jsxs("div", { "data-slot": "message-actions", "data-author": author, className: cn(
|
|
61
|
+
return (_jsxs("div", { "data-slot": "message-actions", "data-author": author, className: cn('sprout-message-actions', className), children: [_jsxs("div", { role: "group", "aria-label": `${Noun} actions`, "data-hover": hover ? '' : undefined, className: "sprout-message-actions-row", children: [_jsx(Button, { variant: "ghost", size: "icon-sm", disabled: disabled, "aria-label": copy === 'copied' ? `${Noun} copied` : `Copy ${noun}`, title: `Copy ${noun}`, "data-copied": copy === 'copied' ? '' : undefined, onClick: () => void copyText(), children: copy === 'copied' ? _jsx(Check, { size: 16, "aria-hidden": "true" }) : _jsx(Copy, { size: 16, "aria-hidden": "true" }) }), createdAt && (_jsx("time", { className: "sprout-message-actions-time", dateTime: createdAt, title: formatDate({ dateStyle: 'full', timeStyle: 'medium' }, new Date(createdAt)), children: messageTime(createdAt) })), onFeedback && (_jsxs(_Fragment, { children: [_jsx(Button, { variant: feedback === 'up' ? 'secondary' : 'ghost', size: "icon-sm", disabled: disabled, "aria-label": "Helpful response", "aria-pressed": feedback === 'up', title: "Helpful", onClick: () => rate('up'), children: _jsx(ThumbsUp, { size: 16, "aria-hidden": "true" }) }), _jsx(Button, { variant: feedback === 'down' ? 'secondary' : 'ghost', size: "icon-sm", disabled: disabled, "aria-label": "Unhelpful response", "aria-pressed": feedback === 'down', title: "Unhelpful", onClick: () => rate('down'), children: _jsx(ThumbsDown, { size: 16, "aria-hidden": "true" }) })] })), onRetry && (_jsx(Button, { variant: "ghost", size: "sm", disabled: disabled, onClick: onRetry, children: "Regenerate" }))] }), copy === 'error' && (_jsxs("p", { role: "alert", className: "sprout-message-actions-error", children: ["Couldn't copy. Select the ", noun, " text or try again."] })), _jsx("span", { role: "status", className: "sprout-message-actions-sr-only", children: copy === 'copied' ? `${Noun} copied to clipboard.` : '' })] }));
|
|
64
62
|
}
|
|
65
63
|
/** Steps between regenerated versions of one response. */
|
|
66
|
-
export function MessageBranch({ index, total, onChange, className
|
|
67
|
-
return (_jsxs("div", { "data-slot": "message-branch", role: "group", "aria-label": "Response versions", className: cn(
|
|
64
|
+
export function MessageBranch({ index, total, onChange, className }) {
|
|
65
|
+
return (_jsxs("div", { "data-slot": "message-branch", role: "group", "aria-label": "Response versions", className: cn('sprout-message-branch', className), children: [_jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Previous response", disabled: index <= 0, onClick: () => onChange(index - 1), children: _jsx(ChevronLeft, { size: 14, "aria-hidden": "true" }) }), _jsxs("span", { "aria-live": "polite", className: "sprout-message-branch-count", children: [index + 1, " / ", total] }), _jsx(Button, { variant: "ghost", size: "icon-sm", "aria-label": "Next response", disabled: index >= total - 1, onClick: () => onChange(index + 1), children: _jsx(ChevronRight, { size: 14, "aria-hidden": "true" }) })] }));
|
|
68
66
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HTMLAttributes, type ReactNode } from
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from 'react';
|
|
2
2
|
/** Renders one Markdown link. Return a plain `<a>` for links you do not handle. */
|
|
3
3
|
export type MessageResponseRenderLink = (href: string, children: ReactNode) => ReactNode;
|
|
4
4
|
export interface MessageTableViewportProps {
|
|
@@ -7,8 +7,8 @@ export interface MessageTableViewportProps {
|
|
|
7
7
|
children?: ReactNode;
|
|
8
8
|
}
|
|
9
9
|
/** Sets how tall the tables in the responses inside it may grow. */
|
|
10
|
-
export declare function MessageTableViewport({ bounded, children
|
|
11
|
-
export interface MessageResponseProps extends Omit<HTMLAttributes<HTMLDivElement>,
|
|
10
|
+
export declare function MessageTableViewport({ bounded, children }: MessageTableViewportProps): import("react").JSX.Element;
|
|
11
|
+
export interface MessageResponseProps extends Omit<HTMLAttributes<HTMLDivElement>, 'children'> {
|
|
12
12
|
/** Markdown with GitHub extensions. Raw HTML is dropped and images are not shown. */
|
|
13
13
|
children: string;
|
|
14
14
|
/** Marks the response busy and shows a caret after the text. */
|
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, useContext, useMemo
|
|
4
|
-
import Markdown, {} from
|
|
5
|
-
import remarkGfm from
|
|
6
|
-
import { cn } from
|
|
7
|
-
import { CodeBlock } from
|
|
3
|
+
import { createContext, useContext, useMemo } from 'react';
|
|
4
|
+
import Markdown, {} from 'react-markdown';
|
|
5
|
+
import remarkGfm from 'remark-gfm';
|
|
6
|
+
import { cn } from '../internal/classes.js';
|
|
7
|
+
import { CodeBlock } from './code-block.js';
|
|
8
8
|
const LinkContext = createContext(undefined);
|
|
9
9
|
const TableContext = createContext(false);
|
|
10
10
|
/** Sets how tall the tables in the responses inside it may grow. */
|
|
11
|
-
export function MessageTableViewport({ bounded, children
|
|
11
|
+
export function MessageTableViewport({ bounded, children }) {
|
|
12
12
|
return _jsx(TableContext, { value: bounded, children: children });
|
|
13
13
|
}
|
|
14
14
|
const ResponseTable = ({ children }) => {
|
|
15
15
|
const bounded = useContext(TableContext);
|
|
16
|
-
return (_jsx("div", { className: "sprout-message-response-table", "data-bounded": bounded ?
|
|
16
|
+
return (_jsx("div", { className: "sprout-message-response-table", "data-bounded": bounded ? '' : undefined, tabIndex: 0, role: "region", "aria-label": "Response table", children: _jsx("table", { children: children }) }));
|
|
17
17
|
};
|
|
18
18
|
function ResponseLink({ href, children }) {
|
|
19
19
|
const render = useContext(LinkContext);
|
|
20
|
-
return render ? (render(href ??
|
|
20
|
+
return render ? (render(href ?? '', children)) : (_jsx("a", { href: href, target: "_blank", rel: "noopener noreferrer", children: children }));
|
|
21
21
|
}
|
|
22
22
|
const components = {
|
|
23
23
|
pre({ node, children }) {
|
|
24
24
|
const code = node?.children[0];
|
|
25
|
-
if (code?.type !==
|
|
25
|
+
if (code?.type !== 'element' || code.tagName !== 'code')
|
|
26
26
|
return _jsx("pre", { children: children });
|
|
27
27
|
const classes = code.properties.className;
|
|
28
28
|
const language = Array.isArray(classes)
|
|
29
|
-
? classes.find((value) => typeof value ===
|
|
29
|
+
? classes.find((value) => typeof value === 'string' && value.startsWith('language-'))
|
|
30
30
|
: undefined;
|
|
31
31
|
const text = code.children
|
|
32
|
-
.map(
|
|
33
|
-
.join(
|
|
34
|
-
.replace(/\n$/,
|
|
35
|
-
return
|
|
32
|
+
.map(child => (child.type === 'text' ? child.value : ''))
|
|
33
|
+
.join('')
|
|
34
|
+
.replace(/\n$/, '');
|
|
35
|
+
return _jsx(CodeBlock, { code: text, language: language ? language.slice(9) : 'text' });
|
|
36
36
|
},
|
|
37
37
|
a: ResponseLink,
|
|
38
38
|
table: ResponseTable,
|
|
39
39
|
// GFM task list boxes have no label of their own; the item text follows them.
|
|
40
|
-
input: ({ node: _node, ...props }) => props.type ===
|
|
40
|
+
input: ({ node: _node, ...props }) => props.type === 'checkbox' ? _jsx("input", { ...props, "aria-label": "Task" }) : _jsx("input", { ...props }),
|
|
41
41
|
};
|
|
42
42
|
/** Renders an assistant's Markdown reply: headings, lists, quotes, tables, task lists, and code blocks. */
|
|
43
43
|
export function MessageResponse({ children, streaming = false, renderLink, className, ...props }) {
|
|
44
|
-
const markdown = useMemo(() => (_jsx(Markdown, { remarkPlugins: [remarkGfm], components: components, skipHtml: true, disallowedElements: [
|
|
45
|
-
return (_jsxs("div", { "data-slot": "message-response", "data-streaming": streaming ?
|
|
44
|
+
const markdown = useMemo(() => (_jsx(Markdown, { remarkPlugins: [remarkGfm], components: components, skipHtml: true, disallowedElements: ['img'], children: children })), [children]);
|
|
45
|
+
return (_jsxs("div", { "data-slot": "message-response", "data-streaming": streaming ? '' : undefined, "aria-busy": streaming, ...props, className: cn('sprout-message-response', className), children: [_jsx(LinkContext, { value: renderLink, children: markdown }), streaming && _jsx("span", { "aria-hidden": "true", className: "sprout-message-response-caret" })] }));
|
|
46
46
|
}
|