@brightlocal/ui-components 0.1.2 → 0.1.3
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/dist/accordion.cjs +1 -1
- package/dist/accordion.d.ts +74 -4
- package/dist/accordion.d.ts.map +1 -1
- package/dist/accordion.js +100 -105
- package/dist/alert-dialog.cjs +1 -1
- package/dist/alert-dialog.d.ts +30 -10
- package/dist/alert-dialog.d.ts.map +1 -1
- package/dist/alert-dialog.js +129 -132
- package/dist/alert.d.ts +22 -1
- package/dist/alert.d.ts.map +1 -1
- package/dist/aspect-ratio.cjs +1 -1
- package/dist/aspect-ratio.d.ts +11 -1
- package/dist/aspect-ratio.d.ts.map +1 -1
- package/dist/aspect-ratio.js +16 -20
- package/dist/avatar.cjs +1 -1
- package/dist/avatar.d.ts +43 -3
- package/dist/avatar.d.ts.map +1 -1
- package/dist/avatar.js +18 -16
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts +24 -9
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +34 -32
- package/dist/blocks/data-table.cjs +1 -1
- package/dist/blocks/data-table.d.ts.map +1 -1
- package/dist/blocks/data-table.js +177 -170
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +1 -1
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +154 -154
- package/dist/breadcrumb.cjs +1 -1
- package/dist/breadcrumb.d.ts +63 -8
- package/dist/breadcrumb.d.ts.map +1 -1
- package/dist/breadcrumb.js +97 -93
- package/dist/button.cjs +1 -1
- package/dist/button.d.ts +17 -45
- package/dist/button.d.ts.map +1 -1
- package/dist/button.js +49 -50
- package/dist/calendar.cjs +1 -1
- package/dist/calendar.d.ts +12 -0
- package/dist/calendar.d.ts.map +1 -1
- package/dist/calendar.js +10 -8
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +58 -18
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +60 -51
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +99 -9
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +142 -128
- package/dist/centred-layout.cjs +1 -1
- package/dist/centred-layout.d.ts +18 -2
- package/dist/centred-layout.d.ts.map +1 -1
- package/dist/centred-layout.js +46 -33
- package/dist/chart.cjs +4 -4
- package/dist/chart.d.ts +70 -7
- package/dist/chart.d.ts.map +1 -1
- package/dist/chart.js +71 -66
- package/dist/checkbox.cjs +1 -1
- package/dist/checkbox.d.ts +9 -5
- package/dist/checkbox.d.ts.map +1 -1
- package/dist/checkbox.js +61 -82
- package/dist/collapsible.cjs +1 -1
- package/dist/collapsible.d.ts +65 -8
- package/dist/collapsible.d.ts.map +1 -1
- package/dist/collapsible.js +41 -55
- package/dist/combobox.cjs +1 -1
- package/dist/combobox.d.ts +29 -11
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +193 -159
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +115 -9
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +176 -152
- package/dist/context-menu.cjs +1 -1
- package/dist/context-menu.d.ts +188 -20
- package/dist/context-menu.d.ts.map +1 -1
- package/dist/context-menu.js +119 -121
- package/dist/date-picker.cjs +1 -1
- package/dist/date-picker.d.ts +75 -9
- package/dist/date-picker.d.ts.map +1 -1
- package/dist/date-picker.js +220 -81
- package/dist/description.cjs +1 -0
- package/dist/description.d.ts +37 -0
- package/dist/description.d.ts.map +1 -0
- package/dist/description.js +25 -0
- package/dist/dialog.cjs +1 -1
- package/dist/dialog.d.ts +73 -9
- package/dist/dialog.d.ts.map +1 -1
- package/dist/dialog.js +103 -112
- package/dist/drawer.cjs +1 -1
- package/dist/drawer.d.ts +92 -0
- package/dist/drawer.d.ts.map +1 -1
- package/dist/drawer.js +67 -52
- package/dist/dropdown-menu.cjs +1 -1
- package/dist/dropdown-menu.d.ts +95 -11
- package/dist/dropdown-menu.d.ts.map +1 -1
- package/dist/dropdown-menu.js +146 -106
- package/dist/field.cjs +1 -1
- package/dist/field.d.ts +23 -6
- package/dist/field.d.ts.map +1 -1
- package/dist/field.js +54 -53
- package/dist/global-layout.cjs +1 -1
- package/dist/global-layout.d.ts +27 -17
- package/dist/global-layout.d.ts.map +1 -1
- package/dist/global-layout.js +86 -79
- package/dist/hover-card.cjs +1 -1
- package/dist/hover-card.d.ts +36 -6
- package/dist/hover-card.d.ts.map +1 -1
- package/dist/hover-card.js +44 -42
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +383 -387
- package/dist/input-group.cjs +1 -1
- package/dist/input-group.d.ts +21 -2
- package/dist/input-group.d.ts.map +1 -1
- package/dist/input-group.js +51 -41
- package/dist/input-password.cjs +1 -1
- package/dist/input-password.d.ts.map +1 -1
- package/dist/input-password.js +24 -25
- package/dist/input.cjs +1 -1
- package/dist/input.d.ts +38 -24
- package/dist/input.d.ts.map +1 -1
- package/dist/input.js +68 -136
- package/dist/label.cjs +1 -1
- package/dist/label.d.ts +20 -1
- package/dist/label.d.ts.map +1 -1
- package/dist/label.js +31 -18
- package/dist/logo.cjs +1 -1
- package/dist/logo.d.ts +3 -0
- package/dist/logo.d.ts.map +1 -1
- package/dist/logo.js +12 -10
- package/dist/menubar.cjs +1 -1
- package/dist/menubar.d.ts +40 -6
- package/dist/menubar.d.ts.map +1 -1
- package/dist/menubar.js +97 -76
- package/dist/popover.cjs +1 -1
- package/dist/popover.d.ts +59 -4
- package/dist/popover.d.ts.map +1 -1
- package/dist/popover.js +42 -34
- package/dist/progress.cjs +1 -1
- package/dist/progress.d.ts +9 -2
- package/dist/progress.d.ts.map +1 -1
- package/dist/progress.js +71 -59
- package/dist/radio-group.d.ts +40 -0
- package/dist/radio-group.d.ts.map +1 -1
- package/dist/rating.d.ts +4 -0
- package/dist/rating.d.ts.map +1 -1
- package/dist/resizable.cjs +1 -1
- package/dist/resizable.d.ts +65 -4
- package/dist/resizable.d.ts.map +1 -1
- package/dist/resizable.js +53 -36
- package/dist/scroll-area.cjs +1 -1
- package/dist/scroll-area.d.ts +46 -5
- package/dist/scroll-area.d.ts.map +1 -1
- package/dist/scroll-area.js +42 -38
- package/dist/select.cjs +1 -1
- package/dist/select.d.ts +30 -0
- package/dist/select.d.ts.map +1 -1
- package/dist/select.js +64 -54
- package/dist/separator.cjs +1 -1
- package/dist/separator.d.ts +49 -2
- package/dist/separator.d.ts.map +1 -1
- package/dist/separator.js +48 -36
- package/dist/sheet.cjs +1 -1
- package/dist/sheet.d.ts +80 -9
- package/dist/sheet.d.ts.map +1 -1
- package/dist/sheet.js +117 -113
- package/dist/skeleton.cjs +1 -1
- package/dist/skeleton.d.ts +24 -2
- package/dist/skeleton.d.ts.map +1 -1
- package/dist/skeleton.js +15 -9
- package/dist/slider.cjs +1 -1
- package/dist/slider.d.ts +18 -4
- package/dist/slider.d.ts.map +1 -1
- package/dist/slider.js +72 -66
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts +4 -2
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +29 -28
- package/dist/split-layout.d.ts +4 -1
- package/dist/split-layout.d.ts.map +1 -1
- package/package.json +8 -2
- package/src/blocks/data-table.tsx +42 -32
- package/src/blocks/sidebar.tsx +4 -12
- package/src/components/accordion.tsx +163 -77
- package/src/components/alert-dialog.tsx +156 -111
- package/src/components/alert.tsx +26 -13
- package/src/components/aspect-ratio.tsx +25 -16
- package/src/components/avatar.tsx +56 -8
- package/src/components/badge.tsx +65 -42
- package/src/components/breadcrumb.tsx +158 -82
- package/src/components/button.tsx +41 -62
- package/src/components/calendar.tsx +16 -2
- package/src/components/card.tsx +92 -40
- package/src/components/carousel.tsx +240 -115
- package/src/components/centred-layout.tsx +67 -35
- package/src/components/chart.tsx +118 -47
- package/src/components/checkbox.tsx +42 -78
- package/src/components/collapsible.tsx +95 -26
- package/src/components/combobox.tsx +242 -144
- package/src/components/command.tsx +295 -121
- package/src/components/context-menu.tsx +278 -81
- package/src/components/date-picker.tsx +281 -30
- package/src/components/description.tsx +60 -0
- package/src/components/dialog.tsx +162 -86
- package/src/components/drawer.tsx +76 -2
- package/src/components/dropdown-menu.tsx +143 -37
- package/src/components/field.tsx +36 -11
- package/src/components/global-layout.tsx +116 -77
- package/src/components/hover-card.tsx +54 -14
- package/src/components/input-group.tsx +56 -18
- package/src/components/input-password.tsx +3 -4
- package/src/components/input.tsx +93 -186
- package/src/components/label.tsx +56 -15
- package/src/components/logo.tsx +3 -0
- package/src/components/menubar.tsx +58 -4
- package/src/components/popover.tsx +103 -20
- package/src/components/progress.tsx +82 -60
- package/src/components/radio-group.tsx +40 -0
- package/src/components/rating.tsx +4 -0
- package/src/components/resizable.tsx +119 -31
- package/src/components/scroll-area.tsx +123 -56
- package/src/components/select.tsx +21 -1
- package/src/components/separator.tsx +97 -20
- package/src/components/sheet.tsx +180 -79
- package/src/components/skeleton.tsx +40 -10
- package/src/components/slider.tsx +83 -57
- package/src/components/sonner.tsx +10 -7
- package/src/components/split-layout.tsx +4 -1
- package/src/index.ts +1 -1
- package/dist/input-base.cjs +0 -1
- package/dist/input-base.d.ts +0 -28
- package/dist/input-base.d.ts.map +0 -1
- package/dist/input-base.js +0 -56
- package/src/components/input-base.tsx +0 -86
|
@@ -2,199 +2,372 @@
|
|
|
2
2
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Command as CommandPrimitive } from "cmdk";
|
|
5
|
-
import { SearchIcon } from "lucide-react";
|
|
5
|
+
import { CheckIcon, SearchIcon, XIcon } from "lucide-react";
|
|
6
6
|
|
|
7
|
+
import { Button } from "@brightlocal/ui-components/button";
|
|
7
8
|
import { cn } from "@brightlocal/ui-components/lib/utils";
|
|
8
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Props for the Command component
|
|
12
|
+
*/
|
|
9
13
|
export interface CommandProps extends React.ComponentProps<
|
|
10
14
|
typeof CommandPrimitive
|
|
11
15
|
> {
|
|
12
|
-
|
|
16
|
+
/**
|
|
17
|
+
* Data hook for automated testing (required)
|
|
18
|
+
*/
|
|
19
|
+
dataHook: string;
|
|
20
|
+
/**
|
|
21
|
+
* Tracking element identifier for analytics
|
|
22
|
+
*/
|
|
13
23
|
trackingEl?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Tracking label for analytics context
|
|
26
|
+
*/
|
|
14
27
|
trackingLabel?: string;
|
|
15
28
|
}
|
|
16
29
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
/**
|
|
31
|
+
* A composable command menu component built with cmdk.
|
|
32
|
+
* Provides search functionality with keyboard navigation.
|
|
33
|
+
*/
|
|
34
|
+
const Command = React.forwardRef<
|
|
35
|
+
React.ComponentRef<typeof CommandPrimitive>,
|
|
36
|
+
CommandProps
|
|
37
|
+
>(({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => (
|
|
38
|
+
<CommandPrimitive
|
|
39
|
+
ref={ref}
|
|
40
|
+
className={cn(
|
|
41
|
+
"bg-popover text-popover-foreground flex w-full flex-col overflow-hidden rounded-lg border shadow-md",
|
|
42
|
+
className
|
|
43
|
+
)}
|
|
44
|
+
data-hook={dataHook}
|
|
45
|
+
data-slot="command"
|
|
46
|
+
data-tracking-el={trackingEl}
|
|
47
|
+
data-tracking-label={trackingLabel}
|
|
48
|
+
{...props}
|
|
49
|
+
/>
|
|
50
|
+
));
|
|
51
|
+
Command.displayName = "Command";
|
|
38
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Props for the CommandInput component
|
|
55
|
+
*/
|
|
39
56
|
export interface CommandInputProps extends React.ComponentProps<
|
|
40
57
|
typeof CommandPrimitive.Input
|
|
41
58
|
> {
|
|
59
|
+
/**
|
|
60
|
+
* Data hook for automated testing
|
|
61
|
+
*/
|
|
42
62
|
dataHook?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Tracking element identifier for analytics
|
|
65
|
+
*/
|
|
43
66
|
trackingEl?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Tracking label for analytics context
|
|
69
|
+
*/
|
|
44
70
|
trackingLabel?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Callback when clear button is clicked
|
|
73
|
+
*/
|
|
74
|
+
onClear?: () => void;
|
|
45
75
|
}
|
|
46
76
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
77
|
+
/**
|
|
78
|
+
* Search input for the Command component.
|
|
79
|
+
* Includes a search icon and optional clear button.
|
|
80
|
+
*/
|
|
81
|
+
const CommandInput = React.forwardRef<
|
|
82
|
+
React.ComponentRef<typeof CommandPrimitive.Input>,
|
|
83
|
+
CommandInputProps
|
|
84
|
+
>(
|
|
85
|
+
(
|
|
86
|
+
{
|
|
87
|
+
className,
|
|
88
|
+
dataHook,
|
|
89
|
+
trackingEl,
|
|
90
|
+
trackingLabel,
|
|
91
|
+
value: controlledValue,
|
|
92
|
+
onValueChange,
|
|
93
|
+
onClear,
|
|
94
|
+
...props
|
|
95
|
+
},
|
|
96
|
+
ref
|
|
97
|
+
) => {
|
|
98
|
+
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
99
|
+
const [internalValue, setInternalValue] = React.useState("");
|
|
100
|
+
|
|
101
|
+
// Merge refs
|
|
102
|
+
React.useImperativeHandle(ref, () => inputRef.current!, []);
|
|
103
|
+
|
|
104
|
+
const isControlled = controlledValue !== undefined;
|
|
105
|
+
const value = isControlled ? controlledValue : internalValue;
|
|
106
|
+
const showClearButton = String(value).length > 0;
|
|
107
|
+
|
|
108
|
+
const handleValueChange = (newValue: string) => {
|
|
109
|
+
if (!isControlled) {
|
|
110
|
+
setInternalValue(newValue);
|
|
111
|
+
}
|
|
112
|
+
onValueChange?.(newValue);
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const handleClear = () => {
|
|
116
|
+
if (!isControlled) {
|
|
117
|
+
setInternalValue("");
|
|
118
|
+
}
|
|
119
|
+
onValueChange?.("");
|
|
120
|
+
onClear?.();
|
|
121
|
+
inputRef.current?.focus();
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return (
|
|
125
|
+
<div
|
|
126
|
+
className="border-base-border flex h-12 items-center gap-2 self-stretch border-b px-3"
|
|
127
|
+
data-hook={dataHook}
|
|
128
|
+
data-slot="command-input-wrapper"
|
|
129
|
+
>
|
|
130
|
+
<SearchIcon className="size-4 shrink-0 opacity-50" />
|
|
131
|
+
<CommandPrimitive.Input
|
|
132
|
+
ref={inputRef}
|
|
133
|
+
className={cn(
|
|
134
|
+
"placeholder:text-muted-foreground flex w-full bg-transparent text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",
|
|
135
|
+
className
|
|
136
|
+
)}
|
|
137
|
+
data-slot="command-input"
|
|
138
|
+
data-tracking-el={trackingEl}
|
|
139
|
+
data-tracking-label={trackingLabel}
|
|
140
|
+
value={value}
|
|
141
|
+
onValueChange={handleValueChange}
|
|
142
|
+
{...props}
|
|
143
|
+
/>
|
|
144
|
+
{showClearButton && (
|
|
145
|
+
<Button
|
|
146
|
+
aria-label="Clear search"
|
|
147
|
+
className="text-muted-foreground hover:text-foreground"
|
|
148
|
+
dataHook="command-input-clear"
|
|
149
|
+
variant="ghost"
|
|
150
|
+
onClick={handleClear}
|
|
151
|
+
>
|
|
152
|
+
<XIcon className="size-4" />
|
|
153
|
+
</Button>
|
|
65
154
|
)}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
</div>
|
|
72
|
-
);
|
|
73
|
-
}
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
);
|
|
159
|
+
CommandInput.displayName = "CommandInput";
|
|
74
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Props for the CommandList component
|
|
163
|
+
*/
|
|
75
164
|
export interface CommandListProps extends React.ComponentProps<
|
|
76
165
|
typeof CommandPrimitive.List
|
|
77
166
|
> {
|
|
167
|
+
/**
|
|
168
|
+
* Data hook for automated testing
|
|
169
|
+
*/
|
|
78
170
|
dataHook?: string;
|
|
79
171
|
}
|
|
80
172
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
173
|
+
/**
|
|
174
|
+
* Scrollable container for command items.
|
|
175
|
+
*/
|
|
176
|
+
const CommandList = React.forwardRef<
|
|
177
|
+
React.ComponentRef<typeof CommandPrimitive.List>,
|
|
178
|
+
CommandListProps
|
|
179
|
+
>(({ className, dataHook, ...props }, ref) => (
|
|
180
|
+
<CommandPrimitive.List
|
|
181
|
+
ref={ref}
|
|
182
|
+
className={cn(
|
|
183
|
+
"max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto",
|
|
184
|
+
className
|
|
185
|
+
)}
|
|
186
|
+
data-hook={dataHook}
|
|
187
|
+
data-slot="command-list"
|
|
188
|
+
{...props}
|
|
189
|
+
/>
|
|
190
|
+
));
|
|
191
|
+
CommandList.displayName = "CommandList";
|
|
94
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Props for the CommandEmpty component
|
|
195
|
+
*/
|
|
95
196
|
export interface CommandEmptyProps extends React.ComponentProps<
|
|
96
197
|
typeof CommandPrimitive.Empty
|
|
97
198
|
> {
|
|
199
|
+
/**
|
|
200
|
+
* Data hook for automated testing
|
|
201
|
+
*/
|
|
98
202
|
dataHook?: string;
|
|
99
203
|
}
|
|
100
204
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
205
|
+
/**
|
|
206
|
+
* Empty state displayed when no results are found.
|
|
207
|
+
*/
|
|
208
|
+
const CommandEmpty = React.forwardRef<
|
|
209
|
+
React.ComponentRef<typeof CommandPrimitive.Empty>,
|
|
210
|
+
CommandEmptyProps
|
|
211
|
+
>(({ dataHook, ...props }, ref) => (
|
|
212
|
+
<CommandPrimitive.Empty
|
|
213
|
+
ref={ref}
|
|
214
|
+
className="py-6 text-center text-sm"
|
|
215
|
+
data-hook={dataHook}
|
|
216
|
+
data-slot="command-empty"
|
|
217
|
+
{...props}
|
|
218
|
+
/>
|
|
219
|
+
));
|
|
220
|
+
CommandEmpty.displayName = "CommandEmpty";
|
|
111
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Props for the CommandGroup component
|
|
224
|
+
*/
|
|
112
225
|
export interface CommandGroupProps extends React.ComponentProps<
|
|
113
226
|
typeof CommandPrimitive.Group
|
|
114
227
|
> {
|
|
228
|
+
/**
|
|
229
|
+
* Data hook for automated testing
|
|
230
|
+
*/
|
|
115
231
|
dataHook?: string;
|
|
116
232
|
}
|
|
117
233
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
234
|
+
/**
|
|
235
|
+
* Groups related command items with an optional heading.
|
|
236
|
+
*/
|
|
237
|
+
const CommandGroup = React.forwardRef<
|
|
238
|
+
React.ComponentRef<typeof CommandPrimitive.Group>,
|
|
239
|
+
CommandGroupProps
|
|
240
|
+
>(({ className, dataHook, ...props }, ref) => (
|
|
241
|
+
<CommandPrimitive.Group
|
|
242
|
+
ref={ref}
|
|
243
|
+
className={cn(
|
|
244
|
+
"text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden px-2 py-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium",
|
|
245
|
+
className
|
|
246
|
+
)}
|
|
247
|
+
data-hook={dataHook}
|
|
248
|
+
data-slot="command-group"
|
|
249
|
+
{...props}
|
|
250
|
+
/>
|
|
251
|
+
));
|
|
252
|
+
CommandGroup.displayName = "CommandGroup";
|
|
131
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Props for the CommandSeparator component
|
|
256
|
+
*/
|
|
132
257
|
export interface CommandSeparatorProps extends React.ComponentProps<
|
|
133
258
|
typeof CommandPrimitive.Separator
|
|
134
259
|
> {
|
|
260
|
+
/**
|
|
261
|
+
* Data hook for automated testing
|
|
262
|
+
*/
|
|
135
263
|
dataHook?: string;
|
|
136
264
|
}
|
|
137
265
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
266
|
+
/**
|
|
267
|
+
* Visual separator between command groups.
|
|
268
|
+
*/
|
|
269
|
+
const CommandSeparator = React.forwardRef<
|
|
270
|
+
React.ComponentRef<typeof CommandPrimitive.Separator>,
|
|
271
|
+
CommandSeparatorProps
|
|
272
|
+
>(({ className, dataHook, ...props }, ref) => (
|
|
273
|
+
<CommandPrimitive.Separator
|
|
274
|
+
ref={ref}
|
|
275
|
+
className={cn("bg-border -mx-1 h-px", className)}
|
|
276
|
+
data-hook={dataHook}
|
|
277
|
+
data-slot="command-separator"
|
|
278
|
+
{...props}
|
|
279
|
+
/>
|
|
280
|
+
));
|
|
281
|
+
CommandSeparator.displayName = "CommandSeparator";
|
|
152
282
|
|
|
283
|
+
/**
|
|
284
|
+
* Props for the CommandItem component
|
|
285
|
+
*/
|
|
153
286
|
export interface CommandItemProps extends React.ComponentProps<
|
|
154
287
|
typeof CommandPrimitive.Item
|
|
155
288
|
> {
|
|
289
|
+
/**
|
|
290
|
+
* Data hook for automated testing
|
|
291
|
+
*/
|
|
156
292
|
dataHook?: string;
|
|
293
|
+
/**
|
|
294
|
+
* Tracking element identifier for analytics
|
|
295
|
+
*/
|
|
157
296
|
trackingEl?: string;
|
|
297
|
+
/**
|
|
298
|
+
* Tracking label for analytics context
|
|
299
|
+
*/
|
|
158
300
|
trackingLabel?: string;
|
|
301
|
+
/**
|
|
302
|
+
* Whether the item is selected (shows checkmark)
|
|
303
|
+
*/
|
|
304
|
+
selected?: boolean;
|
|
159
305
|
}
|
|
160
306
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
307
|
+
/**
|
|
308
|
+
* Interactive item within the command list.
|
|
309
|
+
*/
|
|
310
|
+
const CommandItem = React.forwardRef<
|
|
311
|
+
React.ComponentRef<typeof CommandPrimitive.Item>,
|
|
312
|
+
CommandItemProps
|
|
313
|
+
>(
|
|
314
|
+
(
|
|
315
|
+
{
|
|
316
|
+
className,
|
|
317
|
+
dataHook,
|
|
318
|
+
trackingEl,
|
|
319
|
+
trackingLabel,
|
|
320
|
+
selected,
|
|
321
|
+
children,
|
|
322
|
+
...props
|
|
323
|
+
},
|
|
324
|
+
ref
|
|
325
|
+
) => (
|
|
169
326
|
<CommandPrimitive.Item
|
|
327
|
+
ref={ref}
|
|
170
328
|
className={cn(
|
|
171
|
-
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-
|
|
329
|
+
"data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground data-[disabled=true]:text-muted-foreground relative flex cursor-default items-center gap-2 rounded-sm px-2 py-3 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
172
330
|
className
|
|
173
331
|
)}
|
|
174
332
|
data-hook={dataHook}
|
|
333
|
+
data-selected-item={selected || undefined}
|
|
175
334
|
data-slot="command-item"
|
|
176
335
|
data-tracking-el={trackingEl}
|
|
177
336
|
data-tracking-label={trackingLabel}
|
|
178
337
|
{...props}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
}
|
|
338
|
+
>
|
|
339
|
+
{children}
|
|
340
|
+
{selected && <CheckIcon className="text-foreground ml-auto size-4" />}
|
|
341
|
+
</CommandPrimitive.Item>
|
|
342
|
+
)
|
|
343
|
+
);
|
|
344
|
+
CommandItem.displayName = "CommandItem";
|
|
182
345
|
|
|
346
|
+
/**
|
|
347
|
+
* Props for the CommandShortcut component
|
|
348
|
+
*/
|
|
183
349
|
export interface CommandShortcutProps extends React.ComponentProps<"span"> {
|
|
350
|
+
/**
|
|
351
|
+
* Data hook for automated testing
|
|
352
|
+
*/
|
|
184
353
|
dataHook?: string;
|
|
354
|
+
/**
|
|
355
|
+
* Tracking element identifier for analytics
|
|
356
|
+
*/
|
|
185
357
|
trackingEl?: string;
|
|
358
|
+
/**
|
|
359
|
+
* Tracking label for analytics context
|
|
360
|
+
*/
|
|
186
361
|
trackingLabel?: string;
|
|
187
362
|
}
|
|
188
363
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
trackingLabel,
|
|
194
|
-
...props
|
|
195
|
-
}: CommandShortcutProps) {
|
|
196
|
-
return (
|
|
364
|
+
/**
|
|
365
|
+
* Displays keyboard shortcut for a command item.
|
|
366
|
+
*/
|
|
367
|
+
const CommandShortcut = React.forwardRef<HTMLSpanElement, CommandShortcutProps>(
|
|
368
|
+
({ className, dataHook, trackingEl, trackingLabel, ...props }, ref) => (
|
|
197
369
|
<span
|
|
370
|
+
ref={ref}
|
|
198
371
|
className={cn(
|
|
199
372
|
"text-muted-foreground ml-auto text-xs tracking-widest",
|
|
200
373
|
className
|
|
@@ -205,8 +378,9 @@ function CommandShortcut({
|
|
|
205
378
|
data-tracking-label={trackingLabel}
|
|
206
379
|
{...props}
|
|
207
380
|
/>
|
|
208
|
-
)
|
|
209
|
-
|
|
381
|
+
)
|
|
382
|
+
);
|
|
383
|
+
CommandShortcut.displayName = "CommandShortcut";
|
|
210
384
|
|
|
211
385
|
export {
|
|
212
386
|
Command,
|