@tulipfarm/sprout 0.3.1 → 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 +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 +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 +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 +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 +3 -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,5 +1,5 @@
|
|
|
1
|
-
import { type ChangeEvent, type ComponentProps, type ReactNode } from
|
|
2
|
-
import { type DialogContentProps, type DialogProps } from
|
|
1
|
+
import { type ChangeEvent, type ComponentProps, type ReactNode } from 'react';
|
|
2
|
+
import { type DialogContentProps, type DialogProps } from './dialog.js';
|
|
3
3
|
/** Scores how well `value` and `keywords` match `search`. `0` hides the item; higher ranks first. */
|
|
4
4
|
export type CommandFilter = (value: string, search: string, keywords?: readonly string[]) => number;
|
|
5
5
|
/**
|
|
@@ -8,7 +8,7 @@ export type CommandFilter = (value: string, search: string, keywords?: readonly
|
|
|
8
8
|
* rank above loose ones. Case and accents are ignored.
|
|
9
9
|
*/
|
|
10
10
|
export declare const defaultCommandFilter: CommandFilter;
|
|
11
|
-
export interface CommandProps extends ComponentProps<
|
|
11
|
+
export interface CommandProps extends ComponentProps<'div'> {
|
|
12
12
|
/** Accessible name for the search input when it has no `aria-label`. */
|
|
13
13
|
label?: string;
|
|
14
14
|
/** Set to `false` to filter items yourself and render only the matches. */
|
|
@@ -24,7 +24,7 @@ export interface CommandProps extends ComponentProps<"div"> {
|
|
|
24
24
|
* active item is announced through `aria-activedescendant`.
|
|
25
25
|
*/
|
|
26
26
|
export declare function Command({ label, shouldFilter, filter, loop, className, children, onKeyDown, ref, ...props }: CommandProps): import("react").JSX.Element;
|
|
27
|
-
export interface CommandInputProps extends Omit<ComponentProps<
|
|
27
|
+
export interface CommandInputProps extends Omit<ComponentProps<'input'>, 'value' | 'defaultValue' | 'onChange' | 'type'> {
|
|
28
28
|
/** Controlled search text. */
|
|
29
29
|
value?: string;
|
|
30
30
|
onValueChange?: (search: string) => void;
|
|
@@ -32,17 +32,17 @@ export interface CommandInputProps extends Omit<ComponentProps<"input">, "value"
|
|
|
32
32
|
}
|
|
33
33
|
/** The search field with a leading magnifier. It drives filtering and keyboard navigation. */
|
|
34
34
|
export declare function CommandInput({ value, onValueChange, onChange, className, id, ...props }: CommandInputProps): import("react").JSX.Element;
|
|
35
|
-
export type CommandListProps = ComponentProps<
|
|
35
|
+
export type CommandListProps = ComponentProps<'div'>;
|
|
36
36
|
/**
|
|
37
37
|
* The scrolling listbox. It caps at 18rem and keeps the active item in view.
|
|
38
38
|
* While nothing matches it drops the listbox role so `CommandEmpty` can hold
|
|
39
39
|
* ordinary content such as a Clear search button.
|
|
40
40
|
*/
|
|
41
41
|
export declare function CommandList({ className, children, ...props }: CommandListProps): import("react").JSX.Element;
|
|
42
|
-
export type CommandEmptyProps = ComponentProps<
|
|
42
|
+
export type CommandEmptyProps = ComponentProps<'div'>;
|
|
43
43
|
/** Shown only when no item matches the search. It can hold a recovery action. */
|
|
44
44
|
export declare function CommandEmpty({ className, ...props }: CommandEmptyProps): import("react").JSX.Element | null;
|
|
45
|
-
export interface CommandGroupProps extends Omit<ComponentProps<
|
|
45
|
+
export interface CommandGroupProps extends Omit<ComponentProps<'div'>, 'value'> {
|
|
46
46
|
/** Small muted label above the items. Omit for an unlabeled group. */
|
|
47
47
|
heading?: ReactNode;
|
|
48
48
|
/** Keep the group visible even when none of its items match. */
|
|
@@ -50,12 +50,12 @@ export interface CommandGroupProps extends Omit<ComponentProps<"div">, "value">
|
|
|
50
50
|
}
|
|
51
51
|
/** Groups related items under an optional heading. It hides when none of its items match. */
|
|
52
52
|
export declare function CommandGroup({ heading, forceMount, className, children, style, ...props }: CommandGroupProps): import("react").JSX.Element;
|
|
53
|
-
export interface CommandSeparatorProps extends ComponentProps<
|
|
53
|
+
export interface CommandSeparatorProps extends ComponentProps<'div'> {
|
|
54
54
|
/** Keep the line while searching. By default it hides once the user types. */
|
|
55
55
|
alwaysRender?: boolean;
|
|
56
56
|
}
|
|
57
57
|
export declare function CommandSeparator({ alwaysRender, className, ...props }: CommandSeparatorProps): import("react").JSX.Element | null;
|
|
58
|
-
export interface CommandItemProps extends Omit<ComponentProps<
|
|
58
|
+
export interface CommandItemProps extends Omit<ComponentProps<'div'>, 'value' | 'onSelect'> {
|
|
59
59
|
/** Text the filter matches and `onSelect` receives. Defaults to the item's text. */
|
|
60
60
|
value?: string;
|
|
61
61
|
/** Extra words that match this item, such as a name when `value` is an id. */
|
|
@@ -66,17 +66,17 @@ export interface CommandItemProps extends Omit<ComponentProps<"div">, "value" |
|
|
|
66
66
|
/** Keep the item visible even when it doesn't match the search. */
|
|
67
67
|
forceMount?: boolean;
|
|
68
68
|
/** `true` shows a trailing check for the current choice. Hidden when the item has a shortcut. */
|
|
69
|
-
|
|
69
|
+
'data-checked'?: boolean;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
72
72
|
* One choice. Put an icon first, then the label. A trailing check marks the
|
|
73
73
|
* current choice with `data-checked`; a `CommandShortcut` replaces it.
|
|
74
74
|
*/
|
|
75
75
|
export declare function CommandItem({ value, keywords, disabled, onSelect, forceMount, className, children, style, onClick, onPointerMove, onPointerDown, ...props }: CommandItemProps): import("react").JSX.Element | null;
|
|
76
|
-
export type CommandShortcutProps = ComponentProps<
|
|
76
|
+
export type CommandShortcutProps = ComponentProps<'span'>;
|
|
77
77
|
/** A keyboard hint at the end of an item. */
|
|
78
78
|
export declare function CommandShortcut({ className, ...props }: CommandShortcutProps): import("react").JSX.Element;
|
|
79
|
-
export interface CommandDialogProps extends Omit<DialogProps,
|
|
79
|
+
export interface CommandDialogProps extends Omit<DialogProps, 'children'> {
|
|
80
80
|
/** Visually hidden dialog title. */
|
|
81
81
|
title?: string;
|
|
82
82
|
/** Visually hidden dialog description. */
|
|
@@ -86,7 +86,7 @@ export interface CommandDialogProps extends Omit<DialogProps, "children"> {
|
|
|
86
86
|
showCloseButton?: boolean;
|
|
87
87
|
closeLabel?: string;
|
|
88
88
|
/** Where the portal renders. Defaults to `document.body`. */
|
|
89
|
-
container?: DialogContentProps[
|
|
89
|
+
container?: DialogContentProps['container'];
|
|
90
90
|
/** Usually a `Command`. */
|
|
91
91
|
children: ReactNode;
|
|
92
92
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { createContext, isValidElement, useContext, useId, useLayoutEffect, useRef, useState, useSyncExternalStore, } from
|
|
4
|
-
import { Check } from
|
|
5
|
-
import { Search } from
|
|
6
|
-
import { cn } from
|
|
7
|
-
import { Dialog, DialogContent, DialogDescription, DialogTitle, } from
|
|
3
|
+
import { createContext, isValidElement, useContext, useId, useLayoutEffect, useRef, useState, useSyncExternalStore, } from 'react';
|
|
4
|
+
import { Check } from 'reicon-react/icons/Check';
|
|
5
|
+
import { Search } from 'reicon-react/icons/Search';
|
|
6
|
+
import { cn } from '../internal/classes.js';
|
|
7
|
+
import { Dialog, DialogContent, DialogDescription, DialogTitle, } from './dialog.js';
|
|
8
8
|
const normalize = (text) => text
|
|
9
|
-
.normalize(
|
|
10
|
-
.replace(/\p{Diacritic}/gu,
|
|
9
|
+
.normalize('NFD')
|
|
10
|
+
.replace(/\p{Diacritic}/gu, '')
|
|
11
11
|
.toLowerCase();
|
|
12
12
|
function tokenScore(haystack, token) {
|
|
13
13
|
const index = haystack.indexOf(token);
|
|
@@ -35,7 +35,7 @@ function tokenScore(haystack, token) {
|
|
|
35
35
|
* rank above loose ones. Case and accents are ignored.
|
|
36
36
|
*/
|
|
37
37
|
export const defaultCommandFilter = (value, search, keywords = []) => {
|
|
38
|
-
const haystack = normalize([value, ...keywords].join(
|
|
38
|
+
const haystack = normalize([value, ...keywords].join(' '));
|
|
39
39
|
const tokens = normalize(search).trim().split(/\s+/).filter(Boolean);
|
|
40
40
|
let score = 1;
|
|
41
41
|
for (const token of tokens)
|
|
@@ -43,7 +43,7 @@ export const defaultCommandFilter = (value, search, keywords = []) => {
|
|
|
43
43
|
return score;
|
|
44
44
|
};
|
|
45
45
|
class CommandStore {
|
|
46
|
-
search =
|
|
46
|
+
search = '';
|
|
47
47
|
active = null;
|
|
48
48
|
ready = false;
|
|
49
49
|
count = 0;
|
|
@@ -60,7 +60,7 @@ class CommandStore {
|
|
|
60
60
|
return () => this.listeners.delete(listener);
|
|
61
61
|
};
|
|
62
62
|
get filtering() {
|
|
63
|
-
return this.options.shouldFilter && this.search.trim() !==
|
|
63
|
+
return this.options.shouldFilter && this.search.trim() !== '';
|
|
64
64
|
}
|
|
65
65
|
emit() {
|
|
66
66
|
this.version++;
|
|
@@ -72,9 +72,7 @@ class CommandStore {
|
|
|
72
72
|
this.groupScores.clear();
|
|
73
73
|
let count = 0;
|
|
74
74
|
for (const [id, entry] of this.items) {
|
|
75
|
-
const score = this.filtering
|
|
76
|
-
? this.options.filter(entry.value, this.search, entry.keywords)
|
|
77
|
-
: 1;
|
|
75
|
+
const score = this.filtering ? this.options.filter(entry.value, this.search, entry.keywords) : 1;
|
|
78
76
|
if (score <= 0)
|
|
79
77
|
continue;
|
|
80
78
|
count++;
|
|
@@ -135,10 +133,8 @@ function orderOf(element) {
|
|
|
135
133
|
}
|
|
136
134
|
/** Enabled items in visual order: groups and items reorder by score while searching. */
|
|
137
135
|
function enabledItems(root) {
|
|
138
|
-
const items = [
|
|
139
|
-
|
|
140
|
-
].filter((item) => item.closest('[data-slot="command"]') === root);
|
|
141
|
-
const keyed = items.map((item) => {
|
|
136
|
+
const items = [...root.querySelectorAll(`${ITEM}:not([aria-disabled="true"])`)].filter(item => item.closest('[data-slot="command"]') === root);
|
|
137
|
+
const keyed = items.map(item => {
|
|
142
138
|
const group = item.closest('[data-slot="command-group"]');
|
|
143
139
|
return group && root.contains(group)
|
|
144
140
|
? { item, group, outer: orderOf(group), inner: orderOf(item) }
|
|
@@ -165,8 +161,7 @@ export function Command({ label, shouldFilter = true, filter = defaultCommandFil
|
|
|
165
161
|
context.label = label;
|
|
166
162
|
const version = useStore(store, () => store.version);
|
|
167
163
|
useLayoutEffect(() => {
|
|
168
|
-
const changed = store.options.filter !== filter ||
|
|
169
|
-
store.options.shouldFilter !== shouldFilter;
|
|
164
|
+
const changed = store.options.filter !== filter || store.options.shouldFilter !== shouldFilter;
|
|
170
165
|
store.options = { filter, shouldFilter };
|
|
171
166
|
if (changed && store.ready) {
|
|
172
167
|
store.refilter();
|
|
@@ -186,9 +181,7 @@ export function Command({ label, shouldFilter = true, filter = defaultCommandFil
|
|
|
186
181
|
store.needsFirst = false;
|
|
187
182
|
const first = enabledItems(root.current)[0]?.item;
|
|
188
183
|
store.setActive(first?.id ?? null);
|
|
189
|
-
root.current
|
|
190
|
-
.querySelector('[data-slot="command-list"]')
|
|
191
|
-
?.scrollTo({ top: 0 });
|
|
184
|
+
root.current.querySelector('[data-slot="command-list"]')?.scrollTo({ top: 0 });
|
|
192
185
|
}, [store, version]);
|
|
193
186
|
const move = (to) => {
|
|
194
187
|
if (!root.current)
|
|
@@ -202,12 +195,10 @@ export function Command({ label, shouldFilter = true, filter = defaultCommandFil
|
|
|
202
195
|
return;
|
|
203
196
|
store.setActive(next.item.id);
|
|
204
197
|
const firstInGroup = next.group && items.find(({ group }) => group === next.group) === next;
|
|
205
|
-
const heading = firstInGroup
|
|
206
|
-
|
|
207
|
-
: null;
|
|
208
|
-
(heading ?? next.item).scrollIntoView({ block: "nearest" });
|
|
198
|
+
const heading = firstInGroup ? next.group.querySelector('[data-slot="command-group-heading"]') : null;
|
|
199
|
+
(heading ?? next.item).scrollIntoView({ block: 'nearest' });
|
|
209
200
|
if (heading)
|
|
210
|
-
next.item.scrollIntoView({ block:
|
|
201
|
+
next.item.scrollIntoView({ block: 'nearest' });
|
|
211
202
|
};
|
|
212
203
|
const step = (delta) => move((items, index) => {
|
|
213
204
|
if (index === -1)
|
|
@@ -232,42 +223,41 @@ export function Command({ label, shouldFilter = true, filter = defaultCommandFil
|
|
|
232
223
|
if (event.defaultPrevented || event.nativeEvent.isComposing)
|
|
233
224
|
return;
|
|
234
225
|
const target = event.target;
|
|
235
|
-
const fromInput = target.dataset.slot ===
|
|
236
|
-
if (!fromInput &&
|
|
237
|
-
target.closest("button, a[href], input, textarea, select, [contenteditable]"))
|
|
226
|
+
const fromInput = target.dataset.slot === 'command-input';
|
|
227
|
+
if (!fromInput && target.closest('button, a[href], input, textarea, select, [contenteditable]'))
|
|
238
228
|
return;
|
|
239
229
|
const vim = event.ctrlKey && !event.metaKey && !event.altKey;
|
|
240
230
|
switch (event.key) {
|
|
241
|
-
case
|
|
242
|
-
case
|
|
243
|
-
const delta = event.key ===
|
|
231
|
+
case 'ArrowDown':
|
|
232
|
+
case 'ArrowUp': {
|
|
233
|
+
const delta = event.key === 'ArrowDown' ? 1 : -1;
|
|
244
234
|
if (event.metaKey)
|
|
245
|
-
move(
|
|
235
|
+
move(items => (delta === 1 ? items.length - 1 : 0));
|
|
246
236
|
else if (event.altKey)
|
|
247
237
|
jumpGroup(delta);
|
|
248
238
|
else
|
|
249
239
|
step(delta);
|
|
250
240
|
break;
|
|
251
241
|
}
|
|
252
|
-
case
|
|
253
|
-
case
|
|
242
|
+
case 'n':
|
|
243
|
+
case 'j':
|
|
254
244
|
if (!vim)
|
|
255
245
|
return;
|
|
256
246
|
step(1);
|
|
257
247
|
break;
|
|
258
|
-
case
|
|
259
|
-
case
|
|
248
|
+
case 'p':
|
|
249
|
+
case 'k':
|
|
260
250
|
if (!vim)
|
|
261
251
|
return;
|
|
262
252
|
step(-1);
|
|
263
253
|
break;
|
|
264
|
-
case
|
|
254
|
+
case 'Home':
|
|
265
255
|
move(() => 0);
|
|
266
256
|
break;
|
|
267
|
-
case
|
|
268
|
-
move(
|
|
257
|
+
case 'End':
|
|
258
|
+
move(items => items.length - 1);
|
|
269
259
|
break;
|
|
270
|
-
case
|
|
260
|
+
case 'Enter': {
|
|
271
261
|
if (!store.active)
|
|
272
262
|
return;
|
|
273
263
|
const entry = store.items.get(store.active);
|
|
@@ -282,17 +272,17 @@ export function Command({ label, shouldFilter = true, filter = defaultCommandFil
|
|
|
282
272
|
}
|
|
283
273
|
event.preventDefault();
|
|
284
274
|
};
|
|
285
|
-
return (_jsx(CommandContext.Provider, { value: context, children: _jsxs("div", { "data-slot": "command", ...props, ref:
|
|
275
|
+
return (_jsx(CommandContext.Provider, { value: context, children: _jsxs("div", { "data-slot": "command", ...props, ref: node => {
|
|
286
276
|
root.current = node;
|
|
287
|
-
if (typeof ref ===
|
|
277
|
+
if (typeof ref === 'function')
|
|
288
278
|
return ref(node);
|
|
289
279
|
if (ref)
|
|
290
280
|
ref.current = node;
|
|
291
|
-
}, className: cn(
|
|
281
|
+
}, className: cn('sprout-command', className), onKeyDown: handleKeyDown, children: [label && (_jsx("label", { id: context.labelId, htmlFor: context.inputId, className: "sprout-command-sr-only", children: label })), children] }) }));
|
|
292
282
|
}
|
|
293
283
|
/** The search field with a leading magnifier. It drives filtering and keyboard navigation. */
|
|
294
284
|
export function CommandInput({ value, onValueChange, onChange, className, id, ...props }) {
|
|
295
|
-
const { store, listId, inputId, labelId, label } = useCommandContext(
|
|
285
|
+
const { store, listId, inputId, labelId, label } = useCommandContext('CommandInput');
|
|
296
286
|
const search = useStore(store, () => store.search);
|
|
297
287
|
const active = useStore(store, () => store.active);
|
|
298
288
|
const empty = useStore(store, () => store.ready && store.count === 0);
|
|
@@ -300,12 +290,12 @@ export function CommandInput({ value, onValueChange, onChange, className, id, ..
|
|
|
300
290
|
if (value !== undefined)
|
|
301
291
|
store.setSearch(value);
|
|
302
292
|
}, [store, value]);
|
|
303
|
-
return (_jsx("div", { "data-slot": "command-input-wrapper", className: "sprout-command-input-wrapper", children: _jsxs("div", { "data-slot": "command-input-group", className: "sprout-command-input-group", children: [_jsx(Search, { size: 16, "aria-hidden": "true", className: "sprout-command-input-icon" }), _jsx("input", { id: id ?? inputId, type: "text", role: "combobox", autoComplete: "off", autoCorrect: "off", spellCheck: false, "aria-autocomplete": "list", "aria-expanded": !empty, "aria-controls": listId, "aria-labelledby": label && !props[
|
|
293
|
+
return (_jsx("div", { "data-slot": "command-input-wrapper", className: "sprout-command-input-wrapper", children: _jsxs("div", { "data-slot": "command-input-group", className: "sprout-command-input-group", children: [_jsx(Search, { size: 16, "aria-hidden": "true", className: "sprout-command-input-icon" }), _jsx("input", { id: id ?? inputId, type: "text", role: "combobox", autoComplete: "off", autoCorrect: "off", spellCheck: false, "aria-autocomplete": "list", "aria-expanded": !empty, "aria-controls": listId, "aria-labelledby": label && !props['aria-label'] ? labelId : undefined, "aria-activedescendant": active ?? undefined, "data-slot": "command-input", ...props, value: value ?? search, onChange: event => {
|
|
304
294
|
onChange?.(event);
|
|
305
295
|
onValueChange?.(event.target.value);
|
|
306
296
|
if (value === undefined)
|
|
307
297
|
store.setSearch(event.target.value);
|
|
308
|
-
}, className: cn(
|
|
298
|
+
}, className: cn('sprout-command-input', className) })] }) }));
|
|
309
299
|
}
|
|
310
300
|
/**
|
|
311
301
|
* The scrolling listbox. It caps at 18rem and keeps the active item in view.
|
|
@@ -313,53 +303,51 @@ export function CommandInput({ value, onValueChange, onChange, className, id, ..
|
|
|
313
303
|
* ordinary content such as a Clear search button.
|
|
314
304
|
*/
|
|
315
305
|
export function CommandList({ className, children, ...props }) {
|
|
316
|
-
const { store, listId, label } = useCommandContext(
|
|
306
|
+
const { store, listId, label } = useCommandContext('CommandList');
|
|
317
307
|
const empty = useStore(store, () => store.ready && store.count === 0);
|
|
318
|
-
const {
|
|
319
|
-
|
|
320
|
-
: (label ?? "Suggestions"), "aria-labelledby": ariaLabelledBy, ...rest } = props;
|
|
321
|
-
return (_jsx("div", { id: listId, role: empty ? undefined : "listbox", tabIndex: empty ? undefined : -1, "aria-label": empty ? undefined : ariaLabel, "aria-labelledby": empty ? undefined : ariaLabelledBy, "data-slot": "command-list", "data-empty": empty || undefined, ...rest, className: cn("sprout-command-list", className), children: _jsx("div", { "data-slot": "command-list-sizer", className: "sprout-command-list-sizer", children: children }) }));
|
|
308
|
+
const { 'aria-label': ariaLabel = props['aria-labelledby'] ? undefined : (label ?? 'Suggestions'), 'aria-labelledby': ariaLabelledBy, ...rest } = props;
|
|
309
|
+
return (_jsx("div", { id: listId, role: empty ? undefined : 'listbox', tabIndex: empty ? undefined : -1, "aria-label": empty ? undefined : ariaLabel, "aria-labelledby": empty ? undefined : ariaLabelledBy, "data-slot": "command-list", "data-empty": empty || undefined, ...rest, className: cn('sprout-command-list', className), children: _jsx("div", { "data-slot": "command-list-sizer", className: "sprout-command-list-sizer", children: children }) }));
|
|
322
310
|
}
|
|
323
311
|
/** Shown only when no item matches the search. It can hold a recovery action. */
|
|
324
312
|
export function CommandEmpty({ className, ...props }) {
|
|
325
|
-
const { store } = useCommandContext(
|
|
313
|
+
const { store } = useCommandContext('CommandEmpty');
|
|
326
314
|
const empty = useStore(store, () => store.ready && store.count === 0);
|
|
327
315
|
if (!empty)
|
|
328
316
|
return null;
|
|
329
|
-
return (_jsx("div", { role: "presentation", "data-slot": "command-empty", ...props, className: cn(
|
|
317
|
+
return (_jsx("div", { role: "presentation", "data-slot": "command-empty", ...props, className: cn('sprout-command-empty', className) }));
|
|
330
318
|
}
|
|
331
319
|
/** Groups related items under an optional heading. It hides when none of its items match. */
|
|
332
320
|
export function CommandGroup({ heading, forceMount = false, className, children, style, ...props }) {
|
|
333
|
-
const { store } = useCommandContext(
|
|
321
|
+
const { store } = useCommandContext('CommandGroup');
|
|
334
322
|
const id = useId();
|
|
335
323
|
const headingId = `${id}-heading`;
|
|
336
324
|
const score = useStore(store, () => store.groupScores.get(id));
|
|
337
325
|
const filtering = useStore(store, () => store.filtering);
|
|
338
326
|
const hidden = filtering && score === undefined && !forceMount;
|
|
339
|
-
return (_jsxs("div", { role: "presentation", "data-slot": "command-group", hidden: hidden || undefined, ...props, style: { order: store.order(score), ...style }, className: cn(
|
|
327
|
+
return (_jsxs("div", { role: "presentation", "data-slot": "command-group", hidden: hidden || undefined, ...props, style: { order: store.order(score), ...style }, className: cn('sprout-command-group', className), children: [heading != null && heading !== false && (_jsx("div", { id: headingId, "aria-hidden": "true", "data-slot": "command-group-heading", className: "sprout-command-group-heading", children: heading })), _jsx("div", { role: "group", "aria-labelledby": heading != null && heading !== false ? headingId : undefined, "data-slot": "command-group-items", className: "sprout-command-group-items", children: _jsx(GroupContext.Provider, { value: id, children: children }) })] }));
|
|
340
328
|
}
|
|
341
329
|
export function CommandSeparator({ alwaysRender = false, className, ...props }) {
|
|
342
|
-
const { store } = useCommandContext(
|
|
343
|
-
const searching = useStore(store, () => store.search !==
|
|
330
|
+
const { store } = useCommandContext('CommandSeparator');
|
|
331
|
+
const searching = useStore(store, () => store.search !== '');
|
|
344
332
|
if (searching && !alwaysRender)
|
|
345
333
|
return null;
|
|
346
|
-
return (_jsx("div", { "aria-hidden": "true", "data-slot": "command-separator", ...props, className: cn(
|
|
334
|
+
return (_jsx("div", { "aria-hidden": "true", "data-slot": "command-separator", ...props, className: cn('sprout-command-separator', className) }));
|
|
347
335
|
}
|
|
348
336
|
function textOf(node) {
|
|
349
|
-
if (typeof node ===
|
|
337
|
+
if (typeof node === 'string' || typeof node === 'number')
|
|
350
338
|
return String(node);
|
|
351
339
|
if (Array.isArray(node))
|
|
352
|
-
return node.map(textOf).join(
|
|
340
|
+
return node.map(textOf).join('');
|
|
353
341
|
if (isValidElement(node))
|
|
354
342
|
return textOf(node.props.children);
|
|
355
|
-
return
|
|
343
|
+
return '';
|
|
356
344
|
}
|
|
357
345
|
/**
|
|
358
346
|
* One choice. Put an icon first, then the label. A trailing check marks the
|
|
359
347
|
* current choice with `data-checked`; a `CommandShortcut` replaces it.
|
|
360
348
|
*/
|
|
361
349
|
export function CommandItem({ value, keywords, disabled = false, onSelect, forceMount = false, className, children, style, onClick, onPointerMove, onPointerDown, ...props }) {
|
|
362
|
-
const { store } = useCommandContext(
|
|
350
|
+
const { store } = useCommandContext('CommandItem');
|
|
363
351
|
const group = useContext(GroupContext);
|
|
364
352
|
const id = useId();
|
|
365
353
|
const resolved = (value ?? textOf(children)).trim();
|
|
@@ -368,11 +356,11 @@ export function CommandItem({ value, keywords, disabled = false, onSelect, force
|
|
|
368
356
|
if (!disabled)
|
|
369
357
|
onSelect?.(resolved);
|
|
370
358
|
};
|
|
371
|
-
const keywordKey = (keywords ?? []).join(
|
|
359
|
+
const keywordKey = (keywords ?? []).join('\u0000');
|
|
372
360
|
useLayoutEffect(() => {
|
|
373
361
|
store.items.set(id, {
|
|
374
362
|
value: resolved,
|
|
375
|
-
keywords: keywordKey ? keywordKey.split(
|
|
363
|
+
keywords: keywordKey ? keywordKey.split('\u0000') : [],
|
|
376
364
|
group,
|
|
377
365
|
select: () => select.current(),
|
|
378
366
|
});
|
|
@@ -389,16 +377,16 @@ export function CommandItem({ value, keywords, disabled = false, onSelect, force
|
|
|
389
377
|
const score = useStore(store, () => store.scores.get(id));
|
|
390
378
|
if (!visible)
|
|
391
379
|
return null;
|
|
392
|
-
return (_jsxs("div", { id: id, role: "option", "aria-selected": active, "aria-disabled": disabled || undefined, "data-selected": active || undefined, "data-disabled": disabled || undefined, "data-value": resolved, "data-slot": "command-item", ...props, style: { order: store.order(score), ...style }, className: cn(
|
|
380
|
+
return (_jsxs("div", { id: id, role: "option", "aria-selected": active, "aria-disabled": disabled || undefined, "data-selected": active || undefined, "data-disabled": disabled || undefined, "data-value": resolved, "data-slot": "command-item", ...props, style: { order: store.order(score), ...style }, className: cn('sprout-command-item', className), onPointerDown: event => {
|
|
393
381
|
onPointerDown?.(event);
|
|
394
382
|
// Keep focus in the search input so typing and arrows keep working.
|
|
395
383
|
if (!event.defaultPrevented)
|
|
396
384
|
event.preventDefault();
|
|
397
|
-
}, onPointerMove:
|
|
385
|
+
}, onPointerMove: event => {
|
|
398
386
|
onPointerMove?.(event);
|
|
399
387
|
if (!disabled && !event.defaultPrevented)
|
|
400
388
|
store.setActive(id);
|
|
401
|
-
}, onClick:
|
|
389
|
+
}, onClick: event => {
|
|
402
390
|
onClick?.(event);
|
|
403
391
|
if (!event.defaultPrevented)
|
|
404
392
|
select.current();
|
|
@@ -406,9 +394,9 @@ export function CommandItem({ value, keywords, disabled = false, onSelect, force
|
|
|
406
394
|
}
|
|
407
395
|
/** A keyboard hint at the end of an item. */
|
|
408
396
|
export function CommandShortcut({ className, ...props }) {
|
|
409
|
-
return
|
|
397
|
+
return _jsx("span", { "data-slot": "command-shortcut", ...props, className: cn('sprout-command-shortcut', className) });
|
|
410
398
|
}
|
|
411
399
|
/** A command palette pinned near the top of the viewport. */
|
|
412
|
-
export function CommandDialog({ title =
|
|
413
|
-
return (_jsx(Dialog, { ...props, children: _jsxs(DialogContent, { placement: "top", showCloseButton: showCloseButton, closeLabel: closeLabel, container: container, className: cn(
|
|
400
|
+
export function CommandDialog({ title = 'Command Palette', description = 'Search for a command to run...', className, showCloseButton = false, closeLabel, container, children, ...props }) {
|
|
401
|
+
return (_jsx(Dialog, { ...props, children: _jsxs(DialogContent, { placement: "top", showCloseButton: showCloseButton, closeLabel: closeLabel, container: container, className: cn('sprout-command-dialog', className), children: [_jsx(DialogTitle, { className: "sprout-command-sr-only", children: title }), _jsx(DialogDescription, { className: "sprout-command-sr-only", children: description }), children] }) }));
|
|
414
402
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ComponentProps } from
|
|
2
|
-
import { ContextMenu as ContextMenuPrimitive } from
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { ContextMenu as ContextMenuPrimitive } from '@base-ui/react/context-menu';
|
|
3
3
|
export declare const contextMenuItemVariantNames: readonly ["default", "destructive"];
|
|
4
4
|
export type ContextMenuItemVariant = (typeof contextMenuItemVariantNames)[number];
|
|
5
5
|
export type ContextMenuProps = ContextMenuPrimitive.Root.Props;
|
|
@@ -10,10 +10,10 @@ export declare function ContextMenuPortal(props: ContextMenuPortalProps): import
|
|
|
10
10
|
export type ContextMenuTriggerProps = ContextMenuPrimitive.Trigger.Props;
|
|
11
11
|
/** The area that opens the menu. It renders a `div`; pass `render` to use another element. */
|
|
12
12
|
export declare function ContextMenuTrigger({ className, ...props }: ContextMenuTriggerProps): import("react").JSX.Element;
|
|
13
|
-
type PositionerProps = Pick<ContextMenuPrimitive.Positioner.Props,
|
|
13
|
+
type PositionerProps = Pick<ContextMenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset' | 'collisionPadding' | 'collisionAvoidance' | 'sticky' | 'positionMethod'>;
|
|
14
14
|
export interface ContextMenuContentProps extends ContextMenuPrimitive.Popup.Props, PositionerProps {
|
|
15
15
|
/** Where the portal renders. Defaults to `document.body`. */
|
|
16
|
-
container?: ContextMenuPrimitive.Portal.Props[
|
|
16
|
+
container?: ContextMenuPrimitive.Portal.Props['container'];
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* The menu surface. It renders its own portal and positioner and opens beside
|
|
@@ -51,7 +51,7 @@ export interface ContextMenuRadioItemProps extends ContextMenuPrimitive.RadioIte
|
|
|
51
51
|
export declare function ContextMenuRadioItem({ className, inset, children, ...props }: ContextMenuRadioItemProps): import("react").JSX.Element;
|
|
52
52
|
export type ContextMenuSeparatorProps = ContextMenuPrimitive.Separator.Props;
|
|
53
53
|
export declare function ContextMenuSeparator({ className, ...props }: ContextMenuSeparatorProps): import("react").JSX.Element;
|
|
54
|
-
export type ContextMenuShortcutProps = ComponentProps<
|
|
54
|
+
export type ContextMenuShortcutProps = ComponentProps<'span'>;
|
|
55
55
|
/** Right-aligned hint text, such as a keyboard shortcut. It does not bind keys. */
|
|
56
56
|
export declare function ContextMenuShortcut({ className, ...props }: ContextMenuShortcutProps): import("react").JSX.Element;
|
|
57
57
|
export {};
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
|
|
1
|
+
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { ContextMenu as ContextMenuPrimitive } from
|
|
4
|
-
import { Check } from
|
|
5
|
-
import { ChevronRight } from
|
|
6
|
-
import { cn, stateClassName } from
|
|
7
|
-
export const contextMenuItemVariantNames = [
|
|
3
|
+
import { ContextMenu as ContextMenuPrimitive } from '@base-ui/react/context-menu';
|
|
4
|
+
import { Check } from 'reicon-react/icons/Check';
|
|
5
|
+
import { ChevronRight } from 'reicon-react/icons/ChevronRight';
|
|
6
|
+
import { cn, stateClassName } from '../internal/classes.js';
|
|
7
|
+
export const contextMenuItemVariantNames = ['default', 'destructive'];
|
|
8
8
|
/** Opens a menu at the pointer on right-click, or after a long press on touch screens. */
|
|
9
9
|
export function ContextMenu(props) {
|
|
10
10
|
return _jsx(ContextMenuPrimitive.Root, { ...props });
|
|
11
11
|
}
|
|
12
12
|
export function ContextMenuPortal(props) {
|
|
13
|
-
return
|
|
13
|
+
return _jsx(ContextMenuPrimitive.Portal, { "data-slot": "context-menu-portal", ...props });
|
|
14
14
|
}
|
|
15
15
|
/** The area that opens the menu. It renders a `div`; pass `render` to use another element. */
|
|
16
16
|
export function ContextMenuTrigger({ className, ...props }) {
|
|
17
|
-
return (_jsx(ContextMenuPrimitive.Trigger, { "data-slot": "context-menu-trigger", ...props, className: stateClassName(
|
|
17
|
+
return (_jsx(ContextMenuPrimitive.Trigger, { "data-slot": "context-menu-trigger", ...props, className: stateClassName('sprout-context-menu-trigger', className) }));
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* The menu surface. It renders its own portal and positioner and opens beside
|
|
21
21
|
* the pointer, so place it directly inside `ContextMenu` or `ContextMenuSub`.
|
|
22
22
|
*/
|
|
23
|
-
export function ContextMenuContent({ align =
|
|
24
|
-
return (_jsx(ContextMenuPrimitive.Portal, { container: container, children: _jsx(ContextMenuPrimitive.Positioner, { className: "sprout-context-menu-positioner", align: align, alignOffset: alignOffset, side: side, sideOffset: sideOffset, collisionPadding: collisionPadding, collisionAvoidance: collisionAvoidance, sticky: sticky, positionMethod: positionMethod, children: _jsx(ContextMenuPrimitive.Popup, { "data-slot": "context-menu-content", ...props, className: stateClassName(
|
|
23
|
+
export function ContextMenuContent({ align = 'start', alignOffset = 4, side = 'right', sideOffset = 0, collisionPadding = 8, collisionAvoidance, sticky, positionMethod, container, className, ...props }) {
|
|
24
|
+
return (_jsx(ContextMenuPrimitive.Portal, { container: container, children: _jsx(ContextMenuPrimitive.Positioner, { className: "sprout-context-menu-positioner", align: align, alignOffset: alignOffset, side: side, sideOffset: sideOffset, collisionPadding: collisionPadding, collisionAvoidance: collisionAvoidance, sticky: sticky, positionMethod: positionMethod, children: _jsx(ContextMenuPrimitive.Popup, { "data-slot": "context-menu-content", ...props, className: stateClassName('sprout-context-menu-content', className) }) }) }));
|
|
25
25
|
}
|
|
26
26
|
export function ContextMenuGroup(props) {
|
|
27
|
-
return
|
|
27
|
+
return _jsx(ContextMenuPrimitive.Group, { "data-slot": "context-menu-group", ...props });
|
|
28
28
|
}
|
|
29
29
|
export function ContextMenuLabel({ className, inset, ...props }) {
|
|
30
|
-
return (_jsx(ContextMenuPrimitive.GroupLabel, { "data-slot": "context-menu-label", "data-inset": inset || undefined, ...props, className: stateClassName(
|
|
30
|
+
return (_jsx(ContextMenuPrimitive.GroupLabel, { "data-slot": "context-menu-label", "data-inset": inset || undefined, ...props, className: stateClassName('sprout-context-menu-label', className) }));
|
|
31
31
|
}
|
|
32
|
-
export function ContextMenuItem({ className, inset, variant =
|
|
33
|
-
return (_jsx(ContextMenuPrimitive.Item, { "data-slot": "context-menu-item", "data-inset": inset || undefined, "data-variant": variant, ...props, className: stateClassName(
|
|
32
|
+
export function ContextMenuItem({ className, inset, variant = 'default', ...props }) {
|
|
33
|
+
return (_jsx(ContextMenuPrimitive.Item, { "data-slot": "context-menu-item", "data-inset": inset || undefined, "data-variant": variant, ...props, className: stateClassName('sprout-context-menu-item', className) }));
|
|
34
34
|
}
|
|
35
35
|
export function ContextMenuSub(props) {
|
|
36
36
|
return _jsx(ContextMenuPrimitive.SubmenuRoot, { ...props });
|
|
37
37
|
}
|
|
38
38
|
export function ContextMenuSubTrigger({ className, inset, children, ...props }) {
|
|
39
|
-
return (_jsxs(ContextMenuPrimitive.SubmenuTrigger, { "data-slot": "context-menu-sub-trigger", "data-inset": inset || undefined, ...props, className: stateClassName(
|
|
39
|
+
return (_jsxs(ContextMenuPrimitive.SubmenuTrigger, { "data-slot": "context-menu-sub-trigger", "data-inset": inset || undefined, ...props, className: stateClassName('sprout-context-menu-item sprout-context-menu-sub-trigger', className), children: [children, _jsx(ChevronRight, { size: 16, "aria-hidden": "true", className: "sprout-context-menu-sub-chevron" })] }));
|
|
40
40
|
}
|
|
41
41
|
/** A nested menu surface. It opens to the side of its sub trigger. */
|
|
42
|
-
export function ContextMenuSubContent({ alignOffset = -5, side =
|
|
43
|
-
return (_jsx(ContextMenuContent, { "data-slot": "context-menu-sub-content", alignOffset: alignOffset, side: side, ...props, className: stateClassName(
|
|
42
|
+
export function ContextMenuSubContent({ alignOffset = -5, side = 'right', className, ...props }) {
|
|
43
|
+
return (_jsx(ContextMenuContent, { "data-slot": "context-menu-sub-content", alignOffset: alignOffset, side: side, ...props, className: stateClassName('sprout-context-menu-sub-content', className) }));
|
|
44
44
|
}
|
|
45
45
|
export function ContextMenuCheckboxItem({ className, inset, children, ...props }) {
|
|
46
|
-
return (_jsxs(ContextMenuPrimitive.CheckboxItem, { "data-slot": "context-menu-checkbox-item", "data-inset": inset || undefined, ...props, className: stateClassName(
|
|
46
|
+
return (_jsxs(ContextMenuPrimitive.CheckboxItem, { "data-slot": "context-menu-checkbox-item", "data-inset": inset || undefined, ...props, className: stateClassName('sprout-context-menu-item sprout-context-menu-choice', className), children: [_jsx("span", { className: "sprout-context-menu-indicator", "data-slot": "context-menu-checkbox-item-indicator", children: _jsx(ContextMenuPrimitive.CheckboxItemIndicator, { children: _jsx(Check, { size: 16, "aria-hidden": "true" }) }) }), children] }));
|
|
47
47
|
}
|
|
48
48
|
export function ContextMenuRadioGroup(props) {
|
|
49
|
-
return
|
|
49
|
+
return _jsx(ContextMenuPrimitive.RadioGroup, { "data-slot": "context-menu-radio-group", ...props });
|
|
50
50
|
}
|
|
51
51
|
export function ContextMenuRadioItem({ className, inset, children, ...props }) {
|
|
52
|
-
return (_jsxs(ContextMenuPrimitive.RadioItem, { "data-slot": "context-menu-radio-item", "data-inset": inset || undefined, ...props, className: stateClassName(
|
|
52
|
+
return (_jsxs(ContextMenuPrimitive.RadioItem, { "data-slot": "context-menu-radio-item", "data-inset": inset || undefined, ...props, className: stateClassName('sprout-context-menu-item sprout-context-menu-choice', className), children: [_jsx("span", { className: "sprout-context-menu-indicator", "data-slot": "context-menu-radio-item-indicator", children: _jsx(ContextMenuPrimitive.RadioItemIndicator, { children: _jsx(Check, { size: 16, "aria-hidden": "true" }) }) }), children] }));
|
|
53
53
|
}
|
|
54
54
|
export function ContextMenuSeparator({ className, ...props }) {
|
|
55
|
-
return (_jsx(ContextMenuPrimitive.Separator, { "data-slot": "context-menu-separator", ...props, className: stateClassName(
|
|
55
|
+
return (_jsx(ContextMenuPrimitive.Separator, { "data-slot": "context-menu-separator", ...props, className: stateClassName('sprout-context-menu-separator', className) }));
|
|
56
56
|
}
|
|
57
57
|
/** Right-aligned hint text, such as a keyboard shortcut. It does not bind keys. */
|
|
58
58
|
export function ContextMenuShortcut({ className, ...props }) {
|
|
59
|
-
return (_jsx("span", { "data-slot": "context-menu-shortcut", ...props, className: cn(
|
|
59
|
+
return (_jsx("span", { "data-slot": "context-menu-shortcut", ...props, className: cn('sprout-context-menu-shortcut', className) }));
|
|
60
60
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Dialog as DialogPrimitive } from
|
|
2
|
-
import { useRender } from
|
|
1
|
+
import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
|
|
2
|
+
import { useRender } from '@base-ui/react/use-render';
|
|
3
3
|
export declare const dialogSizeNames: readonly ["default", "form", "split", "fullscreen"];
|
|
4
4
|
export declare const dialogPlacementNames: readonly ["center", "top"];
|
|
5
5
|
export type DialogSize = (typeof dialogSizeNames)[number];
|
|
@@ -23,18 +23,18 @@ export interface DialogContentProps extends DialogPrimitive.Popup.Props {
|
|
|
23
23
|
/** `top` pins the dialog near the top of the viewport for search and command palettes. */
|
|
24
24
|
placement?: DialogPlacement;
|
|
25
25
|
/** Where the portal renders. Defaults to `document.body`. */
|
|
26
|
-
container?: DialogPrimitive.Portal.Props[
|
|
26
|
+
container?: DialogPrimitive.Portal.Props['container'];
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
29
|
* The dialog surface. It renders its own portal and overlay, so place it
|
|
30
30
|
* directly inside `Dialog`.
|
|
31
31
|
*/
|
|
32
32
|
export declare function DialogContent({ className, children, showCloseButton, closeLabel, size, placement, container, ...props }: DialogContentProps): import("react").JSX.Element;
|
|
33
|
-
type PartSlot =
|
|
33
|
+
type PartSlot = 'dialog-header' | 'dialog-body';
|
|
34
34
|
export interface DialogPartState extends Record<string, unknown> {
|
|
35
|
-
slot: PartSlot |
|
|
35
|
+
slot: PartSlot | 'dialog-footer';
|
|
36
36
|
}
|
|
37
|
-
export type DialogPartProps = useRender.ComponentProps<
|
|
37
|
+
export type DialogPartProps = useRender.ComponentProps<'div', DialogPartState>;
|
|
38
38
|
/** Stacks the title and description. */
|
|
39
39
|
export declare const DialogHeader: ({ className, render, ref, ...props }: DialogPartProps) => import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
40
40
|
/**
|