@glasshome/ui 1.34.2 → 1.35.1
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/solid/index.js +4029 -3949
- package/dist/solid/radio-group.d.ts +2 -1
- package/dist/solid/section-card.d.ts +2 -0
- package/dist/solid/settings-row.d.ts +4 -0
- package/dist/testing/happy-dom-fidelity.d.ts +2 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.js +64 -1
- package/dist/{utils-GYi7-pG_.js → utils-BhU5YZKh.js} +1 -0
- package/package.json +4 -3
- package/src/lib/clipboard.ts +2 -0
- package/src/solid/alert.tsx +36 -18
- package/src/solid/area-picker.tsx +9 -1
- package/src/solid/bottom-sheet/scroll-lock.ts +2 -0
- package/src/solid/checkbox.tsx +22 -7
- package/src/solid/data-table.tsx +16 -10
- package/src/solid/dialog-parts.tsx +7 -4
- package/src/solid/field.tsx +9 -5
- package/src/solid/icon.tsx +4 -1
- package/src/solid/image-picker.tsx +8 -1
- package/src/solid/option-card.tsx +4 -2
- package/src/solid/page-header.tsx +10 -7
- package/src/solid/password-input.tsx +5 -3
- package/src/solid/picker-row.tsx +14 -5
- package/src/solid/picker-search.tsx +9 -2
- package/src/solid/preview-tile.tsx +4 -2
- package/src/solid/radio-group.tsx +27 -7
- package/src/solid/schema-form.tsx +16 -3
- package/src/solid/section-card.tsx +42 -23
- package/src/solid/settings-row.tsx +20 -6
- package/src/solid/sheet.tsx +11 -7
- package/src/solid/sonner.tsx +17 -7
- package/src/solid/widget-card.tsx +5 -4
- package/src/styles/globals.css +32 -0
- package/src/styles/theme.css +1 -1
- package/src/testing/happy-dom-fidelity.ts +105 -0
- package/src/testing/index.ts +1 -0
|
@@ -4,4 +4,5 @@ declare const RadioGroup: Component<ComponentProps<typeof RadioGroupPrimitive>>;
|
|
|
4
4
|
declare const RadioGroupItem: Component<ComponentProps<typeof RadioGroupPrimitive.Item> & {
|
|
5
5
|
showControl?: boolean;
|
|
6
6
|
}>;
|
|
7
|
-
|
|
7
|
+
declare function isItemActivation(event: MouseEvent): boolean;
|
|
8
|
+
export { isItemActivation, RadioGroup, RadioGroupItem };
|
|
@@ -39,6 +39,8 @@ type ListRowProps = {
|
|
|
39
39
|
href?: string;
|
|
40
40
|
/** Accessible name for the whole-row activation; required with href or onOpen. */
|
|
41
41
|
openLabel?: string;
|
|
42
|
+
/** Title and subtitle wrap to show a whole sentence instead of truncating. */
|
|
43
|
+
wrap?: boolean;
|
|
42
44
|
class?: string;
|
|
43
45
|
};
|
|
44
46
|
/**
|
|
@@ -16,9 +16,13 @@ export declare function RowActions(props: {
|
|
|
16
16
|
deleteDisabled?: boolean;
|
|
17
17
|
deleteTitle?: string;
|
|
18
18
|
showDelete?: boolean;
|
|
19
|
+
/** What the row is, so each button is named for it: "Edit Kitchen", "Delete Kitchen". */
|
|
20
|
+
name?: string;
|
|
19
21
|
}): JSX.Element;
|
|
22
|
+
/** `for` names one control by the label; without it the label names the group of controls. */
|
|
20
23
|
export declare function LabeledField(props: {
|
|
21
24
|
label: string;
|
|
25
|
+
for?: string;
|
|
22
26
|
children: JSX.Element;
|
|
23
27
|
}): JSX.Element;
|
|
24
28
|
export declare function LabeledIconPicker(props: {
|
package/dist/testing/index.d.ts
CHANGED
package/dist/testing/index.js
CHANGED
|
@@ -36,4 +36,67 @@ function o() {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
//#endregion
|
|
39
|
-
|
|
39
|
+
//#region src/testing/happy-dom-fidelity.ts
|
|
40
|
+
var s = Symbol.for("glasshome.happyDomFidelity"), c = Symbol.for("glasshome.shadowRoots");
|
|
41
|
+
function l(e, t) {
|
|
42
|
+
let n = Reflect.getOwnPropertyDescriptor(e, t)?.get;
|
|
43
|
+
if (typeof n != "function") throw Error(`happy-dom's Event has no ${t} getter`);
|
|
44
|
+
return (e) => Reflect.apply(n, e, []);
|
|
45
|
+
}
|
|
46
|
+
function u(e) {
|
|
47
|
+
let t = [];
|
|
48
|
+
for (let n = e instanceof Node ? e.getRootNode() : void 0; n instanceof ShadowRoot; n = n.host.getRootNode()) t.push(n);
|
|
49
|
+
return t;
|
|
50
|
+
}
|
|
51
|
+
function d(e, t) {
|
|
52
|
+
let n = u(t), r = e;
|
|
53
|
+
for (; r instanceof Node;) {
|
|
54
|
+
let e = r.getRootNode();
|
|
55
|
+
if (!(e instanceof ShadowRoot) || n.includes(e)) return r;
|
|
56
|
+
r = e.host;
|
|
57
|
+
}
|
|
58
|
+
return r;
|
|
59
|
+
}
|
|
60
|
+
function f(e, t) {
|
|
61
|
+
let n = u(t);
|
|
62
|
+
return u(e).some((e) => e.mode === "closed" && !n.includes(e));
|
|
63
|
+
}
|
|
64
|
+
function p() {
|
|
65
|
+
let e = Object.getOwnPropertySymbols(new Event("probe")).find((e) => e.description === "dispatching");
|
|
66
|
+
if (!e) throw Error("happy-dom's Event has no dispatching flag");
|
|
67
|
+
return (t) => Reflect.get(t, e) === !0;
|
|
68
|
+
}
|
|
69
|
+
function m() {
|
|
70
|
+
let e = Event.prototype, t = Reflect.get(e, "composedPath"), n = l(e, "target"), r = l(e, "currentTarget"), i = p();
|
|
71
|
+
e.composedPath = function() {
|
|
72
|
+
if (!i(this)) return [];
|
|
73
|
+
let e = t.call(this), n = r(this);
|
|
74
|
+
return n ? e.filter((e) => !f(e, n)) : e;
|
|
75
|
+
}, Object.defineProperty(e, "target", {
|
|
76
|
+
configurable: !0,
|
|
77
|
+
get() {
|
|
78
|
+
let e = n(this), t = r(this);
|
|
79
|
+
return t ? d(e, t) : i(this) ? e : !this.composed && u(e).length > 0 ? null : d(e, null);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function h() {
|
|
84
|
+
let e = /* @__PURE__ */ new WeakMap();
|
|
85
|
+
Element.prototype[c] = e;
|
|
86
|
+
let t = Reflect.get(Element.prototype, "attachShadow");
|
|
87
|
+
Element.prototype.attachShadow = function(n) {
|
|
88
|
+
let r = t.call(this, n);
|
|
89
|
+
return e.set(this, r), r;
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function g() {
|
|
93
|
+
let e = Event.prototype;
|
|
94
|
+
e[s] || (e[s] = !0, m(), h());
|
|
95
|
+
}
|
|
96
|
+
function _(e) {
|
|
97
|
+
let t = Element.prototype[c];
|
|
98
|
+
if (!t) throw Error("shadowOf needs installHappyDomFidelity() in the suite's setup");
|
|
99
|
+
return e ? t.get(e) : void 0;
|
|
100
|
+
}
|
|
101
|
+
//#endregion
|
|
102
|
+
export { o as installDenyFetch, g as installHappyDomFidelity, r as installSettledAnimations, _ as shadowOf, i as useFakeTime, a as useSystemTime };
|
|
@@ -181,6 +181,7 @@ function xe() {
|
|
|
181
181
|
return typeof ClipboardItem < "u" && typeof navigator.clipboard?.write == "function";
|
|
182
182
|
}
|
|
183
183
|
async function Se(e, t) {
|
|
184
|
+
t.catch(() => {});
|
|
184
185
|
try {
|
|
185
186
|
return await navigator.clipboard.write([new ClipboardItem({ [e]: t })]), !0;
|
|
186
187
|
} catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glasshome/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.35.1",
|
|
4
4
|
"description": "SolidJS component library for GlassHome, built on Kobalte",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|
|
@@ -112,19 +112,20 @@
|
|
|
112
112
|
"@tailwindcss/vite": "^4.1.13",
|
|
113
113
|
"@types/bun": "^1.4.0",
|
|
114
114
|
"@types/node": "^25.2.2",
|
|
115
|
+
"@vitest/browser-playwright": "4.1.11",
|
|
115
116
|
"fallow": "3.17.0",
|
|
116
117
|
"happy-dom": "^20.14.0",
|
|
117
118
|
"oxfmt": "0.65.0",
|
|
118
119
|
"oxlint": "1.81.0",
|
|
119
120
|
"oxlint-tsgolint": "7.0.2001",
|
|
120
|
-
"playwright": "
|
|
121
|
+
"playwright": "1.63.0",
|
|
121
122
|
"publint": "^0.3.21",
|
|
122
123
|
"tailwindcss": "^4.1.13",
|
|
123
124
|
"tw-animate-css": "^1.4.0",
|
|
124
125
|
"typescript": "^7.0.2",
|
|
125
126
|
"vite": "^8.1.0",
|
|
126
127
|
"vite-plugin-solid": "^2.11.12",
|
|
127
|
-
"vitest": "
|
|
128
|
+
"vitest": "4.1.11"
|
|
128
129
|
},
|
|
129
130
|
"peerDependencies": {
|
|
130
131
|
"solid-js": "^1.9.9",
|
package/src/lib/clipboard.ts
CHANGED
|
@@ -41,6 +41,8 @@ function canWriteItems(): boolean {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
async function writeItem(type: string, data: Promise<Blob>): Promise<boolean> {
|
|
44
|
+
// A write refused before it reads the data leaves a rejecting data promise unhandled.
|
|
45
|
+
data.catch(() => {});
|
|
44
46
|
try {
|
|
45
47
|
await navigator.clipboard.write([new ClipboardItem({ [type]: data })]);
|
|
46
48
|
return true;
|
package/src/solid/alert.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
children,
|
|
2
3
|
type Component,
|
|
3
4
|
type ComponentProps,
|
|
4
5
|
createContext,
|
|
@@ -40,6 +41,32 @@ type AlertProps = ComponentProps<"div"> & {
|
|
|
40
41
|
// parent had already resolved.
|
|
41
42
|
const AlertToneContext = createContext<() => string>();
|
|
42
43
|
|
|
44
|
+
// Its own component so title and children resolve under AlertToneContext.
|
|
45
|
+
const AlertBody: Component<{ title?: JSX.Element; toneColor: string; children?: JSX.Element }> = (
|
|
46
|
+
props,
|
|
47
|
+
) => {
|
|
48
|
+
const title = children(() => props.title);
|
|
49
|
+
const body = children(() => props.children);
|
|
50
|
+
return (
|
|
51
|
+
<>
|
|
52
|
+
<Show when={title()}>
|
|
53
|
+
<p
|
|
54
|
+
data-slot="alert-title"
|
|
55
|
+
class={ALERT_TITLE_CLASS}
|
|
56
|
+
style={{ color: glassToneText(props.toneColor) }}
|
|
57
|
+
>
|
|
58
|
+
{title()}
|
|
59
|
+
</p>
|
|
60
|
+
</Show>
|
|
61
|
+
<Show when={body()}>
|
|
62
|
+
<div data-slot="alert-description" class={ALERT_DESCRIPTION_CLASS}>
|
|
63
|
+
{body()}
|
|
64
|
+
</div>
|
|
65
|
+
</Show>
|
|
66
|
+
</>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
|
|
43
70
|
const Alert: Component<AlertProps> = (props) => {
|
|
44
71
|
const [local, rest] = splitProps(props, [
|
|
45
72
|
"class",
|
|
@@ -52,6 +79,8 @@ const Alert: Component<AlertProps> = (props) => {
|
|
|
52
79
|
]);
|
|
53
80
|
const toneKey = () => local.tone ?? "info";
|
|
54
81
|
const tone = () => ALERT_TONES[toneKey()];
|
|
82
|
+
const icon = children(() => local.icon);
|
|
83
|
+
const action = children(() => local.action);
|
|
55
84
|
return (
|
|
56
85
|
<div
|
|
57
86
|
data-slot="alert"
|
|
@@ -68,7 +97,7 @@ const Alert: Component<AlertProps> = (props) => {
|
|
|
68
97
|
>
|
|
69
98
|
<span class={ALERT_ICON_BG_CLASS} style={alertIconBgStyle(tone().color)} aria-hidden="true">
|
|
70
99
|
<Show
|
|
71
|
-
when={
|
|
100
|
+
when={icon()}
|
|
72
101
|
fallback={
|
|
73
102
|
<svg
|
|
74
103
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -82,31 +111,20 @@ const Alert: Component<AlertProps> = (props) => {
|
|
|
82
111
|
/>
|
|
83
112
|
}
|
|
84
113
|
>
|
|
85
|
-
{
|
|
114
|
+
{icon()}
|
|
86
115
|
</Show>
|
|
87
116
|
</span>
|
|
88
117
|
<div class={ALERT_CONTENT_CLASS}>
|
|
89
118
|
<AlertToneContext.Provider value={() => tone().color}>
|
|
90
|
-
<
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
class={ALERT_TITLE_CLASS}
|
|
94
|
-
style={{ color: glassToneText(tone().color) }}
|
|
95
|
-
>
|
|
96
|
-
{local.title}
|
|
97
|
-
</p>
|
|
98
|
-
</Show>
|
|
99
|
-
<Show when={local.children}>
|
|
100
|
-
<div data-slot="alert-description" class={ALERT_DESCRIPTION_CLASS}>
|
|
101
|
-
{local.children}
|
|
102
|
-
</div>
|
|
103
|
-
</Show>
|
|
119
|
+
<AlertBody title={local.title} toneColor={tone().color}>
|
|
120
|
+
{local.children}
|
|
121
|
+
</AlertBody>
|
|
104
122
|
</AlertToneContext.Provider>
|
|
105
123
|
</div>
|
|
106
|
-
<Show when={
|
|
124
|
+
<Show when={action()}>
|
|
107
125
|
{/* self-center: the row is items-start for the icon, which would strand
|
|
108
126
|
the action at the top of a multi-line body. */}
|
|
109
|
-
<div class="flex shrink-0 items-center self-center">{
|
|
127
|
+
<div class="flex shrink-0 items-center self-center">{action()}</div>
|
|
110
128
|
</Show>
|
|
111
129
|
</div>
|
|
112
130
|
);
|
|
@@ -42,6 +42,7 @@ export function AreaPicker(props: AreaPickerProps) {
|
|
|
42
42
|
const data = useEntityData();
|
|
43
43
|
const [open, setOpen] = createSignal(false);
|
|
44
44
|
const [search, setSearch] = createSignal("");
|
|
45
|
+
let searchRef: HTMLInputElement | undefined;
|
|
45
46
|
|
|
46
47
|
const areas = data.useAreas();
|
|
47
48
|
|
|
@@ -171,11 +172,18 @@ export function AreaPicker(props: AreaPickerProps) {
|
|
|
171
172
|
</PickerTrigger>
|
|
172
173
|
</PopoverAnchor>
|
|
173
174
|
<PopoverContent
|
|
174
|
-
onOpenAutoFocus={(e) =>
|
|
175
|
+
onOpenAutoFocus={(e) => {
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
// preventScroll: the panel is portalled at (0,0) until the popper places it.
|
|
178
|
+
searchRef?.focus({ preventScroll: true });
|
|
179
|
+
}}
|
|
175
180
|
onInteractOutside={() => setOpen(false)}
|
|
176
181
|
>
|
|
177
182
|
<div class="flex flex-col">
|
|
178
183
|
<PickerSearch
|
|
184
|
+
inputRef={(el) => {
|
|
185
|
+
searchRef = el;
|
|
186
|
+
}}
|
|
179
187
|
value={search()}
|
|
180
188
|
onValueChange={setSearch}
|
|
181
189
|
placeholder="Search areas..."
|
|
@@ -20,6 +20,7 @@ export function acquireScrollLock(): void {
|
|
|
20
20
|
if (refcount > 1) return;
|
|
21
21
|
if (typeof document === "undefined") return;
|
|
22
22
|
|
|
23
|
+
document.documentElement.setAttribute("data-page-covered", "");
|
|
23
24
|
const body = document.body;
|
|
24
25
|
savedBodyStyles = {
|
|
25
26
|
position: body.style.position,
|
|
@@ -47,6 +48,7 @@ export function releaseScrollLock(): void {
|
|
|
47
48
|
if (refcount > 0) return;
|
|
48
49
|
if (typeof document === "undefined" || !savedBodyStyles) return;
|
|
49
50
|
|
|
51
|
+
document.documentElement.removeAttribute("data-page-covered");
|
|
50
52
|
const body = document.body;
|
|
51
53
|
const wasIOS = body.style.position === "fixed";
|
|
52
54
|
|
package/src/solid/checkbox.tsx
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { Checkbox as CheckboxPrimitive } from "@kobalte/core/checkbox";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
children,
|
|
4
|
+
type Component,
|
|
5
|
+
type ComponentProps,
|
|
6
|
+
type JSX,
|
|
7
|
+
type ParentComponent,
|
|
8
|
+
Show,
|
|
9
|
+
splitProps,
|
|
10
|
+
} from "solid-js";
|
|
3
11
|
import { FIELD_CHROME } from "../lib/input-classes.js";
|
|
4
12
|
import { cn } from "../lib/utils.js";
|
|
5
13
|
import { Icon } from "./icon.js";
|
|
@@ -13,11 +21,22 @@ const CHECKBOX_SIZE = {
|
|
|
13
21
|
|
|
14
22
|
type CheckboxSize = keyof typeof CHECKBOX_SIZE;
|
|
15
23
|
|
|
24
|
+
// Its own component so the label resolves once, under the checkbox's Kobalte context.
|
|
25
|
+
const CheckboxText: ParentComponent = (props) => {
|
|
26
|
+
const label = children(() => props.children);
|
|
27
|
+
return (
|
|
28
|
+
<Show when={label()}>
|
|
29
|
+
<span data-slot="checkbox-text" class="text-sm leading-none">
|
|
30
|
+
{label()}
|
|
31
|
+
</span>
|
|
32
|
+
</Show>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
16
36
|
const Checkbox: Component<ComponentProps<typeof CheckboxPrimitive> & { size?: CheckboxSize }> = (
|
|
17
37
|
props,
|
|
18
38
|
) => {
|
|
19
39
|
const [local, others] = splitProps(props, ["class", "children", "size"]);
|
|
20
|
-
const label = () => local.children as JSX.Element;
|
|
21
40
|
const size = () => CHECKBOX_SIZE[local.size ?? "default"];
|
|
22
41
|
return (
|
|
23
42
|
<CheckboxPrimitive data-slot="checkbox" {...others}>
|
|
@@ -56,11 +75,7 @@ const Checkbox: Component<ComponentProps<typeof CheckboxPrimitive> & { size?: Ch
|
|
|
56
75
|
)}
|
|
57
76
|
/>
|
|
58
77
|
</span>
|
|
59
|
-
{local.children
|
|
60
|
-
<span data-slot="checkbox-text" class="text-sm leading-none">
|
|
61
|
-
{label()}
|
|
62
|
-
</span>
|
|
63
|
-
)}
|
|
78
|
+
<CheckboxText>{local.children as JSX.Element}</CheckboxText>
|
|
64
79
|
</CheckboxPrimitive.Label>
|
|
65
80
|
)}
|
|
66
81
|
</CheckboxPrimitive>
|
package/src/solid/data-table.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
type Accessor,
|
|
3
|
+
children,
|
|
3
4
|
createEffect,
|
|
4
5
|
createMemo,
|
|
5
6
|
createSignal,
|
|
@@ -151,6 +152,7 @@ export function DataTableRow(props: {
|
|
|
151
152
|
class?: string;
|
|
152
153
|
}) {
|
|
153
154
|
const opens = () => props.onOpen !== undefined || props.href !== undefined;
|
|
155
|
+
const actions = children(() => props.actions);
|
|
154
156
|
return (
|
|
155
157
|
<div
|
|
156
158
|
data-slot="data-table-row"
|
|
@@ -180,8 +182,8 @@ export function DataTableRow(props: {
|
|
|
180
182
|
/>
|
|
181
183
|
</Show>
|
|
182
184
|
{props.children}
|
|
183
|
-
<Show when={
|
|
184
|
-
<div class="relative flex shrink-0 items-center gap-1">{
|
|
185
|
+
<Show when={actions()}>
|
|
186
|
+
<div class="relative flex shrink-0 items-center gap-1">{actions()}</div>
|
|
185
187
|
</Show>
|
|
186
188
|
</div>
|
|
187
189
|
);
|
|
@@ -250,22 +252,26 @@ export function TableEmpty(props: {
|
|
|
250
252
|
message: JSX.Element;
|
|
251
253
|
action?: JSX.Element;
|
|
252
254
|
}) {
|
|
255
|
+
const icon = children(() => props.icon);
|
|
256
|
+
const iconName = () => {
|
|
257
|
+
const glyph = icon();
|
|
258
|
+
return typeof glyph === "string" ? glyph : undefined;
|
|
259
|
+
};
|
|
260
|
+
const action = children(() => props.action);
|
|
253
261
|
return (
|
|
254
262
|
<Empty class="gap-3 rounded-none py-12">
|
|
255
263
|
<EmptyHeader>
|
|
256
|
-
<Show when={
|
|
264
|
+
<Show when={icon()}>
|
|
257
265
|
<EmptyMedia media="icon">
|
|
258
|
-
{
|
|
259
|
-
<Icon icon={
|
|
260
|
-
|
|
261
|
-
props.icon
|
|
262
|
-
)}
|
|
266
|
+
<Show when={iconName()} fallback={icon()}>
|
|
267
|
+
{(name) => <Icon icon={name()} width={24} height={24} />}
|
|
268
|
+
</Show>
|
|
263
269
|
</EmptyMedia>
|
|
264
270
|
</Show>
|
|
265
271
|
<EmptyDescription>{props.message}</EmptyDescription>
|
|
266
272
|
</EmptyHeader>
|
|
267
|
-
<Show when={
|
|
268
|
-
<EmptyContent>{
|
|
273
|
+
<Show when={action()}>
|
|
274
|
+
<EmptyContent>{action()}</EmptyContent>
|
|
269
275
|
</Show>
|
|
270
276
|
</Empty>
|
|
271
277
|
);
|
|
@@ -2,6 +2,7 @@ import { Button as KobalteButton } from "@kobalte/core/button";
|
|
|
2
2
|
import { useDialogContext } from "@kobalte/core/dialog";
|
|
3
3
|
import {
|
|
4
4
|
type Accessor,
|
|
5
|
+
children,
|
|
5
6
|
type Component,
|
|
6
7
|
type ComponentProps,
|
|
7
8
|
createContext,
|
|
@@ -116,23 +117,25 @@ export interface ModalParts {
|
|
|
116
117
|
export function createModalParts(slot: string): ModalParts {
|
|
117
118
|
const Header: Component<ModalHeaderProps> = (props) => {
|
|
118
119
|
const [local, rest] = splitProps(props, ["class", "media", "action", "wrap", "children"]);
|
|
120
|
+
const media = children(() => local.media);
|
|
121
|
+
const action = children(() => local.action);
|
|
119
122
|
return (
|
|
120
123
|
<div
|
|
121
124
|
data-slot={`${slot}-header`}
|
|
122
125
|
class={cn(MODAL_HEADER, local.wrap && "flex-wrap", local.class)}
|
|
123
126
|
{...rest}
|
|
124
127
|
>
|
|
125
|
-
<Show when={
|
|
128
|
+
<Show when={media()}>
|
|
126
129
|
<div data-slot={`${slot}-header-media`} class={MODAL_HEADER_MEDIA}>
|
|
127
|
-
{
|
|
130
|
+
{media()}
|
|
128
131
|
</div>
|
|
129
132
|
</Show>
|
|
130
133
|
<div data-slot={`${slot}-header-text`} class={MODAL_HEADER_TEXT}>
|
|
131
134
|
{local.children}
|
|
132
135
|
</div>
|
|
133
|
-
<Show when={
|
|
136
|
+
<Show when={action()}>
|
|
134
137
|
<div data-slot={`${slot}-header-action`} class={MODAL_HEADER_ACTION}>
|
|
135
|
-
{
|
|
138
|
+
{action()}
|
|
136
139
|
</div>
|
|
137
140
|
</Show>
|
|
138
141
|
</div>
|
package/src/solid/field.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cva, type VariantProps } from "cva";
|
|
2
2
|
import {
|
|
3
|
+
children,
|
|
3
4
|
type Component,
|
|
4
5
|
type ComponentProps,
|
|
5
6
|
createMemo,
|
|
@@ -171,20 +172,21 @@ const FieldSubGroup: Component<ComponentProps<"div">> = (props) => {
|
|
|
171
172
|
|
|
172
173
|
const FieldSeparator: ParentComponent<ComponentProps<"div">> = (props) => {
|
|
173
174
|
const [local, rest] = splitProps(props, ["children", "class"]);
|
|
175
|
+
const content = children(() => local.children);
|
|
174
176
|
return (
|
|
175
177
|
<div
|
|
176
178
|
data-slot="field-separator"
|
|
177
|
-
data-content={!!
|
|
179
|
+
data-content={!!content()}
|
|
178
180
|
class={cn("relative h-5 text-sm", local.class)}
|
|
179
181
|
{...rest}
|
|
180
182
|
>
|
|
181
183
|
<Separator class="absolute inset-0 top-1/2" />
|
|
182
|
-
<Show when={
|
|
184
|
+
<Show when={content()}>
|
|
183
185
|
<span
|
|
184
186
|
class="bg-card text-muted-foreground relative mx-auto block w-fit px-2"
|
|
185
187
|
data-slot="field-separator-content"
|
|
186
188
|
>
|
|
187
|
-
{
|
|
189
|
+
{content()}
|
|
188
190
|
</span>
|
|
189
191
|
</Show>
|
|
190
192
|
</div>
|
|
@@ -197,10 +199,12 @@ const FieldError: Component<
|
|
|
197
199
|
}
|
|
198
200
|
> = (props) => {
|
|
199
201
|
const [local, rest] = splitProps(props, ["class", "children", "errors"] as const);
|
|
202
|
+
const body = children(() => local.children);
|
|
200
203
|
|
|
201
204
|
const content = createMemo(() => {
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
const given = body();
|
|
206
|
+
if (given) {
|
|
207
|
+
return given;
|
|
204
208
|
}
|
|
205
209
|
|
|
206
210
|
if (!local.errors?.length) {
|
package/src/solid/icon.tsx
CHANGED
|
@@ -133,6 +133,9 @@ export function Icon(props: IconProps) {
|
|
|
133
133
|
if (!data) return { ...EMPTY, attributes: { ...EMPTY.attributes, ...sizeOrDefault(size) } };
|
|
134
134
|
return iconToSVG(data, size);
|
|
135
135
|
});
|
|
136
|
+
const body = createMemo(() => built().body);
|
|
137
|
+
// A TrustedHTML is a fresh object per call, which the spread would write as a new innerHTML.
|
|
138
|
+
const html = createMemo(() => trusted(body()));
|
|
136
139
|
return (
|
|
137
140
|
<svg
|
|
138
141
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -144,7 +147,7 @@ export function Icon(props: IconProps) {
|
|
|
144
147
|
viewBox={built().attributes.viewBox}
|
|
145
148
|
width={built().attributes.width}
|
|
146
149
|
height={built().attributes.height}
|
|
147
|
-
innerHTML={
|
|
150
|
+
innerHTML={html()}
|
|
148
151
|
/>
|
|
149
152
|
);
|
|
150
153
|
}
|
|
@@ -277,7 +277,14 @@ function ImageGallery(props: ImagePickerProps & { store: MediaStore | undefined
|
|
|
277
277
|
</Show>
|
|
278
278
|
</PickerTrigger>
|
|
279
279
|
</PopoverAnchor>
|
|
280
|
-
<PopoverContent
|
|
280
|
+
<PopoverContent
|
|
281
|
+
class="min-w-72"
|
|
282
|
+
onInteractOutside={(event) => {
|
|
283
|
+
// The delete confirmation takes focus; the gallery stays open to show the result.
|
|
284
|
+
if (pendingDelete()) event.preventDefault();
|
|
285
|
+
else setOpen(false);
|
|
286
|
+
}}
|
|
287
|
+
>
|
|
281
288
|
{/* The panel owns no padding: the gallery body owns its own inset. */}
|
|
282
289
|
<div data-slot="image-picker-body" class="flex flex-col gap-3 p-3">
|
|
283
290
|
<Show when={error()}>
|
|
@@ -15,7 +15,7 @@ import { cn } from "../lib/utils.js";
|
|
|
15
15
|
import { Icon } from "./icon.js";
|
|
16
16
|
import { Ornament } from "./ornament.js";
|
|
17
17
|
import { PickerRow } from "./picker-row.js";
|
|
18
|
-
import { RadioGroup, RadioGroupItem } from "./radio-group.js";
|
|
18
|
+
import { isItemActivation, RadioGroup, RadioGroupItem } from "./radio-group.js";
|
|
19
19
|
|
|
20
20
|
/* Tone without .glass-tint: the card holds body copy, which must stay foreground-coloured. */
|
|
21
21
|
const OPTION_CARD_CHROME = `${CARD_SURFACE} group/option-card relative cursor-pointer overflow-hidden rounded-xl transition-glass duration-200 [&:not([style*=--glass-tone])]:[--glass-tone:var(--primary)] [--glass-wash:9%] hover:[--glass-wash:16%] has-[:focus-visible]:[--glass-edge:var(--ring)] has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-ring/50 data-[checked]:[--glass-wash:30%] data-[checked]:[--glass-edge:oklch(from_var(--glass-tone)_l_c_h/0.75)] data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`;
|
|
@@ -146,7 +146,9 @@ export function OptionCard(props: {
|
|
|
146
146
|
value={props.value}
|
|
147
147
|
disabled={props.disabled}
|
|
148
148
|
showControl={false}
|
|
149
|
-
onClick={() =>
|
|
149
|
+
onClick={(event: MouseEvent) =>
|
|
150
|
+
!props.disabled && isItemActivation(event) && props.onPick?.()
|
|
151
|
+
}
|
|
150
152
|
class="relative w-full cursor-pointer overflow-hidden rounded-[inherit] text-left"
|
|
151
153
|
>
|
|
152
154
|
{/* On the header row, not the card: a grown card keeps its rows clear. */}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type JSX, Show } from "solid-js";
|
|
1
|
+
import { children, type JSX, Show } from "solid-js";
|
|
2
2
|
import { CARD_BLUR, CARD_SURFACE_BASE } from "../lib/card-classes.js";
|
|
3
3
|
import { SECTION_OUTER_RADIUS } from "../lib/section-tokens.js";
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
@@ -32,6 +32,9 @@ export function PageHeader(props: {
|
|
|
32
32
|
glass?: GlassSurface;
|
|
33
33
|
}) {
|
|
34
34
|
const glass = () => props.glass ?? NOOP_GLASS;
|
|
35
|
+
const iconNode = children(() => props.iconNode);
|
|
36
|
+
const subtitle = children(() => props.subtitle);
|
|
37
|
+
const actions = children(() => props.actions);
|
|
35
38
|
return (
|
|
36
39
|
<div
|
|
37
40
|
data-slot="page-header"
|
|
@@ -52,7 +55,7 @@ export function PageHeader(props: {
|
|
|
52
55
|
</Show>
|
|
53
56
|
<div data-slot="page-header-row" class="relative flex items-center gap-3 p-4 sm:gap-5 sm:p-6">
|
|
54
57
|
<Show
|
|
55
|
-
when={
|
|
58
|
+
when={iconNode()}
|
|
56
59
|
fallback={
|
|
57
60
|
<Show when={props.icon}>
|
|
58
61
|
{(icon) => (
|
|
@@ -61,7 +64,7 @@ export function PageHeader(props: {
|
|
|
61
64
|
</Show>
|
|
62
65
|
}
|
|
63
66
|
>
|
|
64
|
-
{
|
|
67
|
+
{iconNode()}
|
|
65
68
|
</Show>
|
|
66
69
|
<div data-slot="page-header-headings" class="flex min-w-0 flex-1 flex-col gap-1.5 sm:gap-2">
|
|
67
70
|
<div data-slot="page-header-headline" class="flex min-w-0 items-center gap-2 sm:gap-3">
|
|
@@ -75,18 +78,18 @@ export function PageHeader(props: {
|
|
|
75
78
|
<CountPill>{props.count}</CountPill>
|
|
76
79
|
</Show>
|
|
77
80
|
</div>
|
|
78
|
-
<Show when={
|
|
81
|
+
<Show when={subtitle()}>
|
|
79
82
|
<div
|
|
80
83
|
data-slot="page-header-subtitle"
|
|
81
84
|
class="text-muted-foreground flex items-center gap-2 text-sm"
|
|
82
85
|
>
|
|
83
|
-
{
|
|
86
|
+
{subtitle()}
|
|
84
87
|
</div>
|
|
85
88
|
</Show>
|
|
86
89
|
</div>
|
|
87
|
-
<Show when={
|
|
90
|
+
<Show when={actions()}>
|
|
88
91
|
<div data-slot="page-header-actions" class="flex shrink-0 items-center gap-2">
|
|
89
|
-
{
|
|
92
|
+
{actions()}
|
|
90
93
|
</div>
|
|
91
94
|
</Show>
|
|
92
95
|
</div>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
children,
|
|
2
3
|
type Component,
|
|
3
4
|
type ComponentProps,
|
|
4
5
|
createSignal,
|
|
@@ -26,10 +27,11 @@ const PasswordInput: Component<
|
|
|
26
27
|
> = (props) => {
|
|
27
28
|
const [local, rest] = splitProps(props, ["class", "leading", "showLabel", "hideLabel"]);
|
|
28
29
|
const [visible, setVisible] = createSignal(false);
|
|
30
|
+
const leading = children(() => local.leading);
|
|
29
31
|
|
|
30
32
|
return (
|
|
31
33
|
<div data-slot="password-input" class="relative">
|
|
32
|
-
<Show when={
|
|
34
|
+
<Show when={leading()}>
|
|
33
35
|
<span
|
|
34
36
|
data-slot="password-input-leading"
|
|
35
37
|
class={cn(
|
|
@@ -38,14 +40,14 @@ const PasswordInput: Component<
|
|
|
38
40
|
)}
|
|
39
41
|
aria-hidden="true"
|
|
40
42
|
>
|
|
41
|
-
{
|
|
43
|
+
{leading()}
|
|
42
44
|
</span>
|
|
43
45
|
</Show>
|
|
44
46
|
<Input
|
|
45
47
|
type={visible() ? "text" : "password"}
|
|
46
48
|
// Caller class first, affordance padding last: a caller-supplied px-*
|
|
47
49
|
// must never win the merge and reclaim a button's space.
|
|
48
|
-
class={cn(local.class,
|
|
50
|
+
class={cn(local.class, leading() && LEADING_RESERVE, TOGGLE_RESERVE)}
|
|
49
51
|
{...rest}
|
|
50
52
|
/>
|
|
51
53
|
<button
|