@diegopluna/narvi 0.3.5 → 0.3.7

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 (43) hide show
  1. package/dist/components/app-shell/AppShellPanel.svelte +37 -11
  2. package/dist/components/app-shell/AppShellPanel.svelte.d.ts +13 -0
  3. package/dist/components/button/Button.svelte +24 -5
  4. package/dist/components/button/Button.svelte.d.ts +13 -1
  5. package/dist/components/command/CommandDialog.svelte +9 -2
  6. package/dist/components/command/CommandDialog.svelte.d.ts +4 -0
  7. package/dist/components/command/CommandEmpty.svelte +38 -4
  8. package/dist/components/command/CommandEmpty.svelte.d.ts +18 -2
  9. package/dist/components/command/CommandFooter.svelte +5 -7
  10. package/dist/components/command/CommandFooter.svelte.d.ts +4 -1
  11. package/dist/components/command/CommandInput.svelte +13 -1
  12. package/dist/components/command/CommandInput.svelte.d.ts +11 -0
  13. package/dist/components/command/CommandItem.svelte +32 -6
  14. package/dist/components/command/CommandItem.svelte.d.ts +20 -0
  15. package/dist/components/command/CommandRoot.svelte +68 -9
  16. package/dist/components/command/CommandRoot.svelte.d.ts +13 -3
  17. package/dist/components/command/styles.d.ts +50 -8
  18. package/dist/components/command/styles.js +50 -8
  19. package/dist/components/menu/MenuContent.svelte +7 -1
  20. package/dist/components/menu/MenuContent.svelte.d.ts +10 -0
  21. package/dist/components/queued-message/QueuedMessage.svelte +3 -2
  22. package/dist/components/rail/RailRoot.svelte +3 -3
  23. package/dist/components/segmented/SegmentedControl.svelte +2 -1
  24. package/dist/components/settings-row/SettingsRow.svelte +3 -2
  25. package/dist/components/split-button/SplitButton.svelte +58 -16
  26. package/dist/components/split-button/SplitButton.svelte.d.ts +22 -5
  27. package/dist/components/tabs/Tabs.svelte +2 -1
  28. package/dist/components/tooltip/TooltipProvider.svelte +23 -0
  29. package/dist/components/tooltip/TooltipProvider.svelte.d.ts +8 -0
  30. package/dist/components/tooltip/index.d.ts +4 -5
  31. package/dist/components/tooltip/index.js +3 -5
  32. package/dist/index.d.ts +2 -2
  33. package/dist/internal/TooltipScope.svelte +19 -0
  34. package/dist/internal/TooltipScope.svelte.d.ts +7 -0
  35. package/dist/internal/layer.d.ts +6 -3
  36. package/dist/internal/layer.js +13 -6
  37. package/package.json +1 -1
  38. package/skills/building-ui/SKILL.md +32 -32
  39. package/skills/building-ui/references/components.md +71 -32
  40. package/skills/markdown/SKILL.md +1 -1
  41. package/skills/setup/SKILL.md +1 -1
  42. package/skills/styling/SKILL.md +1 -1
  43. package/skills/theming/SKILL.md +1 -1
@@ -9,7 +9,10 @@
9
9
  It can also stand in a row of your own inside AppShell.Main, beside a thread
10
10
  rather than beside the page: a flex row with `position: relative`. It then
11
11
  measures that row, and narrow or maximized it lies over the row, whose other
12
- children are inert underneath.
12
+ children are inert underneath, and with `hideCovered` out of sight too.
13
+
14
+ It is raised wherever it stands, so in a row of your own it keeps the sheet's
15
+ colour beside a page of another.
13
16
  -->
14
17
  <script lang="ts" module>
15
18
  import * as stylex from '@stylexjs/stylex';
@@ -23,6 +26,13 @@
23
26
  export type AppShellPanelProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
24
27
  /** Names the region: "Changes", "Files". */
25
28
  label: string;
29
+ /**
30
+ * Names the edge that resizes it, for assistive technology. "Resize the changes panel"
31
+ * by default, from `label`.
32
+ */
33
+ edgeLabel?: string | undefined;
34
+ /** A tooltip on that edge, for the pointer: "Drag to resize, double-click to reset". */
35
+ edgeTitle?: string | undefined;
26
36
  /** Its width in pixels. Bindable; store it if it should be remembered. */
27
37
  width?: number | undefined;
28
38
  minWidth?: number | undefined;
@@ -39,6 +49,12 @@
39
49
  * stays in reach.
40
50
  */
41
51
  maximized?: boolean | undefined;
52
+ /**
53
+ * In a row of your own, also hides what the panel lies over, as the page is hidden under
54
+ * a maximized panel: out of sight and of find-in-page, still laid out, so its scroll is
55
+ * kept. Without it, what is underneath is only inert.
56
+ */
57
+ hideCovered?: boolean | undefined;
42
58
  sx?: Sx | undefined;
43
59
  children?: Snippet | undefined;
44
60
  };
@@ -54,6 +70,7 @@
54
70
  minWidth: 0,
55
71
  minHeight: 0,
56
72
  overflow: 'clip',
73
+ backgroundColor: colors.bgRaised,
57
74
  borderInlineStartWidth: '1px',
58
75
  borderInlineStartStyle: 'solid',
59
76
  borderInlineStartColor: colors.border,
@@ -70,8 +87,7 @@
70
87
  insetInlineEnd: 0,
71
88
  zIndex: 5,
72
89
  width: 'auto',
73
- borderInlineStartWidth: 0,
74
- backgroundColor: colors.bgRaised
90
+ borderInlineStartWidth: 0
75
91
  },
76
92
  // Under the page's header, which stays in reach with the sidebar's toggle
77
93
  narrow: { insetBlockStart: '3rem' },
@@ -87,11 +103,14 @@
87
103
  <script lang="ts">
88
104
  let {
89
105
  label,
106
+ edgeLabel,
107
+ edgeTitle,
90
108
  width = $bindable(560),
91
109
  minWidth = 320,
92
110
  defaultWidth = 560,
93
111
  mainMinWidth = 352,
94
112
  maximized = false,
113
+ hideCovered = false,
95
114
  sx,
96
115
  class: className,
97
116
  children,
@@ -141,17 +160,23 @@
141
160
  });
142
161
 
143
162
  // In a row of the caller's own, what the panel lies over is out of reach underneath:
144
- // its siblings are inert, and come back as they were
163
+ // its siblings are inert, and hidden if asked, and come back as they were
145
164
  $effect(() => {
146
165
  const parent = element?.parentElement;
147
166
  if (inSheet || !over || !parent || !element) return;
148
- const covered = [...parent.children].filter(
149
- (child): child is HTMLElement =>
150
- child instanceof HTMLElement && child !== element && !child.inert
151
- );
152
- for (const child of covered) child.inert = true;
167
+ const hide = hideCovered;
168
+ const covered = [...parent.children]
169
+ .filter((child): child is HTMLElement => child instanceof HTMLElement && child !== element)
170
+ .map((child) => ({ child, inert: child.inert, visibility: child.style.visibility }));
171
+ for (const { child } of covered) {
172
+ child.inert = true;
173
+ if (hide) child.style.visibility = 'hidden';
174
+ }
153
175
  return () => {
154
- for (const child of covered) child.inert = false;
176
+ for (const { child, inert, visibility } of covered) {
177
+ child.inert = inert;
178
+ if (hide) child.style.visibility = visibility;
179
+ }
155
180
  };
156
181
  });
157
182
 
@@ -177,7 +202,8 @@
177
202
  edge="start"
178
203
  target={element}
179
204
  property="--narvi-panel-width"
180
- label="Resize the {label.toLowerCase()} panel"
205
+ label={edgeLabel ?? `Resize the ${label.toLowerCase()} panel`}
206
+ title={edgeTitle}
181
207
  sx={styles.handle}
182
208
  />
183
209
  {/if}
@@ -4,6 +4,13 @@ import { type Sx } from '../../internal/sx.js';
4
4
  export type AppShellPanelProps = Omit<HTMLAttributes<HTMLElement>, 'children'> & {
5
5
  /** Names the region: "Changes", "Files". */
6
6
  label: string;
7
+ /**
8
+ * Names the edge that resizes it, for assistive technology. "Resize the changes panel"
9
+ * by default, from `label`.
10
+ */
11
+ edgeLabel?: string | undefined;
12
+ /** A tooltip on that edge, for the pointer: "Drag to resize, double-click to reset". */
13
+ edgeTitle?: string | undefined;
7
14
  /** Its width in pixels. Bindable; store it if it should be remembered. */
8
15
  width?: number | undefined;
9
16
  minWidth?: number | undefined;
@@ -20,6 +27,12 @@ export type AppShellPanelProps = Omit<HTMLAttributes<HTMLElement>, 'children'> &
20
27
  * stays in reach.
21
28
  */
22
29
  maximized?: boolean | undefined;
30
+ /**
31
+ * In a row of your own, also hides what the panel lies over, as the page is hidden under
32
+ * a maximized panel: out of sight and of find-in-page, still laid out, so its scroll is
33
+ * kept. Without it, what is underneath is only inert.
34
+ */
35
+ hideCovered?: boolean | undefined;
23
36
  sx?: Sx | undefined;
24
37
  children?: Snippet | undefined;
25
38
  };
@@ -8,6 +8,7 @@
8
8
  import { media } from '../../media.stylex.js';
9
9
  import Spinner from '../spinner/Spinner.svelte';
10
10
  import * as Tooltip from '../tooltip/index.js';
11
+ import TooltipScope from '../../internal/TooltipScope.svelte';
11
12
  import { mergeProps } from 'bits-ui';
12
13
  import '../../internal/icons.css';
13
14
 
@@ -32,12 +33,20 @@
32
33
  | 'success-outline';
33
34
  export type ButtonSize = 'micro' | 'xs' | 'sm' | 'md' | 'lg';
34
35
  export type ButtonShape = 'default' | 'pill';
36
+ export type ButtonJustify = 'center' | 'start';
37
+ export type ButtonTooltipSide = 'top' | 'right' | 'bottom' | 'left';
35
38
 
36
39
  export type ButtonProps = Omit<HTMLButtonAttributes & HTMLAnchorAttributes, 'children'> & {
37
40
  variant?: ButtonVariant | undefined;
38
41
  size?: ButtonSize | undefined;
39
42
  /** `pill` rounds the ends fully: for a chip, or a button that floats. */
40
43
  shape?: ButtonShape | undefined;
44
+ /**
45
+ * Where its contents sit: in the `center`, or at the `start`, for a wide button that reads
46
+ * as a menu's row. Either way they fill the button, so a margin of `auto` on the last
47
+ * pushes it to the end.
48
+ */
49
+ justify?: ButtonJustify | undefined;
41
50
  /** Shows a spinner and blocks interaction while keeping the button's width. */
42
51
  loading?: boolean | undefined;
43
52
  /**
@@ -58,9 +67,13 @@
58
67
  /**
59
68
  * A tooltip, shown as the pointer rests on it or the keyboard reaches it: words, or a
60
69
  * snippet for words with a shortcut. It says more than the button's name, which stays as
61
- * it is. It waits 400ms, as Narvi's other parts' tooltips do.
70
+ * it is. It waits as long as the app's Tooltip.Provider says, or 400ms without one.
62
71
  */
63
72
  tooltip?: string | Snippet | undefined;
73
+ /** The side of the button the tooltip opens on. Above it unless there is no room. */
74
+ tooltipSide?: ButtonTooltipSide | undefined;
75
+ /** The keys that do the same, shown after the tooltip's words: `['⌘', 'K']`. */
76
+ tooltipShortcut?: string[] | undefined;
64
77
  /** Renders a link styled as a button. */
65
78
  href?: string | undefined;
66
79
  sx?: Sx | undefined;
@@ -204,6 +217,7 @@
204
217
  },
205
218
 
206
219
  pill: { borderRadius: radius.pill },
220
+ start: { justifyContent: 'flex-start', textAlign: 'start' },
207
221
 
208
222
  // Primary: the one solid, flat, in the text's own colour
209
223
  primary: {
@@ -347,10 +361,11 @@
347
361
  pointerEvents: 'none'
348
362
  },
349
363
  // As wide as the button, so in a wide one something inside can be pushed to the end
364
+ // It takes the button's justification, so `sx` can set that on the button alone
350
365
  content: {
351
366
  display: 'inline-flex',
352
367
  alignItems: 'center',
353
- justifyContent: 'center',
368
+ justifyContent: 'inherit',
354
369
  flexGrow: 1,
355
370
  minWidth: 0,
356
371
  gap: 'inherit',
@@ -458,12 +473,15 @@
458
473
  variant = 'secondary',
459
474
  size = 'md',
460
475
  shape = 'default',
476
+ justify = 'center',
461
477
  loading = false,
462
478
  loadingLabel,
463
479
  disabled = false,
464
480
  pressed,
465
481
  iconOnly = false,
466
482
  tooltip,
483
+ tooltipSide,
484
+ tooltipShortcut,
467
485
  href,
468
486
  type = 'button',
469
487
  sx,
@@ -483,6 +501,7 @@
483
501
  styles[size],
484
502
  iconOnly && iconStyles[size],
485
503
  (shape === 'pill' || variant === 'floating') && styles.pill,
504
+ justify === 'start' && styles.start,
486
505
  variantStyles[variant],
487
506
  disabled && styles.disabled,
488
507
  loading && styles.loading,
@@ -551,16 +570,16 @@
551
570
  {/snippet}
552
571
 
553
572
  {#if tooltip}
554
- <Tooltip.Provider delayDuration={400}>
573
+ <TooltipScope>
555
574
  <Tooltip.Root>
556
575
  <Tooltip.Trigger>
557
576
  {#snippet child({ props })}{@render control(props)}{/snippet}
558
577
  </Tooltip.Trigger>
559
- <Tooltip.Content>
578
+ <Tooltip.Content side={tooltipSide} shortcut={tooltipShortcut}>
560
579
  {#if typeof tooltip === 'function'}{@render tooltip()}{:else}{tooltip}{/if}
561
580
  </Tooltip.Content>
562
581
  </Tooltip.Root>
563
- </Tooltip.Provider>
582
+ </TooltipScope>
564
583
  {:else}
565
584
  {@render control({})}
566
585
  {/if}
@@ -11,11 +11,19 @@ import '../../internal/icons.css';
11
11
  export type ButtonVariant = 'primary' | 'secondary' | 'soft' | 'ghost' | 'bare' | 'link' | 'floating' | 'danger' | 'danger-outline' | 'ghost-danger' | 'warning-outline' | 'success-outline';
12
12
  export type ButtonSize = 'micro' | 'xs' | 'sm' | 'md' | 'lg';
13
13
  export type ButtonShape = 'default' | 'pill';
14
+ export type ButtonJustify = 'center' | 'start';
15
+ export type ButtonTooltipSide = 'top' | 'right' | 'bottom' | 'left';
14
16
  export type ButtonProps = Omit<HTMLButtonAttributes & HTMLAnchorAttributes, 'children'> & {
15
17
  variant?: ButtonVariant | undefined;
16
18
  size?: ButtonSize | undefined;
17
19
  /** `pill` rounds the ends fully: for a chip, or a button that floats. */
18
20
  shape?: ButtonShape | undefined;
21
+ /**
22
+ * Where its contents sit: in the `center`, or at the `start`, for a wide button that reads
23
+ * as a menu's row. Either way they fill the button, so a margin of `auto` on the last
24
+ * pushes it to the end.
25
+ */
26
+ justify?: ButtonJustify | undefined;
19
27
  /** Shows a spinner and blocks interaction while keeping the button's width. */
20
28
  loading?: boolean | undefined;
21
29
  /**
@@ -36,9 +44,13 @@ export type ButtonProps = Omit<HTMLButtonAttributes & HTMLAnchorAttributes, 'chi
36
44
  /**
37
45
  * A tooltip, shown as the pointer rests on it or the keyboard reaches it: words, or a
38
46
  * snippet for words with a shortcut. It says more than the button's name, which stays as
39
- * it is. It waits 400ms, as Narvi's other parts' tooltips do.
47
+ * it is. It waits as long as the app's Tooltip.Provider says, or 400ms without one.
40
48
  */
41
49
  tooltip?: string | Snippet | undefined;
50
+ /** The side of the button the tooltip opens on. Above it unless there is no room. */
51
+ tooltipSide?: ButtonTooltipSide | undefined;
52
+ /** The keys that do the same, shown after the tooltip's words: `['⌘', 'K']`. */
53
+ tooltipShortcut?: string[] | undefined;
42
54
  /** Renders a link styled as a button. */
43
55
  href?: string | undefined;
44
56
  sx?: Sx | undefined;
@@ -6,6 +6,8 @@
6
6
  import { Dialog } from 'bits-ui';
7
7
  import * as stylex from '@stylexjs/stylex';
8
8
  import type { Snippet } from 'svelte';
9
+ import { attrs, type Sx } from '../../internal/sx.js';
10
+ import { visuallyHidden } from '../../visually-hidden.js';
9
11
  import { command } from './styles.js';
10
12
 
11
13
  export type CommandDialogProps = {
@@ -25,6 +27,9 @@
25
27
  restoreFocus?: boolean | undefined;
26
28
  /** What the palette is, for assistive technology. */
27
29
  label?: string | undefined;
30
+ /** On the palette's box: its place, its width, how tall it may grow. */
31
+ sx?: Sx | undefined;
32
+ class?: string | undefined;
28
33
  /** A Command.Root with its Input, List and Footer. */
29
34
  children?: Snippet | undefined;
30
35
  };
@@ -37,6 +42,8 @@
37
42
  onopenchange,
38
43
  onescape,
39
44
  restoreFocus = true,
45
+ sx,
46
+ class: className,
40
47
  children
41
48
  }: CommandDialogProps = $props();
42
49
  </script>
@@ -50,9 +57,9 @@
50
57
  onCloseAutoFocus={(event) => {
51
58
  if (!restoreFocus) event.preventDefault();
52
59
  }}
53
- {...stylex.attrs(command.dialog)}
60
+ {...attrs([command.dialog, sx], className)}
54
61
  >
55
- <Dialog.Title {...stylex.attrs(command.hidden)}>{label}</Dialog.Title>
62
+ <Dialog.Title {...stylex.attrs(visuallyHidden)}>{label}</Dialog.Title>
56
63
  {@render children?.()}
57
64
  </Dialog.Content>
58
65
  </Dialog.Portal>
@@ -1,4 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type Sx } from '../../internal/sx.js';
2
3
  export type CommandDialogProps = {
3
4
  /** Whether it is open. Bindable. */
4
5
  open?: boolean | undefined;
@@ -16,6 +17,9 @@ export type CommandDialogProps = {
16
17
  restoreFocus?: boolean | undefined;
17
18
  /** What the palette is, for assistive technology. */
18
19
  label?: string | undefined;
20
+ /** On the palette's box: its place, its width, how tall it may grow. */
21
+ sx?: Sx | undefined;
22
+ class?: string | undefined;
19
23
  /** A Command.Root with its Input, List and Footer. */
20
24
  children?: Snippet | undefined;
21
25
  };
@@ -1,23 +1,57 @@
1
+ <!--
2
+ What the list says in place of items: that nothing matches, that results are on
3
+ their way, or that they could not be had. It shows only while the list has no
4
+ items, so results still listed stay as they are while new ones load.
5
+ -->
1
6
  <script lang="ts" module>
2
7
  import type { Loose } from '../../internal/loose.js';
3
8
  import { Command } from 'bits-ui';
4
9
  import type { Snippet } from 'svelte';
5
10
  import { attrs, type Sx } from '../../internal/sx.js';
11
+ import Spinner from '../spinner/Spinner.svelte';
6
12
  import { command } from './styles.js';
7
13
 
8
14
  export type CommandEmptyProps = Loose<
9
15
  Omit<Command.EmptyProps, 'children' | 'child'> & {
16
+ /**
17
+ * Why there are no items: `loading`, with a spinner, while they are on their way, or
18
+ * `error`, in the danger colour, when they could not be had. Without it, nothing matches.
19
+ */
20
+ status?: 'loading' | 'error' | undefined;
10
21
  sx?: Sx | undefined;
11
- /** What to say when nothing matches. Say what was searched for, and what to try. */
22
+ /**
23
+ * What to say. For no match, say what was searched for and what to try; for an error,
24
+ * what went wrong and what to do.
25
+ */
12
26
  children?: Snippet | undefined;
13
27
  }
14
28
  >;
29
+
30
+ const fallback = {
31
+ empty: 'Nothing matches.',
32
+ loading: 'Searching…',
33
+ error: 'The results could not be loaded.'
34
+ } as const;
15
35
  </script>
16
36
 
17
37
  <script lang="ts">
18
- let { sx, class: className, children, ...rest }: CommandEmptyProps = $props();
38
+ let { status, sx, class: className, children, ...rest }: CommandEmptyProps = $props();
19
39
  </script>
20
40
 
21
- <Command.Empty data-slot="command-empty" {...rest} {...attrs([command.empty, sx], className)}>
22
- {#if children}{@render children()}{:else}Nothing matches.{/if}
41
+ <Command.Empty
42
+ data-slot="command-empty"
43
+ data-status={status}
44
+ {...rest}
45
+ {...attrs(
46
+ [
47
+ command.empty,
48
+ status === 'loading' && command.emptyLoading,
49
+ status === 'error' && command.emptyError,
50
+ sx
51
+ ],
52
+ className
53
+ )}
54
+ >
55
+ {#if status === 'loading'}<Spinner size={16} label={null} />{/if}
56
+ {#if children}{@render children()}{:else}{fallback[status ?? 'empty']}{/if}
23
57
  </Command.Empty>
@@ -3,13 +3,29 @@ import { Command } from 'bits-ui';
3
3
  import type { Snippet } from 'svelte';
4
4
  import { type Sx } from '../../internal/sx.js';
5
5
  export type CommandEmptyProps = Loose<Omit<Command.EmptyProps, 'children' | 'child'> & {
6
+ /**
7
+ * Why there are no items: `loading`, with a spinner, while they are on their way, or
8
+ * `error`, in the danger colour, when they could not be had. Without it, nothing matches.
9
+ */
10
+ status?: 'loading' | 'error' | undefined;
6
11
  sx?: Sx | undefined;
7
- /** What to say when nothing matches. Say what was searched for, and what to try. */
12
+ /**
13
+ * What to say. For no match, say what was searched for and what to try; for an error,
14
+ * what went wrong and what to do.
15
+ */
8
16
  children?: Snippet | undefined;
9
17
  }>;
10
18
  declare const CommandEmpty: import("svelte").Component<Loose<Omit<Command.EmptyProps, "children" | "child"> & {
19
+ /**
20
+ * Why there are no items: `loading`, with a spinner, while they are on their way, or
21
+ * `error`, in the danger colour, when they could not be had. Without it, nothing matches.
22
+ */
23
+ status?: "loading" | "error" | undefined;
11
24
  sx?: Sx | undefined;
12
- /** What to say when nothing matches. Say what was searched for, and what to try. */
25
+ /**
26
+ * What to say. For no match, say what was searched for and what to try; for an error,
27
+ * what went wrong and what to do.
28
+ */
13
29
  children?: Snippet | undefined;
14
30
  }>, {}, "">;
15
31
  type CommandEmpty = ReturnType<typeof CommandEmpty>;
@@ -6,7 +6,10 @@
6
6
 
7
7
  export type CommandFooterProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
8
8
  sx?: Sx | undefined;
9
- /** Hints for the keys, such as "↑↓ to move". */
9
+ /**
10
+ * Hints for the keys, such as "↑↓ to move", a note, or buttons such as Back. It is read
11
+ * out with the rest; pass `aria-hidden="true"` for hints alone, which the keys already say.
12
+ */
10
13
  children?: Snippet | undefined;
11
14
  };
12
15
  </script>
@@ -15,11 +18,6 @@
15
18
  let { sx, class: className, children, ...rest }: CommandFooterProps = $props();
16
19
  </script>
17
20
 
18
- <div
19
- data-slot="command-footer"
20
- aria-hidden="true"
21
- {...rest}
22
- {...attrs([command.footer, sx], className)}
23
- >
21
+ <div data-slot="command-footer" {...rest} {...attrs([command.footer, sx], className)}>
24
22
  {@render children?.()}
25
23
  </div>
@@ -3,7 +3,10 @@ import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type Sx } from '../../internal/sx.js';
4
4
  export type CommandFooterProps = Omit<HTMLAttributes<HTMLDivElement>, 'children'> & {
5
5
  sx?: Sx | undefined;
6
- /** Hints for the keys, such as "↑↓ to move". */
6
+ /**
7
+ * Hints for the keys, such as "↑↓ to move", a note, or buttons such as Back. It is read
8
+ * out with the rest; pass `aria-hidden="true"` for hints alone, which the keys already say.
9
+ */
7
10
  children?: Snippet | undefined;
8
11
  };
9
12
  declare const CommandFooter: import("svelte").Component<CommandFooterProps, {}, "">;
@@ -2,12 +2,20 @@
2
2
  import type { Loose } from '../../internal/loose.js';
3
3
  import { Command } from 'bits-ui';
4
4
  import * as stylex from '@stylexjs/stylex';
5
+ import type { Snippet } from 'svelte';
5
6
  import Glyph from '../../internal/Glyph.svelte';
6
7
  import { attrs, type Sx } from '../../internal/sx.js';
7
8
  import { command } from './styles.js';
8
9
 
9
10
  export type CommandInputProps = Loose<
10
- Omit<Command.InputProps, 'child'> & { sx?: Sx | undefined }
11
+ Omit<Command.InputProps, 'child'> & {
12
+ /**
13
+ * After the field, in its row: a button or two, such as a filter or how to search, or a
14
+ * Spinner while results are on their way.
15
+ */
16
+ end?: Snippet | undefined;
17
+ sx?: Sx | undefined;
18
+ }
11
19
  >;
12
20
  </script>
13
21
 
@@ -15,6 +23,7 @@
15
23
  let {
16
24
  value = $bindable(''),
17
25
  placeholder = 'Search for a command…',
26
+ end,
18
27
  sx,
19
28
  class: className,
20
29
  ...rest
@@ -33,4 +42,7 @@
33
42
  {...rest}
34
43
  {...attrs([command.input, sx], className)}
35
44
  />
45
+ {#if end}<div data-slot="command-input-end" {...stylex.attrs(command.end)}>
46
+ {@render end()}
47
+ </div>{/if}
36
48
  </div>
@@ -1,10 +1,21 @@
1
1
  import type { Loose } from '../../internal/loose.js';
2
2
  import { Command } from 'bits-ui';
3
+ import type { Snippet } from 'svelte';
3
4
  import { type Sx } from '../../internal/sx.js';
4
5
  export type CommandInputProps = Loose<Omit<Command.InputProps, 'child'> & {
6
+ /**
7
+ * After the field, in its row: a button or two, such as a filter or how to search, or a
8
+ * Spinner while results are on their way.
9
+ */
10
+ end?: Snippet | undefined;
5
11
  sx?: Sx | undefined;
6
12
  }>;
7
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;
8
19
  sx?: Sx | undefined;
9
20
  }>, {}, "value">;
10
21
  type CommandInput = ReturnType<typeof CommandInput>;
@@ -17,6 +17,16 @@
17
17
  * such as one with the words that match the search marked.
18
18
  */
19
19
  detail?: string | Snippet | undefined;
20
+ /**
21
+ * Lets the detail wrap to a second line, rather than be cut short, where its end
22
+ * matters: a path. It gives way before the label does.
23
+ */
24
+ wrapDetail?: boolean | undefined;
25
+ /**
26
+ * Right after the label, before the detail: a mark such as a connected service's, or a
27
+ * Badge. An icon in it is 14px.
28
+ */
29
+ badge?: Snippet | undefined;
20
30
  /**
21
31
  * What the key cap on the highlighted item says Enter does. `↵` by default; words such
22
32
  * as "Open" for an item that does something of its own, or `null` for none.
@@ -34,6 +44,8 @@
34
44
  let {
35
45
  icon,
36
46
  detail,
47
+ wrapDetail = false,
48
+ badge,
37
49
  shortcut,
38
50
  hint = '↵',
39
51
  sx,
@@ -47,12 +59,17 @@
47
59
  {#snippet child({ props })}
48
60
  <div {...props}>
49
61
  {#if icon}<span data-icons {...stylex.attrs(layer.icon)}>{@render icon()}</span>{/if}
50
- <span {...stylex.attrs(layer.label)}>
51
- {@render children?.()}
52
- {#if detail}<span {...stylex.attrs(command.detail)}
53
- >{#if typeof detail === 'function'}{@render detail()}{:else}{detail}{/if}</span
54
- >{/if}
55
- </span>
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}
56
73
  <span {...stylex.attrs(layer.trailing)}>
57
74
  {#if shortcut}{shortcut}{/if}
58
75
  <!-- Enter is the way to choose, shown only on the highlighted row -->
@@ -61,3 +78,12 @@
61
78
  </div>
62
79
  {/snippet}
63
80
  </Command.Item>
81
+
82
+ {#snippet label()}
83
+ {@render children?.()}
84
+ {#if badge}<span data-icons {...stylex.attrs(command.badge)}>{@render badge()}</span>{/if}
85
+ {/snippet}
86
+
87
+ {#snippet detailText()}
88
+ {#if typeof detail === 'function'}{@render detail()}{:else}{detail}{/if}
89
+ {/snippet}
@@ -10,6 +10,16 @@ export type CommandItemProps = Loose<Omit<Command.ItemProps, 'children' | 'child
10
10
  * such as one with the words that match the search marked.
11
11
  */
12
12
  detail?: string | Snippet | undefined;
13
+ /**
14
+ * Lets the detail wrap to a second line, rather than be cut short, where its end
15
+ * matters: a path. It gives way before the label does.
16
+ */
17
+ wrapDetail?: boolean | undefined;
18
+ /**
19
+ * Right after the label, before the detail: a mark such as a connected service's, or a
20
+ * Badge. An icon in it is 14px.
21
+ */
22
+ badge?: Snippet | undefined;
13
23
  /**
14
24
  * What the key cap on the highlighted item says Enter does. `↵` by default; words such
15
25
  * as "Open" for an item that does something of its own, or `null` for none.
@@ -28,6 +38,16 @@ declare const CommandItem: import("svelte").Component<Loose<Omit<Command.ItemPro
28
38
  * such as one with the words that match the search marked.
29
39
  */
30
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;
31
51
  /**
32
52
  * What the key cap on the highlighted item says Enter does. `↵` by default; words such
33
53
  * as "Open" for an item that does something of its own, or `null` for none.