@glasshome/ui 1.41.0 → 1.43.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 (188) hide show
  1. package/SPEC.md +5 -0
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +3 -3
  4. package/dist/lib/anchor-placement.d.ts +34 -0
  5. package/dist/lib/balance-rows.d.ts +10 -4
  6. package/dist/lib/behavior/anchored.d.ts +26 -0
  7. package/dist/lib/behavior/button-root.d.ts +7 -0
  8. package/dist/lib/behavior/collection.d.ts +32 -0
  9. package/dist/lib/behavior/controllable.d.ts +8 -0
  10. package/dist/lib/behavior/dismiss.d.ts +13 -0
  11. package/dist/lib/behavior/focus-scope.d.ts +24 -0
  12. package/dist/lib/behavior/hide-outside.d.ts +7 -0
  13. package/dist/lib/behavior/layer-stack.d.ts +34 -0
  14. package/dist/lib/behavior/menu.d.ts +59 -0
  15. package/dist/lib/behavior/modal-root.d.ts +68 -0
  16. package/dist/lib/behavior/polymorphic.d.ts +6 -0
  17. package/dist/lib/behavior/presence.d.ts +18 -0
  18. package/dist/lib/behavior/range.d.ts +44 -0
  19. package/dist/lib/behavior/solid.d.ts +13 -0
  20. package/dist/lib/color/color.d.ts +41 -0
  21. package/dist/lib/color/index.d.ts +2 -0
  22. package/dist/lib/color/intl.d.ts +40 -0
  23. package/dist/lib/dock-slot-classes.d.ts +2 -0
  24. package/dist/lib/hold.d.ts +1 -1
  25. package/dist/lib/locale.d.ts +3 -0
  26. package/dist/lib/menu-classes.d.ts +2 -0
  27. package/dist/lib/motion-classes.d.ts +5 -2
  28. package/dist/lib/overlay-classes.d.ts +4 -0
  29. package/dist/lib/page-cover.d.ts +8 -0
  30. package/dist/lib/scroll-track.d.ts +3 -2
  31. package/dist/lib/section-tokens.d.ts +1 -1
  32. package/dist/lib/segment-classes.d.ts +2 -0
  33. package/dist/lib/shadow-layer.d.ts +0 -43
  34. package/dist/lib/toggle-set.d.ts +44 -0
  35. package/dist/lib/visually-hidden.d.ts +3 -0
  36. package/dist/solid/accordion.d.ts +35 -11
  37. package/dist/solid/alert-dialog.d.ts +5 -8
  38. package/dist/solid/avatar.d.ts +8 -4
  39. package/dist/solid/bottom-sheet/bottom-sheet.d.ts +2 -2
  40. package/dist/solid/bottom-sheet/constants.d.ts +1 -1
  41. package/dist/solid/button.d.ts +5 -4
  42. package/dist/solid/charts.d.ts +1 -1
  43. package/dist/solid/checkbox.d.ts +14 -4
  44. package/dist/solid/collapsible.d.ts +33 -5
  45. package/dist/solid/color-disc.d.ts +1 -1
  46. package/dist/solid/color-slider.d.ts +1 -1
  47. package/dist/solid/color-wheel.d.ts +1 -1
  48. package/dist/solid/context-menu.d.ts +58 -24
  49. package/dist/solid/dialog-parts.d.ts +53 -16
  50. package/dist/solid/dialog.d.ts +7 -10
  51. package/dist/solid/dropdown-menu.d.ts +55 -24
  52. package/dist/solid/empty.d.ts +1 -1
  53. package/dist/solid/form.d.ts +5 -6
  54. package/dist/solid/hover-card.d.ts +65 -9
  55. package/dist/solid/index.d.ts +5 -2
  56. package/dist/solid/index.js +8671 -14317
  57. package/dist/solid/input-group.d.ts +6 -6
  58. package/dist/solid/item.d.ts +1 -1
  59. package/dist/solid/menu-parts.d.ts +175 -24
  60. package/dist/solid/option-card.d.ts +1 -4
  61. package/dist/solid/picker-row.d.ts +2 -0
  62. package/dist/solid/popover.d.ts +77 -12
  63. package/dist/solid/progress.d.ts +11 -3
  64. package/dist/solid/radio-group.d.ts +31 -6
  65. package/dist/solid/responsive-dialog.d.ts +3 -1
  66. package/dist/solid/scroll-area.d.ts +1 -1
  67. package/dist/solid/section-card.d.ts +2 -3
  68. package/dist/solid/select.d.ts +107 -10
  69. package/dist/solid/selection.d.ts +10 -1
  70. package/dist/solid/sheet.d.ts +6 -9
  71. package/dist/solid/sliding-indicator.d.ts +1 -1
  72. package/dist/solid/sonner.d.ts +1 -1
  73. package/dist/solid/stale-veil.d.ts +7 -0
  74. package/dist/solid/tabs.d.ts +28 -9
  75. package/dist/solid/toggle-group.d.ts +30 -5
  76. package/dist/solid/toggle.d.ts +11 -3
  77. package/dist/solid/tooltip.d.ts +71 -9
  78. package/dist/tokens/index.js +54 -51
  79. package/dist/{utils-CGN4X-2O.js → utils-3Codx-NZ.js} +848 -618
  80. package/package.json +6 -7
  81. package/src/index.ts +1 -0
  82. package/src/lib/anchor-placement.ts +77 -4
  83. package/src/lib/balance-rows.ts +115 -40
  84. package/src/lib/behavior/anchored.ts +106 -0
  85. package/src/lib/behavior/button-root.tsx +103 -0
  86. package/src/lib/behavior/collection.ts +218 -0
  87. package/src/lib/behavior/controllable.ts +22 -0
  88. package/src/lib/behavior/dismiss.ts +185 -0
  89. package/src/lib/behavior/focus-scope.ts +227 -0
  90. package/src/lib/behavior/hide-outside.ts +85 -0
  91. package/src/lib/behavior/layer-stack.ts +150 -0
  92. package/src/lib/behavior/menu.ts +470 -0
  93. package/src/lib/behavior/modal-root.tsx +452 -0
  94. package/src/lib/behavior/polymorphic.tsx +30 -0
  95. package/src/lib/behavior/presence.ts +89 -0
  96. package/src/lib/behavior/range.ts +212 -0
  97. package/src/lib/behavior/solid.ts +30 -0
  98. package/src/lib/clipboard.ts +4 -4
  99. package/src/lib/color/color.ts +746 -0
  100. package/src/lib/color/index.ts +2 -0
  101. package/src/lib/color/intl.ts +60 -0
  102. package/src/lib/dock-slot-classes.ts +3 -0
  103. package/src/lib/hold.ts +1 -1
  104. package/src/lib/locale.ts +62 -0
  105. package/src/lib/menu-classes.ts +3 -0
  106. package/src/lib/motion-classes.ts +33 -8
  107. package/src/lib/overlay-classes.ts +8 -3
  108. package/src/lib/page-cover.ts +47 -0
  109. package/src/lib/scroll-track.ts +11 -6
  110. package/src/lib/section-tokens.ts +1 -1
  111. package/src/lib/segment-classes.ts +3 -0
  112. package/src/lib/shadow-layer.ts +0 -136
  113. package/src/lib/toggle-set.ts +133 -0
  114. package/src/lib/visually-hidden.ts +15 -0
  115. package/src/solid/accordion.tsx +294 -20
  116. package/src/solid/alert-dialog.tsx +36 -85
  117. package/src/solid/area-picker.tsx +5 -3
  118. package/src/solid/avatar.tsx +98 -24
  119. package/src/solid/badge.tsx +5 -5
  120. package/src/solid/bottom-sheet/bottom-sheet.tsx +73 -129
  121. package/src/solid/bottom-sheet/constants.ts +3 -1
  122. package/src/solid/bottom-sheet/drag-controller.ts +11 -0
  123. package/src/solid/breadcrumb.tsx +4 -4
  124. package/src/solid/button-group.tsx +4 -4
  125. package/src/solid/button.tsx +12 -6
  126. package/src/solid/card.tsx +5 -4
  127. package/src/solid/charts.tsx +1 -1
  128. package/src/solid/checkbox.tsx +167 -44
  129. package/src/solid/collapsible.tsx +260 -12
  130. package/src/solid/color-disc.tsx +11 -12
  131. package/src/solid/color-slider.tsx +114 -47
  132. package/src/solid/color-wheel.tsx +137 -39
  133. package/src/solid/context-menu.tsx +287 -86
  134. package/src/solid/dialog-parts.tsx +135 -46
  135. package/src/solid/dialog.tsx +44 -76
  136. package/src/solid/dock-edit.tsx +5 -4
  137. package/src/solid/dock.tsx +6 -5
  138. package/src/solid/dropdown-menu.tsx +252 -107
  139. package/src/solid/empty.tsx +1 -1
  140. package/src/solid/entity-selector.tsx +5 -3
  141. package/src/solid/face-toggle.tsx +43 -18
  142. package/src/solid/form.tsx +9 -9
  143. package/src/solid/glyph-tile.tsx +48 -21
  144. package/src/solid/hover-card.tsx +288 -21
  145. package/src/solid/icon-picker.tsx +2 -1
  146. package/src/solid/image-picker.tsx +6 -5
  147. package/src/solid/index.ts +5 -4
  148. package/src/solid/input-group.tsx +7 -5
  149. package/src/solid/input-otp.tsx +2 -1
  150. package/src/solid/item.tsx +5 -5
  151. package/src/solid/logo.tsx +5 -4
  152. package/src/solid/menu-parts.tsx +619 -145
  153. package/src/solid/option-card.tsx +6 -10
  154. package/src/solid/picker-row.tsx +10 -5
  155. package/src/solid/picker-search.tsx +2 -1
  156. package/src/solid/popover.tsx +424 -71
  157. package/src/solid/preview-tile.tsx +1 -1
  158. package/src/solid/progress.tsx +84 -15
  159. package/src/solid/radio-group.tsx +271 -34
  160. package/src/solid/responsive-dialog.tsx +10 -10
  161. package/src/solid/schema-form.tsx +1 -6
  162. package/src/solid/scroll-area.tsx +1 -1
  163. package/src/solid/section-card.tsx +3 -4
  164. package/src/solid/select.tsx +950 -95
  165. package/src/solid/selection.tsx +142 -66
  166. package/src/solid/sheet.tsx +48 -80
  167. package/src/solid/slider.tsx +115 -65
  168. package/src/solid/sliding-indicator.tsx +1 -1
  169. package/src/solid/sonner.tsx +1 -1
  170. package/src/solid/spotlight.tsx +23 -11
  171. package/src/solid/stale-veil.tsx +20 -0
  172. package/src/solid/switch.tsx +8 -6
  173. package/src/solid/tabs.tsx +377 -52
  174. package/src/solid/term.tsx +3 -4
  175. package/src/solid/toggle-group.tsx +237 -95
  176. package/src/solid/toggle.tsx +43 -9
  177. package/src/solid/tooltip.tsx +285 -26
  178. package/src/styles/globals.css +64 -10
  179. package/src/styles/theme.css +12 -4
  180. package/src/tokens/material.ts +11 -2
  181. package/dist/lib/when-animations-settle.d.ts +0 -4
  182. package/dist/solid/bottom-sheet/focus-trap.d.ts +0 -6
  183. package/dist/solid/bottom-sheet/scroll-lock.d.ts +0 -2
  184. package/dist/solid/bottom-sheet/sheet-motion.d.ts +0 -1
  185. package/src/lib/when-animations-settle.ts +0 -12
  186. package/src/solid/bottom-sheet/focus-trap.ts +0 -63
  187. package/src/solid/bottom-sheet/scroll-lock.ts +0 -66
  188. package/src/solid/bottom-sheet/sheet-motion.ts +0 -4
@@ -1,21 +1,90 @@
1
- import { Progress as ProgressPrimitive } from "@kobalte/core/progress";
2
- import { type Component, type ComponentProps, splitProps } from "solid-js";
1
+ import {
2
+ type Component,
3
+ type ComponentProps,
4
+ createMemo,
5
+ createUniqueId,
6
+ splitProps,
7
+ } from "solid-js";
8
+ import { merge } from "../lib/behavior/solid.js";
3
9
  import { FIELD_CHROME } from "../lib/input-classes.js";
4
10
  import { cn } from "../lib/utils.js";
5
11
 
6
- const Progress: Component<
7
- ComponentProps<typeof ProgressPrimitive> & { value?: number; tone?: string }
8
- > = (props) => {
9
- const [local, rest] = splitProps(props, ["class", "value", "tone"]);
12
+ type ProgressProps = Omit<ComponentProps<"div">, "children"> & {
13
+ value?: number;
14
+ minValue?: number;
15
+ maxValue?: number;
16
+ indeterminate?: boolean;
17
+ getValueLabel?: (params: { value: number; min: number; max: number }) => string;
18
+ tone?: string;
19
+ };
20
+
21
+ const Progress: Component<ProgressProps> = (props) => {
22
+ const fallbackId = `progress-${createUniqueId()}`;
23
+ const [local, rest] = splitProps(props, [
24
+ "class",
25
+ "value",
26
+ "minValue",
27
+ "maxValue",
28
+ "indeterminate",
29
+ "getValueLabel",
30
+ "tone",
31
+ ]);
32
+ const min = () => local.minValue ?? 0;
33
+ const max = () => local.maxValue ?? 100;
34
+ const value = () => Math.min(Math.max(local.value ?? 0, min()), max());
35
+ const share = () => (value() - min()) / (max() - min());
36
+ const percent = createMemo(() => new Intl.NumberFormat(undefined, { style: "percent" }));
37
+ const valueText = () => {
38
+ if (local.indeterminate) return undefined;
39
+ if (local.getValueLabel) return local.getValueLabel({ value: value(), min: min(), max: max() });
40
+ return percent().format(share());
41
+ };
42
+ const markers = {
43
+ get "data-progress"() {
44
+ if (local.indeterminate) return undefined;
45
+ return share() === 1 ? "complete" : "loading";
46
+ },
47
+ get "data-indeterminate"() {
48
+ return local.indeterminate ? "" : undefined;
49
+ },
50
+ };
51
+
10
52
  return (
11
- <ProgressPrimitive
12
- data-slot="progress"
13
- value={local.value}
14
- class={cn(FIELD_CHROME, "relative h-2 w-full overflow-hidden rounded-full", local.class)}
15
- {...rest}
53
+ <div
54
+ {...merge(
55
+ {
56
+ id: fallbackId,
57
+ role: "progressbar" as const,
58
+ get "aria-valuenow"() {
59
+ return local.indeterminate ? undefined : value();
60
+ },
61
+ get "aria-valuemin"() {
62
+ return min();
63
+ },
64
+ get "aria-valuemax"() {
65
+ return max();
66
+ },
67
+ get "aria-valuetext"() {
68
+ return valueText();
69
+ },
70
+ },
71
+ markers,
72
+ { "data-slot": "progress" },
73
+ rest,
74
+ {
75
+ get class() {
76
+ return cn(
77
+ FIELD_CHROME,
78
+ "relative h-2 w-full overflow-hidden rounded-full",
79
+ local.class,
80
+ );
81
+ },
82
+ },
83
+ )}
16
84
  >
17
- <ProgressPrimitive.Track class="h-full w-full">
18
- <ProgressPrimitive.Fill
85
+ <div {...markers} class="h-full w-full">
86
+ <div
87
+ {...markers}
19
88
  data-slot="progress-indicator"
20
89
  class="glass glass-tint transition-glass h-full w-full flex-1"
21
90
  style={{
@@ -23,8 +92,8 @@ const Progress: Component<
23
92
  transform: `translateX(-${100 - (local.value || 0)}%)`,
24
93
  }}
25
94
  />
26
- </ProgressPrimitive.Track>
27
- </ProgressPrimitive>
95
+ </div>
96
+ </div>
28
97
  );
29
98
  };
30
99
 
@@ -1,28 +1,158 @@
1
- import { RadioGroup as RadioGroupPrimitive } from "@kobalte/core/radio-group";
2
1
  import {
3
2
  children,
4
- type Component,
5
3
  type ComponentProps,
4
+ createContext,
5
+ createSignal,
6
+ createUniqueId,
7
+ type JSX,
6
8
  type ParentComponent,
7
9
  Show,
8
10
  splitProps,
11
+ useContext,
9
12
  } from "solid-js";
10
- import { busyProps } from "../lib/busy.js";
13
+ import { createControllableSignal } from "../lib/behavior/controllable.js";
14
+ import { trackFocus } from "../lib/behavior/focus-scope.js";
15
+ import { callEventHandler, effect } from "../lib/behavior/solid.js";
11
16
  import { FIELD_CHROME } from "../lib/input-classes.js";
12
17
  import { cn } from "../lib/utils.js";
18
+ import { VISUALLY_HIDDEN } from "../lib/visually-hidden.js";
19
+
20
+ type RadioGroupContextValue = {
21
+ id: () => string;
22
+ name: () => string;
23
+ isSelectedValue: (value: string) => boolean;
24
+ select: (value: string) => void;
25
+ disabled: () => boolean;
26
+ required: () => boolean;
27
+ readOnly: () => boolean;
28
+ defaultValue: () => string;
29
+ };
30
+
31
+ const RadioGroupContext = createContext<RadioGroupContextValue>();
32
+
33
+ function useRadioGroup(): RadioGroupContextValue {
34
+ const context = useContext(RadioGroupContext);
35
+ if (!context) throw new Error("RadioGroupItem renders inside a RadioGroup");
36
+ return context;
37
+ }
38
+
39
+ const formState = (group: RadioGroupContextValue) => ({
40
+ "data-required": group.required() ? "" : undefined,
41
+ "data-disabled": group.disabled() ? "" : undefined,
42
+ "data-readonly": group.readOnly() ? "" : undefined,
43
+ });
44
+
45
+ type RadioGroupProps = Omit<ComponentProps<"div">, "onChange"> & {
46
+ value?: string;
47
+ defaultValue?: string;
48
+ onChange?: (value: string) => void;
49
+ name?: string;
50
+ orientation?: "horizontal" | "vertical";
51
+ disabled?: boolean;
52
+ required?: boolean;
53
+ readOnly?: boolean;
54
+ };
55
+
56
+ const RadioGroup = (props: RadioGroupProps) => {
57
+ const [local, rest] = splitProps(props, [
58
+ "class",
59
+ "value",
60
+ "defaultValue",
61
+ "onChange",
62
+ "name",
63
+ "orientation",
64
+ "disabled",
65
+ "required",
66
+ "readOnly",
67
+ "id",
68
+ "ref",
69
+ "aria-labelledby",
70
+ "children",
71
+ ]);
72
+ const fallbackId = `radiogroup-${createUniqueId()}`;
73
+ const id = () => local.id ?? fallbackId;
74
+ const [root, setRoot] = createSignal<HTMLDivElement>();
75
+ const [selected, setSelected] = createControllableSignal({
76
+ value: () => local.value,
77
+ defaultValue: () => local.defaultValue ?? "",
78
+ onChange: (next) => local.onChange?.(next),
79
+ });
80
+ // A controlled group that keeps its value must put the browser's own checked state back.
81
+ const syncInputs = () => {
82
+ for (const input of root()?.querySelectorAll<HTMLInputElement>("[type='radio']") ?? []) {
83
+ input.checked = input.value === selected();
84
+ }
85
+ };
86
+ const context: RadioGroupContextValue = {
87
+ id,
88
+ name: () => local.name ?? id(),
89
+ isSelectedValue: (value) => value === selected(),
90
+ select: (value) => {
91
+ if (!local.readOnly && !local.disabled) setSelected(value);
92
+ syncInputs();
93
+ },
94
+ disabled: () => local.disabled ?? false,
95
+ required: () => local.required ?? false,
96
+ readOnly: () => local.readOnly ?? false,
97
+ defaultValue: () => local.defaultValue ?? "",
98
+ };
99
+ effect(root, (el) => {
100
+ if (!el) return;
101
+ // Space on the checked radio sends no click of its own, so a keyboard pick would never reach onPick.
102
+ const down = (event: KeyboardEvent) => {
103
+ arrowKeyHeld = event.key.startsWith("Arrow");
104
+ const target = event.target;
105
+ if (event.key === " " && target instanceof HTMLInputElement && target.checked) target.click();
106
+ };
107
+ const up = () => {
108
+ arrowKeyHeld = false;
109
+ };
110
+ el.addEventListener("keydown", down, true);
111
+ el.addEventListener("keyup", up, true);
112
+ return () => {
113
+ el.removeEventListener("keydown", down, true);
114
+ el.removeEventListener("keyup", up, true);
115
+ };
116
+ });
117
+ effect(
118
+ () => root()?.closest("form"),
119
+ (form) => {
120
+ if (!form) return;
121
+ const reset = () => setSelected(local.defaultValue ?? "");
122
+ form.addEventListener("reset", reset);
123
+ return () => form.removeEventListener("reset", reset);
124
+ },
125
+ );
126
+ const labelledBy = () =>
127
+ [local["aria-labelledby"], local["aria-labelledby"] && rest["aria-label"] ? id() : undefined]
128
+ .filter(Boolean)
129
+ .join(" ") || undefined;
13
130
 
14
- const RadioGroup: Component<ComponentProps<typeof RadioGroupPrimitive>> = (props) => {
15
- const [local, rest] = splitProps(props, ["class"]);
16
131
  return (
17
- <RadioGroupPrimitive
18
- data-slot="radio-group"
19
- class={cn("flex flex-col gap-3", local.class)}
20
- {...rest}
21
- />
132
+ <RadioGroupContext.Provider value={context}>
133
+ <div
134
+ ref={(el) => {
135
+ setRoot(el);
136
+ if (typeof local.ref === "function") local.ref(el);
137
+ }}
138
+ role="radiogroup"
139
+ id={id()}
140
+ aria-labelledby={labelledBy()}
141
+ aria-orientation={local.orientation ?? "vertical"}
142
+ aria-required={local.required || undefined}
143
+ aria-disabled={local.disabled || undefined}
144
+ aria-readonly={local.readOnly || undefined}
145
+ {...formState(context)}
146
+ data-slot="radio-group"
147
+ class={cn("flex flex-col gap-3", local.class)}
148
+ {...rest}
149
+ >
150
+ {local.children}
151
+ </div>
152
+ </RadioGroupContext.Provider>
22
153
  );
23
154
  };
24
155
 
25
- // Its own component so the children resolve once, under the item's Kobalte context.
26
156
  const RadioGroupItemContent: ParentComponent = (props) => {
27
157
  const content = children(() => props.children);
28
158
  return (
@@ -34,26 +164,126 @@ const RadioGroupItemContent: ParentComponent = (props) => {
34
164
  );
35
165
  };
36
166
 
37
- const RadioGroupItem: Component<
38
- ComponentProps<typeof RadioGroupPrimitive.Item> & { showControl?: boolean; busy?: boolean }
39
- > = (props) => {
40
- const [local, rest] = splitProps(props, ["class", "children", "showControl", "busy"]);
167
+ type RadioGroupItemProps = Omit<ComponentProps<"div">, "onClick"> & {
168
+ value: string;
169
+ disabled?: boolean;
170
+ showControl?: boolean;
171
+ /** Presses do nothing; unlike `disabled` it keeps focus. */
172
+ busy?: boolean;
173
+ onClick?: JSX.EventHandlerUnion<HTMLDivElement, MouseEvent>;
174
+ };
175
+
176
+ const RadioGroupItem = (props: RadioGroupItemProps) => {
177
+ const group = useRadioGroup();
178
+ const [local, rest] = splitProps(props, [
179
+ "class",
180
+ "children",
181
+ "showControl",
182
+ "busy",
183
+ "value",
184
+ "disabled",
185
+ "id",
186
+ "ref",
187
+ "onClick",
188
+ ]);
189
+ const fallbackId = `${group.id()}-item-${createUniqueId()}`;
190
+ const id = () => local.id ?? fallbackId;
191
+ const disabled = () => group.disabled() || (local.disabled ?? false);
192
+ const checked = () => group.isSelectedValue(local.value);
193
+ const [item, setItem] = createSignal<HTMLDivElement>();
194
+ const [input, setInput] = createSignal<HTMLInputElement>();
195
+ const state = () => ({
196
+ ...formState(group),
197
+ "data-disabled": disabled() ? "" : undefined,
198
+ "data-checked": checked() ? "" : undefined,
199
+ });
200
+
201
+ effect(
202
+ () => [input(), local.value === group.defaultValue()] as const,
203
+ ([el, isDefault]) => {
204
+ if (el) el.defaultChecked = isDefault;
205
+ },
206
+ );
207
+ let inputFocus: ReturnType<typeof trackFocus> | undefined;
208
+ effect(input, (el) => {
209
+ if (!el) return;
210
+ const tracked = trackFocus(el);
211
+ inputFocus = tracked;
212
+ return tracked.stop;
213
+ });
214
+ // Bound on the elements, since Solid's delegated handlers never reach inside a closed shadow root.
215
+ effect(item, (node) => {
216
+ if (!node) return;
217
+ const pointerdown = (event: PointerEvent) => {
218
+ if (inputFocus?.has()) event.preventDefault();
219
+ };
220
+ const click = (event: MouseEvent) =>
221
+ callEventHandler(
222
+ event as MouseEvent & { currentTarget: HTMLDivElement; target: Element },
223
+ local.onClick,
224
+ );
225
+ node.addEventListener("pointerdown", pointerdown);
226
+ node.addEventListener("click", click);
227
+ return () => {
228
+ node.removeEventListener("pointerdown", pointerdown);
229
+ node.removeEventListener("click", click);
230
+ };
231
+ });
232
+
233
+ const change = (event: Event) => {
234
+ const target = event.currentTarget as HTMLInputElement;
235
+ if (target.checked) group.select(local.value);
236
+ target.checked = checked();
237
+ };
238
+
41
239
  return (
42
- <RadioGroupPrimitive.Item
240
+ <div
241
+ ref={(el) => {
242
+ setItem(el);
243
+ if (typeof local.ref === "function") local.ref(el);
244
+ }}
245
+ role="group"
246
+ id={id()}
247
+ {...state()}
43
248
  data-slot="radio-group-item"
44
249
  class={cn("flex", local.class)}
45
250
  {...rest}
46
251
  >
47
- <RadioGroupPrimitive.ItemInput class="peer" {...(local.busy ? busyProps : undefined)} />
48
- <RadioGroupPrimitive.ItemLabel
252
+ <input
253
+ ref={setInput}
254
+ type="radio"
255
+ id={`${id()}-input`}
256
+ name={group.name()}
257
+ value={local.value}
258
+ checked={checked()}
259
+ required={group.required()}
260
+ disabled={disabled()}
261
+ readOnly={group.readOnly()}
262
+ style={VISUALLY_HIDDEN}
263
+ aria-labelledby={`${id()}-label`}
264
+ {...state()}
265
+ class="peer"
266
+ aria-busy={local.busy || undefined}
267
+ aria-disabled={local.busy || undefined}
268
+ on:click={(event) => {
269
+ if (local.busy) event.preventDefault();
270
+ }}
271
+ on:change={change}
272
+ />
273
+ <label
274
+ for={`${id()}-input`}
275
+ id={`${id()}-label`}
276
+ {...state()}
49
277
  data-slot="radio-group-item-label"
50
278
  class="flex flex-1 cursor-pointer items-center gap-2.5 select-none data-[disabled]:cursor-not-allowed"
51
279
  >
52
280
  <Show when={local.showControl ?? true}>
53
- <RadioGroupPrimitive.ItemControl
281
+ <div
282
+ id={`${id()}-control`}
283
+ {...state()}
54
284
  data-slot="radio-group-item-control"
55
285
  class={cn(
56
- "transition-glass relative flex aspect-square size-7 shrink-0 items-center justify-center overflow-hidden rounded-full duration-200 ease-out active:scale-90",
286
+ "transition-glass relative flex aspect-square size-7 shrink-0 items-center justify-center overflow-hidden rounded-full duration-(--duration-expand) ease-out active:scale-90",
57
287
  FIELD_CHROME,
58
288
  "peer-focus-visible:ring-ring/50 peer-focus-visible:ring-[3px] peer-focus-visible:[--glass-edge:var(--ring)]",
59
289
  "data-[invalid]:ring-destructive/20 data-[disabled]:opacity-40 data-[invalid]:[--glass-edge:var(--destructive)]",
@@ -61,26 +291,33 @@ const RadioGroupItem: Component<
61
291
  >
62
292
  {/* Gradient backgrounds can't transition; the glass rides an inner element
63
293
  that animates in. */}
64
- <RadioGroupPrimitive.ItemIndicator
65
- data-slot="radio-group-item-indicator"
66
- class="glass glass-tint zoom-in-50 fade-in animate-in absolute inset-0 grid place-items-center rounded-full duration-200 [--glass-tone:var(--primary)] [--glass-wash:90%]"
67
- >
68
- <span
69
- data-slot="radio-group-item-dot"
70
- class="color-calc:[background:oklch(from_var(--primary)_calc((0.42_-_l)*100)_0_0)] dark:color-calc:[background:oklch(from_var(--primary)_calc((0.6_-_l)*100)_0_0)] bg-primary-foreground size-[36%] rounded-full"
71
- />
72
- </RadioGroupPrimitive.ItemIndicator>
73
- </RadioGroupPrimitive.ItemControl>
294
+ <Show when={checked()}>
295
+ <div
296
+ id={`${id()}-indicator`}
297
+ {...state()}
298
+ data-slot="radio-group-item-indicator"
299
+ class="glass glass-tint zoom-in-50 fade-in animate-in absolute inset-0 grid place-items-center rounded-full duration-(--duration-expand) [--glass-tone:var(--primary)] [--glass-wash:90%]"
300
+ >
301
+ <span
302
+ data-slot="radio-group-item-dot"
303
+ class="color-calc:[background:oklch(from_var(--primary)_calc((0.42_-_l)*100)_0_0)] dark:color-calc:[background:oklch(from_var(--primary)_calc((0.6_-_l)*100)_0_0)] bg-primary-foreground size-[36%] rounded-full"
304
+ />
305
+ </div>
306
+ </Show>
307
+ </div>
74
308
  </Show>
75
309
  <RadioGroupItemContent>{local.children}</RadioGroupItemContent>
76
- </RadioGroupPrimitive.ItemLabel>
77
- </RadioGroupPrimitive.Item>
310
+ </label>
311
+ </div>
78
312
  );
79
313
  };
80
314
 
315
+ let arrowKeyHeld = false;
316
+
81
317
  // A press on the label reaches the item twice: once itself, once as the input click it forwards.
318
+ // An arrow key checks the next radio with a click of its own, which picks nothing.
82
319
  function isItemActivation(event: MouseEvent): boolean {
83
- return event.target instanceof HTMLInputElement;
320
+ return event.target instanceof HTMLInputElement && !(event.detail === 0 && arrowKeyHeld);
84
321
  }
85
322
 
86
- export { isItemActivation, RadioGroup, RadioGroupItem };
323
+ export { isItemActivation, RadioGroup, RadioGroupItem, useRadioGroup };
@@ -3,7 +3,6 @@ import {
3
3
  type Component,
4
4
  type ComponentProps,
5
5
  createContext,
6
- createSignal,
7
6
  type JSX,
8
7
  type ParentComponent,
9
8
  Show,
@@ -12,6 +11,7 @@ import {
12
11
  type ValidComponent,
13
12
  } from "solid-js";
14
13
  import type { buttonVariants } from "../lib/button-variants.js";
14
+ import { createControllableSignal } from "../lib/behavior/controllable.js";
15
15
  import { createIsMobile } from "../lib/use-is-mobile.js";
16
16
  import {
17
17
  BottomSheet,
@@ -46,27 +46,27 @@ interface ResponsiveDialogProps {
46
46
  open?: boolean;
47
47
  onOpenChange?: (open: boolean) => void;
48
48
  defaultOpen?: boolean;
49
+ /** The centred dialog stays mounted and dormant between opens; the bottom sheet ignores it. */
50
+ keep?: boolean;
49
51
  }
50
52
 
51
- /** Centred kobalte dialog from `sm` up, drag-to-dismiss bottom sheet below it.
53
+ /** Centred dialog from `sm` up, drag-to-dismiss bottom sheet below it.
52
54
  * Both branches render the same parts, so a call site never branches. */
53
55
  const ResponsiveDialog: ParentComponent<ResponsiveDialogProps> = (props) => {
54
- const [uncontrolledOpen, setUncontrolledOpen] = createSignal(props.defaultOpen ?? false);
56
+ const [open, setOpen] = createControllableSignal<boolean>({
57
+ value: () => props.open,
58
+ defaultValue: () => props.defaultOpen ?? false,
59
+ onChange: (next) => props.onOpenChange?.(next),
60
+ });
55
61
  const mobile = createIsMobile();
56
62
  const isMobile = () => mobile() === true;
57
63
 
58
- const open = () => (props.open !== undefined ? props.open === true : uncontrolledOpen());
59
- const setOpen = (next: boolean) => {
60
- if (props.open === undefined) setUncontrolledOpen(next);
61
- props.onOpenChange?.(next);
62
- };
63
-
64
64
  return (
65
65
  <ResponsiveDialogContext.Provider value={{ open, setOpen, isMobile }}>
66
66
  <Show
67
67
  when={isMobile()}
68
68
  fallback={
69
- <Dialog open={open()} onOpenChange={setOpen}>
69
+ <Dialog open={open()} onOpenChange={setOpen} keep={props.keep}>
70
70
  {props.children}
71
71
  </Dialog>
72
72
  }
@@ -72,12 +72,7 @@ export const SCHEMA_FORM_FORM_TYPES = [
72
72
 
73
73
  const warnedLegacyAreaKeys = new Set<string>();
74
74
 
75
- /**
76
- * @deprecated Removed in the next major. Before the SDK had `field.area()`,
77
- * an area picker was inferred from the property name alone, so a field had to
78
- * be called `areaId` to get one and any other name silently rendered a text
79
- * input. Declare `field.area()` instead — it works under any name.
80
- */
75
+ /** @deprecated `field.area()`; removed in 2.0.0. */
81
76
  function isLegacyAreaKey(key: string, prop: ExtendedJSONSchema): boolean {
82
77
  const lower = key.toLowerCase();
83
78
  if (prop.type !== "string" || (lower !== "areaid" && lower !== "area_id")) return false;
@@ -19,7 +19,7 @@ const ScrollArea: ParentComponent<ComponentProps<"div">> = (props) => {
19
19
  );
20
20
  };
21
21
 
22
- /** @deprecated `gh-scroll`'s native-styled bar is the bar; renders nothing. */
22
+ /** @deprecated Ignored; removed in 2.0.0. */
23
23
  const ScrollBar: Component<ComponentProps<"div"> & { orientation?: "vertical" | "horizontal" }> = (
24
24
  _props,
25
25
  ) => null;
@@ -256,7 +256,7 @@ const ICON_DIMENSIONS: Record<SectionIconSize, string> = {
256
256
  lg: "size-12 sm:size-14 [&>[data-slot=icon]]:text-[24px] sm:[&>[data-slot=icon]]:text-[28px]",
257
257
  };
258
258
 
259
- /** @deprecated pass a CSS color to `tone` instead. */
259
+ /** @deprecated Pass a CSS color to `tone`; removed in 2.0.0. */
260
260
  const LEGACY_TONES: Record<string, string | undefined> = {
261
261
  neutral: undefined,
262
262
  primary: "var(--primary)",
@@ -319,8 +319,7 @@ function SectionHeading(props: { children: JSX.Element; class?: string }) {
319
319
  );
320
320
  }
321
321
 
322
- /** @deprecated A bare heading has no owner: `SectionGroup` for a labelled group
323
- * inside a card, `FieldLegend` for a titled group of form rows. */
322
+ /** @deprecated `SectionGroup`, or `FieldLegend` for a titled group of form rows; removed in 2.0.0. */
324
323
  export function SectionSubtitle(props: { children: JSX.Element; class?: string }) {
325
324
  return <SectionHeading class={props.class}>{props.children}</SectionHeading>;
326
325
  }
@@ -357,7 +356,7 @@ export function SectionGroup(props: {
357
356
  );
358
357
  }
359
358
 
360
- /** @deprecated SectionMeta, or FieldLegend for a titled group of rows. */
359
+ /** @deprecated `SectionMeta`, or `FieldLegend` for a titled group of rows; removed in 2.0.0. */
361
360
  export function SectionLabel(props: { children: JSX.Element; class?: string }) {
362
361
  return <SectionMeta class={cn("font-medium", props.class)}>{props.children}</SectionMeta>;
363
362
  }