@casinogate/ui 1.9.2 → 1.9.5
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/assets/css/root.css +75 -1
- package/dist/assets/css/theme.css +157 -155
- package/dist/components/button/styles.d.ts +18 -0
- package/dist/components/button/styles.js +6 -0
- package/dist/components/combobox/api/create-collection.d.ts +1 -0
- package/dist/components/combobox/api/create-collection.js +2 -0
- package/dist/components/combobox/api/index.d.ts +1 -0
- package/dist/components/combobox/api/index.js +1 -0
- package/dist/components/combobox/combobox.svelte +160 -0
- package/dist/components/combobox/combobox.svelte.d.ts +4 -0
- package/dist/components/combobox/exports.d.ts +1 -0
- package/dist/components/combobox/exports.js +1 -0
- package/dist/components/combobox/index.d.ts +3 -0
- package/dist/components/combobox/index.js +3 -0
- package/dist/components/combobox/styles.d.ts +60 -0
- package/dist/components/combobox/styles.js +49 -0
- package/dist/components/combobox/types.d.ts +22 -0
- package/dist/components/combobox/types.js +1 -0
- package/dist/components/command/api/create-collection.d.ts +2 -0
- package/dist/components/command/api/create-collection.js +25 -0
- package/dist/components/command/api/index.d.ts +1 -0
- package/dist/components/command/api/index.js +1 -0
- package/dist/components/command/command.svelte +94 -0
- package/dist/components/command/command.svelte.d.ts +4 -0
- package/dist/components/command/components/command.empty.svelte +15 -0
- package/dist/components/command/components/command.empty.svelte.d.ts +4 -0
- package/dist/components/command/components/command.group-heading.svelte +10 -0
- package/dist/components/command/components/command.group-heading.svelte.d.ts +4 -0
- package/dist/components/command/components/command.group-items.svelte +8 -0
- package/dist/components/command/components/command.group-items.svelte.d.ts +4 -0
- package/dist/components/command/components/command.group.svelte +23 -0
- package/dist/components/command/components/command.group.svelte.d.ts +4 -0
- package/dist/components/command/components/command.input.svelte +23 -0
- package/dist/components/command/components/command.input.svelte.d.ts +4 -0
- package/dist/components/command/components/command.item.svelte +10 -0
- package/dist/components/command/components/command.item.svelte.d.ts +4 -0
- package/dist/components/command/components/command.list.svelte +16 -0
- package/dist/components/command/components/command.list.svelte.d.ts +4 -0
- package/dist/components/command/components/command.loading.svelte +8 -0
- package/dist/components/command/components/command.loading.svelte.d.ts +4 -0
- package/dist/components/command/components/command.root.svelte +26 -0
- package/dist/components/command/components/command.root.svelte.d.ts +4 -0
- package/dist/components/command/components/command.viewport.svelte +8 -0
- package/dist/components/command/components/command.viewport.svelte.d.ts +4 -0
- package/dist/components/command/exports-primitive.d.ts +12 -0
- package/dist/components/command/exports-primitive.js +12 -0
- package/dist/components/command/exports.d.ts +1 -0
- package/dist/components/command/exports.js +1 -0
- package/dist/components/command/index.d.ts +4 -0
- package/dist/components/command/index.js +4 -0
- package/dist/components/command/styles.d.ts +81 -0
- package/dist/components/command/styles.js +69 -0
- package/dist/components/command/types.d.ts +64 -0
- package/dist/components/command/types.js +1 -0
- package/dist/components/icons/exports.d.ts +2 -0
- package/dist/components/icons/exports.js +2 -0
- package/dist/components/icons/magnifier.svelte +12 -0
- package/dist/components/icons/magnifier.svelte.d.ts +3 -0
- package/dist/components/icons/plus.svelte +9 -0
- package/dist/components/icons/plus.svelte.d.ts +3 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/components/kbd/components/kbd.group.svelte +11 -0
- package/dist/components/kbd/components/kbd.group.svelte.d.ts +4 -0
- package/dist/components/kbd/components/kbd.root.svelte +20 -0
- package/dist/components/kbd/components/kbd.root.svelte.d.ts +4 -0
- package/dist/components/kbd/exports.d.ts +2 -0
- package/dist/components/kbd/exports.js +2 -0
- package/dist/components/kbd/index.d.ts +2 -0
- package/dist/components/kbd/index.js +2 -0
- package/dist/components/kbd/styles.d.ts +5 -0
- package/dist/components/kbd/styles.js +12 -0
- package/dist/components/kbd/types.d.ts +8 -0
- package/dist/components/kbd/types.js +1 -0
- package/dist/components/number-input/components/number-input.root.svelte +102 -0
- package/dist/components/number-input/components/number-input.root.svelte.d.ts +4 -0
- package/dist/components/number-input/exports.d.ts +1 -0
- package/dist/components/number-input/exports.js +1 -0
- package/dist/components/number-input/index.d.ts +2 -0
- package/dist/components/number-input/index.js +2 -0
- package/dist/components/number-input/types.d.ts +9 -0
- package/dist/components/number-input/types.js +1 -0
- package/dist/components/popover/index.d.ts +1 -1
- package/dist/components/select/select.async.svelte +28 -5
- package/dist/components/select/select.svelte +4 -1
- package/dist/components/select/styles.d.ts +1 -1
- package/dist/components/select/styles.js +6 -7
- package/dist/components/select/types.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { boolAttr } from '../../internal/utils/attrs.js';
|
|
3
|
+
import { cn } from '../../internal/utils/common.js';
|
|
4
|
+
import type { AnyFn } from 'svelte-toolbelt';
|
|
5
|
+
import { cubicInOut } from 'svelte/easing';
|
|
6
|
+
import { fly } from 'svelte/transition';
|
|
7
|
+
import { CommandPrimitive, type CommandItem } from '../command/index.js';
|
|
8
|
+
import { Icon as IconComponent } from '../icons/index.js';
|
|
9
|
+
import { Kbd } from '../kbd/index.js';
|
|
10
|
+
import { PopoverPrimitive } from '../popover/index.js';
|
|
11
|
+
import { comboboxTriggerVariants } from './styles.js';
|
|
12
|
+
import type { ComboboxProps } from './types.js';
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
open = $bindable(false),
|
|
16
|
+
value = $bindable(''),
|
|
17
|
+
searchValue = $bindable(''),
|
|
18
|
+
collection,
|
|
19
|
+
empty,
|
|
20
|
+
placeholder = 'Select an option',
|
|
21
|
+
searchPlaceholder,
|
|
22
|
+
trigger: triggerSnippet,
|
|
23
|
+
item: itemSnippet,
|
|
24
|
+
portalDisabled = false,
|
|
25
|
+
allowDeselect = true,
|
|
26
|
+
triggerClass,
|
|
27
|
+
size = 'default',
|
|
28
|
+
variant = 'default',
|
|
29
|
+
rounded = 'default',
|
|
30
|
+
fullWidth = true,
|
|
31
|
+
closeOnSelect = true,
|
|
32
|
+
...restProps
|
|
33
|
+
}: ComboboxProps = $props();
|
|
34
|
+
|
|
35
|
+
const groupMap = $derived(new Map(collection.groups.map((g) => [g.value, g])));
|
|
36
|
+
|
|
37
|
+
const groupedItems = $derived(collection.group());
|
|
38
|
+
|
|
39
|
+
const displayValue = $derived.by(() => {
|
|
40
|
+
const val = collection.items.find((item) => item.value === value)?.label ?? value;
|
|
41
|
+
return val.trim() !== '' ? val : placeholder;
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const isPlaceholder = $derived.by(() => {
|
|
45
|
+
return value.trim() === '';
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const onSelectItem = (item: Omit<CommandItem, 'onSelect'>, onSelect?: AnyFn) => () => {
|
|
49
|
+
onSelect?.();
|
|
50
|
+
|
|
51
|
+
if (item.value === value) {
|
|
52
|
+
value = allowDeselect ? '' : value;
|
|
53
|
+
} else {
|
|
54
|
+
value = item.value;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (closeOnSelect) {
|
|
58
|
+
open = false;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
</script>
|
|
62
|
+
|
|
63
|
+
{#snippet renderTrigger()}
|
|
64
|
+
{@const triggerProps = {
|
|
65
|
+
class: cn(comboboxTriggerVariants({ variant, size, rounded, fullWidth, class: triggerClass })),
|
|
66
|
+
'data-placeholder': boolAttr(isPlaceholder),
|
|
67
|
+
}}
|
|
68
|
+
{#if triggerSnippet}
|
|
69
|
+
<PopoverPrimitive.Trigger {...triggerProps}>
|
|
70
|
+
{#snippet child({ props })}
|
|
71
|
+
{@render triggerSnippet?.({ props, displayValue })}
|
|
72
|
+
{/snippet}
|
|
73
|
+
</PopoverPrimitive.Trigger>
|
|
74
|
+
{:else}
|
|
75
|
+
<PopoverPrimitive.Trigger {...triggerProps}>
|
|
76
|
+
{displayValue}
|
|
77
|
+
</PopoverPrimitive.Trigger>
|
|
78
|
+
{/if}
|
|
79
|
+
{/snippet}
|
|
80
|
+
|
|
81
|
+
{#snippet renderItem(item: CommandItem)}
|
|
82
|
+
{@const { value: itemValue, label, icon: Icon, shortcut, onSelect, ...restItem } = item}
|
|
83
|
+
{@const itemAttrs = {
|
|
84
|
+
value: itemValue,
|
|
85
|
+
onSelect: onSelectItem(item, onSelect),
|
|
86
|
+
'data-selected': boolAttr(itemValue === value),
|
|
87
|
+
...restItem,
|
|
88
|
+
}}
|
|
89
|
+
|
|
90
|
+
{#if itemSnippet}
|
|
91
|
+
<CommandPrimitive.Item {...itemAttrs}>
|
|
92
|
+
{#snippet child({ props })}
|
|
93
|
+
{@render itemSnippet?.({ item, props })}
|
|
94
|
+
{/snippet}
|
|
95
|
+
</CommandPrimitive.Item>
|
|
96
|
+
{:else}
|
|
97
|
+
<CommandPrimitive.Item {...itemAttrs}>
|
|
98
|
+
{#if Icon}
|
|
99
|
+
<Icon width={16} height={16} />
|
|
100
|
+
{/if}
|
|
101
|
+
{label ?? value}
|
|
102
|
+
{#if shortcut && shortcut.length > 0}
|
|
103
|
+
<Kbd.Group>
|
|
104
|
+
{#each shortcut as shortcut (shortcut)}
|
|
105
|
+
<Kbd.Root>{shortcut}</Kbd.Root>
|
|
106
|
+
{/each}
|
|
107
|
+
</Kbd.Group>
|
|
108
|
+
{/if}
|
|
109
|
+
{#if itemValue === value}
|
|
110
|
+
<span
|
|
111
|
+
class="cgui:ms-auto cgui:text-icon-regular cgui:size-4 cgui:flex cgui:items-center cgui:justify-center cgui:shrink-0"
|
|
112
|
+
transition:fly={{ duration: 250, y: 4, easing: cubicInOut }}
|
|
113
|
+
>
|
|
114
|
+
<IconComponent.Checkmark class="cgui:ms-auto" width={16} height={16} />
|
|
115
|
+
</span>
|
|
116
|
+
{/if}
|
|
117
|
+
</CommandPrimitive.Item>
|
|
118
|
+
{/if}
|
|
119
|
+
{/snippet}
|
|
120
|
+
|
|
121
|
+
<PopoverPrimitive.Root bind:open {...restProps}>
|
|
122
|
+
{@render renderTrigger()}
|
|
123
|
+
|
|
124
|
+
<PopoverPrimitive.Portal disabled={portalDisabled}>
|
|
125
|
+
<PopoverPrimitive.Content class="cgui:overflow-hidden cgui:rounded-md">
|
|
126
|
+
<CommandPrimitive.Root>
|
|
127
|
+
<CommandPrimitive.Input bind:value={searchValue} placeholder={searchPlaceholder} />
|
|
128
|
+
|
|
129
|
+
<CommandPrimitive.List class="cgui:rounded-inherit">
|
|
130
|
+
<CommandPrimitive.Viewport>
|
|
131
|
+
<CommandPrimitive.Empty>No results found</CommandPrimitive.Empty>
|
|
132
|
+
|
|
133
|
+
{#each groupedItems as [groupKey, items] (groupKey || '__ungrouped__')}
|
|
134
|
+
{#if groupKey}
|
|
135
|
+
{@const group = groupMap.get(groupKey)}
|
|
136
|
+
<CommandPrimitive.Group value={group?.value}>
|
|
137
|
+
<CommandPrimitive.GroupHeading>{group?.label ?? groupKey}</CommandPrimitive.GroupHeading>
|
|
138
|
+
|
|
139
|
+
<CommandPrimitive.GroupItems>
|
|
140
|
+
{#each items as item (item.value)}
|
|
141
|
+
{@render renderItem(item)}
|
|
142
|
+
{/each}
|
|
143
|
+
</CommandPrimitive.GroupItems>
|
|
144
|
+
|
|
145
|
+
{#if group?.separator}
|
|
146
|
+
<CommandPrimitive.Separator />
|
|
147
|
+
{/if}
|
|
148
|
+
</CommandPrimitive.Group>
|
|
149
|
+
{:else}
|
|
150
|
+
{#each items as item (item.value)}
|
|
151
|
+
{@render renderItem(item)}
|
|
152
|
+
{/each}
|
|
153
|
+
{/if}
|
|
154
|
+
{/each}
|
|
155
|
+
</CommandPrimitive.Viewport>
|
|
156
|
+
</CommandPrimitive.List>
|
|
157
|
+
</CommandPrimitive.Root>
|
|
158
|
+
</PopoverPrimitive.Content>
|
|
159
|
+
</PopoverPrimitive.Portal>
|
|
160
|
+
</PopoverPrimitive.Root>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Root } from './combobox.svelte';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as Root } from './combobox.svelte';
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { VariantProps } from 'tailwind-variants';
|
|
2
|
+
export declare const comboboxTriggerVariants: import("tailwind-variants").TVReturnType<{
|
|
3
|
+
variant: {
|
|
4
|
+
default: string[];
|
|
5
|
+
outline: string[];
|
|
6
|
+
clear: never[];
|
|
7
|
+
};
|
|
8
|
+
size: {
|
|
9
|
+
sm: string[];
|
|
10
|
+
default: string[];
|
|
11
|
+
lg: string[];
|
|
12
|
+
};
|
|
13
|
+
rounded: {
|
|
14
|
+
default: string[];
|
|
15
|
+
md: string[];
|
|
16
|
+
lg: string[];
|
|
17
|
+
};
|
|
18
|
+
fullWidth: {
|
|
19
|
+
true: string[];
|
|
20
|
+
};
|
|
21
|
+
}, undefined, string[], {
|
|
22
|
+
variant: {
|
|
23
|
+
default: string[];
|
|
24
|
+
outline: string[];
|
|
25
|
+
clear: never[];
|
|
26
|
+
};
|
|
27
|
+
size: {
|
|
28
|
+
sm: string[];
|
|
29
|
+
default: string[];
|
|
30
|
+
lg: string[];
|
|
31
|
+
};
|
|
32
|
+
rounded: {
|
|
33
|
+
default: string[];
|
|
34
|
+
md: string[];
|
|
35
|
+
lg: string[];
|
|
36
|
+
};
|
|
37
|
+
fullWidth: {
|
|
38
|
+
true: string[];
|
|
39
|
+
};
|
|
40
|
+
}, undefined, import("tailwind-variants").TVReturnType<{
|
|
41
|
+
variant: {
|
|
42
|
+
default: string[];
|
|
43
|
+
outline: string[];
|
|
44
|
+
clear: never[];
|
|
45
|
+
};
|
|
46
|
+
size: {
|
|
47
|
+
sm: string[];
|
|
48
|
+
default: string[];
|
|
49
|
+
lg: string[];
|
|
50
|
+
};
|
|
51
|
+
rounded: {
|
|
52
|
+
default: string[];
|
|
53
|
+
md: string[];
|
|
54
|
+
lg: string[];
|
|
55
|
+
};
|
|
56
|
+
fullWidth: {
|
|
57
|
+
true: string[];
|
|
58
|
+
};
|
|
59
|
+
}, undefined, string[], unknown, unknown, undefined>>;
|
|
60
|
+
export type ComboboxTriggerVariantsProps = VariantProps<typeof comboboxTriggerVariants>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { tv } from '../../internal/utils/tailwindcss.js';
|
|
2
|
+
export const comboboxTriggerVariants = tv({
|
|
3
|
+
base: [
|
|
4
|
+
'cgui:group/combobox-trigger ',
|
|
5
|
+
'cgui:relative cgui:flex cgui:items-center cgui:gap-1 cgui:flex-wrap',
|
|
6
|
+
'cgui:text-body',
|
|
7
|
+
'cgui:transition-all cgui:duration-250 cgui:ease-in-out',
|
|
8
|
+
'cgui:[&_svg]:shrink-0 cgui:[&_svg]:pointer-events-none cgui:[&_svg]:text-icon-regular cgui:[&_svg:not([class*="size-"])]:size-4',
|
|
9
|
+
'cgui:has-[data-slot=chevron]:pr-3',
|
|
10
|
+
],
|
|
11
|
+
variants: {
|
|
12
|
+
variant: {
|
|
13
|
+
default: [
|
|
14
|
+
'cgui:bg-surface-lightest cgui:border cgui:border-stroke-default',
|
|
15
|
+
'cgui:data-[placeholder]:text-fg-regular/70 cgui:text-fg-dark',
|
|
16
|
+
],
|
|
17
|
+
outline: [
|
|
18
|
+
'cgui:data-[placeholder]:text-fg-regular cgui:text-fg-dark',
|
|
19
|
+
'cgui:border-b cgui:border-b-stroke-default',
|
|
20
|
+
'cgui:rounded-none',
|
|
21
|
+
],
|
|
22
|
+
clear: [],
|
|
23
|
+
},
|
|
24
|
+
size: {
|
|
25
|
+
sm: ['cgui:min-h-7.5', 'cgui:px-2.5 cgui:py-1.5', 'cgui:data-[start-chevron]:pl-8 cgui:data-[end-chevron]:pr-8'],
|
|
26
|
+
default: ['cgui:min-h-9', 'cgui:px-3 cgui:py-2', 'cgui:data-[start-chevron]:pl-10 cgui:data-[end-chevron]:pr-10'],
|
|
27
|
+
lg: [
|
|
28
|
+
'cgui:min-h-11',
|
|
29
|
+
'cgui:text-heading-2',
|
|
30
|
+
'cgui:px-4 cgui:py-2.5',
|
|
31
|
+
'cgui:data-[start-chevron]:pl-14 cgui:data-[end-chevron]:pr-14',
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
rounded: {
|
|
35
|
+
default: ['cgui:rounded-sm'],
|
|
36
|
+
md: ['cgui:rounded-md'],
|
|
37
|
+
lg: ['cgui:rounded-lg'],
|
|
38
|
+
},
|
|
39
|
+
fullWidth: {
|
|
40
|
+
true: ['cgui:w-full'],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
defaultVariants: {
|
|
44
|
+
variant: 'default',
|
|
45
|
+
size: 'default',
|
|
46
|
+
rounded: 'default',
|
|
47
|
+
w: 'full',
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { CommandProps } from '../command/index.js';
|
|
3
|
+
import type { PrimitivePopoverRootProps } from '../popover/types.js';
|
|
4
|
+
import type { ComboboxTriggerVariantsProps } from './styles.js';
|
|
5
|
+
export type ComboboxRootProps = PrimitivePopoverRootProps;
|
|
6
|
+
export type ComboboxProps = PrimitivePopoverRootProps & ComboboxTriggerVariantsProps & {
|
|
7
|
+
collection: CommandProps['collection'];
|
|
8
|
+
value?: string;
|
|
9
|
+
empty?: CommandProps['empty'];
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
searchPlaceholder?: string;
|
|
12
|
+
searchValue?: string;
|
|
13
|
+
portalDisabled?: boolean;
|
|
14
|
+
allowDeselect?: boolean;
|
|
15
|
+
triggerClass?: string;
|
|
16
|
+
closeOnSelect?: boolean;
|
|
17
|
+
trigger?: Snippet<[{
|
|
18
|
+
props: Record<string, unknown>;
|
|
19
|
+
displayValue: string;
|
|
20
|
+
}]>;
|
|
21
|
+
item?: CommandProps['item'];
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createListCollection } from '../../../internal/index.js';
|
|
2
|
+
export const createCollection = (opts) => {
|
|
3
|
+
const { items, groups = [], groupSort } = opts;
|
|
4
|
+
const groupOrderMap = new Map();
|
|
5
|
+
groups.forEach((g, index) => {
|
|
6
|
+
groupOrderMap.set(g.value, g.order ?? index);
|
|
7
|
+
});
|
|
8
|
+
return Object.assign(createListCollection({
|
|
9
|
+
items,
|
|
10
|
+
itemToValue: (item) => item.value,
|
|
11
|
+
itemToString: (item) => item.label ?? item.value,
|
|
12
|
+
isItemDisabled: (item) => !!item.disabled,
|
|
13
|
+
groupBy: (item) => item.group ?? '',
|
|
14
|
+
groupSort: groupSort ??
|
|
15
|
+
((a, b) => {
|
|
16
|
+
const orderA = groupOrderMap.get(a) ?? Infinity;
|
|
17
|
+
const orderB = groupOrderMap.get(b) ?? Infinity;
|
|
18
|
+
if (orderA !== orderB)
|
|
19
|
+
return orderA - orderB;
|
|
20
|
+
return a.localeCompare(b);
|
|
21
|
+
}),
|
|
22
|
+
}), {
|
|
23
|
+
groups,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createCollection } from './create-collection.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { createCollection } from './create-collection.js';
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Kbd } from '../kbd/index.js';
|
|
3
|
+
import { cn } from '../../internal/utils/common.js';
|
|
4
|
+
import * as Primitive from './exports-primitive.js';
|
|
5
|
+
import type { CommandItem, CommandProps } from './types.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
ref = $bindable(null),
|
|
9
|
+
value = $bindable(''),
|
|
10
|
+
searchValue = $bindable(''),
|
|
11
|
+
api = $bindable(null),
|
|
12
|
+
collection,
|
|
13
|
+
placeholder = 'Search...',
|
|
14
|
+
item: itemSnippet,
|
|
15
|
+
empty: emptySnippet = 'No results found',
|
|
16
|
+
maxContentHeight,
|
|
17
|
+
listClass,
|
|
18
|
+
viewportClass,
|
|
19
|
+
...restProps
|
|
20
|
+
}: CommandProps = $props();
|
|
21
|
+
|
|
22
|
+
const groupMap = $derived(new Map(collection.groups.map((g) => [g.value, g])));
|
|
23
|
+
|
|
24
|
+
const groupedItems = $derived(collection.group());
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
{#snippet renderItem(item: CommandItem)}
|
|
28
|
+
{@const { value, label, icon: Icon, shortcut, ...restItem } = item}
|
|
29
|
+
{#if itemSnippet}
|
|
30
|
+
<Primitive.Item {value} {...restItem}>
|
|
31
|
+
{#snippet child({ props })}
|
|
32
|
+
{@render itemSnippet?.({ item, props })}
|
|
33
|
+
{/snippet}
|
|
34
|
+
</Primitive.Item>
|
|
35
|
+
{:else}
|
|
36
|
+
<Primitive.Item {value} {...restItem}>
|
|
37
|
+
{#if Icon}
|
|
38
|
+
<Icon width={16} height={16} />
|
|
39
|
+
{/if}
|
|
40
|
+
{label ?? value}
|
|
41
|
+
{#if shortcut && shortcut.length > 0}
|
|
42
|
+
<Kbd.Group>
|
|
43
|
+
{#each shortcut as shortcut (shortcut)}
|
|
44
|
+
<Kbd.Root>{shortcut}</Kbd.Root>
|
|
45
|
+
{/each}
|
|
46
|
+
</Kbd.Group>
|
|
47
|
+
{/if}
|
|
48
|
+
</Primitive.Item>
|
|
49
|
+
{/if}
|
|
50
|
+
{/snippet}
|
|
51
|
+
|
|
52
|
+
<Primitive.Root bind:api bind:ref bind:value {...restProps}>
|
|
53
|
+
<Primitive.Input bind:value={searchValue} {placeholder} />
|
|
54
|
+
|
|
55
|
+
<Primitive.List
|
|
56
|
+
style={maxContentHeight ? { '--max-content-height': maxContentHeight } : undefined}
|
|
57
|
+
class={cn(listClass, 'cgui:max-h-(--max-content-height)')}
|
|
58
|
+
>
|
|
59
|
+
<Primitive.Viewport class={viewportClass}>
|
|
60
|
+
{#if typeof emptySnippet === 'string'}
|
|
61
|
+
<Primitive.Empty>{emptySnippet}</Primitive.Empty>
|
|
62
|
+
{:else}
|
|
63
|
+
<Primitive.Empty>
|
|
64
|
+
{#snippet child({ props })}
|
|
65
|
+
{@render emptySnippet?.({ props })}
|
|
66
|
+
{/snippet}
|
|
67
|
+
</Primitive.Empty>
|
|
68
|
+
{/if}
|
|
69
|
+
|
|
70
|
+
{#each groupedItems as [groupKey, items] (groupKey || '__ungrouped__')}
|
|
71
|
+
{#if groupKey}
|
|
72
|
+
{@const group = groupMap.get(groupKey)}
|
|
73
|
+
<Primitive.Group value={group?.value}>
|
|
74
|
+
<Primitive.GroupHeading>{group?.label ?? groupKey}</Primitive.GroupHeading>
|
|
75
|
+
|
|
76
|
+
<Primitive.GroupItems>
|
|
77
|
+
{#each items as item (item.value)}
|
|
78
|
+
{@render renderItem(item)}
|
|
79
|
+
{/each}
|
|
80
|
+
</Primitive.GroupItems>
|
|
81
|
+
|
|
82
|
+
{#if group?.separator}
|
|
83
|
+
<Primitive.Separator />
|
|
84
|
+
{/if}
|
|
85
|
+
</Primitive.Group>
|
|
86
|
+
{:else}
|
|
87
|
+
{#each items as item (item.value)}
|
|
88
|
+
{@render renderItem(item)}
|
|
89
|
+
{/each}
|
|
90
|
+
{/if}
|
|
91
|
+
{/each}
|
|
92
|
+
</Primitive.Viewport>
|
|
93
|
+
</Primitive.List>
|
|
94
|
+
</Primitive.Root>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { Command as CommandPrimitive } from 'bits-ui';
|
|
4
|
+
import { commandEmptyVariants } from '../styles.js';
|
|
5
|
+
import type { CommandEmptyProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CommandEmptyProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<CommandPrimitive.Empty
|
|
11
|
+
bind:ref
|
|
12
|
+
data-slot="command-empty"
|
|
13
|
+
class={cn(commandEmptyVariants(), className)}
|
|
14
|
+
{...restProps}
|
|
15
|
+
/>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { Command as CommandPrimitive } from 'bits-ui';
|
|
4
|
+
import { commandGroupHeadingVariants } from '../styles.js';
|
|
5
|
+
import type { CommandGroupHeadingProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CommandGroupHeadingProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<CommandPrimitive.GroupHeading bind:ref class={cn(commandGroupHeadingVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Command as CommandPrimitive } from 'bits-ui';
|
|
3
|
+
import type { CommandGroupItemsProps } from '../types.js';
|
|
4
|
+
|
|
5
|
+
let { ref = $bindable(null), ...restProps }: CommandGroupItemsProps = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<CommandPrimitive.GroupItems bind:ref {...restProps} />
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn, useId } from '../../../internal/utils/common.js';
|
|
3
|
+
import { Command as CommandPrimitive } from 'bits-ui';
|
|
4
|
+
import { commandGroupVariants } from '../styles.js';
|
|
5
|
+
import type { CommandGroupProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, value, ...restProps }: CommandGroupProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<CommandPrimitive.Group
|
|
11
|
+
bind:ref
|
|
12
|
+
data-slot="command-group"
|
|
13
|
+
class={cn(commandGroupVariants(), className)}
|
|
14
|
+
value={value ?? `----${useId()}`}
|
|
15
|
+
{...restProps}
|
|
16
|
+
/>
|
|
17
|
+
<!-- {#if heading}
|
|
18
|
+
<CommandPrimitive.GroupHeading class="text-muted-foreground px-2 py-1.5 text-xs font-medium">
|
|
19
|
+
{heading}
|
|
20
|
+
</CommandPrimitive.GroupHeading>
|
|
21
|
+
{/if}
|
|
22
|
+
<CommandPrimitive.GroupItems {children} />
|
|
23
|
+
</CommandPrimitive.Group> -->
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Icon } from '../../icons/index.js';
|
|
3
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
4
|
+
import { Command as CommandPrimitive } from 'bits-ui';
|
|
5
|
+
import { commandInputVariants } from '../styles.js';
|
|
6
|
+
import type { CommandInputProps } from '../types.js';
|
|
7
|
+
|
|
8
|
+
let { ref = $bindable(null), class: className, value = $bindable(''), ...restProps }: CommandInputProps = $props();
|
|
9
|
+
|
|
10
|
+
const variants = $derived(commandInputVariants({}));
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div class={variants.wrapper()} data-slot="command-input-wrapper">
|
|
14
|
+
<Icon.Magnifier width={16} height={16} class={variants.icon()} />
|
|
15
|
+
|
|
16
|
+
<CommandPrimitive.Input
|
|
17
|
+
data-slot="command-input"
|
|
18
|
+
class={cn(variants.input(), className)}
|
|
19
|
+
bind:ref
|
|
20
|
+
bind:value
|
|
21
|
+
{...restProps}
|
|
22
|
+
/>
|
|
23
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { Command as CommandPrimitive } from 'bits-ui';
|
|
4
|
+
import { commandItemVariants } from '../styles.js';
|
|
5
|
+
import type { CommandItemProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let { ref = $bindable(null), class: className, ...restProps }: CommandItemProps = $props();
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<CommandPrimitive.Item bind:ref data-slot="command-item" class={cn(commandItemVariants(), className)} {...restProps} />
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { Command as CommandPrimitive } from 'bits-ui';
|
|
4
|
+
import type { ClassNameValue } from 'tailwind-merge';
|
|
5
|
+
import { commandListVariants } from '../styles.js';
|
|
6
|
+
import type { CommandListProps } from '../types.js';
|
|
7
|
+
|
|
8
|
+
let { ref = $bindable(null), class: className, ...restProps }: CommandListProps = $props();
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<CommandPrimitive.List
|
|
12
|
+
bind:ref
|
|
13
|
+
data-slot="command-list"
|
|
14
|
+
class={cn(commandListVariants({ class: className as ClassNameValue }))}
|
|
15
|
+
{...restProps}
|
|
16
|
+
/>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { Command as CommandPrimitive } from 'bits-ui';
|
|
3
|
+
import type { CommandLoadingProps } from '../types.js';
|
|
4
|
+
|
|
5
|
+
let { ref = $bindable(null), ...restProps }: CommandLoadingProps = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<CommandPrimitive.Loading bind:ref {...restProps} />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cn } from '../../../internal/utils/common.js';
|
|
3
|
+
import { Command as CommandPrimitive } from 'bits-ui';
|
|
4
|
+
import { commandRootVariants } from '../styles.js';
|
|
5
|
+
import type { CommandRootProps } from '../types.js';
|
|
6
|
+
|
|
7
|
+
let {
|
|
8
|
+
api = $bindable(null),
|
|
9
|
+
ref = $bindable(null),
|
|
10
|
+
value = $bindable(''),
|
|
11
|
+
class: className,
|
|
12
|
+
rounded = 'default',
|
|
13
|
+
shadow = true,
|
|
14
|
+
border = true,
|
|
15
|
+
...restProps
|
|
16
|
+
}: CommandRootProps = $props();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<CommandPrimitive.Root
|
|
20
|
+
bind:this={api}
|
|
21
|
+
bind:value
|
|
22
|
+
bind:ref
|
|
23
|
+
data-slot="command"
|
|
24
|
+
class={cn(commandRootVariants({ rounded, shadow, border }), className)}
|
|
25
|
+
{...restProps}
|
|
26
|
+
/>
|