@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,14 +1,292 @@
1
- import { Accordion as AccordionPrimitive } from "@kobalte/core/accordion";
2
- import { type Component, type ComponentProps, type ParentComponent, splitProps } from "solid-js";
1
+ import {
2
+ type Accessor,
3
+ type Component,
4
+ type ComponentProps,
5
+ createContext,
6
+ createSignal,
7
+ createUniqueId,
8
+ type JSX,
9
+ type ParentComponent,
10
+ splitProps,
11
+ useContext,
12
+ type ValidComponent,
13
+ } from "solid-js";
14
+ import { type Collection, createCollection } from "../lib/behavior/collection.js";
15
+ import { createControllableSignal } from "../lib/behavior/controllable.js";
16
+ import { focusWithoutTracking, trackFocus } from "../lib/behavior/focus-scope.js";
17
+ import { Polymorphic } from "../lib/behavior/polymorphic.js";
18
+ import { callEventHandler, effect, merge } from "../lib/behavior/solid.js";
3
19
  import { cn } from "../lib/utils.js";
20
+ import {
21
+ CollapsibleContentRoot,
22
+ CollapsibleRoot,
23
+ CollapsibleTriggerRoot,
24
+ useCollapsible,
25
+ } from "./collapsible.js";
4
26
  import { Icon } from "./icon.js";
5
27
 
6
- const Accordion = AccordionPrimitive;
28
+ type AccordionProps = Omit<ComponentProps<"div">, "onChange"> & {
29
+ as?: ValidComponent;
30
+ value?: string[];
31
+ defaultValue?: string[];
32
+ onChange?: (value: string[]) => void;
33
+ multiple?: boolean;
34
+ collapsible?: boolean;
35
+ shouldFocusWrap?: boolean;
36
+ };
37
+
38
+ type AccordionItemProps = Omit<ComponentProps<"div">, "onChange"> & {
39
+ as?: ValidComponent;
40
+ value: string;
41
+ disabled?: boolean;
42
+ forceMount?: boolean;
43
+ };
44
+
45
+ type AccordionHeaderProps = ComponentProps<"h3"> & { as?: ValidComponent };
46
+ type AccordionTriggerProps = ComponentProps<"button"> & { as?: ValidComponent };
47
+ type AccordionContentProps = ComponentProps<"div"> & { as?: ValidComponent };
48
+
49
+ interface AccordionContextValue {
50
+ rootId: Accessor<string>;
51
+ isOpen: (value: string) => boolean;
52
+ toggle: (value: string) => void;
53
+ collection: Collection;
54
+ }
55
+
56
+ interface AccordionItemContextValue {
57
+ value: Accessor<string>;
58
+ itemId: Accessor<string>;
59
+ triggerId: Accessor<string | undefined>;
60
+ setTriggerId: (id: string | undefined) => void;
61
+ }
62
+
63
+ const AccordionContext = createContext<AccordionContextValue>();
64
+ const AccordionItemContext = createContext<AccordionItemContextValue>();
65
+
66
+ function useAccordion(): AccordionContextValue {
67
+ const ctx = useContext(AccordionContext);
68
+ if (!ctx) throw new Error("An accordion part renders inside an Accordion");
69
+ return ctx;
70
+ }
71
+
72
+ function useAccordionItem(): AccordionItemContextValue {
73
+ const ctx = useContext(AccordionItemContext);
74
+ if (!ctx) throw new Error("An accordion part renders inside an AccordionItem");
75
+ return ctx;
76
+ }
77
+
78
+ const NAVIGATION_KEYS = new Set(["ArrowDown", "ArrowUp", "Home", "End"]);
79
+
80
+ const AccordionRoot: Component<AccordionProps> = (props) => {
81
+ const fallbackId = `accordion-${createUniqueId()}`;
82
+ const [local, others] = splitProps(props, [
83
+ "as",
84
+ "ref",
85
+ "value",
86
+ "defaultValue",
87
+ "onChange",
88
+ "multiple",
89
+ "collapsible",
90
+ "shouldFocusWrap",
91
+ ]);
92
+ const [value, setValue] = createControllableSignal<string[]>({
93
+ value: () => local.value,
94
+ defaultValue: () => local.defaultValue ?? [],
95
+ onChange: (next) => local.onChange?.(next),
96
+ });
97
+ const mayEmpty = () => !!local.multiple || !!local.collapsible;
98
+ const [el, setEl] = createSignal<HTMLElement>();
99
+ const collection = createCollection({
100
+ root: el,
101
+ itemSelector: "[data-key]",
102
+ orientation: () => "vertical",
103
+ focus: "roving",
104
+ loop: () => local.shouldFocusWrap ?? true,
105
+ });
106
+
107
+ const toggle = (item: string) => {
108
+ const current = value();
109
+ if (current.includes(item)) {
110
+ if (local.multiple) setValue(current.filter((v) => v !== item));
111
+ else if (local.collapsible) setValue([]);
112
+ } else setValue(local.multiple ? [...current, item] : [item]);
113
+ };
114
+
115
+ effect(el, (node) => {
116
+ if (!node) return;
117
+ const keydown = (event: KeyboardEvent) => {
118
+ const onTrigger = event.target instanceof HTMLElement && event.target.matches("[data-key]");
119
+ if (onTrigger && NAVIGATION_KEYS.has(event.key)) return collection.onKeyDown(event);
120
+ if (event.key !== "Escape" || event.defaultPrevented || !mayEmpty()) return;
121
+ if (value().length === 0) return;
122
+ event.preventDefault();
123
+ setValue([]);
124
+ };
125
+ node.addEventListener("keydown", keydown);
126
+ return () => node.removeEventListener("keydown", keydown);
127
+ });
128
+
129
+ const ctx: AccordionContextValue = {
130
+ rootId: () => others.id ?? fallbackId,
131
+ isOpen: (item) => value().includes(item),
132
+ toggle,
133
+ collection,
134
+ };
135
+
136
+ return (
137
+ <AccordionContext.Provider value={ctx}>
138
+ <Polymorphic
139
+ {...merge({ id: fallbackId }, others, {
140
+ as: local.as,
141
+ defaultAs: "div" as ValidComponent,
142
+ ref: (node: HTMLElement) => {
143
+ setEl(node);
144
+ if (typeof local.ref === "function") local.ref(node as HTMLDivElement);
145
+ },
146
+ })}
147
+ />
148
+ </AccordionContext.Provider>
149
+ );
150
+ };
151
+
152
+ const AccordionItemRoot: Component<AccordionItemProps> = (props) => {
153
+ const accordion = useAccordion();
154
+ const fallbackId = `${accordion.rootId()}-item-${createUniqueId()}`;
155
+ const [local, others] = splitProps(props, ["value", "disabled"]);
156
+ const [triggerId, setTriggerId] = createSignal<string>();
157
+ const itemId = () => others.id ?? fallbackId;
158
+
159
+ return (
160
+ <AccordionItemContext.Provider
161
+ value={{ value: () => local.value, itemId, triggerId, setTriggerId }}
162
+ >
163
+ <CollapsibleRoot
164
+ {...merge({ id: fallbackId }, others, {
165
+ get open() {
166
+ return accordion.isOpen(local.value);
167
+ },
168
+ onOpenChange: () => accordion.toggle(local.value),
169
+ get disabled() {
170
+ return local.disabled;
171
+ },
172
+ })}
173
+ />
174
+ </AccordionItemContext.Provider>
175
+ );
176
+ };
177
+
178
+ const AccordionHeader: Component<AccordionHeaderProps> = (props) => {
179
+ const collapsible = useCollapsible();
180
+ const [local, others] = splitProps(props, ["as"]);
181
+ return (
182
+ <Polymorphic
183
+ {...merge(collapsible.markers, others, { as: local.as, defaultAs: "h3" as ValidComponent })}
184
+ />
185
+ );
186
+ };
187
+
188
+ const AccordionTriggerRoot: Component<AccordionTriggerProps> = (props) => {
189
+ const accordion = useAccordion();
190
+ const item = useAccordionItem();
191
+ const collapsible = useCollapsible();
192
+ const [local, others] = splitProps(props, ["ref", "onClick"]);
193
+ const [el, setEl] = createSignal<HTMLElement>();
194
+ const id = () => others.id ?? `${item.itemId()}-trigger`;
195
+ effect(id, (value) => {
196
+ item.setTriggerId(value);
197
+ return () => item.setTriggerId(undefined);
198
+ });
199
+
200
+ let focused: ReturnType<typeof trackFocus> | undefined;
201
+ effect(el, (node) => {
202
+ if (!node) return;
203
+ const tracked = trackFocus(node);
204
+ focused = tracked;
205
+ const focus = () => accordion.collection.highlight(item.value(), "pointer");
206
+ node.addEventListener("focus", focus);
207
+ return () => {
208
+ tracked.stop();
209
+ node.removeEventListener("focus", focus);
210
+ };
211
+ });
212
+
213
+ const click: JSX.EventHandler<HTMLButtonElement, MouseEvent> = (event) => {
214
+ callEventHandler(event, local.onClick);
215
+ // WebKit leaves a clicked button unfocused, and the arrows move from the focused trigger.
216
+ const node = el();
217
+ if (node && !collapsible.disabled() && !focused?.has()) focusWithoutTracking(node);
218
+ };
219
+
220
+ return (
221
+ <CollapsibleTriggerRoot
222
+ {...merge(
223
+ {
224
+ get "data-key"() {
225
+ return item.value();
226
+ },
227
+ },
228
+ others,
229
+ {
230
+ get id() {
231
+ return id();
232
+ },
233
+ onClick: click,
234
+ ref: (node: HTMLButtonElement) => {
235
+ setEl(node);
236
+ if (typeof local.ref === "function") local.ref(node);
237
+ },
238
+ },
239
+ )}
240
+ />
241
+ );
242
+ };
243
+
244
+ const CONTENT_VARS = {
245
+ "--accordion-content-height": "var(--collapsible-content-height)",
246
+ "--accordion-content-width": "var(--collapsible-content-width)",
247
+ "--kb-accordion-content-height": "var(--kb-collapsible-content-height)",
248
+ "--kb-accordion-content-width": "var(--kb-collapsible-content-width)",
249
+ };
250
+
251
+ const CONTENT_VARS_CSS = Object.entries(CONTENT_VARS)
252
+ .map(([name, value]) => `${name}:${value};`)
253
+ .join("");
254
+
255
+ const AccordionContentRoot: Component<AccordionContentProps> = (props) => {
256
+ const item = useAccordionItem();
257
+ const [local, others] = splitProps(props, ["style"]);
258
+ return (
259
+ <CollapsibleContentRoot
260
+ {...merge(
261
+ {
262
+ role: "region" as const,
263
+ get "aria-labelledby"() {
264
+ return item.triggerId();
265
+ },
266
+ get style() {
267
+ return typeof local.style === "string"
268
+ ? `${CONTENT_VARS_CSS}${local.style}`
269
+ : { ...CONTENT_VARS, ...local.style };
270
+ },
271
+ },
272
+ others,
273
+ )}
274
+ />
275
+ );
276
+ };
277
+
278
+ const Accordion = Object.assign(AccordionRoot, {
279
+ Root: AccordionRoot,
280
+ Item: AccordionItemRoot,
281
+ Header: AccordionHeader,
282
+ Trigger: AccordionTriggerRoot,
283
+ Content: AccordionContentRoot,
284
+ });
7
285
 
8
- const AccordionItem: Component<ComponentProps<typeof AccordionPrimitive.Item>> = (props) => {
286
+ const AccordionItem: Component<AccordionItemProps> = (props) => {
9
287
  const [local, rest] = splitProps(props, ["class"]);
10
288
  return (
11
- <AccordionPrimitive.Item
289
+ <AccordionItemRoot
12
290
  data-slot="accordion-item"
13
291
  class={cn("border-b last:border-b-0", local.class)}
14
292
  {...rest}
@@ -16,16 +294,14 @@ const AccordionItem: Component<ComponentProps<typeof AccordionPrimitive.Item>> =
16
294
  );
17
295
  };
18
296
 
19
- const AccordionTrigger: ParentComponent<ComponentProps<typeof AccordionPrimitive.Trigger>> = (
20
- props,
21
- ) => {
297
+ const AccordionTrigger: ParentComponent<AccordionTriggerProps> = (props) => {
22
298
  const [local, rest] = splitProps(props, ["class", "children"]);
23
299
  return (
24
- <AccordionPrimitive.Header class="flex">
25
- <AccordionPrimitive.Trigger
300
+ <AccordionHeader class="flex">
301
+ <AccordionTriggerRoot
26
302
  data-slot="accordion-trigger"
27
303
  class={cn(
28
- "focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-expanded]>[data-slot=icon]]:rotate-180",
304
+ "focus-visible:border-ring focus-visible:ring-ring/50 flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left text-sm font-medium transition-all duration-(--duration-state) outline-none hover:underline focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50 [&[data-expanded]>[data-slot=icon]]:rotate-180",
29
305
  local.class,
30
306
  )}
31
307
  {...rest}
@@ -35,25 +311,23 @@ const AccordionTrigger: ParentComponent<ComponentProps<typeof AccordionPrimitive
35
311
  icon="lucide:chevron-down"
36
312
  width={16}
37
313
  height={16}
38
- class="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-200"
314
+ class="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-(--duration-expand)"
39
315
  />
40
- </AccordionPrimitive.Trigger>
41
- </AccordionPrimitive.Header>
316
+ </AccordionTriggerRoot>
317
+ </AccordionHeader>
42
318
  );
43
319
  };
44
320
 
45
- const AccordionContent: ParentComponent<ComponentProps<typeof AccordionPrimitive.Content>> = (
46
- props,
47
- ) => {
321
+ const AccordionContent: ParentComponent<AccordionContentProps> = (props) => {
48
322
  const [local, rest] = splitProps(props, ["class", "children"]);
49
323
  return (
50
- <AccordionPrimitive.Content
324
+ <AccordionContentRoot
51
325
  data-slot="accordion-content"
52
- class="data-[closed]:animate-accordion-up data-[expanded]:animate-accordion-down overflow-hidden text-sm"
326
+ class="data-[closed]:animate-accordion-up data-[expanded]:animate-accordion-down overflow-hidden text-sm duration-(--duration-expand)"
53
327
  {...rest}
54
328
  >
55
329
  <div class={cn("pt-0 pb-4", local.class)}>{local.children}</div>
56
- </AccordionPrimitive.Content>
330
+ </AccordionContentRoot>
57
331
  );
58
332
  };
59
333
 
@@ -1,57 +1,42 @@
1
- import { AlertDialog as AlertDialogPrimitive } from "@kobalte/core/alert-dialog";
2
1
  import { usePortalMount } from "./portal-mount.js";
3
- import { useDialogContext } from "@kobalte/core/dialog";
4
2
  import type { VariantProps } from "cva";
5
3
  import {
6
4
  type Component,
7
5
  type ComponentProps,
8
- createSignal,
9
6
  type JSX,
10
7
  type ParentComponent,
11
8
  splitProps,
12
9
  } from "solid-js";
13
- import { inShadowRoot, shadowLayer } from "../lib/shadow-layer.js";
10
+ import { ModalFrame, useDialogContext } from "../lib/behavior/modal-root.js";
11
+ import { MOTION_EXIT_MS } from "../lib/motion-classes.js";
14
12
  import { buttonVariants } from "../lib/button-variants.js";
15
13
  import { cn } from "../lib/utils.js";
16
14
  import {
17
15
  createModalDismiss,
18
16
  createModalHead,
19
17
  createModalParts,
18
+ createModalRootSkin,
19
+ createModalTextParts,
20
20
  type ModalHeadProps,
21
21
  MODAL_ANCHOR,
22
- MODAL_DESCRIPTION,
23
22
  MODAL_PANEL,
24
23
  MODAL_SCRIM,
25
- MODAL_TITLE,
26
24
  MODAL_WIDTH,
25
+ type ModalContentProps,
27
26
  type ModalDismissProps,
28
- ModalScrollLock,
27
+ ModalCover,
29
28
  type ModalSize,
30
29
  } from "./dialog-parts.js";
31
30
 
32
- const AlertDialog: ParentComponent<ComponentProps<typeof AlertDialogPrimitive>> = (props) => {
33
- const mount = usePortalMount();
34
- return <AlertDialogPrimitive modal={!inShadowRoot(mount)} {...props} preventScroll={false} />;
35
- };
36
-
37
- const AlertDialogTrigger: Component<ComponentProps<typeof AlertDialogPrimitive.Trigger>> = (
38
- props,
39
- ) => <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
31
+ const AlertDialog = createModalRootSkin("alertdialog");
40
32
 
41
- const AlertDialogOverlay: Component<ComponentProps<typeof AlertDialogPrimitive.Overlay>> = (
42
- props,
43
- ) => {
44
- const [local, rest] = splitProps(props, ["class"]);
45
- return (
46
- <AlertDialogPrimitive.Overlay
47
- data-slot="alert-dialog-overlay"
48
- class={cn(MODAL_SCRIM, local.class)}
49
- {...rest}
50
- />
51
- );
52
- };
33
+ const {
34
+ Trigger: AlertDialogTrigger,
35
+ Title: AlertDialogTitle,
36
+ Description: AlertDialogDescription,
37
+ } = createModalTextParts("alert-dialog");
53
38
 
54
- type AlertDialogContentProps = ComponentProps<typeof AlertDialogPrimitive.Content> & {
39
+ type AlertDialogContentProps = ModalContentProps & {
55
40
  size?: ModalSize;
56
41
  /** Names a panel that has no `AlertDialogTitle`. A registered Title wins. */
57
42
  ariaLabel?: string;
@@ -63,46 +48,36 @@ const AlertDialogContent: ParentComponent<AlertDialogContentProps> = (props) =>
63
48
  "children",
64
49
  "size",
65
50
  "ariaLabel",
51
+ "style",
66
52
  "ref",
67
- "onInteractOutside",
68
- "onCloseAutoFocus",
69
- "onOpenAutoFocus",
53
+ "onFocusOutside",
54
+ "forceMount",
70
55
  ]);
71
- const context = useDialogContext();
72
- const [panel, setPanel] = createSignal<HTMLElement>();
73
- const layer = shadowLayer({
74
- content: panel,
75
- open: () => context.isOpen(),
76
- dismiss: () => context.close(),
77
- trapsFocus: true,
78
- consumer: local,
79
- });
56
+ const ctx = useDialogContext();
80
57
  return (
81
- <AlertDialogPrimitive.Portal mount={usePortalMount()}>
82
- <ModalScrollLock />
83
- <AlertDialogOverlay />
84
- <AlertDialogPrimitive.Content
85
- ref={(el: HTMLElement) => {
86
- setPanel(el);
87
- if (typeof local.ref === "function") local.ref(el);
88
- }}
89
- onInteractOutside={layer.onInteractOutside}
90
- onCloseAutoFocus={layer.onCloseAutoFocus}
91
- onOpenAutoFocus={layer.onOpenAutoFocus}
92
- data-slot="alert-dialog-content"
93
- role="alertdialog"
94
- aria-label={context.titleId() ? undefined : local.ariaLabel}
95
- class={cn(
58
+ <>
59
+ <ModalCover panel={ctx.panel} open={ctx.isOpen} dormant={ctx.dormant} />
60
+ <ModalFrame
61
+ slot="alert-dialog"
62
+ mount={usePortalMount()}
63
+ exitMs={MOTION_EXIT_MS.modal}
64
+ scrimClass={MODAL_SCRIM}
65
+ panelClass={cn(
96
66
  MODAL_PANEL,
97
67
  MODAL_WIDTH[local.size ?? "md"],
98
68
  MODAL_ANCHOR[local.size ?? "md"],
99
69
  local.class,
100
70
  )}
71
+ panelStyle={typeof local.style === "object" ? local.style : undefined}
72
+ ariaLabel={local.ariaLabel}
73
+ ref={(el: HTMLElement) => {
74
+ if (typeof local.ref === "function") local.ref(el as HTMLDivElement);
75
+ }}
101
76
  {...rest}
102
77
  >
103
78
  {local.children}
104
- </AlertDialogPrimitive.Content>
105
- </AlertDialogPrimitive.Portal>
79
+ </ModalFrame>
80
+ </>
106
81
  );
107
82
  };
108
83
 
@@ -112,44 +87,20 @@ const {
112
87
  Footer: AlertDialogFooter,
113
88
  } = createModalParts("alert-dialog");
114
89
 
115
- const AlertDialogTitle: Component<ComponentProps<typeof AlertDialogPrimitive.Title>> = (props) => {
116
- const [local, rest] = splitProps(props, ["class"]);
117
- return (
118
- <AlertDialogPrimitive.Title
119
- data-slot="alert-dialog-title"
120
- class={cn(MODAL_TITLE, local.class)}
121
- {...rest}
122
- />
123
- );
124
- };
125
-
126
- const AlertDialogDescription: Component<ComponentProps<typeof AlertDialogPrimitive.Description>> = (
127
- props,
128
- ) => {
129
- const [local, rest] = splitProps(props, ["class"]);
130
- return (
131
- <AlertDialogPrimitive.Description
132
- data-slot="alert-dialog-description"
133
- class={cn(MODAL_DESCRIPTION, local.class)}
134
- {...rest}
135
- />
136
- );
137
- };
138
-
139
90
  /** An alert dialog is read aloud as a description, and the line carries the consequence. */
140
91
  type AlertDialogHeadProps = ModalHeadProps & { line: JSX.Element };
141
92
 
142
93
  const AlertDialogHead = createModalHead<AlertDialogHeadProps>(
143
94
  AlertDialogHeader,
144
- AlertDialogTitle,
145
- AlertDialogDescription,
95
+ AlertDialogTitle as Component<ComponentProps<"h2">>,
96
+ AlertDialogDescription as Component<ComponentProps<"p">>,
146
97
  );
147
98
 
148
99
  type AlertDialogButtonProps = ModalDismissProps &
149
100
  Partial<Pick<VariantProps<typeof buttonVariants>, "variant" | "size">>;
150
101
 
151
- const ActionDismiss = createModalDismiss("alert-dialog-action");
152
- const CancelDismiss = createModalDismiss("alert-dialog-cancel");
102
+ const ActionDismiss = createModalDismiss("alert-dialog-action", useDialogContext);
103
+ const CancelDismiss = createModalDismiss("alert-dialog-cancel", useDialogContext);
153
104
 
154
105
  /** Confirming action. Pass `variant` (e.g. "destructive"); layering a second
155
106
  * buttonVariants() call through `class` cannot work, because the variants
@@ -1,5 +1,6 @@
1
1
  import { createMemo, createSignal, For, Show } from "solid-js";
2
- import { MENU_ITEM } from "../lib/menu-classes.js";
2
+ import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
3
+ import { MENU_ITEM, MENU_ITEM_RADIUS } from "../lib/menu-classes.js";
3
4
  import { STAGGER } from "../lib/motion-classes.js";
4
5
  import { PICKER_LIST } from "../lib/picker-classes.js";
5
6
  import { cn } from "../lib/utils.js";
@@ -175,7 +176,7 @@ export function AreaPicker(props: AreaPickerProps) {
175
176
  onOpenAutoFocus={(e) => {
176
177
  e.preventDefault();
177
178
  // preventScroll: the panel is portalled at (0,0) until the popper places it.
178
- searchRef?.focus({ preventScroll: true });
179
+ focusWithoutTracking(searchRef);
179
180
  }}
180
181
  onInteractOutside={() => setOpen(false)}
181
182
  >
@@ -191,6 +192,7 @@ export function AreaPicker(props: AreaPickerProps) {
191
192
  />
192
193
  <SelectionScope
193
194
  marker="highlighted"
195
+ radius={MENU_ITEM_RADIUS}
194
196
  class={cn("flex flex-col gap-0.5 p-1", STAGGER, PICKER_LIST)}
195
197
  onMouseLeave={() => setHovered(null)}
196
198
  >
@@ -214,7 +216,7 @@ export function AreaPicker(props: AreaPickerProps) {
214
216
  as="button"
215
217
  type="button"
216
218
  data-slot="area-picker-row"
217
- data-highlighted={highlightedId() === area.id || undefined}
219
+ highlighted={highlightedId() === area.id}
218
220
  aria-pressed={multi() ? isSelected(area.id) : undefined}
219
221
  icon={area.icon || "mdi:home-floor-1"}
220
222
  title={area.name}