@glasshome/ui 1.10.1 → 1.12.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 +9 -0
- package/dist/index.js +1 -1
- package/dist/lib/menu-classes.d.ts +2 -2
- package/dist/solid/icon.d.ts +18 -12
- package/dist/solid/index.d.ts +1 -0
- package/dist/solid/index.js +3692 -3490
- package/dist/{utils-CIwpbaOd.js → utils-CdUh67Y9.js} +1 -1
- package/package.json +3 -2
- package/src/lib/menu-classes.ts +1 -1
- package/src/solid/accordion.tsx +1 -1
- package/src/solid/icon.tsx +119 -13
- package/src/solid/index.ts +2 -6
- package/src/solid/section-card.tsx +3 -3
- package/src/solid/sonner.tsx +0 -2
- package/src/styles/globals.css +7 -0
- package/src/styles/theme.css +11 -0
|
@@ -221,7 +221,7 @@ var Ae = "var(--muted-foreground)", je = "[--glass-wash:12%]", Me = (e) => e ===
|
|
|
221
221
|
sub: "text-3xl",
|
|
222
222
|
gap: "gap-2"
|
|
223
223
|
}
|
|
224
|
-
}, Be = "inline-flex items-end", Ve = "flex flex-col gap-0.5", He = "shrink-0", Ue = "whitespace-nowrap font-bold leading-none tracking-tight", We = "font-bold text-primary uppercase leading-none tracking-[0.18em]", Ge = "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 [&>
|
|
224
|
+
}, Be = "inline-flex items-end", Ve = "flex flex-col gap-0.5", He = "shrink-0", Ue = "whitespace-nowrap font-bold leading-none tracking-tight", We = "font-bold text-primary uppercase leading-none tracking-[0.18em]", Ge = "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]", Ke = "px-2", qe = `${Ge} ${Ke}`, Je = "px-2 py-1.5 font-medium text-muted-foreground text-xs", Ye = "-mx-1 my-1 h-px bg-border", Xe = "glass glass-frost [--glass-rim:0.5] [--glass-lift:0.6] [--glass-light:0] [--glass-edge:color-mix(in_srgb,var(--border)_90%,transparent)]", Ze = "backdrop-blur-[var(--glass-blur,24px)] backdrop-saturate-[1.2]", Qe = `${Xe} [--glass-base:color-mix(in_srgb,var(--popover)_92%,transparent)]`, $e = `${Qe} ${Ze}`, et = `${Xe} [--glass-base:var(--popover)]`, tt = "bg-scrim backdrop-blur-md", nt = `${$e} relative ${Pe.overlay} rounded-md text-popover-foreground outline-hidden`, rt = (e) => {
|
|
225
225
|
let t = e?.getBoundingClientRect();
|
|
226
226
|
return t ? {
|
|
227
227
|
x: t.left,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glasshome/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"description": "SolidJS component library for GlassHome, built on Kobalte",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/glasshome/ui#readme",
|
|
@@ -80,13 +80,14 @@
|
|
|
80
80
|
"tw-animate-css": "^1.4.0"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
+
"@iconify/types": "^2.0.0",
|
|
84
|
+
"@iconify/utils": "^3.1.4",
|
|
83
85
|
"@kobalte/core": "^0.13.13",
|
|
84
86
|
"clsx": "^2.1.1",
|
|
85
87
|
"cva": "^1.0.0-beta.4",
|
|
86
88
|
"embla-carousel": "^8.5.1",
|
|
87
89
|
"embla-carousel-autoplay": "^8.5.1",
|
|
88
90
|
"embla-carousel-fade": "^8.5.1",
|
|
89
|
-
"iconify-icon": "^3.0.2",
|
|
90
91
|
"solid-sonner": "^0.3.1",
|
|
91
92
|
"tailwind-merge": "^3.4.0"
|
|
92
93
|
},
|
package/src/lib/menu-classes.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* would come down to CSS emit order. Such a row composes MENU_ITEM_BASE. */
|
|
11
11
|
export const MENU_ITEM_BASE =
|
|
12
12
|
// structural-ok: guards an svg color rule on a sibling data attribute this package always renders, not a class the consumer must also scan
|
|
13
|
-
"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 [&>
|
|
13
|
+
"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]";
|
|
14
14
|
|
|
15
15
|
export const MENU_ITEM_X = "px-2";
|
|
16
16
|
|
package/src/solid/accordion.tsx
CHANGED
|
@@ -25,7 +25,7 @@ const AccordionTrigger: ParentComponent<ComponentProps<typeof AccordionPrimitive
|
|
|
25
25
|
<AccordionPrimitive.Trigger
|
|
26
26
|
data-slot="accordion-trigger"
|
|
27
27
|
class={cn(
|
|
28
|
-
"flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left font-medium text-sm outline-none transition-all hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&[data-expanded]>
|
|
28
|
+
"flex flex-1 items-start justify-between gap-4 rounded-md py-4 text-left font-medium text-sm outline-none transition-all hover:underline focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 [&[data-expanded]>[data-slot=icon]]:rotate-180",
|
|
29
29
|
local.class,
|
|
30
30
|
)}
|
|
31
31
|
{...rest}
|
package/src/solid/icon.tsx
CHANGED
|
@@ -1,20 +1,126 @@
|
|
|
1
|
-
import "iconify
|
|
2
|
-
import
|
|
3
|
-
import type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import type { IconifyIcon } from "@iconify/types";
|
|
2
|
+
import { iconToSVG } from "@iconify/utils";
|
|
3
|
+
import { createMemo, createSignal, type JSX, splitProps } from "solid-js";
|
|
4
|
+
|
|
5
|
+
export type IconData = IconifyIcon;
|
|
6
|
+
|
|
7
|
+
export interface IconSource {
|
|
8
|
+
/** Icons known at build time, keyed `prefix:name`. */
|
|
9
|
+
bundled: Record<string, IconData>;
|
|
10
|
+
/** Resolves the rest in one batch; a name the source does not have maps to null. */
|
|
11
|
+
load?: (names: string[]) => Promise<Record<string, IconData | null>>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Module-level singleton, the same shape as provideEntityData: widget sandboxes
|
|
16
|
+
* mount their own Solid roots but resolve this module through the host import
|
|
17
|
+
* map, so the host's source reaches them too.
|
|
18
|
+
*/
|
|
19
|
+
let source: IconSource | undefined;
|
|
20
|
+
const loaded = new Map<string, IconData | null>();
|
|
21
|
+
const [generation, setGeneration] = createSignal(0);
|
|
22
|
+
let pending = new Set<string>();
|
|
23
|
+
let flush: Promise<void> | null = null;
|
|
24
|
+
|
|
25
|
+
/** Host apps call this once at startup; every mounted Icon re-resolves. */
|
|
26
|
+
export function provideIcons(next: IconSource): void {
|
|
27
|
+
source = next;
|
|
28
|
+
loaded.clear();
|
|
29
|
+
setGeneration((g) => g + 1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function request(name: string): void {
|
|
33
|
+
const load = source?.load;
|
|
34
|
+
if (!load || pending.has(name)) return;
|
|
35
|
+
pending.add(name);
|
|
36
|
+
if (flush) return;
|
|
37
|
+
flush = Promise.resolve().then(async () => {
|
|
38
|
+
const names = [...pending];
|
|
39
|
+
pending = new Set();
|
|
40
|
+
flush = null;
|
|
41
|
+
let result: Record<string, IconData | null> = {};
|
|
42
|
+
try {
|
|
43
|
+
result = await load(names);
|
|
44
|
+
} catch {
|
|
45
|
+
result = {};
|
|
46
|
+
}
|
|
47
|
+
for (const n of names) loaded.set(n, result[n] ?? null);
|
|
48
|
+
setGeneration((g) => g + 1);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function lookup(name: string): IconData | undefined {
|
|
53
|
+
generation();
|
|
54
|
+
const bundled = source?.bundled[name];
|
|
55
|
+
if (bundled) return bundled;
|
|
56
|
+
if (loaded.has(name)) return loaded.get(name) ?? undefined;
|
|
57
|
+
request(name);
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface TrustedPolicy {
|
|
62
|
+
createHTML(input: string): string;
|
|
63
|
+
}
|
|
64
|
+
let policy: TrustedPolicy | null | undefined;
|
|
65
|
+
|
|
66
|
+
// Icon bodies come from the build or the host's own icon route; under a
|
|
67
|
+
// require-trusted-types-for CSP the assignment still needs a policy.
|
|
68
|
+
function trusted(html: string): string {
|
|
69
|
+
if (policy === undefined) {
|
|
70
|
+
const tt = (
|
|
71
|
+
globalThis as {
|
|
72
|
+
trustedTypes?: { createPolicy(name: string, rules: TrustedPolicy): TrustedPolicy };
|
|
73
|
+
}
|
|
74
|
+
).trustedTypes;
|
|
75
|
+
try {
|
|
76
|
+
policy = tt ? tt.createPolicy("glasshome-ui", { createHTML: (s) => s }) : null;
|
|
77
|
+
} catch {
|
|
78
|
+
policy = null;
|
|
10
79
|
}
|
|
11
80
|
}
|
|
81
|
+
return policy ? policy.createHTML(html) : html;
|
|
12
82
|
}
|
|
13
83
|
|
|
14
|
-
export
|
|
84
|
+
export interface IconProps
|
|
85
|
+
extends Omit<JSX.SvgSVGAttributes<SVGSVGElement>, "width" | "height" | "children"> {
|
|
86
|
+
/** `prefix:name`, e.g. `lucide:plus`. */
|
|
87
|
+
icon: string;
|
|
88
|
+
/** Unitless = px; both omitted = 1em, one omitted = the icon's own ratio. */
|
|
89
|
+
width?: number | string;
|
|
90
|
+
height?: number | string;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const EMPTY = { attributes: { viewBox: "0 0 16 16", width: "1em", height: "1em" }, body: "" };
|
|
15
94
|
|
|
16
|
-
|
|
17
|
-
* import-order note in index.ts. */
|
|
95
|
+
/** One inline `<svg>` per icon: no shadow root, no observer, rendered once and kept. */
|
|
18
96
|
export function Icon(props: IconProps) {
|
|
19
|
-
|
|
97
|
+
const [local, rest] = splitProps(props, ["icon", "width", "height"]);
|
|
98
|
+
const built = createMemo(() => {
|
|
99
|
+
const data = lookup(local.icon);
|
|
100
|
+
const size = {
|
|
101
|
+
width: local.width == null ? null : String(local.width),
|
|
102
|
+
height: local.height == null ? null : String(local.height),
|
|
103
|
+
};
|
|
104
|
+
if (!data) return { ...EMPTY, attributes: { ...EMPTY.attributes, ...sizeOrDefault(size) } };
|
|
105
|
+
return iconToSVG(data, size);
|
|
106
|
+
});
|
|
107
|
+
return (
|
|
108
|
+
<svg
|
|
109
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
110
|
+
data-slot="icon"
|
|
111
|
+
data-icon={local.icon}
|
|
112
|
+
aria-hidden="true"
|
|
113
|
+
fill="currentColor"
|
|
114
|
+
{...rest}
|
|
115
|
+
viewBox={built().attributes.viewBox}
|
|
116
|
+
width={built().attributes.width}
|
|
117
|
+
height={built().attributes.height}
|
|
118
|
+
innerHTML={trusted(built().body)}
|
|
119
|
+
/>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function sizeOrDefault(size: { width: string | null; height: string | null }) {
|
|
124
|
+
if (size.width == null && size.height == null) return { width: "1em", height: "1em" };
|
|
125
|
+
return { width: size.width ?? size.height ?? "1em", height: size.height ?? size.width ?? "1em" };
|
|
20
126
|
}
|
package/src/solid/index.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
// Original components
|
|
2
2
|
|
|
3
|
-
// Deliberately NOT re-exported here: `Icon` from ./icon.tsx. A barrel
|
|
4
|
-
// re-export makes every ui import eagerly evaluate iconify-icon, which then
|
|
5
|
-
// claims the <iconify-icon> element before the host registers its bundled icon
|
|
6
|
-
// data — every icon silently falls back to a network fetch (see apps/dash
|
|
7
|
-
// main.tsx import-order comment). One door for icons has to wait for the ui
|
|
8
|
-
// import to stop carrying an iconify copy at all.
|
|
9
3
|
// Color helpers for ColorWheel/ColorSlider consumers, re-exported so they
|
|
10
4
|
// don't need a direct @kobalte/core dependency.
|
|
11
5
|
export { type Color, parseColor } from "@kobalte/core/colors";
|
|
@@ -224,6 +218,8 @@ export {
|
|
|
224
218
|
HoverCardContent,
|
|
225
219
|
HoverCardTrigger,
|
|
226
220
|
} from "./hover-card.js";
|
|
221
|
+
// One door for icons: an inline <svg> fed by the host's icon source.
|
|
222
|
+
export { Icon, type IconData, type IconProps, type IconSource, provideIcons } from "./icon.js";
|
|
227
223
|
export { IconPicker, type IconPickerProps } from "./icon-picker.js";
|
|
228
224
|
export { ImagePicker, type ImagePickerProps } from "./image-picker.js";
|
|
229
225
|
export { Input } from "./input.js";
|
|
@@ -213,9 +213,9 @@ export function ListRow(props: ListRowProps) {
|
|
|
213
213
|
type SectionIconSize = "sm" | "md" | "lg";
|
|
214
214
|
|
|
215
215
|
const ICON_DIMENSIONS: Record<SectionIconSize, string> = {
|
|
216
|
-
sm: "size-7 [&>
|
|
217
|
-
md: "size-10 sm:size-11 [&>
|
|
218
|
-
lg: "size-12 sm:size-14 [&>
|
|
216
|
+
sm: "size-7 [&>[data-slot=icon]]:text-[16px]",
|
|
217
|
+
md: "size-10 sm:size-11 [&>[data-slot=icon]]:text-[20px] sm:[&>[data-slot=icon]]:text-[22px]",
|
|
218
|
+
lg: "size-12 sm:size-14 [&>[data-slot=icon]]:text-[24px] sm:[&>[data-slot=icon]]:text-[28px]",
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
/** @deprecated pass a CSS color to `tone` instead. */
|
package/src/solid/sonner.tsx
CHANGED
|
@@ -57,8 +57,6 @@ type GlassToastProps = {
|
|
|
57
57
|
const GlassToast: Component<GlassToastProps> = (props) => {
|
|
58
58
|
const tone = KIND_TONE[props.kind];
|
|
59
59
|
const toneIcon = KIND_ICON[props.kind];
|
|
60
|
-
// Explicit 112px (= the old [&>svg]:size-28) since host CSS can't reach the
|
|
61
|
-
// iconify shadow-DOM svg.
|
|
62
60
|
const watermarkGlyph: JSX.Element | null =
|
|
63
61
|
props.icon ?? (toneIcon ? <Icon icon={toneIcon} width={112} height={112} /> : null);
|
|
64
62
|
|
package/src/styles/globals.css
CHANGED
package/src/styles/theme.css
CHANGED
|
@@ -259,6 +259,17 @@
|
|
|
259
259
|
--duration-micro: 120ms;
|
|
260
260
|
--duration-state: 160ms;
|
|
261
261
|
--duration-expand: 200ms;
|
|
262
|
+
/* Ambient motion is an event (SPEC motion rule 5): 1 while the host holds
|
|
263
|
+
* html[data-motion="live"], else 0. Inherits into widget shadow roots, so a
|
|
264
|
+
* loop multiplies its duration by it: calc(var(--motion-ambient, 0) * 1s).
|
|
265
|
+
* --motion-play is its keyword twin for a loop that can only pause. */
|
|
266
|
+
--motion-ambient: 0;
|
|
267
|
+
--motion-play: paused;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
html[data-motion="live"] {
|
|
271
|
+
--motion-ambient: 1;
|
|
272
|
+
--motion-play: running;
|
|
262
273
|
}
|
|
263
274
|
|
|
264
275
|
.dark {
|