@glasshome/ui 1.42.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.
- package/dist/index.js +2 -2
- package/dist/lib/anchor-placement.d.ts +4 -0
- package/dist/lib/balance-rows.d.ts +10 -4
- package/dist/lib/behavior/anchored.d.ts +16 -2
- package/dist/lib/behavior/button-root.d.ts +7 -0
- package/dist/lib/behavior/collection.d.ts +8 -0
- package/dist/lib/behavior/dismiss.d.ts +6 -4
- package/dist/lib/behavior/focus-scope.d.ts +7 -1
- package/dist/lib/behavior/hide-outside.d.ts +1 -1
- package/dist/lib/behavior/layer-stack.d.ts +3 -2
- package/dist/lib/behavior/menu.d.ts +59 -0
- package/dist/lib/behavior/modal-root.d.ts +2 -0
- package/dist/lib/behavior/range.d.ts +44 -0
- package/dist/lib/color/color.d.ts +41 -0
- package/dist/lib/color/index.d.ts +2 -0
- package/dist/lib/color/intl.d.ts +40 -0
- package/dist/lib/dock-slot-classes.d.ts +2 -0
- package/dist/lib/hold.d.ts +1 -1
- package/dist/lib/locale.d.ts +3 -0
- package/dist/lib/menu-classes.d.ts +2 -0
- package/dist/lib/motion-classes.d.ts +1 -1
- package/dist/lib/overlay-classes.d.ts +1 -0
- package/dist/lib/scroll-track.d.ts +3 -2
- package/dist/lib/section-tokens.d.ts +1 -1
- package/dist/lib/segment-classes.d.ts +2 -0
- package/dist/lib/shadow-layer.d.ts +0 -45
- package/dist/lib/toggle-set.d.ts +44 -0
- package/dist/lib/visually-hidden.d.ts +3 -0
- package/dist/solid/accordion.d.ts +35 -11
- package/dist/solid/avatar.d.ts +8 -4
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +1 -1
- package/dist/solid/button.d.ts +5 -4
- package/dist/solid/charts.d.ts +1 -1
- package/dist/solid/checkbox.d.ts +14 -4
- package/dist/solid/collapsible.d.ts +33 -5
- package/dist/solid/color-disc.d.ts +1 -1
- package/dist/solid/color-slider.d.ts +1 -1
- package/dist/solid/color-wheel.d.ts +1 -1
- package/dist/solid/context-menu.d.ts +58 -24
- package/dist/solid/dialog-parts.d.ts +8 -8
- package/dist/solid/dropdown-menu.d.ts +55 -24
- package/dist/solid/empty.d.ts +1 -1
- package/dist/solid/form.d.ts +5 -6
- package/dist/solid/hover-card.d.ts +65 -9
- package/dist/solid/index.d.ts +1 -1
- package/dist/solid/index.js +7725 -13458
- package/dist/solid/input-group.d.ts +6 -6
- package/dist/solid/item.d.ts +1 -1
- package/dist/solid/menu-parts.d.ts +175 -24
- package/dist/solid/option-card.d.ts +1 -4
- package/dist/solid/picker-row.d.ts +2 -0
- package/dist/solid/popover.d.ts +77 -12
- package/dist/solid/progress.d.ts +11 -3
- package/dist/solid/radio-group.d.ts +31 -6
- package/dist/solid/responsive-dialog.d.ts +1 -1
- package/dist/solid/scroll-area.d.ts +1 -1
- package/dist/solid/section-card.d.ts +2 -3
- package/dist/solid/select.d.ts +107 -10
- package/dist/solid/selection.d.ts +10 -1
- package/dist/solid/sheet.d.ts +1 -1
- package/dist/solid/sliding-indicator.d.ts +1 -1
- package/dist/solid/sonner.d.ts +1 -1
- package/dist/solid/toggle.d.ts +11 -3
- package/dist/solid/tooltip.d.ts +22 -22
- package/dist/tokens/index.js +54 -51
- package/dist/{utils-CxAii-e9.js → utils-3Codx-NZ.js} +527 -489
- package/package.json +3 -6
- package/src/lib/anchor-placement.ts +10 -3
- package/src/lib/balance-rows.ts +115 -40
- package/src/lib/behavior/anchored.ts +26 -8
- package/src/lib/behavior/button-root.tsx +103 -0
- package/src/lib/behavior/collection.ts +66 -29
- package/src/lib/behavior/dismiss.ts +61 -21
- package/src/lib/behavior/focus-scope.ts +31 -6
- package/src/lib/behavior/hide-outside.ts +2 -2
- package/src/lib/behavior/layer-stack.ts +33 -8
- package/src/lib/behavior/menu.ts +470 -0
- package/src/lib/behavior/modal-root.tsx +24 -18
- package/src/lib/behavior/polymorphic.tsx +1 -1
- package/src/lib/behavior/presence.ts +1 -1
- package/src/lib/behavior/range.ts +212 -0
- package/src/lib/clipboard.ts +2 -3
- package/src/lib/color/color.ts +746 -0
- package/src/lib/color/index.ts +2 -0
- package/src/lib/color/intl.ts +60 -0
- package/src/lib/dock-slot-classes.ts +3 -0
- package/src/lib/hold.ts +1 -1
- package/src/lib/locale.ts +62 -0
- package/src/lib/menu-classes.ts +3 -0
- package/src/lib/motion-classes.ts +7 -7
- package/src/lib/overlay-classes.ts +1 -3
- package/src/lib/scroll-track.ts +11 -6
- package/src/lib/section-tokens.ts +1 -1
- package/src/lib/segment-classes.ts +3 -0
- package/src/lib/shadow-layer.ts +0 -118
- package/src/lib/toggle-set.ts +133 -0
- package/src/lib/visually-hidden.ts +15 -0
- package/src/solid/accordion.tsx +294 -20
- package/src/solid/area-picker.tsx +3 -2
- package/src/solid/avatar.tsx +98 -24
- package/src/solid/bottom-sheet/bottom-sheet.tsx +1 -1
- package/src/solid/button.tsx +12 -6
- package/src/solid/charts.tsx +1 -1
- package/src/solid/checkbox.tsx +167 -44
- package/src/solid/collapsible.tsx +260 -12
- package/src/solid/color-disc.tsx +11 -12
- package/src/solid/color-slider.tsx +114 -47
- package/src/solid/color-wheel.tsx +137 -39
- package/src/solid/context-menu.tsx +285 -94
- package/src/solid/dialog-parts.tsx +9 -9
- package/src/solid/dock.tsx +3 -2
- package/src/solid/dropdown-menu.tsx +252 -115
- package/src/solid/empty.tsx +1 -1
- package/src/solid/entity-selector.tsx +3 -2
- package/src/solid/face-toggle.tsx +43 -18
- package/src/solid/form.tsx +5 -6
- package/src/solid/glyph-tile.tsx +48 -21
- package/src/solid/hover-card.tsx +287 -25
- package/src/solid/image-picker.tsx +2 -2
- package/src/solid/index.ts +1 -3
- package/src/solid/input-group.tsx +2 -2
- package/src/solid/item.tsx +1 -1
- package/src/solid/menu-parts.tsx +619 -145
- package/src/solid/option-card.tsx +6 -10
- package/src/solid/picker-row.tsx +5 -1
- package/src/solid/popover.tsx +424 -79
- package/src/solid/preview-tile.tsx +1 -1
- package/src/solid/progress.tsx +84 -15
- package/src/solid/radio-group.tsx +271 -34
- package/src/solid/responsive-dialog.tsx +1 -1
- package/src/solid/schema-form.tsx +1 -6
- package/src/solid/scroll-area.tsx +1 -1
- package/src/solid/section-card.tsx +3 -4
- package/src/solid/select.tsx +950 -95
- package/src/solid/selection.tsx +142 -66
- package/src/solid/sheet.tsx +1 -1
- package/src/solid/slider.tsx +115 -65
- package/src/solid/sliding-indicator.tsx +1 -1
- package/src/solid/sonner.tsx +1 -1
- package/src/solid/tabs.tsx +12 -6
- package/src/solid/term.tsx +3 -4
- package/src/solid/toggle-group.tsx +29 -99
- package/src/solid/toggle.tsx +43 -9
- package/src/solid/tooltip.tsx +24 -24
- package/src/styles/globals.css +61 -7
- package/src/styles/theme.css +7 -4
- package/src/tokens/material.ts +11 -2
package/src/solid/accordion.tsx
CHANGED
|
@@ -1,14 +1,292 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
-
|
|
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<
|
|
286
|
+
const AccordionItem: Component<AccordionItemProps> = (props) => {
|
|
9
287
|
const [local, rest] = splitProps(props, ["class"]);
|
|
10
288
|
return (
|
|
11
|
-
<
|
|
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<
|
|
20
|
-
props,
|
|
21
|
-
) => {
|
|
297
|
+
const AccordionTrigger: ParentComponent<AccordionTriggerProps> = (props) => {
|
|
22
298
|
const [local, rest] = splitProps(props, ["class", "children"]);
|
|
23
299
|
return (
|
|
24
|
-
<
|
|
25
|
-
<
|
|
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-
|
|
314
|
+
class="text-muted-foreground pointer-events-none size-4 shrink-0 translate-y-0.5 transition-transform duration-(--duration-expand)"
|
|
39
315
|
/>
|
|
40
|
-
</
|
|
41
|
-
</
|
|
316
|
+
</AccordionTriggerRoot>
|
|
317
|
+
</AccordionHeader>
|
|
42
318
|
);
|
|
43
319
|
};
|
|
44
320
|
|
|
45
|
-
const AccordionContent: ParentComponent<
|
|
46
|
-
props,
|
|
47
|
-
) => {
|
|
321
|
+
const AccordionContent: ParentComponent<AccordionContentProps> = (props) => {
|
|
48
322
|
const [local, rest] = splitProps(props, ["class", "children"]);
|
|
49
323
|
return (
|
|
50
|
-
<
|
|
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
|
-
</
|
|
330
|
+
</AccordionContentRoot>
|
|
57
331
|
);
|
|
58
332
|
};
|
|
59
333
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMemo, createSignal, For, Show } from "solid-js";
|
|
2
2
|
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
3
|
-
import { MENU_ITEM } from "../lib/menu-classes.js";
|
|
3
|
+
import { MENU_ITEM, MENU_ITEM_RADIUS } from "../lib/menu-classes.js";
|
|
4
4
|
import { STAGGER } from "../lib/motion-classes.js";
|
|
5
5
|
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
6
6
|
import { cn } from "../lib/utils.js";
|
|
@@ -192,6 +192,7 @@ export function AreaPicker(props: AreaPickerProps) {
|
|
|
192
192
|
/>
|
|
193
193
|
<SelectionScope
|
|
194
194
|
marker="highlighted"
|
|
195
|
+
radius={MENU_ITEM_RADIUS}
|
|
195
196
|
class={cn("flex flex-col gap-0.5 p-1", STAGGER, PICKER_LIST)}
|
|
196
197
|
onMouseLeave={() => setHovered(null)}
|
|
197
198
|
>
|
|
@@ -215,7 +216,7 @@ export function AreaPicker(props: AreaPickerProps) {
|
|
|
215
216
|
as="button"
|
|
216
217
|
type="button"
|
|
217
218
|
data-slot="area-picker-row"
|
|
218
|
-
|
|
219
|
+
highlighted={highlightedId() === area.id}
|
|
219
220
|
aria-pressed={multi() ? isSelected(area.id) : undefined}
|
|
220
221
|
icon={area.icon || "mdi:home-floor-1"}
|
|
221
222
|
title={area.name}
|
package/src/solid/avatar.tsx
CHANGED
|
@@ -1,40 +1,114 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
type Accessor,
|
|
3
|
+
type Component,
|
|
4
|
+
type ComponentProps,
|
|
5
|
+
createContext,
|
|
6
|
+
createSignal,
|
|
7
|
+
Show,
|
|
8
|
+
splitProps,
|
|
9
|
+
useContext,
|
|
10
|
+
} from "solid-js";
|
|
11
|
+
import { effect } from "../lib/behavior/solid.js";
|
|
3
12
|
import { cn } from "../lib/utils.js";
|
|
4
13
|
|
|
5
|
-
|
|
6
|
-
|
|
14
|
+
type LoadingStatus = "idle" | "loading" | "loaded" | "error";
|
|
15
|
+
|
|
16
|
+
type AvatarProps = ComponentProps<"span"> & {
|
|
17
|
+
fallbackDelay?: number;
|
|
18
|
+
onLoadingStatusChange?: (status: LoadingStatus) => void;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
interface AvatarContextValue {
|
|
22
|
+
fallbackDelay: Accessor<number | undefined>;
|
|
23
|
+
status: Accessor<LoadingStatus>;
|
|
24
|
+
report: (status: LoadingStatus) => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const AvatarContext = createContext<AvatarContextValue>();
|
|
28
|
+
|
|
29
|
+
function useAvatar(): AvatarContextValue {
|
|
30
|
+
const ctx = useContext(AvatarContext);
|
|
31
|
+
if (!ctx) throw new Error("An avatar part renders inside an Avatar");
|
|
32
|
+
return ctx;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const Avatar: Component<AvatarProps> = (props) => {
|
|
36
|
+
const [local, rest] = splitProps(props, ["class", "fallbackDelay", "onLoadingStatusChange"]);
|
|
37
|
+
const [status, setStatus] = createSignal<LoadingStatus>("idle");
|
|
38
|
+
const ctx: AvatarContextValue = {
|
|
39
|
+
fallbackDelay: () => local.fallbackDelay,
|
|
40
|
+
status,
|
|
41
|
+
report: (next) => {
|
|
42
|
+
setStatus(next);
|
|
43
|
+
local.onLoadingStatusChange?.(next);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
7
46
|
return (
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
47
|
+
<AvatarContext.Provider value={ctx}>
|
|
48
|
+
<span
|
|
49
|
+
data-slot="avatar"
|
|
50
|
+
class={cn("relative flex size-10 shrink-0 overflow-hidden rounded-full", local.class)}
|
|
51
|
+
{...rest}
|
|
52
|
+
/>
|
|
53
|
+
</AvatarContext.Provider>
|
|
13
54
|
);
|
|
14
55
|
};
|
|
15
56
|
|
|
16
|
-
const AvatarImage: Component<ComponentProps<
|
|
57
|
+
const AvatarImage: Component<ComponentProps<"img">> = (props) => {
|
|
58
|
+
const ctx = useAvatar();
|
|
17
59
|
const [local, rest] = splitProps(props, ["class"]);
|
|
60
|
+
const [status, setStatus] = createSignal<LoadingStatus>("idle");
|
|
61
|
+
|
|
62
|
+
// A detached probe, so the photo replaces the fallback only once it has decoded.
|
|
63
|
+
effect(
|
|
64
|
+
() => props.src,
|
|
65
|
+
(src) => {
|
|
66
|
+
if (!src) return void setStatus("error");
|
|
67
|
+
let live = true;
|
|
68
|
+
const probe = document.createElement("img");
|
|
69
|
+
const settle = (next: LoadingStatus) => () => live && setStatus(next);
|
|
70
|
+
setStatus("loading");
|
|
71
|
+
if (props.crossOrigin !== undefined) probe.crossOrigin = props.crossOrigin;
|
|
72
|
+
if (props.referrerPolicy !== undefined) probe.referrerPolicy = props.referrerPolicy;
|
|
73
|
+
probe.onload = settle("loaded");
|
|
74
|
+
probe.onerror = settle("error");
|
|
75
|
+
probe.src = src;
|
|
76
|
+
return () => {
|
|
77
|
+
live = false;
|
|
78
|
+
};
|
|
79
|
+
},
|
|
80
|
+
);
|
|
81
|
+
effect(status, (next) => {
|
|
82
|
+
if (next !== "idle") ctx.report(next);
|
|
83
|
+
});
|
|
84
|
+
|
|
18
85
|
return (
|
|
19
|
-
<
|
|
20
|
-
data-slot="avatar-image"
|
|
21
|
-
|
|
22
|
-
{...rest}
|
|
23
|
-
/>
|
|
86
|
+
<Show when={status() === "loaded"}>
|
|
87
|
+
<img data-slot="avatar-image" class={cn("aspect-square size-full", local.class)} {...rest} />
|
|
88
|
+
</Show>
|
|
24
89
|
);
|
|
25
90
|
};
|
|
26
91
|
|
|
27
|
-
const AvatarFallback: Component<ComponentProps<
|
|
92
|
+
const AvatarFallback: Component<ComponentProps<"span">> = (props) => {
|
|
93
|
+
const ctx = useAvatar();
|
|
28
94
|
const [local, rest] = splitProps(props, ["class"]);
|
|
95
|
+
const [due, setDue] = createSignal(ctx.fallbackDelay() === undefined);
|
|
96
|
+
effect(ctx.fallbackDelay, (delay) => {
|
|
97
|
+
if (delay === undefined) return;
|
|
98
|
+
const timer = setTimeout(() => setDue(true), delay);
|
|
99
|
+
return () => clearTimeout(timer);
|
|
100
|
+
});
|
|
29
101
|
return (
|
|
30
|
-
<
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
102
|
+
<Show when={due() && ctx.status() !== "loaded"}>
|
|
103
|
+
<span
|
|
104
|
+
data-slot="avatar-fallback"
|
|
105
|
+
class={cn(
|
|
106
|
+
"glass flex size-full items-center justify-center rounded-full font-semibold [--glass-tone:var(--primary)]",
|
|
107
|
+
local.class,
|
|
108
|
+
)}
|
|
109
|
+
{...rest}
|
|
110
|
+
/>
|
|
111
|
+
</Show>
|
|
38
112
|
);
|
|
39
113
|
};
|
|
40
114
|
|
|
@@ -409,7 +409,7 @@ const BottomSheetClose: ParentComponent<SheetButtonProps> = (props) => {
|
|
|
409
409
|
);
|
|
410
410
|
};
|
|
411
411
|
|
|
412
|
-
/** @deprecated
|
|
412
|
+
/** @deprecated The shared modal parts; removed in 2.0.0. */
|
|
413
413
|
export {
|
|
414
414
|
BottomSheet,
|
|
415
415
|
BottomSheetBody,
|
package/src/solid/button.tsx
CHANGED
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { Button as KobalteButton } from "@kobalte/core/button";
|
|
2
1
|
import type { VariantProps } from "cva";
|
|
3
|
-
import { type
|
|
2
|
+
import { type JSX, splitProps, type ValidComponent } from "solid-js";
|
|
3
|
+
import { ButtonRoot, type ButtonRootProps } from "../lib/behavior/button-root.js";
|
|
4
4
|
import { busyProps } from "../lib/busy.js";
|
|
5
5
|
import { buttonVariants } from "../lib/button-variants.js";
|
|
6
6
|
import { cn } from "../lib/utils.js";
|
|
7
7
|
import { Icon } from "./icon.js";
|
|
8
8
|
|
|
9
|
-
type ButtonProps =
|
|
9
|
+
type ButtonProps<T extends ValidComponent = "button"> = ButtonRootProps<T> &
|
|
10
10
|
VariantProps<typeof buttonVariants> & {
|
|
11
11
|
/** Presses do nothing; unlike `disabled` it keeps focus, so the popover or dialog around it stays. */
|
|
12
12
|
busy?: boolean;
|
|
13
|
+
class?: string;
|
|
13
14
|
};
|
|
14
15
|
|
|
15
|
-
function Button(props: ButtonProps) {
|
|
16
|
-
const [local, others] = splitProps(props
|
|
16
|
+
function Button<T extends ValidComponent = "button">(props: ButtonProps<T>) {
|
|
17
|
+
const [local, others] = splitProps(props as ButtonProps<ValidComponent>, [
|
|
18
|
+
"class",
|
|
19
|
+
"variant",
|
|
20
|
+
"size",
|
|
21
|
+
"busy",
|
|
22
|
+
]);
|
|
17
23
|
return (
|
|
18
|
-
<
|
|
24
|
+
<ButtonRoot
|
|
19
25
|
data-slot="button"
|
|
20
26
|
{...others}
|
|
21
27
|
class={cn(buttonVariants({ variant: local.variant, size: local.size }), local.class)}
|
package/src/solid/charts.tsx
CHANGED