@glasshome/ui 1.41.0 → 1.42.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 +5 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/lib/anchor-placement.d.ts +30 -0
- package/dist/lib/behavior/anchored.d.ts +12 -0
- package/dist/lib/behavior/collection.d.ts +24 -0
- package/dist/lib/behavior/controllable.d.ts +8 -0
- package/dist/lib/behavior/dismiss.d.ts +11 -0
- package/dist/lib/behavior/focus-scope.d.ts +18 -0
- package/dist/lib/behavior/hide-outside.d.ts +7 -0
- package/dist/lib/behavior/layer-stack.d.ts +33 -0
- package/dist/lib/behavior/modal-root.d.ts +66 -0
- package/dist/lib/behavior/polymorphic.d.ts +6 -0
- package/dist/lib/behavior/presence.d.ts +18 -0
- package/dist/lib/behavior/solid.d.ts +13 -0
- package/dist/lib/motion-classes.d.ts +5 -2
- package/dist/lib/overlay-classes.d.ts +3 -0
- package/dist/lib/page-cover.d.ts +8 -0
- package/dist/lib/shadow-layer.d.ts +8 -6
- package/dist/solid/alert-dialog.d.ts +5 -8
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +1 -1
- package/dist/solid/bottom-sheet/constants.d.ts +1 -1
- package/dist/solid/dialog-parts.d.ts +51 -14
- package/dist/solid/dialog.d.ts +7 -10
- package/dist/solid/index.d.ts +4 -1
- package/dist/solid/index.js +7797 -7710
- package/dist/solid/responsive-dialog.d.ts +2 -0
- package/dist/solid/sheet.d.ts +5 -8
- package/dist/solid/stale-veil.d.ts +7 -0
- package/dist/solid/tabs.d.ts +28 -9
- package/dist/solid/toggle-group.d.ts +30 -5
- package/dist/solid/tooltip.d.ts +71 -9
- package/dist/{utils-CGN4X-2O.js → utils-CxAii-e9.js} +606 -414
- package/package.json +4 -2
- package/src/index.ts +1 -0
- package/src/lib/anchor-placement.ts +68 -2
- package/src/lib/behavior/anchored.ts +88 -0
- package/src/lib/behavior/collection.ts +181 -0
- package/src/lib/behavior/controllable.ts +22 -0
- package/src/lib/behavior/dismiss.ts +145 -0
- package/src/lib/behavior/focus-scope.ts +202 -0
- package/src/lib/behavior/hide-outside.ts +85 -0
- package/src/lib/behavior/layer-stack.ts +125 -0
- package/src/lib/behavior/modal-root.tsx +446 -0
- package/src/lib/behavior/polymorphic.tsx +30 -0
- package/src/lib/behavior/presence.ts +89 -0
- package/src/lib/behavior/solid.ts +30 -0
- package/src/lib/clipboard.ts +3 -2
- package/src/lib/motion-classes.ts +27 -2
- package/src/lib/overlay-classes.ts +7 -0
- package/src/lib/page-cover.ts +47 -0
- package/src/lib/shadow-layer.ts +48 -66
- package/src/solid/alert-dialog.tsx +36 -85
- package/src/solid/area-picker.tsx +2 -1
- package/src/solid/badge.tsx +5 -5
- package/src/solid/bottom-sheet/bottom-sheet.tsx +72 -128
- package/src/solid/bottom-sheet/constants.ts +3 -1
- package/src/solid/bottom-sheet/drag-controller.ts +11 -0
- package/src/solid/breadcrumb.tsx +4 -4
- package/src/solid/button-group.tsx +4 -4
- package/src/solid/card.tsx +5 -4
- package/src/solid/context-menu.tsx +12 -2
- package/src/solid/dialog-parts.tsx +132 -43
- package/src/solid/dialog.tsx +44 -76
- package/src/solid/dock-edit.tsx +5 -4
- package/src/solid/dock.tsx +3 -3
- package/src/solid/dropdown-menu.tsx +15 -7
- package/src/solid/entity-selector.tsx +2 -1
- package/src/solid/form.tsx +4 -3
- package/src/solid/hover-card.tsx +7 -2
- package/src/solid/icon-picker.tsx +2 -1
- package/src/solid/image-picker.tsx +5 -4
- package/src/solid/index.ts +4 -1
- package/src/solid/input-group.tsx +5 -3
- package/src/solid/input-otp.tsx +2 -1
- package/src/solid/item.tsx +4 -4
- package/src/solid/logo.tsx +5 -4
- package/src/solid/picker-row.tsx +5 -4
- package/src/solid/picker-search.tsx +2 -1
- package/src/solid/popover.tsx +18 -10
- package/src/solid/responsive-dialog.tsx +9 -9
- package/src/solid/sheet.tsx +47 -79
- package/src/solid/spotlight.tsx +23 -11
- package/src/solid/stale-veil.tsx +20 -0
- package/src/solid/switch.tsx +8 -6
- package/src/solid/tabs.tsx +368 -49
- package/src/solid/toggle-group.tsx +305 -93
- package/src/solid/tooltip.tsx +285 -26
- package/src/styles/globals.css +3 -3
- package/src/styles/theme.css +5 -0
- package/dist/lib/when-animations-settle.d.ts +0 -4
- package/dist/solid/bottom-sheet/focus-trap.d.ts +0 -6
- package/dist/solid/bottom-sheet/scroll-lock.d.ts +0 -2
- package/dist/solid/bottom-sheet/sheet-motion.d.ts +0 -1
- package/src/lib/when-animations-settle.ts +0 -12
- package/src/solid/bottom-sheet/focus-trap.ts +0 -63
- package/src/solid/bottom-sheet/scroll-lock.ts +0 -66
- package/src/solid/bottom-sheet/sheet-motion.ts +0 -4
|
@@ -14,15 +14,22 @@ import {
|
|
|
14
14
|
useContext,
|
|
15
15
|
type ValidComponent,
|
|
16
16
|
} from "solid-js";
|
|
17
|
-
import {
|
|
17
|
+
import { Portal } from "solid-js/web";
|
|
18
|
+
import { Polymorphic } from "../../lib/behavior/polymorphic.js";
|
|
18
19
|
import { usePortalMount } from "../portal-mount.js";
|
|
20
|
+
import { createControllableSignal } from "../../lib/behavior/controllable.js";
|
|
19
21
|
import { Z } from "../../lib/layers.js";
|
|
20
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
OVERLAY_SURFACE_OPAQUE,
|
|
24
|
+
SCRIM_CONTAIN,
|
|
25
|
+
SCROLL_CONTAIN,
|
|
26
|
+
} from "../../lib/overlay-classes.js";
|
|
27
|
+
import { coverNow } from "../../lib/page-cover.js";
|
|
28
|
+
import { callEventHandler, effect } from "../../lib/behavior/solid.js";
|
|
21
29
|
import { cn } from "../../lib/utils.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
30
|
+
import { type MotionEvent, watchMotion } from "../../lib/behavior/presence.js";
|
|
31
|
+
import { MOTION_EXIT_MS } from "../../lib/motion-classes.js";
|
|
24
32
|
import {
|
|
25
|
-
callEventHandler,
|
|
26
33
|
createModalLabels,
|
|
27
34
|
createModalParts,
|
|
28
35
|
MODAL_DESCRIPTION,
|
|
@@ -33,9 +40,11 @@ import {
|
|
|
33
40
|
} from "../dialog-parts.js";
|
|
34
41
|
import { EASE, TRANSITION_MS } from "./constants.js";
|
|
35
42
|
import { attachDrag } from "./drag-controller.js";
|
|
36
|
-
import {
|
|
43
|
+
import { createDismiss } from "../../lib/behavior/dismiss.js";
|
|
44
|
+
import { createFocusScope, type InitialFocus } from "../../lib/behavior/focus-scope.js";
|
|
45
|
+
import { createHideOutside } from "../../lib/behavior/hide-outside.js";
|
|
46
|
+
import { registerLayer } from "../../lib/behavior/layer-stack.js";
|
|
37
47
|
import { watchKeyboard } from "./keyboard.js";
|
|
38
|
-
import { acquireScrollLock, releaseScrollLock } from "./scroll-lock.js";
|
|
39
48
|
import { assertTransition, type SheetState } from "./state-machine.js";
|
|
40
49
|
|
|
41
50
|
interface BottomSheetContextValue {
|
|
@@ -48,6 +57,11 @@ interface BottomSheetContextValue {
|
|
|
48
57
|
setContentRef: (el: HTMLDivElement | undefined) => void;
|
|
49
58
|
}
|
|
50
59
|
|
|
60
|
+
const isSheetMotion = (e: MotionEvent) =>
|
|
61
|
+
"animationName" in e
|
|
62
|
+
? e.animationName === "bs-slide-up" || e.animationName === "bs-slide-down"
|
|
63
|
+
: e.propertyName === "transform";
|
|
64
|
+
|
|
51
65
|
const BottomSheetContext = createContext<BottomSheetContextValue>();
|
|
52
66
|
|
|
53
67
|
function useBottomSheetContext(): BottomSheetContextValue {
|
|
@@ -65,18 +79,14 @@ interface BottomSheetRootProps {
|
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
const BottomSheet: ParentComponent<BottomSheetRootProps> = (props) => {
|
|
68
|
-
const [
|
|
82
|
+
const [open, setOpen] = createControllableSignal<boolean>({
|
|
83
|
+
value: () => props.open,
|
|
84
|
+
defaultValue: () => props.defaultOpen ?? false,
|
|
85
|
+
onChange: (next) => props.onOpenChange?.(next),
|
|
86
|
+
});
|
|
69
87
|
const [state, setStateRaw] = createSignal<SheetState>("closed");
|
|
70
88
|
const [contentRef, setContentRef] = createSignal<HTMLDivElement | undefined>(undefined);
|
|
71
89
|
|
|
72
|
-
const isControlled = () => props.open !== undefined;
|
|
73
|
-
const open = (): boolean => (isControlled() ? props.open === true : uncontrolled());
|
|
74
|
-
|
|
75
|
-
const setOpen = (next: boolean) => {
|
|
76
|
-
if (!isControlled()) setUncontrolled(next);
|
|
77
|
-
props.onOpenChange?.(next);
|
|
78
|
-
};
|
|
79
|
-
|
|
80
90
|
const setState = (next: SheetState) => {
|
|
81
91
|
const current = state();
|
|
82
92
|
assertTransition(current, next);
|
|
@@ -122,11 +132,10 @@ type SheetButtonProps = ComponentProps<"button"> &
|
|
|
122
132
|
const BottomSheetTrigger: ParentComponent<SheetButtonProps> = (props) => {
|
|
123
133
|
const [local, rest] = splitProps(props, ["children", "onClick", "as"]);
|
|
124
134
|
const ctx = useBottomSheetContext();
|
|
125
|
-
const component = () => local.as ?? "button";
|
|
126
135
|
return (
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
136
|
+
<Polymorphic
|
|
137
|
+
defaultAs="button"
|
|
138
|
+
as={local.as}
|
|
130
139
|
data-slot="bottom-sheet-trigger"
|
|
131
140
|
aria-haspopup="dialog"
|
|
132
141
|
aria-expanded={ctx.open()}
|
|
@@ -137,7 +146,7 @@ const BottomSheetTrigger: ParentComponent<SheetButtonProps> = (props) => {
|
|
|
137
146
|
{...rest}
|
|
138
147
|
>
|
|
139
148
|
{local.children}
|
|
140
|
-
</
|
|
149
|
+
</Polymorphic>
|
|
141
150
|
);
|
|
142
151
|
};
|
|
143
152
|
|
|
@@ -175,7 +184,7 @@ const BottomSheetOverlay: Component<ComponentProps<"div">> = (props) => {
|
|
|
175
184
|
data-state={dataState()}
|
|
176
185
|
aria-hidden="true"
|
|
177
186
|
class={cn(
|
|
178
|
-
|
|
187
|
+
`fixed inset-0 bg-black/80 transition-opacity duration-300 ease-out ${SCRIM_CONTAIN}`,
|
|
179
188
|
"data-[state=closing]:opacity-0 data-[state=open]:opacity-100",
|
|
180
189
|
local.class,
|
|
181
190
|
)}
|
|
@@ -203,15 +212,9 @@ const BottomSheetContent: ParentComponent<BottomSheetContentProps> = (props) =>
|
|
|
203
212
|
const labels = createModalLabels();
|
|
204
213
|
let el: HTMLDivElement | undefined;
|
|
205
214
|
|
|
206
|
-
/* Keyed on presence, not on mount: a sheet rendered without
|
|
207
|
-
* BottomSheetPortal stays in the tree while closed and must not hold the
|
|
208
|
-
* page lock. Release also runs on unmount, so no animation can strand it. */
|
|
209
215
|
const present = createMemo(() => ctx.state() !== "closed");
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
acquireScrollLock();
|
|
213
|
-
onCleanup(releaseScrollLock);
|
|
214
|
-
});
|
|
216
|
+
|
|
217
|
+
effect(present, (on) => (on && el ? coverNow(el) : undefined));
|
|
215
218
|
|
|
216
219
|
const clearAnimInline = () => {
|
|
217
220
|
if (!el) return;
|
|
@@ -225,16 +228,20 @@ const BottomSheetContent: ParentComponent<BottomSheetContentProps> = (props) =>
|
|
|
225
228
|
if (s !== "opening" && s !== "closing" && s !== "snapping") return;
|
|
226
229
|
const node = el;
|
|
227
230
|
if (!node) return;
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
231
|
+
onCleanup(
|
|
232
|
+
watchMotion(
|
|
233
|
+
node,
|
|
234
|
+
MOTION_EXIT_MS.sheet,
|
|
235
|
+
() => {
|
|
236
|
+
if (s === "opening") ctx.setState("open");
|
|
237
|
+
else {
|
|
238
|
+
ctx.setState(s === "snapping" ? "open" : "closed");
|
|
239
|
+
clearAnimInline();
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
isSheetMotion,
|
|
243
|
+
),
|
|
244
|
+
);
|
|
238
245
|
});
|
|
239
246
|
|
|
240
247
|
createEffect(() => {
|
|
@@ -257,92 +264,30 @@ const BottomSheetContent: ParentComponent<BottomSheetContentProps> = (props) =>
|
|
|
257
264
|
onCleanup(() => handle.destroy());
|
|
258
265
|
});
|
|
259
266
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
267
|
+
const handle = registerLayer({
|
|
268
|
+
element: ctx.contentRef,
|
|
269
|
+
open: ctx.open,
|
|
270
|
+
kind: "modal",
|
|
271
|
+
escape: ctx.dismissible,
|
|
272
|
+
dismiss: () => ctx.setOpen(false),
|
|
266
273
|
});
|
|
267
274
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
};
|
|
276
|
-
document.addEventListener("keydown", onKey);
|
|
277
|
-
onCleanup(() => document.removeEventListener("keydown", onKey));
|
|
275
|
+
createHideOutside({ layer: handle, active: ctx.open });
|
|
276
|
+
|
|
277
|
+
createFocusScope({
|
|
278
|
+
container: ctx.contentRef,
|
|
279
|
+
active: () => ctx.state() !== "closed" && ctx.state() !== "closing",
|
|
280
|
+
trapped: () => true,
|
|
281
|
+
initialFocus: local.initialFocus ?? "container",
|
|
278
282
|
});
|
|
279
283
|
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
let attached = false;
|
|
288
|
-
let pendingClick: ((click: Event) => void) | null = null;
|
|
289
|
-
|
|
290
|
-
const PORTAL_LAYER_SELECTOR =
|
|
291
|
-
'[data-kb-top-layer], [role="dialog"], [role="menu"], [role="listbox"], [role="combobox"], [role="tooltip"]';
|
|
292
|
-
// Judged along the composed path: a press inside an icon's own shadow root is still inside the
|
|
293
|
-
// sheet. Only the part below the listening root counts: a realm's host inside a page dialog
|
|
294
|
-
// must not make every press in the realm look like one inside a layer.
|
|
295
|
-
const isOutside = (e: Event): boolean => {
|
|
296
|
-
if (!el || !(e.target instanceof Element)) return false;
|
|
297
|
-
const full = e.composedPath();
|
|
298
|
-
const listener = e.currentTarget;
|
|
299
|
-
const end = listener && listener !== document ? full.indexOf(listener) : -1;
|
|
300
|
-
const path = end >= 0 ? full.slice(0, end) : full;
|
|
301
|
-
if (path.includes(el)) return false;
|
|
302
|
-
return !path.some(
|
|
303
|
-
(node) =>
|
|
304
|
-
node instanceof Element &&
|
|
305
|
-
(node.matches("[data-sheet-content]") || node.matches(PORTAL_LAYER_SELECTOR)),
|
|
306
|
-
);
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
// Inside a shadow root the page sees every press there as one on the root's host, so the
|
|
310
|
-
// sheet judges those from its own root and only the page's other presses from the document.
|
|
311
|
-
const scope = (el?.getRootNode() ?? document) as Document | ShadowRoot;
|
|
312
|
-
const scopes: (Document | ShadowRoot)[] = scope === document ? [document] : [scope, document];
|
|
313
|
-
const host = scope instanceof ShadowRoot ? scope.host : undefined;
|
|
314
|
-
const onPointerDown = (e: Event) => {
|
|
315
|
-
if (e.currentTarget === document && host && e.target === host) return;
|
|
316
|
-
// Every press starts over: a touch that scrolled never clicked, and its close must not wait for the next tap.
|
|
317
|
-
if (pendingClick) document.removeEventListener("click", pendingClick);
|
|
318
|
-
pendingClick = null;
|
|
319
|
-
if (!isOutside(e)) return;
|
|
320
|
-
const dismiss = () => {
|
|
321
|
-
if (ctx.state() === "open") ctx.setOpen(false);
|
|
322
|
-
};
|
|
323
|
-
if ((e as PointerEvent).pointerType === "touch") {
|
|
324
|
-
pendingClick = (click: Event) => {
|
|
325
|
-
pendingClick = null;
|
|
326
|
-
// The click lands where the touch ended; it closes only if that is still outside.
|
|
327
|
-
if (el && !click.composedPath().includes(el)) dismiss();
|
|
328
|
-
};
|
|
329
|
-
document.addEventListener("click", pendingClick, { once: true });
|
|
330
|
-
} else {
|
|
331
|
-
dismiss();
|
|
332
|
-
}
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
const timer = window.setTimeout(() => {
|
|
336
|
-
for (const s of scopes) s.addEventListener("pointerdown", onPointerDown, true);
|
|
337
|
-
attached = true;
|
|
338
|
-
}, 0);
|
|
339
|
-
|
|
340
|
-
onCleanup(() => {
|
|
341
|
-
window.clearTimeout(timer);
|
|
342
|
-
if (attached)
|
|
343
|
-
for (const s of scopes) s.removeEventListener("pointerdown", onPointerDown, true);
|
|
344
|
-
if (pendingClick) document.removeEventListener("click", pendingClick);
|
|
345
|
-
});
|
|
284
|
+
createDismiss({
|
|
285
|
+
layer: handle,
|
|
286
|
+
outsidePress: ctx.dismissible,
|
|
287
|
+
onDismiss: (reason) => {
|
|
288
|
+
if (reason === "outside-press" && ctx.state() !== "open") return;
|
|
289
|
+
ctx.setOpen(false);
|
|
290
|
+
},
|
|
346
291
|
});
|
|
347
292
|
|
|
348
293
|
const setRef = (node: HTMLDivElement) => {
|
|
@@ -383,7 +328,7 @@ const BottomSheetContent: ParentComponent<BottomSheetContentProps> = (props) =>
|
|
|
383
328
|
}}
|
|
384
329
|
class={cn(
|
|
385
330
|
"bs-content",
|
|
386
|
-
`fixed inset-x-0 bottom-0 flex ${MODAL_MAX_H} flex-col rounded-t-xl ${OVERLAY_SURFACE_OPAQUE} outline-none`,
|
|
331
|
+
`fixed inset-x-0 bottom-0 flex ${MODAL_MAX_H} flex-col ${SCROLL_CONTAIN} rounded-t-xl ${OVERLAY_SURFACE_OPAQUE} outline-none`,
|
|
387
332
|
"after:absolute after:inset-x-0 after:top-full after:h-1/2 after:bg-inherit",
|
|
388
333
|
local.class,
|
|
389
334
|
)}
|
|
@@ -448,11 +393,10 @@ const BottomSheetDescription: Component<ComponentProps<"p">> = (props) => {
|
|
|
448
393
|
const BottomSheetClose: ParentComponent<SheetButtonProps> = (props) => {
|
|
449
394
|
const [local, rest] = splitProps(props, ["children", "onClick", "as"]);
|
|
450
395
|
const ctx = useBottomSheetContext();
|
|
451
|
-
const component = () => local.as ?? "button";
|
|
452
396
|
return (
|
|
453
|
-
<
|
|
454
|
-
|
|
455
|
-
|
|
397
|
+
<Polymorphic
|
|
398
|
+
defaultAs="button"
|
|
399
|
+
as={local.as}
|
|
456
400
|
data-slot="bottom-sheet-close"
|
|
457
401
|
onClick={(event: MouseEvent & { currentTarget: HTMLButtonElement; target: Element }) => {
|
|
458
402
|
callEventHandler(event, local.onClick);
|
|
@@ -461,7 +405,7 @@ const BottomSheetClose: ParentComponent<SheetButtonProps> = (props) => {
|
|
|
461
405
|
{...rest}
|
|
462
406
|
>
|
|
463
407
|
{local.children}
|
|
464
|
-
</
|
|
408
|
+
</Polymorphic>
|
|
465
409
|
);
|
|
466
410
|
};
|
|
467
411
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { MOTION_EXIT_MS } from "../../lib/motion-classes.js";
|
|
2
|
+
|
|
1
3
|
export const EASE = "cubic-bezier(0.32, 0.72, 0, 1)";
|
|
2
|
-
export const TRANSITION_MS =
|
|
4
|
+
export const TRANSITION_MS = MOTION_EXIT_MS.sheet;
|
|
3
5
|
|
|
4
6
|
export const DEAD_ZONE_PX = 6;
|
|
5
7
|
export const CLOSE_DISTANCE_RATIO = 0.4;
|
|
@@ -43,6 +43,7 @@ export function attachDrag(opts: DragOptions): DragHandle {
|
|
|
43
43
|
let dragAborted = false;
|
|
44
44
|
let height = 0;
|
|
45
45
|
let lastTotalDy = 0;
|
|
46
|
+
let shownDy = 0;
|
|
46
47
|
|
|
47
48
|
const isDraggableState = (): boolean => {
|
|
48
49
|
const s = getState();
|
|
@@ -55,6 +56,7 @@ export function attachDrag(opts: DragOptions): DragHandle {
|
|
|
55
56
|
const value = pendingDy;
|
|
56
57
|
pendingDy = null;
|
|
57
58
|
const applied = value < 0 ? dampen(-value) * -1 : value;
|
|
59
|
+
shownDy = applied;
|
|
58
60
|
el.style.transform = `translate3d(0, ${applied}px, 0)`;
|
|
59
61
|
};
|
|
60
62
|
|
|
@@ -77,6 +79,7 @@ export function attachDrag(opts: DragOptions): DragHandle {
|
|
|
77
79
|
startX = e.clientX;
|
|
78
80
|
pointerTarget = target;
|
|
79
81
|
dy = 0;
|
|
82
|
+
shownDy = 0;
|
|
80
83
|
lastTotalDy = 0;
|
|
81
84
|
movedPastDeadZone = false;
|
|
82
85
|
dragAborted = false;
|
|
@@ -141,6 +144,14 @@ export function attachDrag(opts: DragOptions): DragHandle {
|
|
|
141
144
|
|
|
142
145
|
const settleSnap = () => {
|
|
143
146
|
setState("snapping");
|
|
147
|
+
if (shownDy === 0) {
|
|
148
|
+
el.style.transition = "";
|
|
149
|
+
el.style.animation = "";
|
|
150
|
+
el.style.transform = "";
|
|
151
|
+
setState("open");
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
shownDy = 0;
|
|
144
155
|
el.style.transition = TRANSITION_CSS;
|
|
145
156
|
el.style.animation = "";
|
|
146
157
|
el.style.transform = "translate3d(0, 0, 0)";
|
package/src/solid/breadcrumb.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
splitProps,
|
|
6
6
|
type ValidComponent,
|
|
7
7
|
} from "solid-js";
|
|
8
|
-
import {
|
|
8
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
9
9
|
import { cn } from "../lib/utils.js";
|
|
10
10
|
import { Icon } from "./icon.js";
|
|
11
11
|
|
|
@@ -40,10 +40,10 @@ const BreadcrumbItem: Component<ComponentProps<"li">> = (props) => {
|
|
|
40
40
|
|
|
41
41
|
const BreadcrumbLink: Component<ComponentProps<"a"> & { as?: ValidComponent }> = (props) => {
|
|
42
42
|
const [local, rest] = splitProps(props, ["class", "as"]);
|
|
43
|
-
const Comp = () => local.as || "a";
|
|
44
43
|
return (
|
|
45
|
-
<
|
|
46
|
-
|
|
44
|
+
<Polymorphic
|
|
45
|
+
defaultAs="a"
|
|
46
|
+
as={local.as}
|
|
47
47
|
data-slot="breadcrumb-link"
|
|
48
48
|
class={cn("hover:text-foreground transition-colors", local.class)}
|
|
49
49
|
{...rest}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { cva, type VariantProps } from "cva";
|
|
2
2
|
import { type Component, type ComponentProps, splitProps, type ValidComponent } from "solid-js";
|
|
3
|
-
import {
|
|
3
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
4
4
|
import { cn } from "../lib/utils.js";
|
|
5
5
|
import { Separator } from "./separator.js";
|
|
6
6
|
|
|
@@ -35,10 +35,10 @@ const ButtonGroup: Component<ComponentProps<"div"> & VariantProps<typeof buttonG
|
|
|
35
35
|
|
|
36
36
|
const ButtonGroupText: Component<ComponentProps<"div"> & { as?: ValidComponent }> = (props) => {
|
|
37
37
|
const [local, rest] = splitProps(props, ["class", "as"] as const);
|
|
38
|
-
const Comp = () => local.as || "div";
|
|
39
38
|
return (
|
|
40
|
-
<
|
|
41
|
-
|
|
39
|
+
<Polymorphic
|
|
40
|
+
defaultAs="div"
|
|
41
|
+
as={local.as}
|
|
42
42
|
class={cn(
|
|
43
43
|
"glass text-muted-foreground flex items-center gap-2 rounded-md px-4 text-sm font-medium [--glass-edge:var(--border)] [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",
|
|
44
44
|
local.class,
|
package/src/solid/card.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
splitProps,
|
|
6
6
|
type ValidComponent,
|
|
7
7
|
} from "solid-js";
|
|
8
|
-
import {
|
|
8
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
9
9
|
import {
|
|
10
10
|
CARD_ACTION_CLASS,
|
|
11
11
|
CARD_CONTENT_CLASS,
|
|
@@ -48,8 +48,9 @@ const Card: Component<CardProps> = (props) => {
|
|
|
48
48
|
"children",
|
|
49
49
|
]);
|
|
50
50
|
return (
|
|
51
|
-
<
|
|
52
|
-
|
|
51
|
+
<Polymorphic
|
|
52
|
+
defaultAs="div"
|
|
53
|
+
as={local.as}
|
|
53
54
|
data-slot="card"
|
|
54
55
|
class={cn(
|
|
55
56
|
local.opaque ? CARD_SURFACE_OPAQUE : CARD_SURFACE,
|
|
@@ -63,7 +64,7 @@ const Card: Component<CardProps> = (props) => {
|
|
|
63
64
|
>
|
|
64
65
|
<Show when={local.ornament}>{(kind) => <Ornament kind={kind()} />}</Show>
|
|
65
66
|
{local.children}
|
|
66
|
-
</
|
|
67
|
+
</Polymorphic>
|
|
67
68
|
);
|
|
68
69
|
};
|
|
69
70
|
|
|
@@ -9,7 +9,12 @@ import {
|
|
|
9
9
|
splitProps,
|
|
10
10
|
} from "solid-js";
|
|
11
11
|
import { OVERLAY_MOTION } from "../lib/motion-classes.js";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
createCoveredRoot,
|
|
14
|
+
inShadowRoot,
|
|
15
|
+
ReportCovered,
|
|
16
|
+
shadowLayer,
|
|
17
|
+
} from "../lib/shadow-layer.js";
|
|
13
18
|
import { cn } from "../lib/utils.js";
|
|
14
19
|
import {
|
|
15
20
|
MENU_CONTENT_CLASS,
|
|
@@ -26,7 +31,12 @@ import {
|
|
|
26
31
|
const ContextMenuRoot: Component<ComponentProps<typeof ContextMenuPrimitive>> = (props) => {
|
|
27
32
|
// Modal in a shadow root, Kobalte would aria-hide the realm's host, menu included.
|
|
28
33
|
const inShadow = inShadowRoot(usePortalMount());
|
|
29
|
-
|
|
34
|
+
const cover = createCoveredRoot();
|
|
35
|
+
return (
|
|
36
|
+
<ReportCovered.Provider value={cover.report}>
|
|
37
|
+
<ContextMenuPrimitive {...props} modal={inShadow || cover.covered() ? false : props.modal} />
|
|
38
|
+
</ReportCovered.Provider>
|
|
39
|
+
);
|
|
30
40
|
};
|
|
31
41
|
const ContextMenu = Object.assign(ContextMenuRoot, ContextMenuPrimitive) as Component<
|
|
32
42
|
ComponentProps<typeof ContextMenuPrimitive>
|