@glasshome/ui 1.13.0 → 1.15.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 +8 -1
- package/dist/index.js +2 -2
- package/dist/lib/motion-classes.d.ts +2 -0
- package/dist/solid/dock-paging.d.ts +8 -0
- package/dist/solid/dock.d.ts +8 -0
- package/dist/solid/index.d.ts +2 -0
- package/dist/solid/index.js +5345 -5118
- package/dist/solid/picker-trigger.d.ts +11 -0
- package/dist/solid/schema-form.d.ts +1 -1
- package/dist/{utils-CdUh67Y9.js → utils-DMaksjvy.js} +511 -511
- package/package.json +2 -2
- package/src/lib/motion-classes.ts +11 -0
- package/src/solid/area-picker.tsx +18 -14
- package/src/solid/dock-paging.ts +24 -0
- package/src/solid/dock.tsx +172 -22
- package/src/solid/entity-selector.tsx +30 -47
- package/src/solid/icon-picker.tsx +13 -15
- package/src/solid/image-picker.tsx +15 -15
- package/src/solid/index.ts +2 -0
- package/src/solid/picker-trigger.tsx +68 -0
- package/src/solid/schema-form.tsx +58 -18
- package/src/styles/globals.css +40 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glasshome/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.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",
|
|
@@ -84,6 +84,7 @@
|
|
|
84
84
|
"@iconify/types": "^2.0.0",
|
|
85
85
|
"@iconify/utils": "^3.1.4",
|
|
86
86
|
"@kobalte/core": "^0.13.13",
|
|
87
|
+
"@types/json-schema": "^7.0.15",
|
|
87
88
|
"clsx": "^2.1.1",
|
|
88
89
|
"cva": "^1.0.0-beta.4",
|
|
89
90
|
"embla-carousel": "^8.5.1",
|
|
@@ -100,7 +101,6 @@
|
|
|
100
101
|
"@iconify-json/simple-icons": "^1.2.95",
|
|
101
102
|
"@solidjs/testing-library": "^0.8.10",
|
|
102
103
|
"@tailwindcss/vite": "^4.1.13",
|
|
103
|
-
"@types/json-schema": "^7.0.15",
|
|
104
104
|
"@types/node": "^25.2.2",
|
|
105
105
|
"fallow": "3.17.0",
|
|
106
106
|
"happy-dom": "^20.11.0",
|
|
@@ -38,3 +38,14 @@ export const SETTLE_MOTION =
|
|
|
38
38
|
|
|
39
39
|
/* Every pressable dips the same amount. */
|
|
40
40
|
export const PRESS_DIP = "active:scale-[0.97]";
|
|
41
|
+
|
|
42
|
+
/* Hold progress: a fill grows out of the touch while held, dissolves once the
|
|
43
|
+
* hold fires, and drains back faster if let go early. The host sets data-hold / data-fired. */
|
|
44
|
+
export const HOLD_MOTION =
|
|
45
|
+
"scale-0 opacity-0 transition-[scale,opacity] duration-(--duration-state) ease-(--ease-contract) data-[hold]:scale-100 data-[hold]:opacity-100 data-[hold]:duration-(--duration-morph) data-[hold]:ease-linear data-[fired]:scale-100 data-[fired]:opacity-0";
|
|
46
|
+
|
|
47
|
+
/* MODAL_MOTION's twin for a surface that stays mounted: it rises out of what
|
|
48
|
+
* opened it, and its closed state is a resting style, since a mount door's exit
|
|
49
|
+
* ends and leaves the element showing. */
|
|
50
|
+
export const RISE_MOTION =
|
|
51
|
+
"origin-bottom transition-[opacity,scale,translate] data-[expanded]:duration-(--duration-expand) data-[expanded]:ease-(--ease-expand) data-[closed]:duration-(--duration-micro) data-[closed]:ease-(--ease-contract) data-[closed]:pointer-events-none data-[closed]:translate-y-2 data-[closed]:scale-95 data-[closed]:opacity-0";
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createMemo, createSignal, For, Show } from "solid-js";
|
|
2
2
|
import { MENU_ITEM } from "../lib/menu-classes.js";
|
|
3
3
|
import { STAGGER } from "../lib/motion-classes.js";
|
|
4
|
-
import { PICKER_LIST
|
|
4
|
+
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
5
5
|
import { cn } from "../lib/utils.js";
|
|
6
6
|
import { useEntityData } from "./entity-data.js";
|
|
7
7
|
import { Icon } from "./icon.js";
|
|
8
8
|
import { PickerRow } from "./picker-row.js";
|
|
9
9
|
import { PickerSearch } from "./picker-search.js";
|
|
10
|
+
import { PickerTrigger } from "./picker-trigger.js";
|
|
10
11
|
import { Popover, PopoverAnchor, PopoverContent } from "./popover.js";
|
|
11
12
|
import { SlidingIndicator } from "./sliding-indicator.js";
|
|
12
13
|
|
|
@@ -106,6 +107,15 @@ export function AreaPicker(props: AreaPickerProps) {
|
|
|
106
107
|
setSearch("");
|
|
107
108
|
};
|
|
108
109
|
|
|
110
|
+
const showTriggerClear = () =>
|
|
111
|
+
props.allowClear !== false && (multi() ? selected().length > 0 : Boolean(props.value));
|
|
112
|
+
|
|
113
|
+
const clearSelection = () => {
|
|
114
|
+
if (props.disabled) return;
|
|
115
|
+
props.onChange?.("");
|
|
116
|
+
props.onValuesChange?.([]);
|
|
117
|
+
};
|
|
118
|
+
|
|
109
119
|
const toggleArea = (areaId: string) => {
|
|
110
120
|
if (props.disabled) return;
|
|
111
121
|
const current = selected();
|
|
@@ -127,14 +137,14 @@ export function AreaPicker(props: AreaPickerProps) {
|
|
|
127
137
|
modal
|
|
128
138
|
>
|
|
129
139
|
<PopoverAnchor as="div" class={props.class}>
|
|
130
|
-
<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
140
|
+
<PickerTrigger
|
|
141
|
+
slot="area-picker-trigger"
|
|
142
|
+
open={open()}
|
|
143
|
+
onToggle={() => setOpen(!open())}
|
|
134
144
|
aria-labelledby={props["aria-labelledby"]}
|
|
135
|
-
class={PICKER_TRIGGER}
|
|
136
145
|
disabled={props.disabled}
|
|
137
|
-
|
|
146
|
+
onClear={showTriggerClear() ? clearSelection : undefined}
|
|
147
|
+
clearLabel={multi() ? "Clear areas" : "Clear area"}
|
|
138
148
|
>
|
|
139
149
|
<Show
|
|
140
150
|
when={triggerArea()}
|
|
@@ -160,13 +170,7 @@ export function AreaPicker(props: AreaPickerProps) {
|
|
|
160
170
|
</>
|
|
161
171
|
)}
|
|
162
172
|
</Show>
|
|
163
|
-
|
|
164
|
-
icon="mdi:chevron-down"
|
|
165
|
-
width={16}
|
|
166
|
-
height={16}
|
|
167
|
-
class="shrink-0 text-muted-foreground"
|
|
168
|
-
/>
|
|
169
|
-
</button>
|
|
173
|
+
</PickerTrigger>
|
|
170
174
|
</PopoverAnchor>
|
|
171
175
|
<PopoverContent
|
|
172
176
|
onOpenAutoFocus={(e) => e.preventDefault()}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** A page is one strip-width of items. The last one is whatever is left. */
|
|
2
|
+
export function pageCount(scrollWidth: number, viewport: number): number {
|
|
3
|
+
if (viewport <= 0) return 1;
|
|
4
|
+
return Math.max(1, Math.ceil(scrollWidth / viewport));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** The page a scroll position sits on, counting a half-page as turned. */
|
|
8
|
+
export function pageOf(scrollLeft: number, viewport: number): number {
|
|
9
|
+
if (viewport <= 0) return 0;
|
|
10
|
+
return Math.round(scrollLeft / viewport);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Where to scroll for a page, clamped to the end of the strip. */
|
|
14
|
+
export function pageOffset(page: number, viewport: number, scrollWidth: number): number {
|
|
15
|
+
const max = Math.max(0, scrollWidth - viewport);
|
|
16
|
+
return Math.min(max, Math.max(0, page * viewport));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** The strip shows whole items: a half-drawn icon at the edge reads as damage, not as a hint. */
|
|
20
|
+
export function stripWidth(available: number, itemWidth: number, gap: number): number {
|
|
21
|
+
if (available <= 0 || itemWidth <= 0) return available;
|
|
22
|
+
const count = Math.max(1, Math.floor((available + gap) / (itemWidth + gap)));
|
|
23
|
+
return Math.min(available, count * itemWidth + (count - 1) * gap);
|
|
24
|
+
}
|
package/src/solid/dock.tsx
CHANGED
|
@@ -12,9 +12,10 @@ import {
|
|
|
12
12
|
} from "solid-js";
|
|
13
13
|
import { Dynamic } from "solid-js/web";
|
|
14
14
|
import { CARD_SURFACE } from "../lib/card-classes.js";
|
|
15
|
-
import { PRESS_DIP } from "../lib/motion-classes.js";
|
|
15
|
+
import { HOLD_MOTION, PRESS_DIP } from "../lib/motion-classes.js";
|
|
16
16
|
import { cn } from "../lib/utils.js";
|
|
17
17
|
import { Badge } from "./badge.js";
|
|
18
|
+
import { pageCount, pageOf, pageOffset, stripWidth } from "./dock-paging.js";
|
|
18
19
|
import { SlidingIndicator } from "./sliding-indicator.js";
|
|
19
20
|
import { Tooltip, TooltipContent, TooltipTrigger } from "./tooltip.js";
|
|
20
21
|
|
|
@@ -31,6 +32,10 @@ interface DockItem {
|
|
|
31
32
|
interface DockProps extends ComponentProps<"div"> {
|
|
32
33
|
items: DockItem[];
|
|
33
34
|
dockMode?: "floating" | "docked";
|
|
35
|
+
/** Where a hold started, relative to the surface; `fired` once it has triggered. */
|
|
36
|
+
hold?: { x: number; y: number; fired: boolean } | null;
|
|
37
|
+
/** A rim light that orbits for as long as a mode is on. */
|
|
38
|
+
glow?: boolean;
|
|
34
39
|
}
|
|
35
40
|
|
|
36
41
|
interface DockIconButtonProps extends ComponentProps<"button"> {
|
|
@@ -95,10 +100,28 @@ const DockIconButton: Component<DockIconButtonProps> = (props) => {
|
|
|
95
100
|
};
|
|
96
101
|
|
|
97
102
|
const Dock: Component<DockProps> = (props) => {
|
|
98
|
-
const [local, rest] = splitProps(props, ["items", "class", "dockMode"]);
|
|
103
|
+
const [local, rest] = splitProps(props, ["items", "class", "dockMode", "hold", "glow"]);
|
|
104
|
+
// The drain plays where the fill grew, so the point outlives the hold.
|
|
105
|
+
const [holdPoint, setHoldPoint] = createSignal({ x: 0, y: 0, r: 0 });
|
|
106
|
+
let surfaceRef: HTMLDivElement | undefined;
|
|
107
|
+
createEffect(() => {
|
|
108
|
+
const h = local.hold;
|
|
109
|
+
if (!h) return;
|
|
110
|
+
const w = surfaceRef?.clientWidth ?? 0;
|
|
111
|
+
const ht = surfaceRef?.clientHeight ?? 0;
|
|
112
|
+
// Reaches the farthest corner exactly at full scale, so the fill ends as the hold does.
|
|
113
|
+
setHoldPoint({
|
|
114
|
+
x: h.x,
|
|
115
|
+
y: h.y,
|
|
116
|
+
r: Math.hypot(Math.max(h.x, w - h.x), Math.max(h.y, ht - h.y)),
|
|
117
|
+
});
|
|
118
|
+
});
|
|
99
119
|
const dockMode = () => local.dockMode ?? "floating";
|
|
100
120
|
let containerRef!: HTMLDivElement;
|
|
101
121
|
const [needsScroll, setNeedsScroll] = createSignal(false);
|
|
122
|
+
const [pages, setPages] = createSignal(1);
|
|
123
|
+
const [page, setPage] = createSignal(0);
|
|
124
|
+
const [viewportWidth, setViewportWidth] = createSignal(0);
|
|
102
125
|
|
|
103
126
|
// The moving background: the shared SlidingIndicator tracks the active item.
|
|
104
127
|
const activeIndex = () => {
|
|
@@ -106,34 +129,95 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
106
129
|
return i < 0 ? null : i;
|
|
107
130
|
};
|
|
108
131
|
|
|
132
|
+
const gapWidth = () =>
|
|
133
|
+
containerRef ? Number.parseFloat(getComputedStyle(containerRef).columnGap) || 0 : 0;
|
|
134
|
+
const itemWidth = () =>
|
|
135
|
+
containerRef?.querySelector('[data-slot="dock-item"]')?.getBoundingClientRect().width ?? 0;
|
|
136
|
+
|
|
109
137
|
const checkOverflow = () => {
|
|
110
|
-
if (containerRef)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
setNeedsScroll(
|
|
138
|
+
if (!containerRef) return;
|
|
139
|
+
const surface = containerRef.parentElement;
|
|
140
|
+
if (!surface) {
|
|
141
|
+
setNeedsScroll(containerRef.scrollWidth > window.innerWidth);
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
const surfaceStyle = getComputedStyle(surface);
|
|
145
|
+
const paddingX =
|
|
146
|
+
(Number.parseFloat(surfaceStyle.paddingLeft) || 0) +
|
|
147
|
+
(Number.parseFloat(surfaceStyle.paddingRight) || 0);
|
|
148
|
+
let siblingWidth = 0;
|
|
149
|
+
for (const child of Array.from(surface.children)) {
|
|
150
|
+
if (child === containerRef) continue;
|
|
151
|
+
const childStyle = getComputedStyle(child);
|
|
152
|
+
// The page dots overlay the bar out of flow; they do not narrow it.
|
|
153
|
+
if (childStyle.position === "absolute" || childStyle.position === "fixed") continue;
|
|
154
|
+
siblingWidth +=
|
|
155
|
+
child.getBoundingClientRect().width +
|
|
156
|
+
(Number.parseFloat(childStyle.marginLeft) || 0) +
|
|
157
|
+
(Number.parseFloat(childStyle.marginRight) || 0);
|
|
158
|
+
}
|
|
159
|
+
const availableWidth = surface.clientWidth - paddingX - siblingWidth;
|
|
160
|
+
const overflowing = containerRef.scrollWidth > availableWidth;
|
|
161
|
+
const trimmed = overflowing ? stripWidth(availableWidth, itemWidth(), gapWidth()) : 0;
|
|
162
|
+
if (trimmed > 0) containerRef.style.width = `${trimmed}px`;
|
|
163
|
+
setNeedsScroll(overflowing);
|
|
164
|
+
const viewport = trimmed > 0 ? trimmed : containerRef.clientWidth;
|
|
165
|
+
setViewportWidth(viewport);
|
|
166
|
+
setPages(pageCount(containerRef.scrollWidth, viewport));
|
|
167
|
+
setPage(pageOf(containerRef.scrollLeft, viewport));
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// The surface animates its width, so a read taken right after we set one is
|
|
171
|
+
// mid-transition: clearing our trim has to settle before the next measure.
|
|
172
|
+
let settleId: ReturnType<typeof setTimeout> | undefined;
|
|
173
|
+
const remeasure = () => {
|
|
174
|
+
if (!containerRef) return;
|
|
175
|
+
if (!containerRef.style.width) {
|
|
176
|
+
checkOverflow();
|
|
177
|
+
return;
|
|
114
178
|
}
|
|
179
|
+
containerRef.style.width = "";
|
|
180
|
+
clearTimeout(settleId);
|
|
181
|
+
settleId = setTimeout(checkOverflow, 250);
|
|
115
182
|
};
|
|
116
183
|
|
|
184
|
+
const goToPage = (next: number) => {
|
|
185
|
+
if (!containerRef) return;
|
|
186
|
+
containerRef.scrollTo({
|
|
187
|
+
left: pageOffset(next, viewportWidth(), containerRef.scrollWidth),
|
|
188
|
+
behavior: "smooth",
|
|
189
|
+
});
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// The active dashboard may sit on another page after a switch elsewhere.
|
|
193
|
+
createEffect(() => {
|
|
194
|
+
const i = activeIndex();
|
|
195
|
+
if (i === null || !containerRef || !needsScroll()) return;
|
|
196
|
+
const item = containerRef.querySelectorAll('[data-slot="dock-item"]')[i];
|
|
197
|
+
item?.scrollIntoView({ inline: "nearest", block: "nearest", behavior: "smooth" });
|
|
198
|
+
});
|
|
199
|
+
|
|
117
200
|
onMount(() => {
|
|
118
|
-
const timeoutId = setTimeout(
|
|
119
|
-
//
|
|
120
|
-
//
|
|
201
|
+
const timeoutId = setTimeout(remeasure, 100);
|
|
202
|
+
// Watching the bar would see its own trim and re-trim forever; the viewport
|
|
203
|
+
// is the only width the dock does not derive from itself.
|
|
121
204
|
let resizeTimeoutId: ReturnType<typeof setTimeout> | undefined;
|
|
122
|
-
const
|
|
205
|
+
const onResize = () => {
|
|
123
206
|
clearTimeout(resizeTimeoutId);
|
|
124
|
-
resizeTimeoutId = setTimeout(
|
|
125
|
-
}
|
|
126
|
-
|
|
207
|
+
resizeTimeoutId = setTimeout(remeasure, 50);
|
|
208
|
+
};
|
|
209
|
+
window.addEventListener("resize", onResize);
|
|
127
210
|
onCleanup(() => {
|
|
128
211
|
clearTimeout(timeoutId);
|
|
129
212
|
clearTimeout(resizeTimeoutId);
|
|
130
|
-
|
|
213
|
+
clearTimeout(settleId);
|
|
214
|
+
window.removeEventListener("resize", onResize);
|
|
131
215
|
});
|
|
132
216
|
});
|
|
133
217
|
|
|
134
218
|
createEffect(() => {
|
|
135
219
|
local.items.length;
|
|
136
|
-
const timeoutId = setTimeout(
|
|
220
|
+
const timeoutId = setTimeout(remeasure, 150);
|
|
137
221
|
onCleanup(() => clearTimeout(timeoutId));
|
|
138
222
|
});
|
|
139
223
|
|
|
@@ -141,22 +225,66 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
141
225
|
<div
|
|
142
226
|
data-slot="dock"
|
|
143
227
|
class={cn(
|
|
144
|
-
"flex items-center justify-center",
|
|
228
|
+
"flex max-w-full items-center justify-center",
|
|
145
229
|
dockMode() === "floating" ? "p-1 sm:p-2" : "",
|
|
146
230
|
local.class,
|
|
147
231
|
)}
|
|
148
232
|
{...rest}
|
|
149
233
|
>
|
|
150
|
-
<div
|
|
234
|
+
<div
|
|
235
|
+
ref={surfaceRef}
|
|
236
|
+
data-slot="dock-surface"
|
|
237
|
+
class={cn(
|
|
238
|
+
// isolate: the layers behind the icons stay inside the dock even with blur off.
|
|
239
|
+
"relative isolate flex max-w-full items-center justify-center p-1.5 sm:p-2",
|
|
240
|
+
// Room for the page dots inside the glass; outside it they sit on
|
|
241
|
+
// the screen edge and get clipped.
|
|
242
|
+
pages() > 1 && "pb-4 sm:pb-5",
|
|
243
|
+
CARD_SURFACE,
|
|
244
|
+
"[--glass-lift:0.55]",
|
|
245
|
+
dockMode() === "floating" ? "rounded-xl" : "rounded-t-xl",
|
|
246
|
+
)}
|
|
247
|
+
>
|
|
248
|
+
<div
|
|
249
|
+
aria-hidden="true"
|
|
250
|
+
class="pointer-events-none absolute inset-0 -z-10 overflow-hidden rounded-[inherit]"
|
|
251
|
+
>
|
|
252
|
+
<span
|
|
253
|
+
data-slot="dock-flood"
|
|
254
|
+
data-hold={local.hold && !local.hold.fired ? "" : undefined}
|
|
255
|
+
data-fired={local.hold?.fired ? "" : undefined}
|
|
256
|
+
class={cn(
|
|
257
|
+
"absolute -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary/45",
|
|
258
|
+
HOLD_MOTION,
|
|
259
|
+
)}
|
|
260
|
+
style={{
|
|
261
|
+
left: `${holdPoint().x}px`,
|
|
262
|
+
top: `${holdPoint().y}px`,
|
|
263
|
+
width: `${holdPoint().r * 2}px`,
|
|
264
|
+
height: `${holdPoint().r * 2}px`,
|
|
265
|
+
}}
|
|
266
|
+
/>
|
|
267
|
+
</div>
|
|
268
|
+
<Show when={local.glow}>
|
|
269
|
+
<div
|
|
270
|
+
data-slot="dock-glow"
|
|
271
|
+
aria-hidden="true"
|
|
272
|
+
class="glass-edge-orbit fade-in-0 animate-in duration-(--duration-state)"
|
|
273
|
+
>
|
|
274
|
+
<div />
|
|
275
|
+
</div>
|
|
276
|
+
</Show>
|
|
151
277
|
<div
|
|
152
278
|
ref={containerRef}
|
|
153
279
|
data-slot="dock-bar"
|
|
280
|
+
onScroll={() => {
|
|
281
|
+
if (containerRef) setPage(pageOf(containerRef.scrollLeft, viewportWidth()));
|
|
282
|
+
}}
|
|
154
283
|
class={cn(
|
|
155
|
-
"flex items-center gap-0.5
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
needsScroll() ? "scrollbar-hide overflow-x-auto" : "overflow-visible",
|
|
284
|
+
"flex items-center gap-0.5 sm:gap-1",
|
|
285
|
+
needsScroll()
|
|
286
|
+
? "scrollbar-hide snap-x snap-mandatory overflow-x-auto overscroll-x-contain scroll-smooth"
|
|
287
|
+
: "overflow-visible",
|
|
160
288
|
!needsScroll() && "justify-center",
|
|
161
289
|
)}
|
|
162
290
|
style={{
|
|
@@ -167,6 +295,7 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
167
295
|
<Index each={local.items}>
|
|
168
296
|
{(item) => (
|
|
169
297
|
<DockIconButton
|
|
298
|
+
class={needsScroll() ? "snap-start" : undefined}
|
|
170
299
|
icon={item().icon}
|
|
171
300
|
label={item().label}
|
|
172
301
|
onClick={item().onClick}
|
|
@@ -177,6 +306,27 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
177
306
|
</Index>
|
|
178
307
|
</SlidingIndicator>
|
|
179
308
|
</div>
|
|
309
|
+
<Show when={pages() > 1}>
|
|
310
|
+
<div
|
|
311
|
+
data-slot="dock-pages"
|
|
312
|
+
class="pointer-events-auto absolute inset-x-0 bottom-1.5 flex justify-center gap-1.5"
|
|
313
|
+
>
|
|
314
|
+
<Index each={Array.from({ length: pages() })}>
|
|
315
|
+
{(_, i) => (
|
|
316
|
+
<button
|
|
317
|
+
type="button"
|
|
318
|
+
aria-label={`Page ${i + 1}`}
|
|
319
|
+
aria-current={page() === i ? "true" : undefined}
|
|
320
|
+
onClick={() => goToPage(i)}
|
|
321
|
+
class={cn(
|
|
322
|
+
"h-1.5 rounded-full transition-glass",
|
|
323
|
+
page() === i ? "w-4 bg-foreground/70" : "w-1.5 bg-foreground/25",
|
|
324
|
+
)}
|
|
325
|
+
/>
|
|
326
|
+
)}
|
|
327
|
+
</Index>
|
|
328
|
+
</div>
|
|
329
|
+
</Show>
|
|
180
330
|
</div>
|
|
181
331
|
</div>
|
|
182
332
|
);
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
Show,
|
|
11
11
|
} from "solid-js";
|
|
12
12
|
import { MENU_LABEL } from "../lib/menu-classes.js";
|
|
13
|
-
import { PICKER_LIST
|
|
13
|
+
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
14
14
|
import { createIsMobile } from "../lib/use-is-mobile.js";
|
|
15
15
|
import { cn } from "../lib/utils.js";
|
|
16
16
|
import {
|
|
@@ -24,6 +24,7 @@ import { type EntityViewLike, useEntityData } from "./entity-data.js";
|
|
|
24
24
|
import { Icon } from "./icon.js";
|
|
25
25
|
import { PICKER_ROW_HEIGHT, PickerRow } from "./picker-row.js";
|
|
26
26
|
import { PickerSearch } from "./picker-search.js";
|
|
27
|
+
import { PickerTrigger } from "./picker-trigger.js";
|
|
27
28
|
import { Popover, PopoverAnchor, PopoverContent } from "./popover.js";
|
|
28
29
|
import { SlidingIndicator } from "./sliding-indicator.js";
|
|
29
30
|
|
|
@@ -309,9 +310,10 @@ export function EntitySelector(props: EntitySelectorProps) {
|
|
|
309
310
|
setActiveIndex(0);
|
|
310
311
|
};
|
|
311
312
|
|
|
313
|
+
// A re-tap on the picked entity clears it, the way every picker toggles.
|
|
312
314
|
const toggleEntity = (entityId: string) => {
|
|
313
315
|
if (props.multiple === false) {
|
|
314
|
-
props.onEntityIdsChange([entityId]);
|
|
316
|
+
props.onEntityIdsChange(props.entityIds.includes(entityId) ? [] : [entityId]);
|
|
315
317
|
closePicker();
|
|
316
318
|
return;
|
|
317
319
|
}
|
|
@@ -375,59 +377,40 @@ export function EntitySelector(props: EntitySelectorProps) {
|
|
|
375
377
|
};
|
|
376
378
|
|
|
377
379
|
const isSingle = () => props.multiple === false;
|
|
378
|
-
const showTriggerClear = () =>
|
|
380
|
+
const showTriggerClear = () => props.entityIds.length > 0;
|
|
379
381
|
|
|
380
382
|
const clearSelection = () => {
|
|
381
383
|
props.onEntityIdsChange([]);
|
|
382
384
|
};
|
|
383
385
|
|
|
384
386
|
const TriggerButton = (p: { onClick: () => void }) => (
|
|
385
|
-
<
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
387
|
+
<PickerTrigger
|
|
388
|
+
slot="entity-selector-trigger"
|
|
389
|
+
role="combobox"
|
|
390
|
+
open={open()}
|
|
391
|
+
onToggle={p.onClick}
|
|
392
|
+
aria-labelledby={props["aria-labelledby"]}
|
|
393
|
+
aria-expanded={open()}
|
|
394
|
+
aria-controls={listboxId}
|
|
395
|
+
aria-haspopup="listbox"
|
|
396
|
+
onClear={showTriggerClear() ? clearSelection : undefined}
|
|
397
|
+
>
|
|
398
|
+
<Show when={triggerIcon()}>
|
|
399
|
+
{(icon) => (
|
|
400
|
+
<Icon icon={icon()} width={16} height={16} class="shrink-0 text-muted-foreground" />
|
|
401
|
+
)}
|
|
402
|
+
</Show>
|
|
403
|
+
<Show
|
|
404
|
+
when={triggerLabel()}
|
|
405
|
+
fallback={
|
|
406
|
+
<span class="flex-1 truncate text-left text-muted-foreground">
|
|
407
|
+
Select {props.domain} {isSingle() ? "entity" : "entities"}...
|
|
408
|
+
</span>
|
|
409
|
+
}
|
|
397
410
|
>
|
|
398
|
-
<
|
|
399
|
-
{(icon) => (
|
|
400
|
-
<Icon icon={icon()} width={16} height={16} class="shrink-0 text-muted-foreground" />
|
|
401
|
-
)}
|
|
402
|
-
</Show>
|
|
403
|
-
<Show
|
|
404
|
-
when={triggerLabel()}
|
|
405
|
-
fallback={
|
|
406
|
-
<span class="flex-1 truncate text-left text-muted-foreground">
|
|
407
|
-
Select {props.domain} {isSingle() ? "entity" : "entities"}...
|
|
408
|
-
</span>
|
|
409
|
-
}
|
|
410
|
-
>
|
|
411
|
-
{(label) => <span class="flex-1 truncate text-left">{label()}</span>}
|
|
412
|
-
</Show>
|
|
413
|
-
<Icon
|
|
414
|
-
icon="mdi:chevron-down"
|
|
415
|
-
width={16}
|
|
416
|
-
height={16}
|
|
417
|
-
class={`shrink-0 text-muted-foreground transition-transform ${open() ? "rotate-180" : ""}`}
|
|
418
|
-
/>
|
|
419
|
-
</button>
|
|
420
|
-
<Show when={showTriggerClear()}>
|
|
421
|
-
<button
|
|
422
|
-
type="button"
|
|
423
|
-
aria-label="Clear selection"
|
|
424
|
-
class="absolute top-1/2 right-8 flex -translate-y-1/2 items-center rounded-sm p-1 text-muted-foreground transition-colors hover:text-foreground"
|
|
425
|
-
onClick={clearSelection}
|
|
426
|
-
>
|
|
427
|
-
<Icon icon="mdi:close-circle" width={16} height={16} />
|
|
428
|
-
</button>
|
|
411
|
+
{(label) => <span class="flex-1 truncate text-left">{label()}</span>}
|
|
429
412
|
</Show>
|
|
430
|
-
</
|
|
413
|
+
</PickerTrigger>
|
|
431
414
|
);
|
|
432
415
|
|
|
433
416
|
const EntityRow = (p: { id: string; entityIndex: number; top: number }) => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { createMemo, createSignal, For, Show } from "solid-js";
|
|
2
2
|
import { STAGGER } from "../lib/motion-classes.js";
|
|
3
|
-
import { PICKER_LIST
|
|
3
|
+
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
4
4
|
import { CHIP, ICON_PILL_TINT } from "../lib/pill-classes.js";
|
|
5
5
|
import { cn } from "../lib/utils.js";
|
|
6
6
|
import { Icon } from "./icon.js";
|
|
7
7
|
import { PickerSearch } from "./picker-search.js";
|
|
8
|
+
import { PickerTrigger } from "./picker-trigger.js";
|
|
8
9
|
import { Popover, PopoverAnchor, PopoverContent } from "./popover.js";
|
|
9
10
|
|
|
10
11
|
const ICON_LIBRARIES = [
|
|
@@ -311,12 +312,15 @@ export function IconPicker(props: IconPickerProps) {
|
|
|
311
312
|
return defaultIcons().filter((icon) => icon.toLowerCase().includes(q));
|
|
312
313
|
});
|
|
313
314
|
|
|
315
|
+
// A re-tap on the picked icon clears it, the way every picker toggles.
|
|
314
316
|
const selectIcon = (icon: string) => {
|
|
315
|
-
props.onChange(icon);
|
|
317
|
+
props.onChange(icon === props.value.trim() ? "" : icon);
|
|
316
318
|
setOpen(false);
|
|
317
319
|
setSearch("");
|
|
318
320
|
};
|
|
319
321
|
|
|
322
|
+
const clearIcon = () => props.onChange("");
|
|
323
|
+
|
|
320
324
|
const handleLibChange = (prefix: string) => {
|
|
321
325
|
setActiveLib(prefix);
|
|
322
326
|
setApiResults([]);
|
|
@@ -328,13 +332,13 @@ export function IconPicker(props: IconPickerProps) {
|
|
|
328
332
|
return (
|
|
329
333
|
<Popover surface="field" open={open()} onOpenChange={setOpen} modal>
|
|
330
334
|
<PopoverAnchor as="div" class={props.class}>
|
|
331
|
-
<
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
+
<PickerTrigger
|
|
336
|
+
slot="icon-picker-trigger"
|
|
337
|
+
open={open()}
|
|
338
|
+
onToggle={() => setOpen(!open())}
|
|
335
339
|
aria-labelledby={props["aria-labelledby"]}
|
|
336
|
-
|
|
337
|
-
|
|
340
|
+
onClear={props.value.trim() ? clearIcon : undefined}
|
|
341
|
+
clearLabel="Clear icon"
|
|
338
342
|
>
|
|
339
343
|
<Show
|
|
340
344
|
when={props.value.trim()}
|
|
@@ -347,13 +351,7 @@ export function IconPicker(props: IconPickerProps) {
|
|
|
347
351
|
<Icon icon={props.value.trim()} width={18} height={18} class="shrink-0" />
|
|
348
352
|
<span class="flex-1 truncate text-left">{props.value}</span>
|
|
349
353
|
</Show>
|
|
350
|
-
|
|
351
|
-
icon="mdi:chevron-down"
|
|
352
|
-
width={16}
|
|
353
|
-
height={16}
|
|
354
|
-
class="shrink-0 text-muted-foreground"
|
|
355
|
-
/>
|
|
356
|
-
</button>
|
|
354
|
+
</PickerTrigger>
|
|
357
355
|
</PopoverAnchor>
|
|
358
356
|
<PopoverContent
|
|
359
357
|
onOpenAutoFocus={(e) => {
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
Show,
|
|
9
9
|
Switch,
|
|
10
10
|
} from "solid-js";
|
|
11
|
-
import { PICKER_LIST
|
|
11
|
+
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
12
12
|
import { cn } from "../lib/utils.js";
|
|
13
13
|
import { Alert } from "./alert.js";
|
|
14
14
|
import {
|
|
@@ -49,6 +49,7 @@ import {
|
|
|
49
49
|
PaginationNext,
|
|
50
50
|
PaginationPrevious,
|
|
51
51
|
} from "./pagination.js";
|
|
52
|
+
import { PickerTrigger } from "./picker-trigger.js";
|
|
52
53
|
import { Popover, PopoverAnchor, PopoverContent } from "./popover.js";
|
|
53
54
|
import { SectionMeta } from "./section-card.js";
|
|
54
55
|
import { Skeleton } from "./skeleton.js";
|
|
@@ -103,6 +104,11 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
103
104
|
: `This image is used in ${used} widget${used === 1 ? "" : "s"}. Deleting it will leave those widgets without an image.`;
|
|
104
105
|
});
|
|
105
106
|
|
|
107
|
+
const clearImage = () => {
|
|
108
|
+
props.onChange("");
|
|
109
|
+
setThumbBroken(false);
|
|
110
|
+
};
|
|
111
|
+
|
|
106
112
|
const openGallery = (next: boolean) => {
|
|
107
113
|
if (next) setEverOpened(true);
|
|
108
114
|
setOpen(next);
|
|
@@ -154,13 +160,13 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
154
160
|
<div data-slot="image-picker" class={cn(props.class)}>
|
|
155
161
|
<Popover surface="field" open={open()} onOpenChange={openGallery} modal>
|
|
156
162
|
<PopoverAnchor as="div">
|
|
157
|
-
<
|
|
158
|
-
type="button"
|
|
163
|
+
<PickerTrigger
|
|
159
164
|
id={props.id}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
slot="image-picker-trigger"
|
|
166
|
+
open={open()}
|
|
167
|
+
onToggle={() => openGallery(!open())}
|
|
168
|
+
onClear={props.value ? clearImage : undefined}
|
|
169
|
+
clearLabel="Clear image"
|
|
164
170
|
>
|
|
165
171
|
<Show
|
|
166
172
|
when={!thumbBroken() && props.value}
|
|
@@ -189,13 +195,7 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
189
195
|
/>
|
|
190
196
|
<span class="flex-1 truncate text-left">Image selected</span>
|
|
191
197
|
</Show>
|
|
192
|
-
|
|
193
|
-
icon="lucide:chevron-down"
|
|
194
|
-
width={16}
|
|
195
|
-
height={16}
|
|
196
|
-
class="shrink-0 text-muted-foreground"
|
|
197
|
-
/>
|
|
198
|
-
</button>
|
|
198
|
+
</PickerTrigger>
|
|
199
199
|
</PopoverAnchor>
|
|
200
200
|
<PopoverContent class="min-w-72" onInteractOutside={() => setOpen(false)}>
|
|
201
201
|
{/* The panel owns no padding: the gallery body owns its own inset. */}
|
|
@@ -268,7 +268,7 @@ export function ImagePicker(props: ImagePickerProps) {
|
|
|
268
268
|
markUnused
|
|
269
269
|
selected={props.value === image.id}
|
|
270
270
|
onSelect={() => {
|
|
271
|
-
props.onChange(image.id);
|
|
271
|
+
props.onChange(props.value === image.id ? "" : image.id);
|
|
272
272
|
setThumbBroken(false);
|
|
273
273
|
setOpen(false);
|
|
274
274
|
}}
|
package/src/solid/index.ts
CHANGED
|
@@ -5,6 +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
9
|
export { OVERLAY_SURFACE } from "../lib/overlay-classes.js";
|
|
9
10
|
// Section tokens re-exported from the Solid entry for convenience.
|
|
10
11
|
export {
|
|
@@ -299,6 +300,7 @@ export {
|
|
|
299
300
|
export { PasswordInput } from "./password-input.js";
|
|
300
301
|
export { PICKER_ROW_HEIGHT, PickerRow } from "./picker-row.js";
|
|
301
302
|
export { PickerSearch, type PickerSearchProps } from "./picker-search.js";
|
|
303
|
+
export { PickerTrigger, type PickerTriggerProps } from "./picker-trigger.js";
|
|
302
304
|
export {
|
|
303
305
|
Popover,
|
|
304
306
|
PopoverAnchor,
|