@glasshome/ui 1.26.1 → 1.27.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 +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/icon-picker.d.ts +1 -6
- package/dist/solid/icon.d.ts +3 -0
- package/dist/solid/index.js +2972 -2953
- package/dist/solid/schema-form.d.ts +1 -1
- package/dist/solid/settings-row.d.ts +1 -0
- 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/icon-picker.tsx +12 -10
- package/src/solid/icon.tsx +6 -0
- package/src/solid/schema-form.tsx +1 -1
- package/src/solid/settings-row.tsx +1 -0
- package/src/solid/tabs.tsx +3 -28
- package/src/solid/toggle-group.tsx +9 -1
|
@@ -49,7 +49,7 @@ interface SchemaFormProps {
|
|
|
49
49
|
data: Record<string, unknown>;
|
|
50
50
|
onChange: (data: Record<string, unknown>) => void;
|
|
51
51
|
errors?: string[];
|
|
52
|
-
/**
|
|
52
|
+
/** @deprecated Pass `search` to `provideIcons` once; removed in 2.0.0. */
|
|
53
53
|
searchIcons?: IconPickerProps["searchIcons"];
|
|
54
54
|
class?: string;
|
|
55
55
|
}
|
|
@@ -26,6 +26,7 @@ export declare function LabeledIconPicker(props: {
|
|
|
26
26
|
value: string;
|
|
27
27
|
onChange: (value: string) => void;
|
|
28
28
|
placeholder?: string;
|
|
29
|
+
/** @deprecated Pass `search` to `provideIcons` once; removed in 2.0.0. */
|
|
29
30
|
searchIcons?: IconPickerProps["searchIcons"];
|
|
30
31
|
}): JSX.Element;
|
|
31
32
|
export declare function LabeledInput(props: {
|
|
@@ -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
|
+
}
|
|
@@ -3,7 +3,7 @@ import { STAGGER } from "../lib/motion-classes.js";
|
|
|
3
3
|
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
4
4
|
import { CHIP, ICON_PILL_TINT } from "../lib/pill-classes.js";
|
|
5
5
|
import { cn } from "../lib/utils.js";
|
|
6
|
-
import { Icon } from "./icon.js";
|
|
6
|
+
import { Icon, iconSearch } from "./icon.js";
|
|
7
7
|
import { PickerSearch } from "./picker-search.js";
|
|
8
8
|
import { PickerTrigger } from "./picker-trigger.js";
|
|
9
9
|
import { Popover, PopoverAnchor, PopoverContent } from "./popover.js";
|
|
@@ -256,12 +256,7 @@ export interface IconPickerProps {
|
|
|
256
256
|
onChange: (value: string) => void;
|
|
257
257
|
placeholder?: string;
|
|
258
258
|
class?: string;
|
|
259
|
-
/**
|
|
260
|
-
* Host-provided icon search. The design system carries no network or CSP
|
|
261
|
-
* policy of its own: dash proxies the Iconify API same-origin so its
|
|
262
|
-
* connect-src allowlist stays free of third-party origins. Without this the
|
|
263
|
-
* picker still works, showing the curated set only.
|
|
264
|
-
*/
|
|
259
|
+
/** @deprecated Pass `search` to `provideIcons` once; removed in 2.0.0. */
|
|
265
260
|
searchIcons?: (query: string, prefix: string) => Promise<string[]>;
|
|
266
261
|
/** Id of the element naming the trigger, for forms that label it outside. */
|
|
267
262
|
"aria-labelledby"?: string;
|
|
@@ -283,12 +278,19 @@ export function IconPicker(props: IconPickerProps) {
|
|
|
283
278
|
setApiResults([]);
|
|
284
279
|
return;
|
|
285
280
|
}
|
|
286
|
-
const
|
|
287
|
-
|
|
281
|
+
const legacy = props.searchIcons;
|
|
282
|
+
const hosted = iconSearch();
|
|
283
|
+
const prefixes = prefix ? [prefix] : ICON_LIBRARIES.map((lib) => lib.prefix).filter(Boolean);
|
|
284
|
+
const run = legacy
|
|
285
|
+
? () => legacy(query, prefix)
|
|
286
|
+
: hosted
|
|
287
|
+
? () => hosted(query, prefixes)
|
|
288
|
+
: undefined;
|
|
289
|
+
if (!run) return;
|
|
288
290
|
setLoading(true);
|
|
289
291
|
debounceTimer = setTimeout(async () => {
|
|
290
292
|
try {
|
|
291
|
-
setApiResults(await
|
|
293
|
+
setApiResults(await run());
|
|
292
294
|
} catch {
|
|
293
295
|
setApiResults([]);
|
|
294
296
|
} finally {
|
package/src/solid/icon.tsx
CHANGED
|
@@ -9,6 +9,8 @@ export interface IconSource {
|
|
|
9
9
|
bundled: Record<string, IconData>;
|
|
10
10
|
/** Resolves the rest in one batch; a name the source does not have maps to null. */
|
|
11
11
|
load?: (names: string[]) => Promise<Record<string, IconData | null>>;
|
|
12
|
+
/** `prefix:name` matches for `query` across `prefixes`; powers every IconPicker. */
|
|
13
|
+
search?: (query: string, prefixes: string[]) => Promise<string[]>;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
/**
|
|
@@ -42,6 +44,10 @@ export function provideIcons(next: IconSource): void {
|
|
|
42
44
|
setGeneration((g) => g + 1);
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
export function iconSearch(): IconSource["search"] {
|
|
48
|
+
return source?.search;
|
|
49
|
+
}
|
|
50
|
+
|
|
45
51
|
function request(name: string): void {
|
|
46
52
|
const load = source?.load;
|
|
47
53
|
if (!load || requested.has(name)) return;
|
|
@@ -188,7 +188,7 @@ interface SchemaFormProps {
|
|
|
188
188
|
data: Record<string, unknown>;
|
|
189
189
|
onChange: (data: Record<string, unknown>) => void;
|
|
190
190
|
errors?: string[];
|
|
191
|
-
/**
|
|
191
|
+
/** @deprecated Pass `search` to `provideIcons` once; removed in 2.0.0. */
|
|
192
192
|
searchIcons?: IconPickerProps["searchIcons"];
|
|
193
193
|
class?: string;
|
|
194
194
|
}
|
|
@@ -72,6 +72,7 @@ export function LabeledIconPicker(props: {
|
|
|
72
72
|
value: string;
|
|
73
73
|
onChange: (value: string) => void;
|
|
74
74
|
placeholder?: string;
|
|
75
|
+
/** @deprecated Pass `search` to `provideIcons` once; removed in 2.0.0. */
|
|
75
76
|
searchIcons?: IconPickerProps["searchIcons"];
|
|
76
77
|
}) {
|
|
77
78
|
return (
|
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}
|