@glasshome/ui 1.19.0 → 1.21.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/SPEC.md +2 -1
- package/dist/index.js +2 -2
- package/dist/lib/anchor-placement.d.ts +5 -0
- package/dist/lib/button-variants.d.ts +1 -1
- package/dist/lib/motion-classes.d.ts +1 -0
- package/dist/solid/color-disc.d.ts +33 -0
- package/dist/solid/dashboard-preview.d.ts +24 -0
- package/dist/solid/dialog-parts.d.ts +1 -0
- package/dist/solid/dialog.d.ts +3 -0
- package/dist/solid/image-picker.d.ts +3 -0
- package/dist/solid/index.d.ts +3 -1
- package/dist/solid/index.js +5931 -5537
- package/dist/solid/media-store.d.ts +10 -0
- package/dist/solid/option-card.d.ts +1 -0
- package/dist/solid/page-header.d.ts +2 -2
- package/dist/solid/preview-tile.d.ts +2 -0
- package/dist/solid/responsive-dialog.d.ts +2 -0
- package/dist/solid/schema-form.d.ts +6 -1
- package/dist/solid/sliding-indicator.d.ts +2 -0
- package/dist/solid/toggle-group.d.ts +4 -1
- package/dist/tokens/index.js +2 -1
- package/dist/{utils-CV6G6fr8.js → utils-CMk7R3zM.js} +413 -413
- package/package.json +1 -1
- package/scripts/check-ui-drift.mjs +5 -0
- package/src/lib/anchor-placement.ts +30 -0
- package/src/lib/button-variants.ts +12 -12
- package/src/lib/motion-classes.ts +5 -0
- package/src/solid/bottom-sheet/bottom-sheet.tsx +8 -1
- package/src/solid/color-disc.tsx +253 -0
- package/src/solid/dashboard-preview.tsx +128 -0
- package/src/solid/dialog-parts.tsx +5 -1
- package/src/solid/dialog.tsx +47 -5
- package/src/solid/entity-selector.tsx +2 -2
- package/src/solid/image-picker.tsx +232 -147
- package/src/solid/index.ts +9 -0
- package/src/solid/media-store.ts +20 -1
- package/src/solid/option-card.tsx +2 -0
- package/src/solid/page-header.tsx +9 -16
- package/src/solid/preview-tile.tsx +10 -0
- package/src/solid/responsive-dialog.tsx +10 -2
- package/src/solid/schema-form.tsx +30 -4
- package/src/solid/sliding-indicator.tsx +21 -5
- package/src/solid/toggle-group.tsx +18 -5
- package/src/styles/theme.css +12 -3
- package/src/tokens/presets.ts +1 -0
|
@@ -16,8 +16,9 @@ import { IconPicker, type IconPickerProps } from "./icon-picker.js";
|
|
|
16
16
|
import { ImagePicker } from "./image-picker.js";
|
|
17
17
|
import { Input } from "./input.js";
|
|
18
18
|
import { createListReorder } from "./list-reorder.js";
|
|
19
|
-
import { useMediaStore } from "./media-store.js";
|
|
19
|
+
import { type ImagePreset, imagePreset, useMediaStore } from "./media-store.js";
|
|
20
20
|
import { NumberField } from "./number-field.js";
|
|
21
|
+
import { OptionCard, OptionCardGroup } from "./option-card.js";
|
|
21
22
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "./select.js";
|
|
22
23
|
import { Switch } from "./switch.js";
|
|
23
24
|
import { ToggleGroup, ToggleGroupItem } from "./toggle-group.js";
|
|
@@ -33,8 +34,12 @@ export interface ExtendedJSONSchema extends JSONSchema7 {
|
|
|
33
34
|
deviceClass?: string;
|
|
34
35
|
/** formType "variants": the property that selects the active branch. */
|
|
35
36
|
discriminator?: string;
|
|
36
|
-
/**
|
|
37
|
+
/** Enum value → display name (field.choice, field.choices, the variants selector). */
|
|
37
38
|
labels?: Record<string, string>;
|
|
39
|
+
/** field.choice: enum value → icon name; set, the choice renders as icon cards. */
|
|
40
|
+
icons?: Record<string, string>;
|
|
41
|
+
/** formType "image-picker": built-in pictures offered beside the uploads. */
|
|
42
|
+
presets?: Record<string, ImagePreset>;
|
|
38
43
|
/** formType "list": add-button caption. */
|
|
39
44
|
addLabel?: string;
|
|
40
45
|
/** formType "list": item field whose value captions the collapsed row. */
|
|
@@ -372,6 +377,7 @@ function FieldControl(props: FieldProps) {
|
|
|
372
377
|
<Match when={kind() === "image"}>
|
|
373
378
|
<ImagePicker
|
|
374
379
|
id={props.id}
|
|
380
|
+
presets={props.prop.presets}
|
|
375
381
|
value={String(current() ?? "")}
|
|
376
382
|
onChange={(val) => props.onChange(val)}
|
|
377
383
|
/>
|
|
@@ -383,6 +389,22 @@ function FieldControl(props: FieldProps) {
|
|
|
383
389
|
onChange={(val) => props.onChange(val)}
|
|
384
390
|
/>
|
|
385
391
|
</Match>
|
|
392
|
+
<Match when={kind() === "enum" && props.prop.icons}>
|
|
393
|
+
{(icons) => (
|
|
394
|
+
<OptionCardGroup
|
|
395
|
+
aria-labelledby={props.labelledBy}
|
|
396
|
+
value={String(current() ?? "")}
|
|
397
|
+
onChange={(val) => props.onChange(val)}
|
|
398
|
+
class="grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))]"
|
|
399
|
+
>
|
|
400
|
+
<For each={(props.prop.enum ?? []).map(String)}>
|
|
401
|
+
{(value) => (
|
|
402
|
+
<OptionCard value={value} title={enumLabel(value)} icon={icons()[value]} />
|
|
403
|
+
)}
|
|
404
|
+
</For>
|
|
405
|
+
</OptionCardGroup>
|
|
406
|
+
)}
|
|
407
|
+
</Match>
|
|
386
408
|
<Match when={kind() === "enum"}>
|
|
387
409
|
<Select
|
|
388
410
|
value={String(current() ?? "")}
|
|
@@ -479,10 +501,14 @@ function ListControl(props: FieldProps) {
|
|
|
479
501
|
|
|
480
502
|
const thumbUrl = (item: unknown) => {
|
|
481
503
|
const key = imageKey();
|
|
482
|
-
|
|
483
|
-
if (key === undefined || !store) return undefined;
|
|
504
|
+
if (key === undefined) return undefined;
|
|
484
505
|
const id = recordOf(item)[key];
|
|
485
506
|
if (typeof id !== "string" || id === "") return undefined;
|
|
507
|
+
const preset = imagePreset(id);
|
|
508
|
+
if (preset !== undefined)
|
|
509
|
+
return propertiesOf(itemSchema()).find(([k]) => k === key)?.[1].presets?.[preset]?.thumb;
|
|
510
|
+
const store = mediaStore;
|
|
511
|
+
if (!store) return undefined;
|
|
486
512
|
// A 32px row chip: the thumb variant, never the original.
|
|
487
513
|
return store.url(id, "thumb");
|
|
488
514
|
};
|
|
@@ -45,10 +45,12 @@ interface SlidingIndicatorProps extends ComponentProps<"div"> {
|
|
|
45
45
|
indicatorTone?: string;
|
|
46
46
|
/** Selector for the measurable items. Default: direct children (minus the indicator). */
|
|
47
47
|
itemSelector?: string;
|
|
48
|
+
/** Items wrap onto rows: the indicator follows the active item's row as well as its place in it. */
|
|
49
|
+
wrapped?: boolean;
|
|
48
50
|
children: JSX.Element;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
|
-
type Pos = { offset: number; size: number; cross: number };
|
|
53
|
+
type Pos = { offset: number; size: number; cross: number; crossOffset: number };
|
|
52
54
|
|
|
53
55
|
// One duration for both the slide (transform transition) and the scale dip, so
|
|
54
56
|
// they always overlap exactly. Shorter = snappier.
|
|
@@ -73,6 +75,7 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
|
|
|
73
75
|
"indicatorClass",
|
|
74
76
|
"indicatorTone",
|
|
75
77
|
"itemSelector",
|
|
78
|
+
"wrapped",
|
|
76
79
|
"class",
|
|
77
80
|
"children",
|
|
78
81
|
"ref",
|
|
@@ -174,11 +177,14 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
|
|
|
174
177
|
(er.left - cr.left) / sx - tx - containerRef.clientLeft + containerRef.scrollLeft,
|
|
175
178
|
size: er.width / sx,
|
|
176
179
|
cross: er.height / sy,
|
|
180
|
+
crossOffset:
|
|
181
|
+
(er.top - cr.top) / sy - ty - containerRef.clientTop + containerRef.scrollTop,
|
|
177
182
|
}
|
|
178
183
|
: {
|
|
179
184
|
offset: (er.top - cr.top) / sy - ty - containerRef.clientTop + containerRef.scrollTop,
|
|
180
185
|
size: er.height / sy,
|
|
181
186
|
cross: er.width / sx,
|
|
187
|
+
crossOffset: 0,
|
|
182
188
|
},
|
|
183
189
|
);
|
|
184
190
|
};
|
|
@@ -275,16 +281,26 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
|
|
|
275
281
|
aria-hidden="true"
|
|
276
282
|
class={cn(
|
|
277
283
|
"pointer-events-none absolute -z-10",
|
|
278
|
-
|
|
284
|
+
local.wrapped
|
|
285
|
+
? "top-0 left-0"
|
|
286
|
+
: horizontal()
|
|
287
|
+
? "inset-y-0 left-0"
|
|
288
|
+
: "inset-x-0 top-0",
|
|
279
289
|
"glass glass-tint",
|
|
280
290
|
local.indicatorClass ?? "rounded-lg",
|
|
281
291
|
)}
|
|
282
292
|
style={{
|
|
283
293
|
transition: `transform ${SLIDE_MS}ms ease-in-out, width ${SLIDE_MS}ms ease-in-out, height ${SLIDE_MS}ms ease-in-out`,
|
|
284
294
|
"--glass-tone": local.indicatorTone ?? "var(--primary)",
|
|
285
|
-
...(horizontal()
|
|
286
|
-
? {
|
|
287
|
-
|
|
295
|
+
...(local.wrapped && horizontal()
|
|
296
|
+
? {
|
|
297
|
+
transform: `translate(${p().offset}px, ${p().crossOffset}px)`,
|
|
298
|
+
width: `${p().size}px`,
|
|
299
|
+
height: `${p().cross}px`,
|
|
300
|
+
}
|
|
301
|
+
: horizontal()
|
|
302
|
+
? { transform: `translateX(${p().offset}px)`, width: `${p().size}px` }
|
|
303
|
+
: { transform: `translateY(${p().offset}px)`, height: `${p().size}px` }),
|
|
288
304
|
}}
|
|
289
305
|
/>
|
|
290
306
|
)}
|
|
@@ -27,9 +27,19 @@ const ToggleGroupContext = createContext<ToggleGroupContextValue>({
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
const ToggleGroup: ParentComponent<
|
|
30
|
-
ComponentProps<typeof ToggleGroupPrimitive> &
|
|
30
|
+
ComponentProps<typeof ToggleGroupPrimitive> &
|
|
31
|
+
VariantProps<typeof toggleVariants> & {
|
|
32
|
+
/** CSS colour for the selected segment's glass. Default `var(--primary)`. */
|
|
33
|
+
tone?: string;
|
|
34
|
+
}
|
|
31
35
|
> = (props) => {
|
|
32
|
-
const [local, rest] = splitProps(props, [
|
|
36
|
+
const [local, rest] = splitProps(props, [
|
|
37
|
+
"class",
|
|
38
|
+
"variant",
|
|
39
|
+
"size",
|
|
40
|
+
"tone",
|
|
41
|
+
"children",
|
|
42
|
+
] as const);
|
|
33
43
|
// Read `multiple` without splitting it out: Kobalte's root is a single/multiple
|
|
34
44
|
// discriminated union, so pulling `multiple` into a separate prop collapses the
|
|
35
45
|
// union and mistypes `value`. Leave it in `rest` and just peek at it here.
|
|
@@ -40,7 +50,7 @@ const ToggleGroup: ParentComponent<
|
|
|
40
50
|
data-variant={local.variant}
|
|
41
51
|
data-size={local.size}
|
|
42
52
|
class={cn(
|
|
43
|
-
`group/toggle-group flex w-fit items-center rounded-lg ${TRACK_SURFACE} p-1 data-[variant=outline]:shadow-xs`,
|
|
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`,
|
|
44
54
|
local.class,
|
|
45
55
|
)}
|
|
46
56
|
{...rest}
|
|
@@ -54,7 +64,9 @@ const ToggleGroup: ParentComponent<
|
|
|
54
64
|
<SlidingIndicator
|
|
55
65
|
activeSelector="[data-pressed]"
|
|
56
66
|
indicatorClass="rounded-md"
|
|
57
|
-
|
|
67
|
+
indicatorTone={local.tone}
|
|
68
|
+
wrapped
|
|
69
|
+
class="flex w-full flex-wrap items-center gap-y-1"
|
|
58
70
|
>
|
|
59
71
|
{local.children}
|
|
60
72
|
</SlidingIndicator>
|
|
@@ -80,7 +92,8 @@ const ToggleGroupItem: Component<
|
|
|
80
92
|
variant: context.variant || local.variant,
|
|
81
93
|
size: context.size || local.size,
|
|
82
94
|
}),
|
|
83
|
-
|
|
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",
|
|
84
97
|
// Single-select: the sliding indicator paints the active segment, so the
|
|
85
98
|
// item needs no pressed fill of its own and hover only tints the text.
|
|
86
99
|
// Multi-select has no single indicator, so each pressed segment carries
|
package/src/styles/theme.css
CHANGED
|
@@ -68,10 +68,13 @@
|
|
|
68
68
|
|
|
69
69
|
/* Trigger morph: the panel is anchored over the trigger's top edge and starts
|
|
70
70
|
* clipped to the trigger's own box and radius (--morph-w/h/radius, written by
|
|
71
|
-
* the content from its trigger
|
|
71
|
+
* the content from its trigger; --morph-x/y when the panel had to shift off
|
|
72
|
+
* the trigger's corner to stay on screen), then unrolls into its own box. The pill
|
|
72
73
|
* becomes the panel; nothing scales, so no row or radius distorts. */
|
|
73
74
|
--animate-morph-in: morph-in var(--duration-morph) var(--ease-morph) both;
|
|
74
75
|
--animate-morph-out: morph-out calc(var(--duration-morph) / 2) var(--ease-contract) both;
|
|
76
|
+
/* Unfilled once done, so the anchored panel's clip lets go and its shadow shows. */
|
|
77
|
+
--animate-anchored-in: morph-in var(--duration-morph) var(--ease-morph) backwards;
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
@keyframes collapsible-down {
|
|
@@ -120,7 +123,8 @@
|
|
|
120
123
|
from {
|
|
121
124
|
opacity: 0;
|
|
122
125
|
clip-path: inset(
|
|
123
|
-
|
|
126
|
+
var(--morph-y, 0px) calc(100% - var(--morph-x, 0px) - var(--morph-w, 100%))
|
|
127
|
+
calc(100% - var(--morph-y, 0px) - var(--morph-h, 2.5rem)) var(--morph-x, 0px) round
|
|
124
128
|
var(--morph-radius, 9999px)
|
|
125
129
|
);
|
|
126
130
|
pointer-events: none;
|
|
@@ -145,7 +149,8 @@
|
|
|
145
149
|
to {
|
|
146
150
|
opacity: 0;
|
|
147
151
|
clip-path: inset(
|
|
148
|
-
|
|
152
|
+
var(--morph-y, 0px) calc(100% - var(--morph-x, 0px) - var(--morph-w, 100%))
|
|
153
|
+
calc(100% - var(--morph-y, 0px) - var(--morph-h, 2.5rem)) var(--morph-x, 0px) round
|
|
149
154
|
var(--morph-radius, 9999px)
|
|
150
155
|
);
|
|
151
156
|
}
|
|
@@ -583,6 +588,10 @@ html[data-motion="live"] {
|
|
|
583
588
|
backdrop-filter: none !important;
|
|
584
589
|
-webkit-backdrop-filter: none !important;
|
|
585
590
|
}
|
|
591
|
+
/* A control that cannot blur takes the opaque card fill, never bare see-through. */
|
|
592
|
+
.reduce-blur .glass-control {
|
|
593
|
+
--glass-base: var(--card);
|
|
594
|
+
}
|
|
586
595
|
|
|
587
596
|
/* Accessibility: minimize animations/transitions when reduce-motion is active */
|
|
588
597
|
.reduce-motion,
|