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
@@ -0,0 +1,204 @@
1
+ <!--
2
+ @component
3
+ The calendar's three views (days, months, years) and their controls, shared by `Calendar` and the
4
+ popover of `DatePicker`; rendered inside Ark's `DatePicker.Root`, whose state it shows. The day view
5
+ always shows six weeks (the root sets `fixedWeeks`), and the month and year views take exactly its
6
+ size, so the calendar never changes size as the user moves between them. The previous and next
7
+ buttons show their accessible name in a tooltip too, and the view switch is named by the visible
8
+ month, year or decade first, then by what it does, so its name holds its label (WCAG 2.5.3).
9
+ -->
10
+ <script lang="ts">
11
+ import { DatePicker, type DatePickerRootProps } from '@ark-ui/svelte';
12
+ import type { DatePickerDateView } from '@ark-ui/svelte/date-picker';
13
+ import { cn } from '../../utils.js';
14
+ import MingcuteLeftLine from '~icons/mingcute/left-line';
15
+ import MingcuteRightLine from '~icons/mingcute/right-line';
16
+ import Tooltip from '../tooltip/Tooltip.svelte';
17
+ import type { CalendarTriggerIds } from './trigger-ids';
18
+
19
+ let {
20
+ ids,
21
+ translations,
22
+ tableRoleDescription,
23
+ maxView = 'year'
24
+ }: {
25
+ /** The ids of the previous and next buttons, the root's own (`calendarTriggerIds`). */
26
+ ids: CalendarTriggerIds;
27
+ /** The names of the previous and next buttons and of the view switch, as the root has them. */
28
+ translations: Required<
29
+ Pick<
30
+ NonNullable<DatePickerRootProps['translations']>,
31
+ 'prevTrigger' | 'nextTrigger' | 'viewTrigger'
32
+ >
33
+ >;
34
+ /** The role the table of each view is announced as, such as "calendar month" for `day`. */
35
+ tableRoleDescription: (view: DatePickerDateView) => string;
36
+ /** The root's widest view, which has no view to switch to. */
37
+ maxView?: DatePickerDateView;
38
+ } = $props();
39
+
40
+ const views: DatePickerDateView[] = ['day', 'month', 'year'];
41
+
42
+ /** The view the view switch opens from `view`, as Ark picks it; none from the widest view. */
43
+ function nextView(view: DatePickerDateView): DatePickerDateView | undefined {
44
+ const next = views.indexOf(view) + 1;
45
+ return next <= views.indexOf(maxView) ? views[next] : undefined;
46
+ }
47
+
48
+ /** The text Ark's `RangeText` shows: the visible month, year or decade, or a range of them. */
49
+ function rangeText({ start, end }: { start: string; end: string }): string {
50
+ return [...new Set([start, end])].filter(Boolean).join(' - ');
51
+ }
52
+
53
+ const cellClass = cn(
54
+ 'inline-flex items-center justify-center',
55
+ 'h-9 w-full min-w-9',
56
+ 'whitespace-nowrap font-normal text-sm text-fg leading-none',
57
+ 'rounded-lg border border-transparent',
58
+ 'hover:bg-hover hover:text-fg',
59
+ 'data-today:after:absolute data-today:after:bottom-1 data-today:after:left-1/2 data-today:after:size-1 data-today:after:-translate-x-1/2 data-today:after:rounded-full data-today:after:bg-primary data-today:data-selected:after:bg-background',
60
+ 'outline-none focus-visible:border-primary focus-visible:ring-[3px] focus-visible:ring-primary/30',
61
+ 'data-disabled:pointer-events-none data-disabled:opacity-64',
62
+ 'data-unavailable:pointer-events-none data-unavailable:line-through data-unavailable:opacity-64',
63
+ 'data-selected:bg-primary! data-selected:text-on-primary!'
64
+ );
65
+
66
+ const navButtonClass = cn(
67
+ 'inline-flex items-center justify-center size-8 rounded-lg border border-border',
68
+ 'bg-transparent hover:bg-hover hover:text-fg',
69
+ 'disabled:opacity-40 transition-colors'
70
+ );
71
+
72
+ // Every view has the day view's size (cells of --cell-size, which the root sets): seven cells wide; the view control (h-8), the gap under
73
+ // it and seven rows (the weekday names and six weeks) of a cell and its top margin (mt-1) high.
74
+ const viewClass =
75
+ 'flex h-[calc(var(--spacing)*16+var(--cell-size)*7)] w-[calc(var(--cell-size)*7)] flex-col gap-1';
76
+
77
+ // The month and year grids stretch their rows and cells over that size, four to a row (the
78
+ // columns Ark's arrow keys move by in those views, and the grid-cols-4 of their rows).
79
+ const gridColumns = 4;
80
+ </script>
81
+
82
+ {#snippet viewControl(view: DatePickerDateView)}
83
+ <DatePicker.ViewControl
84
+ class="relative flex h-auto w-full items-center gap-1.5"
85
+ data-slot="calendar-view-control"
86
+ >
87
+ <Tooltip content={translations.prevTrigger(view)} triggerId={ids.prevTrigger(view)}>
88
+ {#snippet trigger(props)}
89
+ <DatePicker.PrevTrigger {...props} class={navButtonClass} data-slot="calendar-prev-trigger">
90
+ <MingcuteLeftLine class="size-4" aria-hidden="true" />
91
+ </DatePicker.PrevTrigger>
92
+ {/snippet}
93
+ </Tooltip>
94
+ <DatePicker.Context>
95
+ {#snippet render(api)}
96
+ <!-- Named by the visible month, year or decade first, then by what it does, so its
97
+ name holds its label (WCAG 2.5.3). -->
98
+ <DatePicker.ViewTrigger
99
+ class="h-8 flex-1 rounded-lg px-2 text-sm font-medium transition-colors hover:bg-hover hover:text-fg"
100
+ aria-label="{rangeText(api().visibleRangeText)}, {translations.viewTrigger(
101
+ view,
102
+ nextView(view)
103
+ )}"
104
+ data-slot="calendar-view-trigger"
105
+ >
106
+ <DatePicker.RangeText data-slot="calendar-range-text" />
107
+ </DatePicker.ViewTrigger>
108
+ {/snippet}
109
+ </DatePicker.Context>
110
+ <Tooltip content={translations.nextTrigger(view)} triggerId={ids.nextTrigger(view)}>
111
+ {#snippet trigger(props)}
112
+ <DatePicker.NextTrigger {...props} class={navButtonClass} data-slot="calendar-next-trigger">
113
+ <MingcuteRightLine class="size-4" aria-hidden="true" />
114
+ </DatePicker.NextTrigger>
115
+ {/snippet}
116
+ </Tooltip>
117
+ </DatePicker.ViewControl>
118
+ {/snippet}
119
+
120
+ {#snippet grid(view: 'month' | 'year', cells: { label: string; value: number }[][])}
121
+ <DatePicker.Table
122
+ class="flex w-full flex-1 border-collapse flex-col"
123
+ aria-roledescription={tableRoleDescription(view)}
124
+ data-slot="calendar-table"
125
+ >
126
+ <DatePicker.TableBody class="flex flex-1 flex-col gap-1 pt-1">
127
+ {#each cells as row (row[0].value)}
128
+ <DatePicker.TableRow class="grid w-full flex-1 grid-cols-4 gap-1">
129
+ {#each row as cell (cell.value)}
130
+ <DatePicker.TableCell class="relative text-center" value={cell.value}>
131
+ <DatePicker.TableCellTrigger class={cn(cellClass, 'h-full')}>
132
+ {cell.label}
133
+ </DatePicker.TableCellTrigger>
134
+ </DatePicker.TableCell>
135
+ {/each}
136
+ </DatePicker.TableRow>
137
+ {/each}
138
+ </DatePicker.TableBody>
139
+ </DatePicker.Table>
140
+ {/snippet}
141
+
142
+ <DatePicker.View view="day" class={viewClass} data-slot="calendar-view">
143
+ {@render viewControl('day')}
144
+ <DatePicker.Context>
145
+ {#snippet render(api)}
146
+ <DatePicker.Table
147
+ class="group w-full border-collapse"
148
+ aria-roledescription={tableRoleDescription('day')}
149
+ data-slot="calendar-table"
150
+ >
151
+ <DatePicker.TableHead data-slot="calendar-table-head">
152
+ <DatePicker.TableRow class="mt-1 flex w-full" data-slot="calendar-table-row">
153
+ {#each api().weekDays as weekDay (weekDay.long)}
154
+ <DatePicker.TableHeader
155
+ class="flex h-(--cell-size) w-full items-center justify-center rounded-lg text-xs font-medium text-faint"
156
+ data-slot="calendar-table-header"
157
+ >
158
+ {weekDay.narrow}
159
+ </DatePicker.TableHeader>
160
+ {/each}
161
+ </DatePicker.TableRow>
162
+ </DatePicker.TableHead>
163
+ <DatePicker.TableBody data-slot="calendar-table-body">
164
+ {#each api().weeks as week (week[0].toString())}
165
+ <DatePicker.TableRow class="mt-1 flex w-full" data-slot="calendar-table-row">
166
+ {#each week as day (day.toString())}
167
+ <DatePicker.TableCell
168
+ class="relative h-(--cell-size) w-full text-center [&:first-child[aria-selected=true]_div]:rounded-l-lg [&:last-child[aria-selected=true]_div]:rounded-r-lg"
169
+ data-slot="calendar-table-cell"
170
+ value={day}
171
+ >
172
+ <DatePicker.TableCellTrigger
173
+ class={cellClass}
174
+ data-slot="calendar-table-cell-trigger"
175
+ >
176
+ {day.day}
177
+ </DatePicker.TableCellTrigger>
178
+ </DatePicker.TableCell>
179
+ {/each}
180
+ </DatePicker.TableRow>
181
+ {/each}
182
+ </DatePicker.TableBody>
183
+ </DatePicker.Table>
184
+ {/snippet}
185
+ </DatePicker.Context>
186
+ </DatePicker.View>
187
+
188
+ <DatePicker.View view="month" class={viewClass} data-slot="calendar-month-view">
189
+ {@render viewControl('month')}
190
+ <DatePicker.Context>
191
+ {#snippet render(api)}
192
+ {@render grid('month', api().getMonthsGrid({ columns: gridColumns, format: 'short' }))}
193
+ {/snippet}
194
+ </DatePicker.Context>
195
+ </DatePicker.View>
196
+
197
+ <DatePicker.View view="year" class={viewClass} data-slot="calendar-year-view">
198
+ {@render viewControl('year')}
199
+ <DatePicker.Context>
200
+ {#snippet render(api)}
201
+ {@render grid('year', api().getYearsGrid({ columns: gridColumns }))}
202
+ {/snippet}
203
+ </DatePicker.Context>
204
+ </DatePicker.View>
@@ -0,0 +1,24 @@
1
+ import { type DatePickerRootProps } from '@ark-ui/svelte';
2
+ import type { DatePickerDateView } from '@ark-ui/svelte/date-picker';
3
+ import type { CalendarTriggerIds } from './trigger-ids';
4
+ type $$ComponentProps = {
5
+ /** The ids of the previous and next buttons, the root's own (`calendarTriggerIds`). */
6
+ ids: CalendarTriggerIds;
7
+ /** The names of the previous and next buttons and of the view switch, as the root has them. */
8
+ translations: Required<Pick<NonNullable<DatePickerRootProps['translations']>, 'prevTrigger' | 'nextTrigger' | 'viewTrigger'>>;
9
+ /** The role the table of each view is announced as, such as "calendar month" for `day`. */
10
+ tableRoleDescription: (view: DatePickerDateView) => string;
11
+ /** The root's widest view, which has no view to switch to. */
12
+ maxView?: DatePickerDateView;
13
+ };
14
+ /**
15
+ * The calendar's three views (days, months, years) and their controls, shared by `Calendar` and the
16
+ * popover of `DatePicker`; rendered inside Ark's `DatePicker.Root`, whose state it shows. The day view
17
+ * always shows six weeks (the root sets `fixedWeeks`), and the month and year views take exactly its
18
+ * size, so the calendar never changes size as the user moves between them. The previous and next
19
+ * buttons show their accessible name in a tooltip too, and the view switch is named by the visible
20
+ * month, year or decade first, then by what it does, so its name holds its label (WCAG 2.5.3).
21
+ */
22
+ declare const CalendarViews: import("svelte").Component<$$ComponentProps, {}, "">;
23
+ type CalendarViews = ReturnType<typeof CalendarViews>;
24
+ export default CalendarViews;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The ids of the calendar's previous and next buttons, which both Ark's date picker (through its
3
+ * `ids`) and their tooltips find them by: `Calendar` and `DatePicker` pass the same ids to their
4
+ * root and to `CalendarViews`.
5
+ * @module
6
+ */
7
+ import type { DatePickerDateView } from '@ark-ui/svelte/date-picker';
8
+ /** The previous and next buttons' ids, for each view. */
9
+ export interface CalendarTriggerIds {
10
+ prevTrigger: (view: DatePickerDateView) => string;
11
+ nextTrigger: (view: DatePickerDateView) => string;
12
+ }
13
+ /** The ids of the previous and next buttons of the calendar whose unique id is `uid`. */
14
+ export declare function calendarTriggerIds(uid: string): CalendarTriggerIds;
@@ -0,0 +1,7 @@
1
+ /** The ids of the previous and next buttons of the calendar whose unique id is `uid`. */
2
+ export function calendarTriggerIds(uid) {
3
+ return {
4
+ prevTrigger: (view) => `${uid}-previous-${view}`,
5
+ nextTrigger: (view) => `${uid}-next-${view}`
6
+ };
7
+ }
@@ -1,7 +1,8 @@
1
1
  <!--
2
2
  @component
3
3
  A surface that groups related content: an optional title and description, the content, and an
4
- optional footer.
4
+ optional footer. The title is a heading of `headingLevel` (3 by default, a card inside a section
5
+ of the page), so the page's outline stays in order.
5
6
  -->
6
7
  <script lang="ts">
7
8
  import type { Snippet } from 'svelte';
@@ -10,6 +11,7 @@ optional footer.
10
11
  let {
11
12
  class: className = '',
12
13
  title,
14
+ headingLevel = 3,
13
15
  description,
14
16
  children,
15
17
  footer,
@@ -19,6 +21,8 @@ optional footer.
19
21
  class?: string;
20
22
  /** The card's title, at its top. */
21
23
  title?: string;
24
+ /** The title's heading level: 3 for a card inside a section, 2 for one right under the page's title. */
25
+ headingLevel?: 2 | 3 | 4 | 5 | 6;
22
26
  /** A line under the title. */
23
27
  description?: string;
24
28
  /** The card's content. */
@@ -41,7 +45,9 @@ optional footer.
41
45
  {#if title || description}
42
46
  <div class="flex flex-col gap-1 px-4 pt-3.5" data-slot="card-header">
43
47
  {#if title}
44
- <h3 class="text-md font-bold" data-slot="card-title">{title}</h3>
48
+ <svelte:element this={`h${headingLevel}`} class="text-md font-bold" data-slot="card-title">
49
+ {title}
50
+ </svelte:element>
45
51
  {/if}
46
52
  {#if description}
47
53
  <p class="text-sm text-muted" data-slot="card-description">{description}</p>
@@ -4,6 +4,8 @@ type $$ComponentProps = {
4
4
  class?: string;
5
5
  /** The card's title, at its top. */
6
6
  title?: string;
7
+ /** The title's heading level: 3 for a card inside a section, 2 for one right under the page's title. */
8
+ headingLevel?: 2 | 3 | 4 | 5 | 6;
7
9
  /** A line under the title. */
8
10
  description?: string;
9
11
  /** The card's content. */
@@ -15,7 +17,8 @@ type $$ComponentProps = {
15
17
  };
16
18
  /**
17
19
  * A surface that groups related content: an optional title and description, the content, and an
18
- * optional footer.
20
+ * optional footer. The title is a heading of `headingLevel` (3 by default, a card inside a section
21
+ * of the page), so the page's outline stays in order.
19
22
  */
20
23
  declare const Card: import("svelte").Component<$$ComponentProps, {}, "">;
21
24
  type Card = ReturnType<typeof Card>;
@@ -2,12 +2,14 @@
2
2
  @component
3
3
  A horizontal slideshow with previous and next controls and indicators (Ark Carousel);
4
4
  `translations` name the slides and the controls and give the roles the carousel and its slides are
5
- announced as.
5
+ announced as. The arrows and the dots have no text, so each shows its name in a tooltip, the same
6
+ text as its accessible name.
6
7
  -->
7
8
  <script lang="ts">
8
- import type { Snippet } from 'svelte';
9
+ import type { ComponentProps, Snippet } from 'svelte';
9
10
  import { Carousel, type CarouselRootProps } from '@ark-ui/svelte';
10
11
  import { cn } from '../../utils.js';
12
+ import Tooltip from '../tooltip/Tooltip.svelte';
11
13
  import MingcuteLeftLine from '~icons/mingcute/left-line';
12
14
  import MingcuteRightLine from '~icons/mingcute/right-line';
13
15
 
@@ -18,6 +20,7 @@ announced as.
18
20
  showIndicators = true,
19
21
  showArrows = true,
20
22
  translations,
23
+ ids: appIds,
21
24
  ...rest
22
25
  }: {
23
26
  /** The slides, in order. */
@@ -42,16 +45,32 @@ announced as.
42
45
  'item' | 'indicator' | 'prevTrigger' | 'nextTrigger'
43
46
  >
44
47
  > & { roleDescription: string; slideRoleDescription: string };
48
+ /** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
49
+ ids?: ComponentProps<typeof Carousel.Root>['ids'];
45
50
  /** Other props of Ark's `Carousel.Root`: `page` and `onPageChange`, `loop`, `slidesPerPage`. */
46
51
  [key: string]: unknown;
47
52
  } = $props();
48
53
 
54
+ /** The look of the previous and next buttons, which differ only by their side. */
55
+ const arrowClass =
56
+ 'inline-flex size-8 -translate-y-1/2 items-center justify-center rounded-full border border-border bg-raised text-fg shadow-sm transition-colors hover:bg-background disabled:opacity-50';
57
+
58
+ // The tooltips and the carousel name each button with the same id: the tooltip finds its
59
+ // trigger by it, and the carousel moves the focus between its dots by it.
60
+ const uid = $props.id();
61
+ const ids = {
62
+ prevTrigger: `${uid}-previous`,
63
+ nextTrigger: `${uid}-next`,
64
+ indicator: (index: number) => `${uid}-indicator-${index}`
65
+ };
66
+
49
67
  const slideCount = $derived(slides.length);
50
68
  const { roleDescription, slideRoleDescription, ...arkTranslations } = $derived(translations);
51
69
  </script>
52
70
 
53
71
  <Carousel.Root
54
72
  {slideCount}
73
+ ids={{ ...appIds, ...ids }}
55
74
  translations={arkTranslations}
56
75
  aria-roledescription={roleDescription}
57
76
  aria-label={label}
@@ -73,18 +92,30 @@ announced as.
73
92
  {/each}
74
93
  </Carousel.ItemGroup>
75
94
  {#if showArrows}
76
- <Carousel.PrevTrigger
77
- class="absolute top-1/2 left-3 z-10 inline-flex size-8 -translate-y-1/2 items-center justify-center rounded-full border border-border bg-raised text-fg shadow-sm transition-colors hover:bg-background disabled:opacity-50"
78
- data-slot="carousel-prev"
79
- >
80
- <MingcuteLeftLine class="size-4" aria-hidden="true" />
81
- </Carousel.PrevTrigger>
82
- <Carousel.NextTrigger
83
- class="absolute top-1/2 right-3 z-10 inline-flex size-8 -translate-y-1/2 items-center justify-center rounded-full border border-border bg-raised text-fg shadow-sm transition-colors hover:bg-background disabled:opacity-50"
84
- data-slot="carousel-next"
85
- >
86
- <MingcuteRightLine class="size-4" aria-hidden="true" />
87
- </Carousel.NextTrigger>
95
+ <Tooltip content={arkTranslations.prevTrigger} triggerId={ids.prevTrigger}>
96
+ {#snippet trigger(props)}
97
+ <Carousel.PrevTrigger
98
+ {...props}
99
+ aria-label={arkTranslations.prevTrigger}
100
+ class={['absolute top-1/2 left-3 z-10', arrowClass]}
101
+ data-slot="carousel-prev"
102
+ >
103
+ <MingcuteLeftLine class="size-4" aria-hidden="true" />
104
+ </Carousel.PrevTrigger>
105
+ {/snippet}
106
+ </Tooltip>
107
+ <Tooltip content={arkTranslations.nextTrigger} triggerId={ids.nextTrigger}>
108
+ {#snippet trigger(props)}
109
+ <Carousel.NextTrigger
110
+ {...props}
111
+ aria-label={arkTranslations.nextTrigger}
112
+ class={['absolute top-1/2 right-3 z-10', arrowClass]}
113
+ data-slot="carousel-next"
114
+ >
115
+ <MingcuteRightLine class="size-4" aria-hidden="true" />
116
+ </Carousel.NextTrigger>
117
+ {/snippet}
118
+ </Tooltip>
88
119
  {/if}
89
120
  {#if showIndicators}
90
121
  <Carousel.IndicatorGroup
@@ -93,11 +124,18 @@ announced as.
93
124
  >
94
125
  <!-- eslint-disable-next-line @typescript-eslint/no-unused-vars -->
95
126
  {#each slides as _, i (i)}
96
- <Carousel.Indicator
97
- index={i}
98
- class="size-1.5 rounded-full bg-faint transition-all data-current:w-4 data-current:bg-primary"
99
- data-slot="carousel-indicator"
100
- />
127
+ {@const name = arkTranslations.indicator(i)}
128
+ <Tooltip content={name} triggerId={ids.indicator(i)}>
129
+ {#snippet trigger(props)}
130
+ <Carousel.Indicator
131
+ {...props}
132
+ index={i}
133
+ aria-label={name}
134
+ class="size-1.5 rounded-full bg-faint transition-all data-current:w-4 data-current:bg-primary"
135
+ data-slot="carousel-indicator"
136
+ />
137
+ {/snippet}
138
+ </Tooltip>
101
139
  {/each}
102
140
  </Carousel.IndicatorGroup>
103
141
  {/if}
@@ -1,4 +1,4 @@
1
- import type { Snippet } from 'svelte';
1
+ import type { ComponentProps, Snippet } from 'svelte';
2
2
  import { Carousel, type CarouselRootProps } from '@ark-ui/svelte';
3
3
  type $$ComponentProps = {
4
4
  /** The slides, in order. */
@@ -21,13 +21,16 @@ type $$ComponentProps = {
21
21
  roleDescription: string;
22
22
  slideRoleDescription: string;
23
23
  };
24
+ /** Ark's `ids`, merged with the ids the kit gives the buttons it adds a tooltip to, which win. */
25
+ ids?: ComponentProps<typeof Carousel.Root>['ids'];
24
26
  /** Other props of Ark's `Carousel.Root`: `page` and `onPageChange`, `loop`, `slidesPerPage`. */
25
27
  [key: string]: unknown;
26
28
  };
27
29
  /**
28
30
  * A horizontal slideshow with previous and next controls and indicators (Ark Carousel);
29
31
  * `translations` name the slides and the controls and give the roles the carousel and its slides are
30
- * announced as.
32
+ * announced as. The arrows and the dots have no text, so each shows its name in a tooltip, the same
33
+ * text as its accessible name.
31
34
  */
32
35
  declare const Carousel: import("svelte").Component<$$ComponentProps, {}, "">;
33
36
  type Carousel = ReturnType<typeof Carousel>;
@@ -1,13 +1,13 @@
1
1
  <!--
2
2
  @component
3
3
  A checkbox with its label (Ark Checkbox); `checked` binds true, false or indeterminate, drawn
4
- as a check or a dash.
4
+ as a check or a dash (a rounded bar as thick as the check).
5
5
  -->
6
6
  <script lang="ts">
7
7
  import type { Snippet } from 'svelte';
8
8
  import { Checkbox, type CheckboxCheckedChangeDetails } from '@ark-ui/svelte';
9
9
  import MingcuteCheckFill from '~icons/mingcute/check-fill';
10
- import MingcuteSubtractFill from '~icons/mingcute/subtract-fill';
10
+ import MingcuteMinimizeFill from '~icons/mingcute/minimize-fill';
11
11
  import { cn } from '../../utils.js';
12
12
 
13
13
  type SizeConfig = { control: string; icon: number; label: string };
@@ -43,7 +43,7 @@ as a check or a dash.
43
43
  [key: string]: unknown;
44
44
  } = $props();
45
45
 
46
- const sz = $derived(sizes[size]);
46
+ const sizing = $derived(sizes[size]);
47
47
  </script>
48
48
 
49
49
  <Checkbox.Root
@@ -62,18 +62,18 @@ as a check or a dash.
62
62
  <Checkbox.Control
63
63
  class={cn(
64
64
  'peer shrink-0 border border-border bg-sunken shadow-sm 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 data-[state=checked]:text-on-primary data-[state=indeterminate]:border-primary data-[state=indeterminate]:bg-primary data-[state=indeterminate]:text-on-primary',
65
- sz.control
65
+ sizing.control
66
66
  )}
67
67
  >
68
68
  <Checkbox.Indicator class="flex items-center justify-center text-current">
69
- <MingcuteCheckFill width={sz.icon} height={sz.icon} aria-hidden="true" />
69
+ <MingcuteCheckFill width={sizing.icon} height={sizing.icon} aria-hidden="true" />
70
70
  </Checkbox.Indicator>
71
71
  <Checkbox.Indicator indeterminate class="flex items-center justify-center text-current">
72
- <MingcuteSubtractFill width={sz.icon} height={sz.icon} aria-hidden="true" />
72
+ <MingcuteMinimizeFill width={sizing.icon} height={sizing.icon} aria-hidden="true" />
73
73
  </Checkbox.Indicator>
74
74
  </Checkbox.Control>
75
75
  {#if label || children}
76
- <Checkbox.Label class={cn('leading-none font-medium', sz.label)}>
76
+ <Checkbox.Label class={cn('leading-none font-medium', sizing.label)}>
77
77
  {#if children}
78
78
  {@render children()}
79
79
  {:else}
@@ -18,7 +18,7 @@ type $$ComponentProps = {
18
18
  };
19
19
  /**
20
20
  * A checkbox with its label (Ark Checkbox); `checked` binds true, false or indeterminate, drawn
21
- * as a check or a dash.
21
+ * as a check or a dash (a rounded bar as thick as the check).
22
22
  */
23
23
  declare const Checkbox: import("svelte").Component<$$ComponentProps, {}, "checked">;
24
24
  type Checkbox = ReturnType<typeof Checkbox>;
@@ -1,12 +1,13 @@
1
1
  <!--
2
2
  @component
3
- A ring that fills with progress, with an optional value in its centre and a label under it. It
3
+ A ring that fills with progress, with round ends, an optional value in its centre and a label under it. It
4
4
  is a `progressbar` named by `label`; `valueText`, the value formatted by the app (such as "72%"),
5
5
  is shown in the centre and announced instead of the raw number.
6
6
  -->
7
7
  <script lang="ts">
8
8
  import type { Snippet } from 'svelte';
9
9
  import { cn } from '../../utils.js';
10
+ import Ring from '../ring/Ring.svelte';
10
11
 
11
12
  let {
12
13
  class: className = '',
@@ -61,14 +62,7 @@ is shown in the centre and announced instead of the raw number.
61
62
  data-slot="circular-progress"
62
63
  {...rest}
63
64
  >
64
- <!-- A conic gradient drawn as a ring by a radial mask, which reads only the alpha of its colours. -->
65
- <div
66
- aria-hidden="true"
67
- class="absolute inset-0 rounded-full"
68
- style:background="conic-gradient(var(--primary) {progress}turn, var(--hover) 0)"
69
- style:mask="radial-gradient(farthest-side, transparent calc(100% - {strokeWidth}px - 0.5px),
70
- currentColor calc(100% - {strokeWidth}px))"
71
- ></div>
65
+ <Ring turn={progress} thickness={strokeWidth} />
72
66
  <div class="absolute inset-0 flex items-center justify-center" aria-hidden="true">
73
67
  {#if children}
74
68
  {@render children()}
@@ -22,7 +22,7 @@ type $$ComponentProps = {
22
22
  [key: string]: unknown;
23
23
  };
24
24
  /**
25
- * A ring that fills with progress, with an optional value in its centre and a label under it. It
25
+ * A ring that fills with progress, with round ends, an optional value in its centre and a label under it. It
26
26
  * is a `progressbar` named by `label`; `valueText`, the value formatted by the app (such as "72%"),
27
27
  * is shown in the centre and announced instead of the raw number.
28
28
  */
@@ -1,13 +1,14 @@
1
1
  <!--
2
2
  @component
3
3
  A circular control that picks an angle, from 0 to 359, along a ring that fills clockwise from the
4
- top up to its thumb (Ark AngleSlider), with the value written in its centre as `valueText` formats
4
+ top, with a round start, up to its thumb (Ark AngleSlider), with the value written in its centre as `valueText` formats
5
5
  it. `label` is its accessible name and `valueText` its spoken value; the arrow keys move it by
6
6
  `step`.
7
7
  -->
8
8
  <script lang="ts">
9
9
  import { AngleSlider } from '@ark-ui/svelte';
10
10
  import { cn } from '../../utils.js';
11
+ import Ring from '../ring/Ring.svelte';
11
12
 
12
13
  let {
13
14
  class: className = '',
@@ -68,22 +69,15 @@ it. `label` is its accessible name and `valueText` its spoken value; the arrow k
68
69
  >
69
70
  <AngleSlider.Label class="sr-only">{label}</AngleSlider.Label>
70
71
  <AngleSlider.Context>
71
- {#snippet render(ctx)}
72
- {@const api = ctx()}
72
+ {#snippet render(context)}
73
+ {@const api = context()}
73
74
  {@const turn = api.value / 360}
74
75
  {@const text = valueText(api.value)}
75
76
  <AngleSlider.Control
76
77
  class="group/circular-slider-control absolute inset-0"
77
78
  data-slot="circular-slider-control"
78
79
  >
79
- <!-- A conic gradient drawn as a ring by a radial mask, which reads only the alpha of its colours. -->
80
- <div
81
- aria-hidden="true"
82
- class="pointer-events-none absolute inset-0 rounded-full"
83
- style:background="conic-gradient(var(--primary) {turn}turn, var(--hover) 0)"
84
- style:mask="radial-gradient(farthest-side, transparent calc(100% - {thickness}px - 0.5px),
85
- currentColor calc(100% - {thickness}px))"
86
- ></div>
80
+ <Ring {turn} {thickness} />
87
81
 
88
82
  <!-- Zag announces a maximum of 360, but clamps the value to 359. -->
89
83
  <AngleSlider.Thumb
@@ -27,7 +27,7 @@ type $$ComponentProps = {
27
27
  };
28
28
  /**
29
29
  * A circular control that picks an angle, from 0 to 359, along a ring that fills clockwise from the
30
- * top up to its thumb (Ark AngleSlider), with the value written in its centre as `valueText` formats
30
+ * top, with a round start, up to its thumb (Ark AngleSlider), with the value written in its centre as `valueText` formats
31
31
  * it. `label` is its accessible name and `valueText` its spoken value; the arrow keys move it by
32
32
  * `step`.
33
33
  */