@glasshome/ui 1.26.0 → 1.26.2
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 +1 -1
- package/dist/lib/card-classes.d.ts +2 -2
- package/dist/lib/overlay-classes.d.ts +2 -2
- package/dist/lib/scroll-track.d.ts +5 -0
- package/dist/solid/index.js +1721 -1705
- package/dist/{utils-Sl2ceVna.js → utils-C1h9S08F.js} +2 -2
- package/package.json +1 -1
- package/src/lib/card-classes.ts +1 -1
- package/src/lib/overlay-classes.ts +1 -1
- package/src/lib/scroll-track.ts +47 -0
- package/src/solid/data-table.tsx +1 -1
- package/src/solid/tabs.tsx +3 -28
- package/src/solid/toggle-group.tsx +9 -1
|
@@ -152,7 +152,7 @@ var g = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, _ = [], { com
|
|
|
152
152
|
}), ne = S({
|
|
153
153
|
variant: "outline",
|
|
154
154
|
size: "none"
|
|
155
|
-
}), re = "inline-flex shrink-0 cursor-pointer items-center justify-center rounded-lg transition-glass duration-150 hover:bg-primary/10 active:scale-[0.97]", w = "data-[expanded]:animate-in data-[expanded]:duration-(--duration-expand) data-[expanded]:ease-(--ease-expand)", T = "data-[closed]:animate-out data-[closed]:duration-(--duration-micro) data-[closed]:ease-(--ease-contract)", ie = `origin-(--kb-popper-content-transform-origin) ${w} data-[expanded]:fade-in-0 data-[expanded]:zoom-in-90 ${T} data-[closed]:fade-out-0 data-[closed]:zoom-out-95`, E = "data-[closed]:animate-select-out data-[expanded]:animate-select-in", D = "[--morph-w:var(--kb-popper-anchor-width)] min-w-[var(--kb-popper-anchor-width)] data-[expanded]:animate-morph-in data-[closed]:animate-morph-out", O = "data-[expanded]:animate-anchored-in data-[closed]:animate-morph-out", k = "gh-stagger", A = `${w} data-[expanded]:fade-in-0 data-[expanded]:zoom-in-[0.94] data-[expanded]:slide-in-from-bottom-2 ${T} data-[closed]:fade-out-0 data-[closed]:zoom-out-[0.96]`, j = `${w} data-[expanded]:fade-in-0 ${T} data-[closed]:fade-out-0`, ae = "animate-in fade-in-0 slide-in-from-bottom-1 duration-(--duration-state) ease-(--ease-expand)", oe = "active:scale-[0.97]", se = "scale-0 opacity-0 transition-[scale,opacity] duration-(--duration-state) ease-(--ease-contract) data-[hold]:scale-100 data-[hold]:opacity-100 data-[hold]:duration-(--duration-hold) data-[hold]:ease-linear data-[fired]:scale-100 data-[fired]:opacity-0", ce = "origin-bottom transition-[opacity,scale,translate] data-[expanded]:duration-(--duration-expand) data-[expanded]:ease-(--ease-expand) data-[closed]:duration-(--duration-micro) data-[closed]:ease-(--ease-contract) data-[closed]:pointer-events-none data-[closed]:translate-y-2 data-[closed]:scale-95 data-[closed]:opacity-0", M = "transition-[translate,clip-path] duration-(--duration-morph) ease-(--ease-expand)", N = "glass [--glass-grain:var(--_material-grain)] [--glass-wash:20%] [--glass-rim:0.3] [--glass-lift:0.45] [--glass-shade:0.05] dark:[--glass-shade:0]", P = `${N} [--glass-base:color-mix(in_srgb,var(--card)_var(--material-clarity),transparent)]`, le = "backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[calc(
|
|
155
|
+
}), re = "inline-flex shrink-0 cursor-pointer items-center justify-center rounded-lg transition-glass duration-150 hover:bg-primary/10 active:scale-[0.97]", w = "data-[expanded]:animate-in data-[expanded]:duration-(--duration-expand) data-[expanded]:ease-(--ease-expand)", T = "data-[closed]:animate-out data-[closed]:duration-(--duration-micro) data-[closed]:ease-(--ease-contract)", ie = `origin-(--kb-popper-content-transform-origin) ${w} data-[expanded]:fade-in-0 data-[expanded]:zoom-in-90 ${T} data-[closed]:fade-out-0 data-[closed]:zoom-out-95`, E = "data-[closed]:animate-select-out data-[expanded]:animate-select-in", D = "[--morph-w:var(--kb-popper-anchor-width)] min-w-[var(--kb-popper-anchor-width)] data-[expanded]:animate-morph-in data-[closed]:animate-morph-out", O = "data-[expanded]:animate-anchored-in data-[closed]:animate-morph-out", k = "gh-stagger", A = `${w} data-[expanded]:fade-in-0 data-[expanded]:zoom-in-[0.94] data-[expanded]:slide-in-from-bottom-2 ${T} data-[closed]:fade-out-0 data-[closed]:zoom-out-[0.96]`, j = `${w} data-[expanded]:fade-in-0 ${T} data-[closed]:fade-out-0`, ae = "animate-in fade-in-0 slide-in-from-bottom-1 duration-(--duration-state) ease-(--ease-expand)", oe = "active:scale-[0.97]", se = "scale-0 opacity-0 transition-[scale,opacity] duration-(--duration-state) ease-(--ease-contract) data-[hold]:scale-100 data-[hold]:opacity-100 data-[hold]:duration-(--duration-hold) data-[hold]:ease-linear data-[fired]:scale-100 data-[fired]:opacity-0", ce = "origin-bottom transition-[opacity,scale,translate] data-[expanded]:duration-(--duration-expand) data-[expanded]:ease-(--ease-expand) data-[closed]:duration-(--duration-micro) data-[closed]:ease-(--ease-contract) data-[closed]:pointer-events-none data-[closed]:translate-y-2 data-[closed]:scale-95 data-[closed]:opacity-0", M = "transition-[translate,clip-path] duration-(--duration-morph) ease-(--ease-expand)", N = "glass [--glass-grain:var(--_material-grain)] [--glass-wash:20%] [--glass-rim:0.3] [--glass-lift:0.45] [--glass-shade:0.05] dark:[--glass-shade:0]", P = `${N} [--glass-base:color-mix(in_srgb,var(--card)_var(--material-clarity),transparent)]`, le = "backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[calc(var(--_material-vibrancy,1)*1.8)] backdrop-brightness-[calc(1+(var(--_material-vibrancy,1)-1)*0.2)]", F = `${P} ${le}`, ue = N, I = "glass [--glass-rim:0.3] [--glass-base:color-mix(in_srgb,var(--card)_var(--material-clarity),transparent)]", L = "border border-border/50 bg-card/40 backdrop-blur-sm", R = {
|
|
156
156
|
slots: "flex flex-col gap-3 p-3 md:gap-4 md:p-4",
|
|
157
157
|
md: "flex flex-col gap-3 p-4",
|
|
158
158
|
sm: "flex flex-col gap-2 p-3",
|
|
@@ -222,7 +222,7 @@ var Ie = "var(--muted-foreground)", Le = "[--glass-wash:12%]", Re = (e) => e ===
|
|
|
222
222
|
sub: "text-3xl",
|
|
223
223
|
gap: "gap-2"
|
|
224
224
|
}
|
|
225
|
-
}, Ke = "inline-flex items-end", qe = "flex flex-col gap-0.5", Je = "shrink-0", Ye = "whitespace-nowrap font-bold leading-none tracking-tight", Xe = "font-bold text-primary uppercase leading-none tracking-[0.18em]", Ze = "relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 text-sm outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&:not([data-tone])_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:text-[16px]", Qe = "px-2", $e = `${Ze} ${Qe}`, et = "px-2 py-1.5 font-medium text-muted-foreground text-xs", tt = "-mx-1 my-1 h-px bg-border", nt = 350, rt = 100, it = "glass glass-frost [--glass-rim:0.5] [--glass-lift:0.6] [--glass-light:0] [--glass-edge:color-mix(in_srgb,var(--border)_90%,transparent)]", at = "backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[calc(
|
|
225
|
+
}, Ke = "inline-flex items-end", qe = "flex flex-col gap-0.5", Je = "shrink-0", Ye = "whitespace-nowrap font-bold leading-none tracking-tight", Xe = "font-bold text-primary uppercase leading-none tracking-[0.18em]", Ze = "relative flex cursor-default select-none items-center gap-2 rounded-sm py-1.5 text-sm outline-hidden transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg:not([class*='size-'])]:size-4 [&:not([data-tone])_svg:not([class*='text-'])]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&>[data-slot=icon]]:shrink-0 [&>[data-slot=icon]]:text-[16px]", Qe = "px-2", $e = `${Ze} ${Qe}`, et = "px-2 py-1.5 font-medium text-muted-foreground text-xs", tt = "-mx-1 my-1 h-px bg-border", nt = 350, rt = 100, it = "glass glass-frost [--glass-rim:0.5] [--glass-lift:0.6] [--glass-light:0] [--glass-edge:color-mix(in_srgb,var(--border)_90%,transparent)]", at = "backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[calc(var(--_material-vibrancy,1)*1.2)] backdrop-brightness-[calc(1+(var(--_material-vibrancy,1)-1)*0.2)]", ot = `${it} [--glass-base:color-mix(in_srgb,var(--popover)_92%,transparent)]`, st = `${ot} ${at}`, ct = `${it} [--glass-base:var(--popover)]`, lt = "bg-scrim backdrop-blur-md", ut = `${Be.overlay} rounded-md text-popover-foreground outline-hidden`;
|
|
226
226
|
`${st}${ut}`;
|
|
227
227
|
var dt = `${st} relative ${ut}`, ft = (e) => {
|
|
228
228
|
let t = e?.getBoundingClientRect();
|
package/package.json
CHANGED
package/src/lib/card-classes.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const CARD_SURFACE_BASE = `${CARD_KNOBS} [--glass-base:color-mix(in_srgb,
|
|
|
8
8
|
/* Split from the surface so dash's performant-blur engine can gate it off and
|
|
9
9
|
* paint a precomputed frost instead. */
|
|
10
10
|
export const CARD_BLUR =
|
|
11
|
-
"backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[calc(
|
|
11
|
+
"backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[calc(var(--_material-vibrancy,1)*1.8)] backdrop-brightness-[calc(1+(var(--_material-vibrancy,1)-1)*0.2)]";
|
|
12
12
|
|
|
13
13
|
export const CARD_SURFACE = `${CARD_SURFACE_BASE} ${CARD_BLUR}`;
|
|
14
14
|
|
|
@@ -9,7 +9,7 @@ const OVERLAY_KNOBS =
|
|
|
9
9
|
/* Split from the surface the way CARD_BLUR is, so a host can gate it off and
|
|
10
10
|
* paint a precomputed frost instead. */
|
|
11
11
|
export const OVERLAY_BLUR =
|
|
12
|
-
"backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[calc(
|
|
12
|
+
"backdrop-blur-[var(--glass-blur,var(--material-blur,24px))] backdrop-saturate-[calc(var(--_material-vibrancy,1)*1.2)] backdrop-brightness-[calc(1+(var(--_material-vibrancy,1)-1)*0.2)]";
|
|
13
13
|
|
|
14
14
|
export const OVERLAY_SURFACE_BASE = `${OVERLAY_KNOBS} [--glass-base:color-mix(in_srgb,var(--popover)_92%,transparent)]`;
|
|
15
15
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* A row of segments that scrolls sideways (tabs, a scrolling toggle group):
|
|
2
|
+
* the selected segment stays in view and a clipped edge fades out, so the row
|
|
3
|
+
* reads as "more this way" instead of ending mid-label. */
|
|
4
|
+
|
|
5
|
+
/** Fades whichever edge the track writes as clipped. */
|
|
6
|
+
export const SCROLL_TRACK_FADE =
|
|
7
|
+
"data-[clip-end]:[mask-image:linear-gradient(to_right,black_85%,transparent)] data-[clip-start]:[mask-image:linear-gradient(to_left,black_85%,transparent)] data-[clip-start]:data-[clip-end]:[mask-image:linear-gradient(to_right,transparent,black_15%,black_85%,transparent)]";
|
|
8
|
+
|
|
9
|
+
function writeClip(list: HTMLElement): void {
|
|
10
|
+
const end = list.scrollWidth - list.clientWidth - list.scrollLeft;
|
|
11
|
+
list.toggleAttribute("data-clip-start", list.scrollLeft > 1);
|
|
12
|
+
list.toggleAttribute("data-clip-end", end > 1);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Centres the segment matching `selected` whenever it changes; drives
|
|
16
|
+
* scrollLeft, since scrollIntoView would scroll the page with it. */
|
|
17
|
+
export function trackScroll(list: HTMLElement, selected: string, attribute: string): () => void {
|
|
18
|
+
const reveal = () => {
|
|
19
|
+
writeClip(list);
|
|
20
|
+
if (list.scrollWidth <= list.clientWidth) return;
|
|
21
|
+
const item = list.querySelector(selected);
|
|
22
|
+
if (!item) return;
|
|
23
|
+
const track = list.getBoundingClientRect();
|
|
24
|
+
const box = item.getBoundingClientRect();
|
|
25
|
+
const left = list.scrollLeft + (box.left - track.left) - (track.width - box.width) / 2;
|
|
26
|
+
const smooth = !matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
27
|
+
list.scrollTo({ left, behavior: smooth ? "smooth" : "auto" });
|
|
28
|
+
};
|
|
29
|
+
const clip = () => writeClip(list);
|
|
30
|
+
// A frame late: on mount the track has no width yet, and during a press
|
|
31
|
+
// the focus scroll cancels a smooth scroll started in the same task.
|
|
32
|
+
let frame = requestAnimationFrame(reveal);
|
|
33
|
+
const observer = new MutationObserver(() => {
|
|
34
|
+
cancelAnimationFrame(frame);
|
|
35
|
+
frame = requestAnimationFrame(reveal);
|
|
36
|
+
});
|
|
37
|
+
observer.observe(list, { attributes: true, attributeFilter: [attribute], subtree: true });
|
|
38
|
+
const resize = new ResizeObserver(clip);
|
|
39
|
+
resize.observe(list);
|
|
40
|
+
list.addEventListener("scroll", clip, { passive: true });
|
|
41
|
+
return () => {
|
|
42
|
+
cancelAnimationFrame(frame);
|
|
43
|
+
observer.disconnect();
|
|
44
|
+
resize.disconnect();
|
|
45
|
+
list.removeEventListener("scroll", clip);
|
|
46
|
+
};
|
|
47
|
+
}
|
package/src/solid/data-table.tsx
CHANGED
|
@@ -209,7 +209,7 @@ export function TableSortHeader(props: {
|
|
|
209
209
|
data-slot="table-sort-header"
|
|
210
210
|
class={cn(
|
|
211
211
|
"text-muted-foreground hover:text-foreground h-auto gap-1 px-1.5 py-0.5 text-xs font-medium",
|
|
212
|
-
props.align === "end"
|
|
212
|
+
props.align === "end" ? "justify-end" : "justify-start",
|
|
213
213
|
props.class,
|
|
214
214
|
)}
|
|
215
215
|
aria-label={`Sort by ${props.label}`}
|
package/src/solid/tabs.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { Tabs as TabsPrimitive } from "@kobalte/core/tabs";
|
|
|
2
2
|
import { type Component, type ComponentProps, onCleanup, onMount, splitProps } from "solid-js";
|
|
3
3
|
import { TRACK_SURFACE } from "../lib/card-classes.js";
|
|
4
4
|
import { PRESS_DIP, SETTLE_MOTION } from "../lib/motion-classes.js";
|
|
5
|
+
import { SCROLL_TRACK_FADE, trackScroll } from "../lib/scroll-track.js";
|
|
5
6
|
import { SEGMENT_ITEM } from "../lib/segment-classes.js";
|
|
6
7
|
import { cn } from "../lib/utils.js";
|
|
7
8
|
import { Icon } from "./icon.js";
|
|
@@ -31,44 +32,18 @@ const Tabs: Component<TabsProps> = (props) => {
|
|
|
31
32
|
);
|
|
32
33
|
};
|
|
33
34
|
|
|
34
|
-
/** Keeps the selected trigger centred in the scrolled track, so a deep link to
|
|
35
|
-
* a tab past the fold does not land on a track scrolled to the first one.
|
|
36
|
-
* Drives scrollLeft rather than scrollIntoView, which would scroll the page
|
|
37
|
-
* with it. */
|
|
38
|
-
function followSelection(list: HTMLElement): () => void {
|
|
39
|
-
const reveal = () => {
|
|
40
|
-
if (list.scrollWidth <= list.clientWidth) return;
|
|
41
|
-
const selected = list.querySelector("[data-selected]");
|
|
42
|
-
if (!selected) return;
|
|
43
|
-
const track = list.getBoundingClientRect();
|
|
44
|
-
const item = selected.getBoundingClientRect();
|
|
45
|
-
const left = list.scrollLeft + (item.left - track.left) - (track.width - item.width) / 2;
|
|
46
|
-
const smooth = !matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
47
|
-
list.scrollTo({ left, behavior: smooth ? "smooth" : "auto" });
|
|
48
|
-
};
|
|
49
|
-
// The track has no width during mount, so the first pass has to wait for
|
|
50
|
-
// layout or it measures a track that cannot scroll yet.
|
|
51
|
-
const first = requestAnimationFrame(reveal);
|
|
52
|
-
const observer = new MutationObserver(reveal);
|
|
53
|
-
observer.observe(list, { attributes: true, attributeFilter: ["data-selected"], subtree: true });
|
|
54
|
-
return () => {
|
|
55
|
-
cancelAnimationFrame(first);
|
|
56
|
-
observer.disconnect();
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
|
|
60
35
|
const TabsList: Component<ComponentProps<typeof TabsPrimitive.List>> = (props) => {
|
|
61
36
|
const [local, others] = splitProps(props, ["class", "children"]);
|
|
62
37
|
let listRef: HTMLDivElement | undefined;
|
|
63
38
|
onMount(() => {
|
|
64
|
-
if (listRef) onCleanup(
|
|
39
|
+
if (listRef) onCleanup(trackScroll(listRef, "[data-selected]", "data-selected"));
|
|
65
40
|
});
|
|
66
41
|
return (
|
|
67
42
|
<TabsPrimitive.List
|
|
68
43
|
ref={listRef}
|
|
69
44
|
data-slot="tabs-list"
|
|
70
45
|
class={cn(
|
|
71
|
-
`scrollbar-hide inline-flex h-9 w-full items-center overflow-x-auto rounded-lg has-[[data-slot=tabs-trigger-icon]]:h-auto ${TRACK_SURFACE} text-muted-foreground p-1`,
|
|
46
|
+
`scrollbar-hide inline-flex h-9 w-full items-center overflow-x-auto rounded-lg has-[[data-slot=tabs-trigger-icon]]:h-auto ${TRACK_SURFACE} ${SCROLL_TRACK_FADE} text-muted-foreground p-1`,
|
|
72
47
|
local.class,
|
|
73
48
|
)}
|
|
74
49
|
{...others}
|
|
@@ -5,11 +5,14 @@ import {
|
|
|
5
5
|
type ComponentProps,
|
|
6
6
|
createContext,
|
|
7
7
|
type ParentComponent,
|
|
8
|
+
onCleanup,
|
|
9
|
+
onMount,
|
|
8
10
|
Show,
|
|
9
11
|
splitProps,
|
|
10
12
|
useContext,
|
|
11
13
|
} from "solid-js";
|
|
12
14
|
import { TRACK_SURFACE } from "../lib/card-classes.js";
|
|
15
|
+
import { SCROLL_TRACK_FADE, trackScroll } from "../lib/scroll-track.js";
|
|
13
16
|
import { cn } from "../lib/utils.js";
|
|
14
17
|
import { SlidingIndicator } from "./sliding-indicator.js";
|
|
15
18
|
import { toggleVariants } from "./toggle.js";
|
|
@@ -47,15 +50,20 @@ const ToggleGroup: ParentComponent<
|
|
|
47
50
|
// discriminated union, so pulling `multiple` into a separate prop collapses the
|
|
48
51
|
// union and mistypes `value`. Leave it in `rest` and just peek at it here.
|
|
49
52
|
const sliding = () => !(props as { multiple?: boolean }).multiple;
|
|
53
|
+
let root: HTMLDivElement | undefined;
|
|
54
|
+
onMount(() => {
|
|
55
|
+
if (local.scroll && root) onCleanup(trackScroll(root, "[data-pressed]", "data-pressed"));
|
|
56
|
+
});
|
|
50
57
|
return (
|
|
51
58
|
<ToggleGroupPrimitive
|
|
59
|
+
ref={root}
|
|
52
60
|
data-slot="toggle-group"
|
|
53
61
|
data-variant={local.variant}
|
|
54
62
|
data-size={local.size}
|
|
55
63
|
data-scroll={local.scroll ? "" : undefined}
|
|
56
64
|
class={cn(
|
|
57
65
|
`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`,
|
|
58
|
-
local.scroll &&
|
|
66
|
+
local.scroll && `[scrollbar-width:none] flex-nowrap overflow-x-auto ${SCROLL_TRACK_FADE}`,
|
|
59
67
|
local.class,
|
|
60
68
|
)}
|
|
61
69
|
{...rest}
|