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

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 (59) hide show
  1. package/dist/autocomplete/item/autocomplete-item.svelte +10 -0
  2. package/dist/button/root/button-root.svelte +9 -0
  3. package/dist/calendar/body-cell/calendar-body-cell.svelte +7 -0
  4. package/dist/checkbox/indicator/checkbox-indicator.svelte +1 -0
  5. package/dist/checkbox/indicator/checkbox-indicator.svelte.d.ts +1 -0
  6. package/dist/checkbox/root/checkbox-root.svelte +106 -30
  7. package/dist/checkbox/root/checkbox-root.svelte.d.ts +5 -0
  8. package/dist/checkbox-group/README.md +95 -0
  9. package/dist/checkbox-group/index.d.ts +15 -0
  10. package/dist/checkbox-group/index.js +6 -0
  11. package/dist/checkbox-group/index.parts.d.ts +4 -0
  12. package/dist/checkbox-group/index.parts.js +7 -0
  13. package/dist/checkbox-group/label/checkbox-group-label.svelte +36 -0
  14. package/dist/checkbox-group/label/checkbox-group-label.svelte.d.ts +4 -0
  15. package/dist/checkbox-group/root/checkbox-group-root.svelte +118 -0
  16. package/dist/checkbox-group/root/checkbox-group-root.svelte.d.ts +4 -0
  17. package/dist/checkbox-group/root/context.svelte.d.ts +52 -0
  18. package/dist/checkbox-group/root/context.svelte.js +251 -0
  19. package/dist/checkbox-group/types.d.ts +57 -0
  20. package/dist/checkbox-group/types.js +1 -0
  21. package/dist/index.d.ts +4 -0
  22. package/dist/index.js +4 -0
  23. package/dist/primitives/focus-visible.svelte.d.ts +14 -0
  24. package/dist/primitives/focus-visible.svelte.js +19 -0
  25. package/dist/primitives/index.d.ts +1 -0
  26. package/dist/primitives/index.js +1 -0
  27. package/dist/primitives/input-modality.d.ts +7 -0
  28. package/dist/primitives/input-modality.js +32 -5
  29. package/dist/radio-group/README.md +103 -0
  30. package/dist/radio-group/index.d.ts +18 -0
  31. package/dist/radio-group/index.js +9 -0
  32. package/dist/radio-group/index.parts.d.ts +4 -0
  33. package/dist/radio-group/index.parts.js +4 -0
  34. package/dist/radio-group/indicator/radio-group-indicator.svelte +43 -0
  35. package/dist/radio-group/indicator/radio-group-indicator.svelte.d.ts +12 -0
  36. package/dist/radio-group/item/context.d.ts +18 -0
  37. package/dist/radio-group/item/context.js +15 -0
  38. package/dist/radio-group/item/radio-group-item.svelte +377 -0
  39. package/dist/radio-group/item/radio-group-item.svelte.d.ts +35 -0
  40. package/dist/radio-group/label/radio-group-label.svelte +37 -0
  41. package/dist/radio-group/label/radio-group-label.svelte.d.ts +4 -0
  42. package/dist/radio-group/root/context.svelte.d.ts +57 -0
  43. package/dist/radio-group/root/context.svelte.js +284 -0
  44. package/dist/radio-group/root/radio-group-root.svelte +193 -0
  45. package/dist/radio-group/root/radio-group-root.svelte.d.ts +4 -0
  46. package/dist/radio-group/types.d.ts +50 -0
  47. package/dist/radio-group/types.js +1 -0
  48. package/dist/switch/root/switch-root.svelte +9 -0
  49. package/dist/table/column-header-cell/table-column-header-cell.svelte +24 -0
  50. package/dist/table/root/table-root.svelte +29 -6
  51. package/dist/timepicker/input/time-picker-input.svelte +12 -4
  52. package/dist/timepicker/input/time-picker-input.svelte.d.ts +12 -4
  53. package/dist/toggle/root/toggle-root.svelte +28 -0
  54. package/dist/toggle/root/toggle-root.svelte.d.ts +19 -0
  55. package/dist/toggle-group/README.md +6 -4
  56. package/dist/toggle-group/index.d.ts +2 -0
  57. package/dist/toggle-group/index.parts.d.ts +1 -0
  58. package/dist/toggle-group/index.parts.js +4 -0
  59. package/package.json +11 -1
@@ -2,17 +2,25 @@ import type { Snippet } from 'svelte';
2
2
  import type { HTMLAttributes } from 'svelte/elements';
3
3
  import { type TimePickerSegmentPart } from '../root/context';
4
4
  type TimePickerInputProps = Omit<HTMLAttributes<HTMLDivElement>, 'children' | 'class' | 'id' | 'role' | 'tabindex' | 'aria-invalid'> & {
5
+ /**
6
+ * The id of the hidden proxy input. A `<label for>` points to it, and the segmented group
7
+ * then takes a derived id.
8
+ */
5
9
  id?: string;
6
10
  /**
7
- * Name of the hidden proxy input used for form submission. The proxy only
8
- * mirrors the committed value: autofill is NOT supported (it renders with
9
- * `autocomplete="off"` so browsers and password managers do not write
10
- * into it) — times are entered through the editable segments.
11
+ * Name of the hidden proxy input for form submission. The proxy shows only the committed
12
+ * value. It does not support autofill: it renders with `autocomplete="off"`, thus browsers
13
+ * and password managers do not write into it. The user gives the time through the editable
14
+ * segments.
11
15
  */
12
16
  name?: string;
13
17
  children?: Snippet<[TimePickerSegmentPart]>;
14
18
  class?: string;
15
19
  'aria-label'?: string;
20
+ /**
21
+ * Marks the input as invalid. The group is also invalid while a segment draft is not
22
+ * committable.
23
+ */
16
24
  'aria-invalid'?: HTMLAttributes<HTMLDivElement>['aria-invalid'];
17
25
  };
18
26
  declare const TimePickerInput: import("svelte").Component<TimePickerInputProps, {}, "">;
@@ -5,6 +5,7 @@
5
5
  shouldShowFocusVisible,
6
6
  trackInteractionModality
7
7
  } from '../../primitives/input-modality';
8
+ import { watchFocusVisible } from '../../primitives/focus-visible.svelte';
8
9
  import {
9
10
  getToggleGroupContext,
10
11
  type ToggleGroupValue
@@ -23,13 +24,32 @@
23
24
  HTMLButtonAttributes,
24
25
  'children' | 'class' | 'disabled' | 'aria-pressed' | 'type' | 'value'
25
26
  > & {
27
+ /**
28
+ * The stable identifier, which the component puts on the button. In a `ToggleGroup.Root`, the
29
+ * selection needs it. It does not show the selected state.
30
+ */
26
31
  value?: ToggleGroupValue;
32
+ /**
33
+ * The selected state at the start, for when the component controls the state. In a
34
+ * `ToggleGroup`, the component ignores it.
35
+ */
27
36
  defaultSelected?: boolean;
37
+ /**
38
+ * The selected state. You can bind it. When your own code controls the state, `undefined`
39
+ * becomes `false`. In a `ToggleGroup`, the component ignores it.
40
+ */
28
41
  selected?: boolean;
42
+ /** The component calls it when the user changes the selected state. */
29
43
  onChange?: (selected: boolean) => void;
44
+ /** Stops the interaction with the toggle and removes it from the focus order. */
30
45
  disabled?: boolean;
46
+ /**
47
+ * The content of the button. As a snippet, it can receive the current render state, for
48
+ * example `selected`.
49
+ */
31
50
  children?: Snippet<[ToggleRenderState]> | Snippet;
32
51
  class?: string;
52
+ /** A bindable reference to the button element. */
33
53
  element?: HTMLButtonElement | null;
34
54
  };
35
55
 
@@ -91,6 +111,14 @@
91
111
  let pressed = $state(false);
92
112
  let focused = $state(false);
93
113
  let focusVisible = $state(false);
114
+
115
+ // The focus ring must appear when a pointer press is followed by a key press, and the
116
+ // modality alone changes there — no focus event fires to re-read it.
117
+ watchFocusVisible({
118
+ isFocused: () => focused,
119
+ element: () => buttonRef,
120
+ set: (visible) => (focusVisible = visible)
121
+ });
94
122
  let pressedKey: 'Enter' | 'Space' | null = $state(null);
95
123
 
96
124
  untrack(() => {
@@ -10,13 +10,32 @@ export type ToggleRenderState = {
10
10
  disabled: boolean;
11
11
  };
12
12
  type ToggleRootProps = Omit<HTMLButtonAttributes, 'children' | 'class' | 'disabled' | 'aria-pressed' | 'type' | 'value'> & {
13
+ /**
14
+ * The stable identifier, which the component puts on the button. In a `ToggleGroup.Root`, the
15
+ * selection needs it. It does not show the selected state.
16
+ */
13
17
  value?: ToggleGroupValue;
18
+ /**
19
+ * The selected state at the start, for when the component controls the state. In a
20
+ * `ToggleGroup`, the component ignores it.
21
+ */
14
22
  defaultSelected?: boolean;
23
+ /**
24
+ * The selected state. You can bind it. When your own code controls the state, `undefined`
25
+ * becomes `false`. In a `ToggleGroup`, the component ignores it.
26
+ */
15
27
  selected?: boolean;
28
+ /** The component calls it when the user changes the selected state. */
16
29
  onChange?: (selected: boolean) => void;
30
+ /** Stops the interaction with the toggle and removes it from the focus order. */
17
31
  disabled?: boolean;
32
+ /**
33
+ * The content of the button. As a snippet, it can receive the current render state, for
34
+ * example `selected`.
35
+ */
18
36
  children?: Snippet<[ToggleRenderState]> | Snippet;
19
37
  class?: string;
38
+ /** A bindable reference to the button element. */
20
39
  element?: HTMLButtonElement | null;
21
40
  };
22
41
  declare const ToggleRoot: import("svelte").Component<ToggleRootProps, {}, "element" | "selected">;
@@ -7,12 +7,12 @@
7
7
  ## Anatomy
8
8
 
9
9
  - `ToggleGroup.Root`
10
- - `Toggle.Root`
10
+ - `ToggleGroup.Item`
11
11
 
12
12
  ```svelte
13
13
  <ToggleGroup.Root defaultValue={['bold']} selectionMode="multiple" aria-label="Text style">
14
- <Toggle.Root value="bold">Bold</Toggle.Root>
15
- <Toggle.Root value="italic">Italic</Toggle.Root>
14
+ <ToggleGroup.Item value="bold">Bold</ToggleGroup.Item>
15
+ <ToggleGroup.Item value="italic">Italic</ToggleGroup.Item>
16
16
  </ToggleGroup.Root>
17
17
  ```
18
18
 
@@ -26,7 +26,9 @@
26
26
  - Use `selectionMode="single"` when only one toggle can be selected.
27
27
  - Use `selectionMode="multiple"` when several toggles can be selected.
28
28
  - Use `disallowEmptySelection` when at least one enabled toggle must remain selected.
29
- - Every grouped `Toggle.Root` must provide a unique `value`.
29
+ - `ToggleGroup.Item` is `Toggle.Root` under the namespace of the group, and the two names are
30
+ the same component. A toggle works on its own, thus it keeps its own name too.
31
+ - Every toggle in a group must provide a unique `value`.
30
32
 
31
33
  ## API reference
32
34
 
@@ -1,8 +1,10 @@
1
1
  import type { ComponentProps } from 'svelte';
2
+ import type ToggleRootComponent from '../toggle/root/toggle-root.svelte';
2
3
  import type ToggleGroupRootComponent from './root/toggle-group-root.svelte';
3
4
  export * as ToggleGroup from './index.parts.js';
4
5
  export { default as ToggleGroupRoot } from './root/toggle-group-root.svelte';
5
6
  export type ToggleGroupRootProps = ComponentProps<typeof ToggleGroupRootComponent>;
7
+ export type ToggleGroupItemProps = ComponentProps<typeof ToggleRootComponent>;
6
8
  export { createToggleGroupContext, getToggleGroupContext, setToggleGroupContext, valuesToArray, type CreateToggleGroupContextOptions, type ToggleGroupContext, type ToggleGroupOrientation, type ToggleGroupSelectionMode, type ToggleGroupValue } from './root/context.svelte';
7
9
  import * as ToggleGroupParts from './index.parts.js';
8
10
  export default ToggleGroupParts;
@@ -1 +1,2 @@
1
1
  export { default as Root } from './root/toggle-group-root.svelte';
2
+ export { default as Item } from '../toggle/root/toggle-root.svelte';
@@ -1 +1,5 @@
1
1
  export { default as Root } from './root/toggle-group-root.svelte';
2
+ // `Item` is `Toggle.Root` under the namespace of the group. A toggle works on its own, so it keeps
3
+ // its own name; this only gives every group in the library the same shape — `Group.Root` with
4
+ // `Group.Item` inside.
5
+ export { default as Item } from '../toggle/root/toggle-root.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@human-kit/ui",
3
- "version": "1.0.0-beta.6",
3
+ "version": "1.0.0-beta.7",
4
4
  "description": "Accessible, typed UI components for Svelte 5 — shipped as native ESM with per-component subpath exports so bundlers only include what you import.",
5
5
  "license": "MIT",
6
6
  "author": "Agustin Delgado <agustindariodelgado@gmail.com>",
@@ -73,6 +73,11 @@
73
73
  "svelte": "./dist/checkbox/index.js",
74
74
  "default": "./dist/checkbox/index.js"
75
75
  },
76
+ "./checkbox-group": {
77
+ "types": "./dist/checkbox-group/index.d.ts",
78
+ "svelte": "./dist/checkbox-group/index.js",
79
+ "default": "./dist/checkbox-group/index.js"
80
+ },
76
81
  "./collapsible": {
77
82
  "types": "./dist/collapsible/index.d.ts",
78
83
  "svelte": "./dist/collapsible/index.js",
@@ -148,6 +153,11 @@
148
153
  "svelte": "./dist/popover/index.js",
149
154
  "default": "./dist/popover/index.js"
150
155
  },
156
+ "./radio-group": {
157
+ "types": "./dist/radio-group/index.d.ts",
158
+ "svelte": "./dist/radio-group/index.js",
159
+ "default": "./dist/radio-group/index.js"
160
+ },
151
161
  "./table": {
152
162
  "types": "./dist/table/index.d.ts",
153
163
  "svelte": "./dist/table/index.js",