@human-kit/ui 1.0.0-beta.6 → 1.0.0-beta.8

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 (223) hide show
  1. package/dist/FOCUS_STATE_CONTRACT.md +15 -4
  2. package/dist/FOCUS_STATE_REVIEW_TEMPLATE.md +8 -8
  3. package/dist/autocomplete/item/autocomplete-item.svelte +10 -0
  4. package/dist/avatar/README.md +52 -0
  5. package/dist/avatar/count/avatar-count.svelte +56 -0
  6. package/dist/avatar/count/avatar-count.svelte.d.ts +4 -0
  7. package/dist/avatar/fallback/avatar-fallback.svelte +67 -0
  8. package/dist/avatar/fallback/avatar-fallback.svelte.d.ts +4 -0
  9. package/dist/avatar/group/avatar-group.svelte +65 -0
  10. package/dist/avatar/group/avatar-group.svelte.d.ts +4 -0
  11. package/dist/avatar/group/context.d.ts +15 -0
  12. package/dist/avatar/group/context.js +15 -0
  13. package/dist/avatar/image/avatar-image.svelte +104 -0
  14. package/dist/avatar/image/avatar-image.svelte.d.ts +4 -0
  15. package/dist/avatar/index.d.ts +22 -0
  16. package/dist/avatar/index.js +10 -0
  17. package/dist/avatar/index.parts.d.ts +5 -0
  18. package/dist/avatar/index.parts.js +5 -0
  19. package/dist/avatar/root/avatar-root.svelte +79 -0
  20. package/dist/avatar/root/avatar-root.svelte.d.ts +4 -0
  21. package/dist/avatar/root/context.d.ts +14 -0
  22. package/dist/avatar/root/context.js +15 -0
  23. package/dist/avatar/types.d.ts +84 -0
  24. package/dist/avatar/types.js +1 -0
  25. package/dist/breadcrumbs/README.md +65 -0
  26. package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte +62 -0
  27. package/dist/breadcrumbs/ellipsis/breadcrumbs-ellipsis.svelte.d.ts +4 -0
  28. package/dist/breadcrumbs/index.d.ts +23 -0
  29. package/dist/breadcrumbs/index.js +10 -0
  30. package/dist/breadcrumbs/index.parts.d.ts +6 -0
  31. package/dist/breadcrumbs/index.parts.js +6 -0
  32. package/dist/breadcrumbs/item/breadcrumbs-item.svelte +42 -0
  33. package/dist/breadcrumbs/item/breadcrumbs-item.svelte.d.ts +4 -0
  34. package/dist/breadcrumbs/link/breadcrumbs-link.svelte +47 -0
  35. package/dist/breadcrumbs/link/breadcrumbs-link.svelte.d.ts +4 -0
  36. package/dist/breadcrumbs/list/breadcrumbs-list.svelte +31 -0
  37. package/dist/breadcrumbs/list/breadcrumbs-list.svelte.d.ts +4 -0
  38. package/dist/breadcrumbs/root/breadcrumbs-root.svelte +112 -0
  39. package/dist/breadcrumbs/root/breadcrumbs-root.svelte.d.ts +4 -0
  40. package/dist/breadcrumbs/root/context.d.ts +19 -0
  41. package/dist/breadcrumbs/root/context.js +15 -0
  42. package/dist/breadcrumbs/separator/breadcrumbs-separator.svelte +35 -0
  43. package/dist/breadcrumbs/separator/breadcrumbs-separator.svelte.d.ts +4 -0
  44. package/dist/breadcrumbs/types.d.ts +80 -0
  45. package/dist/breadcrumbs/types.js +1 -0
  46. package/dist/button/root/button-root.svelte +9 -0
  47. package/dist/calendar/body-cell/calendar-body-cell.svelte +7 -0
  48. package/dist/checkbox/indicator/checkbox-indicator.svelte +1 -0
  49. package/dist/checkbox/indicator/checkbox-indicator.svelte.d.ts +1 -0
  50. package/dist/checkbox/root/checkbox-root.svelte +106 -30
  51. package/dist/checkbox/root/checkbox-root.svelte.d.ts +5 -0
  52. package/dist/checkbox-group/README.md +95 -0
  53. package/dist/checkbox-group/index.d.ts +15 -0
  54. package/dist/checkbox-group/index.js +6 -0
  55. package/dist/checkbox-group/index.parts.d.ts +4 -0
  56. package/dist/checkbox-group/index.parts.js +7 -0
  57. package/dist/checkbox-group/label/checkbox-group-label.svelte +36 -0
  58. package/dist/checkbox-group/label/checkbox-group-label.svelte.d.ts +4 -0
  59. package/dist/checkbox-group/root/checkbox-group-root.svelte +118 -0
  60. package/dist/checkbox-group/root/checkbox-group-root.svelte.d.ts +4 -0
  61. package/dist/checkbox-group/root/context.svelte.d.ts +52 -0
  62. package/dist/checkbox-group/root/context.svelte.js +251 -0
  63. package/dist/checkbox-group/types.d.ts +57 -0
  64. package/dist/checkbox-group/types.js +1 -0
  65. package/dist/combobox/popover/combobox-popover.svelte +4 -56
  66. package/dist/dialog/root/dialog-root.svelte +15 -2
  67. package/dist/drawer/root/drawer-root.svelte +15 -2
  68. package/dist/index.d.ts +18 -0
  69. package/dist/index.js +17 -0
  70. package/dist/internal/localized-strings.d.ts +48 -0
  71. package/dist/internal/localized-strings.js +48 -0
  72. package/dist/internal/number-precision.d.ts +9 -0
  73. package/dist/internal/number-precision.js +27 -0
  74. package/dist/menu/root/focus-state.d.ts +2 -2
  75. package/dist/menu/root/focus-state.js +8 -32
  76. package/dist/menu/root/menu-state.svelte.js +5 -1
  77. package/dist/numberfield/root/number-utils.js +1 -20
  78. package/dist/popover/root/focus-state.d.ts +2 -2
  79. package/dist/popover/root/focus-state.js +7 -34
  80. package/dist/primitives/contain-wheel.d.ts +9 -0
  81. package/dist/primitives/contain-wheel.js +41 -0
  82. package/dist/primitives/floating.d.ts +6 -0
  83. package/dist/primitives/floating.js +26 -5
  84. package/dist/primitives/focus-visible.svelte.d.ts +14 -0
  85. package/dist/primitives/focus-visible.svelte.js +19 -0
  86. package/dist/primitives/index.d.ts +1 -0
  87. package/dist/primitives/index.js +1 -0
  88. package/dist/primitives/input-modality.d.ts +7 -0
  89. package/dist/primitives/input-modality.js +32 -5
  90. package/dist/primitives/keyboard-navigation.d.ts +6 -0
  91. package/dist/primitives/keyboard-navigation.js +2 -1
  92. package/dist/primitives/trigger-focus-state.d.ts +29 -0
  93. package/dist/primitives/trigger-focus-state.js +57 -0
  94. package/dist/progress/README.md +54 -0
  95. package/dist/progress/index.d.ts +21 -0
  96. package/dist/progress/index.js +9 -0
  97. package/dist/progress/index.parts.d.ts +5 -0
  98. package/dist/progress/index.parts.js +5 -0
  99. package/dist/progress/indicator/progress-indicator.svelte +37 -0
  100. package/dist/progress/indicator/progress-indicator.svelte.d.ts +4 -0
  101. package/dist/progress/label/progress-label.svelte +34 -0
  102. package/dist/progress/label/progress-label.svelte.d.ts +4 -0
  103. package/dist/progress/root/context.d.ts +26 -0
  104. package/dist/progress/root/context.js +15 -0
  105. package/dist/progress/root/progress-root.svelte +136 -0
  106. package/dist/progress/root/progress-root.svelte.d.ts +4 -0
  107. package/dist/progress/root/progress-utils.d.ts +12 -0
  108. package/dist/progress/root/progress-utils.js +41 -0
  109. package/dist/progress/track/progress-track.svelte +27 -0
  110. package/dist/progress/track/progress-track.svelte.d.ts +4 -0
  111. package/dist/progress/types.d.ts +81 -0
  112. package/dist/progress/types.js +1 -0
  113. package/dist/progress/value/progress-value.svelte +36 -0
  114. package/dist/progress/value/progress-value.svelte.d.ts +4 -0
  115. package/dist/radio-group/README.md +103 -0
  116. package/dist/radio-group/index.d.ts +18 -0
  117. package/dist/radio-group/index.js +9 -0
  118. package/dist/radio-group/index.parts.d.ts +4 -0
  119. package/dist/radio-group/index.parts.js +4 -0
  120. package/dist/radio-group/indicator/radio-group-indicator.svelte +43 -0
  121. package/dist/radio-group/indicator/radio-group-indicator.svelte.d.ts +12 -0
  122. package/dist/radio-group/item/context.d.ts +18 -0
  123. package/dist/radio-group/item/context.js +15 -0
  124. package/dist/radio-group/item/radio-group-item.svelte +377 -0
  125. package/dist/radio-group/item/radio-group-item.svelte.d.ts +35 -0
  126. package/dist/radio-group/label/radio-group-label.svelte +37 -0
  127. package/dist/radio-group/label/radio-group-label.svelte.d.ts +4 -0
  128. package/dist/radio-group/root/context.svelte.d.ts +57 -0
  129. package/dist/radio-group/root/context.svelte.js +284 -0
  130. package/dist/radio-group/root/radio-group-root.svelte +193 -0
  131. package/dist/radio-group/root/radio-group-root.svelte.d.ts +4 -0
  132. package/dist/radio-group/types.d.ts +50 -0
  133. package/dist/radio-group/types.js +1 -0
  134. package/dist/select/README.md +129 -0
  135. package/dist/select/index.d.ts +30 -0
  136. package/dist/select/index.js +16 -0
  137. package/dist/select/index.parts.d.ts +8 -0
  138. package/dist/select/index.parts.js +9 -0
  139. package/dist/select/item/select-item.svelte +68 -0
  140. package/dist/select/item/select-item.svelte.d.ts +10 -0
  141. package/dist/select/item-indicator/select-item-indicator.svelte +55 -0
  142. package/dist/select/item-indicator/select-item-indicator.svelte.d.ts +4 -0
  143. package/dist/select/label/select-label.svelte +46 -0
  144. package/dist/select/label/select-label.svelte.d.ts +4 -0
  145. package/dist/select/list/select-list.svelte +241 -0
  146. package/dist/select/list/select-list.svelte.d.ts +62 -0
  147. package/dist/select/popover/select-popover.svelte +80 -0
  148. package/dist/select/popover/select-popover.svelte.d.ts +9 -0
  149. package/dist/select/root/context.d.ts +106 -0
  150. package/dist/select/root/context.js +22 -0
  151. package/dist/select/root/select-root.svelte +544 -0
  152. package/dist/select/root/select-root.svelte.d.ts +25 -0
  153. package/dist/select/trigger/select-trigger.svelte +192 -0
  154. package/dist/select/trigger/select-trigger.svelte.d.ts +4 -0
  155. package/dist/select/types.d.ts +133 -0
  156. package/dist/select/types.js +1 -0
  157. package/dist/select/value/select-value.svelte +61 -0
  158. package/dist/select/value/select-value.svelte.d.ts +4 -0
  159. package/dist/separator/README.md +35 -0
  160. package/dist/separator/index.d.ts +7 -0
  161. package/dist/separator/index.js +3 -0
  162. package/dist/separator/separator.svelte +254 -0
  163. package/dist/separator/separator.svelte.d.ts +45 -0
  164. package/dist/separator/types.d.ts +1 -0
  165. package/dist/separator/types.js +1 -0
  166. package/dist/slider/README.md +61 -0
  167. package/dist/slider/fill/slider-fill.svelte +40 -0
  168. package/dist/slider/fill/slider-fill.svelte.d.ts +4 -0
  169. package/dist/slider/index.d.ts +9 -0
  170. package/dist/slider/index.js +8 -0
  171. package/dist/slider/index.parts.d.ts +6 -0
  172. package/dist/slider/index.parts.js +6 -0
  173. package/dist/slider/label/slider-label.svelte +44 -0
  174. package/dist/slider/label/slider-label.svelte.d.ts +4 -0
  175. package/dist/slider/output/slider-output.svelte +46 -0
  176. package/dist/slider/output/slider-output.svelte.d.ts +4 -0
  177. package/dist/slider/root/context.d.ts +106 -0
  178. package/dist/slider/root/context.js +15 -0
  179. package/dist/slider/root/slider-root.svelte +545 -0
  180. package/dist/slider/root/slider-root.svelte.d.ts +4 -0
  181. package/dist/slider/root/slider-utils.d.ts +57 -0
  182. package/dist/slider/root/slider-utils.js +88 -0
  183. package/dist/slider/thumb/slider-thumb.svelte +276 -0
  184. package/dist/slider/thumb/slider-thumb.svelte.d.ts +4 -0
  185. package/dist/slider/track/slider-track.svelte +60 -0
  186. package/dist/slider/track/slider-track.svelte.d.ts +4 -0
  187. package/dist/slider/types.d.ts +144 -0
  188. package/dist/slider/types.js +1 -0
  189. package/dist/switch/root/switch-root.svelte +9 -0
  190. package/dist/table/column-header-cell/table-column-header-cell.svelte +24 -0
  191. package/dist/table/root/table-root.svelte +29 -6
  192. package/dist/timepicker/input/time-picker-input.svelte +12 -4
  193. package/dist/timepicker/input/time-picker-input.svelte.d.ts +12 -4
  194. package/dist/toggle/root/toggle-root.svelte +28 -0
  195. package/dist/toggle/root/toggle-root.svelte.d.ts +19 -0
  196. package/dist/toggle-group/README.md +6 -4
  197. package/dist/toggle-group/index.d.ts +2 -0
  198. package/dist/toggle-group/index.parts.d.ts +1 -0
  199. package/dist/toggle-group/index.parts.js +4 -0
  200. package/dist/tooltip/README.md +53 -0
  201. package/dist/tooltip/arrow/tooltip-arrow.svelte +36 -0
  202. package/dist/tooltip/arrow/tooltip-arrow.svelte.d.ts +4 -0
  203. package/dist/tooltip/content/tooltip-content.svelte +148 -0
  204. package/dist/tooltip/content/tooltip-content.svelte.d.ts +4 -0
  205. package/dist/tooltip/index.d.ts +8 -0
  206. package/dist/tooltip/index.js +7 -0
  207. package/dist/tooltip/index.parts.d.ts +5 -0
  208. package/dist/tooltip/index.parts.js +5 -0
  209. package/dist/tooltip/provider/tooltip-provider.svelte +36 -0
  210. package/dist/tooltip/provider/tooltip-provider.svelte.d.ts +4 -0
  211. package/dist/tooltip/root/context.d.ts +46 -0
  212. package/dist/tooltip/root/context.js +22 -0
  213. package/dist/tooltip/root/safe-polygon.d.ts +26 -0
  214. package/dist/tooltip/root/safe-polygon.js +66 -0
  215. package/dist/tooltip/root/tooltip-group.d.ts +26 -0
  216. package/dist/tooltip/root/tooltip-group.js +41 -0
  217. package/dist/tooltip/root/tooltip-root.svelte +454 -0
  218. package/dist/tooltip/root/tooltip-root.svelte.d.ts +4 -0
  219. package/dist/tooltip/trigger/tooltip-trigger.svelte +52 -0
  220. package/dist/tooltip/trigger/tooltip-trigger.svelte.d.ts +4 -0
  221. package/dist/tooltip/types.d.ts +105 -0
  222. package/dist/tooltip/types.js +1 -0
  223. package/package.json +46 -1
@@ -0,0 +1,81 @@
1
+ import type { Snippet } from 'svelte';
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { ProgressContext, ProgressOrientation, ProgressStatus } from './root/context.js';
4
+ export type { ProgressContext, ProgressOrientation, ProgressStatus } from './root/context.js';
5
+ export type ProgressRootProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'id' | 'role' | 'aria-valuenow' | 'aria-valuemin' | 'aria-valuemax'> & {
6
+ /**
7
+ * The progress of the task, between `min` and `max`. `null` makes the progress indeterminate:
8
+ * the task runs, and its end is not known. A value out of the range is held at the near end.
9
+ */
10
+ value: number | null;
11
+ /** The value at the start of the task. */
12
+ min?: number;
13
+ /** The value at the end of the task. The progress is complete when the value reaches it. */
14
+ max?: number;
15
+ /**
16
+ * The format of the value as text. Without it, the text is the position in the range as a
17
+ * percentage. Give the options of `Intl.NumberFormat` to show the value itself, in a unit.
18
+ */
19
+ format?: Intl.NumberFormatOptions;
20
+ /**
21
+ * Makes the text a screen reader gets for the value. It gets the formatted text and the value.
22
+ * Without it, the screen reader gets the formatted text.
23
+ */
24
+ getValueText?: (formattedValue: string, value: number | null) => string;
25
+ /**
26
+ * The text a screen reader gets for the value. It wins over `getValueText`. It has no effect
27
+ * while the progress is indeterminate: without a number, a text for the number is nothing.
28
+ */
29
+ 'aria-valuetext'?: string;
30
+ /**
31
+ * The direction of the bar. It sets `data-orientation` for your styles, and it tells the
32
+ * indicator which side to fill from.
33
+ */
34
+ orientation?: ProgressOrientation;
35
+ /** The parts of the progress bar. */
36
+ children?: Snippet;
37
+ /** The CSS class names of the element. */
38
+ class?: string;
39
+ /** The id of the root element. The component makes one when you give none. */
40
+ id?: string;
41
+ /** The root element. Use `bind:element` to read it. */
42
+ element?: HTMLDivElement | null;
43
+ /**
44
+ * The state of the progress. Use `bind:context` to read `percent`, `status` and
45
+ * `formattedValue` for a shape of your own, such as a ring.
46
+ */
47
+ context?: ProgressContext;
48
+ };
49
+ export type ProgressLabelProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class' | 'id'> & {
50
+ /** The name of the task. */
51
+ children?: Snippet;
52
+ /** The CSS class names of the element. */
53
+ class?: string;
54
+ /** The id of the label element. The component makes one when you give none. */
55
+ id?: string;
56
+ };
57
+ export type ProgressTrackProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
58
+ /** The indicator. */
59
+ children?: Snippet;
60
+ /** The CSS class names of the element. */
61
+ class?: string;
62
+ };
63
+ export type ProgressIndicatorProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class'> & {
64
+ /** Content inside the indicator, such as a stripe. */
65
+ children?: Snippet;
66
+ /** The CSS class names of the element. */
67
+ class?: string;
68
+ };
69
+ export type ProgressValueState = {
70
+ /** The value as text. Empty while the progress is indeterminate. */
71
+ formattedValue: string;
72
+ /** The value, held in the range. `null` while the progress is indeterminate. */
73
+ value: number | null;
74
+ status: ProgressStatus;
75
+ };
76
+ export type ProgressValueProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
77
+ /** The content in place of the formatted text. It gets the text, the value and the status. */
78
+ children?: Snippet<[ProgressValueState]>;
79
+ /** The CSS class names of the element. */
80
+ class?: string;
81
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ <script lang="ts">
2
+ import type { ProgressValueProps } from '../types.js';
3
+ import { useProgressContext } from '../root/context';
4
+
5
+ /**
6
+ * Progress.Value — the value as text, for the user.
7
+ *
8
+ * It is `aria-hidden`: the screen reader already gets the value from the progress bar, thus a
9
+ * second copy would read twice. Give it children to shape the text; without them, it shows
10
+ * the formatted value, and nothing while the progress is indeterminate.
11
+ */
12
+ let { children, class: className = '', ...restProps }: ProgressValueProps = $props();
13
+
14
+ const progress = useProgressContext('Progress.Value');
15
+ </script>
16
+
17
+ <span
18
+ {...restProps}
19
+ class={className}
20
+ aria-hidden="true"
21
+ data-progress-value="true"
22
+ data-orientation={progress.orientation}
23
+ data-progressing={progress.status === 'progressing' || undefined}
24
+ data-complete={progress.status === 'complete' || undefined}
25
+ data-indeterminate={progress.status === 'indeterminate' || undefined}
26
+ >
27
+ {#if children}
28
+ {@render children({
29
+ formattedValue: progress.formattedValue,
30
+ value: progress.value,
31
+ status: progress.status
32
+ })}
33
+ {:else}
34
+ {progress.formattedValue}
35
+ {/if}
36
+ </span>
@@ -0,0 +1,4 @@
1
+ import type { ProgressValueProps } from '../types.js';
2
+ declare const ProgressValue: import("svelte").Component<ProgressValueProps, {}, "">;
3
+ type ProgressValue = ReturnType<typeof ProgressValue>;
4
+ export default ProgressValue;
@@ -0,0 +1,103 @@
1
+ # RadioGroup
2
+
3
+ ## Description
4
+
5
+ `RadioGroup` coordinates a set of `RadioGroup.Item` buttons as one field. It holds a single value, and
6
+ it shares a `name` for form submission. It also spreads group-wide disabled, read-only and required
7
+ state, and it controls the roving focus the pattern asks for.
8
+
9
+ ## Anatomy
10
+
11
+ - `RadioGroup.Root`
12
+ - `RadioGroup.Label`
13
+ - `RadioGroup.Item`
14
+ - `RadioGroup.Indicator`
15
+
16
+ ```svelte
17
+ <RadioGroup.Root name="size" defaultValue="medium">
18
+ <RadioGroup.Label>Size</RadioGroup.Label>
19
+ <RadioGroup.Item value="small">
20
+ <RadioGroup.Indicator>x</RadioGroup.Indicator>
21
+ Small
22
+ </RadioGroup.Item>
23
+ <RadioGroup.Item value="medium">
24
+ <RadioGroup.Indicator>x</RadioGroup.Indicator>
25
+ Medium
26
+ </RadioGroup.Item>
27
+ </RadioGroup.Root>
28
+ ```
29
+
30
+ ## Usage guidelines
31
+
32
+ - Use `bind:value` to hand the group your state, or plain `value` + `onChange` to own it yourself.
33
+ There is no flag to declare which: supplying `value` makes it the source of truth either way, and
34
+ `onChange` always reports.
35
+ - A parent that holds `value` and refuses a change — it sends no new value down — still sees the
36
+ group move. The group then goes back to the value of the parent at the next render.
37
+ - Give the group a `name` to submit the answer as one field.
38
+ - Every `RadioGroup.Item` must provide a unique `value`, and it must sit inside a `RadioGroup.Root`. A
39
+ radio on its own has nothing to answer, and the component reports that rather than guessing.
40
+
41
+ ## API reference
42
+
43
+ `RadioGroup.Root` supports:
44
+
45
+ - `value?: string | null`
46
+ - `defaultValue?: string | null`
47
+ - `onChange?: (value: string) => void`
48
+ - `name?: string`
49
+ - `form?: string`
50
+ - `disabled?: boolean`
51
+ - `readonly?: boolean`
52
+ - `required?: boolean`
53
+ - `orientation?: 'horizontal' | 'vertical'`
54
+ - `context?: RadioGroupContext`
55
+ - `children?: Snippet`
56
+ - `...restProps: HTMLAttributes<HTMLDivElement>`
57
+
58
+ `RadioGroup.Item` supports `value` (required), `disabled`, `children`, `class`, `element` and the
59
+ usual `HTMLAttributes<HTMLSpanElement>`. It makes a span with `role="radio"` and a hidden radio
60
+ input for the form.
61
+
62
+ `RadioGroup.Indicator` supports `forceMount`. It is in the DOM only while its radio is checked.
63
+
64
+ `RadioGroup.Label` supports `children`, `class`, `id` and the usual `HTMLAttributes<HTMLSpanElement>`.
65
+ It renders a span, and it registers its id with the group as `aria-labelledby`.
66
+
67
+ ## Accessibility
68
+
69
+ - `RadioGroup.Root` renders `role="radiogroup"`, with `aria-orientation`, `aria-required`,
70
+ `aria-disabled` and `aria-readonly`. That role supports all four, which the plain `group` role of
71
+ a checkbox group does not.
72
+ - Give the group an accessible name with `RadioGroup.Label`, or with `aria-label` on the root for a
73
+ name the user does not see. Two labels read as one name, in the order they appear. An
74
+ `aria-labelledby` that the caller gives stands, thus an element of your own wins.
75
+ - `RadioGroup.Label` renders a span, and not a `<label>`: a `<label>` names one control, thus it
76
+ cannot name a set.
77
+ - The id reaches the group through the context. The server cannot do that: the group tag is
78
+ already written when the label registers. Thus `aria-labelledby` appears at hydration. Give
79
+ `aria-label` as well when the name must be there on the first paint.
80
+ - The group holds **one** tab stop, on the checked radio, and on the first enabled radio while
81
+ nothing is checked. Thus Tab enters the group where the user left it, and Tab leaves the group
82
+ rather than walking through it.
83
+ - The arrow keys move the focus **and** the selection, and they wrap at both ends. `Home` and `End`
84
+ jump to the bounds. Both axes work in either orientation, the way a native radio group does.
85
+ - `Space` selects the focused radio. `Enter` does not: it submits the form of a native radio.
86
+ - `aria-readonly` and `aria-required` are on the group, and never on an item: the `radio` role
87
+ does not support them.
88
+ - Give each radio an accessible name with its content, `aria-label` or `aria-labelledby`.
89
+
90
+ ## Notes
91
+
92
+ - There is no unselecting. The platform gives the user no way to take a radio answer back, so a
93
+ second press on the selected radio reports nothing.
94
+ - A radio that leaves a mounted group keeps its value in the group. Its hidden input goes with it,
95
+ so the form stops submitting that answer, which is what a native radio group does. A parent
96
+ that holds the value keeps it. The group gives the tab stop to the first enabled radio.
97
+ - Values are strings only. A radio carries its value on a native `<input>`, which stores it as a
98
+ string. A number would thus let `value={1}` miss a radio declared as `value="1"`.
99
+ - Both parts show each visual state in `data-*` attributes: `data-checked`, `data-unchecked`,
100
+ `data-pressed`, `data-disabled`, `data-readonly`, `data-required`, `data-focused` and
101
+ `data-focus-visible`.
102
+ - The selection follows the focus. This is the rule that parts a radio group from every other group
103
+ in this library. In a `ToggleGroup` or a `CheckboxGroup` the arrows only move.
@@ -0,0 +1,18 @@
1
+ import type { ComponentProps } from 'svelte';
2
+ import type RadioGroupIndicatorComponent from './indicator/radio-group-indicator.svelte';
3
+ import type RadioGroupLabelComponent from './label/radio-group-label.svelte';
4
+ import type RadioGroupItemComponent from './item/radio-group-item.svelte';
5
+ import type RadioGroupRootComponent from './root/radio-group-root.svelte';
6
+ export * as RadioGroup from './index.parts.js';
7
+ export { default as RadioGroupRoot } from './root/radio-group-root.svelte';
8
+ export { default as RadioGroupLabel } from './label/radio-group-label.svelte';
9
+ export { default as RadioGroupItem } from './item/radio-group-item.svelte';
10
+ export { default as RadioGroupIndicator } from './indicator/radio-group-indicator.svelte';
11
+ export type RadioGroupRootProps = ComponentProps<typeof RadioGroupRootComponent>;
12
+ export type RadioGroupLabelProps = ComponentProps<typeof RadioGroupLabelComponent>;
13
+ export type RadioGroupItemProps = ComponentProps<typeof RadioGroupItemComponent>;
14
+ export type RadioGroupIndicatorProps = ComponentProps<typeof RadioGroupIndicatorComponent>;
15
+ export { createRadioGroupContext, getRadioGroupContext, setRadioGroupContext, useRadioGroupContext, type CreateRadioGroupContextOptions, type RadioGroupContext, type RadioGroupOrientation, type RadioGroupValue } from './root/context.svelte';
16
+ export { getRadioGroupItemContext, setRadioGroupItemContext, useRadioGroupItemContext, type RadioGroupItemContext, type RadioGroupItemState } from './item/context.js';
17
+ import * as RadioGroupParts from './index.parts.js';
18
+ export default RadioGroupParts;
@@ -0,0 +1,9 @@
1
+ export * as RadioGroup from './index.parts.js';
2
+ export { default as RadioGroupRoot } from './root/radio-group-root.svelte';
3
+ export { default as RadioGroupLabel } from './label/radio-group-label.svelte';
4
+ export { default as RadioGroupItem } from './item/radio-group-item.svelte';
5
+ export { default as RadioGroupIndicator } from './indicator/radio-group-indicator.svelte';
6
+ export { createRadioGroupContext, getRadioGroupContext, setRadioGroupContext, useRadioGroupContext } from './root/context.svelte';
7
+ export { getRadioGroupItemContext, setRadioGroupItemContext, useRadioGroupItemContext } from './item/context.js';
8
+ import * as RadioGroupParts from './index.parts.js';
9
+ export default RadioGroupParts;
@@ -0,0 +1,4 @@
1
+ export { default as Root } from './root/radio-group-root.svelte';
2
+ export { default as Label } from './label/radio-group-label.svelte';
3
+ export { default as Item } from './item/radio-group-item.svelte';
4
+ export { default as Indicator } from './indicator/radio-group-indicator.svelte';
@@ -0,0 +1,4 @@
1
+ export { default as Root } from './root/radio-group-root.svelte';
2
+ export { default as Label } from './label/radio-group-label.svelte';
3
+ export { default as Item } from './item/radio-group-item.svelte';
4
+ export { default as Indicator } from './indicator/radio-group-indicator.svelte';
@@ -0,0 +1,43 @@
1
+ <script lang="ts">
2
+ import type { HTMLAttributes } from 'svelte/elements';
3
+ import type { Snippet } from 'svelte';
4
+ import { useRadioGroupItemContext } from '../item/context';
5
+
6
+ type RadioGroupIndicatorProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
7
+ /** Keeps the indicator in the DOM while the radio is not checked, for exit animations. */
8
+ forceMount?: boolean;
9
+ /** The mark itself. */
10
+ children?: Snippet;
11
+ class?: string;
12
+ };
13
+
14
+ let {
15
+ forceMount = false,
16
+ children,
17
+ class: className = '',
18
+ ...restProps
19
+ }: RadioGroupIndicatorProps = $props();
20
+
21
+ const radio = useRadioGroupItemContext();
22
+ const visible = $derived(radio.isChecked);
23
+ </script>
24
+
25
+ {#if forceMount || visible}
26
+ <span
27
+ {...restProps}
28
+ data-radio-group-indicator="true"
29
+ data-checked={radio.isChecked || undefined}
30
+ data-unchecked={!radio.isChecked || undefined}
31
+ data-pressed={radio.pressed || undefined}
32
+ data-disabled={radio.isDisabled || undefined}
33
+ data-readonly={radio.isReadOnly || undefined}
34
+ data-required={radio.required || undefined}
35
+ data-focused={radio.focused || undefined}
36
+ data-focus-visible={radio.focusVisible || undefined}
37
+ hidden={forceMount && !visible}
38
+ aria-hidden={forceMount && !visible ? 'true' : undefined}
39
+ class={className}
40
+ >
41
+ {@render children?.()}
42
+ </span>
43
+ {/if}
@@ -0,0 +1,12 @@
1
+ import type { HTMLAttributes } from 'svelte/elements';
2
+ import type { Snippet } from 'svelte';
3
+ type RadioGroupIndicatorProps = Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'class'> & {
4
+ /** Keeps the indicator in the DOM while the radio is not checked, for exit animations. */
5
+ forceMount?: boolean;
6
+ /** The mark itself. */
7
+ children?: Snippet;
8
+ class?: string;
9
+ };
10
+ declare const RadioGroupIndicator: import("svelte").Component<RadioGroupIndicatorProps, {}, "">;
11
+ type RadioGroupIndicator = ReturnType<typeof RadioGroupIndicator>;
12
+ export default RadioGroupIndicator;
@@ -0,0 +1,18 @@
1
+ export type RadioGroupItemState = 'checked' | 'unchecked';
2
+ export type RadioGroupItemContext = {
3
+ id: string;
4
+ inputId: string;
5
+ value: string;
6
+ state: RadioGroupItemState;
7
+ pressed: boolean;
8
+ isChecked: boolean;
9
+ isDisabled: boolean;
10
+ isReadOnly: boolean;
11
+ required: boolean;
12
+ focused: boolean;
13
+ focusVisible: boolean;
14
+ select: (event?: Event) => void;
15
+ };
16
+ export declare function setRadioGroupItemContext(context: RadioGroupItemContext): void;
17
+ export declare function getRadioGroupItemContext(): RadioGroupItemContext | undefined;
18
+ export declare function useRadioGroupItemContext(): RadioGroupItemContext;
@@ -0,0 +1,15 @@
1
+ import { getContext, setContext } from 'svelte';
2
+ const RADIO_GROUP_ITEM_CONTEXT_KEY = Symbol('radio-group-item');
3
+ export function setRadioGroupItemContext(context) {
4
+ setContext(RADIO_GROUP_ITEM_CONTEXT_KEY, context);
5
+ }
6
+ export function getRadioGroupItemContext() {
7
+ return getContext(RADIO_GROUP_ITEM_CONTEXT_KEY);
8
+ }
9
+ export function useRadioGroupItemContext() {
10
+ const context = getRadioGroupItemContext();
11
+ if (!context) {
12
+ throw new Error('Radio components must be used within RadioGroup.Item.');
13
+ }
14
+ return context;
15
+ }