@glasshome/ui 1.39.0 → 1.41.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 +26 -4
- package/dist/index.js +1 -1
- package/dist/lib/overlay-classes.d.ts +1 -1
- package/dist/solid/alert-dialog.d.ts +10 -9
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +1 -5
- package/dist/solid/confirm-dialog.d.ts +22 -0
- package/dist/solid/dialog-parts.d.ts +27 -1
- package/dist/solid/dialog.d.ts +3 -6
- package/dist/solid/dock-edit.d.ts +1 -1
- package/dist/solid/dock.d.ts +6 -1
- package/dist/solid/docked-panel.d.ts +1 -5
- package/dist/solid/icon-nodes.d.ts +13 -0
- package/dist/solid/index.d.ts +6 -4
- package/dist/solid/index.js +5080 -4841
- package/dist/solid/responsive-dialog.d.ts +3 -6
- package/dist/solid/sheet.d.ts +1 -5
- package/dist/solid/tabs.d.ts +3 -1
- package/dist/solid/term.d.ts +14 -0
- package/dist/{utils-DXEj_oXa.js → utils-CGN4X-2O.js} +1 -1
- package/package.json +14 -3
- package/scripts/check-gallery.ts +22 -4
- package/src/lib/overlay-classes.ts +2 -4
- package/src/solid/alert-dialog.tsx +13 -0
- package/src/solid/alert.tsx +1 -1
- package/src/solid/confirm-dialog.tsx +62 -0
- package/src/solid/dialog-parts.tsx +51 -1
- package/src/solid/dialog.tsx +4 -0
- package/src/solid/dock-edit.tsx +11 -16
- package/src/solid/dock.tsx +115 -25
- package/src/solid/icon-nodes.ts +71 -0
- package/src/solid/icon.tsx +44 -39
- package/src/solid/image-picker.tsx +9 -9
- package/src/solid/index.ts +6 -1
- package/src/solid/option-card.tsx +1 -1
- package/src/solid/responsive-dialog.tsx +8 -1
- package/src/solid/select.tsx +7 -2
- package/src/solid/tabs.tsx +11 -10
- package/src/solid/term.tsx +51 -0
- package/src/solid/toggle-group.tsx +12 -5
- package/src/styles/globals.css +6 -2
- package/src/styles/theme.css +7 -5
package/src/solid/dock.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
children,
|
|
2
3
|
type Component,
|
|
3
4
|
type ComponentProps,
|
|
4
5
|
createEffect,
|
|
@@ -64,8 +65,13 @@ interface DockProps extends ComponentProps<"div"> {
|
|
|
64
65
|
onAdd?: () => void;
|
|
65
66
|
/** The full id order after a drag or an Alt+arrow move. */
|
|
66
67
|
onReorder?: (ids: string[]) => void;
|
|
67
|
-
/** While editing, a grip
|
|
68
|
+
/** While editing, a grip at the dock's start carries the whole dock to a screen edge; fires once on release over one. */
|
|
68
69
|
onMovePlacement?: (placement: DockPlacement) => void;
|
|
70
|
+
/** Sits inside the glass before the strip, never pages away; the strip's room shrinks by it. */
|
|
71
|
+
lead?: JSX.Element;
|
|
72
|
+
/** A second glass unit that grows out of the dock while `companionOpen`: above a bottom dock, under a side dock, which pages to make room. */
|
|
73
|
+
companion?: JSX.Element;
|
|
74
|
+
companionOpen?: boolean;
|
|
69
75
|
}
|
|
70
76
|
|
|
71
77
|
interface DockIconButtonProps extends ComponentProps<"button"> {
|
|
@@ -166,12 +172,21 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
166
172
|
"onAdd",
|
|
167
173
|
"onReorder",
|
|
168
174
|
"onMovePlacement",
|
|
175
|
+
"lead",
|
|
176
|
+
"companion",
|
|
177
|
+
"companionOpen",
|
|
169
178
|
]);
|
|
170
179
|
const placement = () => local.placement ?? "bottom";
|
|
171
180
|
const vertical = () => placement() !== "bottom";
|
|
181
|
+
const gripShown = () => Boolean(local.editing && local.onMovePlacement);
|
|
172
182
|
// The drain plays where the fill grew, so the point outlives the hold.
|
|
173
183
|
const [holdPoint, setHoldPoint] = createSignal({ x: 0, y: 0, r: 0 });
|
|
174
184
|
let surfaceRef: HTMLDivElement | undefined;
|
|
185
|
+
let dotsRef: HTMLDivElement | undefined;
|
|
186
|
+
let leadRef: HTMLDivElement | undefined;
|
|
187
|
+
let companionRef: HTMLDivElement | undefined;
|
|
188
|
+
const lead = children(() => local.lead);
|
|
189
|
+
const companion = children(() => local.companion);
|
|
175
190
|
createEffect(() => {
|
|
176
191
|
const h = local.hold;
|
|
177
192
|
if (!h) return;
|
|
@@ -254,7 +269,10 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
254
269
|
const availableSpan = () => {
|
|
255
270
|
const box = containerRef?.closest<HTMLElement>('[data-slot="dock"]');
|
|
256
271
|
if (!box || !surfaceRef) return 0;
|
|
257
|
-
|
|
272
|
+
const lead = leadRef ? (vertical() ? leadRef.offsetHeight : leadRef.offsetWidth) : 0;
|
|
273
|
+
// A side dock's companion stacks along the edge, so the strip gives up its height.
|
|
274
|
+
const companion = vertical() && local.companionOpen ? (companionRef?.offsetHeight ?? 0) : 0;
|
|
275
|
+
return viewSize(box) - padAlong(box) - padAlong(surfaceRef) - lead - companion;
|
|
258
276
|
};
|
|
259
277
|
|
|
260
278
|
const checkOverflow = () => {
|
|
@@ -307,11 +325,12 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
307
325
|
const inSurfaceAlong = vertical()
|
|
308
326
|
? point.y >= surface.top && point.y <= surface.bottom
|
|
309
327
|
: point.x >= surface.left && point.x <= surface.right;
|
|
328
|
+
const dots = dotsRef?.getBoundingClientRect();
|
|
310
329
|
const pastStrip =
|
|
311
330
|
place === "left"
|
|
312
|
-
? point.x
|
|
331
|
+
? point.x >= surface.left && point.x <= (dots?.right ?? strip.left)
|
|
313
332
|
: place === "right"
|
|
314
|
-
? point.x
|
|
333
|
+
? point.x <= surface.right && point.x >= (dots?.left ?? strip.right)
|
|
315
334
|
: point.y > strip.bottom && point.y <= surface.bottom;
|
|
316
335
|
if (!pastStrip || !inSurfaceAlong) return;
|
|
317
336
|
const ratio = vertical()
|
|
@@ -356,12 +375,38 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
356
375
|
});
|
|
357
376
|
});
|
|
358
377
|
|
|
378
|
+
// The companion's own content can change height while open, under a side dock that is the strip's room.
|
|
379
|
+
onMount(() => {
|
|
380
|
+
if (!companionRef) return;
|
|
381
|
+
let frame = 0;
|
|
382
|
+
const observer = new ResizeObserver(() => {
|
|
383
|
+
if (!vertical() || !local.companionOpen) return;
|
|
384
|
+
cancelAnimationFrame(frame);
|
|
385
|
+
frame = requestAnimationFrame(checkOverflow);
|
|
386
|
+
});
|
|
387
|
+
observer.observe(companionRef);
|
|
388
|
+
onCleanup(() => {
|
|
389
|
+
cancelAnimationFrame(frame);
|
|
390
|
+
observer.disconnect();
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
|
|
359
394
|
// The box pads by mode and the strip runs along the edge, so either switching changes the room it has.
|
|
360
395
|
createEffect(
|
|
361
|
-
on(
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
396
|
+
on(
|
|
397
|
+
[
|
|
398
|
+
() => local.items.length,
|
|
399
|
+
dockMode,
|
|
400
|
+
vertical,
|
|
401
|
+
() => Boolean(lead()),
|
|
402
|
+
() => local.companionOpen,
|
|
403
|
+
gripShown,
|
|
404
|
+
],
|
|
405
|
+
() => {
|
|
406
|
+
const frame = requestAnimationFrame(checkOverflow);
|
|
407
|
+
onCleanup(() => cancelAnimationFrame(frame));
|
|
408
|
+
},
|
|
409
|
+
),
|
|
365
410
|
);
|
|
366
411
|
|
|
367
412
|
return (
|
|
@@ -370,7 +415,7 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
370
415
|
data-placement={placement()}
|
|
371
416
|
class={cn(
|
|
372
417
|
"flex max-w-full items-center justify-center",
|
|
373
|
-
vertical()
|
|
418
|
+
vertical() ? "h-full max-h-full flex-col" : "flex-col-reverse",
|
|
374
419
|
dockMode() === "floating" ? "p-1 sm:p-2" : "",
|
|
375
420
|
local.class,
|
|
376
421
|
)}
|
|
@@ -382,17 +427,14 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
382
427
|
class={cn(
|
|
383
428
|
// isolate: the layers behind the icons stay inside the dock even with blur off.
|
|
384
429
|
"pointer-events-auto relative isolate flex max-w-full items-center justify-center p-1.5 sm:p-2",
|
|
385
|
-
vertical() && "max-h-full flex-col",
|
|
386
|
-
// A flush side dock runs the whole edge.
|
|
387
|
-
vertical() && dockMode() === "docked" && "
|
|
388
|
-
// Room for the page dots inside the glass; outside it they sit on
|
|
389
|
-
//
|
|
390
|
-
pages() > 1 &&
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
left: "pr-4 sm:pr-5",
|
|
394
|
-
right: "pl-4 sm:pl-5",
|
|
395
|
-
}[placement()],
|
|
430
|
+
vertical() && "max-h-full min-h-0 flex-col",
|
|
431
|
+
// A flush side dock runs the whole edge, less what the companion takes.
|
|
432
|
+
vertical() && dockMode() === "docked" && "flex-1",
|
|
433
|
+
// Room for the page dots inside the glass; outside it they sit on the screen edge and get
|
|
434
|
+
// clipped. A side dock's dots sit behind its icons, so paging never widens or shifts it.
|
|
435
|
+
pages() > 1 && placement() === "bottom" && "pb-4 sm:pb-5",
|
|
436
|
+
// The grip takes the start of the dock's length, so the items stay centred across it.
|
|
437
|
+
gripShown() && (vertical() ? "pt-5 sm:pt-6" : "pl-5 sm:pl-6"),
|
|
396
438
|
CARD_SURFACE,
|
|
397
439
|
"[--glass-lift:0.55]",
|
|
398
440
|
dockMode() === "floating"
|
|
@@ -429,6 +471,22 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
429
471
|
<div />
|
|
430
472
|
</div>
|
|
431
473
|
</Show>
|
|
474
|
+
<Show when={lead()}>
|
|
475
|
+
<div
|
|
476
|
+
ref={leadRef}
|
|
477
|
+
data-slot="dock-lead"
|
|
478
|
+
class={cn(
|
|
479
|
+
"flex shrink-0 items-center gap-0.5 sm:gap-1",
|
|
480
|
+
vertical() ? "flex-col pb-1 sm:pb-2" : "pr-1 sm:pr-2",
|
|
481
|
+
)}
|
|
482
|
+
>
|
|
483
|
+
{lead()}
|
|
484
|
+
<span
|
|
485
|
+
aria-hidden="true"
|
|
486
|
+
class={cn("bg-foreground/15 rounded-full", vertical() ? "h-px w-6" : "h-6 w-px")}
|
|
487
|
+
/>
|
|
488
|
+
</div>
|
|
489
|
+
</Show>
|
|
432
490
|
<div
|
|
433
491
|
ref={containerRef}
|
|
434
492
|
data-slot="dock-bar"
|
|
@@ -520,18 +578,20 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
520
578
|
</Show>
|
|
521
579
|
</SelectionScope>
|
|
522
580
|
</div>
|
|
523
|
-
<Show when={
|
|
581
|
+
<Show when={gripShown()}>
|
|
524
582
|
<DockMoveGrip placement={placement()} onMove={(next) => local.onMovePlacement?.(next)} />
|
|
525
583
|
</Show>
|
|
526
584
|
<Show when={pages() > 1}>
|
|
527
585
|
<div
|
|
586
|
+
ref={dotsRef}
|
|
528
587
|
data-slot="dock-pages"
|
|
529
588
|
class={cn(
|
|
530
589
|
"pointer-events-auto absolute flex justify-center gap-1.5",
|
|
531
590
|
{
|
|
532
591
|
bottom: "inset-x-0 bottom-1.5",
|
|
533
|
-
|
|
534
|
-
|
|
592
|
+
// 10px from the glass rim, which draws a 1px border.
|
|
593
|
+
left: "inset-y-0 left-[9px] -z-1 flex-col items-center",
|
|
594
|
+
right: "inset-y-0 right-[9px] -z-1 flex-col items-center",
|
|
535
595
|
}[placement()],
|
|
536
596
|
)}
|
|
537
597
|
>
|
|
@@ -544,10 +604,10 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
544
604
|
onClick={() => goToPage(i)}
|
|
545
605
|
class={cn(
|
|
546
606
|
"transition-glass rounded-full",
|
|
547
|
-
vertical() ? "w-1
|
|
607
|
+
vertical() ? "w-1" : "h-1.5",
|
|
548
608
|
page() === i
|
|
549
609
|
? cn("bg-foreground/70", vertical() ? "h-4" : "w-4")
|
|
550
|
-
: cn("bg-foreground/25", vertical() ? "h-1
|
|
610
|
+
: cn("bg-foreground/25", vertical() ? "h-1" : "w-1.5"),
|
|
551
611
|
)}
|
|
552
612
|
/>
|
|
553
613
|
)}
|
|
@@ -555,6 +615,36 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
555
615
|
</div>
|
|
556
616
|
</Show>
|
|
557
617
|
</div>
|
|
618
|
+
<Show when={companion()}>
|
|
619
|
+
<div
|
|
620
|
+
data-slot="dock-companion-reveal"
|
|
621
|
+
data-open={local.companionOpen ? "" : undefined}
|
|
622
|
+
aria-hidden={local.companionOpen ? undefined : "true"}
|
|
623
|
+
inert={!local.companionOpen}
|
|
624
|
+
class={cn(
|
|
625
|
+
"grid shrink-0 grid-rows-[0fr] opacity-0 transition-[grid-template-rows,opacity] duration-(--duration-micro) ease-(--ease-contract) data-[open]:grid-rows-[1fr] data-[open]:opacity-100 data-[open]:duration-(--duration-expand) data-[open]:ease-(--ease-expand)",
|
|
626
|
+
// Takes the dock's width instead of widening it.
|
|
627
|
+
vertical() && "self-stretch [contain:inline-size]",
|
|
628
|
+
)}
|
|
629
|
+
>
|
|
630
|
+
<div class="min-h-0 min-w-0 overflow-hidden">
|
|
631
|
+
<div ref={companionRef} class={vertical() ? "pt-2" : "px-2 pt-2 pb-1"}>
|
|
632
|
+
<div
|
|
633
|
+
data-slot="dock-companion"
|
|
634
|
+
data-placement={placement()}
|
|
635
|
+
class={cn(
|
|
636
|
+
"pointer-events-auto flex items-center gap-1 rounded-xl p-1.5",
|
|
637
|
+
vertical() ? "w-full flex-col" : "w-max",
|
|
638
|
+
CARD_SURFACE,
|
|
639
|
+
"[--glass-lift:0.55]",
|
|
640
|
+
)}
|
|
641
|
+
>
|
|
642
|
+
{companion()}
|
|
643
|
+
</div>
|
|
644
|
+
</div>
|
|
645
|
+
</div>
|
|
646
|
+
</div>
|
|
647
|
+
</Show>
|
|
558
648
|
</div>
|
|
559
649
|
);
|
|
560
650
|
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
interface TrustedPolicy {
|
|
2
|
+
createHTML(input: string): string;
|
|
3
|
+
}
|
|
4
|
+
let policy: TrustedPolicy | null | undefined;
|
|
5
|
+
|
|
6
|
+
// Icon bodies come from the build or the host's own icon route; under a
|
|
7
|
+
// require-trusted-types-for CSP the assignment still needs a policy.
|
|
8
|
+
export function trusted(html: string): string {
|
|
9
|
+
if (policy === undefined) {
|
|
10
|
+
const tt = (
|
|
11
|
+
globalThis as {
|
|
12
|
+
trustedTypes?: { createPolicy(name: string, rules: TrustedPolicy): TrustedPolicy };
|
|
13
|
+
}
|
|
14
|
+
).trustedTypes;
|
|
15
|
+
try {
|
|
16
|
+
policy = tt ? tt.createPolicy("glasshome-ui", { createHTML: (s) => s }) : null;
|
|
17
|
+
} catch {
|
|
18
|
+
policy = null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return policy ? policy.createHTML(html) : html;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
25
|
+
|
|
26
|
+
function parseBody(body: string): Element {
|
|
27
|
+
const holder = document.createElementNS(SVG_NAMESPACE, "svg");
|
|
28
|
+
holder.innerHTML = trusted(body);
|
|
29
|
+
return holder;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface BodyParseCache {
|
|
33
|
+
/** Fresh copies of the nodes `parse` makes for `body`; the caller owns them. */
|
|
34
|
+
nodes(body: string): Node[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Parses each distinct body once and hands every caller its own deep copy, so no two icons
|
|
39
|
+
* share a node. Holds at most `limit` bodies; past that the oldest is dropped and parsed again
|
|
40
|
+
* if asked for later. A `parse` that throws leaves nothing cached.
|
|
41
|
+
*/
|
|
42
|
+
export function createBodyParseCache(
|
|
43
|
+
limit: number,
|
|
44
|
+
parse: (body: string) => Element,
|
|
45
|
+
): BodyParseCache {
|
|
46
|
+
// A Map iterates in insertion order, so its first key is the oldest body.
|
|
47
|
+
const parsed = new Map<string, Element>();
|
|
48
|
+
return {
|
|
49
|
+
nodes(body) {
|
|
50
|
+
if (!body) return [];
|
|
51
|
+
let holder = parsed.get(body);
|
|
52
|
+
if (!holder) {
|
|
53
|
+
holder = parse(body);
|
|
54
|
+
if (parsed.size >= limit) {
|
|
55
|
+
const oldest = parsed.keys().next();
|
|
56
|
+
if (!oldest.done) parsed.delete(oldest.value);
|
|
57
|
+
}
|
|
58
|
+
parsed.set(body, holder);
|
|
59
|
+
}
|
|
60
|
+
return Array.from(holder.childNodes, (node) => node.cloneNode(true));
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const MAX_PARSED_BODIES = 512;
|
|
66
|
+
const bodies = createBodyParseCache(MAX_PARSED_BODIES, parseBody);
|
|
67
|
+
|
|
68
|
+
/** The nodes of one icon body, parsed once per distinct body. Needs a DOM. */
|
|
69
|
+
export function iconNodes(body: string): Node[] {
|
|
70
|
+
return bodies.nodes(body);
|
|
71
|
+
}
|
package/src/solid/icon.tsx
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import type { IconifyIcon } from "@iconify/types";
|
|
2
2
|
import { iconToSVG } from "@iconify/utils";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
batch,
|
|
5
|
+
createMemo,
|
|
6
|
+
createSignal,
|
|
7
|
+
type JSX,
|
|
8
|
+
mergeProps,
|
|
9
|
+
type Signal,
|
|
10
|
+
splitProps,
|
|
11
|
+
} from "solid-js";
|
|
12
|
+
import { isServer } from "solid-js/web";
|
|
13
|
+
import { iconNodes, trusted } from "./icon-nodes.js";
|
|
4
14
|
|
|
5
15
|
export type IconData = IconifyIcon;
|
|
6
16
|
|
|
@@ -85,29 +95,6 @@ function lookup(name: string): IconData | undefined {
|
|
|
85
95
|
return undefined;
|
|
86
96
|
}
|
|
87
97
|
|
|
88
|
-
interface TrustedPolicy {
|
|
89
|
-
createHTML(input: string): string;
|
|
90
|
-
}
|
|
91
|
-
let policy: TrustedPolicy | null | undefined;
|
|
92
|
-
|
|
93
|
-
// Icon bodies come from the build or the host's own icon route; under a
|
|
94
|
-
// require-trusted-types-for CSP the assignment still needs a policy.
|
|
95
|
-
function trusted(html: string): string {
|
|
96
|
-
if (policy === undefined) {
|
|
97
|
-
const tt = (
|
|
98
|
-
globalThis as {
|
|
99
|
-
trustedTypes?: { createPolicy(name: string, rules: TrustedPolicy): TrustedPolicy };
|
|
100
|
-
}
|
|
101
|
-
).trustedTypes;
|
|
102
|
-
try {
|
|
103
|
-
policy = tt ? tt.createPolicy("glasshome-ui", { createHTML: (s) => s }) : null;
|
|
104
|
-
} catch {
|
|
105
|
-
policy = null;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return policy ? policy.createHTML(html) : html;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
98
|
export interface IconProps extends Omit<
|
|
112
99
|
JSX.SvgSVGAttributes<SVGSVGElement>,
|
|
113
100
|
"width" | "height" | "children"
|
|
@@ -134,22 +121,40 @@ export function Icon(props: IconProps) {
|
|
|
134
121
|
return iconToSVG(data, size);
|
|
135
122
|
});
|
|
136
123
|
const body = createMemo(() => built().body);
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
xmlns
|
|
142
|
-
data-slot
|
|
143
|
-
data-icon
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
{
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
124
|
+
const named = () =>
|
|
125
|
+
rest["aria-label"] != null || rest["aria-labelledby"] != null || rest.role != null;
|
|
126
|
+
const shell = mergeProps(
|
|
127
|
+
{
|
|
128
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
129
|
+
"data-slot": "icon",
|
|
130
|
+
get "data-icon"() {
|
|
131
|
+
return local.icon;
|
|
132
|
+
},
|
|
133
|
+
get "aria-hidden"() {
|
|
134
|
+
return named() ? undefined : ("true" as const);
|
|
135
|
+
},
|
|
136
|
+
fill: "currentColor",
|
|
137
|
+
},
|
|
138
|
+
rest,
|
|
139
|
+
{
|
|
140
|
+
get viewBox() {
|
|
141
|
+
return built().attributes.viewBox;
|
|
142
|
+
},
|
|
143
|
+
get width() {
|
|
144
|
+
return built().attributes.width;
|
|
145
|
+
},
|
|
146
|
+
get height() {
|
|
147
|
+
return built().attributes.height;
|
|
148
|
+
},
|
|
149
|
+
},
|
|
152
150
|
);
|
|
151
|
+
if (isServer) {
|
|
152
|
+
// A TrustedHTML is a fresh object per call, which the spread would write as a new innerHTML.
|
|
153
|
+
const html = createMemo(() => trusted(body()));
|
|
154
|
+
return <svg {...shell} innerHTML={html()} />;
|
|
155
|
+
}
|
|
156
|
+
const nodes = createMemo(() => iconNodes(body()));
|
|
157
|
+
return <svg {...shell}>{nodes()}</svg>;
|
|
153
158
|
}
|
|
154
159
|
|
|
155
160
|
function sizeOrDefault(size: { width: string | null; height: string | null }) {
|
|
@@ -18,10 +18,8 @@ import {
|
|
|
18
18
|
AlertDialogAction,
|
|
19
19
|
AlertDialogCancel,
|
|
20
20
|
AlertDialogContent,
|
|
21
|
-
AlertDialogDescription,
|
|
22
21
|
AlertDialogFooter,
|
|
23
|
-
|
|
24
|
-
AlertDialogTitle,
|
|
22
|
+
AlertDialogHead,
|
|
25
23
|
} from "./alert-dialog.js";
|
|
26
24
|
import { Badge } from "./badge.js";
|
|
27
25
|
import { Button } from "./button.js";
|
|
@@ -180,8 +178,8 @@ function ImageGallery(
|
|
|
180
178
|
const deleteDescription = createMemo(() => {
|
|
181
179
|
const used = pendingDelete()?.usedBy ?? 0;
|
|
182
180
|
return used === 0
|
|
183
|
-
? "
|
|
184
|
-
:
|
|
181
|
+
? "No widget uses it."
|
|
182
|
+
: `${used} widget${used === 1 ? "" : "s"} will lose the image.`;
|
|
185
183
|
});
|
|
186
184
|
|
|
187
185
|
const chosenPreset = () => {
|
|
@@ -516,10 +514,12 @@ function ImageGallery(
|
|
|
516
514
|
} else holdFocus();
|
|
517
515
|
}}
|
|
518
516
|
>
|
|
519
|
-
<
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
517
|
+
<AlertDialogHead
|
|
518
|
+
icon="lucide:image-off"
|
|
519
|
+
tone="var(--destructive)"
|
|
520
|
+
title="Delete image?"
|
|
521
|
+
line={deleteDescription()}
|
|
522
|
+
/>
|
|
523
523
|
<AlertDialogFooter>
|
|
524
524
|
<AlertDialogCancel aria-label="Cancel">Cancel</AlertDialogCancel>
|
|
525
525
|
<AlertDialogAction
|
package/src/solid/index.ts
CHANGED
|
@@ -29,6 +29,7 @@ export {
|
|
|
29
29
|
AlertDialogContent,
|
|
30
30
|
AlertDialogDescription,
|
|
31
31
|
AlertDialogFooter,
|
|
32
|
+
AlertDialogHead,
|
|
32
33
|
AlertDialogHeader,
|
|
33
34
|
AlertDialogTitle,
|
|
34
35
|
AlertDialogTrigger,
|
|
@@ -148,11 +149,13 @@ export {
|
|
|
148
149
|
DialogContent,
|
|
149
150
|
DialogDescription,
|
|
150
151
|
DialogFooter,
|
|
152
|
+
DialogHead,
|
|
151
153
|
DialogHeader,
|
|
152
154
|
DialogTitle,
|
|
153
155
|
DialogTrigger,
|
|
154
156
|
} from "./dialog.js";
|
|
155
|
-
export type
|
|
157
|
+
export { ConfirmDialog, type ConfirmDialogProps } from "./confirm-dialog.js";
|
|
158
|
+
export type { ModalHeadProps, ModalMedia, ModalSize } from "./dialog-parts.js";
|
|
156
159
|
export type { DockIconButtonProps, DockItem, DockPlacement, DockProps } from "./dock.js";
|
|
157
160
|
export { Dock } from "./dock.js";
|
|
158
161
|
export {
|
|
@@ -315,6 +318,7 @@ export {
|
|
|
315
318
|
ResponsiveDialogContent,
|
|
316
319
|
ResponsiveDialogDescription,
|
|
317
320
|
ResponsiveDialogFooter,
|
|
321
|
+
ResponsiveDialogHead,
|
|
318
322
|
ResponsiveDialogHeader,
|
|
319
323
|
ResponsiveDialogTitle,
|
|
320
324
|
ResponsiveDialogTrigger,
|
|
@@ -396,6 +400,7 @@ export {
|
|
|
396
400
|
TableRow,
|
|
397
401
|
} from "./table.js";
|
|
398
402
|
export { Tabs, TabsContent, TabsList, TabsTrigger } from "./tabs.js";
|
|
403
|
+
export { Term, type TermDefinition } from "./term.js";
|
|
399
404
|
export { Textarea } from "./textarea.js";
|
|
400
405
|
export { Toggle, toggleVariants } from "./toggle.js";
|
|
401
406
|
export { ToggleGroup, ToggleGroupItem } from "./toggle-group.js";
|
|
@@ -31,7 +31,7 @@ const OPTION_CHOICE_ROW =
|
|
|
31
31
|
"rounded-sm text-foreground/75 transition-colors hover:bg-foreground/5 aria-checked:text-foreground";
|
|
32
32
|
|
|
33
33
|
const OPTION_CARD_DRAWER_CONTENT =
|
|
34
|
-
"-translate-y-2 flex flex-col gap-0.5 pr-1 pb-2 pl-[calc(var(--spacing)*3.5+54px)] opacity-0 transition-[opacity,translate] duration-(--duration-expand) ease-(--ease-morph) group-data-[checked]/option-card:translate-y-0 group-data-[checked]/option-card:opacity-100 group-data-[checked]/option-card:delay-[80ms]";
|
|
34
|
+
"-translate-y-2 flex flex-col gap-0.5 pr-1 pb-2 pl-[calc(var(--spacing)*3.5+54px)] opacity-0 transition-[opacity,translate] duration-(--duration-expand) ease-(--ease-morph) group-data-[checked]/option-card:translate-y-0 group-data-[checked]/option-card:opacity-100 group-data-[checked]/option-card:delay-[var(--stagger-base,80ms)]";
|
|
35
35
|
|
|
36
36
|
/* Sub-options are rows of the card, chosen in place: the same row a picker
|
|
37
37
|
* list shows, flat on the card (a glass pill on a glass card is a layer too
|
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
} from "./bottom-sheet/index.js";
|
|
26
26
|
import { Button } from "./button.js";
|
|
27
27
|
import { Dialog, DialogContent, DialogDescription, DialogTitle, DialogTrigger } from "./dialog.js";
|
|
28
|
-
import { createModalParts, type ModalSize } from "./dialog-parts.js";
|
|
28
|
+
import { createModalHead, createModalParts, type ModalSize } from "./dialog-parts.js";
|
|
29
29
|
|
|
30
30
|
interface ResponsiveDialogContextValue {
|
|
31
31
|
open: () => boolean;
|
|
@@ -153,6 +153,12 @@ const ResponsiveDialogDescription: Component<ComponentProps<"p">> = (props) => {
|
|
|
153
153
|
);
|
|
154
154
|
};
|
|
155
155
|
|
|
156
|
+
const ResponsiveDialogHead = createModalHead(
|
|
157
|
+
ResponsiveDialogHeader,
|
|
158
|
+
ResponsiveDialogTitle,
|
|
159
|
+
ResponsiveDialogDescription,
|
|
160
|
+
);
|
|
161
|
+
|
|
156
162
|
/** Defaults to the footer's outline button; an icon-only close passes `ghost`
|
|
157
163
|
* so the glyph is not boxed. */
|
|
158
164
|
const ResponsiveDialogClose: ParentComponent<
|
|
@@ -182,6 +188,7 @@ export {
|
|
|
182
188
|
ResponsiveDialogContent,
|
|
183
189
|
ResponsiveDialogDescription,
|
|
184
190
|
ResponsiveDialogFooter,
|
|
191
|
+
ResponsiveDialogHead,
|
|
185
192
|
ResponsiveDialogHeader,
|
|
186
193
|
ResponsiveDialogTitle,
|
|
187
194
|
ResponsiveDialogTrigger,
|
package/src/solid/select.tsx
CHANGED
|
@@ -69,6 +69,7 @@ const SelectContent: ParentComponent<
|
|
|
69
69
|
]);
|
|
70
70
|
const select = useSelectContext();
|
|
71
71
|
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
72
|
+
const [list, setList] = createSignal<HTMLElement>();
|
|
72
73
|
const layer = shadowLayer({
|
|
73
74
|
content: panel,
|
|
74
75
|
open: () => select.isOpen(),
|
|
@@ -98,11 +99,15 @@ const SelectContent: ParentComponent<
|
|
|
98
99
|
{...rest}
|
|
99
100
|
>
|
|
100
101
|
<SelectionScope
|
|
101
|
-
ref={
|
|
102
|
+
ref={(el: HTMLElement) => {
|
|
103
|
+
ignoreOpeningRelease(el);
|
|
104
|
+
setList(el);
|
|
105
|
+
}}
|
|
102
106
|
marker="highlighted"
|
|
103
107
|
class={cn("w-full", PICKER_LIST)}
|
|
104
108
|
>
|
|
105
|
-
|
|
109
|
+
{/* Kobalte scrolls its scrollRef to the highlighted option; the scope is what scrolls. */}
|
|
110
|
+
<SelectPrimitive.Listbox scrollRef={list} class={cn(STAGGER, local.listboxClass)} />
|
|
106
111
|
</SelectionScope>
|
|
107
112
|
</SelectPrimitive.Content>
|
|
108
113
|
</SelectPrimitive.Portal>
|
package/src/solid/tabs.tsx
CHANGED
|
@@ -57,19 +57,20 @@ const TabsList: Component<ComponentProps<typeof TabsPrimitive.List>> = (props) =
|
|
|
57
57
|
);
|
|
58
58
|
};
|
|
59
59
|
|
|
60
|
-
/** `icon` stacks a glyph over the word, so a tab row reads apart from the toggle groups under it.
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
/** `icon` stacks a glyph over the word, so a tab row reads apart from the toggle groups under it.
|
|
61
|
+
* `inline` sets the glyph beside the word instead, for a row that stands alone. */
|
|
62
|
+
const TabsTrigger: Component<
|
|
63
|
+
ComponentProps<typeof TabsPrimitive.Trigger> & { icon?: string; inline?: boolean }
|
|
64
|
+
> = (props) => {
|
|
65
|
+
const [local, others] = splitProps(props, ["class", "icon", "inline", "children"]);
|
|
65
66
|
return (
|
|
66
67
|
<TabsPrimitive.Trigger
|
|
67
68
|
data-slot="tabs-trigger"
|
|
68
69
|
class={cn(
|
|
69
70
|
SEGMENT_ITEM,
|
|
70
71
|
PRESS_DIP,
|
|
71
|
-
"
|
|
72
|
-
local.icon && "h-auto flex-1 flex-col gap-1 py-2 text-xs",
|
|
72
|
+
"not-data-[selected]:hover:text-foreground relative isolate data-[selected]:text-(--material-accent)",
|
|
73
|
+
local.icon && !local.inline && "h-auto flex-1 flex-col gap-1 py-2 text-xs",
|
|
73
74
|
local.class,
|
|
74
75
|
)}
|
|
75
76
|
{...others}
|
|
@@ -77,10 +78,10 @@ const TabsTrigger: Component<ComponentProps<typeof TabsPrimitive.Trigger> & { ic
|
|
|
77
78
|
<SelectionHighlight />
|
|
78
79
|
{local.icon && (
|
|
79
80
|
<Icon
|
|
80
|
-
data-slot="tabs-trigger-icon"
|
|
81
|
+
data-slot={local.inline ? "tabs-trigger-inline-icon" : "tabs-trigger-icon"}
|
|
81
82
|
icon={local.icon}
|
|
82
|
-
width={18}
|
|
83
|
-
height={18}
|
|
83
|
+
width={local.inline ? 16 : 18}
|
|
84
|
+
height={local.inline ? 16 : 18}
|
|
84
85
|
aria-hidden="true"
|
|
85
86
|
/>
|
|
86
87
|
)}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Popover as PopoverPrimitive } from "@kobalte/core/popover";
|
|
2
|
+
import { type JSX, Show } from "solid-js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
import { Icon } from "./icon.js";
|
|
5
|
+
import { Popover, PopoverContent } from "./popover.js";
|
|
6
|
+
import { SectionIcon } from "./section-card.js";
|
|
7
|
+
|
|
8
|
+
export interface TermDefinition {
|
|
9
|
+
icon: string;
|
|
10
|
+
title: string;
|
|
11
|
+
/** One sentence a homeowner reads in a glance. */
|
|
12
|
+
line: string;
|
|
13
|
+
href?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** A word a homeowner may not know; tapping it explains it in place. */
|
|
17
|
+
export function Term(props: { term: TermDefinition; children?: JSX.Element; class?: string }) {
|
|
18
|
+
return (
|
|
19
|
+
<Popover>
|
|
20
|
+
<PopoverPrimitive.Trigger
|
|
21
|
+
data-slot="term"
|
|
22
|
+
class={cn(
|
|
23
|
+
"decoration-muted-foreground/60 hover:decoration-foreground cursor-help underline decoration-dotted underline-offset-4 outline-none focus-visible:rounded-sm focus-visible:ring-2 focus-visible:ring-[var(--material-accent)]",
|
|
24
|
+
props.class,
|
|
25
|
+
)}
|
|
26
|
+
>
|
|
27
|
+
{props.children ?? props.term.title}
|
|
28
|
+
</PopoverPrimitive.Trigger>
|
|
29
|
+
<PopoverContent class="flex w-72 items-start gap-3 text-left">
|
|
30
|
+
<SectionIcon icon={props.term.icon} tone="var(--material-accent)" size="sm" />
|
|
31
|
+
<div class="flex min-w-0 flex-col gap-1">
|
|
32
|
+
<span class="text-foreground text-sm font-semibold">{props.term.title}</span>
|
|
33
|
+
<span class="text-muted-foreground text-xs leading-snug">{props.term.line}</span>
|
|
34
|
+
<Show when={props.term.href}>
|
|
35
|
+
{(href) => (
|
|
36
|
+
<a
|
|
37
|
+
href={href()}
|
|
38
|
+
target="_blank"
|
|
39
|
+
rel="noopener noreferrer"
|
|
40
|
+
class="text-primary-tint-foreground mt-1 inline-flex items-center gap-1 self-start text-xs font-medium underline-offset-4 hover:underline"
|
|
41
|
+
>
|
|
42
|
+
Learn more
|
|
43
|
+
<Icon icon="lucide:arrow-up-right" width={12} height={12} />
|
|
44
|
+
</a>
|
|
45
|
+
)}
|
|
46
|
+
</Show>
|
|
47
|
+
</div>
|
|
48
|
+
</PopoverContent>
|
|
49
|
+
</Popover>
|
|
50
|
+
);
|
|
51
|
+
}
|