@glasshome/ui 1.20.0 → 1.21.1
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/solid/alert-dialog.d.ts +7 -1
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +7 -1
- package/dist/solid/dialog-parts.d.ts +3 -2
- package/dist/solid/dialog.d.ts +7 -1
- package/dist/solid/docked-panel.d.ts +7 -1
- package/dist/solid/index.js +170 -188
- package/dist/solid/media-store.d.ts +4 -1
- package/dist/solid/option-card.d.ts +4 -1
- package/dist/solid/responsive-dialog.d.ts +7 -1
- package/dist/solid/sheet.d.ts +7 -1
- package/dist/tokens/index.js +2 -1
- package/package.json +1 -1
- package/src/solid/dialog-parts.tsx +2 -2
- package/src/solid/dock.tsx +8 -7
- package/src/solid/media-store.ts +4 -1
- package/src/solid/option-card.tsx +4 -1
- package/src/solid/schema-form.tsx +13 -6
- package/src/solid/sliding-indicator.tsx +1 -1
- package/src/solid/toggle-group.tsx +5 -30
- package/src/tokens/presets.ts +1 -0
|
@@ -61,5 +61,8 @@ export declare function presetValue(key: string): string;
|
|
|
61
61
|
/** The built-in picture a stored image value names, or undefined for an upload. */
|
|
62
62
|
export declare function imagePreset(value: string | null | undefined): string | undefined;
|
|
63
63
|
export declare function mediaUrl(id: string | null | undefined): string | undefined;
|
|
64
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* Reads better than mediaUrl in an image widget's source.
|
|
66
|
+
* @alias
|
|
67
|
+
*/
|
|
65
68
|
export declare const imageUrl: typeof mediaUrl;
|
|
@@ -36,5 +36,8 @@ export declare function OptionCard(props: {
|
|
|
36
36
|
* reveal them while it is picked. */
|
|
37
37
|
children?: JSX.Element;
|
|
38
38
|
}): JSX.Element;
|
|
39
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated OptionCard carries the same props; HeroOption is an alias.
|
|
41
|
+
* @alias
|
|
42
|
+
*/
|
|
40
43
|
export declare const HeroOption: typeof OptionCard;
|
|
@@ -23,7 +23,13 @@ type ResponsiveDialogContentProps = ComponentProps<"div"> & {
|
|
|
23
23
|
anchor?: HTMLElement;
|
|
24
24
|
};
|
|
25
25
|
declare const ResponsiveDialogContent: ParentComponent<ResponsiveDialogContentProps>;
|
|
26
|
-
declare const ResponsiveDialogHeader: Component<
|
|
26
|
+
declare const ResponsiveDialogHeader: Component<JSX.HTMLAttributes<HTMLDivElement> & {
|
|
27
|
+
media?: JSX.Element;
|
|
28
|
+
action?: JSX.Element;
|
|
29
|
+
wrap?: boolean;
|
|
30
|
+
}>, ResponsiveDialogBody: Component<JSX.HTMLAttributes<HTMLDivElement> & {
|
|
31
|
+
as?: ValidComponent;
|
|
32
|
+
}>, ResponsiveDialogFooter: Component<JSX.HTMLAttributes<HTMLDivElement>>;
|
|
27
33
|
declare const ResponsiveDialogTitle: Component<ComponentProps<"h2">>;
|
|
28
34
|
declare const ResponsiveDialogDescription: Component<ComponentProps<"p">>;
|
|
29
35
|
/** Defaults to the footer's outline button; an icon-only close passes `ghost`
|
package/dist/solid/sheet.d.ts
CHANGED
|
@@ -24,7 +24,13 @@ type SheetContentProps = ComponentProps<typeof DialogPrimitive.Content> & {
|
|
|
24
24
|
ariaLabel?: string;
|
|
25
25
|
};
|
|
26
26
|
declare const SheetContent: ParentComponent<SheetContentProps>;
|
|
27
|
-
declare const SheetHeader: Component<
|
|
27
|
+
declare const SheetHeader: Component<JSX.HTMLAttributes<HTMLDivElement> & {
|
|
28
|
+
media?: JSX.Element;
|
|
29
|
+
action?: JSX.Element;
|
|
30
|
+
wrap?: boolean;
|
|
31
|
+
}>, SheetBody: Component<JSX.HTMLAttributes<HTMLDivElement> & {
|
|
32
|
+
as?: import("solid-js").ValidComponent;
|
|
33
|
+
}>, SheetFooter: Component<JSX.HTMLAttributes<HTMLDivElement>>;
|
|
28
34
|
declare const SheetTitle: Component<ComponentProps<typeof DialogPrimitive.Title>>;
|
|
29
35
|
declare const SheetDescription: Component<ComponentProps<typeof DialogPrimitive.Description>>;
|
|
30
36
|
export { Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, };
|
package/dist/tokens/index.js
CHANGED
package/package.json
CHANGED
|
@@ -93,7 +93,7 @@ const MODAL_FOOTER =
|
|
|
93
93
|
export const MODAL_TITLE = "font-semibold text-foreground text-lg leading-none tracking-tight";
|
|
94
94
|
export const MODAL_DESCRIPTION = "text-muted-foreground text-sm";
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
type ModalHeaderProps = ComponentProps<"div"> & {
|
|
97
97
|
/** Avatar or icon, rendered ahead of the title column. */
|
|
98
98
|
media?: JSX.Element;
|
|
99
99
|
action?: JSX.Element;
|
|
@@ -104,7 +104,7 @@ export type ModalHeaderProps = ComponentProps<"div"> & {
|
|
|
104
104
|
|
|
105
105
|
/** `as="form"` makes the scroll container the form, so a footer submit button
|
|
106
106
|
* reaches it through `form="<id>"` with no wrapper in between. */
|
|
107
|
-
|
|
107
|
+
type ModalBodyProps = ComponentProps<"div"> & { as?: ValidComponent };
|
|
108
108
|
|
|
109
109
|
export interface ModalParts {
|
|
110
110
|
Header: Component<ModalHeaderProps>;
|
package/src/solid/dock.tsx
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
createSignal,
|
|
7
7
|
Index,
|
|
8
8
|
type JSX,
|
|
9
|
+
on,
|
|
9
10
|
onCleanup,
|
|
10
11
|
onMount,
|
|
11
12
|
Show,
|
|
@@ -252,13 +253,13 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
252
253
|
});
|
|
253
254
|
});
|
|
254
255
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
256
|
+
// The box pads by mode, so switching it changes the room the strip has.
|
|
257
|
+
createEffect(
|
|
258
|
+
on([() => local.items.length, dockMode], () => {
|
|
259
|
+
const timeoutId = setTimeout(checkOverflow, 150);
|
|
260
|
+
onCleanup(() => clearTimeout(timeoutId));
|
|
261
|
+
}),
|
|
262
|
+
);
|
|
262
263
|
|
|
263
264
|
return (
|
|
264
265
|
<div
|
package/src/solid/media-store.ts
CHANGED
|
@@ -125,5 +125,8 @@ export function mediaUrl(id: string | null | undefined): string | undefined {
|
|
|
125
125
|
return useMediaStore()?.url(id);
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* Reads better than mediaUrl in an image widget's source.
|
|
130
|
+
* @alias
|
|
131
|
+
*/
|
|
129
132
|
export const imageUrl = mediaUrl;
|
|
@@ -210,5 +210,8 @@ function OptionIconWell(props: { icon?: string; image?: string }) {
|
|
|
210
210
|
);
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
/**
|
|
213
|
+
/**
|
|
214
|
+
* @deprecated OptionCard carries the same props; HeroOption is an alias.
|
|
215
|
+
* @alias
|
|
216
|
+
*/
|
|
214
217
|
export const HeroOption = OptionCard;
|
|
@@ -123,6 +123,12 @@ function recordOf(value: unknown): Record<string, unknown> {
|
|
|
123
123
|
return typeof value === "object" && value !== null ? (value as Record<string, unknown>) : {};
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
function textOf(value: unknown): string {
|
|
127
|
+
return typeof value === "string" || typeof value === "number" || typeof value === "boolean"
|
|
128
|
+
? String(value)
|
|
129
|
+
: "";
|
|
130
|
+
}
|
|
131
|
+
|
|
126
132
|
/** Property defaults declared on the wire (`default`), plus `const` seeds
|
|
127
133
|
* (a variant branch's discriminator literal serializes as `const`). */
|
|
128
134
|
function propertyDefaults(branch: ExtendedJSONSchema): Record<string, unknown> {
|
|
@@ -332,6 +338,7 @@ function LabeledField(props: FieldProps) {
|
|
|
332
338
|
/** The one recursive dispatch: every nesting level renders through here. */
|
|
333
339
|
function FieldControl(props: FieldProps) {
|
|
334
340
|
const current = () => props.value ?? props.prop.default;
|
|
341
|
+
const text = () => textOf(current());
|
|
335
342
|
const enumLabel = (value: string) => props.prop.labels?.[value] ?? value;
|
|
336
343
|
const kind = () => controlKind(props.prop, props.name);
|
|
337
344
|
return (
|
|
@@ -340,7 +347,7 @@ function FieldControl(props: FieldProps) {
|
|
|
340
347
|
<Input
|
|
341
348
|
id={props.id}
|
|
342
349
|
type="text"
|
|
343
|
-
value={
|
|
350
|
+
value={text()}
|
|
344
351
|
onInput={(e) => props.onChange(e.currentTarget.value)}
|
|
345
352
|
/>
|
|
346
353
|
}
|
|
@@ -369,7 +376,7 @@ function FieldControl(props: FieldProps) {
|
|
|
369
376
|
<Match when={kind() === "icon"}>
|
|
370
377
|
<IconPicker
|
|
371
378
|
aria-labelledby={props.labelledBy}
|
|
372
|
-
value={
|
|
379
|
+
value={text()}
|
|
373
380
|
onChange={(val) => props.onChange(val)}
|
|
374
381
|
searchIcons={props.searchIcons}
|
|
375
382
|
/>
|
|
@@ -378,14 +385,14 @@ function FieldControl(props: FieldProps) {
|
|
|
378
385
|
<ImagePicker
|
|
379
386
|
id={props.id}
|
|
380
387
|
presets={props.prop.presets}
|
|
381
|
-
value={
|
|
388
|
+
value={text()}
|
|
382
389
|
onChange={(val) => props.onChange(val)}
|
|
383
390
|
/>
|
|
384
391
|
</Match>
|
|
385
392
|
<Match when={kind() === "area"}>
|
|
386
393
|
<AreaPicker
|
|
387
394
|
aria-labelledby={props.labelledBy}
|
|
388
|
-
value={
|
|
395
|
+
value={text()}
|
|
389
396
|
onChange={(val) => props.onChange(val)}
|
|
390
397
|
/>
|
|
391
398
|
</Match>
|
|
@@ -393,7 +400,7 @@ function FieldControl(props: FieldProps) {
|
|
|
393
400
|
{(icons) => (
|
|
394
401
|
<OptionCardGroup
|
|
395
402
|
aria-labelledby={props.labelledBy}
|
|
396
|
-
value={
|
|
403
|
+
value={text()}
|
|
397
404
|
onChange={(val) => props.onChange(val)}
|
|
398
405
|
class="grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))]"
|
|
399
406
|
>
|
|
@@ -407,7 +414,7 @@ function FieldControl(props: FieldProps) {
|
|
|
407
414
|
</Match>
|
|
408
415
|
<Match when={kind() === "enum"}>
|
|
409
416
|
<Select
|
|
410
|
-
value={
|
|
417
|
+
value={text()}
|
|
411
418
|
onChange={(val) => {
|
|
412
419
|
if (val != null) props.onChange(val);
|
|
413
420
|
}}
|
|
@@ -257,7 +257,7 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
|
|
|
257
257
|
// (the same class of bug the item-level ResizeObserver above fixes for
|
|
258
258
|
// icons); one extra pass once fonts settle catches that too.
|
|
259
259
|
if (typeof document !== "undefined" && document.fonts) {
|
|
260
|
-
document.fonts.ready.then(() => {
|
|
260
|
+
void document.fonts.ready.then(() => {
|
|
261
261
|
if (!disposed) measure();
|
|
262
262
|
});
|
|
263
263
|
}
|
|
@@ -4,9 +4,6 @@ import {
|
|
|
4
4
|
type Component,
|
|
5
5
|
type ComponentProps,
|
|
6
6
|
createContext,
|
|
7
|
-
createSignal,
|
|
8
|
-
onCleanup,
|
|
9
|
-
onMount,
|
|
10
7
|
type ParentComponent,
|
|
11
8
|
Show,
|
|
12
9
|
splitProps,
|
|
@@ -47,36 +44,13 @@ const ToggleGroup: ParentComponent<
|
|
|
47
44
|
// discriminated union, so pulling `multiple` into a separate prop collapses the
|
|
48
45
|
// union and mistypes `value`. Leave it in `rest` and just peek at it here.
|
|
49
46
|
const sliding = () => !(props as { multiple?: boolean }).multiple;
|
|
50
|
-
// Items that overflow the width they are given wrap onto rows; measured, so labels of any length work.
|
|
51
|
-
const [wrap, setWrap] = createSignal(false);
|
|
52
|
-
let root: HTMLDivElement | undefined;
|
|
53
|
-
const measure = () => {
|
|
54
|
-
if (!root) return;
|
|
55
|
-
const items = root.querySelectorAll<HTMLElement>('[data-slot="toggle-group-item"]');
|
|
56
|
-
let needed = 8 + 4 * Math.max(0, items.length - 1);
|
|
57
|
-
for (const item of items) needed += item.scrollWidth;
|
|
58
|
-
const room = root.parentElement?.clientWidth ?? root.clientWidth;
|
|
59
|
-
setWrap(needed > room + 1);
|
|
60
|
-
};
|
|
61
|
-
onMount(() => {
|
|
62
|
-
if (!root || typeof ResizeObserver === "undefined") return;
|
|
63
|
-
const ro = new ResizeObserver(measure);
|
|
64
|
-
ro.observe(root);
|
|
65
|
-
if (root.parentElement) ro.observe(root.parentElement);
|
|
66
|
-
onCleanup(() => ro.disconnect());
|
|
67
|
-
});
|
|
68
47
|
return (
|
|
69
48
|
<ToggleGroupPrimitive
|
|
70
|
-
ref={(el: HTMLDivElement) => {
|
|
71
|
-
root = el;
|
|
72
|
-
}}
|
|
73
49
|
data-slot="toggle-group"
|
|
74
50
|
data-variant={local.variant}
|
|
75
51
|
data-size={local.size}
|
|
76
|
-
data-wrap={wrap() ? "" : undefined}
|
|
77
52
|
class={cn(
|
|
78
|
-
`group/toggle-group flex w-fit max-w-full items-center rounded-lg ${TRACK_SURFACE} p-1 data-[variant=outline]:shadow-xs`,
|
|
79
|
-
wrap() && "flex-wrap gap-1",
|
|
53
|
+
`group/toggle-group flex w-fit max-w-full flex-wrap items-center gap-y-1 rounded-lg ${TRACK_SURFACE} p-1 data-[variant=outline]:shadow-xs`,
|
|
80
54
|
local.class,
|
|
81
55
|
)}
|
|
82
56
|
{...rest}
|
|
@@ -91,8 +65,8 @@ const ToggleGroup: ParentComponent<
|
|
|
91
65
|
activeSelector="[data-pressed]"
|
|
92
66
|
indicatorClass="rounded-md"
|
|
93
67
|
indicatorTone={local.tone}
|
|
94
|
-
wrapped
|
|
95
|
-
class=
|
|
68
|
+
wrapped
|
|
69
|
+
class="flex w-full flex-wrap items-center gap-y-1"
|
|
96
70
|
>
|
|
97
71
|
{local.children}
|
|
98
72
|
</SlidingIndicator>
|
|
@@ -118,7 +92,8 @@ const ToggleGroupItem: Component<
|
|
|
118
92
|
variant: context.variant || local.variant,
|
|
119
93
|
size: context.size || local.size,
|
|
120
94
|
}),
|
|
121
|
-
|
|
95
|
+
// Wrapping is plain CSS: an item never shrinks below its label, so a row that runs out of width breaks.
|
|
96
|
+
"min-w-max flex-1 shrink-0 rounded-md px-4 shadow-none focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first-of-type:border-l",
|
|
122
97
|
// Single-select: the sliding indicator paints the active segment, so the
|
|
123
98
|
// item needs no pressed fill of its own and hover only tints the text.
|
|
124
99
|
// Multi-select has no single indicator, so each pressed segment carries
|