@nocoo/basalt 2.0.2 → 2.1.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 +134 -15
- package/ai/COMPATIBILITY.md +180 -0
- package/ai/INTEGRATION.md +1760 -0
- package/ai/RECIPES.md +161 -0
- package/ai/USAGE.md +99 -0
- package/ai/registry.json +38099 -0
- package/ai/sources.json +10 -0
- package/dist/assets/brand-mark.d.ts +1 -0
- package/dist/assets/brand-mark.js +7 -0
- package/dist/assets/brand-mark.js.map +1 -0
- package/dist/charts/area.d.ts +58 -5
- package/dist/charts/area.js +20 -12
- package/dist/charts/area.js.map +1 -1
- package/dist/charts/bar.d.ts +54 -5
- package/dist/charts/bar.js +16 -10
- package/dist/charts/bar.js.map +1 -1
- package/dist/charts/bullet.d.ts +18 -1
- package/dist/charts/bullet.js +6 -3
- package/dist/charts/bullet.js.map +1 -1
- package/dist/charts/charts.d.ts +58 -5
- package/dist/charts/charts.js +13 -2
- package/dist/charts/charts.js.map +1 -1
- package/dist/charts/config.d.ts +7 -0
- package/dist/charts/config.js +5 -1
- package/dist/charts/config.js.map +1 -1
- package/dist/charts/custom-chart.d.ts +58 -5
- package/dist/charts/custom-chart.js +13 -2
- package/dist/charts/custom-chart.js.map +1 -1
- package/dist/charts/donut.d.ts +18 -1
- package/dist/charts/donut.js +6 -3
- package/dist/charts/donut.js.map +1 -1
- package/dist/charts/frame.d.ts +40 -3
- package/dist/charts/frame.js +55 -28
- package/dist/charts/frame.js.map +1 -1
- package/dist/charts/funnel.d.ts +18 -1
- package/dist/charts/funnel.js +5 -1
- package/dist/charts/funnel.js.map +1 -1
- package/dist/charts/gauge.d.ts +18 -1
- package/dist/charts/gauge.js +38 -20
- package/dist/charts/gauge.js.map +1 -1
- package/dist/charts/grouped-bar.d.ts +54 -5
- package/dist/charts/grouped-bar.js +16 -10
- package/dist/charts/grouped-bar.js.map +1 -1
- package/dist/charts/heatmap-calendar.d.ts +61 -0
- package/dist/charts/heatmap-calendar.js +287 -96
- package/dist/charts/heatmap-calendar.js.map +1 -1
- package/dist/charts/heatmap-matrix.d.ts +99 -0
- package/dist/charts/heatmap-matrix.js +249 -0
- package/dist/charts/heatmap-matrix.js.map +1 -0
- package/dist/charts/line.d.ts +66 -5
- package/dist/charts/line.js +37 -30
- package/dist/charts/line.js.map +1 -1
- package/dist/charts/palette.d.ts +1 -0
- package/dist/charts/palette.js +7 -1
- package/dist/charts/palette.js.map +1 -1
- package/dist/charts/radar.d.ts +18 -1
- package/dist/charts/radar.js +26 -19
- package/dist/charts/radar.js.map +1 -1
- package/dist/charts/sankey.d.ts +18 -1
- package/dist/charts/sankey.js +4 -1
- package/dist/charts/sankey.js.map +1 -1
- package/dist/charts/series.d.ts +5 -7
- package/dist/charts/series.js.map +1 -1
- package/dist/charts/slot-bar.d.ts +38 -6
- package/dist/charts/slot-bar.js +5 -2
- package/dist/charts/slot-bar.js.map +1 -1
- package/dist/charts/sparkline.d.ts +35 -5
- package/dist/charts/sparkline.js +22 -18
- package/dist/charts/sparkline.js.map +1 -1
- package/dist/charts/stacked-bar.d.ts +58 -5
- package/dist/charts/stacked-bar.js +19 -12
- package/dist/charts/stacked-bar.js.map +1 -1
- package/dist/charts/stat-card.d.ts +51 -1
- package/dist/charts/stat-card.js +66 -39
- package/dist/charts/stat-card.js.map +1 -1
- package/dist/charts/timeline.d.ts +3 -0
- package/dist/charts/timeline.js +4 -3
- package/dist/charts/timeline.js.map +1 -1
- package/dist/charts/timeseries.d.ts +58 -5
- package/dist/charts/timeseries.js +13 -2
- package/dist/charts/timeseries.js.map +1 -1
- package/dist/charts/tooltip.d.ts +57 -0
- package/dist/charts/tooltip.js +119 -2
- package/dist/charts/tooltip.js.map +1 -1
- package/dist/components/accordion.d.ts +117 -2
- package/dist/components/accordion.js +20 -13
- package/dist/components/accordion.js.map +1 -1
- package/dist/components/alert-dialog.d.ts +131 -13
- package/dist/components/alert-dialog.js +13 -10
- package/dist/components/alert-dialog.js.map +1 -1
- package/dist/components/app-header.js +18 -17
- package/dist/components/app-header.js.map +1 -1
- package/dist/components/app-shell.js +15 -14
- package/dist/components/app-shell.js.map +1 -1
- package/dist/components/autocomplete.d.ts +4 -0
- package/dist/components/autocomplete.js.map +1 -1
- package/dist/components/avatar.d.ts +76 -3
- package/dist/components/avatar.js.map +1 -1
- package/dist/components/badge.d.ts +15 -1
- package/dist/components/badge.js +17 -16
- package/dist/components/badge.js.map +1 -1
- package/dist/components/banner.d.ts +88 -2
- package/dist/components/banner.js +41 -40
- package/dist/components/banner.js.map +1 -1
- package/dist/components/basalt-mark.js +14 -8
- package/dist/components/basalt-mark.js.map +1 -1
- package/dist/components/battery-meter.d.ts +10 -0
- package/dist/components/battery-meter.js +56 -0
- package/dist/components/battery-meter.js.map +1 -0
- package/dist/components/breadcrumbs.d.ts +27 -7
- package/dist/components/breadcrumbs.js +21 -20
- package/dist/components/breadcrumbs.js.map +1 -1
- package/dist/components/button.d.ts +48 -2
- package/dist/components/button.js +87 -36
- package/dist/components/button.js.map +1 -1
- package/dist/components/chat-bubble.d.ts +24 -0
- package/dist/components/chat-bubble.js +26 -0
- package/dist/components/chat-bubble.js.map +1 -0
- package/dist/components/chat-composer.d.ts +45 -0
- package/dist/components/chat-composer.js +74 -0
- package/dist/components/chat-composer.js.map +1 -0
- package/dist/components/chat-header.d.ts +25 -0
- package/dist/components/chat-header.js +34 -0
- package/dist/components/chat-header.js.map +1 -0
- package/dist/components/chat-inbox.d.ts +33 -0
- package/dist/components/chat-inbox.js +44 -0
- package/dist/components/chat-inbox.js.map +1 -0
- package/dist/components/checkbox.js +84 -53
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/clipboard-text.d.ts +13 -2
- package/dist/components/clipboard-text.js +4 -4
- package/dist/components/clipboard-text.js.map +1 -1
- package/dist/components/collapsible.d.ts +58 -15
- package/dist/components/collapsible.js.map +1 -1
- package/dist/components/command-palette.d.ts +151 -61
- package/dist/components/command-palette.js.map +1 -1
- package/dist/components/confirm-dialog.d.ts +1 -1
- package/dist/components/confirm-dialog.js +6 -4
- package/dist/components/confirm-dialog.js.map +1 -1
- package/dist/components/context-menu.d.ts +210 -2
- package/dist/components/context-menu.js +7 -4
- package/dist/components/context-menu.js.map +1 -1
- package/dist/components/data-table.d.ts +40 -2
- package/dist/components/data-table.js +168 -120
- package/dist/components/data-table.js.map +1 -1
- package/dist/components/date-picker.d.ts +53 -2
- package/dist/components/date-picker.js +387 -219
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/delete-resource.d.ts +7 -1
- package/dist/components/delete-resource.js +22 -18
- package/dist/components/delete-resource.js.map +1 -1
- package/dist/components/description-list.js +16 -15
- package/dist/components/description-list.js.map +1 -1
- package/dist/components/dialog.d.ts +141 -12
- package/dist/components/dialog.js +43 -39
- package/dist/components/dialog.js.map +1 -1
- package/dist/components/dock.d.ts +39 -0
- package/dist/components/dock.js +97 -0
- package/dist/components/dock.js.map +1 -0
- package/dist/components/dropdown-menu.d.ts +229 -15
- package/dist/components/dropdown-menu.js +9 -6
- package/dist/components/dropdown-menu.js.map +1 -1
- package/dist/components/editable-nav-item.d.ts +33 -0
- package/dist/components/editable-nav-item.js +90 -0
- package/dist/components/editable-nav-item.js.map +1 -0
- package/dist/components/empty.d.ts +22 -2
- package/dist/components/empty.js +22 -13
- package/dist/components/empty.js.map +1 -1
- package/dist/components/fab.d.ts +23 -0
- package/dist/components/fab.js +25 -0
- package/dist/components/fab.js.map +1 -0
- package/dist/components/field.js +31 -30
- package/dist/components/field.js.map +1 -1
- package/dist/components/file-dropzone.d.ts +37 -0
- package/dist/components/file-dropzone.js +103 -0
- package/dist/components/file-dropzone.js.map +1 -0
- package/dist/components/filter-bar.d.ts +34 -0
- package/dist/components/filter-bar.js +52 -0
- package/dist/components/filter-bar.js.map +1 -0
- package/dist/components/flow.js +19 -18
- package/dist/components/flow.js.map +1 -1
- package/dist/components/grid.d.ts +3 -1
- package/dist/components/grid.js.map +1 -1
- package/dist/components/hover-card.d.ts +111 -1
- package/dist/components/hover-card.js +9 -6
- package/dist/components/hover-card.js.map +1 -1
- package/dist/components/icon-picker.d.ts +34 -0
- package/dist/components/icon-picker.js +77 -0
- package/dist/components/icon-picker.js.map +1 -0
- package/dist/components/inline-editable.d.ts +46 -0
- package/dist/components/inline-editable.js +124 -0
- package/dist/components/inline-editable.js.map +1 -0
- package/dist/components/input-area.js +3 -3
- package/dist/components/input-group.js +7 -7
- package/dist/components/input.js +3 -3
- package/dist/components/label.js +18 -17
- package/dist/components/label.js.map +1 -1
- package/dist/components/layer-card.d.ts +10 -2
- package/dist/components/layer-card.js +71 -68
- package/dist/components/layer-card.js.map +1 -1
- package/dist/components/loader.d.ts +10 -2
- package/dist/components/loader.js.map +1 -1
- package/dist/components/menu-bar.d.ts +174 -6
- package/dist/components/menu-bar.js +33 -29
- package/dist/components/menu-bar.js.map +1 -1
- package/dist/components/meter.d.ts +27 -2
- package/dist/components/meter.js.map +1 -1
- package/dist/components/multi-select.d.ts +64 -0
- package/dist/components/multi-select.js +218 -0
- package/dist/components/multi-select.js.map +1 -0
- package/dist/components/navigation-menu.d.ts +88 -5
- package/dist/components/navigation-menu.js.map +1 -1
- package/dist/components/overlay.js +6 -5
- package/dist/components/overlay.js.map +1 -1
- package/dist/components/page-header.js +23 -21
- package/dist/components/page-header.js.map +1 -1
- package/dist/components/pagination.js +7 -7
- package/dist/components/popover.d.ts +136 -16
- package/dist/components/popover.js +32 -28
- package/dist/components/popover.js.map +1 -1
- package/dist/components/radio.js +38 -37
- package/dist/components/radio.js.map +1 -1
- package/dist/components/resource-list.d.ts +26 -1
- package/dist/components/resource-list.js +28 -15
- package/dist/components/resource-list.js.map +1 -1
- package/dist/components/responsive-master-detail.d.ts +27 -0
- package/dist/components/responsive-master-detail.js +85 -0
- package/dist/components/responsive-master-detail.js.map +1 -0
- package/dist/components/section-rule.js +23 -22
- package/dist/components/section-rule.js.map +1 -1
- package/dist/components/select.d.ts +27 -3
- package/dist/components/select.js +11 -11
- package/dist/components/select.js.map +1 -1
- package/dist/components/sheet.d.ts +115 -11
- package/dist/components/sheet.js +37 -30
- package/dist/components/sheet.js.map +1 -1
- package/dist/components/sidebar.d.ts +109 -17
- package/dist/components/sidebar.js +109 -108
- package/dist/components/sidebar.js.map +1 -1
- package/dist/components/skeleton-line.d.ts +22 -2
- package/dist/components/skeleton-line.js.map +1 -1
- package/dist/components/slider.d.ts +61 -1
- package/dist/components/slider.js +31 -15
- package/dist/components/slider.js.map +1 -1
- package/dist/components/stat-strip.js +16 -15
- package/dist/components/stat-strip.js.map +1 -1
- package/dist/components/switch.js +78 -47
- package/dist/components/switch.js.map +1 -1
- package/dist/components/table-of-contents.js +18 -17
- package/dist/components/table-of-contents.js.map +1 -1
- package/dist/components/table-pager.js +20 -19
- package/dist/components/table-pager.js.map +1 -1
- package/dist/components/table.d.ts +9 -3
- package/dist/components/table.js +19 -18
- package/dist/components/table.js.map +1 -1
- package/dist/components/tabs.js +29 -22
- package/dist/components/tabs.js.map +1 -1
- package/dist/components/tag-badge.d.ts +58 -0
- package/dist/components/tag-badge.js +72 -0
- package/dist/components/tag-badge.js.map +1 -0
- package/dist/components/tag-color-picker.d.ts +20 -0
- package/dist/components/tag-color-picker.js +42 -0
- package/dist/components/tag-color-picker.js.map +1 -0
- package/dist/components/text.js +17 -16
- package/dist/components/text.js.map +1 -1
- package/dist/components/toast.d.ts +173 -3
- package/dist/components/toast.js +1 -1
- package/dist/components/toast.js.map +1 -1
- package/dist/components/toggle-group.d.ts +88 -2
- package/dist/components/toggle-group.js +32 -31
- package/dist/components/toggle-group.js.map +1 -1
- package/dist/components/toggle.d.ts +35 -2
- package/dist/components/toggle.js +12 -11
- package/dist/components/toggle.js.map +1 -1
- package/dist/components/tooltip.d.ts +144 -6
- package/dist/components/tooltip.js +9 -6
- package/dist/components/tooltip.js.map +1 -1
- package/dist/components/typeahead-field.js +193 -132
- package/dist/components/typeahead-field.js.map +1 -1
- package/dist/components/upload-queue.d.ts +51 -0
- package/dist/components/upload-queue.js +116 -0
- package/dist/components/upload-queue.js.map +1 -0
- package/dist/providers/accent.d.ts +46 -2
- package/dist/providers/accent.js +358 -172
- package/dist/providers/accent.js.map +1 -1
- package/dist/providers/link.d.ts +14 -4
- package/dist/providers/link.js.map +1 -1
- package/dist/providers/theme.d.ts +38 -2
- package/dist/providers/theme.js +160 -27
- package/dist/providers/theme.js.map +1 -1
- package/dist/styles/base.css +83 -0
- package/dist/styles/standalone.css +820 -120
- package/dist/styles/tailwind.css +21 -7
- package/dist/styles/tokens.css +146 -91
- package/dist/utils/control-surface.d.ts +2 -1
- package/dist/utils/control-surface.js +4 -4
- package/dist/utils/control-surface.js.map +1 -1
- package/dist/utils/selection-indicator.js +2 -2
- package/dist/utils/selection-indicator.js.map +1 -1
- package/package.json +8 -4
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
import type * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
1
2
|
import type { DialogProps } from "@radix-ui/react-dialog";
|
|
3
|
+
import { Command as CommandPrimitive } from "cmdk";
|
|
2
4
|
import * as React from "react";
|
|
3
|
-
export
|
|
5
|
+
export interface CommandPaletteProps extends Omit<DialogProps, "open" | "defaultOpen" | "onOpenChange" | "children" | "modal"> {
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
7
|
+
* Command palette structure elements, including CommandPaletteTrigger and inner command items.
|
|
8
|
+
* Note: Triggers must be direct children of CommandPalette (child.type === CommandPaletteTrigger)
|
|
9
|
+
* to be separated from modal dialog content. Wrapping triggers in Fragments or HOCs will cause
|
|
10
|
+
* them to be treated as modal content.
|
|
11
|
+
*/
|
|
12
|
+
children?: React.ReactNode;
|
|
13
|
+
/**
|
|
14
|
+
* The controlled open state of the command palette dialog.
|
|
6
15
|
*/
|
|
7
16
|
open?: boolean;
|
|
8
17
|
/**
|
|
9
|
-
* The uncontrolled initial open state.
|
|
18
|
+
* The uncontrolled initial open state of the command palette dialog.
|
|
10
19
|
* @default false
|
|
11
20
|
*/
|
|
12
21
|
defaultOpen?: boolean;
|
|
@@ -19,65 +28,146 @@ export type CommandPaletteProps = Omit<DialogProps, "open" | "defaultOpen" | "on
|
|
|
19
28
|
* @default true
|
|
20
29
|
*/
|
|
21
30
|
shouldFilter?: boolean;
|
|
22
|
-
|
|
23
|
-
|
|
31
|
+
/**
|
|
32
|
+
* The modality of the dialog. When set to true, interaction with outside elements
|
|
33
|
+
* will be disabled and only dialog content will be visible to screen readers.
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
modal?: boolean;
|
|
37
|
+
}
|
|
38
|
+
type RadixDialogTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;
|
|
39
|
+
export interface CommandPaletteTriggerProps extends Omit<RadixDialogTriggerProps, "asChild"> {
|
|
40
|
+
/**
|
|
41
|
+
* Change the default rendered button element to the child element, merging props and behavior.
|
|
42
|
+
* CommandPaletteTrigger is an alias for DialogTrigger; forwards ref to HTMLButtonElement and inherits native button attributes.
|
|
43
|
+
* @default false
|
|
44
|
+
*/
|
|
45
|
+
asChild?: RadixDialogTriggerProps["asChild"];
|
|
46
|
+
}
|
|
47
|
+
export declare const CommandPaletteTrigger: React.ForwardRefExoticComponent<DialogPrimitive.DialogTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
24
48
|
export declare function CommandPalette({ children, shouldFilter, ...props }: CommandPaletteProps): React.JSX.Element;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
49
|
+
type RadixCommandInputProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>;
|
|
50
|
+
export interface CommandInputProps extends Omit<RadixCommandInputProps, "value" | "onValueChange" | "asChild"> {
|
|
51
|
+
/**
|
|
52
|
+
* Optional controlled state for the search input value.
|
|
53
|
+
* Note: Underlying cmdk input excludes standard onChange/type props in favor of value/onValueChange.
|
|
54
|
+
*/
|
|
55
|
+
value?: RadixCommandInputProps["value"];
|
|
56
|
+
/**
|
|
57
|
+
* Event handler called when the search value changes.
|
|
58
|
+
*/
|
|
59
|
+
onValueChange?: RadixCommandInputProps["onValueChange"];
|
|
60
|
+
/**
|
|
61
|
+
* Change the default rendered input element to the child element, merging props and behavior.
|
|
62
|
+
* CommandInput forwards ref to HTMLInputElement and inherits native input attributes (excluding onChange/type).
|
|
63
|
+
* Note: When aria-label is omitted, defaults to placeholder if string, or "Command Palette".
|
|
64
|
+
* @default false
|
|
65
|
+
*/
|
|
66
|
+
asChild?: RadixCommandInputProps["asChild"];
|
|
67
|
+
}
|
|
68
|
+
export declare const CommandInput: React.ForwardRefExoticComponent<CommandInputProps & React.RefAttributes<HTMLInputElement>>;
|
|
69
|
+
type RadixCommandListProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>;
|
|
70
|
+
export interface CommandListProps extends Omit<RadixCommandListProps, "label" | "asChild"> {
|
|
71
|
+
/**
|
|
72
|
+
* Accessible label for this list of suggestions. Not shown visibly.
|
|
73
|
+
* @default "Suggestions"
|
|
74
|
+
*/
|
|
75
|
+
label?: RadixCommandListProps["label"];
|
|
76
|
+
/**
|
|
77
|
+
* Change the default rendered div element to the child element, merging props and behavior.
|
|
78
|
+
* CommandList forwards ref to HTMLDivElement and inherits native div attributes.
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
81
|
+
asChild?: RadixCommandListProps["asChild"];
|
|
82
|
+
}
|
|
83
|
+
export declare const CommandList: React.ForwardRefExoticComponent<CommandListProps & React.RefAttributes<HTMLDivElement>>;
|
|
84
|
+
type RadixCommandEmptyProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>;
|
|
85
|
+
export interface CommandEmptyProps extends Omit<RadixCommandEmptyProps, "asChild"> {
|
|
86
|
+
/**
|
|
87
|
+
* Change the default rendered div element to the child element, merging props and behavior.
|
|
88
|
+
* CommandEmpty forwards ref to HTMLDivElement and inherits native div attributes.
|
|
89
|
+
* Note: cmdk Empty does not support forceMount.
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
asChild?: RadixCommandEmptyProps["asChild"];
|
|
93
|
+
}
|
|
94
|
+
export declare const CommandEmpty: React.ForwardRefExoticComponent<CommandEmptyProps & React.RefAttributes<HTMLDivElement>>;
|
|
95
|
+
type RadixCommandGroupProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>;
|
|
96
|
+
export interface CommandGroupProps extends Omit<RadixCommandGroupProps, "heading" | "value" | "forceMount" | "asChild"> {
|
|
97
|
+
/**
|
|
98
|
+
* Heading to render for this group of command items.
|
|
99
|
+
*/
|
|
100
|
+
heading?: RadixCommandGroupProps["heading"];
|
|
101
|
+
/**
|
|
102
|
+
* Unique value identifying this group. If no heading is provided, value must be specified.
|
|
103
|
+
*/
|
|
104
|
+
value?: RadixCommandGroupProps["value"];
|
|
105
|
+
/**
|
|
106
|
+
* Whether this group is forcibly rendered regardless of filtering state.
|
|
107
|
+
*/
|
|
108
|
+
forceMount?: RadixCommandGroupProps["forceMount"];
|
|
109
|
+
/**
|
|
110
|
+
* Change the default rendered div element to the child element, merging props and behavior.
|
|
111
|
+
* CommandGroup forwards ref to HTMLDivElement and inherits native div attributes.
|
|
112
|
+
* @default false
|
|
113
|
+
*/
|
|
114
|
+
asChild?: RadixCommandGroupProps["asChild"];
|
|
115
|
+
}
|
|
116
|
+
export declare const CommandGroup: React.ForwardRefExoticComponent<CommandGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
117
|
+
type RadixCommandSeparatorProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>;
|
|
118
|
+
export interface CommandSeparatorProps extends Omit<RadixCommandSeparatorProps, "alwaysRender" | "asChild"> {
|
|
119
|
+
/**
|
|
120
|
+
* Whether this separator should always be rendered. Useful when automatic filtering is disabled.
|
|
121
|
+
* When false (default), visible only when the search query is empty.
|
|
122
|
+
*/
|
|
123
|
+
alwaysRender?: RadixCommandSeparatorProps["alwaysRender"];
|
|
124
|
+
/**
|
|
125
|
+
* Change the default rendered div element to the child element, merging props and behavior.
|
|
126
|
+
* CommandSeparator forwards ref to HTMLDivElement and inherits native div attributes.
|
|
127
|
+
* @default false
|
|
128
|
+
*/
|
|
129
|
+
asChild?: RadixCommandSeparatorProps["asChild"];
|
|
130
|
+
}
|
|
131
|
+
export declare const CommandSeparator: React.ForwardRefExoticComponent<CommandSeparatorProps & React.RefAttributes<HTMLDivElement>>;
|
|
132
|
+
type RadixCommandItemProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>;
|
|
133
|
+
export interface CommandItemProps extends Omit<RadixCommandItemProps, "disabled" | "onSelect" | "value" | "keywords" | "forceMount" | "asChild"> {
|
|
134
|
+
/**
|
|
135
|
+
* Whether this item is currently disabled from selection.
|
|
136
|
+
* @default false
|
|
137
|
+
*/
|
|
138
|
+
disabled?: RadixCommandItemProps["disabled"];
|
|
139
|
+
/**
|
|
140
|
+
* Event handler called when this item is selected via click or keyboard.
|
|
141
|
+
* Note: cmdk passes the item's resolved value string `(value: string) => void`,
|
|
142
|
+
* not a standard DOM SelectEvent.
|
|
143
|
+
*/
|
|
144
|
+
onSelect?: RadixCommandItemProps["onSelect"];
|
|
145
|
+
/**
|
|
146
|
+
* Unique value identifying this item during filtering and selection.
|
|
147
|
+
* Inferred from children/textContent if omitted.
|
|
148
|
+
*/
|
|
149
|
+
value?: RadixCommandItemProps["value"];
|
|
150
|
+
/**
|
|
151
|
+
* Optional additional keywords matched during filtering.
|
|
152
|
+
*/
|
|
153
|
+
keywords?: RadixCommandItemProps["keywords"];
|
|
154
|
+
/**
|
|
155
|
+
* Whether this item is forcibly rendered regardless of query filtering.
|
|
156
|
+
* Inherits forceMount from parent CommandGroup when omitted.
|
|
157
|
+
*/
|
|
158
|
+
forceMount?: RadixCommandItemProps["forceMount"];
|
|
159
|
+
/**
|
|
160
|
+
* Change the default rendered div element to the child element, merging props and behavior.
|
|
161
|
+
* CommandItem forwards ref to HTMLDivElement and inherits native div attributes.
|
|
162
|
+
* @default false
|
|
163
|
+
*/
|
|
164
|
+
asChild?: RadixCommandItemProps["asChild"];
|
|
165
|
+
}
|
|
166
|
+
export declare const CommandItem: React.ForwardRefExoticComponent<CommandItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
167
|
+
export interface CommandShortcutProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
168
|
+
}
|
|
169
|
+
export declare function CommandShortcut({ className, ...props }: CommandShortcutProps): React.JSX.Element;
|
|
81
170
|
export declare namespace CommandShortcut {
|
|
82
171
|
var displayName: string;
|
|
83
172
|
}
|
|
173
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command-palette.js","names":[],"sources":["../../src/components/command-palette.tsx"],"sourcesContent":["import type { DialogProps } from \"@radix-ui/react-dialog\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { Search } from \"lucide-react\";\nimport * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Dialog, DialogContent, DialogTitle, DialogTrigger } from \"./dialog\";\n\nconst Command = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive>,\n\tReact.ComponentPropsWithoutRef<typeof CommandPrimitive>\n>(({ className, ...props }, ref) => (\n\t<CommandPrimitive\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"flex h-full w-full flex-col overflow-hidden rounded-basalt-md bg-basalt-popover text-basalt-popover-foreground\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t/>\n));\nCommand.displayName = CommandPrimitive.displayName;\n\nexport type CommandPaletteProps = Omit<DialogProps, \"open\" | \"defaultOpen\" | \"onOpenChange\"> & {\n\t/**\n\t * The controlled open state.\n\t */\n\topen?: boolean;\n\t/**\n\t * The uncontrolled initial open state.\n\t * @default false\n\t */\n\tdefaultOpen?: boolean;\n\t/**\n\t * Called when the open state changes.\n\t */\n\tonOpenChange?: (open: boolean) => void;\n\t/**\n\t * Filter items as the query changes.\n\t * @default true\n\t */\n\tshouldFilter?: boolean;\n};\n\nexport const CommandPaletteTrigger = DialogTrigger;\n\nexport function CommandPalette({ children, shouldFilter, ...props }: CommandPaletteProps) {\n\tconst kids = React.Children.toArray(children);\n\tconst triggers = kids.filter(\n\t\t(child) => React.isValidElement(child) && child.type === CommandPaletteTrigger,\n\t);\n\tconst content = kids.filter(\n\t\t(child) => !(React.isValidElement(child) && child.type === CommandPaletteTrigger),\n\t);\n\treturn (\n\t\t<Dialog {...props}>\n\t\t\t{triggers}\n\t\t\t<DialogContent\n\t\t\t\tsize=\"lg\"\n\t\t\t\taria-describedby={undefined}\n\t\t\t\tclassName=\"overflow-hidden bg-basalt-popover p-0 shadow-lg\"\n\t\t\t>\n\t\t\t\t<DialogTitle className=\"sr-only\">Command Palette</DialogTitle>\n\t\t\t\t<Command\n\t\t\t\t\tlabel=\"Command Palette\"\n\t\t\t\t\t{...(shouldFilter !== undefined && { shouldFilter })}\n\t\t\t\t\tclassName=\"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-basalt-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5\"\n\t\t\t\t>\n\t\t\t\t\t{content}\n\t\t\t\t</Command>\n\t\t\t</DialogContent>\n\t\t</Dialog>\n\t);\n}\n\nexport const CommandInput = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.Input>,\n\tReact.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>\n>(({ className, ...props }, ref) => (\n\t<div className=\"flex items-center border-b border-basalt-border px-3\" cmdk-input-wrapper=\"\">\n\t\t<Search className=\"mr-2 size-4 shrink-0 opacity-50\" aria-hidden=\"true\" />\n\t\t<CommandPrimitive.Input\n\t\t\tref={ref}\n\t\t\tclassName={cn(\n\t\t\t\t\"flex h-11 w-full rounded-basalt-md bg-transparent py-3 text-sm outline-hidden ring-0 shadow-none placeholder:text-basalt-muted-foreground disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t\taria-label={\n\t\t\t\tprops[\"aria-label\"] ??\n\t\t\t\t(typeof props.placeholder === \"string\" ? props.placeholder : \"Command Palette\")\n\t\t\t}\n\t\t/>\n\t</div>\n));\nCommandInput.displayName = CommandPrimitive.Input.displayName;\n\nexport const CommandList = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.List>,\n\tReact.ComponentPropsWithoutRef<typeof CommandPrimitive.List>\n>(({ className, ...props }, ref) => (\n\t<CommandPrimitive.List\n\t\tref={ref}\n\t\tclassName={cn(\"max-h-[300px] overflow-y-auto overflow-x-hidden\", className)}\n\t\t{...props}\n\t/>\n));\nCommandList.displayName = CommandPrimitive.List.displayName;\n\nexport const CommandEmpty = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.Empty>,\n\tReact.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>\n>((props, ref) => (\n\t<CommandPrimitive.Empty\n\t\tref={ref}\n\t\tclassName=\"py-6 text-center text-sm text-basalt-muted-foreground\"\n\t\t{...props}\n\t/>\n));\nCommandEmpty.displayName = CommandPrimitive.Empty.displayName;\n\nexport const CommandGroup = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.Group>,\n\tReact.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>\n>(({ className, ...props }, ref) => (\n\t<CommandPrimitive.Group\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"overflow-hidden p-1 text-basalt-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-basalt-muted-foreground\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t/>\n));\nCommandGroup.displayName = CommandPrimitive.Group.displayName;\n\nexport const CommandSeparator = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.Separator>,\n\tReact.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>\n>(({ className, ...props }, ref) => (\n\t<CommandPrimitive.Separator\n\t\tref={ref}\n\t\tclassName={cn(\"-mx-1 h-px bg-basalt-border\", className)}\n\t\t{...props}\n\t/>\n));\nCommandSeparator.displayName = CommandPrimitive.Separator.displayName;\n\nexport const CommandItem = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.Item>,\n\tReact.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>\n>(({ className, ...props }, ref) => (\n\t<CommandPrimitive.Item\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"relative flex cursor-default items-center rounded-basalt-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-basalt-accent data-[selected=true]:text-basalt-accent-foreground data-[disabled=true]:opacity-50\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t/>\n));\nCommandItem.displayName = CommandPrimitive.Item.displayName;\n\nexport function CommandShortcut({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) {\n\treturn (\n\t\t<span\n\t\t\tclassName={cn(\"ml-auto text-xs tracking-widest text-basalt-muted-foreground\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\nCommandShortcut.displayName = \"CommandShortcut\";\n"],"mappings":";;;;;;;;AAOA,IAAM,IAAU,EAAM,YAGnB,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,GAAD;CACM;CACL,WAAW,EACV,kHACA,CACD;CACA,GAAI;AACJ,CAAA,CACD;AACD,EAAQ,cAAc,EAAiB;AAuBvC,IAAa,IAAwB;AAErC,SAAgB,EAAe,EAAE,aAAU,iBAAc,GAAG,KAA8B;CACzF,IAAM,IAAO,EAAM,SAAS,QAAQ,CAAQ,GACtC,IAAW,EAAK,QACpB,MAAU,EAAM,eAAe,CAAK,KAAK,EAAM,SAAS,CAC1D,GACM,IAAU,EAAK,QACnB,MAAU,EAAE,EAAM,eAAe,CAAK,KAAK,EAAM,SAAS,EAC5D;CACA,OACC,kBAAC,GAAD;EAAQ,GAAI;EAAZ,UAAA,CACE,GACD,kBAAC,GAAD;GACC,MAAK;GACL,oBAAkB,KAAA;GAClB,WAAU;GAHX,UAAA,CAKC,kBAAC,GAAD;IAAa,WAAU;IAAU,UAAA;GAA4B,CAAA,GAC7D,kBAAC,GAAD;IACC,OAAM;IACN,GAAK,MAAiB,KAAA,KAAa,EAAE,gBAAa;IAClD,WAAU;IAET,UAAA;GACO,CAAA,CACK;EACR,CAAA,CAAA;;AAEV;AAEA,IAAa,IAAe,EAAM,YAG/B,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,OAAD;CAAK,WAAU;CAAuD,sBAAmB;CAAzF,UAAA,CACC,kBAAC,GAAD;EAAQ,WAAU;EAAkC,eAAY;CAAQ,CAAA,GACxE,kBAAC,EAAiB,OAAlB;EACM;EACL,WAAW,EACV,6LACA,CACD;EACA,GAAI;EACJ,cACC,EAAM,kBACL,OAAO,EAAM,eAAgB,WAAW,EAAM,cAAc;CAE9D,CAAA,CACG;AACL,CAAA,CAAA;AACD,EAAa,cAAc,EAAiB,MAAM;AAElD,IAAa,IAAc,EAAM,YAG9B,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAiB,MAAlB;CACM;CACL,WAAW,EAAG,mDAAmD,CAAS;CAC1E,GAAI;AACJ,CAAA,CACD;AACD,EAAY,cAAc,EAAiB,KAAK;AAEhD,IAAa,IAAe,EAAM,YAG/B,GAAO,MACT,kBAAC,EAAiB,OAAlB;CACM;CACL,WAAU;CACV,GAAI;AACJ,CAAA,CACD;AACD,EAAa,cAAc,EAAiB,MAAM;AAElD,IAAa,IAAe,EAAM,YAG/B,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAiB,OAAlB;CACM;CACL,WAAW,EACV,wOACA,CACD;CACA,GAAI;AACJ,CAAA,CACD;AACD,EAAa,cAAc,EAAiB,MAAM;AAElD,IAAa,IAAmB,EAAM,YAGnC,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAiB,WAAlB;CACM;CACL,WAAW,EAAG,+BAA+B,CAAS;CACtD,GAAI;AACJ,CAAA,CACD;AACD,EAAiB,cAAc,EAAiB,UAAU;AAE1D,IAAa,IAAc,EAAM,YAG9B,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAiB,MAAlB;CACM;CACL,WAAW,EACV,gRACA,CACD;CACA,GAAI;AACJ,CAAA,CACD;AACD,EAAY,cAAc,EAAiB,KAAK;AAEhD,SAAgB,EAAgB,EAAE,cAAW,GAAG,KAAgD;CAC/F,OACC,kBAAC,QAAD;EACC,WAAW,EAAG,gEAAgE,CAAS;EACvF,GAAI;CACJ,CAAA;AAEH;AACA,EAAgB,cAAc"}
|
|
1
|
+
{"version":3,"file":"command-palette.js","names":[],"sources":["../../src/components/command-palette.tsx"],"sourcesContent":["import type * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport type { DialogProps } from \"@radix-ui/react-dialog\";\nimport { Command as CommandPrimitive } from \"cmdk\";\nimport { Search } from \"lucide-react\";\nimport * as React from \"react\";\nimport { cn } from \"../utils/cn\";\nimport { Dialog, DialogContent, DialogTitle, DialogTrigger } from \"./dialog\";\n\nconst Command = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive>,\n\tReact.ComponentPropsWithoutRef<typeof CommandPrimitive>\n>(({ className, ...props }, ref) => (\n\t<CommandPrimitive\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"flex h-full w-full flex-col overflow-hidden rounded-basalt-md bg-basalt-popover text-basalt-popover-foreground\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t/>\n));\nCommand.displayName = CommandPrimitive.displayName;\n\nexport interface CommandPaletteProps\n\textends Omit<DialogProps, \"open\" | \"defaultOpen\" | \"onOpenChange\" | \"children\" | \"modal\"> {\n\t/**\n\t * Command palette structure elements, including CommandPaletteTrigger and inner command items.\n\t * Note: Triggers must be direct children of CommandPalette (child.type === CommandPaletteTrigger)\n\t * to be separated from modal dialog content. Wrapping triggers in Fragments or HOCs will cause\n\t * them to be treated as modal content.\n\t */\n\tchildren?: React.ReactNode;\n\t/**\n\t * The controlled open state of the command palette dialog.\n\t */\n\topen?: boolean;\n\t/**\n\t * The uncontrolled initial open state of the command palette dialog.\n\t * @default false\n\t */\n\tdefaultOpen?: boolean;\n\t/**\n\t * Called when the open state changes.\n\t */\n\tonOpenChange?: (open: boolean) => void;\n\t/**\n\t * Filter items as the query changes.\n\t * @default true\n\t */\n\tshouldFilter?: boolean;\n\t/**\n\t * The modality of the dialog. When set to true, interaction with outside elements\n\t * will be disabled and only dialog content will be visible to screen readers.\n\t * @default true\n\t */\n\tmodal?: boolean;\n}\n\ntype RadixDialogTriggerProps = React.ComponentPropsWithoutRef<typeof DialogPrimitive.Trigger>;\n\nexport interface CommandPaletteTriggerProps extends Omit<RadixDialogTriggerProps, \"asChild\"> {\n\t/**\n\t * Change the default rendered button element to the child element, merging props and behavior.\n\t * CommandPaletteTrigger is an alias for DialogTrigger; forwards ref to HTMLButtonElement and inherits native button attributes.\n\t * @default false\n\t */\n\tasChild?: RadixDialogTriggerProps[\"asChild\"];\n}\n\nexport const CommandPaletteTrigger = DialogTrigger;\n\nexport function CommandPalette({ children, shouldFilter, ...props }: CommandPaletteProps) {\n\tconst kids = React.Children.toArray(children);\n\tconst triggers = kids.filter(\n\t\t(child) => React.isValidElement(child) && child.type === CommandPaletteTrigger,\n\t);\n\tconst content = kids.filter(\n\t\t(child) => !(React.isValidElement(child) && child.type === CommandPaletteTrigger),\n\t);\n\treturn (\n\t\t<Dialog {...props}>\n\t\t\t{triggers}\n\t\t\t<DialogContent\n\t\t\t\tsize=\"lg\"\n\t\t\t\taria-describedby={undefined}\n\t\t\t\tclassName=\"overflow-hidden bg-basalt-popover p-0 shadow-lg\"\n\t\t\t>\n\t\t\t\t<DialogTitle className=\"sr-only\">Command Palette</DialogTitle>\n\t\t\t\t<Command\n\t\t\t\t\tlabel=\"Command Palette\"\n\t\t\t\t\t{...(shouldFilter !== undefined && { shouldFilter })}\n\t\t\t\t\tclassName=\"[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-basalt-muted-foreground [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5\"\n\t\t\t\t>\n\t\t\t\t\t{content}\n\t\t\t\t</Command>\n\t\t\t</DialogContent>\n\t\t</Dialog>\n\t);\n}\n\ntype RadixCommandInputProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input>;\n\nexport interface CommandInputProps\n\textends Omit<RadixCommandInputProps, \"value\" | \"onValueChange\" | \"asChild\"> {\n\t/**\n\t * Optional controlled state for the search input value.\n\t * Note: Underlying cmdk input excludes standard onChange/type props in favor of value/onValueChange.\n\t */\n\tvalue?: RadixCommandInputProps[\"value\"];\n\t/**\n\t * Event handler called when the search value changes.\n\t */\n\tonValueChange?: RadixCommandInputProps[\"onValueChange\"];\n\t/**\n\t * Change the default rendered input element to the child element, merging props and behavior.\n\t * CommandInput forwards ref to HTMLInputElement and inherits native input attributes (excluding onChange/type).\n\t * Note: When aria-label is omitted, defaults to placeholder if string, or \"Command Palette\".\n\t * @default false\n\t */\n\tasChild?: RadixCommandInputProps[\"asChild\"];\n}\n\nexport const CommandInput = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.Input>,\n\tCommandInputProps\n>(({ className, ...props }, ref) => (\n\t<div className=\"flex items-center border-b border-basalt-border px-3\" cmdk-input-wrapper=\"\">\n\t\t<Search className=\"mr-2 size-4 shrink-0 opacity-50\" aria-hidden=\"true\" />\n\t\t<CommandPrimitive.Input\n\t\t\tref={ref}\n\t\t\tclassName={cn(\n\t\t\t\t\"flex h-11 w-full rounded-basalt-md bg-transparent py-3 text-sm outline-hidden ring-0 shadow-none placeholder:text-basalt-muted-foreground disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t\taria-label={\n\t\t\t\tprops[\"aria-label\"] ??\n\t\t\t\t(typeof props.placeholder === \"string\" ? props.placeholder : \"Command Palette\")\n\t\t\t}\n\t\t/>\n\t</div>\n));\nCommandInput.displayName = CommandPrimitive.Input.displayName;\n\ntype RadixCommandListProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.List>;\n\nexport interface CommandListProps extends Omit<RadixCommandListProps, \"label\" | \"asChild\"> {\n\t/**\n\t * Accessible label for this list of suggestions. Not shown visibly.\n\t * @default \"Suggestions\"\n\t */\n\tlabel?: RadixCommandListProps[\"label\"];\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * CommandList forwards ref to HTMLDivElement and inherits native div attributes.\n\t * @default false\n\t */\n\tasChild?: RadixCommandListProps[\"asChild\"];\n}\n\nexport const CommandList = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.List>,\n\tCommandListProps\n>(({ className, ...props }, ref) => (\n\t<CommandPrimitive.List\n\t\tref={ref}\n\t\tclassName={cn(\"max-h-[300px] overflow-y-auto overflow-x-hidden\", className)}\n\t\t{...props}\n\t/>\n));\nCommandList.displayName = CommandPrimitive.List.displayName;\n\ntype RadixCommandEmptyProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty>;\n\nexport interface CommandEmptyProps extends Omit<RadixCommandEmptyProps, \"asChild\"> {\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * CommandEmpty forwards ref to HTMLDivElement and inherits native div attributes.\n\t * Note: cmdk Empty does not support forceMount.\n\t * @default false\n\t */\n\tasChild?: RadixCommandEmptyProps[\"asChild\"];\n}\n\nexport const CommandEmpty = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.Empty>,\n\tCommandEmptyProps\n>((props, ref) => (\n\t<CommandPrimitive.Empty\n\t\tref={ref}\n\t\tclassName=\"py-6 text-center text-sm text-basalt-muted-foreground\"\n\t\t{...props}\n\t/>\n));\nCommandEmpty.displayName = CommandPrimitive.Empty.displayName;\n\ntype RadixCommandGroupProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group>;\n\nexport interface CommandGroupProps\n\textends Omit<RadixCommandGroupProps, \"heading\" | \"value\" | \"forceMount\" | \"asChild\"> {\n\t/**\n\t * Heading to render for this group of command items.\n\t */\n\theading?: RadixCommandGroupProps[\"heading\"];\n\t/**\n\t * Unique value identifying this group. If no heading is provided, value must be specified.\n\t */\n\tvalue?: RadixCommandGroupProps[\"value\"];\n\t/**\n\t * Whether this group is forcibly rendered regardless of filtering state.\n\t */\n\tforceMount?: RadixCommandGroupProps[\"forceMount\"];\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * CommandGroup forwards ref to HTMLDivElement and inherits native div attributes.\n\t * @default false\n\t */\n\tasChild?: RadixCommandGroupProps[\"asChild\"];\n}\n\nexport const CommandGroup = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.Group>,\n\tCommandGroupProps\n>(({ className, ...props }, ref) => (\n\t<CommandPrimitive.Group\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"overflow-hidden p-1 text-basalt-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-basalt-muted-foreground\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t/>\n));\nCommandGroup.displayName = CommandPrimitive.Group.displayName;\n\ntype RadixCommandSeparatorProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator>;\n\nexport interface CommandSeparatorProps\n\textends Omit<RadixCommandSeparatorProps, \"alwaysRender\" | \"asChild\"> {\n\t/**\n\t * Whether this separator should always be rendered. Useful when automatic filtering is disabled.\n\t * When false (default), visible only when the search query is empty.\n\t */\n\talwaysRender?: RadixCommandSeparatorProps[\"alwaysRender\"];\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * CommandSeparator forwards ref to HTMLDivElement and inherits native div attributes.\n\t * @default false\n\t */\n\tasChild?: RadixCommandSeparatorProps[\"asChild\"];\n}\n\nexport const CommandSeparator = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.Separator>,\n\tCommandSeparatorProps\n>(({ className, ...props }, ref) => (\n\t<CommandPrimitive.Separator\n\t\tref={ref}\n\t\tclassName={cn(\"-mx-1 h-px bg-basalt-border\", className)}\n\t\t{...props}\n\t/>\n));\nCommandSeparator.displayName = CommandPrimitive.Separator.displayName;\n\ntype RadixCommandItemProps = React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item>;\n\nexport interface CommandItemProps\n\textends Omit<\n\t\tRadixCommandItemProps,\n\t\t\"disabled\" | \"onSelect\" | \"value\" | \"keywords\" | \"forceMount\" | \"asChild\"\n\t> {\n\t/**\n\t * Whether this item is currently disabled from selection.\n\t * @default false\n\t */\n\tdisabled?: RadixCommandItemProps[\"disabled\"];\n\t/**\n\t * Event handler called when this item is selected via click or keyboard.\n\t * Note: cmdk passes the item's resolved value string `(value: string) => void`,\n\t * not a standard DOM SelectEvent.\n\t */\n\tonSelect?: RadixCommandItemProps[\"onSelect\"];\n\t/**\n\t * Unique value identifying this item during filtering and selection.\n\t * Inferred from children/textContent if omitted.\n\t */\n\tvalue?: RadixCommandItemProps[\"value\"];\n\t/**\n\t * Optional additional keywords matched during filtering.\n\t */\n\tkeywords?: RadixCommandItemProps[\"keywords\"];\n\t/**\n\t * Whether this item is forcibly rendered regardless of query filtering.\n\t * Inherits forceMount from parent CommandGroup when omitted.\n\t */\n\tforceMount?: RadixCommandItemProps[\"forceMount\"];\n\t/**\n\t * Change the default rendered div element to the child element, merging props and behavior.\n\t * CommandItem forwards ref to HTMLDivElement and inherits native div attributes.\n\t * @default false\n\t */\n\tasChild?: RadixCommandItemProps[\"asChild\"];\n}\n\nexport const CommandItem = React.forwardRef<\n\tReact.ElementRef<typeof CommandPrimitive.Item>,\n\tCommandItemProps\n>(({ className, ...props }, ref) => (\n\t<CommandPrimitive.Item\n\t\tref={ref}\n\t\tclassName={cn(\n\t\t\t\"relative flex cursor-default items-center rounded-basalt-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[selected=true]:bg-basalt-accent data-[selected=true]:text-basalt-accent-foreground data-[disabled=true]:opacity-50\",\n\t\t\tclassName,\n\t\t)}\n\t\t{...props}\n\t/>\n));\nCommandItem.displayName = CommandPrimitive.Item.displayName;\n\nexport interface CommandShortcutProps extends React.HTMLAttributes<HTMLSpanElement> {}\n\nexport function CommandShortcut({ className, ...props }: CommandShortcutProps) {\n\treturn (\n\t\t<span\n\t\t\tclassName={cn(\"ml-auto text-xs tracking-widest text-basalt-muted-foreground\", className)}\n\t\t\t{...props}\n\t\t/>\n\t);\n}\nCommandShortcut.displayName = \"CommandShortcut\";\n"],"mappings":";;;;;;;;AAQA,IAAM,IAAU,EAAM,YAGnB,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,GAAD;CACM;CACL,WAAW,EACV,kHACA,CACD;CACA,GAAI;AACJ,CAAA,CACD;AACD,EAAQ,cAAc,EAAiB;AAgDvC,IAAa,IAAwB;AAErC,SAAgB,EAAe,EAAE,aAAU,iBAAc,GAAG,KAA8B;CACzF,IAAM,IAAO,EAAM,SAAS,QAAQ,CAAQ,GACtC,IAAW,EAAK,QACpB,MAAU,EAAM,eAAe,CAAK,KAAK,EAAM,SAAS,CAC1D,GACM,IAAU,EAAK,QACnB,MAAU,EAAE,EAAM,eAAe,CAAK,KAAK,EAAM,SAAS,EAC5D;CACA,OACC,kBAAC,GAAD;EAAQ,GAAI;EAAZ,UAAA,CACE,GACD,kBAAC,GAAD;GACC,MAAK;GACL,oBAAkB,KAAA;GAClB,WAAU;GAHX,UAAA,CAKC,kBAAC,GAAD;IAAa,WAAU;IAAU,UAAA;GAA4B,CAAA,GAC7D,kBAAC,GAAD;IACC,OAAM;IACN,GAAK,MAAiB,KAAA,KAAa,EAAE,gBAAa;IAClD,WAAU;IAET,UAAA;GACO,CAAA,CACK;EACR,CAAA,CAAA;;AAEV;AAwBA,IAAa,IAAe,EAAM,YAG/B,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,OAAD;CAAK,WAAU;CAAuD,sBAAmB;CAAzF,UAAA,CACC,kBAAC,GAAD;EAAQ,WAAU;EAAkC,eAAY;CAAQ,CAAA,GACxE,kBAAC,EAAiB,OAAlB;EACM;EACL,WAAW,EACV,6LACA,CACD;EACA,GAAI;EACJ,cACC,EAAM,kBACL,OAAO,EAAM,eAAgB,WAAW,EAAM,cAAc;CAE9D,CAAA,CACG;AACL,CAAA,CAAA;AACD,EAAa,cAAc,EAAiB,MAAM;AAkBlD,IAAa,IAAc,EAAM,YAG9B,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAiB,MAAlB;CACM;CACL,WAAW,EAAG,mDAAmD,CAAS;CAC1E,GAAI;AACJ,CAAA,CACD;AACD,EAAY,cAAc,EAAiB,KAAK;AAchD,IAAa,IAAe,EAAM,YAG/B,GAAO,MACT,kBAAC,EAAiB,OAAlB;CACM;CACL,WAAU;CACV,GAAI;AACJ,CAAA,CACD;AACD,EAAa,cAAc,EAAiB,MAAM;AA0BlD,IAAa,IAAe,EAAM,YAG/B,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAiB,OAAlB;CACM;CACL,WAAW,EACV,wOACA,CACD;CACA,GAAI;AACJ,CAAA,CACD;AACD,EAAa,cAAc,EAAiB,MAAM;AAmBlD,IAAa,IAAmB,EAAM,YAGnC,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAiB,WAAlB;CACM;CACL,WAAW,EAAG,+BAA+B,CAAS;CACtD,GAAI;AACJ,CAAA,CACD;AACD,EAAiB,cAAc,EAAiB,UAAU;AA0C1D,IAAa,IAAc,EAAM,YAG9B,EAAE,cAAW,GAAG,KAAS,MAC3B,kBAAC,EAAiB,MAAlB;CACM;CACL,WAAW,EACV,gRACA,CACD;CACA,GAAI;AACJ,CAAA,CACD;AACD,EAAY,cAAc,EAAiB,KAAK;AAIhD,SAAgB,EAAgB,EAAE,cAAW,GAAG,KAA+B;CAC9E,OACC,kBAAC,QAAD;EACC,WAAW,EAAG,gEAAgE,CAAS;EACvF,GAAI;CACJ,CAAA;AAEH;AACA,EAAgB,cAAc"}
|
|
@@ -5,7 +5,7 @@ export interface ConfirmDialogProps {
|
|
|
5
5
|
open: boolean;
|
|
6
6
|
/** Called when the dialog requests to open or close. */
|
|
7
7
|
onOpenChange: (open: boolean) => void;
|
|
8
|
-
/** Called once when the user confirms. The dialog does not close itself. */
|
|
8
|
+
/** Called once when the user confirms. The dialog does not close itself; caller manages loading and asynchronous errors. */
|
|
9
9
|
onConfirm: () => void | Promise<void>;
|
|
10
10
|
/** The dialog title. */
|
|
11
11
|
title: React.ReactNode;
|
|
@@ -6,9 +6,11 @@ import * as l from "react";
|
|
|
6
6
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
7
7
|
//#region src/components/confirm-dialog.tsx
|
|
8
8
|
function f({ cancelLabel: f = "Cancel", confirmLabel: p = "Confirm", description: m, loading: h = !1, onConfirm: g, onOpenChange: _, open: v, title: y, trigger: b, variant: x = "default" }) {
|
|
9
|
-
let S = l.useRef(null), C = l.useRef(null), w = l.useRef(null), T = l.useRef(v)
|
|
9
|
+
let S = l.useRef(null), C = l.useRef(null), w = l.useRef(null), T = l.useRef(v), E = l.useRef(null), D = l.useCallback(() => {
|
|
10
|
+
S.current?.isConnected ? S.current.focus() : E.current?.isConnected && E.current.focus(), E.current = null;
|
|
11
|
+
}, []);
|
|
10
12
|
return l.useEffect(() => {
|
|
11
|
-
T.current && !v && S.current?.focus(), T.current = v;
|
|
13
|
+
T.current && !v && S.current?.isConnected && S.current.focus(), T.current = v;
|
|
12
14
|
}, [v]), /* @__PURE__ */ d(t, {
|
|
13
15
|
open: v,
|
|
14
16
|
onOpenChange: (e) => {
|
|
@@ -21,14 +23,14 @@ function f({ cancelLabel: f = "Cancel", confirmLabel: p = "Confirm", description
|
|
|
21
23
|
}) : null, /* @__PURE__ */ d(n, {
|
|
22
24
|
ref: C,
|
|
23
25
|
onOpenAutoFocus: (e) => {
|
|
24
|
-
if (e.preventDefault(), w.current && !w.current.disabled) {
|
|
26
|
+
if (e.preventDefault(), !E.current?.isConnected && document.activeElement instanceof HTMLElement && !C.current?.contains(document.activeElement) && (E.current = document.activeElement), w.current && !w.current.disabled) {
|
|
25
27
|
w.current.focus();
|
|
26
28
|
return;
|
|
27
29
|
}
|
|
28
30
|
C.current?.focus();
|
|
29
31
|
},
|
|
30
32
|
onCloseAutoFocus: (e) => {
|
|
31
|
-
e.preventDefault(),
|
|
33
|
+
e.preventDefault(), D();
|
|
32
34
|
},
|
|
33
35
|
children: [/* @__PURE__ */ d(a, { children: [/* @__PURE__ */ u(o, { children: y }), /* @__PURE__ */ u(r, { children: m })] }), /* @__PURE__ */ d(i, { children: [/* @__PURE__ */ u(c.Cancel, {
|
|
34
36
|
asChild: !0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confirm-dialog.js","names":[],"sources":["../../src/components/confirm-dialog.tsx"],"sourcesContent":["import * as AlertDialogPrimitive from \"@radix-ui/react-alert-dialog\";\nimport * as React from \"react\";\nimport {\n\tAlertDialog,\n\tAlertDialogContent,\n\tAlertDialogDescription,\n\tAlertDialogFooter,\n\tAlertDialogHeader,\n\tAlertDialogTitle,\n\tAlertDialogTrigger,\n} from \"./alert-dialog\";\nimport { Button } from \"./button\";\n\nexport type ConfirmDialogVariant = \"default\" | \"destructive\";\n\nexport interface ConfirmDialogProps {\n\t/** Whether the confirmation dialog is shown. */\n\topen: boolean;\n\t/** Called when the dialog requests to open or close. */\n\tonOpenChange: (open: boolean) => void;\n\t/** Called once when the user confirms. The dialog does not close itself. */\n\tonConfirm: () => void | Promise<void>;\n\t/** The dialog title. */\n\ttitle: React.ReactNode;\n\t/** Supporting copy that describes the action. */\n\tdescription: React.ReactNode;\n\t/**\n\t * Label for the confirm button.\n\t * @default \"Confirm\"\n\t */\n\tconfirmLabel?: React.ReactNode;\n\t/**\n\t * Label for the cancel button.\n\t * @default \"Cancel\"\n\t */\n\tcancelLabel?: React.ReactNode;\n\t/**\n\t * Appearance of the confirm button.\n\t * @default \"default\"\n\t */\n\tvariant?: ConfirmDialogVariant;\n\t/**\n\t * Disable both actions and ignore close requests while work is pending.\n\t * @default false\n\t */\n\tloading?: boolean;\n\t/**\n\t * Control that opens the dialog. When set, closing restores focus to it.\n\t */\n\ttrigger?: React.ReactElement;\n}\n\nexport interface UseConfirmOptions {\n\t/** The dialog title. */\n\ttitle: React.ReactNode;\n\t/** Supporting copy that describes the action. */\n\tdescription: React.ReactNode;\n\t/** Label for the confirm button. */\n\tconfirmLabel?: React.ReactNode;\n\t/** Label for the cancel button. */\n\tcancelLabel?: React.ReactNode;\n\t/** Appearance of the confirm button. */\n\tvariant?: ConfirmDialogVariant;\n}\n\nexport interface UseConfirmResult {\n\tconfirm: (options: UseConfirmOptions) => Promise<boolean>;\n\tdialogProps: ConfirmDialogProps;\n}\n\nexport function ConfirmDialog({\n\tcancelLabel = \"Cancel\",\n\tconfirmLabel = \"Confirm\",\n\tdescription,\n\tloading = false,\n\tonConfirm,\n\tonOpenChange,\n\topen,\n\ttitle,\n\ttrigger,\n\tvariant = \"default\",\n}: ConfirmDialogProps) {\n\tconst triggerRef = React.useRef<HTMLButtonElement>(null);\n\tconst panelRef = React.useRef<HTMLDivElement>(null);\n\tconst cancelRef = React.useRef<HTMLButtonElement>(null);\n\tconst wasOpenRef = React.useRef(open);\n\tReact.useEffect(() => {\n\t\tif (wasOpenRef.current && !open) {\n\t\t\ttriggerRef.current
|
|
1
|
+
{"version":3,"file":"confirm-dialog.js","names":[],"sources":["../../src/components/confirm-dialog.tsx"],"sourcesContent":["import * as AlertDialogPrimitive from \"@radix-ui/react-alert-dialog\";\nimport * as React from \"react\";\nimport {\n\tAlertDialog,\n\tAlertDialogContent,\n\tAlertDialogDescription,\n\tAlertDialogFooter,\n\tAlertDialogHeader,\n\tAlertDialogTitle,\n\tAlertDialogTrigger,\n} from \"./alert-dialog\";\nimport { Button } from \"./button\";\n\nexport type ConfirmDialogVariant = \"default\" | \"destructive\";\n\nexport interface ConfirmDialogProps {\n\t/** Whether the confirmation dialog is shown. */\n\topen: boolean;\n\t/** Called when the dialog requests to open or close. */\n\tonOpenChange: (open: boolean) => void;\n\t/** Called once when the user confirms. The dialog does not close itself; caller manages loading and asynchronous errors. */\n\tonConfirm: () => void | Promise<void>;\n\t/** The dialog title. */\n\ttitle: React.ReactNode;\n\t/** Supporting copy that describes the action. */\n\tdescription: React.ReactNode;\n\t/**\n\t * Label for the confirm button.\n\t * @default \"Confirm\"\n\t */\n\tconfirmLabel?: React.ReactNode;\n\t/**\n\t * Label for the cancel button.\n\t * @default \"Cancel\"\n\t */\n\tcancelLabel?: React.ReactNode;\n\t/**\n\t * Appearance of the confirm button.\n\t * @default \"default\"\n\t */\n\tvariant?: ConfirmDialogVariant;\n\t/**\n\t * Disable both actions and ignore close requests while work is pending.\n\t * @default false\n\t */\n\tloading?: boolean;\n\t/**\n\t * Control that opens the dialog. When set, closing restores focus to it.\n\t */\n\ttrigger?: React.ReactElement;\n}\n\nexport interface UseConfirmOptions {\n\t/** The dialog title. */\n\ttitle: React.ReactNode;\n\t/** Supporting copy that describes the action. */\n\tdescription: React.ReactNode;\n\t/** Label for the confirm button. */\n\tconfirmLabel?: React.ReactNode;\n\t/** Label for the cancel button. */\n\tcancelLabel?: React.ReactNode;\n\t/** Appearance of the confirm button. */\n\tvariant?: ConfirmDialogVariant;\n}\n\nexport interface UseConfirmResult {\n\tconfirm: (options: UseConfirmOptions) => Promise<boolean>;\n\tdialogProps: ConfirmDialogProps;\n}\n\nexport function ConfirmDialog({\n\tcancelLabel = \"Cancel\",\n\tconfirmLabel = \"Confirm\",\n\tdescription,\n\tloading = false,\n\tonConfirm,\n\tonOpenChange,\n\topen,\n\ttitle,\n\ttrigger,\n\tvariant = \"default\",\n}: ConfirmDialogProps) {\n\tconst triggerRef = React.useRef<HTMLButtonElement>(null);\n\tconst panelRef = React.useRef<HTMLDivElement>(null);\n\tconst cancelRef = React.useRef<HTMLButtonElement>(null);\n\tconst wasOpenRef = React.useRef(open);\n\tconst openerRef = React.useRef<HTMLElement | null>(null);\n\n\tconst restoreFocus = React.useCallback(() => {\n\t\tif (triggerRef.current?.isConnected) {\n\t\t\ttriggerRef.current.focus();\n\t\t} else if (openerRef.current?.isConnected) {\n\t\t\topenerRef.current.focus();\n\t\t}\n\t\topenerRef.current = null;\n\t}, []);\n\n\tReact.useEffect(() => {\n\t\tif (wasOpenRef.current && !open) {\n\t\t\tif (triggerRef.current?.isConnected) {\n\t\t\t\ttriggerRef.current.focus();\n\t\t\t}\n\t\t}\n\t\twasOpenRef.current = open;\n\t}, [open]);\n\n\treturn (\n\t\t<AlertDialog\n\t\t\topen={open}\n\t\t\tonOpenChange={(next) => {\n\t\t\t\tif (loading && !next) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tonOpenChange(next);\n\t\t\t}}\n\t\t>\n\t\t\t{React.isValidElement(trigger) ? (\n\t\t\t\t<AlertDialogTrigger ref={triggerRef} asChild>\n\t\t\t\t\t{trigger}\n\t\t\t\t</AlertDialogTrigger>\n\t\t\t) : null}\n\t\t\t<AlertDialogContent\n\t\t\t\tref={panelRef}\n\t\t\t\tonOpenAutoFocus={(event) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tif (\n\t\t\t\t\t\t!openerRef.current?.isConnected &&\n\t\t\t\t\t\tdocument.activeElement instanceof HTMLElement &&\n\t\t\t\t\t\t!panelRef.current?.contains(document.activeElement)\n\t\t\t\t\t) {\n\t\t\t\t\t\topenerRef.current = document.activeElement;\n\t\t\t\t\t}\n\t\t\t\t\tif (cancelRef.current && !cancelRef.current.disabled) {\n\t\t\t\t\t\tcancelRef.current.focus();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tpanelRef.current?.focus();\n\t\t\t\t}}\n\t\t\t\tonCloseAutoFocus={(event) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\trestoreFocus();\n\t\t\t\t}}\n\t\t\t>\n\t\t\t\t<AlertDialogHeader>\n\t\t\t\t\t<AlertDialogTitle>{title}</AlertDialogTitle>\n\t\t\t\t\t<AlertDialogDescription>{description}</AlertDialogDescription>\n\t\t\t\t</AlertDialogHeader>\n\t\t\t\t<AlertDialogFooter>\n\t\t\t\t\t<AlertDialogPrimitive.Cancel asChild>\n\t\t\t\t\t\t<Button ref={cancelRef} disabled={loading} variant=\"outline\">\n\t\t\t\t\t\t\t{cancelLabel}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</AlertDialogPrimitive.Cancel>\n\t\t\t\t\t<AlertDialogPrimitive.Action asChild>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tloading={loading}\n\t\t\t\t\t\t\tvariant={variant}\n\t\t\t\t\t\t\tonClick={(event) => {\n\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\tif (!loading) {\n\t\t\t\t\t\t\t\t\tvoid onConfirm();\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{confirmLabel}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</AlertDialogPrimitive.Action>\n\t\t\t\t</AlertDialogFooter>\n\t\t\t</AlertDialogContent>\n\t\t</AlertDialog>\n\t);\n}\n\nexport function useConfirm(): UseConfirmResult {\n\tconst [open, setOpen] = React.useState(false);\n\tconst [options, setOptions] = React.useState<UseConfirmOptions>({\n\t\ttitle: \"\",\n\t\tdescription: \"\",\n\t});\n\tconst resolverRef = React.useRef<((value: boolean) => void) | null>(null);\n\n\tconst settle = React.useCallback((value: boolean) => {\n\t\tconst resolve = resolverRef.current;\n\t\tresolverRef.current = null;\n\t\tresolve?.(value);\n\t}, []);\n\n\tReact.useEffect(() => {\n\t\treturn () => {\n\t\t\tsettle(false);\n\t\t};\n\t}, [settle]);\n\n\tconst confirm = React.useCallback(\n\t\t(next: UseConfirmOptions) => {\n\t\t\tsettle(false);\n\t\t\tsetOptions(next);\n\t\t\tsetOpen(true);\n\t\t\treturn new Promise<boolean>((resolve) => {\n\t\t\t\tresolverRef.current = resolve;\n\t\t\t});\n\t\t},\n\t\t[settle],\n\t);\n\n\treturn {\n\t\tconfirm,\n\t\tdialogProps: {\n\t\t\topen,\n\t\t\ttitle: options.title,\n\t\t\tdescription: options.description,\n\t\t\tconfirmLabel: options.confirmLabel,\n\t\t\tcancelLabel: options.cancelLabel,\n\t\t\tvariant: options.variant,\n\t\t\tonOpenChange: (next) => {\n\t\t\t\tsetOpen(next);\n\t\t\t\tif (!next) {\n\t\t\t\t\tsettle(false);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonConfirm: () => {\n\t\t\t\tsettle(true);\n\t\t\t\tsetOpen(false);\n\t\t\t},\n\t\t},\n\t};\n}\n"],"mappings":";;;;;;;AAsEA,SAAgB,EAAc,EAC7B,iBAAc,UACd,kBAAe,WACf,gBACA,aAAU,IACV,cACA,iBACA,SACA,UACA,YACA,aAAU,aACY;CACtB,IAAM,IAAa,EAAM,OAA0B,IAAI,GACjD,IAAW,EAAM,OAAuB,IAAI,GAC5C,IAAY,EAAM,OAA0B,IAAI,GAChD,IAAa,EAAM,OAAO,CAAI,GAC9B,IAAY,EAAM,OAA2B,IAAI,GAEjD,IAAe,EAAM,kBAAkB;EAM5C,AALI,EAAW,SAAS,cACvB,EAAW,QAAQ,MAAM,IACf,EAAU,SAAS,eAC7B,EAAU,QAAQ,MAAM,GAEzB,EAAU,UAAU;CACrB,GAAG,CAAC,CAAC;CAWL,OATA,EAAM,gBAAgB;EAMrB,AALI,EAAW,WAAW,CAAC,KACtB,EAAW,SAAS,eACvB,EAAW,QAAQ,MAAM,GAG3B,EAAW,UAAU;CACtB,GAAG,CAAC,CAAI,CAAC,GAGR,kBAAC,GAAD;EACO;EACN,eAAe,MAAS;GACnB,KAAW,CAAC,KAGhB,EAAa,CAAI;EAClB;EAPD,UAAA,CASE,EAAM,eAAe,CAAO,IAC5B,kBAAC,GAAD;GAAoB,KAAK;GAAY,SAAA;GACnC,UAAA;EACkB,CAAA,IACjB,MACJ,kBAAC,GAAD;GACC,KAAK;GACL,kBAAkB,MAAU;IAS3B,IARA,EAAM,eAAe,GAEpB,CAAC,EAAU,SAAS,eACpB,SAAS,yBAAyB,eAClC,CAAC,EAAS,SAAS,SAAS,SAAS,aAAa,MAElD,EAAU,UAAU,SAAS,gBAE1B,EAAU,WAAW,CAAC,EAAU,QAAQ,UAAU;KACrD,EAAU,QAAQ,MAAM;KACxB;IACD;IACA,EAAS,SAAS,MAAM;GACzB;GACA,mBAAmB,MAAU;IAE5B,AADA,EAAM,eAAe,GACrB,EAAa;GACd;GApBD,UAAA,CAsBC,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,GAAD,EAAA,UAAmB,EAAwB,CAAA,GAC3C,kBAAC,GAAD,EAAA,UAAyB,EAAoC,CAAA,CAC3C,EAAA,CAAA,GACnB,kBAAC,GAAD,EAAA,UAAA,CACC,kBAAC,EAAqB,QAAtB;IAA6B,SAAA;IAC5B,UAAA,kBAAC,GAAD;KAAQ,KAAK;KAAW,UAAU;KAAS,SAAQ;KACjD,UAAA;IACM,CAAA;GACoB,CAAA,GAC7B,kBAAC,EAAqB,QAAtB;IAA6B,SAAA;IAC5B,UAAA,kBAAC,GAAD;KACU;KACA;KACT,UAAU,MAAU;MAEnB,AADA,EAAM,eAAe,GAChB,KACJ,EAAe;KAEjB;KAEC,UAAA;IACM,CAAA;GACoB,CAAA,CACX,EAAA,CAAA,CACA;EACR,CAAA,CAAA;;AAEf;AAEA,SAAgB,IAA+B;CAC9C,IAAM,CAAC,GAAM,KAAW,EAAM,SAAS,EAAK,GACtC,CAAC,GAAS,KAAc,EAAM,SAA4B;EAC/D,OAAO;EACP,aAAa;CACd,CAAC,GACK,IAAc,EAAM,OAA0C,IAAI,GAElE,IAAS,EAAM,aAAa,MAAmB;EACpD,IAAM,IAAU,EAAY;EAE5B,AADA,EAAY,UAAU,MACtB,IAAU,CAAK;CAChB,GAAG,CAAC,CAAC;CAoBL,OAlBA,EAAM,sBACQ;EACZ,EAAO,EAAK;CACb,GACE,CAAC,CAAM,CAAC,GAcJ;EACN,SAbe,EAAM,aACpB,OACA,EAAO,EAAK,GACZ,EAAW,CAAI,GACf,EAAQ,EAAI,GACL,IAAI,SAAkB,MAAY;GACxC,EAAY,UAAU;EACvB,CAAC,IAEF,CAAC,CAAM,CAIP;EACA,aAAa;GACZ;GACA,OAAO,EAAQ;GACf,aAAa,EAAQ;GACrB,cAAc,EAAQ;GACtB,aAAa,EAAQ;GACrB,SAAS,EAAQ;GACjB,eAAe,MAAS;IAEvB,AADA,EAAQ,CAAI,GACP,KACJ,EAAO,EAAK;GAEd;GACA,iBAAiB;IAEhB,AADA,EAAO,EAAI,GACX,EAAQ,EAAK;GACd;EACD;CACD;AACD"}
|
|
@@ -1,7 +1,215 @@
|
|
|
1
1
|
import * as ContextMenuPrimitive from "@radix-ui/react-context-menu";
|
|
2
2
|
import * as React from "react";
|
|
3
|
+
type RadixContextMenuProps = React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Root>;
|
|
4
|
+
type RadixContextMenuTriggerProps = React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Trigger>;
|
|
5
|
+
type RadixContextMenuContentProps = React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Content>;
|
|
6
|
+
type RadixContextMenuItemProps = React.ComponentPropsWithoutRef<typeof ContextMenuPrimitive.Item>;
|
|
7
|
+
export interface ContextMenuProps extends Omit<RadixContextMenuProps, "open" | "onOpenChange" | "dir" | "modal"> {
|
|
8
|
+
/**
|
|
9
|
+
* Controlled open state of the context menu.
|
|
10
|
+
* When set to true before pointer trigger interaction, positions at the top-left of the viewport.
|
|
11
|
+
*/
|
|
12
|
+
open?: RadixContextMenuProps["open"];
|
|
13
|
+
/**
|
|
14
|
+
* Callback invoked when open state changes.
|
|
15
|
+
*/
|
|
16
|
+
onOpenChange?: RadixContextMenuProps["onOpenChange"];
|
|
17
|
+
/**
|
|
18
|
+
* The reading direction of the context menu.
|
|
19
|
+
* @default "ltr"
|
|
20
|
+
*/
|
|
21
|
+
dir?: RadixContextMenuProps["dir"];
|
|
22
|
+
/**
|
|
23
|
+
* Whether the context menu is modal, preventing outside interactions.
|
|
24
|
+
* @default true
|
|
25
|
+
*/
|
|
26
|
+
modal?: RadixContextMenuProps["modal"];
|
|
27
|
+
}
|
|
3
28
|
export declare const ContextMenu: React.FC<ContextMenuPrimitive.ContextMenuProps>;
|
|
29
|
+
export interface ContextMenuTriggerProps extends Omit<RadixContextMenuTriggerProps, "disabled" | "asChild"> {
|
|
30
|
+
/**
|
|
31
|
+
* Disable the context menu trigger from opening on right-click.
|
|
32
|
+
* @default false
|
|
33
|
+
*/
|
|
34
|
+
disabled?: RadixContextMenuTriggerProps["disabled"];
|
|
35
|
+
/**
|
|
36
|
+
* Change the default rendered span element to the child element, merging props and behavior.
|
|
37
|
+
* Trigger forwards ref to HTMLSpanElement and inherits native span attributes.
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
asChild?: RadixContextMenuTriggerProps["asChild"];
|
|
41
|
+
}
|
|
4
42
|
export declare const ContextMenuTrigger: React.ForwardRefExoticComponent<ContextMenuPrimitive.ContextMenuTriggerProps & React.RefAttributes<HTMLSpanElement>>;
|
|
43
|
+
export interface ContextMenuContentProps extends Omit<RadixContextMenuContentProps, "loop" | "alignOffset" | "avoidCollisions" | "collisionBoundary" | "collisionPadding" | "arrowPadding" | "sticky" | "hideWhenDetached" | "forceMount" | "asChild" | "onCloseAutoFocus" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside"> {
|
|
44
|
+
/**
|
|
45
|
+
* Whether keyboard navigation should loop around item boundaries.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
loop?: RadixContextMenuContentProps["loop"];
|
|
49
|
+
/**
|
|
50
|
+
* Offset in pixels from the start or end alignment position.
|
|
51
|
+
* @default 0
|
|
52
|
+
*/
|
|
53
|
+
alignOffset?: RadixContextMenuContentProps["alignOffset"];
|
|
54
|
+
/**
|
|
55
|
+
* Whether to reposition content to avoid viewport boundary collisions.
|
|
56
|
+
* @default true
|
|
57
|
+
*/
|
|
58
|
+
avoidCollisions?: RadixContextMenuContentProps["avoidCollisions"];
|
|
59
|
+
/**
|
|
60
|
+
* Element or elements bounding boundary collision calculations.
|
|
61
|
+
* @default []
|
|
62
|
+
*/
|
|
63
|
+
collisionBoundary?: RadixContextMenuContentProps["collisionBoundary"];
|
|
64
|
+
/**
|
|
65
|
+
* Virtual padding from collision boundaries in pixels.
|
|
66
|
+
* @default 0
|
|
67
|
+
*/
|
|
68
|
+
collisionPadding?: RadixContextMenuContentProps["collisionPadding"];
|
|
69
|
+
/**
|
|
70
|
+
* Padding in pixels between popper arrow and floating panel edge.
|
|
71
|
+
* @default 0
|
|
72
|
+
*/
|
|
73
|
+
arrowPadding?: RadixContextMenuContentProps["arrowPadding"];
|
|
74
|
+
/**
|
|
75
|
+
* Sticky positioning behavior along the align axis when overflowing.
|
|
76
|
+
* @default "partial"
|
|
77
|
+
*/
|
|
78
|
+
sticky?: RadixContextMenuContentProps["sticky"];
|
|
79
|
+
/**
|
|
80
|
+
* Whether to hide content completely when trigger is fully occluded.
|
|
81
|
+
* @default false
|
|
82
|
+
*/
|
|
83
|
+
hideWhenDetached?: RadixContextMenuContentProps["hideWhenDetached"];
|
|
84
|
+
/**
|
|
85
|
+
* Force mounting content in DOM for external animation controls.
|
|
86
|
+
* Note: Bare ContextMenuContent mounts directly without a built-in Portal wrapper.
|
|
87
|
+
*/
|
|
88
|
+
forceMount?: true;
|
|
89
|
+
/**
|
|
90
|
+
* Change the default rendered div element to the child element, merging props and behavior.
|
|
91
|
+
* Content forwards ref to HTMLDivElement and inherits native div attributes.
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
asChild?: RadixContextMenuContentProps["asChild"];
|
|
95
|
+
/**
|
|
96
|
+
* Callback fired when auto-focusing on close. Can be prevented.
|
|
97
|
+
*/
|
|
98
|
+
onCloseAutoFocus?: RadixContextMenuContentProps["onCloseAutoFocus"];
|
|
99
|
+
/**
|
|
100
|
+
* Callback fired when the Escape key is down on the dismissable layer. Can be prevented.
|
|
101
|
+
*/
|
|
102
|
+
onEscapeKeyDown?: RadixContextMenuContentProps["onEscapeKeyDown"];
|
|
103
|
+
/**
|
|
104
|
+
* Callback fired when a pointerdown event happens outside the bounds of the dismissable layer. Can be prevented.
|
|
105
|
+
*/
|
|
106
|
+
onPointerDownOutside?: RadixContextMenuContentProps["onPointerDownOutside"];
|
|
107
|
+
/**
|
|
108
|
+
* Callback fired when focus moves outside the bounds of the dismissable layer. Can be prevented.
|
|
109
|
+
*/
|
|
110
|
+
onFocusOutside?: RadixContextMenuContentProps["onFocusOutside"];
|
|
111
|
+
/**
|
|
112
|
+
* Callback fired when an interaction (pointerdown or focus) happens outside the bounds of the dismissable layer. Can be prevented.
|
|
113
|
+
*/
|
|
114
|
+
onInteractOutside?: RadixContextMenuContentProps["onInteractOutside"];
|
|
115
|
+
}
|
|
5
116
|
export declare const ContextMenuContent: React.ForwardRefExoticComponent<ContextMenuPrimitive.ContextMenuContentProps & React.RefAttributes<HTMLDivElement>>;
|
|
6
|
-
export
|
|
7
|
-
|
|
117
|
+
export interface ContextMenuItemProps extends Omit<RadixContextMenuItemProps, "disabled" | "onSelect" | "textValue" | "asChild"> {
|
|
118
|
+
/**
|
|
119
|
+
* Disable the context menu item.
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
disabled?: RadixContextMenuItemProps["disabled"];
|
|
123
|
+
/**
|
|
124
|
+
* Event handler called when the context menu item is selected (via click or keyboard).
|
|
125
|
+
*/
|
|
126
|
+
onSelect?: RadixContextMenuItemProps["onSelect"];
|
|
127
|
+
/**
|
|
128
|
+
* Optional text used for typeahead navigation. By default typeahead uses item text content.
|
|
129
|
+
*/
|
|
130
|
+
textValue?: RadixContextMenuItemProps["textValue"];
|
|
131
|
+
/**
|
|
132
|
+
* Change the default rendered div element to the child element, merging props and behavior.
|
|
133
|
+
* Item forwards ref to HTMLDivElement and inherits native div attributes.
|
|
134
|
+
* @default false
|
|
135
|
+
*/
|
|
136
|
+
asChild?: RadixContextMenuItemProps["asChild"];
|
|
137
|
+
}
|
|
138
|
+
export declare const ContextMenuItem: React.ForwardRefExoticComponent<ContextMenuItemProps & React.RefAttributes<HTMLDivElement>>;
|
|
139
|
+
export interface ContextMenuPanelProps extends Omit<React.ComponentProps<typeof ContextMenuPrimitive.Content>, "loop" | "alignOffset" | "avoidCollisions" | "collisionBoundary" | "collisionPadding" | "arrowPadding" | "sticky" | "hideWhenDetached" | "forceMount" | "asChild" | "onCloseAutoFocus" | "onEscapeKeyDown" | "onPointerDownOutside" | "onFocusOutside" | "onInteractOutside"> {
|
|
140
|
+
/**
|
|
141
|
+
* Whether keyboard navigation should loop around item boundaries.
|
|
142
|
+
* @default false
|
|
143
|
+
*/
|
|
144
|
+
loop?: RadixContextMenuContentProps["loop"];
|
|
145
|
+
/**
|
|
146
|
+
* Offset in pixels from the start or end alignment position.
|
|
147
|
+
* @default 0
|
|
148
|
+
*/
|
|
149
|
+
alignOffset?: RadixContextMenuContentProps["alignOffset"];
|
|
150
|
+
/**
|
|
151
|
+
* Whether to reposition content to avoid viewport boundary collisions.
|
|
152
|
+
* @default true
|
|
153
|
+
*/
|
|
154
|
+
avoidCollisions?: RadixContextMenuContentProps["avoidCollisions"];
|
|
155
|
+
/**
|
|
156
|
+
* Element or elements bounding boundary collision calculations.
|
|
157
|
+
* @default []
|
|
158
|
+
*/
|
|
159
|
+
collisionBoundary?: RadixContextMenuContentProps["collisionBoundary"];
|
|
160
|
+
/**
|
|
161
|
+
* Virtual padding from collision boundaries in pixels.
|
|
162
|
+
* @default 0
|
|
163
|
+
*/
|
|
164
|
+
collisionPadding?: RadixContextMenuContentProps["collisionPadding"];
|
|
165
|
+
/**
|
|
166
|
+
* Padding in pixels between popper arrow and floating panel edge.
|
|
167
|
+
* @default 0
|
|
168
|
+
*/
|
|
169
|
+
arrowPadding?: RadixContextMenuContentProps["arrowPadding"];
|
|
170
|
+
/**
|
|
171
|
+
* Sticky positioning behavior along the align axis when overflowing.
|
|
172
|
+
* @default "partial"
|
|
173
|
+
*/
|
|
174
|
+
sticky?: RadixContextMenuContentProps["sticky"];
|
|
175
|
+
/**
|
|
176
|
+
* Whether to hide content completely when trigger is fully occluded.
|
|
177
|
+
* @default false
|
|
178
|
+
*/
|
|
179
|
+
hideWhenDetached?: RadixContextMenuContentProps["hideWhenDetached"];
|
|
180
|
+
/**
|
|
181
|
+
* Force mounting content in DOM for external animation controls.
|
|
182
|
+
* When forceMount is true, the content remains mounted even when closed.
|
|
183
|
+
* The caller is responsible for visibility transitions and unmounting after animation completes.
|
|
184
|
+
* Note: Keeping modal content forceMounted may isolate background interactions until unmounted.
|
|
185
|
+
*/
|
|
186
|
+
forceMount?: true;
|
|
187
|
+
/**
|
|
188
|
+
* Change the default rendered div element to the child element, merging props and behavior.
|
|
189
|
+
* Content forwards ref to HTMLDivElement and inherits native div attributes.
|
|
190
|
+
* @default false
|
|
191
|
+
*/
|
|
192
|
+
asChild?: RadixContextMenuContentProps["asChild"];
|
|
193
|
+
/**
|
|
194
|
+
* Callback fired when auto-focusing on close. Can be prevented.
|
|
195
|
+
*/
|
|
196
|
+
onCloseAutoFocus?: RadixContextMenuContentProps["onCloseAutoFocus"];
|
|
197
|
+
/**
|
|
198
|
+
* Callback fired when the Escape key is down on the dismissable layer. Can be prevented.
|
|
199
|
+
*/
|
|
200
|
+
onEscapeKeyDown?: RadixContextMenuContentProps["onEscapeKeyDown"];
|
|
201
|
+
/**
|
|
202
|
+
* Callback fired when a pointerdown event happens outside the bounds of the dismissable layer. Can be prevented.
|
|
203
|
+
*/
|
|
204
|
+
onPointerDownOutside?: RadixContextMenuContentProps["onPointerDownOutside"];
|
|
205
|
+
/**
|
|
206
|
+
* Callback fired when focus moves outside the bounds of the dismissable layer. Can be prevented.
|
|
207
|
+
*/
|
|
208
|
+
onFocusOutside?: RadixContextMenuContentProps["onFocusOutside"];
|
|
209
|
+
/**
|
|
210
|
+
* Callback fired when an interaction (pointerdown or focus) happens outside the bounds of the dismissable layer. Can be prevented.
|
|
211
|
+
*/
|
|
212
|
+
onInteractOutside?: RadixContextMenuContentProps["onInteractOutside"];
|
|
213
|
+
}
|
|
214
|
+
export declare function ContextMenuPanel({ className, ...props }: ContextMenuPanelProps): React.JSX.Element;
|
|
215
|
+
export {};
|
|
@@ -12,10 +12,13 @@ var o = a.Root, s = a.Trigger, c = a.Content, l = r.forwardRef(({ className: n,
|
|
|
12
12
|
}));
|
|
13
13
|
l.displayName = a.Item.displayName;
|
|
14
14
|
function u({ className: t, ...r }) {
|
|
15
|
-
return /* @__PURE__ */ i(a.Portal, {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
return /* @__PURE__ */ i(a.Portal, {
|
|
16
|
+
forceMount: r.forceMount,
|
|
17
|
+
children: /* @__PURE__ */ i(a.Content, {
|
|
18
|
+
className: n(e("min-w-40", t)),
|
|
19
|
+
...r
|
|
20
|
+
})
|
|
21
|
+
});
|
|
19
22
|
}
|
|
20
23
|
//#endregion
|
|
21
24
|
export { o as ContextMenu, c as ContextMenuContent, l as ContextMenuItem, u as ContextMenuPanel, s as ContextMenuTrigger };
|