horizon-design 1.0.0 → 2.0.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 (169) hide show
  1. package/README.md +153 -105
  2. package/dist/components/accordion/AccordionItem.svelte +3 -2
  3. package/dist/components/accordion/AccordionItem.svelte.d.ts +4 -1
  4. package/dist/components/angle-slider/AngleSlider.svelte +8 -4
  5. package/dist/components/angle-slider/AngleSlider.svelte.d.ts +5 -1
  6. package/dist/components/asset-card/AssetCard.svelte +23 -10
  7. package/dist/components/asset-card/AssetCard.svelte.d.ts +11 -5
  8. package/dist/components/avatar/Avatar.svelte +8 -2
  9. package/dist/components/avatar/Avatar.svelte.d.ts +1 -1
  10. package/dist/components/button/Button.svelte +1 -1
  11. package/dist/components/button/Button.svelte.d.ts +1 -1
  12. package/dist/components/button/button-variants.d.ts +2 -0
  13. package/dist/components/button/button-variants.js +2 -0
  14. package/dist/components/calendar/Calendar.svelte +22 -167
  15. package/dist/components/calendar/Calendar.svelte.d.ts +9 -3
  16. package/dist/components/calendar/CalendarViews.svelte +204 -0
  17. package/dist/components/calendar/CalendarViews.svelte.d.ts +24 -0
  18. package/dist/components/calendar/trigger-ids.d.ts +14 -0
  19. package/dist/components/calendar/trigger-ids.js +7 -0
  20. package/dist/components/card/Card.svelte +8 -2
  21. package/dist/components/card/Card.svelte.d.ts +4 -1
  22. package/dist/components/carousel/Carousel.svelte +57 -19
  23. package/dist/components/carousel/Carousel.svelte.d.ts +5 -2
  24. package/dist/components/checkbox/Checkbox.svelte +7 -7
  25. package/dist/components/checkbox/Checkbox.svelte.d.ts +1 -1
  26. package/dist/components/circular-progress/CircularProgress.svelte +3 -9
  27. package/dist/components/circular-progress/CircularProgress.svelte.d.ts +1 -1
  28. package/dist/components/circular-slider/CircularSlider.svelte +5 -11
  29. package/dist/components/circular-slider/CircularSlider.svelte.d.ts +1 -1
  30. package/dist/components/clipboard/Clipboard.svelte +30 -13
  31. package/dist/components/clipboard/Clipboard.svelte.d.ts +6 -2
  32. package/dist/components/collapsible/Collapsible.svelte +10 -3
  33. package/dist/components/collapsible/Collapsible.svelte.d.ts +7 -2
  34. package/dist/components/color-picker/ColorPicker.svelte +105 -28
  35. package/dist/components/color-picker/ColorPicker.svelte.d.ts +20 -5
  36. package/dist/components/color-picker/formats.d.ts +23 -0
  37. package/dist/components/color-picker/formats.js +52 -0
  38. package/dist/components/color-picker/index.d.ts +3 -1
  39. package/dist/components/color-picker/index.js +2 -1
  40. package/dist/components/combobox/Combobox.svelte +28 -4
  41. package/dist/components/combobox/Combobox.svelte.d.ts +9 -1
  42. package/dist/components/date-picker/DatePicker.svelte +46 -139
  43. package/dist/components/date-picker/DatePicker.svelte.d.ts +12 -2
  44. package/dist/components/dialog/Dialog.svelte +28 -10
  45. package/dist/components/dialog/Dialog.svelte.d.ts +6 -3
  46. package/dist/components/dialog/DialogClose.svelte +48 -21
  47. package/dist/components/dialog/DialogClose.svelte.d.ts +16 -6
  48. package/dist/components/dialog/context.d.ts +9 -0
  49. package/dist/components/dialog/context.js +16 -0
  50. package/dist/components/drawer/Drawer.svelte +25 -10
  51. package/dist/components/drawer/Drawer.svelte.d.ts +5 -3
  52. package/dist/components/editable/Editable.svelte +3 -0
  53. package/dist/components/file-upload/FileUpload.svelte +8 -6
  54. package/dist/components/file-upload/FileUpload.svelte.d.ts +4 -3
  55. package/dist/components/floating-panel/FloatingPanel.svelte +16 -9
  56. package/dist/components/floating-panel/FloatingPanel.svelte.d.ts +3 -2
  57. package/dist/components/frame/Frame.svelte +10 -6
  58. package/dist/components/frame/Frame.svelte.d.ts +2 -1
  59. package/dist/components/game-hero/GameHero.svelte +1 -1
  60. package/dist/components/game-hero/GameHero.svelte.d.ts +1 -1
  61. package/dist/components/icon-button/IconButton.svelte +60 -0
  62. package/dist/components/icon-button/IconButton.svelte.d.ts +31 -0
  63. package/dist/components/icon-button/index.d.ts +5 -0
  64. package/dist/components/icon-button/index.js +5 -0
  65. package/dist/components/item/Item.svelte +34 -11
  66. package/dist/components/item/Item.svelte.d.ts +11 -2
  67. package/dist/components/kbd/Kbd.svelte +34 -4
  68. package/dist/components/kbd/Kbd.svelte.d.ts +16 -2
  69. package/dist/components/listbox/Listbox.svelte +6 -3
  70. package/dist/components/listbox/Listbox.svelte.d.ts +4 -1
  71. package/dist/components/menu/Menu.svelte +33 -5
  72. package/dist/components/menu/Menu.svelte.d.ts +12 -2
  73. package/dist/components/native-select/NativeSelect.svelte +3 -2
  74. package/dist/components/native-select/NativeSelect.svelte.d.ts +2 -1
  75. package/dist/components/notification-center/NotificationCenter.svelte +1 -1
  76. package/dist/components/number-input/NumberInput.svelte +39 -13
  77. package/dist/components/number-input/NumberInput.svelte.d.ts +5 -3
  78. package/dist/components/pagination/Pagination.svelte +4 -3
  79. package/dist/components/pagination/Pagination.svelte.d.ts +2 -1
  80. package/dist/components/pagination/PaginationNextTrigger.svelte +30 -11
  81. package/dist/components/pagination/PaginationNextTrigger.svelte.d.ts +9 -1
  82. package/dist/components/pagination/PaginationPrevTrigger.svelte +30 -11
  83. package/dist/components/pagination/PaginationPrevTrigger.svelte.d.ts +9 -1
  84. package/dist/components/pin-input/PinInput.svelte +3 -2
  85. package/dist/components/pin-input/PinInput.svelte.d.ts +2 -1
  86. package/dist/components/popover/Popover.svelte +34 -6
  87. package/dist/components/popover/Popover.svelte.d.ts +11 -3
  88. package/dist/components/popover/PopoverClose.svelte +24 -9
  89. package/dist/components/popover/PopoverClose.svelte.d.ts +6 -1
  90. package/dist/components/progress/Progress.svelte +3 -3
  91. package/dist/components/radio-group/RadioGroup.svelte +43 -34
  92. package/dist/components/radio-group/RadioGroup.svelte.d.ts +3 -1
  93. package/dist/components/rating-group/RatingGroup.svelte +7 -2
  94. package/dist/components/rating-group/RatingGroup.svelte.d.ts +1 -0
  95. package/dist/components/ring/Ring.svelte +42 -0
  96. package/dist/components/ring/Ring.svelte.d.ts +16 -0
  97. package/dist/components/scroll-area/ScrollArea.svelte +30 -10
  98. package/dist/components/scroll-area/ScrollArea.svelte.d.ts +9 -1
  99. package/dist/components/segment-group/SegmentGroup.svelte +38 -17
  100. package/dist/components/segment-group/SegmentGroup.svelte.d.ts +9 -4
  101. package/dist/components/select/Select.svelte +2 -2
  102. package/dist/components/select/Select.svelte.d.ts +1 -1
  103. package/dist/components/sheet/Sheet.svelte +54 -15
  104. package/dist/components/sheet/Sheet.svelte.d.ts +15 -6
  105. package/dist/components/sidebar/Sidebar.svelte +18 -3
  106. package/dist/components/sidebar/Sidebar.svelte.d.ts +9 -3
  107. package/dist/components/sidebar/SidebarItem.svelte +53 -26
  108. package/dist/components/sidebar/SidebarItem.svelte.d.ts +8 -4
  109. package/dist/components/sidebar/SidebarSection.svelte +1 -1
  110. package/dist/components/sidebar/context.d.ts +9 -0
  111. package/dist/components/sidebar/context.js +15 -0
  112. package/dist/components/signature-pad/SignaturePad.svelte +3 -2
  113. package/dist/components/signature-pad/SignaturePad.svelte.d.ts +2 -1
  114. package/dist/components/slider/Slider.svelte +21 -10
  115. package/dist/components/slider/Slider.svelte.d.ts +3 -1
  116. package/dist/components/splitter/Splitter.svelte +8 -2
  117. package/dist/components/splitter/Splitter.svelte.d.ts +2 -1
  118. package/dist/components/switch/Switch.svelte +26 -41
  119. package/dist/components/switch/Switch.svelte.d.ts +2 -2
  120. package/dist/components/table/Table.svelte +21 -26
  121. package/dist/components/table/Table.svelte.d.ts +41 -22
  122. package/dist/components/table/index.d.ts +2 -2
  123. package/dist/components/table/index.js +1 -1
  124. package/dist/components/tag-picker/TagPicker.svelte +3 -5
  125. package/dist/components/tag-picker/TagPicker.svelte.d.ts +1 -1
  126. package/dist/components/textarea/Textarea.svelte +8 -2
  127. package/dist/components/textarea/Textarea.svelte.d.ts +4 -1
  128. package/dist/components/theme-switch/ThemeSwitch.svelte +64 -18
  129. package/dist/components/theme-switch/ThemeSwitch.svelte.d.ts +6 -3
  130. package/dist/components/thumb-card/ThumbCard.svelte +19 -6
  131. package/dist/components/thumb-card/ThumbCard.svelte.d.ts +9 -2
  132. package/dist/components/timer/Timer.svelte +26 -15
  133. package/dist/components/timer/Timer.svelte.d.ts +3 -2
  134. package/dist/components/toast/Toast.svelte +15 -8
  135. package/dist/components/toast/Toast.svelte.d.ts +3 -2
  136. package/dist/components/toast/Toaster.svelte +1 -1
  137. package/dist/components/toast/Toaster.svelte.d.ts +1 -1
  138. package/dist/components/toggle/Toggle.svelte +4 -2
  139. package/dist/components/toggle/Toggle.svelte.d.ts +4 -2
  140. package/dist/components/toggle-group/ToggleGroup.svelte +61 -14
  141. package/dist/components/toggle-group/ToggleGroup.svelte.d.ts +13 -5
  142. package/dist/components/toggle-tooltip/ToggleTooltip.svelte +26 -29
  143. package/dist/components/toggle-tooltip/ToggleTooltip.svelte.d.ts +4 -3
  144. package/dist/components/tooltip/Tooltip.svelte +31 -5
  145. package/dist/components/tooltip/Tooltip.svelte.d.ts +10 -2
  146. package/dist/components/tour/Tour.svelte +21 -13
  147. package/dist/components/tour/Tour.svelte.d.ts +3 -3
  148. package/dist/components/virtual-tree/VirtualTree.svelte +7 -6
  149. package/dist/components/virtual-tree/VirtualTree.svelte.d.ts +3 -2
  150. package/dist/editor/horizon-layout/HorizonLayout.svelte +8 -7
  151. package/dist/editor/horizon-layout/HorizonLayout.svelte.d.ts +2 -2
  152. package/dist/editor/inspector-panel/InspectorPanel.svelte +60 -9
  153. package/dist/editor/inspector-panel/InspectorPanel.svelte.d.ts +19 -1
  154. package/dist/generated/theme.css +16 -11
  155. package/dist/generated/tokens.d.ts +1 -1
  156. package/dist/generated/tokens.js +13 -11
  157. package/dist/index.d.ts +3 -2
  158. package/dist/index.js +2 -1
  159. package/dist/motion/sliding-indicator.d.ts +28 -0
  160. package/dist/motion/sliding-indicator.js +54 -0
  161. package/dist/platform.d.ts +21 -0
  162. package/dist/platform.js +19 -0
  163. package/dist/theme.svelte.d.ts +3 -3
  164. package/dist/theme.svelte.js +7 -7
  165. package/package.json +12 -12
  166. package/dist/components/tabs/Tabs.svelte +0 -119
  167. package/dist/components/tabs/Tabs.svelte.d.ts +0 -31
  168. package/dist/components/tabs/index.d.ts +0 -5
  169. package/dist/components/tabs/index.js +0 -5
@@ -44,9 +44,9 @@ bar for assistive technology; without one, the bar is named by its value.
44
44
  {#if label || showValue}
45
45
  <div class="flex items-center justify-between gap-2">
46
46
  {#if label}
47
- <Progress.Label class="text-sm font-medium" data-slot="progress-label"
48
- >{label}</Progress.Label
49
- >
47
+ <Progress.Label class="text-sm font-medium" data-slot="progress-label">
48
+ {label}
49
+ </Progress.Label>
50
50
  {/if}
51
51
  {#if showValue}
52
52
  <Progress.ValueText
@@ -2,7 +2,9 @@
2
2
  @component
3
3
  A group of radio buttons to choose one option (Ark RadioGroup): from `items`, or Ark's
4
4
  `RadioGroup.Item` parts in `children`. `value` binds the chosen option; without it, Ark's
5
- `defaultValue` sets the first one. Without `label`, name the group with an `aria-label`.
5
+ `defaultValue` sets the first one. Without `label`, name the group with an `aria-label`. Ark's
6
+ `orientation="horizontal"` lays the options out in a row, and its `invalid` turns the circles
7
+ danger.
6
8
  -->
7
9
  <script lang="ts">
8
10
  import type { Snippet } from 'svelte';
@@ -48,11 +50,11 @@ A group of radio buttons to choose one option (Ark RadioGroup): from `items`, or
48
50
  [key: string]: unknown;
49
51
  } = $props();
50
52
 
51
- const sz = $derived(sizes[size]);
53
+ const sizeClasses = $derived(sizes[size]);
52
54
  </script>
53
55
 
54
56
  <RadioGroup.Root
55
- class={cn('flex flex-col gap-3', className)}
57
+ class={cn('group/radio-group flex flex-col gap-3', className)}
56
58
  data-slot="radio-group"
57
59
  {value}
58
60
  onValueChange={(details) => {
@@ -62,40 +64,47 @@ A group of radio buttons to choose one option (Ark RadioGroup): from `items`, or
62
64
  {...rest}
63
65
  >
64
66
  {#if label}
65
- <RadioGroup.Label class={cn('leading-none font-medium', sz.label)} data-slot="radio-group-label"
66
- >{label}</RadioGroup.Label
67
+ <RadioGroup.Label
68
+ class={cn('leading-none font-medium', sizeClasses.label)}
69
+ data-slot="radio-group-label"
67
70
  >
71
+ {label}
72
+ </RadioGroup.Label>
68
73
  {/if}
69
- {#if items}
70
- {#each items as item (item.value)}
71
- <RadioGroup.Item
72
- value={item.value}
73
- disabled={item.disabled}
74
- class="flex items-center gap-2 data-disabled:cursor-not-allowed data-disabled:opacity-50"
75
- data-slot="radio-group-item"
76
- >
77
- <RadioGroup.ItemControl
78
- class={cn(
79
- 'group relative aspect-square rounded-full border border-border bg-sunken transition-colors outline-none data-focus-visible:ring-2 data-focus-visible:ring-primary data-focus-visible:ring-offset-2 data-focus-visible:ring-offset-background data-[state=checked]:border-primary data-[state=checked]:bg-primary',
80
- sz.control
81
- )}
74
+ <div
75
+ class="flex flex-col gap-3 group-data-[orientation=horizontal]/radio-group:flex-row group-data-[orientation=horizontal]/radio-group:flex-wrap group-data-[orientation=horizontal]/radio-group:gap-x-5"
76
+ >
77
+ {#if items}
78
+ {#each items as item (item.value)}
79
+ <RadioGroup.Item
80
+ value={item.value}
81
+ disabled={item.disabled}
82
+ class="flex items-center gap-2 data-disabled:cursor-not-allowed data-disabled:opacity-50"
83
+ data-slot="radio-group-item"
82
84
  >
83
- <div
85
+ <RadioGroup.ItemControl
84
86
  class={cn(
85
- 'absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 scale-0 rounded-full bg-paper transition-transform group-data-[state=checked]:scale-100',
86
- sz.dot
87
+ 'group relative aspect-square rounded-full border border-border bg-sunken transition-colors outline-none data-focus-visible:ring-2 data-focus-visible:ring-primary data-focus-visible:ring-offset-2 data-focus-visible:ring-offset-background data-invalid:border-danger data-[state=checked]:border-primary data-[state=checked]:bg-primary data-invalid:data-[state=checked]:bg-danger',
88
+ sizeClasses.control
87
89
  )}
88
- ></div>
89
- </RadioGroup.ItemControl>
90
- {#if typeof item.label === 'string'}
91
- <span class={sz.label}>{item.label}</span>
92
- {:else}
93
- {@render item.label()}
94
- {/if}
95
- <RadioGroup.ItemHiddenInput />
96
- </RadioGroup.Item>
97
- {/each}
98
- {:else}
99
- {@render children?.()}
100
- {/if}
90
+ >
91
+ <div
92
+ class={cn(
93
+ 'absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 scale-0 rounded-full bg-paper transition-transform group-data-[state=checked]:scale-100',
94
+ sizeClasses.dot
95
+ )}
96
+ ></div>
97
+ </RadioGroup.ItemControl>
98
+ {#if typeof item.label === 'string'}
99
+ <span class={sizeClasses.label}>{item.label}</span>
100
+ {:else}
101
+ {@render item.label()}
102
+ {/if}
103
+ <RadioGroup.ItemHiddenInput />
104
+ </RadioGroup.Item>
105
+ {/each}
106
+ {:else}
107
+ {@render children?.()}
108
+ {/if}
109
+ </div>
101
110
  </RadioGroup.Root>
@@ -27,7 +27,9 @@ type $$ComponentProps = {
27
27
  /**
28
28
  * A group of radio buttons to choose one option (Ark RadioGroup): from `items`, or Ark's
29
29
  * `RadioGroup.Item` parts in `children`. `value` binds the chosen option; without it, Ark's
30
- * `defaultValue` sets the first one. Without `label`, name the group with an `aria-label`.
30
+ * `defaultValue` sets the first one. Without `label`, name the group with an `aria-label`. Ark's
31
+ * `orientation="horizontal"` lays the options out in a row, and its `invalid` turns the circles
32
+ * danger.
31
33
  */
32
34
  declare const RadioGroup: import("svelte").Component<$$ComponentProps, {}, "value">;
33
35
  type RadioGroup = ReturnType<typeof RadioGroup>;
@@ -3,6 +3,7 @@
3
3
  A row of stars to give a rating (Ark RatingGroup). `label` names the group; `translations` names
4
4
  each star (`ratingValueText`, "3 stars") and gives the role a star is announced as
5
5
  (`roleDescription`). `value` binds the rating; without it, Ark's `defaultValue` sets the first one.
6
+ With Ark's `allowHalf`, a half rating fills half a star.
6
7
  -->
7
8
  <script lang="ts">
8
9
  import {
@@ -63,14 +64,18 @@ each star (`ratingValueText`, "3 stars") and gives the role a star is announced
63
64
  </RatingGroup.Label>
64
65
  <RatingGroup.Context>
65
66
  {#snippet render(api)}
66
- <RatingGroup.Control class="flex items-center gap-1">
67
+ <RatingGroup.Control class="flex items-center gap-1 data-disabled:opacity-50">
67
68
  {#each api().items as item (item)}
68
69
  <RatingGroup.Item
69
70
  index={item}
70
71
  aria-roledescription={roleDescription}
71
- class="rounded-sm text-muted transition-colors data-highlighted:text-warning"
72
+ class="group/star relative rounded-sm text-muted transition-colors data-highlighted:not-data-half:text-warning"
72
73
  >
73
74
  <MingcuteStarFill class="size-5" aria-hidden="true" />
75
+ <MingcuteStarFill
76
+ class="absolute inset-0 hidden size-5 text-warning [clip-path:inset(0_50%_0_0)] group-data-half/star:block rtl:[clip-path:inset(0_0_0_50%)]"
77
+ aria-hidden="true"
78
+ />
74
79
  </RatingGroup.Item>
75
80
  {/each}
76
81
  </RatingGroup.Control>
@@ -24,6 +24,7 @@ type $$ComponentProps = {
24
24
  * A row of stars to give a rating (Ark RatingGroup). `label` names the group; `translations` names
25
25
  * each star (`ratingValueText`, "3 stars") and gives the role a star is announced as
26
26
  * (`roleDescription`). `value` binds the rating; without it, Ark's `defaultValue` sets the first one.
27
+ * With Ark's `allowHalf`, a half rating fills half a star.
27
28
  */
28
29
  declare const RatingGroup: import("svelte").Component<$$ComponentProps, {}, "value">;
29
30
  type RatingGroup = ReturnType<typeof RatingGroup>;
@@ -0,0 +1,42 @@
1
+ <!--
2
+ @component
3
+ The ring `CircularProgress` and `CircularSlider` draw: a track that fills clockwise from the top
4
+ up to `turn` (0 to 1 of a full turn), with round ends. The fill is a conic gradient drawn as a ring
5
+ by a radial mask (which reads only the alpha of its colours), and each end of the fill is a dot as
6
+ wide as the ring, centred on the ring's middle line, which rounds it. It fills its positioned
7
+ parent and is hidden from assistive technology: the parent names and announces the value.
8
+ -->
9
+ <script lang="ts">
10
+ let {
11
+ turn,
12
+ thickness
13
+ }: {
14
+ /** How much of the ring is filled, from 0 (none) to 1 (all of it). */
15
+ turn: number;
16
+ /** The ring's thickness, in pixels. */
17
+ thickness: number;
18
+ } = $props();
19
+ </script>
20
+
21
+ {#snippet cap(angle: number)}
22
+ <div class="absolute inset-0" style:rotate="{angle}turn" data-slot="ring-cap">
23
+ <div
24
+ class="absolute top-0 left-1/2 -translate-x-1/2 rounded-full bg-primary"
25
+ style:width="{thickness}px"
26
+ style:height="{thickness}px"
27
+ ></div>
28
+ </div>
29
+ {/snippet}
30
+
31
+ <div aria-hidden="true" class="pointer-events-none absolute inset-0" data-slot="ring">
32
+ <div
33
+ class="absolute inset-0 rounded-full"
34
+ style:background="conic-gradient(var(--primary) {turn}turn, var(--hover) 0)"
35
+ style:mask="radial-gradient(farthest-side, transparent calc(100% - {thickness}px - 0.5px),
36
+ currentColor calc(100% - {thickness}px))"
37
+ ></div>
38
+ {#if turn > 0}
39
+ {@render cap(0)}
40
+ {@render cap(turn)}
41
+ {/if}
42
+ </div>
@@ -0,0 +1,16 @@
1
+ type $$ComponentProps = {
2
+ /** How much of the ring is filled, from 0 (none) to 1 (all of it). */
3
+ turn: number;
4
+ /** The ring's thickness, in pixels. */
5
+ thickness: number;
6
+ };
7
+ /**
8
+ * The ring `CircularProgress` and `CircularSlider` draw: a track that fills clockwise from the top
9
+ * up to `turn` (0 to 1 of a full turn), with round ends. The fill is a conic gradient drawn as a ring
10
+ * by a radial mask (which reads only the alpha of its colours), and each end of the fill is a dot as
11
+ * wide as the ring, centred on the ring's middle line, which rounds it. It fills its positioned
12
+ * parent and is hidden from assistive technology: the parent names and announces the value.
13
+ */
14
+ declare const Ring: import("svelte").Component<$$ComponentProps, {}, "">;
15
+ type Ring = ReturnType<typeof Ring>;
16
+ export default Ring;
@@ -1,7 +1,10 @@
1
1
  <!--
2
2
  @component
3
3
  A scrolling region with a thin, themed vertical scrollbar (Ark ScrollArea), shown only while the
4
- content is taller than the region.
4
+ content is taller than the region. The scrollbar keeps 8 px from the region's top and bottom, so a
5
+ rounded container's corners never cover its thumb. While the content overflows, the viewport takes
6
+ the keyboard focus, so the arrow keys scroll it even when nothing inside is focusable; it is a
7
+ region named by `label`, required.
5
8
  -->
6
9
  <script lang="ts">
7
10
  import type { Snippet } from 'svelte';
@@ -11,6 +14,7 @@ content is taller than the region.
11
14
  let {
12
15
  class: className = '',
13
16
  innerClass = '',
17
+ label,
14
18
  children,
15
19
  ...rest
16
20
  }: {
@@ -18,6 +22,11 @@ content is taller than the region.
18
22
  class?: string;
19
23
  /** Classes added to the content, inside the scrolling viewport. */
20
24
  innerClass?: string;
25
+ /**
26
+ * The region's name, translated, such as "Players": the viewport is a region of that name,
27
+ * which keyboard users reach while it scrolls.
28
+ */
29
+ label: string;
21
30
  /** The content that scrolls. */
22
31
  children?: Snippet;
23
32
  /** Other props of Ark's `ScrollArea.Root`. */
@@ -30,17 +39,28 @@ content is taller than the region.
30
39
  data-slot="scroll-area"
31
40
  {...rest}
32
41
  >
33
- <ScrollArea.Viewport
34
- class="size-full scrollbar-none rounded-[inherit] [&::-webkit-scrollbar]:hidden"
35
- >
36
- <!-- Ark measures this element to size the thumb, so it grows with the content. -->
37
- <ScrollArea.Content class={cn('min-h-full', innerClass)}>
38
- {@render children?.()}
39
- </ScrollArea.Content>
40
- </ScrollArea.Viewport>
42
+ <ScrollArea.Context>
43
+ {#snippet render(api)}
44
+ <!-- In the tab order only while there is something to scroll: the keyboard can then scroll
45
+ it even when nothing inside takes the focus. Out of it otherwise, whatever Ark decides. -->
46
+ <ScrollArea.Viewport
47
+ tabindex={api().hasOverflowY ? 0 : -1}
48
+ role="region"
49
+ aria-label={label}
50
+ class="size-full scrollbar-none rounded-[inherit] outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-inset [&::-webkit-scrollbar]:hidden"
51
+ data-slot="scroll-area-viewport"
52
+ >
53
+ <!-- Ark measures this element to size the thumb, so it grows with the content. -->
54
+ <ScrollArea.Content class={cn('min-h-full', innerClass)}>
55
+ {@render children?.()}
56
+ </ScrollArea.Content>
57
+ </ScrollArea.Viewport>
58
+ {/snippet}
59
+ </ScrollArea.Context>
41
60
  <ScrollArea.Scrollbar
42
61
  orientation="vertical"
43
- class="group/scrollbar hidden w-2.5 touch-none border-l border-l-transparent p-px transition-colors select-none data-overflow-y:flex"
62
+ data-slot="scroll-area-scrollbar"
63
+ class="group/scrollbar hidden w-2.5 touch-none border-l border-l-transparent px-px py-2 transition-colors select-none data-overflow-y:flex"
44
64
  >
45
65
  <ScrollArea.Thumb
46
66
  class="relative flex-1 rounded-full bg-border transition-colors group-data-dragging/scrollbar:bg-muted group-data-scrolling/scrollbar:bg-faint hover:bg-border-strong"
@@ -5,6 +5,11 @@ type $$ComponentProps = {
5
5
  class?: string;
6
6
  /** Classes added to the content, inside the scrolling viewport. */
7
7
  innerClass?: string;
8
+ /**
9
+ * The region's name, translated, such as "Players": the viewport is a region of that name,
10
+ * which keyboard users reach while it scrolls.
11
+ */
12
+ label: string;
8
13
  /** The content that scrolls. */
9
14
  children?: Snippet;
10
15
  /** Other props of Ark's `ScrollArea.Root`. */
@@ -12,7 +17,10 @@ type $$ComponentProps = {
12
17
  };
13
18
  /**
14
19
  * A scrolling region with a thin, themed vertical scrollbar (Ark ScrollArea), shown only while the
15
- * content is taller than the region.
20
+ * content is taller than the region. The scrollbar keeps 8 px from the region's top and bottom, so a
21
+ * rounded container's corners never cover its thumb. While the content overflows, the viewport takes
22
+ * the keyboard focus, so the arrow keys scroll it even when nothing inside is focusable; it is a
23
+ * region named by `label`, required.
16
24
  */
17
25
  declare const ScrollArea: import("svelte").Component<$$ComponentProps, {}, "">;
18
26
  type ScrollArea = ReturnType<typeof ScrollArea>;
@@ -1,32 +1,34 @@
1
1
  <!--
2
2
  @component
3
- A segmented control: a sunken track whose chosen segment is raised (Ark SegmentGroup), such as the
4
- theme or a view switch. `value` binds the chosen segment; without it, Ark's `defaultValue` sets the
5
- first one. Name the group with an `aria-label`.
3
+ A segmented control (Ark SegmentGroup), such as a view switch: with the `default` variant, a sunken
4
+ track whose chosen segment is raised; with `underline`, a row of labels with a bar under the chosen
5
+ one, for switching between the views of a page (render the view of `value` below it). The raised
6
+ segment or the bar slides to the chosen segment. `value` binds the chosen segment; without it,
7
+ Ark's `defaultValue` sets the first one. Name the group with an `aria-label`.
6
8
  -->
7
9
  <script lang="ts">
8
10
  import type { Snippet } from 'svelte';
9
11
  import { SegmentGroup, type SegmentGroupValueChangeDetails } from '@ark-ui/svelte';
10
12
  import { cn } from '../../utils.js';
11
13
 
12
- /** One segment: its value and its label (text or a snippet). */
14
+ /** One segment: its value, its label (text or a snippet), and whether it can't be chosen. */
13
15
  interface SegmentItem {
14
16
  value: string;
15
17
  label: string | Snippet;
18
+ disabled?: boolean;
16
19
  }
17
20
 
18
- type SizeConfig = { item: string };
19
-
20
- const sizes: Record<'sm' | 'md' | 'lg', SizeConfig> = {
21
- sm: { item: 'px-2 py-0.75 text-xs rounded-md' },
22
- md: { item: 'px-3 py-1 text-sm rounded-md' },
23
- lg: { item: 'px-4 py-1.5 text-base rounded-md' }
21
+ const sizes: Record<'sm' | 'md' | 'lg', string> = {
22
+ sm: 'px-2 py-0.75 text-xs',
23
+ md: 'px-3 py-1 text-sm',
24
+ lg: 'px-4 py-1.5 text-base'
24
25
  };
25
26
 
26
27
  let {
27
28
  items = [],
28
29
  class: className = '',
29
30
  size = 'md',
31
+ variant = 'default',
30
32
  value = $bindable(),
31
33
  onValueChange,
32
34
  ...rest
@@ -37,6 +39,8 @@ first one. Name the group with an `aria-label`.
37
39
  class?: string;
38
40
  /** The size of the segments and of their text. */
39
41
  size?: 'sm' | 'md' | 'lg';
42
+ /** A raised segment on a sunken track, or a bar under the chosen label. */
43
+ variant?: 'default' | 'underline';
40
44
  /** The chosen segment's value; `null` when none is. */
41
45
  value?: string | null;
42
46
  /** Called on every change of the value, after `value` is updated. */
@@ -45,8 +49,6 @@ first one. Name the group with an `aria-label`.
45
49
  [key: string]: unknown;
46
50
  } = $props();
47
51
 
48
- const sz = $derived(sizes[size]);
49
-
50
52
  function isSnippet(v: string | Snippet): v is Snippet {
51
53
  return typeof v === 'function';
52
54
  }
@@ -54,10 +56,14 @@ first one. Name the group with an `aria-label`.
54
56
 
55
57
  <SegmentGroup.Root
56
58
  class={cn(
57
- 'inline-flex items-stretch gap-1 rounded-lg border border-border bg-hover p-1',
59
+ 'relative inline-flex items-stretch',
60
+ variant === 'default'
61
+ ? 'gap-1 rounded-lg border border-border bg-hover p-1'
62
+ : 'gap-1 border-b border-border',
58
63
  className
59
64
  )}
60
65
  data-slot="segment-group"
66
+ data-variant={variant}
61
67
  {value}
62
68
  onValueChange={(details) => {
63
69
  value = details.value;
@@ -65,16 +71,31 @@ first one. Name the group with an `aria-label`.
65
71
  }}
66
72
  {...rest}
67
73
  >
74
+ <!-- Ark sets the chosen segment's box as --left, --top, --width and --height, and moves the
75
+ indicator there as the value changes, with its own inline transition, which reads the duration
76
+ and the easing from the variables set here (none under reduced motion). The underline's bar
77
+ takes only the box's left and width, and sits on the bottom border (Ark sets `top`
78
+ itself, which `top: auto` undoes). -->
68
79
  <SegmentGroup.Indicator
69
- class="absolute rounded-md border border-border bg-background shadow-sm transition-all"
70
- style="left: var(--left); top: var(--top); width: var(--width); height: var(--height);"
80
+ class={cn(
81
+ 'absolute [--transition-duration:200ms] [--transition-timing-function:var(--ease-standard)] motion-reduce:[--transition-duration:0ms]',
82
+ variant === 'default'
83
+ ? 'rounded-md border border-border bg-background shadow-sm'
84
+ : '-bottom-px h-0.5 rounded-full bg-primary'
85
+ )}
86
+ style={variant === 'default'
87
+ ? 'left: var(--left); top: var(--top); width: var(--width); height: var(--height);'
88
+ : 'left: var(--left); width: var(--width); top: auto;'}
89
+ data-slot="segment-group-indicator"
71
90
  />
72
91
  {#each items as item (item.value)}
73
92
  <SegmentGroup.Item
74
93
  value={item.value}
94
+ disabled={item.disabled}
75
95
  class={cn(
76
- 'relative z-10 flex items-center justify-center font-medium text-muted transition-colors data-focus-visible:ring-2 data-focus-visible:ring-primary data-[state=checked]:text-fg',
77
- sz.item
96
+ 'relative z-10 flex cursor-pointer items-center justify-center rounded-md font-medium whitespace-nowrap text-muted transition-colors hover:text-fg data-disabled:cursor-not-allowed data-disabled:opacity-50 data-focus-visible:ring-2 data-focus-visible:ring-primary data-[state=checked]:text-fg',
97
+ sizes[size],
98
+ variant === 'underline' && 'pb-2'
78
99
  )}
79
100
  data-slot="segment-group-item"
80
101
  >
@@ -1,9 +1,10 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import { SegmentGroup, type SegmentGroupValueChangeDetails } from '@ark-ui/svelte';
3
- /** One segment: its value and its label (text or a snippet). */
3
+ /** One segment: its value, its label (text or a snippet), and whether it can't be chosen. */
4
4
  interface SegmentItem {
5
5
  value: string;
6
6
  label: string | Snippet;
7
+ disabled?: boolean;
7
8
  }
8
9
  type $$ComponentProps = {
9
10
  /** The segments, in order. */
@@ -12,6 +13,8 @@ type $$ComponentProps = {
12
13
  class?: string;
13
14
  /** The size of the segments and of their text. */
14
15
  size?: 'sm' | 'md' | 'lg';
16
+ /** A raised segment on a sunken track, or a bar under the chosen label. */
17
+ variant?: 'default' | 'underline';
15
18
  /** The chosen segment's value; `null` when none is. */
16
19
  value?: string | null;
17
20
  /** Called on every change of the value, after `value` is updated. */
@@ -20,9 +23,11 @@ type $$ComponentProps = {
20
23
  [key: string]: unknown;
21
24
  };
22
25
  /**
23
- * A segmented control: a sunken track whose chosen segment is raised (Ark SegmentGroup), such as the
24
- * theme or a view switch. `value` binds the chosen segment; without it, Ark's `defaultValue` sets the
25
- * first one. Name the group with an `aria-label`.
26
+ * A segmented control (Ark SegmentGroup), such as a view switch: with the `default` variant, a sunken
27
+ * track whose chosen segment is raised; with `underline`, a row of labels with a bar under the chosen
28
+ * one, for switching between the views of a page (render the view of `value` below it). The raised
29
+ * segment or the bar slides to the chosen segment. `value` binds the chosen segment; without it,
30
+ * Ark's `defaultValue` sets the first one. Name the group with an `aria-label`.
26
31
  */
27
32
  declare const SegmentGroup: import("svelte").Component<$$ComponentProps, {}, "value">;
28
33
  type SegmentGroup = ReturnType<typeof SegmentGroup>;
@@ -2,7 +2,7 @@
2
2
  @component
3
3
  A select field with a dropdown list of options (Ark Select); `value` binds the chosen values
4
4
  (without it, Ark's `defaultValue` sets the first ones) and `placeholder` shows while none is
5
- chosen. `label`, required, names the field.
5
+ chosen. `label`, required, names the field. Ark's `invalid` turns the field's border danger.
6
6
  -->
7
7
  <script lang="ts">
8
8
  import { Select, createListCollection, type SelectValueChangeDetails } from '@ark-ui/svelte';
@@ -64,7 +64,7 @@ chosen. `label`, required, names the field.
64
64
  <Select.Control class="isolate">
65
65
  <Select.Trigger
66
66
  class={cn(
67
- 'flex h-9 w-full items-center justify-between rounded-lg border border-border bg-sunken px-3 py-2 text-sm text-fg shadow-sm transition-colors outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50 data-placeholder:text-muted',
67
+ 'flex h-9 w-full items-center justify-between rounded-lg border border-border bg-sunken px-3 py-2 text-sm text-fg shadow-sm transition-colors outline-none focus-visible:border-primary focus-visible:ring-2 focus-visible:ring-primary disabled:cursor-not-allowed disabled:opacity-50 data-invalid:border-danger data-invalid:focus-visible:ring-danger data-placeholder-shown:text-muted',
68
68
  triggerClass
69
69
  )}
70
70
  data-slot="select-trigger"
@@ -28,7 +28,7 @@ type $$ComponentProps = {
28
28
  /**
29
29
  * A select field with a dropdown list of options (Ark Select); `value` binds the chosen values
30
30
  * (without it, Ark's `defaultValue` sets the first ones) and `placeholder` shows while none is
31
- * chosen. `label`, required, names the field.
31
+ * chosen. `label`, required, names the field. Ark's `invalid` turns the field's border danger.
32
32
  */
33
33
  declare const Select: import("svelte").Component<$$ComponentProps, {}, "value">;
34
34
  type Select = ReturnType<typeof Select>;
@@ -1,21 +1,26 @@
1
1
  <!--
2
2
  @component
3
3
  A modal panel that slides in from one side of the window (Ark Dialog); `closeLabel` names its
4
- close button; `frosted` for a translucent surface. The trigger is a button holding the `trigger`
5
- snippet, styled by `triggerClass`; the title and description name and describe the panel. `open`
6
- binds whether it is open; without it, Ark's `defaultOpen` sets the first state.
4
+ close button, which shows it as a tooltip too; `frosted` for a translucent surface. The trigger is
5
+ a button holding the `trigger` snippet, styled by `triggerClass`, and a trigger that shows only an
6
+ icon takes a `triggerLabel`: its accessible name and its tooltip. The title and description name
7
+ and describe the panel. `open` binds whether it is open; without it, Ark's `defaultOpen` sets the
8
+ first state.
7
9
  -->
8
10
  <script lang="ts">
9
- import type { Snippet } from 'svelte';
11
+ import type { ComponentProps, Snippet } from 'svelte';
10
12
  import { Dialog, type DialogOpenChangeDetails } from '@ark-ui/svelte';
11
13
  import { Portal } from '@ark-ui/svelte/portal';
12
14
  import { cn } from '../../utils.js';
15
+ import Tooltip from '../tooltip/Tooltip.svelte';
16
+ import { setDialogContext } from '../dialog/context';
13
17
  import MingcuteCloseLine from '~icons/mingcute/close-line';
14
18
 
15
19
  type Side = 'top' | 'bottom' | 'left' | 'right';
16
20
 
17
21
  let {
18
- trigger,
22
+ trigger: triggerContent,
23
+ triggerLabel,
19
24
  triggerClass = '',
20
25
  title,
21
26
  description,
@@ -28,10 +33,16 @@ binds whether it is open; without it, Ark's `defaultOpen` sets the first state.
28
33
  class: className = '',
29
34
  open = $bindable(),
30
35
  onOpenChange,
36
+ ids: appIds,
31
37
  ...rest
32
38
  }: {
33
39
  /** The trigger button's content; without it, the sheet opens only through `open`. */
34
40
  trigger?: Snippet;
41
+ /**
42
+ * The trigger's action, translated, such as "Open the menu", for a trigger that shows only an
43
+ * icon: its accessible name and its tooltip. Unset, the trigger's content names it.
44
+ */
45
+ triggerLabel?: string;
35
46
  /** Classes of the trigger button, such as `buttonVariants(...)`. */
36
47
  triggerClass?: string;
37
48
  /** The panel's title, which names it. */
@@ -46,7 +57,7 @@ binds whether it is open; without it, Ark's `defaultOpen` sets the first state.
46
57
  side?: Side;
47
58
  /** Shows the close button in the top corner. */
48
59
  showClose?: boolean;
49
- /** The close button's accessible name, such as "Close". */
60
+ /** The close button's accessible name and tooltip, such as "Close". */
50
61
  closeLabel: string;
51
62
  /** A translucent, blurred surface: for overlays above busy content only. */
52
63
  frosted?: boolean;
@@ -56,6 +67,8 @@ binds whether it is open; without it, Ark's `defaultOpen` sets the first state.
56
67
  open?: boolean;
57
68
  /** Called when the panel opens or closes, after `open` is updated. */
58
69
  onOpenChange?: (details: DialogOpenChangeDetails) => void;
70
+ /** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
71
+ ids?: ComponentProps<typeof Dialog.Root>['ids'];
59
72
  /** Other props of Ark's `Dialog.Root`. */
60
73
  [key: string]: unknown;
61
74
  } = $props();
@@ -68,9 +81,17 @@ binds whether it is open; without it, Ark's `defaultOpen` sets the first state.
68
81
  right:
69
82
  'inset-y-0 right-0 border-l data-[state=open]:animate-sheet-enter-right data-[state=closed]:animate-sheet-exit-right h-full w-full max-w-sm rounded-l-xl'
70
83
  };
84
+
85
+ const uid = $props.id();
86
+ // The ids of the buttons that have a tooltip, shared by Ark's dialog and the tooltips, which
87
+ // both find them by id.
88
+ const triggerId = `${uid}-trigger`;
89
+ const closeTriggerId = `${uid}-close`;
90
+ setDialogContext({ closeTriggerId });
71
91
  </script>
72
92
 
73
93
  <Dialog.Root
94
+ ids={{ ...appIds, trigger: triggerId, closeTrigger: closeTriggerId }}
74
95
  {open}
75
96
  onOpenChange={(details) => {
76
97
  open = details.open;
@@ -78,9 +99,22 @@ binds whether it is open; without it, Ark's `defaultOpen` sets the first state.
78
99
  }}
79
100
  {...rest}
80
101
  >
81
- {#if trigger}
102
+ {#if triggerContent && triggerLabel}
103
+ <Tooltip content={triggerLabel} {triggerId}>
104
+ {#snippet trigger(props)}
105
+ <Dialog.Trigger
106
+ {...props}
107
+ aria-label={triggerLabel}
108
+ class={triggerClass || undefined}
109
+ data-slot="sheet-trigger"
110
+ >
111
+ {@render triggerContent()}
112
+ </Dialog.Trigger>
113
+ {/snippet}
114
+ </Tooltip>
115
+ {:else if triggerContent}
82
116
  <Dialog.Trigger class={triggerClass || undefined} data-slot="sheet-trigger">
83
- {@render trigger()}
117
+ {@render triggerContent()}
84
118
  </Dialog.Trigger>
85
119
  {/if}
86
120
  <Portal>
@@ -98,13 +132,18 @@ binds whether it is open; without it, Ark's `defaultOpen` sets the first state.
98
132
  data-slot="sheet-content"
99
133
  >
100
134
  {#if showClose}
101
- <Dialog.CloseTrigger
102
- class="absolute top-3.5 right-3.5 inline-flex size-7 items-center justify-center rounded-md text-muted transition-colors outline-none hover:bg-hover hover:text-fg focus-visible:ring-2 focus-visible:ring-primary"
103
- aria-label={closeLabel}
104
- data-slot="sheet-close"
105
- >
106
- <MingcuteCloseLine class="size-4" aria-hidden="true" />
107
- </Dialog.CloseTrigger>
135
+ <Tooltip content={closeLabel} triggerId={closeTriggerId}>
136
+ {#snippet trigger(props)}
137
+ <Dialog.CloseTrigger
138
+ {...props}
139
+ class="absolute top-3.5 right-3.5 inline-flex size-7 items-center justify-center rounded-md text-muted transition-colors outline-none hover:bg-hover hover:text-fg focus-visible:ring-2 focus-visible:ring-primary"
140
+ aria-label={closeLabel}
141
+ data-slot="sheet-close"
142
+ >
143
+ <MingcuteCloseLine class="size-4" aria-hidden="true" />
144
+ </Dialog.CloseTrigger>
145
+ {/snippet}
146
+ </Tooltip>
108
147
  {/if}
109
148
  {#if title || description}
110
149
  <div