@diegopluna/narvi 0.4.0 → 0.5.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.
Files changed (183) hide show
  1. package/README.md +3 -1
  2. package/dist/base.css +3 -0
  3. package/dist/components/button/Button.svelte +29 -17
  4. package/dist/components/checkbox/Checkbox.svelte +106 -54
  5. package/dist/components/checkbox/Checkbox.svelte.d.ts +22 -8
  6. package/dist/components/choice-cards/ChoiceCards.svelte +68 -39
  7. package/dist/components/choice-cards/ChoiceCards.svelte.d.ts +12 -8
  8. package/dist/components/collapsible/CollapsibleContent.svelte +71 -17
  9. package/dist/components/collapsible/CollapsibleContent.svelte.d.ts +14 -10
  10. package/dist/components/collapsible/CollapsibleRoot.svelte +13 -9
  11. package/dist/components/collapsible/CollapsibleRoot.svelte.d.ts +8 -9
  12. package/dist/components/collapsible/CollapsibleTrigger.svelte +24 -15
  13. package/dist/components/collapsible/CollapsibleTrigger.svelte.d.ts +10 -14
  14. package/dist/components/color-field/ColorField.svelte +13 -7
  15. package/dist/components/command/CommandDialog.svelte +30 -20
  16. package/dist/components/command/CommandDialog.svelte.d.ts +4 -3
  17. package/dist/components/command/CommandEmpty.svelte +11 -9
  18. package/dist/components/command/CommandEmpty.svelte.d.ts +6 -17
  19. package/dist/components/command/CommandGroup.svelte +32 -11
  20. package/dist/components/command/CommandGroup.svelte.d.ts +7 -11
  21. package/dist/components/command/CommandInput.svelte +25 -10
  22. package/dist/components/command/CommandInput.svelte.d.ts +8 -12
  23. package/dist/components/command/CommandItem.svelte +67 -29
  24. package/dist/components/command/CommandItem.svelte.d.ts +6 -32
  25. package/dist/components/command/CommandList.svelte +8 -10
  26. package/dist/components/command/CommandList.svelte.d.ts +6 -8
  27. package/dist/components/command/CommandRoot.svelte +247 -57
  28. package/dist/components/command/CommandRoot.svelte.d.ts +14 -28
  29. package/dist/components/command/CommandSeparator.svelte +18 -0
  30. package/dist/components/command/CommandSeparator.svelte.d.ts +7 -0
  31. package/dist/components/command/context.d.ts +27 -0
  32. package/dist/components/command/context.js +16 -0
  33. package/dist/components/command/index.d.ts +6 -4
  34. package/dist/components/command/index.js +5 -4
  35. package/dist/components/command/score.d.ts +27 -0
  36. package/dist/components/command/score.js +77 -0
  37. package/dist/components/command/styles.d.ts +32 -9
  38. package/dist/components/command/styles.js +42 -14
  39. package/dist/components/composer/ComposerModelPicker.svelte +365 -347
  40. package/dist/components/composer/ComposerModelPicker.svelte.d.ts +6 -3
  41. package/dist/components/composer/ComposerRoot.svelte.d.ts +1 -1
  42. package/dist/components/dialog/ConfirmDialog.svelte +73 -53
  43. package/dist/components/dialog/DialogClose.svelte +17 -0
  44. package/dist/components/dialog/DialogClose.svelte.d.ts +10 -0
  45. package/dist/components/dialog/DialogContent.svelte +35 -33
  46. package/dist/components/dialog/DialogContent.svelte.d.ts +6 -20
  47. package/dist/components/dialog/DialogDescription.svelte +9 -12
  48. package/dist/components/dialog/DialogDescription.svelte.d.ts +6 -8
  49. package/dist/components/dialog/DialogRoot.svelte +20 -0
  50. package/dist/components/dialog/DialogRoot.svelte.d.ts +7 -0
  51. package/dist/components/dialog/DialogTitle.svelte +12 -8
  52. package/dist/components/dialog/DialogTitle.svelte.d.ts +8 -8
  53. package/dist/components/dialog/DialogTrigger.svelte +17 -0
  54. package/dist/components/dialog/DialogTrigger.svelte.d.ts +10 -0
  55. package/dist/components/dialog/index.d.ts +6 -5
  56. package/dist/components/dialog/index.js +3 -6
  57. package/dist/components/dialog/styles.d.ts +1 -2
  58. package/dist/components/dialog/styles.js +11 -8
  59. package/dist/components/hover-card/HoverCardContent.svelte +35 -29
  60. package/dist/components/hover-card/HoverCardContent.svelte.d.ts +8 -12
  61. package/dist/components/hover-card/HoverCardRoot.svelte +7 -7
  62. package/dist/components/hover-card/HoverCardRoot.svelte.d.ts +5 -4
  63. package/dist/components/hover-card/HoverCardTrigger.svelte +18 -0
  64. package/dist/components/hover-card/HoverCardTrigger.svelte.d.ts +10 -0
  65. package/dist/components/hover-card/index.d.ts +2 -3
  66. package/dist/components/hover-card/index.js +1 -5
  67. package/dist/components/input/Input.svelte.d.ts +1 -1
  68. package/dist/components/markdown/MarkdownBlock.svelte +6 -3
  69. package/dist/components/markdown/MarkdownTable.svelte +15 -7
  70. package/dist/components/menu/ContextMenuContent.svelte +15 -15
  71. package/dist/components/menu/ContextMenuContent.svelte.d.ts +6 -9
  72. package/dist/components/menu/ContextMenuTrigger.svelte +14 -16
  73. package/dist/components/menu/ContextMenuTrigger.svelte.d.ts +8 -14
  74. package/dist/components/menu/MenuCheckboxItem.svelte +22 -11
  75. package/dist/components/menu/MenuCheckboxItem.svelte.d.ts +8 -22
  76. package/dist/components/menu/MenuContent.svelte +16 -18
  77. package/dist/components/menu/MenuContent.svelte.d.ts +6 -18
  78. package/dist/components/menu/MenuGroup.svelte +4 -4
  79. package/dist/components/menu/MenuGroup.svelte.d.ts +5 -4
  80. package/dist/components/menu/MenuItem.svelte +25 -12
  81. package/dist/components/menu/MenuItem.svelte.d.ts +6 -21
  82. package/dist/components/menu/MenuLabel.svelte +7 -11
  83. package/dist/components/menu/MenuLabel.svelte.d.ts +6 -8
  84. package/dist/components/menu/MenuRadioGroup.svelte +4 -4
  85. package/dist/components/menu/MenuRadioGroup.svelte.d.ts +5 -4
  86. package/dist/components/menu/MenuRadioItem.svelte +16 -14
  87. package/dist/components/menu/MenuRadioItem.svelte.d.ts +6 -19
  88. package/dist/components/menu/MenuSeparator.svelte +6 -10
  89. package/dist/components/menu/MenuSeparator.svelte.d.ts +6 -7
  90. package/dist/components/menu/MenuSubContent.svelte +22 -19
  91. package/dist/components/menu/MenuSubContent.svelte.d.ts +8 -15
  92. package/dist/components/menu/MenuSubTrigger.svelte +7 -11
  93. package/dist/components/menu/MenuSubTrigger.svelte.d.ts +6 -15
  94. package/dist/components/menu/MenuTrigger.svelte +17 -0
  95. package/dist/components/menu/MenuTrigger.svelte.d.ts +10 -0
  96. package/dist/components/menu/context-menu.d.ts +2 -2
  97. package/dist/components/menu/context-menu.js +3 -2
  98. package/dist/components/menu/group.js +1 -1
  99. package/dist/components/menu/index.d.ts +5 -4
  100. package/dist/components/menu/index.js +5 -5
  101. package/dist/components/menu/row.d.ts +20 -0
  102. package/dist/components/menu/row.js +12 -0
  103. package/dist/components/popover/PopoverClose.svelte +17 -0
  104. package/dist/components/popover/PopoverClose.svelte.d.ts +10 -0
  105. package/dist/components/popover/PopoverContent.svelte +30 -29
  106. package/dist/components/popover/PopoverContent.svelte.d.ts +6 -17
  107. package/dist/components/popover/PopoverTrigger.svelte +17 -0
  108. package/dist/components/popover/PopoverTrigger.svelte.d.ts +10 -0
  109. package/dist/components/popover/index.d.ts +6 -4
  110. package/dist/components/popover/index.js +6 -5
  111. package/dist/components/progress/Progress.svelte +16 -22
  112. package/dist/components/progress/Progress.svelte.d.ts +6 -5
  113. package/dist/components/queued-message/QueuedMessage.svelte +10 -3
  114. package/dist/components/queued-message/QueuedMessage.svelte.d.ts +2 -1
  115. package/dist/components/rail/RailItem.svelte +20 -6
  116. package/dist/components/reasoning/ReasoningRoot.svelte.d.ts +1 -1
  117. package/dist/components/segmented/SegmentedControl.svelte +100 -91
  118. package/dist/components/segmented/SegmentedControl.svelte.d.ts +6 -4
  119. package/dist/components/select/Select.svelte +97 -59
  120. package/dist/components/select/Select.svelte.d.ts +3 -2
  121. package/dist/components/sheet/SheetContent.svelte +31 -38
  122. package/dist/components/sheet/SheetContent.svelte.d.ts +7 -22
  123. package/dist/components/sheet/index.d.ts +3 -5
  124. package/dist/components/sheet/index.js +3 -5
  125. package/dist/components/sheet/styles.js +26 -5
  126. package/dist/components/sidebar/SidebarItem.svelte +10 -6
  127. package/dist/components/slider/Slider.svelte +86 -65
  128. package/dist/components/slider/Slider.svelte.d.ts +9 -8
  129. package/dist/components/split-button/SplitButton.svelte +20 -3
  130. package/dist/components/split-button/SplitButton.svelte.d.ts +1 -1
  131. package/dist/components/switch/Switch.svelte +77 -49
  132. package/dist/components/switch/Switch.svelte.d.ts +15 -8
  133. package/dist/components/tab-strip/TabStrip.svelte +110 -76
  134. package/dist/components/tab-strip/TabStrip.svelte.d.ts +7 -2
  135. package/dist/components/tabs/Tabs.svelte +129 -99
  136. package/dist/components/tabs/Tabs.svelte.d.ts +6 -4
  137. package/dist/components/textarea/Textarea.svelte.d.ts +1 -1
  138. package/dist/components/toast/Toaster.svelte +132 -115
  139. package/dist/components/toast/Toaster.svelte.d.ts +5 -0
  140. package/dist/components/toast/toasts.svelte.d.ts +10 -23
  141. package/dist/components/toast/toasts.svelte.js +62 -40
  142. package/dist/components/toggle/Toggle.svelte +15 -9
  143. package/dist/components/toggle/Toggle.svelte.d.ts +8 -17
  144. package/dist/components/toggle-group/ToggleGroupItem.svelte +20 -9
  145. package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +10 -10
  146. package/dist/components/toggle-group/ToggleGroupRoot.svelte +33 -18
  147. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +4 -4
  148. package/dist/components/tool/ToolRoot.svelte.d.ts +1 -1
  149. package/dist/components/tooltip/TooltipContent.svelte +38 -28
  150. package/dist/components/tooltip/TooltipContent.svelte.d.ts +6 -15
  151. package/dist/components/tooltip/TooltipProvider.svelte +34 -10
  152. package/dist/components/tooltip/TooltipProvider.svelte.d.ts +18 -4
  153. package/dist/components/tooltip/TooltipRoot.svelte +52 -23
  154. package/dist/components/tooltip/TooltipRoot.svelte.d.ts +10 -10
  155. package/dist/components/tooltip/TooltipTrigger.svelte +14 -17
  156. package/dist/components/tooltip/TooltipTrigger.svelte.d.ts +10 -4
  157. package/dist/components/tooltip/index.d.ts +1 -1
  158. package/dist/components/tooltip/index.js +1 -1
  159. package/dist/components/work-fold/WorkFold.svelte +14 -5
  160. package/dist/index.d.ts +5 -5
  161. package/dist/index.js +1 -1
  162. package/dist/internal/TooltipScope.svelte +4 -4
  163. package/dist/internal/layer.d.ts +11 -9
  164. package/dist/internal/layer.js +21 -15
  165. package/dist/internal/loose.d.ts +30 -5
  166. package/dist/internal/loose.js +1 -1
  167. package/dist/internal/markers.stylex.d.ts +0 -4
  168. package/dist/internal/markers.stylex.js +0 -2
  169. package/dist/internal/toggle.d.ts +3 -0
  170. package/dist/internal/toggle.js +6 -2
  171. package/dist/internal/tooltip-trigger.d.ts +7 -6
  172. package/dist/internal/tooltip-trigger.js +9 -12
  173. package/dist/typography.d.ts +5 -0
  174. package/dist/typography.js +5 -0
  175. package/dist/vite.d.ts +7 -1
  176. package/dist/vite.js +20 -5
  177. package/package.json +3 -2
  178. package/skills/building-ui/SKILL.md +21 -21
  179. package/skills/building-ui/references/components.md +22 -7
  180. package/skills/markdown/SKILL.md +1 -1
  181. package/skills/setup/SKILL.md +4 -8
  182. package/skills/styling/SKILL.md +4 -2
  183. 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 { Command } from 'bits-ui';
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 { Sx } from '../../internal/sx.js';
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 type CommandGroupProps = Loose<
10
- Omit<Command.GroupProps, 'children' | 'child'> & {
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
- <Command.Group data-slot="command-group" {...rest} {...stylex.attrs(sx)}>
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
- <Command.GroupHeading {...stylex.attrs(layer.heading)}>{heading}</Command.GroupHeading>
44
+ <CommandGroupLabel {...stylex.attrs(layer.heading, command.groupHeading)}
45
+ >{heading}</CommandGroupLabel
46
+ >
26
47
  {/if}
27
- <Command.GroupItems>{@render children?.()}</Command.GroupItems>
28
- </Command.Group>
48
+ {@render children?.()}
49
+ </UiCommandGroup>
@@ -1,18 +1,14 @@
1
- import type { Loose } from '../../internal/loose.js';
2
- import { Command } from 'bits-ui';
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 { Sx } from '../../internal/sx.js';
5
- export type CommandGroupProps = Loose<Omit<Command.GroupProps, 'children' | 'child'> & {
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
- declare const CommandGroup: import("svelte").Component<Loose<Omit<Command.GroupProps, "children" | "child"> & {
12
- /** The group's name, shown above its items. */
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 { Command } from 'bits-ui';
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 type CommandInputProps = Loose<
11
- Omit<Command.InputProps, 'child'> & {
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
- <Command.Input
37
- bind:value
50
+ <UiCommandInput
38
51
  {placeholder}
39
- autocomplete="off"
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 { Command } from 'bits-ui';
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 type CommandInputProps = Loose<Omit<Command.InputProps, 'child'> & {
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
- declare const CommandInput: import("svelte").Component<Loose<Omit<Command.InputProps, "child"> & {
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 { Command } from 'bits-ui';
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 type CommandItemProps = Loose<
12
- Omit<Command.ItemProps, 'children' | 'child'> & {
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
- <Command.Item data-slot="command-item" {...rest} {...attrs([command.item, sx], className)}>
59
- {#snippet child({ props })}
60
- <div {...props}>
61
- {#if icon}<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>{/if}
62
- {#if wrapDetail && detail}
63
- <span {...stylex.attrs(command.wrapRow)}>
64
- <span {...stylex.attrs(command.wrapLabel)}>{@render label()}</span>
65
- <span {...stylex.attrs(command.wrapped)}>{@render detailText()}</span>
66
- </span>
67
- {:else}
68
- <span {...stylex.attrs(layer.label)}>
69
- {@render label()}
70
- {#if detail}<span {...stylex.attrs(command.detail)}>{@render detailText()}</span>{/if}
71
- </span>
72
- {/if}
73
- <span {...stylex.attrs(layer.trailing)}>
74
- {#if shortcut}{shortcut}{/if}
75
- <!-- Enter is the way to choose, shown only on the highlighted row -->
76
- {#if hint !== null && props['data-selected'] !== undefined}<Kbd>{hint}</Kbd>{/if}
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
- </div>
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
- </Command.Item>
117
+ </UiCommandItem>
81
118
 
82
- {#snippet label()}
83
- {@render children?.()}
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 { Command } from 'bits-ui';
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 type CommandItemProps = Loose<Omit<Command.ItemProps, 'children' | 'child'> & {
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
- declare const CommandItem: import("svelte").Component<Loose<Omit<Command.ItemProps, "children" | "child"> & {
34
- /** A 16px icon before the label. */
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 { Command } from 'bits-ui';
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 type CommandListProps = Loose<
9
- Omit<Command.ListProps, 'children' | 'child'> & {
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
- <Command.List data-slot="command-list" {...rest} {...attrs([command.list, sx], className)}>
21
- <Command.Viewport>
22
- {@render children?.()}
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 { Command } from 'bits-ui';
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 type CommandListProps = Loose<Omit<Command.ListProps, 'children' | 'child'> & {
5
+ export interface CommandListProps extends Loose<Omit<PartProps<typeof UiCommandList>, 'children' | 'render'> & {
6
6
  sx?: Sx | undefined;
7
7
  children?: Snippet | undefined;
8
- }>;
9
- declare const CommandList: import("svelte").Component<Loose<Omit<Command.ListProps, "children" | "child"> & {
10
- sx?: Sx | undefined;
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;