@diegopluna/narvi 0.4.1 → 0.5.1
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 +3 -1
- package/dist/base.css +3 -0
- package/dist/components/app-shell/AppShellPanel.svelte +3 -2
- package/dist/components/button/Button.svelte +29 -17
- package/dist/components/checkbox/Checkbox.svelte +106 -54
- package/dist/components/checkbox/Checkbox.svelte.d.ts +22 -8
- package/dist/components/choice-cards/ChoiceCards.svelte +68 -39
- package/dist/components/choice-cards/ChoiceCards.svelte.d.ts +12 -8
- package/dist/components/collapsible/CollapsibleContent.svelte +71 -17
- package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +14 -10
- package/dist/components/collapsible/CollapsibleRoot.svelte +13 -9
- package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +8 -9
- package/dist/components/collapsible/CollapsibleTrigger.svelte +24 -15
- package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +10 -14
- package/dist/components/color-field/ColorField.svelte +13 -7
- package/dist/components/command/CommandDialog.svelte +30 -20
- package/dist/components/command/CommandDialog.svelte.d.ts +4 -3
- package/dist/components/command/CommandEmpty.svelte +11 -9
- package/dist/components/command/CommandEmpty.svelte.d.ts +6 -17
- package/dist/components/command/CommandGroup.svelte +32 -11
- package/dist/components/command/CommandGroup.svelte.d.ts +7 -11
- package/dist/components/command/CommandInput.svelte +25 -10
- package/dist/components/command/CommandInput.svelte.d.ts +8 -12
- package/dist/components/command/CommandItem.svelte +67 -29
- package/dist/components/command/CommandItem.svelte.d.ts +6 -32
- package/dist/components/command/CommandList.svelte +8 -10
- package/dist/components/command/CommandList.svelte.d.ts +6 -8
- package/dist/components/command/CommandRoot.svelte +247 -57
- package/dist/components/command/CommandRoot.svelte.d.ts +14 -28
- package/dist/components/command/CommandSeparator.svelte +18 -0
- package/dist/components/command/CommandSeparator.svelte.d.ts +7 -0
- package/dist/components/command/context.d.ts +27 -0
- package/dist/components/command/context.js +16 -0
- package/dist/components/command/index.d.ts +6 -4
- package/dist/components/command/index.js +5 -4
- package/dist/components/command/score.d.ts +27 -0
- package/dist/components/command/score.js +77 -0
- package/dist/components/command/styles.d.ts +32 -9
- package/dist/components/command/styles.js +42 -14
- package/dist/components/composer/ComposerModelPicker.svelte +350 -346
- package/dist/components/composer/ComposerModelPicker.svelte.d.ts +6 -3
- package/dist/components/composer/ComposerRoot.svelte.d.ts +1 -1
- package/dist/components/dialog/ConfirmDialog.svelte +73 -53
- package/dist/components/dialog/DialogClose.svelte +17 -0
- package/dist/components/dialog/DialogClose.svelte.d.ts +10 -0
- package/dist/components/dialog/DialogContent.svelte +35 -33
- package/dist/components/dialog/DialogContent.svelte.d.ts +6 -20
- package/dist/components/dialog/DialogDescription.svelte +9 -12
- package/dist/components/dialog/DialogDescription.svelte.d.ts +6 -8
- package/dist/components/dialog/DialogRoot.svelte +20 -0
- package/dist/components/dialog/DialogRoot.svelte.d.ts +7 -0
- package/dist/components/dialog/DialogTitle.svelte +12 -8
- package/dist/components/dialog/DialogTitle.svelte.d.ts +8 -8
- package/dist/components/dialog/DialogTrigger.svelte +17 -0
- package/dist/components/dialog/DialogTrigger.svelte.d.ts +10 -0
- package/dist/components/dialog/index.d.ts +6 -5
- package/dist/components/dialog/index.js +3 -6
- package/dist/components/dialog/styles.d.ts +1 -2
- package/dist/components/dialog/styles.js +11 -8
- package/dist/components/hover-card/HoverCardContent.svelte +35 -29
- package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -12
- package/dist/components/hover-card/HoverCardRoot.svelte +7 -7
- package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +5 -4
- package/dist/components/hover-card/HoverCardTrigger.svelte +18 -0
- package/dist/components/hover-card/HoverCardTrigger.svelte.d.ts +10 -0
- package/dist/components/hover-card/index.d.ts +2 -3
- package/dist/components/hover-card/index.js +1 -5
- package/dist/components/input/Input.svelte.d.ts +1 -1
- package/dist/components/markdown/MarkdownBlock.svelte +6 -3
- package/dist/components/markdown/MarkdownTable.svelte +15 -7
- package/dist/components/menu/ContextMenuContent.svelte +15 -15
- package/dist/components/menu/ContextMenuContent.svelte.d.ts +6 -9
- package/dist/components/menu/ContextMenuTrigger.svelte +14 -16
- package/dist/components/menu/ContextMenuTrigger.svelte.d.ts +8 -14
- package/dist/components/menu/MenuCheckboxItem.svelte +22 -11
- package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +8 -22
- package/dist/components/menu/MenuContent.svelte +16 -18
- package/dist/components/menu/MenuContent.svelte.d.ts +6 -18
- package/dist/components/menu/MenuGroup.svelte +4 -4
- package/dist/components/menu/MenuGroup.svelte.d.ts +5 -4
- package/dist/components/menu/MenuItem.svelte +25 -12
- package/dist/components/menu/MenuItem.svelte.d.ts +6 -21
- package/dist/components/menu/MenuLabel.svelte +7 -11
- package/dist/components/menu/MenuLabel.svelte.d.ts +6 -8
- package/dist/components/menu/MenuRadioGroup.svelte +4 -4
- package/dist/components/menu/MenuRadioGroup.svelte.d.ts +5 -4
- package/dist/components/menu/MenuRadioItem.svelte +16 -14
- package/dist/components/menu/MenuRadioItem.svelte.d.ts +6 -19
- package/dist/components/menu/MenuSeparator.svelte +6 -10
- package/dist/components/menu/MenuSeparator.svelte.d.ts +6 -7
- package/dist/components/menu/MenuSubContent.svelte +22 -19
- package/dist/components/menu/MenuSubContent.svelte.d.ts +8 -15
- package/dist/components/menu/MenuSubTrigger.svelte +7 -11
- package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -15
- package/dist/components/menu/MenuTrigger.svelte +17 -0
- package/dist/components/menu/MenuTrigger.svelte.d.ts +10 -0
- package/dist/components/menu/context-menu.d.ts +2 -2
- package/dist/components/menu/context-menu.js +3 -2
- package/dist/components/menu/group.js +1 -1
- package/dist/components/menu/index.d.ts +5 -4
- package/dist/components/menu/index.js +5 -5
- package/dist/components/menu/row.d.ts +20 -0
- package/dist/components/menu/row.js +12 -0
- package/dist/components/popover/PopoverClose.svelte +17 -0
- package/dist/components/popover/PopoverClose.svelte.d.ts +10 -0
- package/dist/components/popover/PopoverContent.svelte +30 -29
- package/dist/components/popover/PopoverContent.svelte.d.ts +6 -17
- package/dist/components/popover/PopoverTrigger.svelte +17 -0
- package/dist/components/popover/PopoverTrigger.svelte.d.ts +10 -0
- package/dist/components/popover/index.d.ts +6 -4
- package/dist/components/popover/index.js +6 -5
- package/dist/components/progress/Progress.svelte +16 -22
- package/dist/components/progress/Progress.svelte.d.ts +6 -5
- package/dist/components/reasoning/ReasoningRoot.svelte.d.ts +1 -1
- package/dist/components/resize-handle/ResizeHandle.svelte +80 -14
- package/dist/components/resize-handle/ResizeHandle.svelte.d.ts +15 -1
- package/dist/components/segmented/SegmentedControl.svelte +100 -91
- package/dist/components/segmented/SegmentedControl.svelte.d.ts +6 -4
- package/dist/components/select/Select.svelte +97 -59
- package/dist/components/select/Select.svelte.d.ts +3 -2
- package/dist/components/sheet/SheetContent.svelte +31 -38
- package/dist/components/sheet/SheetContent.svelte.d.ts +7 -22
- package/dist/components/sheet/index.d.ts +3 -5
- package/dist/components/sheet/index.js +3 -5
- package/dist/components/sheet/styles.js +26 -5
- package/dist/components/sidebar/SidebarItem.svelte +2 -3
- package/dist/components/slider/Slider.svelte +86 -65
- package/dist/components/slider/Slider.svelte.d.ts +9 -8
- package/dist/components/split-button/SplitButton.svelte +20 -3
- package/dist/components/split-button/SplitButton.svelte.d.ts +1 -1
- package/dist/components/switch/Switch.svelte +77 -49
- package/dist/components/switch/Switch.svelte.d.ts +15 -8
- package/dist/components/tab-strip/TabStrip.svelte +87 -68
- package/dist/components/tabs/Tabs.svelte +129 -99
- package/dist/components/tabs/Tabs.svelte.d.ts +6 -4
- package/dist/components/textarea/Textarea.svelte.d.ts +1 -1
- package/dist/components/toast/Toaster.svelte +132 -115
- package/dist/components/toast/Toaster.svelte.d.ts +5 -0
- package/dist/components/toast/toasts.svelte.d.ts +10 -23
- package/dist/components/toast/toasts.svelte.js +62 -40
- package/dist/components/toggle/Toggle.svelte +15 -9
- package/dist/components/toggle/Toggle.svelte.d.ts +8 -17
- package/dist/components/toggle-group/ToggleGroupItem.svelte +20 -9
- package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +10 -10
- package/dist/components/toggle-group/ToggleGroupRoot.svelte +33 -18
- package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +4 -4
- package/dist/components/tool/ToolRoot.svelte.d.ts +1 -1
- package/dist/components/tooltip/TooltipContent.svelte +38 -28
- package/dist/components/tooltip/TooltipContent.svelte.d.ts +6 -15
- package/dist/components/tooltip/TooltipProvider.svelte +34 -10
- package/dist/components/tooltip/TooltipProvider.svelte.d.ts +18 -4
- package/dist/components/tooltip/TooltipRoot.svelte +52 -23
- package/dist/components/tooltip/TooltipRoot.svelte.d.ts +10 -10
- package/dist/components/tooltip/TooltipTrigger.svelte +14 -17
- package/dist/components/tooltip/TooltipTrigger.svelte.d.ts +10 -4
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/components/tooltip/index.js +1 -1
- package/dist/components/work-fold/WorkFold.svelte +14 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +1 -1
- package/dist/internal/TooltipScope.svelte +4 -4
- package/dist/internal/layer.d.ts +11 -9
- package/dist/internal/layer.js +21 -15
- package/dist/internal/loose.d.ts +30 -5
- package/dist/internal/loose.js +1 -1
- package/dist/internal/markers.stylex.d.ts +0 -4
- package/dist/internal/markers.stylex.js +0 -2
- package/dist/internal/toggle.d.ts +3 -0
- package/dist/internal/toggle.js +6 -2
- package/dist/internal/tooltip-trigger.d.ts +7 -6
- package/dist/internal/tooltip-trigger.js +9 -12
- package/dist/vite.d.ts +7 -1
- package/dist/vite.js +20 -5
- package/package.json +3 -2
- package/skills/building-ui/SKILL.md +22 -22
- package/skills/building-ui/references/components.md +30 -4
- package/skills/markdown/SKILL.md +1 -1
- package/skills/setup/SKILL.md +4 -8
- package/skills/styling/SKILL.md +1 -1
- package/skills/theming/SKILL.md +3 -7
|
@@ -1,28 +1,49 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { Loose } from '../../internal/loose.js';
|
|
3
|
-
import {
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { CommandGroup as UiCommandGroup, CommandGroupLabel } from '@ui-sdk/svelte/command';
|
|
4
4
|
import * as stylex from '@stylexjs/stylex';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
6
|
+
import { SvelteMap } from 'svelte/reactivity';
|
|
6
7
|
import { layer } from '../../internal/layer.js';
|
|
7
|
-
import type
|
|
8
|
+
import { attrs, type Sx } from '../../internal/sx.js';
|
|
9
|
+
import { provideCommandGroup } from './context.js';
|
|
10
|
+
import { command } from './styles.js';
|
|
8
11
|
|
|
9
|
-
export
|
|
10
|
-
Omit<
|
|
12
|
+
export interface CommandGroupProps extends Loose<
|
|
13
|
+
Omit<PartProps<typeof UiCommandGroup>, 'children' | 'render'> & {
|
|
11
14
|
/** The group's name, shown above its items. */
|
|
12
15
|
heading?: string | undefined;
|
|
13
16
|
sx?: Sx | undefined;
|
|
14
17
|
children?: Snippet | undefined;
|
|
15
18
|
}
|
|
16
|
-
|
|
19
|
+
> {}
|
|
17
20
|
</script>
|
|
18
21
|
|
|
19
22
|
<script lang="ts">
|
|
20
|
-
let { heading, sx, children, ...rest }: CommandGroupProps = $props();
|
|
23
|
+
let { heading, style, sx, class: className, children, ...rest }: CommandGroupProps = $props();
|
|
24
|
+
|
|
25
|
+
// The place of each item that matches the search: the group goes where its best one would
|
|
26
|
+
const places = new SvelteMap<string, number>();
|
|
27
|
+
provideCommandGroup({
|
|
28
|
+
place(id, order) {
|
|
29
|
+
if (order === undefined) places.delete(id);
|
|
30
|
+
else if (places.get(id) !== order) places.set(id, order);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
const order = $derived(places.size ? Math.min(...places.values()) : undefined);
|
|
21
34
|
</script>
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
<!-- It hides while none of its items matches the search -->
|
|
37
|
+
<UiCommandGroup
|
|
38
|
+
{...rest}
|
|
39
|
+
style={[order === undefined ? '' : `order: ${order}`, style ?? ''].filter(Boolean).join('; ') ||
|
|
40
|
+
undefined}
|
|
41
|
+
{...attrs([command.group, sx], className)}
|
|
42
|
+
>
|
|
24
43
|
{#if heading}
|
|
25
|
-
<
|
|
44
|
+
<CommandGroupLabel {...stylex.attrs(layer.heading, command.groupHeading)}
|
|
45
|
+
>{heading}</CommandGroupLabel
|
|
46
|
+
>
|
|
26
47
|
{/if}
|
|
27
|
-
|
|
28
|
-
</
|
|
48
|
+
{@render children?.()}
|
|
49
|
+
</UiCommandGroup>
|
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import type { Loose } from '../../internal/loose.js';
|
|
2
|
-
import {
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { CommandGroup as UiCommandGroup } from '@ui-sdk/svelte/command';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
|
-
import type
|
|
5
|
-
export
|
|
4
|
+
import { type Sx } from '../../internal/sx.js';
|
|
5
|
+
export interface CommandGroupProps extends Loose<Omit<PartProps<typeof UiCommandGroup>, 'children' | 'render'> & {
|
|
6
6
|
/** The group's name, shown above its items. */
|
|
7
7
|
heading?: string | undefined;
|
|
8
8
|
sx?: Sx | undefined;
|
|
9
9
|
children?: Snippet | undefined;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
heading?: string | undefined;
|
|
14
|
-
sx?: Sx | undefined;
|
|
15
|
-
children?: Snippet | undefined;
|
|
16
|
-
}>, {}, "">;
|
|
10
|
+
}> {
|
|
11
|
+
}
|
|
12
|
+
declare const CommandGroup: import("svelte").Component<CommandGroupProps, {}, "">;
|
|
17
13
|
type CommandGroup = ReturnType<typeof CommandGroup>;
|
|
18
14
|
export default CommandGroup;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { Loose } from '../../internal/loose.js';
|
|
3
|
-
import {
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { CommandInput as UiCommandInput } from '@ui-sdk/svelte/command';
|
|
4
4
|
import * as stylex from '@stylexjs/stylex';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
6
6
|
import Glyph from '../../internal/Glyph.svelte';
|
|
7
7
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
8
|
+
import { useCommand } from './context.js';
|
|
8
9
|
import { command } from './styles.js';
|
|
9
10
|
|
|
10
|
-
export
|
|
11
|
-
Omit<
|
|
11
|
+
export interface CommandInputProps extends Loose<
|
|
12
|
+
Omit<PartProps<typeof UiCommandInput>, 'children' | 'render' | 'value'> & {
|
|
13
|
+
/** What has been typed, which the list is searched by. Bindable. */
|
|
14
|
+
value?: string | undefined;
|
|
12
15
|
/**
|
|
13
16
|
* After the field, in its row: a button or two, such as a filter or how to search, or a
|
|
14
17
|
* Spinner while results are on their way.
|
|
@@ -16,7 +19,7 @@
|
|
|
16
19
|
end?: Snippet | undefined;
|
|
17
20
|
sx?: Sx | undefined;
|
|
18
21
|
}
|
|
19
|
-
|
|
22
|
+
> {}
|
|
20
23
|
</script>
|
|
21
24
|
|
|
22
25
|
<script lang="ts">
|
|
@@ -24,22 +27,34 @@
|
|
|
24
27
|
value = $bindable(''),
|
|
25
28
|
placeholder = 'Search for a command…',
|
|
26
29
|
end,
|
|
30
|
+
onkeydown,
|
|
27
31
|
sx,
|
|
28
32
|
class: className,
|
|
29
33
|
...rest
|
|
30
34
|
}: CommandInputProps = $props();
|
|
35
|
+
|
|
36
|
+
const root = useCommand();
|
|
37
|
+
|
|
38
|
+
// The search is the root's in ui-sdk; this field's `value` is lent to it
|
|
39
|
+
$effect.pre(() =>
|
|
40
|
+
root?.bindQuery(
|
|
41
|
+
() => value,
|
|
42
|
+
(next) => (value = next)
|
|
43
|
+
)
|
|
44
|
+
);
|
|
31
45
|
</script>
|
|
32
46
|
|
|
33
47
|
<!-- Focus stays here while the arrow keys move through the list -->
|
|
34
48
|
<div {...stylex.attrs(command.search)}>
|
|
35
49
|
<Glyph name="search" />
|
|
36
|
-
<
|
|
37
|
-
bind:value
|
|
50
|
+
<UiCommandInput
|
|
38
51
|
{placeholder}
|
|
39
|
-
|
|
40
|
-
spellcheck={false}
|
|
41
|
-
data-slot="command-input"
|
|
52
|
+
aria-label={root?.label()}
|
|
42
53
|
{...rest}
|
|
54
|
+
onkeydown={(event: KeyboardEvent & { currentTarget: EventTarget & HTMLInputElement }) => {
|
|
55
|
+
onkeydown?.(event);
|
|
56
|
+
root?.keydown(event);
|
|
57
|
+
}}
|
|
43
58
|
{...attrs([command.input, sx], className)}
|
|
44
59
|
/>
|
|
45
60
|
{#if end}<div data-slot="command-input-end" {...stylex.attrs(command.end)}>
|
|
@@ -1,22 +1,18 @@
|
|
|
1
|
-
import type { Loose } from '../../internal/loose.js';
|
|
2
|
-
import {
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { CommandInput as UiCommandInput } from '@ui-sdk/svelte/command';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
|
-
export
|
|
5
|
+
export interface CommandInputProps extends Loose<Omit<PartProps<typeof UiCommandInput>, 'children' | 'render' | 'value'> & {
|
|
6
|
+
/** What has been typed, which the list is searched by. Bindable. */
|
|
7
|
+
value?: string | undefined;
|
|
6
8
|
/**
|
|
7
9
|
* After the field, in its row: a button or two, such as a filter or how to search, or a
|
|
8
10
|
* Spinner while results are on their way.
|
|
9
11
|
*/
|
|
10
12
|
end?: Snippet | undefined;
|
|
11
13
|
sx?: Sx | undefined;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
* After the field, in its row: a button or two, such as a filter or how to search, or a
|
|
16
|
-
* Spinner while results are on their way.
|
|
17
|
-
*/
|
|
18
|
-
end?: Snippet | undefined;
|
|
19
|
-
sx?: Sx | undefined;
|
|
20
|
-
}>, {}, "value">;
|
|
14
|
+
}> {
|
|
15
|
+
}
|
|
16
|
+
declare const CommandInput: import("svelte").Component<CommandInputProps, {}, "value">;
|
|
21
17
|
type CommandInput = ReturnType<typeof CommandInput>;
|
|
22
18
|
export default CommandInput;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { Loose } from '../../internal/loose.js';
|
|
3
|
-
import {
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { CommandItem as UiCommandItem } from '@ui-sdk/svelte/command';
|
|
4
4
|
import * as stylex from '@stylexjs/stylex';
|
|
5
5
|
import type { Snippet } from 'svelte';
|
|
6
6
|
import { layer } from '../../internal/layer.js';
|
|
7
7
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
8
8
|
import Kbd from '../kbd/Kbd.svelte';
|
|
9
|
+
import { useCommand, useCommandGroup } from './context.js';
|
|
10
|
+
import { orderOf } from './score.js';
|
|
9
11
|
import { command } from './styles.js';
|
|
10
12
|
|
|
11
|
-
export
|
|
12
|
-
Omit<
|
|
13
|
+
export interface CommandItemProps extends Loose<
|
|
14
|
+
Omit<PartProps<typeof UiCommandItem>, 'children' | 'render' | 'shortcut'> & {
|
|
13
15
|
/** A 16px icon before the label. */
|
|
14
16
|
icon?: Snippet | undefined;
|
|
15
17
|
/**
|
|
@@ -37,11 +39,15 @@
|
|
|
37
39
|
sx?: Sx | undefined;
|
|
38
40
|
children?: Snippet | undefined;
|
|
39
41
|
}
|
|
40
|
-
|
|
42
|
+
> {}
|
|
41
43
|
</script>
|
|
42
44
|
|
|
43
45
|
<script lang="ts">
|
|
44
46
|
let {
|
|
47
|
+
value,
|
|
48
|
+
label,
|
|
49
|
+
keywords,
|
|
50
|
+
style,
|
|
45
51
|
icon,
|
|
46
52
|
detail,
|
|
47
53
|
wrapDetail = false,
|
|
@@ -50,37 +56,69 @@
|
|
|
50
56
|
hint = '↵',
|
|
51
57
|
sx,
|
|
52
58
|
class: className,
|
|
53
|
-
children,
|
|
59
|
+
children: content,
|
|
54
60
|
...rest
|
|
55
61
|
}: CommandItemProps = $props();
|
|
62
|
+
|
|
63
|
+
// An item without a value still has one, which the root's bound `value` reports
|
|
64
|
+
const generated = $props.id();
|
|
65
|
+
const key = $derived(value ?? `narvi-${generated}`);
|
|
66
|
+
|
|
67
|
+
// While the search ranks the list, the item goes by how well it matches: the best first.
|
|
68
|
+
// It matches its `label`, its `value`, or, with neither, its words, as ui-sdk's search does.
|
|
69
|
+
const root = useCommand();
|
|
70
|
+
const group = useCommandGroup();
|
|
71
|
+
let element = $state<HTMLElement | null>(null);
|
|
72
|
+
const score = $derived(
|
|
73
|
+
root?.score({ label: label ?? value ?? element?.textContent ?? '', keywords })
|
|
74
|
+
);
|
|
75
|
+
const order = $derived(score === undefined || score <= 0 ? undefined : orderOf(score));
|
|
76
|
+
$effect(() => group?.place(generated, order));
|
|
77
|
+
$effect(() => () => group?.place(generated, undefined));
|
|
78
|
+
const hold = (node: HTMLElement) => {
|
|
79
|
+
element = node;
|
|
80
|
+
return () => {
|
|
81
|
+
if (element === node) element = null;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
56
84
|
</script>
|
|
57
85
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<span {...stylex.attrs(
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
86
|
+
<!-- The search matches `value`, as bits-ui's did; without one, the item's words -->
|
|
87
|
+
<UiCommandItem
|
|
88
|
+
value={key}
|
|
89
|
+
label={label ?? value}
|
|
90
|
+
{keywords}
|
|
91
|
+
data-value={key}
|
|
92
|
+
{...rest}
|
|
93
|
+
style={[order === undefined ? '' : `order: ${order}`, style ?? ''].filter(Boolean).join('; ') ||
|
|
94
|
+
undefined}
|
|
95
|
+
{@attach hold}
|
|
96
|
+
{...attrs([command.item, sx], className)}
|
|
97
|
+
>
|
|
98
|
+
{#snippet children(state)}
|
|
99
|
+
{#if icon}<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>{/if}
|
|
100
|
+
{#if wrapDetail && detail}
|
|
101
|
+
<span {...stylex.attrs(command.wrapRow)}>
|
|
102
|
+
<span {...stylex.attrs(command.wrapLabel)}>{@render name()}</span>
|
|
103
|
+
<span {...stylex.attrs(command.wrapped)}>{@render detailText()}</span>
|
|
104
|
+
</span>
|
|
105
|
+
{:else}
|
|
106
|
+
<span {...stylex.attrs(layer.label, command.label)}>
|
|
107
|
+
{@render name()}
|
|
108
|
+
{#if detail}<span {...stylex.attrs(command.detail)}>{@render detailText()}</span>{/if}
|
|
77
109
|
</span>
|
|
78
|
-
|
|
110
|
+
{/if}
|
|
111
|
+
<span {...stylex.attrs(layer.trailing)}>
|
|
112
|
+
{#if shortcut}{shortcut}{/if}
|
|
113
|
+
<!-- Enter is the way to choose, shown only on the highlighted row -->
|
|
114
|
+
{#if hint !== null && state.highlighted}<Kbd>{hint}</Kbd>{/if}
|
|
115
|
+
</span>
|
|
79
116
|
{/snippet}
|
|
80
|
-
</
|
|
117
|
+
</UiCommandItem>
|
|
81
118
|
|
|
82
|
-
|
|
83
|
-
|
|
119
|
+
<!-- The words give way before the badge does, so a long label never hides it -->
|
|
120
|
+
{#snippet name()}
|
|
121
|
+
<span {...stylex.attrs(command.name)}>{@render content?.()}</span>
|
|
84
122
|
{#if badge}<span data-icons {...stylex.attrs(command.badge)}>{@render badge()}</span>{/if}
|
|
85
123
|
{/snippet}
|
|
86
124
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { Loose } from '../../internal/loose.js';
|
|
2
|
-
import {
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { CommandItem as UiCommandItem } from '@ui-sdk/svelte/command';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
|
-
export
|
|
5
|
+
export interface CommandItemProps extends Loose<Omit<PartProps<typeof UiCommandItem>, 'children' | 'render' | 'shortcut'> & {
|
|
6
6
|
/** A 16px icon before the label. */
|
|
7
7
|
icon?: Snippet | undefined;
|
|
8
8
|
/**
|
|
@@ -29,34 +29,8 @@ export type CommandItemProps = Loose<Omit<Command.ItemProps, 'children' | 'child
|
|
|
29
29
|
shortcut?: string | undefined;
|
|
30
30
|
sx?: Sx | undefined;
|
|
31
31
|
children?: Snippet | undefined;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
icon?: Snippet | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* A quieter note after the label, such as where a thread lives: words, or a snippet,
|
|
38
|
-
* such as one with the words that match the search marked.
|
|
39
|
-
*/
|
|
40
|
-
detail?: string | Snippet | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* Lets the detail wrap to a second line, rather than be cut short, where its end
|
|
43
|
-
* matters: a path. It gives way before the label does.
|
|
44
|
-
*/
|
|
45
|
-
wrapDetail?: boolean | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Right after the label, before the detail: a mark such as a connected service's, or a
|
|
48
|
-
* Badge. An icon in it is 14px.
|
|
49
|
-
*/
|
|
50
|
-
badge?: Snippet | undefined;
|
|
51
|
-
/**
|
|
52
|
-
* What the key cap on the highlighted item says Enter does. `↵` by default; words such
|
|
53
|
-
* as "Open" for an item that does something of its own, or `null` for none.
|
|
54
|
-
*/
|
|
55
|
-
hint?: string | null | undefined;
|
|
56
|
-
/** The keys that do the same from anywhere, such as "⌘N". */
|
|
57
|
-
shortcut?: string | undefined;
|
|
58
|
-
sx?: Sx | undefined;
|
|
59
|
-
children?: Snippet | undefined;
|
|
60
|
-
}>, {}, "">;
|
|
32
|
+
}> {
|
|
33
|
+
}
|
|
34
|
+
declare const CommandItem: import("svelte").Component<CommandItemProps, {}, "">;
|
|
61
35
|
type CommandItem = ReturnType<typeof CommandItem>;
|
|
62
36
|
export default CommandItem;
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
<script lang="ts" module>
|
|
2
|
-
import type { Loose } from '../../internal/loose.js';
|
|
3
|
-
import {
|
|
2
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
3
|
+
import { CommandList as UiCommandList } from '@ui-sdk/svelte/command';
|
|
4
4
|
import type { Snippet } from 'svelte';
|
|
5
5
|
import { attrs, type Sx } from '../../internal/sx.js';
|
|
6
6
|
import { command } from './styles.js';
|
|
7
7
|
|
|
8
|
-
export
|
|
9
|
-
Omit<
|
|
8
|
+
export interface CommandListProps extends Loose<
|
|
9
|
+
Omit<PartProps<typeof UiCommandList>, 'children' | 'render'> & {
|
|
10
10
|
sx?: Sx | undefined;
|
|
11
11
|
children?: Snippet | undefined;
|
|
12
12
|
}
|
|
13
|
-
|
|
13
|
+
> {}
|
|
14
14
|
</script>
|
|
15
15
|
|
|
16
16
|
<script lang="ts">
|
|
17
17
|
let { sx, class: className, children, ...rest }: CommandListProps = $props();
|
|
18
18
|
</script>
|
|
19
19
|
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
</Command.Viewport>
|
|
24
|
-
</Command.List>
|
|
20
|
+
<UiCommandList {...rest} {...attrs([command.list, sx], className)}>
|
|
21
|
+
{@render children?.()}
|
|
22
|
+
</UiCommandList>
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type { Loose } from '../../internal/loose.js';
|
|
2
|
-
import {
|
|
1
|
+
import type { Loose, PartProps } from '../../internal/loose.js';
|
|
2
|
+
import { CommandList as UiCommandList } from '@ui-sdk/svelte/command';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
4
|
import { type Sx } from '../../internal/sx.js';
|
|
5
|
-
export
|
|
5
|
+
export interface CommandListProps extends Loose<Omit<PartProps<typeof UiCommandList>, 'children' | 'render'> & {
|
|
6
6
|
sx?: Sx | undefined;
|
|
7
7
|
children?: Snippet | undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
children?: Snippet | undefined;
|
|
12
|
-
}>, {}, "">;
|
|
8
|
+
}> {
|
|
9
|
+
}
|
|
10
|
+
declare const CommandList: import("svelte").Component<CommandListProps, {}, "">;
|
|
13
11
|
type CommandList = ReturnType<typeof CommandList>;
|
|
14
12
|
export default CommandList;
|