@trycompai/design-system 1.0.26 → 1.0.28
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/package.json
CHANGED
|
@@ -10,7 +10,7 @@ function Textarea({
|
|
|
10
10
|
<textarea
|
|
11
11
|
data-slot="textarea"
|
|
12
12
|
data-size={size}
|
|
13
|
-
className="border-input dark:bg-input/30 focus-visible:border-primary focus-visible:ring-primary/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 rounded-sm border bg-transparent px-2.5 py-2 text-base transition-colors focus-visible:ring-[3px] aria-invalid:ring-[3px] md:text-sm placeholder:text-muted-foreground flex field-sizing-content min-h-16 min-w-0 w-full resize-y outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[size=sm]:max-w-xs data-[size=default]:max-w-md data-[size=lg]:max-w-xl"
|
|
13
|
+
className="border-input dark:bg-input/30 focus-visible:border-primary focus-visible:ring-primary/30 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:aria-invalid:border-destructive/50 disabled:bg-input/50 dark:disabled:bg-input/80 rounded-sm border bg-transparent px-2.5 py-2 text-base transition-colors focus-visible:ring-[3px] aria-invalid:ring-[3px] md:text-sm placeholder:text-muted-foreground flex field-sizing-content min-h-16 min-w-0 w-full resize-y outline-none disabled:cursor-not-allowed disabled:opacity-50 data-[size=sm]:max-w-xs data-[size=default]:max-w-md data-[size=lg]:max-w-xl data-[size=full]:max-w-none"
|
|
14
14
|
{...props}
|
|
15
15
|
/>
|
|
16
16
|
);
|
|
@@ -5,7 +5,6 @@ import { Dialog as DialogPrimitive } from '@base-ui/react/dialog';
|
|
|
5
5
|
import { Combobox as ComboboxPrimitive } from '@base-ui/react';
|
|
6
6
|
import { Checkmark, ChevronDown, Search } from '@carbon/icons-react';
|
|
7
7
|
import * as React from 'react';
|
|
8
|
-
|
|
9
8
|
// ============================================================================
|
|
10
9
|
// Types
|
|
11
10
|
// ============================================================================
|
|
@@ -54,6 +53,12 @@ export interface OrganizationSelectorProps {
|
|
|
54
53
|
hotkey?: string | null;
|
|
55
54
|
/** Whether to open as a full-screen modal (like Cmd+K) instead of dropdown */
|
|
56
55
|
modal?: boolean;
|
|
56
|
+
/** Optional footer content rendered below the list (e.g., create org action) */
|
|
57
|
+
footer?: React.ReactNode;
|
|
58
|
+
/** Optional label for a create action rendered as the final list item */
|
|
59
|
+
createLabel?: string;
|
|
60
|
+
/** Callback when create action is selected */
|
|
61
|
+
onCreate?: () => void;
|
|
57
62
|
}
|
|
58
63
|
|
|
59
64
|
// ============================================================================
|
|
@@ -124,6 +129,9 @@ function OrganizationSelector({
|
|
|
124
129
|
maxWidth = '150px',
|
|
125
130
|
hotkey = 'o',
|
|
126
131
|
modal = false,
|
|
132
|
+
footer,
|
|
133
|
+
createLabel = 'Create organization',
|
|
134
|
+
onCreate,
|
|
127
135
|
}: OrganizationSelectorProps) {
|
|
128
136
|
const [internalValue, setInternalValue] = React.useState(defaultValue ?? '');
|
|
129
137
|
const [searchQuery, setSearchQuery] = React.useState('');
|
|
@@ -295,6 +303,28 @@ function OrganizationSelector({
|
|
|
295
303
|
</CommandPrimitive.Group>
|
|
296
304
|
)}
|
|
297
305
|
</CommandPrimitive.List>
|
|
306
|
+
{(footer || onCreate) && (
|
|
307
|
+
<div
|
|
308
|
+
data-slot="organization-selector-footer"
|
|
309
|
+
className="border-t border-border p-2"
|
|
310
|
+
>
|
|
311
|
+
{footer ?? (
|
|
312
|
+
<button
|
|
313
|
+
type="button"
|
|
314
|
+
disabled={disabled || loading}
|
|
315
|
+
onClick={() => {
|
|
316
|
+
onCreate?.();
|
|
317
|
+
setSearchQuery('');
|
|
318
|
+
setOpen(false);
|
|
319
|
+
}}
|
|
320
|
+
className="hover:bg-accent hover:text-foreground w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50"
|
|
321
|
+
>
|
|
322
|
+
<span className="mr-1 text-base leading-none">+</span>
|
|
323
|
+
{createLabel}
|
|
324
|
+
</button>
|
|
325
|
+
)}
|
|
326
|
+
</div>
|
|
327
|
+
)}
|
|
298
328
|
</CommandPrimitive>
|
|
299
329
|
</DialogPrimitive.Popup>
|
|
300
330
|
</DialogPrimitive.Portal>
|
|
@@ -365,7 +395,7 @@ function OrganizationSelector({
|
|
|
365
395
|
key={org.id}
|
|
366
396
|
data-slot="organization-selector-item"
|
|
367
397
|
value={org.id}
|
|
368
|
-
className="data-highlighted:bg-accent data-highlighted:text-accent-foreground gap-2 rounded-md py-1.5 pr-8 pl-2 text-sm relative flex w-full cursor-default items-center outline-hidden select-none data-
|
|
398
|
+
className="data-highlighted:bg-accent data-highlighted:text-accent-foreground gap-2 rounded-md py-1.5 pr-8 pl-2 text-sm relative flex w-full cursor-default items-center outline-hidden select-none data-disabled:pointer-events-none data-disabled:opacity-50"
|
|
369
399
|
>
|
|
370
400
|
<OrganizationItemContent org={org} />
|
|
371
401
|
<ComboboxPrimitive.ItemIndicator
|
|
@@ -379,6 +409,28 @@ function OrganizationSelector({
|
|
|
379
409
|
))
|
|
380
410
|
)}
|
|
381
411
|
</ComboboxPrimitive.List>
|
|
412
|
+
{(footer || onCreate) && (
|
|
413
|
+
<div
|
|
414
|
+
data-slot="organization-selector-footer"
|
|
415
|
+
className="border-t border-border p-2"
|
|
416
|
+
>
|
|
417
|
+
{footer ?? (
|
|
418
|
+
<button
|
|
419
|
+
type="button"
|
|
420
|
+
disabled={disabled || loading}
|
|
421
|
+
onClick={() => {
|
|
422
|
+
onCreate?.();
|
|
423
|
+
setSearchQuery('');
|
|
424
|
+
triggerRef.current?.click();
|
|
425
|
+
}}
|
|
426
|
+
className="hover:bg-accent hover:text-foreground w-full rounded-md px-2 py-1.5 text-left text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50"
|
|
427
|
+
>
|
|
428
|
+
<span className="mr-1 text-base leading-none">+</span>
|
|
429
|
+
{createLabel}
|
|
430
|
+
</button>
|
|
431
|
+
)}
|
|
432
|
+
</div>
|
|
433
|
+
)}
|
|
382
434
|
</ComboboxPrimitive.Popup>
|
|
383
435
|
</ComboboxPrimitive.Positioner>
|
|
384
436
|
</ComboboxPrimitive.Portal>
|