@glasshome/ui 1.18.0 → 1.20.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 +84 -2
- package/dist/index.js +2 -2
- package/dist/lib/anchor-placement.d.ts +5 -0
- package/dist/lib/button-variants.d.ts +4 -1
- package/dist/lib/card-classes.d.ts +4 -4
- package/dist/lib/motion-classes.d.ts +2 -0
- package/dist/lib/overlay-classes.d.ts +4 -2
- package/dist/lib/spotlight-geometry.d.ts +22 -0
- package/dist/solid/button.d.ts +8 -3
- package/dist/solid/color-disc.d.ts +33 -0
- package/dist/solid/dashboard-preview.d.ts +24 -0
- package/dist/solid/dialog-parts.d.ts +1 -0
- package/dist/solid/dialog.d.ts +3 -0
- package/dist/solid/dock.d.ts +9 -0
- package/dist/solid/docked-panel.d.ts +11 -0
- package/dist/solid/image-picker.d.ts +3 -0
- package/dist/solid/index.d.ts +9 -3
- package/dist/solid/index.js +6254 -5475
- package/dist/solid/media-store.d.ts +10 -0
- package/dist/solid/option-card.d.ts +2 -1
- package/dist/solid/page-header.d.ts +2 -2
- package/dist/solid/preview-tile.d.ts +35 -0
- package/dist/solid/responsive-dialog.d.ts +2 -0
- package/dist/solid/schema-form.d.ts +6 -1
- package/dist/solid/sliding-indicator.d.ts +2 -0
- package/dist/solid/spotlight.d.ts +14 -0
- package/dist/solid/swatch-picker.d.ts +12 -0
- package/dist/solid/tabs.d.ts +4 -1
- package/dist/solid/toggle-group.d.ts +4 -1
- package/dist/solid/widget-identity.d.ts +2 -0
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.js +336 -118
- package/dist/tokens/material.d.ts +40 -0
- package/dist/tokens/presets.d.ts +3 -0
- package/dist/tokens/theme-colors.d.ts +13 -3
- package/dist/tokens/theme-recipe.d.ts +8 -0
- package/dist/{utils-COITV1s9.js → utils-CMk7R3zM.js} +488 -485
- package/package.json +2 -2
- package/scripts/check-ui-drift.mjs +5 -0
- package/src/lib/anchor-placement.ts +30 -0
- package/src/lib/button-variants.ts +13 -12
- package/src/lib/card-classes.ts +4 -3
- package/src/lib/motion-classes.ts +10 -0
- package/src/lib/overlay-classes.ts +10 -2
- package/src/lib/spotlight-geometry.ts +90 -0
- package/src/solid/bottom-sheet/bottom-sheet.tsx +8 -1
- package/src/solid/button.tsx +17 -2
- package/src/solid/color-disc.tsx +253 -0
- package/src/solid/dashboard-preview.tsx +128 -0
- package/src/solid/dialog-parts.tsx +5 -1
- package/src/solid/dialog.tsx +47 -5
- package/src/solid/dock.tsx +67 -9
- package/src/solid/docked-panel.tsx +56 -0
- package/src/solid/entity-selector.tsx +2 -2
- package/src/solid/hero-action.tsx +2 -2
- package/src/solid/image-picker.tsx +232 -147
- package/src/solid/index.ts +20 -2
- package/src/solid/media-store.ts +20 -1
- package/src/solid/option-card.tsx +27 -31
- package/src/solid/page-header.tsx +9 -16
- package/src/solid/preview-tile.tsx +89 -0
- package/src/solid/radio-group.tsx +7 -2
- package/src/solid/responsive-dialog.tsx +10 -2
- package/src/solid/schema-form.tsx +30 -4
- package/src/solid/section-card.tsx +4 -2
- package/src/solid/sliding-indicator.tsx +34 -17
- package/src/solid/spotlight.tsx +179 -0
- package/src/solid/swatch-picker.tsx +47 -0
- package/src/solid/tabs.tsx +20 -4
- package/src/solid/toggle-group.tsx +43 -8
- package/src/solid/widget-identity.tsx +3 -1
- package/src/styles/globals.css +166 -14
- package/src/styles/theme.css +25 -3
- package/src/tokens/index.ts +1 -0
- package/src/tokens/material.ts +116 -0
- package/src/tokens/presets.ts +195 -56
- package/src/tokens/theme-colors.ts +15 -3
- package/src/tokens/theme-recipe.ts +18 -4
|
@@ -8,7 +8,9 @@ import {
|
|
|
8
8
|
Show,
|
|
9
9
|
Switch,
|
|
10
10
|
} from "solid-js";
|
|
11
|
+
import { FIELD_CHROME } from "../lib/input-classes.js";
|
|
11
12
|
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
13
|
+
import { SECTION_INNER_RADIUS } from "../lib/section-tokens.js";
|
|
12
14
|
import { cn } from "../lib/utils.js";
|
|
13
15
|
import { Alert } from "./alert.js";
|
|
14
16
|
import {
|
|
@@ -21,6 +23,7 @@ import {
|
|
|
21
23
|
AlertDialogHeader,
|
|
22
24
|
AlertDialogTitle,
|
|
23
25
|
} from "./alert-dialog.js";
|
|
26
|
+
import { Badge } from "./badge.js";
|
|
24
27
|
import { Button } from "./button.js";
|
|
25
28
|
import { formatBytes } from "./charts.js";
|
|
26
29
|
import {
|
|
@@ -35,8 +38,12 @@ import { Icon } from "./icon.js";
|
|
|
35
38
|
import { mediaIndexErrorCopy, mediaStoreErrorCopy, toMediaStoreError } from "./media-copy.js";
|
|
36
39
|
import {
|
|
37
40
|
createBrokenMedia,
|
|
41
|
+
type ImagePreset,
|
|
42
|
+
imagePreset,
|
|
38
43
|
MEDIA_PAGE_SIZE,
|
|
44
|
+
type MediaStore,
|
|
39
45
|
type MediaStoreError,
|
|
46
|
+
presetValue,
|
|
40
47
|
type StoredMedia,
|
|
41
48
|
sortMediaForClearing,
|
|
42
49
|
useMediaStore,
|
|
@@ -59,19 +66,66 @@ export interface ImagePickerProps {
|
|
|
59
66
|
id?: string;
|
|
60
67
|
value: string;
|
|
61
68
|
onChange: (id: string) => void;
|
|
69
|
+
/** Built-in pictures offered before the uploads; picking one stores `presetValue(key)`. */
|
|
70
|
+
presets?: Record<string, ImagePreset>;
|
|
62
71
|
class?: string;
|
|
63
72
|
}
|
|
64
73
|
|
|
65
74
|
export function ImagePicker(props: ImagePickerProps) {
|
|
66
75
|
const store = useMediaStore();
|
|
76
|
+
return (
|
|
77
|
+
<Show
|
|
78
|
+
when={store || props.presets}
|
|
79
|
+
fallback={
|
|
80
|
+
<div data-slot="image-picker" class={cn(props.class)}>
|
|
81
|
+
<Alert tone="info">This dashboard cannot store images.</Alert>
|
|
82
|
+
</div>
|
|
83
|
+
}
|
|
84
|
+
>
|
|
85
|
+
<ImageGallery {...props} store={store} />
|
|
86
|
+
</Show>
|
|
87
|
+
);
|
|
88
|
+
}
|
|
67
89
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
type GalleryTile =
|
|
91
|
+
| { kind: "preset"; key: string; preset: ImagePreset }
|
|
92
|
+
| { kind: "media"; image: StoredMedia };
|
|
93
|
+
|
|
94
|
+
function PresetTile(props: { preset: ImagePreset; selected: boolean; onSelect: () => void }) {
|
|
95
|
+
return (
|
|
96
|
+
<div data-slot="image-picker-preset" class="relative min-w-0">
|
|
97
|
+
<button
|
|
98
|
+
type="button"
|
|
99
|
+
aria-label={`Use ${props.preset.label}`}
|
|
100
|
+
aria-pressed={props.selected}
|
|
101
|
+
onClick={() => props.onSelect()}
|
|
102
|
+
class={cn(
|
|
103
|
+
FIELD_CHROME,
|
|
104
|
+
SECTION_INNER_RADIUS,
|
|
105
|
+
"relative block aspect-square w-full overflow-hidden",
|
|
106
|
+
props.selected && "ring-2 ring-primary",
|
|
107
|
+
)}
|
|
108
|
+
>
|
|
109
|
+
<img
|
|
110
|
+
src={props.preset.thumb}
|
|
111
|
+
alt={props.preset.label}
|
|
112
|
+
loading="lazy"
|
|
113
|
+
decoding="async"
|
|
114
|
+
class="absolute inset-0 h-full w-full object-cover"
|
|
115
|
+
/>
|
|
116
|
+
</button>
|
|
117
|
+
<Badge
|
|
118
|
+
tone="var(--muted-foreground)"
|
|
119
|
+
class="pointer-events-none absolute bottom-1 left-1 backdrop-blur-md"
|
|
120
|
+
>
|
|
121
|
+
Built in
|
|
122
|
+
</Badge>
|
|
123
|
+
</div>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function ImageGallery(props: ImagePickerProps & { store: MediaStore | undefined }) {
|
|
128
|
+
const store = props.store;
|
|
75
129
|
|
|
76
130
|
const [open, setOpen] = createSignal(false);
|
|
77
131
|
const [everOpened, setEverOpened] = createSignal(false);
|
|
@@ -80,11 +134,14 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
80
134
|
const [thumbBroken, setThumbBroken] = createSignal(false);
|
|
81
135
|
const [uploading, setUploading] = createSignal(false);
|
|
82
136
|
const [page, setPage] = createSignal(0);
|
|
83
|
-
const thumbUrl = (id: string) => store
|
|
137
|
+
const thumbUrl = (id: string) => store?.url(id, "thumb") ?? "";
|
|
84
138
|
const brokenTiles = createBrokenMedia(thumbUrl);
|
|
85
139
|
let fileInput: HTMLInputElement | undefined;
|
|
86
140
|
|
|
87
|
-
const [index, { refetch }] = createResource(
|
|
141
|
+
const [index, { refetch }] = createResource(
|
|
142
|
+
() => everOpened() && store !== undefined,
|
|
143
|
+
() => (store ? store.index() : Promise.reject(new Error("no media store"))),
|
|
144
|
+
);
|
|
88
145
|
// Reading index() on a rejected resource rethrows, which crashes the popover's
|
|
89
146
|
// portal and leaves its overlay swallowing clicks. Every read goes through this.
|
|
90
147
|
const indexError = createMemo(() =>
|
|
@@ -92,10 +149,17 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
92
149
|
);
|
|
93
150
|
const loaded = () => (index.error === undefined ? index() : undefined);
|
|
94
151
|
const sorted = createMemo(() => sortMediaForClearing(loaded()?.media ?? []));
|
|
95
|
-
|
|
152
|
+
// Built-in pictures lead the grid; the household's uploads follow them.
|
|
153
|
+
const tiles = createMemo<GalleryTile[]>(() => [
|
|
154
|
+
...Object.entries(props.presets ?? {}).map(
|
|
155
|
+
([key, preset]): GalleryTile => ({ kind: "preset", key, preset }),
|
|
156
|
+
),
|
|
157
|
+
...sorted().map((image): GalleryTile => ({ kind: "media", image })),
|
|
158
|
+
]);
|
|
159
|
+
const pageCount = createMemo(() => Math.max(1, Math.ceil(tiles().length / MEDIA_PAGE_SIZE)));
|
|
96
160
|
const current = createMemo(() => Math.min(page(), pageCount() - 1));
|
|
97
|
-
const
|
|
98
|
-
|
|
161
|
+
const pageTiles = createMemo(() =>
|
|
162
|
+
tiles().slice(current() * MEDIA_PAGE_SIZE, current() * MEDIA_PAGE_SIZE + MEDIA_PAGE_SIZE),
|
|
99
163
|
);
|
|
100
164
|
const deleteDescription = createMemo(() => {
|
|
101
165
|
const used = pendingDelete()?.usedBy ?? 0;
|
|
@@ -104,6 +168,17 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
104
168
|
: `This image is used in ${used} widget${used === 1 ? "" : "s"}. Deleting it will leave those widgets without an image.`;
|
|
105
169
|
});
|
|
106
170
|
|
|
171
|
+
const chosenPreset = () => {
|
|
172
|
+
const key = imagePreset(props.value);
|
|
173
|
+
return key === undefined ? undefined : props.presets?.[key];
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const pick = (value: string) => {
|
|
177
|
+
props.onChange(props.value === value ? "" : value);
|
|
178
|
+
setThumbBroken(false);
|
|
179
|
+
setOpen(false);
|
|
180
|
+
};
|
|
181
|
+
|
|
107
182
|
const clearImage = () => {
|
|
108
183
|
props.onChange("");
|
|
109
184
|
setThumbBroken(false);
|
|
@@ -132,6 +207,7 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
132
207
|
setError(undefined);
|
|
133
208
|
setUploading(true);
|
|
134
209
|
try {
|
|
210
|
+
if (!store) return;
|
|
135
211
|
const uploaded = await store.upload(file);
|
|
136
212
|
await refetch();
|
|
137
213
|
props.onChange(uploaded.id);
|
|
@@ -147,7 +223,7 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
147
223
|
if (!target) return;
|
|
148
224
|
setError(undefined);
|
|
149
225
|
try {
|
|
150
|
-
await store
|
|
226
|
+
await store?.remove(target.id);
|
|
151
227
|
await refetch();
|
|
152
228
|
} catch (cause) {
|
|
153
229
|
fail(cause);
|
|
@@ -169,7 +245,7 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
169
245
|
clearLabel="Clear image"
|
|
170
246
|
>
|
|
171
247
|
<Show
|
|
172
|
-
when={!thumbBroken() && props.value}
|
|
248
|
+
when={!thumbBroken() && props.value && (chosenPreset() ?? store)}
|
|
173
249
|
fallback={
|
|
174
250
|
<>
|
|
175
251
|
<Icon
|
|
@@ -185,7 +261,7 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
185
261
|
}
|
|
186
262
|
>
|
|
187
263
|
<img
|
|
188
|
-
src={store
|
|
264
|
+
src={chosenPreset()?.thumb ?? store?.url(props.value)}
|
|
189
265
|
alt=""
|
|
190
266
|
width={24}
|
|
191
267
|
height={24}
|
|
@@ -193,7 +269,9 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
193
269
|
class="size-6 shrink-0 rounded-sm object-cover"
|
|
194
270
|
onError={() => setThumbBroken(true)}
|
|
195
271
|
/>
|
|
196
|
-
<span class="flex-1 truncate text-left">
|
|
272
|
+
<span class="flex-1 truncate text-left">
|
|
273
|
+
{chosenPreset()?.label ?? "Image selected"}
|
|
274
|
+
</span>
|
|
197
275
|
</Show>
|
|
198
276
|
</PickerTrigger>
|
|
199
277
|
</PopoverAnchor>
|
|
@@ -207,42 +285,43 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
207
285
|
</Alert>
|
|
208
286
|
)}
|
|
209
287
|
</Show>
|
|
210
|
-
<
|
|
288
|
+
<Show when={indexError()}>
|
|
289
|
+
{(failure) => (
|
|
290
|
+
// role="status": the gallery is explaining itself, not raising an alarm.
|
|
291
|
+
<Empty role="status">
|
|
292
|
+
<EmptyHeader>
|
|
293
|
+
<EmptyMedia variant="icon">
|
|
294
|
+
<Icon icon="lucide:image-off" width={24} height={24} />
|
|
295
|
+
</EmptyMedia>
|
|
296
|
+
<EmptyTitle>Images unavailable</EmptyTitle>
|
|
297
|
+
<EmptyDescription>{mediaIndexErrorCopy(failure())}</EmptyDescription>
|
|
298
|
+
</EmptyHeader>
|
|
299
|
+
<EmptyContent>
|
|
300
|
+
<Button
|
|
301
|
+
type="button"
|
|
302
|
+
variant="outline"
|
|
303
|
+
size="sm"
|
|
304
|
+
data-slot="image-picker-retry"
|
|
305
|
+
onClick={() => void refetch()}
|
|
306
|
+
>
|
|
307
|
+
Try again
|
|
308
|
+
</Button>
|
|
309
|
+
</EmptyContent>
|
|
310
|
+
</Empty>
|
|
311
|
+
)}
|
|
312
|
+
</Show>
|
|
313
|
+
<Show
|
|
314
|
+
when={tiles().length > 0}
|
|
211
315
|
fallback={
|
|
212
|
-
<
|
|
213
|
-
<
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
<
|
|
221
|
-
<EmptyHeader>
|
|
222
|
-
<EmptyMedia variant="icon">
|
|
223
|
-
<Icon icon="lucide:image-off" width={24} height={24} />
|
|
224
|
-
</EmptyMedia>
|
|
225
|
-
<EmptyTitle>Images unavailable</EmptyTitle>
|
|
226
|
-
<EmptyDescription>{mediaIndexErrorCopy(failure())}</EmptyDescription>
|
|
227
|
-
</EmptyHeader>
|
|
228
|
-
<EmptyContent>
|
|
229
|
-
<Button
|
|
230
|
-
type="button"
|
|
231
|
-
variant="outline"
|
|
232
|
-
size="sm"
|
|
233
|
-
data-slot="image-picker-retry"
|
|
234
|
-
onClick={() => void refetch()}
|
|
235
|
-
>
|
|
236
|
-
Try again
|
|
237
|
-
</Button>
|
|
238
|
-
</EmptyContent>
|
|
239
|
-
</Empty>
|
|
240
|
-
)}
|
|
241
|
-
</Match>
|
|
242
|
-
<Match when={loaded()}>
|
|
243
|
-
<Show
|
|
244
|
-
when={sorted().length > 0}
|
|
245
|
-
fallback={
|
|
316
|
+
<Switch>
|
|
317
|
+
<Match when={store && !loaded() && !indexError()}>
|
|
318
|
+
<div data-slot="image-picker-loading" class="grid grid-cols-3 gap-2">
|
|
319
|
+
<For each={[0, 1, 2, 3, 4, 5]}>
|
|
320
|
+
{() => <Skeleton class="aspect-square" />}
|
|
321
|
+
</For>
|
|
322
|
+
</div>
|
|
323
|
+
</Match>
|
|
324
|
+
<Match when={loaded()}>
|
|
246
325
|
<Empty>
|
|
247
326
|
<EmptyHeader>
|
|
248
327
|
<EmptyMedia variant="icon">
|
|
@@ -252,103 +331,109 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
252
331
|
<EmptyDescription>Upload one to use it here.</EmptyDescription>
|
|
253
332
|
</EmptyHeader>
|
|
254
333
|
</Empty>
|
|
255
|
-
|
|
256
|
-
>
|
|
257
|
-
|
|
258
|
-
data-slot="image-picker-gallery"
|
|
259
|
-
class={cn("grid grid-cols-3 gap-2", PICKER_LIST)}
|
|
260
|
-
>
|
|
261
|
-
<For each={pageImages()}>
|
|
262
|
-
{(image) => (
|
|
263
|
-
<MediaTile
|
|
264
|
-
item={image}
|
|
265
|
-
thumbUrl={thumbUrl(image.id)}
|
|
266
|
-
label={`Use ${image.id}`}
|
|
267
|
-
broken={brokenTiles.isBroken(image)}
|
|
268
|
-
markUnused
|
|
269
|
-
selected={props.value === image.id}
|
|
270
|
-
onSelect={() => {
|
|
271
|
-
props.onChange(props.value === image.id ? "" : image.id);
|
|
272
|
-
setThumbBroken(false);
|
|
273
|
-
setOpen(false);
|
|
274
|
-
}}
|
|
275
|
-
onBroken={() => brokenTiles.markBroken(image)}
|
|
276
|
-
onDelete={() => setPendingDelete(image)}
|
|
277
|
-
/>
|
|
278
|
-
)}
|
|
279
|
-
</For>
|
|
280
|
-
</div>
|
|
281
|
-
<Show when={pageCount() > 1}>
|
|
282
|
-
<Pagination>
|
|
283
|
-
<PaginationContent class="w-full justify-between">
|
|
284
|
-
<PaginationItem>
|
|
285
|
-
<PaginationPrevious
|
|
286
|
-
href="#"
|
|
287
|
-
aria-disabled={current() === 0}
|
|
288
|
-
class={current() === 0 ? "pointer-events-none opacity-50" : undefined}
|
|
289
|
-
onClick={(event) => {
|
|
290
|
-
event.preventDefault();
|
|
291
|
-
step(-1);
|
|
292
|
-
}}
|
|
293
|
-
/>
|
|
294
|
-
</PaginationItem>
|
|
295
|
-
<PaginationItem data-testid="image-picker-page-label">
|
|
296
|
-
<SectionMeta>
|
|
297
|
-
Page {current() + 1} of {pageCount()}
|
|
298
|
-
</SectionMeta>
|
|
299
|
-
</PaginationItem>
|
|
300
|
-
<PaginationItem>
|
|
301
|
-
<PaginationNext
|
|
302
|
-
href="#"
|
|
303
|
-
aria-disabled={current() === pageCount() - 1}
|
|
304
|
-
class={
|
|
305
|
-
current() === pageCount() - 1
|
|
306
|
-
? "pointer-events-none opacity-50"
|
|
307
|
-
: undefined
|
|
308
|
-
}
|
|
309
|
-
onClick={(event) => {
|
|
310
|
-
event.preventDefault();
|
|
311
|
-
step(1);
|
|
312
|
-
}}
|
|
313
|
-
/>
|
|
314
|
-
</PaginationItem>
|
|
315
|
-
</PaginationContent>
|
|
316
|
-
</Pagination>
|
|
317
|
-
</Show>
|
|
318
|
-
</Show>
|
|
319
|
-
<Show when={loaded()?.usage}>
|
|
320
|
-
{(u) => (
|
|
321
|
-
<SectionMeta>
|
|
322
|
-
{formatBytes(u().bytes)} of {formatBytes(u().limitBytes)} · {u().files} of{" "}
|
|
323
|
-
{u().limitFiles} images
|
|
324
|
-
</SectionMeta>
|
|
325
|
-
)}
|
|
326
|
-
</Show>
|
|
327
|
-
</Match>
|
|
328
|
-
</Switch>
|
|
329
|
-
<input
|
|
330
|
-
ref={fileInput}
|
|
331
|
-
type="file"
|
|
332
|
-
accept="image/*"
|
|
333
|
-
data-testid="image-upload-input"
|
|
334
|
-
class="hidden"
|
|
335
|
-
onChange={(e) => {
|
|
336
|
-
const file = e.currentTarget.files?.[0];
|
|
337
|
-
e.currentTarget.value = "";
|
|
338
|
-
if (file) void handleUpload(file);
|
|
339
|
-
}}
|
|
340
|
-
/>
|
|
341
|
-
<Button
|
|
342
|
-
type="button"
|
|
343
|
-
variant="outline"
|
|
344
|
-
size="sm"
|
|
345
|
-
data-slot="image-picker-upload"
|
|
346
|
-
disabled={uploading()}
|
|
347
|
-
onClick={() => fileInput?.click()}
|
|
334
|
+
</Match>
|
|
335
|
+
</Switch>
|
|
336
|
+
}
|
|
348
337
|
>
|
|
349
|
-
<
|
|
350
|
-
|
|
351
|
-
|
|
338
|
+
<div
|
|
339
|
+
data-slot="image-picker-gallery"
|
|
340
|
+
class={cn("grid grid-cols-3 gap-2", PICKER_LIST, "overflow-x-hidden")}
|
|
341
|
+
>
|
|
342
|
+
<For each={pageTiles()}>
|
|
343
|
+
{(tile) =>
|
|
344
|
+
tile.kind === "preset" ? (
|
|
345
|
+
<PresetTile
|
|
346
|
+
preset={tile.preset}
|
|
347
|
+
selected={props.value === presetValue(tile.key)}
|
|
348
|
+
onSelect={() => pick(presetValue(tile.key))}
|
|
349
|
+
/>
|
|
350
|
+
) : (
|
|
351
|
+
<MediaTile
|
|
352
|
+
item={tile.image}
|
|
353
|
+
thumbUrl={thumbUrl(tile.image.id)}
|
|
354
|
+
label={`Use ${tile.image.id}`}
|
|
355
|
+
broken={brokenTiles.isBroken(tile.image)}
|
|
356
|
+
markUnused
|
|
357
|
+
selected={props.value === tile.image.id}
|
|
358
|
+
onSelect={() => pick(tile.image.id)}
|
|
359
|
+
onBroken={() => brokenTiles.markBroken(tile.image)}
|
|
360
|
+
onDelete={() => setPendingDelete(tile.image)}
|
|
361
|
+
/>
|
|
362
|
+
)
|
|
363
|
+
}
|
|
364
|
+
</For>
|
|
365
|
+
</div>
|
|
366
|
+
<Show when={pageCount() > 1}>
|
|
367
|
+
<Pagination>
|
|
368
|
+
<PaginationContent class="w-full justify-between">
|
|
369
|
+
<PaginationItem>
|
|
370
|
+
<PaginationPrevious
|
|
371
|
+
href="#"
|
|
372
|
+
aria-disabled={current() === 0}
|
|
373
|
+
class={current() === 0 ? "pointer-events-none opacity-50" : undefined}
|
|
374
|
+
onClick={(event) => {
|
|
375
|
+
event.preventDefault();
|
|
376
|
+
step(-1);
|
|
377
|
+
}}
|
|
378
|
+
/>
|
|
379
|
+
</PaginationItem>
|
|
380
|
+
<PaginationItem data-testid="image-picker-page-label">
|
|
381
|
+
<SectionMeta>
|
|
382
|
+
Page {current() + 1} of {pageCount()}
|
|
383
|
+
</SectionMeta>
|
|
384
|
+
</PaginationItem>
|
|
385
|
+
<PaginationItem>
|
|
386
|
+
<PaginationNext
|
|
387
|
+
href="#"
|
|
388
|
+
aria-disabled={current() === pageCount() - 1}
|
|
389
|
+
class={
|
|
390
|
+
current() === pageCount() - 1
|
|
391
|
+
? "pointer-events-none opacity-50"
|
|
392
|
+
: undefined
|
|
393
|
+
}
|
|
394
|
+
onClick={(event) => {
|
|
395
|
+
event.preventDefault();
|
|
396
|
+
step(1);
|
|
397
|
+
}}
|
|
398
|
+
/>
|
|
399
|
+
</PaginationItem>
|
|
400
|
+
</PaginationContent>
|
|
401
|
+
</Pagination>
|
|
402
|
+
</Show>
|
|
403
|
+
</Show>
|
|
404
|
+
<Show when={loaded()?.usage}>
|
|
405
|
+
{(u) => (
|
|
406
|
+
<SectionMeta>
|
|
407
|
+
{formatBytes(u().bytes)} of {formatBytes(u().limitBytes)} · {u().files} of{" "}
|
|
408
|
+
{u().limitFiles} images
|
|
409
|
+
</SectionMeta>
|
|
410
|
+
)}
|
|
411
|
+
</Show>
|
|
412
|
+
<Show when={store}>
|
|
413
|
+
<input
|
|
414
|
+
ref={fileInput}
|
|
415
|
+
type="file"
|
|
416
|
+
accept="image/*"
|
|
417
|
+
data-testid="image-upload-input"
|
|
418
|
+
class="hidden"
|
|
419
|
+
onChange={(e) => {
|
|
420
|
+
const file = e.currentTarget.files?.[0];
|
|
421
|
+
e.currentTarget.value = "";
|
|
422
|
+
if (file) void handleUpload(file);
|
|
423
|
+
}}
|
|
424
|
+
/>
|
|
425
|
+
<Button
|
|
426
|
+
type="button"
|
|
427
|
+
variant="outline"
|
|
428
|
+
size="sm"
|
|
429
|
+
data-slot="image-picker-upload"
|
|
430
|
+
disabled={uploading()}
|
|
431
|
+
onClick={() => fileInput?.click()}
|
|
432
|
+
>
|
|
433
|
+
<Icon icon="lucide:upload" width={14} height={14} />
|
|
434
|
+
{uploading() ? "Uploading..." : "Upload"}
|
|
435
|
+
</Button>
|
|
436
|
+
</Show>
|
|
352
437
|
</div>
|
|
353
438
|
</PopoverContent>
|
|
354
439
|
</Popover>
|
package/src/solid/index.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
export { type Color, parseColor } from "@kobalte/core/colors";
|
|
6
6
|
// Floating glass panel + its shared surface token.
|
|
7
7
|
export { SECTION_ROW_SURFACE } from "../lib/card-classes.js";
|
|
8
|
-
export { RISE_MOTION } from "../lib/motion-classes.js";
|
|
8
|
+
export { RISE_MOTION, SETTLE_MOTION, TRAVEL_MOTION } from "../lib/motion-classes.js";
|
|
9
9
|
export { OVERLAY_SURFACE } from "../lib/overlay-classes.js";
|
|
10
10
|
// Section tokens re-exported from the Solid entry for convenience.
|
|
11
11
|
export {
|
|
@@ -62,7 +62,7 @@ export {
|
|
|
62
62
|
BreadcrumbPage,
|
|
63
63
|
BreadcrumbSeparator,
|
|
64
64
|
} from "./breadcrumb.js";
|
|
65
|
-
export { Button, buttonVariants } from "./button.js";
|
|
65
|
+
export { Button, ButtonWell, buttonVariants } from "./button.js";
|
|
66
66
|
export {
|
|
67
67
|
ButtonGroup,
|
|
68
68
|
ButtonGroupSeparator,
|
|
@@ -102,6 +102,11 @@ export {
|
|
|
102
102
|
CollapsibleContent,
|
|
103
103
|
CollapsibleTrigger,
|
|
104
104
|
} from "./collapsible.js";
|
|
105
|
+
export {
|
|
106
|
+
ColorDisc,
|
|
107
|
+
kelvinToCss,
|
|
108
|
+
TemperatureBar,
|
|
109
|
+
} from "./color-disc.js";
|
|
105
110
|
export { ColorSlider } from "./color-slider.js";
|
|
106
111
|
export { ColorWheel } from "./color-wheel.js";
|
|
107
112
|
export {
|
|
@@ -122,6 +127,7 @@ export {
|
|
|
122
127
|
} from "./context-menu.js";
|
|
123
128
|
export { CopyButton } from "./copy-button.js";
|
|
124
129
|
export { CountPill } from "./count-pill.js";
|
|
130
|
+
export { DashboardPreview, type DashboardPreviewTile } from "./dashboard-preview.js";
|
|
125
131
|
export {
|
|
126
132
|
DataTableHead,
|
|
127
133
|
DataTableRow,
|
|
@@ -156,6 +162,12 @@ export {
|
|
|
156
162
|
export type { ModalSize } from "./dialog-parts.js";
|
|
157
163
|
export type { DockIconButtonProps, DockItem, DockProps } from "./dock.js";
|
|
158
164
|
export { Dock } from "./dock.js";
|
|
165
|
+
export {
|
|
166
|
+
DockedPanel,
|
|
167
|
+
DockedPanelBody,
|
|
168
|
+
DockedPanelFooter,
|
|
169
|
+
DockedPanelHeader,
|
|
170
|
+
} from "./docked-panel.js";
|
|
159
171
|
export {
|
|
160
172
|
DropdownMenu,
|
|
161
173
|
DropdownMenuCheckboxItem,
|
|
@@ -269,6 +281,8 @@ export {
|
|
|
269
281
|
export {
|
|
270
282
|
type BrokenMedia,
|
|
271
283
|
createBrokenMedia,
|
|
284
|
+
type ImagePreset,
|
|
285
|
+
imagePreset,
|
|
272
286
|
imageUrl,
|
|
273
287
|
isMediaImage,
|
|
274
288
|
MEDIA_PAGE_SIZE,
|
|
@@ -280,6 +294,7 @@ export {
|
|
|
280
294
|
type MediaStoreErrorKind,
|
|
281
295
|
type MediaVariant,
|
|
282
296
|
mediaUrl,
|
|
297
|
+
presetValue,
|
|
283
298
|
provideMediaStore,
|
|
284
299
|
type StoredMedia,
|
|
285
300
|
sortMediaForClearing,
|
|
@@ -309,6 +324,7 @@ export {
|
|
|
309
324
|
PopoverContent,
|
|
310
325
|
PopoverTrigger,
|
|
311
326
|
} from "./popover.js";
|
|
327
|
+
export { PreviewTile, PreviewTileGroup } from "./preview-tile.js";
|
|
312
328
|
export { Progress } from "./progress.js";
|
|
313
329
|
export { RadioGroup, RadioGroupItem } from "./radio-group.js";
|
|
314
330
|
export {
|
|
@@ -389,7 +405,9 @@ export { SlidingIndicator } from "./sliding-indicator.js";
|
|
|
389
405
|
// Wave 4: React-Library Alternatives - Simpler
|
|
390
406
|
export { GlassToast, Toaster, toast } from "./sonner.js";
|
|
391
407
|
export { Spinner } from "./spinner.js";
|
|
408
|
+
export { Spotlight } from "./spotlight.js";
|
|
392
409
|
export { StepIndicator } from "./step-indicator.js";
|
|
410
|
+
export { SwatchPicker } from "./swatch-picker.js";
|
|
393
411
|
export { Switch } from "./switch.js";
|
|
394
412
|
export {
|
|
395
413
|
TABLE_CELL_INSET,
|
package/src/solid/media-store.ts
CHANGED
|
@@ -101,8 +101,27 @@ export function createBrokenMedia(thumbUrl: (id: string) => string): BrokenMedia
|
|
|
101
101
|
};
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
const PRESET_PREFIX = "preset:";
|
|
105
|
+
|
|
106
|
+
/** A built-in picture a widget offers beside the household's own uploads. */
|
|
107
|
+
export interface ImagePreset {
|
|
108
|
+
label: string;
|
|
109
|
+
/** Small image for the picker; the widget keeps the full picture. */
|
|
110
|
+
thumb: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** The stored value that picks a built-in picture. */
|
|
114
|
+
export function presetValue(key: string): string {
|
|
115
|
+
return `${PRESET_PREFIX}${key}`;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The built-in picture a stored image value names, or undefined for an upload. */
|
|
119
|
+
export function imagePreset(value: string | null | undefined): string | undefined {
|
|
120
|
+
return value?.startsWith(PRESET_PREFIX) ? value.slice(PRESET_PREFIX.length) : undefined;
|
|
121
|
+
}
|
|
122
|
+
|
|
104
123
|
export function mediaUrl(id: string | null | undefined): string | undefined {
|
|
105
|
-
if (!id) return undefined;
|
|
124
|
+
if (!id || imagePreset(id) !== undefined) return undefined;
|
|
106
125
|
return useMediaStore()?.url(id);
|
|
107
126
|
}
|
|
108
127
|
|