@hydrateless/svelte 0.8.0 → 0.9.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 (155) hide show
  1. package/README.md +173 -38
  2. package/dist/components/Accordion.svelte +28 -17
  3. package/dist/components/Accordion.svelte.d.ts +3 -0
  4. package/dist/components/AccordionItem.svelte +17 -11
  5. package/dist/components/AccordionItem.svelte.d.ts +5 -3
  6. package/dist/components/Alert.svelte +4 -0
  7. package/dist/components/Alert.svelte.d.ts +4 -0
  8. package/dist/components/Avatar.svelte +5 -0
  9. package/dist/components/Avatar.svelte.d.ts +5 -0
  10. package/dist/components/AvatarGroup.svelte +1 -0
  11. package/dist/components/AvatarGroup.svelte.d.ts +1 -0
  12. package/dist/components/Badge.svelte +4 -0
  13. package/dist/components/Badge.svelte.d.ts +4 -0
  14. package/dist/components/Breadcrumb.svelte +1 -0
  15. package/dist/components/Breadcrumb.svelte.d.ts +1 -0
  16. package/dist/components/BreadcrumbItem.svelte +3 -0
  17. package/dist/components/BreadcrumbItem.svelte.d.ts +3 -0
  18. package/dist/components/Button.svelte +7 -0
  19. package/dist/components/Button.svelte.d.ts +7 -0
  20. package/dist/components/Card.svelte +2 -0
  21. package/dist/components/Card.svelte.d.ts +2 -0
  22. package/dist/components/CardBody.svelte +1 -0
  23. package/dist/components/CardBody.svelte.d.ts +1 -0
  24. package/dist/components/CardDescription.svelte +1 -0
  25. package/dist/components/CardDescription.svelte.d.ts +1 -0
  26. package/dist/components/CardFooter.svelte +1 -0
  27. package/dist/components/CardFooter.svelte.d.ts +1 -0
  28. package/dist/components/CardHeader.svelte +1 -0
  29. package/dist/components/CardHeader.svelte.d.ts +1 -0
  30. package/dist/components/CardTitle.svelte +1 -0
  31. package/dist/components/CardTitle.svelte.d.ts +1 -0
  32. package/dist/components/Checkbox.svelte +24 -2
  33. package/dist/components/Checkbox.svelte.d.ts +2 -0
  34. package/dist/components/Combobox.svelte +37 -26
  35. package/dist/components/Combobox.svelte.d.ts +12 -3
  36. package/dist/components/ComboboxInput.svelte +21 -2
  37. package/dist/components/ComboboxInput.svelte.d.ts +1 -0
  38. package/dist/components/ComboboxList.svelte +4 -1
  39. package/dist/components/ComboboxList.svelte.d.ts +1 -0
  40. package/dist/components/ComboboxOption.svelte +6 -2
  41. package/dist/components/ComboboxOption.svelte.d.ts +4 -0
  42. package/dist/components/Command.svelte +36 -9
  43. package/dist/components/Command.svelte.d.ts +12 -5
  44. package/dist/components/CommandEmpty.svelte +1 -0
  45. package/dist/components/CommandEmpty.svelte.d.ts +1 -0
  46. package/dist/components/CommandGroup.svelte +1 -0
  47. package/dist/components/CommandGroup.svelte.d.ts +1 -0
  48. package/dist/components/CommandItem.svelte +2 -0
  49. package/dist/components/CommandItem.svelte.d.ts +2 -0
  50. package/dist/components/CommandList.svelte +1 -0
  51. package/dist/components/CommandList.svelte.d.ts +1 -0
  52. package/dist/components/Disclosure.svelte +29 -19
  53. package/dist/components/Disclosure.svelte.d.ts +6 -1
  54. package/dist/components/Drawer.svelte +26 -20
  55. package/dist/components/Drawer.svelte.d.ts +6 -1
  56. package/dist/components/DrawerBody.svelte +1 -0
  57. package/dist/components/DrawerBody.svelte.d.ts +1 -0
  58. package/dist/components/DrawerFooter.svelte +1 -0
  59. package/dist/components/DrawerFooter.svelte.d.ts +1 -0
  60. package/dist/components/DrawerHeader.svelte +1 -0
  61. package/dist/components/DrawerHeader.svelte.d.ts +1 -0
  62. package/dist/components/Dropdown.svelte +45 -24
  63. package/dist/components/Dropdown.svelte.d.ts +13 -2
  64. package/dist/components/DropdownGroup.svelte +19 -0
  65. package/dist/components/DropdownGroup.svelte.d.ts +11 -0
  66. package/dist/components/DropdownItem.svelte +28 -4
  67. package/dist/components/DropdownItem.svelte.d.ts +11 -2
  68. package/dist/components/DropdownMenu.svelte +14 -2
  69. package/dist/components/DropdownMenu.svelte.d.ts +1 -0
  70. package/dist/components/DropdownSeparator.svelte +3 -2
  71. package/dist/components/DropdownTrigger.svelte +14 -2
  72. package/dist/components/DropdownTrigger.svelte.d.ts +1 -0
  73. package/dist/components/Field.svelte +42 -3
  74. package/dist/components/Field.svelte.d.ts +16 -0
  75. package/dist/components/FieldError.svelte +4 -3
  76. package/dist/components/FieldError.svelte.d.ts +1 -0
  77. package/dist/components/FieldHelp.svelte +4 -3
  78. package/dist/components/FieldHelp.svelte.d.ts +1 -0
  79. package/dist/components/FieldLabel.svelte +4 -3
  80. package/dist/components/FieldLabel.svelte.d.ts +1 -0
  81. package/dist/components/Fieldset.svelte +2 -0
  82. package/dist/components/Fieldset.svelte.d.ts +2 -0
  83. package/dist/components/Input.svelte +22 -6
  84. package/dist/components/Input.svelte.d.ts +3 -0
  85. package/dist/components/Kbd.svelte +1 -0
  86. package/dist/components/Kbd.svelte.d.ts +1 -0
  87. package/dist/components/Menu.svelte +36 -23
  88. package/dist/components/Menu.svelte.d.ts +18 -5
  89. package/dist/components/MenuItem.svelte +46 -18
  90. package/dist/components/MenuItem.svelte.d.ts +10 -7
  91. package/dist/components/MenuSubmenu.svelte +30 -0
  92. package/dist/components/MenuSubmenu.svelte.d.ts +17 -0
  93. package/dist/components/Modal.svelte +17 -18
  94. package/dist/components/Modal.svelte.d.ts +4 -0
  95. package/dist/components/ModalBody.svelte +1 -0
  96. package/dist/components/ModalBody.svelte.d.ts +1 -0
  97. package/dist/components/ModalFooter.svelte +1 -0
  98. package/dist/components/ModalFooter.svelte.d.ts +1 -0
  99. package/dist/components/ModalHeader.svelte +1 -0
  100. package/dist/components/ModalHeader.svelte.d.ts +1 -0
  101. package/dist/components/Pagination.svelte +5 -0
  102. package/dist/components/Pagination.svelte.d.ts +5 -0
  103. package/dist/components/Popover.svelte +37 -20
  104. package/dist/components/Popover.svelte.d.ts +12 -2
  105. package/dist/components/Progress.svelte +4 -0
  106. package/dist/components/Progress.svelte.d.ts +4 -0
  107. package/dist/components/Radio.svelte +2 -0
  108. package/dist/components/Radio.svelte.d.ts +2 -0
  109. package/dist/components/RadioGroup.svelte +34 -4
  110. package/dist/components/RadioGroup.svelte.d.ts +10 -1
  111. package/dist/components/SegmentedControl.svelte +25 -10
  112. package/dist/components/SegmentedControl.svelte.d.ts +11 -3
  113. package/dist/components/Select.svelte +16 -5
  114. package/dist/components/Select.svelte.d.ts +4 -0
  115. package/dist/components/Separator.svelte +2 -0
  116. package/dist/components/Separator.svelte.d.ts +2 -0
  117. package/dist/components/Skeleton.svelte +6 -3
  118. package/dist/components/Skeleton.svelte.d.ts +4 -1
  119. package/dist/components/SkipLink.svelte +1 -0
  120. package/dist/components/SkipLink.svelte.d.ts +1 -0
  121. package/dist/components/Slider.svelte +23 -2
  122. package/dist/components/Slider.svelte.d.ts +1 -0
  123. package/dist/components/Spinner.svelte +2 -0
  124. package/dist/components/Spinner.svelte.d.ts +2 -0
  125. package/dist/components/Switch.svelte +25 -2
  126. package/dist/components/Switch.svelte.d.ts +2 -0
  127. package/dist/components/Tab.svelte +16 -2
  128. package/dist/components/Tab.svelte.d.ts +1 -0
  129. package/dist/components/TabList.svelte +1 -0
  130. package/dist/components/TabList.svelte.d.ts +1 -0
  131. package/dist/components/TabPanel.svelte +8 -1
  132. package/dist/components/TabPanel.svelte.d.ts +1 -0
  133. package/dist/components/Table.svelte +30 -0
  134. package/dist/components/Table.svelte.d.ts +17 -0
  135. package/dist/components/Tabs.svelte +41 -19
  136. package/dist/components/Tabs.svelte.d.ts +6 -1
  137. package/dist/components/Textarea.svelte +26 -6
  138. package/dist/components/Textarea.svelte.d.ts +5 -0
  139. package/dist/components/ToastRegion.svelte +18 -2
  140. package/dist/components/ToastRegion.svelte.d.ts +8 -1
  141. package/dist/components/Toc.svelte +19 -8
  142. package/dist/components/Toc.svelte.d.ts +6 -0
  143. package/dist/components/Tooltip.svelte +57 -19
  144. package/dist/components/Tooltip.svelte.d.ts +16 -7
  145. package/dist/context.d.ts +84 -8
  146. package/dist/context.js +60 -11
  147. package/dist/index.d.ts +8 -4
  148. package/dist/index.js +6 -4
  149. package/dist/toast.d.ts +12 -7
  150. package/dist/toast.js +20 -11
  151. package/dist/useEnhancer.svelte.d.ts +40 -0
  152. package/dist/useEnhancer.svelte.js +58 -0
  153. package/package.json +4 -4
  154. package/dist/actions.d.ts +0 -25
  155. package/dist/actions.js +0 -31
@@ -1,11 +1,21 @@
1
+ import { type EnhancePopoverOptions } from '@hydrateless/enhancers';
1
2
  import type { Snippet } from 'svelte';
2
3
  import type { HTMLAttributes } from 'svelte/elements';
3
4
  interface Props extends HTMLAttributes<HTMLDivElement> {
4
- /** Open state; two-way bindable (`bind:open`). The browser's light-dismiss
5
- * (Escape/outside click) closes it and updates the binding. */
5
+ /**
6
+ * Open state; two-way bindable (`bind:open`). The browser's light-dismiss
7
+ * (Escape/outside click) closes it and updates the binding.
8
+ */
6
9
  open?: boolean;
7
10
  /** Show the popover initially for uncontrolled usage. */
8
11
  defaultOpen?: boolean;
12
+ /** Called after the popover shows or hides. */
13
+ onOpenChange?: (open: boolean) => void;
14
+ /** Preferred placement relative to the invoker. Defaults to `bottom`. */
15
+ placement?: EnhancePopoverOptions['placement'];
16
+ /** Open on hover/focus of the invoker instead of on click. */
17
+ hover?: boolean;
18
+ /** Popover content. Point a `<button popovertarget={id}>` at this element's `id`. */
9
19
  children?: Snippet;
10
20
  }
11
21
  declare const Popover: import("svelte").Component<Props, {}, "open">;
@@ -2,9 +2,13 @@
2
2
  import type { HTMLProgressAttributes } from 'svelte/elements';
3
3
 
4
4
  interface Props extends HTMLProgressAttributes {
5
+ /** Current progress; omit for an indeterminate bar. */
5
6
  value?: number;
7
+ /** Value that represents completion. Defaults to `100`. */
6
8
  max?: number;
9
+ /** Semantic tone; sets `data-hl-intent`. */
7
10
  intent?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
11
+ /** Bar thickness. */
8
12
  size?: 'sm' | 'md' | 'lg';
9
13
  }
10
14
 
@@ -1,8 +1,12 @@
1
1
  import type { HTMLProgressAttributes } from 'svelte/elements';
2
2
  interface Props extends HTMLProgressAttributes {
3
+ /** Current progress; omit for an indeterminate bar. */
3
4
  value?: number;
5
+ /** Value that represents completion. Defaults to `100`. */
4
6
  max?: number;
7
+ /** Semantic tone; sets `data-hl-intent`. */
5
8
  intent?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
9
+ /** Bar thickness. */
6
10
  size?: 'sm' | 'md' | 'lg';
7
11
  }
8
12
  declare const Progress: import("svelte").Component<Props, {}, "">;
@@ -4,7 +4,9 @@
4
4
  import { getRadioGroupContext } from '../context.js';
5
5
 
6
6
  interface Props extends Omit<HTMLInputAttributes, 'type' | 'value'> {
7
+ /** Value reported to the enclosing `<RadioGroup>` when selected. */
7
8
  value: string;
9
+ /** Label text rendered next to the radio. */
8
10
  children?: Snippet;
9
11
  }
10
12
 
@@ -1,7 +1,9 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLInputAttributes } from 'svelte/elements';
3
3
  interface Props extends Omit<HTMLInputAttributes, 'type' | 'value'> {
4
+ /** Value reported to the enclosing `<RadioGroup>` when selected. */
4
5
  value: string;
6
+ /** Label text rendered next to the radio. */
5
7
  children?: Snippet;
6
8
  }
7
9
  declare const Radio: import("svelte").Component<Props, {}, "">;
@@ -3,27 +3,57 @@
3
3
  import type { HTMLAttributes } from 'svelte/elements';
4
4
  import { setRadioGroupContext } from '../context.js';
5
5
 
6
- interface Props extends HTMLAttributes<HTMLDivElement> {
6
+ interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'onchange'> {
7
+ /** Selected value; two-way bindable (`bind:value`). */
7
8
  value?: string;
9
+ /** Initially selected value for uncontrolled usage. */
10
+ defaultValue?: string;
11
+ /** Called with the new value after every selection change. */
12
+ onValueChange?: (value: string) => void;
13
+ /** Shared `name` of the radios; generated when omitted. */
8
14
  name?: string;
15
+ /** Layout direction. */
16
+ orientation?: 'horizontal' | 'vertical';
17
+ /** `<Radio>`s. */
9
18
  children?: Snippet;
10
19
  }
11
20
 
12
- let { value = $bindable(), name, class: klass, children, ...rest }: Props = $props();
21
+ let {
22
+ value = $bindable(),
23
+ defaultValue,
24
+ onValueChange,
25
+ name,
26
+ orientation,
27
+ class: klass,
28
+ children,
29
+ ...rest
30
+ }: Props = $props();
31
+ // svelte-ignore state_referenced_locally -- seeds the uncontrolled initial value once
32
+ if (value === undefined) value = defaultValue;
33
+ // SSR-safe: $props.id() is stable across server and client renders.
34
+ const generatedId = $props.id();
35
+ const groupName = `hl-radio-${generatedId}`;
13
36
 
14
37
  setRadioGroupContext({
15
38
  get name() {
16
- return name;
39
+ return name ?? groupName;
17
40
  },
18
41
  get value() {
19
42
  return value;
20
43
  },
21
44
  select: (next: string) => {
22
45
  value = next;
46
+ onValueChange?.(next);
23
47
  },
24
48
  });
25
49
  </script>
26
50
 
27
- <div {...rest} role="radiogroup" class={['hl-radio-group', klass]}>
51
+ <div
52
+ {...rest}
53
+ role="radiogroup"
54
+ class={['hl-radio-group', klass]}
55
+ data-hl-orientation={orientation}
56
+ aria-orientation={orientation}
57
+ >
28
58
  {@render children?.()}
29
59
  </div>
@@ -1,8 +1,17 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
- interface Props extends HTMLAttributes<HTMLDivElement> {
3
+ interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'onchange'> {
4
+ /** Selected value; two-way bindable (`bind:value`). */
4
5
  value?: string;
6
+ /** Initially selected value for uncontrolled usage. */
7
+ defaultValue?: string;
8
+ /** Called with the new value after every selection change. */
9
+ onValueChange?: (value: string) => void;
10
+ /** Shared `name` of the radios; generated when omitted. */
5
11
  name?: string;
12
+ /** Layout direction. */
13
+ orientation?: 'horizontal' | 'vertical';
14
+ /** `<Radio>`s. */
6
15
  children?: Snippet;
7
16
  }
8
17
  declare const RadioGroup: import("svelte").Component<Props, {}, "value">;
@@ -2,34 +2,49 @@
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
 
4
4
  interface SegmentedOption {
5
+ /** Visible label. */
5
6
  label: string;
7
+ /** Value reported when the segment is selected. */
6
8
  value: string;
9
+ /** Render the segment disabled. */
7
10
  disabled?: boolean;
8
11
  }
9
12
 
10
- interface Props extends HTMLAttributes<HTMLDivElement> {
13
+ interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'onchange'> {
14
+ /** Segments to render, in order. */
15
+ options?: SegmentedOption[];
11
16
  /** Selected value; two-way bindable (`bind:value`). */
12
17
  value?: string;
13
- /** Initially selected value for uncontrolled usage. */
18
+ /** Initially selected value for uncontrolled usage. Defaults to the first option. */
14
19
  defaultValue?: string;
15
- options?: SegmentedOption[];
20
+ /** Called with the new value after every selection change. */
21
+ onValueChange?: (value: string) => void;
22
+ /** Shared `name` of the underlying radios; generated when omitted. */
16
23
  name?: string;
24
+ /** Control size. */
17
25
  size?: 'sm' | 'md' | 'lg';
18
26
  }
19
27
 
20
28
  let {
29
+ options = [],
21
30
  value = $bindable(),
22
31
  defaultValue,
23
- options = [],
32
+ onValueChange,
24
33
  name,
25
34
  size,
26
35
  class: klass,
27
36
  ...rest
28
37
  }: Props = $props();
38
+ // svelte-ignore state_referenced_locally -- seeds the uncontrolled initial value once
39
+ if (value === undefined) value = defaultValue ?? options[0]?.value;
29
40
  // SSR-safe: $props.id() is stable across server and client renders.
30
- const generatedName = $props.id();
31
- const groupName = $derived(name ?? `hl-seg-${generatedName}`);
32
- const current = $derived(value ?? defaultValue);
41
+ const generatedId = $props.id();
42
+ const groupName = `hl-seg-${generatedId}`;
43
+
44
+ function select(next: string) {
45
+ value = next;
46
+ onValueChange?.(next);
47
+ }
33
48
  </script>
34
49
 
35
50
  <div {...rest} role="radiogroup" class={['hl-segmented', klass]} data-hl-size={size}>
@@ -37,11 +52,11 @@
37
52
  <label class="hl-segmented-item">
38
53
  <input
39
54
  type="radio"
40
- name={groupName}
55
+ name={name ?? groupName}
41
56
  value={option.value}
42
- checked={current === option.value}
57
+ checked={value === option.value}
43
58
  disabled={option.disabled}
44
- onchange={() => (value = option.value)}
59
+ onchange={() => select(option.value)}
45
60
  />
46
61
  <span>{option.label}</span>
47
62
  </label>
@@ -1,16 +1,24 @@
1
1
  import type { HTMLAttributes } from 'svelte/elements';
2
2
  interface SegmentedOption {
3
+ /** Visible label. */
3
4
  label: string;
5
+ /** Value reported when the segment is selected. */
4
6
  value: string;
7
+ /** Render the segment disabled. */
5
8
  disabled?: boolean;
6
9
  }
7
- interface Props extends HTMLAttributes<HTMLDivElement> {
10
+ interface Props extends Omit<HTMLAttributes<HTMLDivElement>, 'onchange'> {
11
+ /** Segments to render, in order. */
12
+ options?: SegmentedOption[];
8
13
  /** Selected value; two-way bindable (`bind:value`). */
9
14
  value?: string;
10
- /** Initially selected value for uncontrolled usage. */
15
+ /** Initially selected value for uncontrolled usage. Defaults to the first option. */
11
16
  defaultValue?: string;
12
- options?: SegmentedOption[];
17
+ /** Called with the new value after every selection change. */
18
+ onValueChange?: (value: string) => void;
19
+ /** Shared `name` of the underlying radios; generated when omitted. */
13
20
  name?: string;
21
+ /** Control size. */
14
22
  size?: 'sm' | 'md' | 'lg';
15
23
  }
16
24
  declare const SegmentedControl: import("svelte").Component<Props, {}, "value">;
@@ -1,12 +1,16 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
3
  import type { HTMLSelectAttributes } from 'svelte/elements';
4
- import { fieldBindings } from '../context.js';
4
+ import { useField } from '../context.js';
5
5
 
6
6
  interface Props extends Omit<HTMLSelectAttributes, 'size'> {
7
+ /** Selected value; two-way bindable (`bind:value`). */
7
8
  value?: string;
9
+ /** Control size. */
8
10
  size?: 'sm' | 'md' | 'lg';
11
+ /** Mark the control invalid; also inherited from an enclosing `<Field invalid>`. */
9
12
  invalid?: boolean;
13
+ /** `<option>`s. */
10
14
  children?: Snippet;
11
15
  }
12
16
 
@@ -14,22 +18,29 @@
14
18
  value = $bindable(),
15
19
  size,
16
20
  invalid = false,
21
+ id,
22
+ required,
23
+ 'aria-describedby': describedBy,
17
24
  class: klass,
18
25
  children,
19
26
  ...rest
20
27
  }: Props = $props();
21
- const field = fieldBindings();
28
+ // Optional: wires id/aria-describedby/aria-invalid/required when inside a <Field>.
29
+ const field = useField();
30
+ const isInvalid = $derived(invalid || Boolean(field?.invalid));
22
31
  </script>
23
32
 
24
33
  <span class="hl-select-wrapper">
25
34
  <select
26
- {...field}
27
35
  {...rest}
36
+ id={id ?? field?.id}
37
+ required={required ?? (field?.required || undefined)}
38
+ aria-describedby={describedBy ?? field?.describedBy}
28
39
  bind:value
29
40
  class={['hl-select', klass]}
30
41
  data-hl-size={size}
31
- data-hl-invalid={invalid || undefined}
32
- aria-invalid={invalid || undefined}
42
+ data-hl-invalid={isInvalid || undefined}
43
+ aria-invalid={isInvalid || undefined}
33
44
  >
34
45
  {@render children?.()}
35
46
  </select>
@@ -1,9 +1,13 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLSelectAttributes } from 'svelte/elements';
3
3
  interface Props extends Omit<HTMLSelectAttributes, 'size'> {
4
+ /** Selected value; two-way bindable (`bind:value`). */
4
5
  value?: string;
6
+ /** Control size. */
5
7
  size?: 'sm' | 'md' | 'lg';
8
+ /** Mark the control invalid; also inherited from an enclosing `<Field invalid>`. */
6
9
  invalid?: boolean;
10
+ /** `<option>`s. */
7
11
  children?: Snippet;
8
12
  }
9
13
  declare const Select: import("svelte").Component<Props, {}, "value">;
@@ -2,7 +2,9 @@
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
 
4
4
  interface Props extends HTMLAttributes<HTMLHRElement> {
5
+ /** Direction of the rule. Defaults to `horizontal`. */
5
6
  orientation?: 'horizontal' | 'vertical';
7
+ /** Purely visual: removes the separator from the accessibility tree. */
6
8
  decorative?: boolean;
7
9
  }
8
10
 
@@ -1,6 +1,8 @@
1
1
  import type { HTMLAttributes } from 'svelte/elements';
2
2
  interface Props extends HTMLAttributes<HTMLHRElement> {
3
+ /** Direction of the rule. Defaults to `horizontal`. */
3
4
  orientation?: 'horizontal' | 'vertical';
5
+ /** Purely visual: removes the separator from the accessibility tree. */
4
6
  decorative?: boolean;
5
7
  }
6
8
  declare const Separator: import("svelte").Component<Props, {}, "">;
@@ -2,12 +2,15 @@
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
 
4
4
  interface Props extends HTMLAttributes<HTMLSpanElement> {
5
- variant?: 'rect' | 'text' | 'circle';
5
+ /** Placeholder shape. */
6
+ shape?: 'text' | 'circle' | 'rect';
7
+ /** Inline size; numbers are pixels. */
6
8
  width?: string | number;
9
+ /** Block size; numbers are pixels. */
7
10
  height?: string | number;
8
11
  }
9
12
 
10
- let { variant, width, height, style, class: klass, ...rest }: Props = $props();
13
+ let { shape, width, height, style, class: klass, ...rest }: Props = $props();
11
14
 
12
15
  function dim(v: string | number): string {
13
16
  return typeof v === 'number' ? `${v}px` : v;
@@ -27,7 +30,7 @@
27
30
  <span
28
31
  {...rest}
29
32
  class={['hl-skeleton', klass]}
30
- data-hl-variant={variant}
33
+ data-hl-shape={shape}
31
34
  style={sizeStyle || undefined}
32
35
  aria-hidden="true"
33
36
  ></span>
@@ -1,7 +1,10 @@
1
1
  import type { HTMLAttributes } from 'svelte/elements';
2
2
  interface Props extends HTMLAttributes<HTMLSpanElement> {
3
- variant?: 'rect' | 'text' | 'circle';
3
+ /** Placeholder shape. */
4
+ shape?: 'text' | 'circle' | 'rect';
5
+ /** Inline size; numbers are pixels. */
4
6
  width?: string | number;
7
+ /** Block size; numbers are pixels. */
5
8
  height?: string | number;
6
9
  }
7
10
  declare const Skeleton: import("svelte").Component<Props, {}, "">;
@@ -3,6 +3,7 @@
3
3
  import type { HTMLAnchorAttributes } from 'svelte/elements';
4
4
 
5
5
  interface Props extends HTMLAnchorAttributes {
6
+ /** Link text. Defaults to "Skip to content". */
6
7
  children?: Snippet;
7
8
  }
8
9
 
@@ -1,6 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAnchorAttributes } from 'svelte/elements';
3
3
  interface Props extends HTMLAnchorAttributes {
4
+ /** Link text. Defaults to "Skip to content". */
4
5
  children?: Snippet;
5
6
  }
6
7
  declare const SkipLink: import("svelte").Component<Props, {}, "">;
@@ -1,11 +1,32 @@
1
1
  <script lang="ts">
2
2
  import type { HTMLInputAttributes } from 'svelte/elements';
3
+ import { useField } from '../context.js';
3
4
 
4
5
  interface Props extends Omit<HTMLInputAttributes, 'type'> {
6
+ /** Current value; two-way bindable (`bind:value`). */
5
7
  value?: string | number;
6
8
  }
7
9
 
8
- let { value = $bindable(), class: klass, ...rest }: Props = $props();
10
+ let {
11
+ value = $bindable(),
12
+ id,
13
+ required,
14
+ 'aria-describedby': describedBy,
15
+ 'aria-invalid': ariaInvalid,
16
+ class: klass,
17
+ ...rest
18
+ }: Props = $props();
19
+ // Optional: wires id/aria-describedby/aria-invalid/required when inside a <Field>.
20
+ const field = useField();
9
21
  </script>
10
22
 
11
- <input {...rest} type="range" class={['hl-slider', klass]} bind:value />
23
+ <input
24
+ {...rest}
25
+ id={id ?? field?.id}
26
+ required={required ?? (field?.required || undefined)}
27
+ aria-describedby={describedBy ?? field?.describedBy}
28
+ aria-invalid={ariaInvalid ?? (field?.invalid || undefined)}
29
+ type="range"
30
+ class={['hl-slider', klass]}
31
+ bind:value
32
+ />
@@ -1,5 +1,6 @@
1
1
  import type { HTMLInputAttributes } from 'svelte/elements';
2
2
  interface Props extends Omit<HTMLInputAttributes, 'type'> {
3
+ /** Current value; two-way bindable (`bind:value`). */
3
4
  value?: string | number;
4
5
  }
5
6
  declare const Slider: import("svelte").Component<Props, {}, "value">;
@@ -2,7 +2,9 @@
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
 
4
4
  interface Props extends HTMLAttributes<HTMLSpanElement> {
5
+ /** Spinner size. */
5
6
  size?: 'sm' | 'md' | 'lg' | 'xl';
7
+ /** Accessible name announced by screen readers. Defaults to "Loading". */
6
8
  label?: string;
7
9
  }
8
10
 
@@ -1,6 +1,8 @@
1
1
  import type { HTMLAttributes } from 'svelte/elements';
2
2
  interface Props extends HTMLAttributes<HTMLSpanElement> {
3
+ /** Spinner size. */
3
4
  size?: 'sm' | 'md' | 'lg' | 'xl';
5
+ /** Accessible name announced by screen readers. Defaults to "Loading". */
4
6
  label?: string;
5
7
  }
6
8
  declare const Spinner: import("svelte").Component<Props, {}, "">;
@@ -1,16 +1,39 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
3
  import type { HTMLInputAttributes } from 'svelte/elements';
4
+ import { useField } from '../context.js';
4
5
 
5
6
  interface Props extends Omit<HTMLInputAttributes, 'type' | 'checked' | 'role'> {
7
+ /** On/off state; two-way bindable (`bind:checked`). */
6
8
  checked?: boolean;
9
+ /** Label text rendered next to the switch. */
7
10
  children?: Snippet;
8
11
  }
9
12
 
10
- let { checked = $bindable(), class: klass, children, ...rest }: Props = $props();
13
+ let {
14
+ checked = $bindable(),
15
+ id,
16
+ required,
17
+ 'aria-describedby': describedBy,
18
+ 'aria-invalid': ariaInvalid,
19
+ class: klass,
20
+ children,
21
+ ...rest
22
+ }: Props = $props();
23
+ // Optional: wires id/aria-describedby/aria-invalid/required when inside a <Field>.
24
+ const field = useField();
11
25
  </script>
12
26
 
13
27
  <label data-hl-switch class={klass}>
14
- <input {...rest} type="checkbox" role="switch" bind:checked />
28
+ <input
29
+ {...rest}
30
+ id={id ?? field?.id}
31
+ required={required ?? (field?.required || undefined)}
32
+ aria-describedby={describedBy ?? field?.describedBy}
33
+ aria-invalid={ariaInvalid ?? (field?.invalid || undefined)}
34
+ type="checkbox"
35
+ role="switch"
36
+ bind:checked
37
+ />
15
38
  {@render children?.()}
16
39
  </label>
@@ -1,7 +1,9 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLInputAttributes } from 'svelte/elements';
3
3
  interface Props extends Omit<HTMLInputAttributes, 'type' | 'checked' | 'role'> {
4
+ /** On/off state; two-way bindable (`bind:checked`). */
4
5
  checked?: boolean;
6
+ /** Label text rendered next to the switch. */
5
7
  children?: Snippet;
6
8
  }
7
9
  declare const Switch: import("svelte").Component<Props, {}, "checked">;
@@ -1,16 +1,30 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
3
  import type { HTMLButtonAttributes } from 'svelte/elements';
4
+ import { getTabsContext } from '../context.js';
4
5
 
5
6
  interface Props extends HTMLButtonAttributes {
6
7
  /** Stable value identifying this tab; defaults to its index. */
7
8
  value?: string;
9
+ /** Tab label. */
8
10
  children?: Snippet;
9
11
  }
10
12
 
11
- let { value, children, ...rest }: Props = $props();
13
+ let { value, type, children, ...rest }: Props = $props();
14
+ const tabs = getTabsContext();
15
+ // svelte-ignore state_referenced_locally -- the value identifies this tab for its lifetime
16
+ const index = tabs?.registerTab(value) ?? 0;
17
+ const ownValue = $derived(value ?? String(index));
18
+ const selected = $derived(tabs ? tabs.value === ownValue : undefined);
12
19
  </script>
13
20
 
14
- <button type="button" {...rest} role="tab" data-hl-value={value}>
21
+ <button
22
+ {...rest}
23
+ type={type ?? 'button'}
24
+ role="tab"
25
+ data-hl-value={value}
26
+ aria-selected={selected}
27
+ tabindex={selected === undefined ? undefined : selected ? 0 : -1}
28
+ >
15
29
  {@render children?.()}
16
30
  </button>
@@ -3,6 +3,7 @@ import type { HTMLButtonAttributes } from 'svelte/elements';
3
3
  interface Props extends HTMLButtonAttributes {
4
4
  /** Stable value identifying this tab; defaults to its index. */
5
5
  value?: string;
6
+ /** Tab label. */
6
7
  children?: Snippet;
7
8
  }
8
9
  declare const Tab: import("svelte").Component<Props, {}, "">;
@@ -3,6 +3,7 @@
3
3
  import type { HTMLAttributes } from 'svelte/elements';
4
4
 
5
5
  interface Props extends HTMLAttributes<HTMLDivElement> {
6
+ /** `<Tab>`s, in the same order as the panels. */
6
7
  children?: Snippet;
7
8
  }
8
9
 
@@ -1,6 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  interface Props extends HTMLAttributes<HTMLDivElement> {
4
+ /** `<Tab>`s, in the same order as the panels. */
4
5
  children?: Snippet;
5
6
  }
6
7
  declare const TabList: import("svelte").Component<Props, {}, "">;
@@ -1,14 +1,21 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
3
  import type { HTMLAttributes } from 'svelte/elements';
4
+ import { getTabsContext } from '../context.js';
4
5
 
5
6
  interface Props extends HTMLAttributes<HTMLDivElement> {
7
+ /** Panel content, shown while the tab at the same index is selected. */
6
8
  children?: Snippet;
7
9
  }
8
10
 
9
11
  let { children, ...rest }: Props = $props();
12
+ const tabs = getTabsContext();
13
+ const index = tabs?.registerPanel() ?? 0;
14
+ // Rendered on the server too, so the unselected panels never flash before
15
+ // the enhancer takes over `hidden`.
16
+ const hidden = $derived(tabs ? tabs.value !== tabs.tabValueAt(index) : false);
10
17
  </script>
11
18
 
12
- <div {...rest} role="tabpanel">
19
+ <div {...rest} role="tabpanel" {hidden} tabindex={tabs ? 0 : undefined}>
13
20
  {@render children?.()}
14
21
  </div>
@@ -1,6 +1,7 @@
1
1
  import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  interface Props extends HTMLAttributes<HTMLDivElement> {
4
+ /** Panel content, shown while the tab at the same index is selected. */
4
5
  children?: Snippet;
5
6
  }
6
7
  declare const TabPanel: import("svelte").Component<Props, {}, "">;
@@ -0,0 +1,30 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte';
3
+ import type { HTMLTableAttributes } from 'svelte/elements';
4
+
5
+ interface Props extends Omit<HTMLTableAttributes, 'align'> {
6
+ /** Zebra-stripe the body rows. */
7
+ striped?: boolean;
8
+ /** Highlight a body row under the pointer. */
9
+ hover?: boolean;
10
+ /** Default text alignment of cells (logical, RTL-aware). */
11
+ align?: 'start' | 'center' | 'end';
12
+ /** Cell padding scale. */
13
+ size?: 'sm' | 'md' | 'lg';
14
+ /** `<thead>`, `<tbody>`, `<tfoot>`, and `<caption>` as usual. */
15
+ children?: Snippet;
16
+ }
17
+
18
+ let { striped, hover, align, size, class: klass, children, ...rest }: Props = $props();
19
+ </script>
20
+
21
+ <table
22
+ {...rest}
23
+ class={['hl-table', klass]}
24
+ data-hl-striped={striped || undefined}
25
+ data-hl-hover={hover || undefined}
26
+ data-hl-align={align}
27
+ data-hl-size={size}
28
+ >
29
+ {@render children?.()}
30
+ </table>