@diegopluna/narvi 0.4.1 → 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 (177) 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 +350 -346
  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/reasoning/ReasoningRoot.svelte.d.ts +1 -1
  114. package/dist/components/segmented/SegmentedControl.svelte +100 -91
  115. package/dist/components/segmented/SegmentedControl.svelte.d.ts +6 -4
  116. package/dist/components/select/Select.svelte +97 -59
  117. package/dist/components/select/Select.svelte.d.ts +3 -2
  118. package/dist/components/sheet/SheetContent.svelte +31 -38
  119. package/dist/components/sheet/SheetContent.svelte.d.ts +7 -22
  120. package/dist/components/sheet/index.d.ts +3 -5
  121. package/dist/components/sheet/index.js +3 -5
  122. package/dist/components/sheet/styles.js +26 -5
  123. package/dist/components/sidebar/SidebarItem.svelte +2 -3
  124. package/dist/components/slider/Slider.svelte +86 -65
  125. package/dist/components/slider/Slider.svelte.d.ts +9 -8
  126. package/dist/components/split-button/SplitButton.svelte +20 -3
  127. package/dist/components/split-button/SplitButton.svelte.d.ts +1 -1
  128. package/dist/components/switch/Switch.svelte +77 -49
  129. package/dist/components/switch/Switch.svelte.d.ts +15 -8
  130. package/dist/components/tab-strip/TabStrip.svelte +87 -68
  131. package/dist/components/tabs/Tabs.svelte +129 -99
  132. package/dist/components/tabs/Tabs.svelte.d.ts +6 -4
  133. package/dist/components/textarea/Textarea.svelte.d.ts +1 -1
  134. package/dist/components/toast/Toaster.svelte +132 -115
  135. package/dist/components/toast/Toaster.svelte.d.ts +5 -0
  136. package/dist/components/toast/toasts.svelte.d.ts +10 -23
  137. package/dist/components/toast/toasts.svelte.js +62 -40
  138. package/dist/components/toggle/Toggle.svelte +15 -9
  139. package/dist/components/toggle/Toggle.svelte.d.ts +8 -17
  140. package/dist/components/toggle-group/ToggleGroupItem.svelte +20 -9
  141. package/dist/components/toggle-group/ToggleGroupItem.svelte.d.ts +10 -10
  142. package/dist/components/toggle-group/ToggleGroupRoot.svelte +33 -18
  143. package/dist/components/toggle-group/ToggleGroupRoot.svelte.d.ts +4 -4
  144. package/dist/components/tool/ToolRoot.svelte.d.ts +1 -1
  145. package/dist/components/tooltip/TooltipContent.svelte +38 -28
  146. package/dist/components/tooltip/TooltipContent.svelte.d.ts +6 -15
  147. package/dist/components/tooltip/TooltipProvider.svelte +34 -10
  148. package/dist/components/tooltip/TooltipProvider.svelte.d.ts +18 -4
  149. package/dist/components/tooltip/TooltipRoot.svelte +52 -23
  150. package/dist/components/tooltip/TooltipRoot.svelte.d.ts +10 -10
  151. package/dist/components/tooltip/TooltipTrigger.svelte +14 -17
  152. package/dist/components/tooltip/TooltipTrigger.svelte.d.ts +10 -4
  153. package/dist/components/tooltip/index.d.ts +1 -1
  154. package/dist/components/tooltip/index.js +1 -1
  155. package/dist/components/work-fold/WorkFold.svelte +14 -5
  156. package/dist/index.d.ts +5 -5
  157. package/dist/index.js +1 -1
  158. package/dist/internal/TooltipScope.svelte +4 -4
  159. package/dist/internal/layer.d.ts +11 -9
  160. package/dist/internal/layer.js +21 -15
  161. package/dist/internal/loose.d.ts +30 -5
  162. package/dist/internal/loose.js +1 -1
  163. package/dist/internal/markers.stylex.d.ts +0 -4
  164. package/dist/internal/markers.stylex.js +0 -2
  165. package/dist/internal/toggle.d.ts +3 -0
  166. package/dist/internal/toggle.js +6 -2
  167. package/dist/internal/tooltip-trigger.d.ts +7 -6
  168. package/dist/internal/tooltip-trigger.js +9 -12
  169. package/dist/vite.d.ts +7 -1
  170. package/dist/vite.js +20 -5
  171. package/package.json +3 -2
  172. package/skills/building-ui/SKILL.md +20 -20
  173. package/skills/building-ui/references/components.md +11 -4
  174. package/skills/markdown/SKILL.md +1 -1
  175. package/skills/setup/SKILL.md +4 -8
  176. package/skills/styling/SKILL.md +1 -1
  177. package/skills/theming/SKILL.md +3 -7
@@ -1,10 +1,10 @@
1
- import type { Loose } from '../../internal/loose.js';
2
- import { Dialog } from 'bits-ui';
1
+ import type { Loose, PartProps } from '../../internal/loose.js';
2
+ import { DialogContent } from '@ui-sdk/svelte/dialog';
3
3
  import type { Snippet } from 'svelte';
4
4
  import { type Sx } from '../../internal/sx.js';
5
5
  export type SheetSide = 'start' | 'end' | 'top' | 'bottom';
6
6
  export type SheetSize = 'sm' | 'md' | 'lg' | 'xl' | '2xl';
7
- export type SheetContentProps = Loose<Omit<Dialog.ContentProps, 'children' | 'child'> & {
7
+ export interface SheetContentProps extends Loose<Omit<PartProps<typeof DialogContent>, 'children' | 'render'> & {
8
8
  /** The edge it slides in from. `start` and `end` follow the writing direction. */
9
9
  side?: SheetSide | undefined;
10
10
  /** How wide a sheet along the start or end is: 20, 26, 36, 44 or 56rem. */
@@ -14,29 +14,14 @@ export type SheetContentProps = Loose<Omit<Dialog.ContentProps, 'children' | 'ch
14
14
  /**
15
15
  * What takes the focus as it opens: `sheet`, the sheet itself, so a list or a rail in
16
16
  * it shows no focus ring until the keys move into it; or `first`, its first control,
17
- * for a sheet that holds a form.
17
+ * for a sheet that holds a form. `initialFocus` names anything else and wins over it.
18
18
  */
19
19
  focusOnOpen?: 'sheet' | 'first' | undefined;
20
20
  sx?: Sx | undefined;
21
21
  /** A Sheet.Header, a Sheet.Body and a Sheet.Footer. */
22
22
  children?: Snippet | undefined;
23
- }>;
24
- declare const SheetContent: import("svelte").Component<Loose<Omit<Dialog.ContentProps, "children" | "child"> & {
25
- /** The edge it slides in from. `start` and `end` follow the writing direction. */
26
- side?: SheetSide | undefined;
27
- /** How wide a sheet along the start or end is: 20, 26, 36, 44 or 56rem. */
28
- size?: SheetSize | undefined;
29
- /** Accessible name of the close button in the corner. `null` leaves it out. */
30
- closeLabel?: string | null | undefined;
31
- /**
32
- * What takes the focus as it opens: `sheet`, the sheet itself, so a list or a rail in
33
- * it shows no focus ring until the keys move into it; or `first`, its first control,
34
- * for a sheet that holds a form.
35
- */
36
- focusOnOpen?: "sheet" | "first" | undefined;
37
- sx?: Sx | undefined;
38
- /** A Sheet.Header, a Sheet.Body and a Sheet.Footer. */
39
- children?: Snippet | undefined;
40
- }>, {}, "ref">;
23
+ }> {
24
+ }
25
+ declare const SheetContent: import("svelte").Component<SheetContentProps, {}, "">;
41
26
  type SheetContent = ReturnType<typeof SheetContent>;
42
27
  export default SheetContent;
@@ -1,13 +1,11 @@
1
- import { Dialog } from 'bits-ui';
2
- import { type Loosened } from '../../internal/loose.js';
3
1
  import Body from '../dialog/DialogBody.svelte';
2
+ import Close from '../dialog/DialogClose.svelte';
4
3
  import Description from '../dialog/DialogDescription.svelte';
5
4
  import Footer from '../dialog/DialogFooter.svelte';
6
5
  import Header from '../dialog/DialogHeader.svelte';
6
+ import Root from '../dialog/DialogRoot.svelte';
7
7
  import Title from '../dialog/DialogTitle.svelte';
8
+ import Trigger from '../dialog/DialogTrigger.svelte';
8
9
  import Content from './SheetContent.svelte';
9
- declare const Root: Loosened<typeof Dialog.Root>;
10
- declare const Trigger: Loosened<typeof Dialog.Trigger>;
11
- declare const Close: Loosened<typeof Dialog.Close>;
12
10
  export { Root, Trigger, Content, Header, Title, Description, Body, Footer, Close };
13
11
  export type { SheetContentProps, SheetSide, SheetSize } from './SheetContent.svelte';
@@ -1,13 +1,11 @@
1
- import { Dialog } from 'bits-ui';
2
- import { loose } from '../../internal/loose.js';
3
1
  import Body from '../dialog/DialogBody.svelte';
2
+ import Close from '../dialog/DialogClose.svelte';
4
3
  import Description from '../dialog/DialogDescription.svelte';
5
4
  import Footer from '../dialog/DialogFooter.svelte';
6
5
  import Header from '../dialog/DialogHeader.svelte';
6
+ import Root from '../dialog/DialogRoot.svelte';
7
7
  import Title from '../dialog/DialogTitle.svelte';
8
+ import Trigger from '../dialog/DialogTrigger.svelte';
8
9
  import Content from './SheetContent.svelte';
9
10
  // A sheet is a dialog along an edge: the same behaviour and the same parts
10
- const Root = loose(Dialog.Root);
11
- const Trigger = loose(Dialog.Trigger);
12
- const Close = loose(Dialog.Close);
13
11
  export { Root, Trigger, Content, Header, Title, Description, Body, Footer, Close };
@@ -1,7 +1,8 @@
1
1
  import * as stylex from '@stylexjs/stylex';
2
2
  import { motion } from '../../tokens.stylex.js';
3
3
  import { media } from '../../media.stylex.js';
4
- const CLOSED = ':is([data-state="closed"])';
4
+ const CLOSED = ':is([data-ending-style])';
5
+ const STARTING = ':is([data-starting-style])';
5
6
  // iOS's drawer curve: it leaves the edge quickly and settles long
6
7
  const DRAWER = 'cubic-bezier(0.32, 0.72, 0, 1)';
7
8
  /** Laid over Dialog's content: a panel along one edge of the window, which it slides in from. */
@@ -29,7 +30,12 @@ export const sheet = stylex.create({
29
30
  insetInlineEnd: 0,
30
31
  translate: {
31
32
  default: null,
32
- [media.motion]: { default: '0 0', '@starting-style': '100% 0', [CLOSED]: '100% 0' }
33
+ [media.motion]: {
34
+ default: '0 0',
35
+ '@starting-style': '100% 0',
36
+ [STARTING]: '100% 0',
37
+ [CLOSED]: '100% 0'
38
+ }
33
39
  }
34
40
  },
35
41
  start: {
@@ -39,7 +45,12 @@ export const sheet = stylex.create({
39
45
  insetInlineEnd: 'auto',
40
46
  translate: {
41
47
  default: null,
42
- [media.motion]: { default: '0 0', '@starting-style': '-100% 0', [CLOSED]: '-100% 0' }
48
+ [media.motion]: {
49
+ default: '0 0',
50
+ '@starting-style': '-100% 0',
51
+ [STARTING]: '-100% 0',
52
+ [CLOSED]: '-100% 0'
53
+ }
43
54
  }
44
55
  },
45
56
  // Along the top or bottom it runs the full width, as tall as its content, and
@@ -51,7 +62,12 @@ export const sheet = stylex.create({
51
62
  maxHeight: 'calc(100dvh - 4rem)',
52
63
  translate: {
53
64
  default: null,
54
- [media.motion]: { default: '0 0', '@starting-style': '0 -100%', [CLOSED]: '0 -100%' }
65
+ [media.motion]: {
66
+ default: '0 0',
67
+ '@starting-style': '0 -100%',
68
+ [STARTING]: '0 -100%',
69
+ [CLOSED]: '0 -100%'
70
+ }
55
71
  }
56
72
  },
57
73
  bottom: {
@@ -61,7 +77,12 @@ export const sheet = stylex.create({
61
77
  maxHeight: 'calc(100dvh - 4rem)',
62
78
  translate: {
63
79
  default: null,
64
- [media.motion]: { default: '0 0', '@starting-style': '0 100%', [CLOSED]: '0 100%' }
80
+ [media.motion]: {
81
+ default: '0 0',
82
+ '@starting-style': '0 100%',
83
+ [STARTING]: '0 100%',
84
+ [CLOSED]: '0 100%'
85
+ }
65
86
  }
66
87
  }
67
88
  });
@@ -76,9 +76,8 @@
76
76
  // closes, the actions stay over the row, under the menu that came from them
77
77
  const OPEN = ':has([data-slot="sidebar-item-actions"] [aria-expanded="true"])';
78
78
  // The row stays lit while a menu from it is open: the actions', or a context menu whose
79
- // trigger is the element around the row (`itemProps`)
80
- const LIT =
81
- ':is([data-state="open"], :has([data-slot="sidebar-item-actions"] [aria-expanded="true"]))';
79
+ // trigger is the element around the row (`itemProps`), which ui-sdk marks `data-open`
80
+ const LIT = ':is([data-open], :has([data-slot="sidebar-item-actions"] [aria-expanded="true"]))';
82
81
 
83
82
  /** A length at the window's density (`density` in the tokens). */
84
83
  const d = (rem: string) => `calc(${rem} * ${density.factor})`;
@@ -1,5 +1,11 @@
1
1
  <script lang="ts" module>
2
- import { Slider } from 'bits-ui';
2
+ import {
3
+ Slider as UiSlider,
4
+ SliderControl,
5
+ SliderIndicator,
6
+ SliderThumb,
7
+ SliderTrack
8
+ } from '@ui-sdk/svelte/slider';
3
9
  import * as stylex from '@stylexjs/stylex';
4
10
  import type { HTMLAttributes } from 'svelte/elements';
5
11
  import { attrs, type Sx } from '../../internal/sx.js';
@@ -7,7 +13,7 @@
7
13
  import { media } from '../../media.stylex.js';
8
14
 
9
15
  export type SliderProps<T extends number | number[] = number> = Omit<
10
- HTMLAttributes<HTMLSpanElement>,
16
+ HTMLAttributes<HTMLDivElement>,
11
17
  'children' | 'dir'
12
18
  > & {
13
19
  /**
@@ -21,10 +27,12 @@
21
27
  onValueCommit?: ((value: T) => void) | undefined;
22
28
  min?: number | undefined;
23
29
  max?: number | undefined;
24
- /** How far one step goes, or the values it may stop at. */
25
- step?: number | number[] | undefined;
30
+ /** How far one step goes, counted from `min`. */
31
+ step?: number | undefined;
26
32
  orientation?: 'horizontal' | 'vertical' | undefined;
27
- /** Set `rtl` in a right-to-left layout, so the slider runs from the right. */
33
+ /**
34
+ * `rtl` runs the slider from the right. Left out, it follows the page's direction.
35
+ */
28
36
  dir?: 'ltr' | 'rtl' | undefined;
29
37
  disabled?: boolean | undefined;
30
38
  /**
@@ -35,11 +43,13 @@
35
43
  /** Reads a value out in words, such as `0:42` for a playhead or `40%`. */
36
44
  format?: ((value: number) => string) | undefined;
37
45
  sx?: Sx | undefined;
38
- ref?: HTMLSpanElement | null | undefined;
46
+ ref?: HTMLElement | null | undefined;
39
47
  };
40
48
 
41
49
  const DISABLED = ':is([data-disabled])';
42
- const ACTIVE = ':is([data-active])';
50
+ const DRAGGING = ':is([data-dragging])';
51
+ // The thumb's range input, hidden inside it, is what takes focus
52
+ const FOCUSED = ':has(:focus-visible)';
43
53
 
44
54
  const styles = stylex.create({
45
55
  root: {
@@ -56,17 +66,31 @@
56
66
  cursor: { default: 'pointer', [DISABLED]: 'not-allowed' },
57
67
  opacity: { default: 1, [DISABLED]: 0.5 }
58
68
  },
59
- horizontal: { width: '100%', minWidth: '6rem', height: '1.5rem' },
69
+ // In a row beside a label or a value, it gives way down to its least width
70
+ horizontal: { flexShrink: 1, width: '100%', minWidth: '6rem', height: '1.5rem' },
60
71
  vertical: {
61
72
  flexDirection: 'column',
62
73
  width: '1.5rem',
63
74
  height: '100%',
64
75
  minHeight: '6rem'
65
76
  },
77
+ // Where presses land: the whole height of the slider around its thin track
78
+ control: { display: 'flex', flexGrow: 1, alignSelf: 'stretch', minWidth: 0 },
79
+ controlVertical: { flexDirection: 'column' },
80
+ // What ui-sdk places the thumbs along, in percent: as long as the track, as tall as the control.
81
+ // Inset by half a thumb, so a thumb at either end stays inside the slider's box.
82
+ rail: {
83
+ display: 'flex',
84
+ alignItems: 'center',
85
+ justifyContent: 'center',
86
+ flexGrow: 1,
87
+ alignSelf: 'stretch'
88
+ },
89
+ railHorizontal: { marginInline: '0.5rem' },
90
+ railVertical: { marginBlock: '0.5rem' },
66
91
  // A recess, like Progress's track
67
92
  track: {
68
93
  position: 'relative',
69
- flexGrow: 1,
70
94
  overflow: 'hidden',
71
95
  borderRadius: radius.pill,
72
96
  backgroundColor: colors.fillSunken,
@@ -75,9 +99,10 @@
75
99
  outlineColor: 'transparent',
76
100
  outlineOffset: '-1px'
77
101
  },
78
- trackHorizontal: { height: '0.25rem' },
79
- trackVertical: { width: '0.25rem' },
80
- // How far along: lit with the accent, as progress is
102
+ trackHorizontal: { width: '100%', height: '0.25rem' },
103
+ // Stretched to the rail, which has a height even where the slider's is not given
104
+ trackVertical: { width: '0.25rem', alignSelf: 'stretch' },
105
+ // How far along: lit with the accent, as progress is. ui-sdk places and sizes it.
81
106
  range: {
82
107
  backgroundColor: colors.accent,
83
108
  // Forced colours drop a background colour, not an image
@@ -87,11 +112,8 @@
87
112
  },
88
113
  forcedColorAdjust: 'none'
89
114
  },
90
- rangeHorizontal: { height: '100%' },
91
- rangeVertical: { width: '100%' },
92
- // Placed by bits-ui with `left` and `translate`, so a press grows it with `scale`
115
+ // Placed by ui-sdk with `inset` and `translate`, so a press grows it with `scale`
93
116
  thumb: {
94
- zIndex: 1,
95
117
  boxSizing: 'border-box',
96
118
  display: 'block',
97
119
  width: '1rem',
@@ -106,15 +128,15 @@
106
128
  }
107
129
  },
108
130
  forcedColorAdjust: 'none',
109
- cursor: { default: 'grab', [ACTIVE]: 'grabbing', [DISABLED]: 'not-allowed' },
110
- scale: { default: null, [media.motion]: { default: 1, [ACTIVE]: 1.15 } },
131
+ cursor: { default: 'grab', [DRAGGING]: 'grabbing', [DISABLED]: 'not-allowed' },
132
+ scale: { default: null, [media.motion]: { default: 1, [DRAGGING]: 1.15 } },
111
133
  outlineStyle: 'solid',
112
- outlineWidth: { default: '1px', ':focus-visible': '2px' },
134
+ outlineWidth: { default: '1px', [FOCUSED]: '2px' },
113
135
  outlineColor: {
114
136
  default: 'transparent',
115
- ':focus-visible': { default: colors.focusRing, [media.forcedColors]: 'Highlight' }
137
+ [FOCUSED]: { default: colors.focusRing, [media.forcedColors]: 'Highlight' }
116
138
  },
117
- outlineOffset: { default: '-1px', ':focus-visible': '2px' },
139
+ outlineOffset: { default: '-1px', [FOCUSED]: '2px' },
118
140
  transitionProperty: { default: 'box-shadow', [media.motion]: 'scale, box-shadow' },
119
141
  transitionDuration: motion.fast,
120
142
  transitionTimingFunction: motion.easeOut,
@@ -138,7 +160,7 @@
138
160
  max = 100,
139
161
  step = 1,
140
162
  orientation = 'horizontal',
141
- dir = 'ltr',
163
+ dir,
142
164
  disabled = false,
143
165
  thumbLabels,
144
166
  format,
@@ -151,50 +173,49 @@
151
173
  }: SliderProps<T> = $props();
152
174
 
153
175
  const vertical = $derived(orientation === 'vertical');
154
-
155
- // bits-ui types a single and a multiple slider apart; which one this is
156
- // follows from the value it is given
157
- const root = $derived({
158
- type: Array.isArray(value) ? 'multiple' : 'single',
159
- value,
160
- onValueChange: (next: number | number[]) => {
161
- value = next as T;
162
- onValueChange?.(next as T);
163
- },
164
- onValueCommit: (next: number | number[]) => onValueCommit?.(next as T),
165
- min,
166
- max,
167
- step,
168
- orientation,
169
- dir,
170
- disabled
171
- } as Slider.RootProps);
172
-
173
- const valueAt = (index: number) =>
174
- Array.isArray(value) ? (value[index] ?? min) : ((value as number | undefined) ?? min);
176
+ // One thumb for a number, one for each value of an array
177
+ const thumbs = $derived(Array.isArray(value) ? value.length : 1);
178
+ // A thumb of its own name leaves the slider's to the group around the thumbs
179
+ const named = $derived(!!thumbLabels?.length);
175
180
  </script>
176
181
 
177
- <Slider.Root
178
- bind:ref
179
- data-slot="slider"
180
- {...root}
181
- {...rest as Record<string, unknown>}
182
+ <UiSlider
183
+ bind:value={() => value as number | number[] | undefined, (next) => (value = next as T)}
184
+ onValueChange={(next) => onValueChange?.(next as T)}
185
+ onValueCommit={(next) => onValueCommit?.(next as T)}
186
+ {min}
187
+ {max}
188
+ {step}
189
+ {orientation}
190
+ {disabled}
191
+ {format}
192
+ {dir}
193
+ aria-label={named ? ariaLabel : undefined}
194
+ aria-labelledby={named ? ariaLabelledby : undefined}
195
+ {...rest}
182
196
  {...attrs([styles.root, vertical ? styles.vertical : styles.horizontal, sx], className)}
197
+ {@attach (element: HTMLElement) => {
198
+ ref = element;
199
+ return () => (ref = null);
200
+ }}
183
201
  >
184
- {#snippet children({ thumbItems })}
185
- <span {...stylex.attrs(styles.track, vertical ? styles.trackVertical : styles.trackHorizontal)}>
186
- <Slider.Range
187
- {...stylex.attrs(styles.range, vertical ? styles.rangeVertical : styles.rangeHorizontal)}
188
- />
189
- </span>
190
- {#each thumbItems as thumb (thumb.index)}
191
- <Slider.Thumb
192
- index={thumb.index}
193
- aria-label={thumbLabels?.[thumb.index] ?? ariaLabel}
194
- aria-labelledby={thumbLabels?.[thumb.index] ? undefined : ariaLabelledby}
195
- aria-valuetext={format?.(valueAt(thumb.index))}
196
- {...stylex.attrs(styles.thumb)}
197
- />
198
- {/each}
199
- {/snippet}
200
- </Slider.Root>
202
+ <SliderControl {...stylex.attrs(styles.control, vertical && styles.controlVertical)}>
203
+ <SliderTrack
204
+ {...stylex.attrs(styles.rail, vertical ? styles.railVertical : styles.railHorizontal)}
205
+ >
206
+ <span
207
+ {...stylex.attrs(styles.track, vertical ? styles.trackVertical : styles.trackHorizontal)}
208
+ >
209
+ <SliderIndicator {...stylex.attrs(styles.range)} />
210
+ </span>
211
+ {#each { length: thumbs }, index (index)}
212
+ <SliderThumb
213
+ {index}
214
+ aria-label={thumbLabels?.[index] ?? ariaLabel}
215
+ aria-labelledby={thumbLabels?.[index] ? undefined : ariaLabelledby}
216
+ {...stylex.attrs(styles.thumb)}
217
+ />
218
+ {/each}
219
+ </SliderTrack>
220
+ </SliderControl>
221
+ </UiSlider>
@@ -1,7 +1,6 @@
1
- import { Slider } from 'bits-ui';
2
1
  import type { HTMLAttributes } from 'svelte/elements';
3
2
  import { type Sx } from '../../internal/sx.js';
4
- export type SliderProps<T extends number | number[] = number> = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'dir'> & {
3
+ export type SliderProps<T extends number | number[] = number> = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'dir'> & {
5
4
  /**
6
5
  * Where the thumb stands. Bindable. A number gives one thumb; an array gives
7
6
  * one thumb for each of its values, such as a range's two ends.
@@ -13,10 +12,12 @@ export type SliderProps<T extends number | number[] = number> = Omit<HTMLAttribu
13
12
  onValueCommit?: ((value: T) => void) | undefined;
14
13
  min?: number | undefined;
15
14
  max?: number | undefined;
16
- /** How far one step goes, or the values it may stop at. */
17
- step?: number | number[] | undefined;
15
+ /** How far one step goes, counted from `min`. */
16
+ step?: number | undefined;
18
17
  orientation?: 'horizontal' | 'vertical' | undefined;
19
- /** Set `rtl` in a right-to-left layout, so the slider runs from the right. */
18
+ /**
19
+ * `rtl` runs the slider from the right. Left out, it follows the page's direction.
20
+ */
20
21
  dir?: 'ltr' | 'rtl' | undefined;
21
22
  disabled?: boolean | undefined;
22
23
  /**
@@ -27,12 +28,12 @@ export type SliderProps<T extends number | number[] = number> = Omit<HTMLAttribu
27
28
  /** Reads a value out in words, such as `0:42` for a playhead or `40%`. */
28
29
  format?: ((value: number) => string) | undefined;
29
30
  sx?: Sx | undefined;
30
- ref?: HTMLSpanElement | null | undefined;
31
+ ref?: HTMLElement | null | undefined;
31
32
  };
32
33
  declare function $$render<T extends number | number[] = number>(): {
33
34
  props: SliderProps<T>;
34
35
  exports: {};
35
- bindings: "ref" | "value";
36
+ bindings: "value" | "ref";
36
37
  slots: {};
37
38
  events: {};
38
39
  };
@@ -40,7 +41,7 @@ declare class __sveltets_Render<T extends number | number[] = number> {
40
41
  props(): ReturnType<typeof $$render<T>>['props'];
41
42
  events(): ReturnType<typeof $$render<T>>['events'];
42
43
  slots(): ReturnType<typeof $$render<T>>['slots'];
43
- bindings(): "ref" | "value";
44
+ bindings(): "value" | "ref";
44
45
  exports(): {};
45
46
  }
46
47
  interface $$IsomorphicComponent {
@@ -74,8 +74,21 @@
74
74
  display: 'inline-flex',
75
75
  alignItems: 'stretch',
76
76
  flexShrink: 0,
77
+ // Never wider than what holds it: a long label is cut short at the main button's end,
78
+ // and the button that opens the menu stays whole
79
+ maxWidth: '100%',
77
80
  verticalAlign: 'middle'
78
81
  },
82
+ mainFits: { flexShrink: 1, minWidth: 0 },
83
+ // The label and its icon in a row, as the button lays them out, cut at the side only, so
84
+ // accents and descenders keep their room
85
+ label: {
86
+ display: 'inline-flex',
87
+ alignItems: 'center',
88
+ gap: 'inherit',
89
+ minWidth: 0,
90
+ overflowX: 'clip'
91
+ },
79
92
  // The focused half is drawn over its neighbour, so its ring is whole
80
93
  half: { zIndex: { default: null, ':focus-visible': 1 } },
81
94
  main: { borderStartEndRadius: 0, borderEndEndRadius: 0 },
@@ -138,6 +151,9 @@
138
151
  ...rest
139
152
  }: SplitButtonProps = $props();
140
153
 
154
+ // The menu lines up with the pair, not with its chevron alone, as `align` says
155
+ let pair = $state<HTMLElement | null>(null);
156
+
141
157
  const glyph = { micro: 10, xs: 12, sm: 12, md: 14, lg: 16 } as const;
142
158
  const divider = {
143
159
  primary: styles.morePrimary,
@@ -151,6 +167,7 @@
151
167
  aria-label={label}
152
168
  data-slot="split-button"
153
169
  {...attrs([styles.group, sx], className)}
170
+ bind:this={pair}
154
171
  >
155
172
  <Button
156
173
  bind:ref
@@ -161,9 +178,9 @@
161
178
  disabled={disabled || mainDisabled}
162
179
  {loading}
163
180
  {tooltipSide}
164
- sx={[styles.half, menu && styles.main, mainSx]}
181
+ sx={[styles.half, styles.mainFits, menu && styles.main, mainSx]}
165
182
  >
166
- {@render children?.()}
183
+ <span {...stylex.attrs(styles.label)}>{@render children?.()}</span>
167
184
  </Button>
168
185
  {#if menu}
169
186
  <Menu.Root bind:open onOpenChange={onopenchange}>
@@ -184,7 +201,7 @@
184
201
  </Button>
185
202
  {/snippet}
186
203
  </Menu.Trigger>
187
- <Menu.Content {align} width={menuWidth} minWidth={menuMinWidth}>
204
+ <Menu.Content {align} anchor={pair} width={menuWidth} minWidth={menuMinWidth}>
188
205
  {@render menu()}
189
206
  </Menu.Content>
190
207
  </Menu.Root>
@@ -48,6 +48,6 @@ export type SplitButtonProps = Omit<ButtonProps, 'variant' | 'iconOnly' | 'href'
48
48
  /** The main button's label, and its icon if it has one. */
49
49
  children?: Snippet | undefined;
50
50
  };
51
- declare const SplitButton: import("svelte").Component<SplitButtonProps, {}, "ref" | "open">;
51
+ declare const SplitButton: import("svelte").Component<SplitButtonProps, {}, "open" | "ref">;
52
52
  type SplitButton = ReturnType<typeof SplitButton>;
53
53
  export default SplitButton;