@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
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Button as KobalteButton } from "@kobalte/core/button";
|
|
2
|
-
import { useDialogContext } from "@kobalte/core/dialog";
|
|
3
2
|
import {
|
|
4
3
|
type Accessor,
|
|
5
4
|
children,
|
|
6
5
|
type Component,
|
|
7
6
|
type ComponentProps,
|
|
8
7
|
createContext,
|
|
8
|
+
createEffect,
|
|
9
9
|
createSignal,
|
|
10
10
|
createUniqueId,
|
|
11
11
|
type JSX,
|
|
@@ -17,19 +17,114 @@ import {
|
|
|
17
17
|
useContext,
|
|
18
18
|
type ValidComponent,
|
|
19
19
|
} from "solid-js";
|
|
20
|
-
import {
|
|
20
|
+
import {
|
|
21
|
+
type FocusOutsideEvent,
|
|
22
|
+
type InteractOutsideEvent,
|
|
23
|
+
ModalDescription,
|
|
24
|
+
type ModalPartProps,
|
|
25
|
+
type PointerDownOutsideEvent,
|
|
26
|
+
type ModalRole,
|
|
27
|
+
ModalRoot,
|
|
28
|
+
ModalTitle,
|
|
29
|
+
ModalTrigger,
|
|
30
|
+
} from "../lib/behavior/modal-root.js";
|
|
31
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
32
|
+
import { callEventHandler } from "../lib/behavior/solid.js";
|
|
21
33
|
import { busyProps } from "../lib/busy.js";
|
|
22
34
|
import { Z_CLASS } from "../lib/layers.js";
|
|
23
35
|
import { ANCHORED_MOTION, MODAL_MOTION, SCRIM_MOTION } from "../lib/motion-classes.js";
|
|
24
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
OVERLAY_SURFACE,
|
|
38
|
+
SCRIM_CLASS,
|
|
39
|
+
SCRIM_CONTAIN,
|
|
40
|
+
SCROLL_CONTAIN,
|
|
41
|
+
} from "../lib/overlay-classes.js";
|
|
42
|
+
import { coverOnceOpen } from "../lib/page-cover.js";
|
|
43
|
+
import { inShadowRoot } from "../lib/shadow-layer.js";
|
|
25
44
|
import { cn } from "../lib/utils.js";
|
|
26
|
-
import {
|
|
45
|
+
import { usePortalMount } from "./portal-mount.js";
|
|
27
46
|
import { SectionIcon } from "./section-card.js";
|
|
28
47
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
48
|
+
export interface ModalRootSkinProps {
|
|
49
|
+
open?: boolean;
|
|
50
|
+
defaultOpen?: boolean;
|
|
51
|
+
onOpenChange?: (open: boolean) => void;
|
|
52
|
+
/** Modal toward the page. Defaults to true on the page and false inside a shadow root. */
|
|
53
|
+
modal?: boolean;
|
|
54
|
+
/** Stays mounted and dormant after it closes, so the next open shows the same nodes instead of building them. */
|
|
55
|
+
keep?: boolean;
|
|
56
|
+
/** @deprecated No effect; the panel takes its own id. */
|
|
57
|
+
id?: string;
|
|
58
|
+
/** @deprecated No effect; the panel stays mounted through its exit on its own. */
|
|
59
|
+
forceMount?: boolean;
|
|
60
|
+
/** @deprecated No effect; a dialog never locks page scroll. */
|
|
61
|
+
preventScroll?: boolean;
|
|
62
|
+
/** @deprecated No effect. */
|
|
63
|
+
translations?: Record<string, string>;
|
|
64
|
+
children?: JSX.Element;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function createModalRootSkin(role: ModalRole): ParentComponent<ModalRootSkinProps> {
|
|
68
|
+
return (props) => {
|
|
69
|
+
const mount = usePortalMount();
|
|
70
|
+
return (
|
|
71
|
+
<ModalRoot
|
|
72
|
+
open={props.open}
|
|
73
|
+
defaultOpen={props.defaultOpen}
|
|
74
|
+
onOpenChange={props.onOpenChange}
|
|
75
|
+
modal={props.modal ?? !inShadowRoot(mount)}
|
|
76
|
+
keep={props.keep}
|
|
77
|
+
role={role}
|
|
78
|
+
>
|
|
79
|
+
{props.children}
|
|
80
|
+
</ModalRoot>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export type ModalContentProps = Omit<ComponentProps<"div">, "style" | "role"> & {
|
|
86
|
+
as?: ValidComponent;
|
|
87
|
+
style?: JSX.CSSProperties | string;
|
|
88
|
+
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
89
|
+
onPointerDownOutside?: (event: PointerDownOutsideEvent) => void;
|
|
90
|
+
onInteractOutside?: (event: InteractOutsideEvent) => void;
|
|
91
|
+
onOpenAutoFocus?: (event: Event) => void;
|
|
92
|
+
onCloseAutoFocus?: (event: Event) => void;
|
|
93
|
+
/** @deprecated No effect; focus never leaves an open dialog. */
|
|
94
|
+
onFocusOutside?: (event: FocusOutsideEvent) => void;
|
|
95
|
+
/** @deprecated No effect; the panel stays mounted through its exit on its own. */
|
|
96
|
+
forceMount?: boolean;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export interface ModalTextParts {
|
|
100
|
+
Trigger: <T extends ValidComponent = "button">(props: ModalPartProps<T>) => JSX.Element;
|
|
101
|
+
Title: <T extends ValidComponent = "h2">(props: ModalPartProps<T>) => JSX.Element;
|
|
102
|
+
Description: <T extends ValidComponent = "p">(props: ModalPartProps<T>) => JSX.Element;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function createModalTextParts(slot: string): ModalTextParts {
|
|
106
|
+
return {
|
|
107
|
+
Trigger: (props) => (
|
|
108
|
+
<ModalTrigger data-slot={`${slot}-trigger`} {...(props as ModalPartProps<"button">)} />
|
|
109
|
+
),
|
|
110
|
+
Title: (props) => {
|
|
111
|
+
const [local, rest] = splitProps(props as ModalPartProps<"h2">, ["class"]);
|
|
112
|
+
return (
|
|
113
|
+
<ModalTitle data-slot={`${slot}-title`} class={cn(MODAL_TITLE, local.class)} {...rest} />
|
|
114
|
+
);
|
|
115
|
+
},
|
|
116
|
+
Description: (props) => {
|
|
117
|
+
const [local, rest] = splitProps(props as ModalPartProps<"p">, ["class"]);
|
|
118
|
+
return (
|
|
119
|
+
<ModalDescription
|
|
120
|
+
data-slot={`${slot}-description`}
|
|
121
|
+
class={cn(MODAL_DESCRIPTION, local.class)}
|
|
122
|
+
{...rest}
|
|
123
|
+
/>
|
|
124
|
+
);
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
33
128
|
|
|
34
129
|
export type ModalSize = "sm" | "md" | "lg" | "xl" | "full";
|
|
35
130
|
|
|
@@ -62,13 +157,13 @@ export const MODAL_ANCHOR: Record<ModalSize, string> = {
|
|
|
62
157
|
/* The panel: it clips, it never scrolls, and it carries no padding. Every inset
|
|
63
158
|
* belongs to Header, Body or Footer, so the Body scrollbar rides inside the
|
|
64
159
|
* panel edge instead of under the header. */
|
|
65
|
-
export const MODAL_PANEL = `${OVERLAY_SURFACE} ${MODAL_MOTION} fixed left-1/2 flex ${MODAL_MAX_H} w-[calc(100%-2rem)] -translate-x-1/2 flex-col overflow-hidden rounded-lg outline-none ${Z_CLASS.overlay}`;
|
|
160
|
+
export const MODAL_PANEL = `${OVERLAY_SURFACE} ${MODAL_MOTION} fixed left-1/2 flex ${MODAL_MAX_H} w-[calc(100%-2rem)] -translate-x-1/2 flex-col overflow-hidden ${SCROLL_CONTAIN} rounded-lg outline-none ${Z_CLASS.overlay}`;
|
|
66
161
|
|
|
67
162
|
/* A panel anchored on the element that opened it: placed and sized inline (lib/anchor-placement),
|
|
68
163
|
* so it drops the centring, and it unrolls out of that element instead of rising in. */
|
|
69
|
-
export const ANCHORED_PANEL = `${OVERLAY_SURFACE} ${ANCHORED_MOTION} fixed flex ${MODAL_MAX_H} flex-col overflow-hidden rounded-lg outline-none ${Z_CLASS.overlay}`;
|
|
164
|
+
export const ANCHORED_PANEL = `${OVERLAY_SURFACE} ${ANCHORED_MOTION} fixed flex ${MODAL_MAX_H} flex-col overflow-hidden ${SCROLL_CONTAIN} rounded-lg outline-none ${Z_CLASS.overlay}`;
|
|
70
165
|
|
|
71
|
-
export const MODAL_SCRIM = `${SCRIM_MOTION} fixed inset-0 ${Z_CLASS.overlay} ${SCRIM_CLASS}`;
|
|
166
|
+
export const MODAL_SCRIM = `${SCRIM_MOTION} fixed inset-0 ${Z_CLASS.overlay} ${SCRIM_CLASS} ${SCRIM_CONTAIN}`;
|
|
72
167
|
|
|
73
168
|
const MODAL_HEADER =
|
|
74
169
|
"flex shrink-0 items-start gap-4 px-6 pt-6 pb-3 in-data-[slot=bottom-sheet-content]:px-4 [[data-slot=bottom-sheet-handle]+&]:pt-1";
|
|
@@ -81,9 +176,8 @@ const MODAL_HEADER_ACTION = "flex shrink-0 items-center gap-2";
|
|
|
81
176
|
|
|
82
177
|
/* The only scroll container.
|
|
83
178
|
* - The inset is the full one and a Header or Footer sibling shortens it, keyed
|
|
84
|
-
* on data-slot rather than on position:
|
|
85
|
-
*
|
|
86
|
-
* element siblings, so `first:`/`first-of-type:` all lie.
|
|
179
|
+
* on data-slot rather than on position: Sheet's `above` and the sheet handle
|
|
180
|
+
* add element siblings, so `first:`/`first-of-type:` lie.
|
|
87
181
|
* - `pan-y pinch-zoom` leaves the single-finger vertical gesture to the sheet's
|
|
88
182
|
* drag arbitration without taking two-finger zoom away.
|
|
89
183
|
* - The reserved scrollbar lives inside the right inset, so the content column
|
|
@@ -155,8 +249,9 @@ export function createModalParts(slot: string): ModalParts {
|
|
|
155
249
|
if (el) el.style.setProperty("--scrollbar-gutter", `${el.offsetWidth - el.clientWidth}px`);
|
|
156
250
|
});
|
|
157
251
|
return (
|
|
158
|
-
<
|
|
159
|
-
|
|
252
|
+
<Polymorphic
|
|
253
|
+
defaultAs="div"
|
|
254
|
+
as={local.as}
|
|
160
255
|
ref={(node: HTMLElement) => {
|
|
161
256
|
el = node;
|
|
162
257
|
if (typeof local.ref === "function") local.ref(node as HTMLDivElement);
|
|
@@ -226,32 +321,21 @@ export function createModalHead<P extends ModalHeadProps = ModalHeadProps>(
|
|
|
226
321
|
};
|
|
227
322
|
}
|
|
228
323
|
|
|
229
|
-
/** Solid's handler prop is a union: a plain function, or the bound
|
|
230
|
-
* `[handler, data]` form that calls `handler(data, event)`. A wrapper that
|
|
231
|
-
* only checks for a function silently drops the bound one. */
|
|
232
|
-
export function callEventHandler<T, E extends Event>(
|
|
233
|
-
event: E & { currentTarget: T; target: Element },
|
|
234
|
-
handler: JSX.EventHandlerUnion<T, E> | undefined,
|
|
235
|
-
): void {
|
|
236
|
-
if (!handler) return;
|
|
237
|
-
if (typeof handler === "function") handler(event);
|
|
238
|
-
else handler[0](handler[1], event);
|
|
239
|
-
}
|
|
240
|
-
|
|
241
324
|
export type ModalDismissProps = ComponentProps<typeof KobalteButton> & {
|
|
242
325
|
/** Presses do nothing, the dialog stays open and focus stays put; see Button. */
|
|
243
326
|
busy?: boolean;
|
|
244
327
|
};
|
|
245
328
|
|
|
246
|
-
/*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
329
|
+
/* A name is set only when the caller passes one: an aria-label outranks the
|
|
330
|
+
* visible text, so a default label would rename every close button. Each
|
|
331
|
+
* family hands in the context its parts close through. */
|
|
332
|
+
export function createModalDismiss(
|
|
333
|
+
slot: string,
|
|
334
|
+
useCloser: () => { close(): void },
|
|
335
|
+
): ParentComponent<ModalDismissProps> {
|
|
252
336
|
return (props) => {
|
|
253
337
|
const [local, rest] = splitProps(props, ["onClick", "busy"]);
|
|
254
|
-
const context =
|
|
338
|
+
const context = useCloser();
|
|
255
339
|
return (
|
|
256
340
|
<KobalteButton
|
|
257
341
|
data-slot={slot}
|
|
@@ -266,11 +350,16 @@ export function createModalDismiss(slot: string): ParentComponent<ModalDismissPr
|
|
|
266
350
|
};
|
|
267
351
|
}
|
|
268
352
|
|
|
269
|
-
/** Renderless
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
353
|
+
/** Renderless, inside the modal's portal: the panel covers the page from the end of its open animation until the portal leaves. */
|
|
354
|
+
export const ModalCover: Component<{
|
|
355
|
+
panel: Accessor<Element | undefined>;
|
|
356
|
+
open: Accessor<boolean>;
|
|
357
|
+
dormant: Accessor<boolean>;
|
|
358
|
+
}> = (props) => {
|
|
359
|
+
createEffect(() => {
|
|
360
|
+
const panel = props.panel();
|
|
361
|
+
if (panel && !props.dormant()) onCleanup(coverOnceOpen(panel, props.open));
|
|
362
|
+
});
|
|
274
363
|
return null;
|
|
275
364
|
};
|
|
276
365
|
|
|
@@ -285,9 +374,9 @@ export interface ModalLabels {
|
|
|
285
374
|
|
|
286
375
|
const ModalLabelsContext = createContext<ModalLabels>();
|
|
287
376
|
|
|
288
|
-
/**
|
|
289
|
-
*
|
|
290
|
-
*
|
|
377
|
+
/** ModalRoot wires title/description ids for its families; BottomSheet wires
|
|
378
|
+
* them through this. The part registers the id it actually rendered, so a
|
|
379
|
+
* caller's own `id` still labels the panel. */
|
|
291
380
|
export function createModalLabels(): ModalLabels {
|
|
292
381
|
const titleId = createUniqueId();
|
|
293
382
|
const descriptionId = createUniqueId();
|
package/src/solid/dialog.tsx
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import { Dialog as DialogPrimitive, useDialogContext } from "@kobalte/core/dialog";
|
|
2
1
|
import { usePortalMount } from "./portal-mount.js";
|
|
3
2
|
import type { VariantProps } from "cva";
|
|
4
3
|
import {
|
|
5
4
|
type Component,
|
|
6
5
|
type ComponentProps,
|
|
7
6
|
createEffect,
|
|
7
|
+
createMemo,
|
|
8
8
|
createSignal,
|
|
9
|
+
type JSX,
|
|
9
10
|
onCleanup,
|
|
10
11
|
type ParentComponent,
|
|
11
12
|
splitProps,
|
|
12
13
|
} from "solid-js";
|
|
13
14
|
import { overAnchor } from "../lib/anchor-placement.js";
|
|
14
|
-
import {
|
|
15
|
+
import { ModalFrame, useDialogContext } from "../lib/behavior/modal-root.js";
|
|
16
|
+
import { MOTION_EXIT_MS } from "../lib/motion-classes.js";
|
|
15
17
|
import { buttonVariants } from "../lib/button-variants.js";
|
|
16
18
|
import { cn } from "../lib/utils.js";
|
|
17
19
|
import {
|
|
@@ -19,33 +21,30 @@ import {
|
|
|
19
21
|
createModalDismiss,
|
|
20
22
|
createModalHead,
|
|
21
23
|
createModalParts,
|
|
24
|
+
createModalRootSkin,
|
|
25
|
+
createModalTextParts,
|
|
22
26
|
MODAL_ANCHOR,
|
|
23
|
-
MODAL_DESCRIPTION,
|
|
24
27
|
MODAL_PANEL,
|
|
25
28
|
MODAL_SCRIM,
|
|
26
|
-
MODAL_TITLE,
|
|
27
29
|
MODAL_WIDTH,
|
|
30
|
+
type ModalContentProps,
|
|
28
31
|
type ModalDismissProps,
|
|
29
|
-
|
|
32
|
+
ModalCover,
|
|
30
33
|
type ModalSize,
|
|
31
34
|
} from "./dialog-parts.js";
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
* (bottom-sheet/scroll-lock.ts) serves every modal family, so a nested modal
|
|
35
|
-
* cannot release the page early. */
|
|
36
|
-
const Dialog: ParentComponent<ComponentProps<typeof DialogPrimitive>> = (props) => {
|
|
37
|
-
const mount = usePortalMount();
|
|
38
|
-
return <DialogPrimitive modal={!inShadowRoot(mount)} {...props} preventScroll={false} />;
|
|
39
|
-
};
|
|
36
|
+
const Dialog = createModalRootSkin("dialog");
|
|
40
37
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
const {
|
|
39
|
+
Trigger: DialogTrigger,
|
|
40
|
+
Title: DialogTitle,
|
|
41
|
+
Description: DialogDescription,
|
|
42
|
+
} = createModalTextParts("dialog");
|
|
44
43
|
|
|
45
44
|
type DialogCloseProps = ModalDismissProps &
|
|
46
45
|
Partial<Pick<VariantProps<typeof buttonVariants>, "variant" | "size">>;
|
|
47
46
|
|
|
48
|
-
const DialogDismiss = createModalDismiss("dialog-close");
|
|
47
|
+
const DialogDismiss = createModalDismiss("dialog-close", useDialogContext);
|
|
49
48
|
|
|
50
49
|
/** Already the outline button, so `as` is for a non-button element (a link),
|
|
51
50
|
* never for `Button`: two buttonVariants() calls leave tone knobs side by side
|
|
@@ -65,7 +64,7 @@ const DialogClose: ParentComponent<DialogCloseProps> = (props) => {
|
|
|
65
64
|
);
|
|
66
65
|
};
|
|
67
66
|
|
|
68
|
-
type DialogContentProps =
|
|
67
|
+
type DialogContentProps = ModalContentProps & {
|
|
69
68
|
size?: ModalSize;
|
|
70
69
|
/** Names a panel that has no `DialogTitle`. A registered Title wins. */
|
|
71
70
|
ariaLabel?: string;
|
|
@@ -92,97 +91,66 @@ const DialogContent: ParentComponent<DialogContentProps> = (props) => {
|
|
|
92
91
|
"anchor",
|
|
93
92
|
"style",
|
|
94
93
|
"ref",
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"onOpenAutoFocus",
|
|
94
|
+
"onFocusOutside",
|
|
95
|
+
"forceMount",
|
|
98
96
|
]);
|
|
99
|
-
const
|
|
97
|
+
const ctx = useDialogContext();
|
|
100
98
|
const [viewport, setViewport] = createSignal(0);
|
|
101
|
-
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
102
|
-
const layer = shadowLayer({
|
|
103
|
-
content: panel,
|
|
104
|
-
open: () => context.isOpen(),
|
|
105
|
-
dismiss: () => context.close(),
|
|
106
|
-
trapsFocus: true,
|
|
107
|
-
consumer: local,
|
|
108
|
-
});
|
|
109
99
|
const [height, setHeight] = createSignal<number>();
|
|
110
100
|
createEffect(() => {
|
|
111
|
-
if (!local.anchor || !
|
|
101
|
+
if (!local.anchor || !ctx.isOpen()) return;
|
|
112
102
|
const measure = () => setViewport((n) => n + 1);
|
|
113
103
|
window.addEventListener("resize", measure);
|
|
114
104
|
onCleanup(() => window.removeEventListener("resize", measure));
|
|
115
105
|
});
|
|
116
106
|
createEffect(() => {
|
|
117
|
-
const el = panel();
|
|
107
|
+
const el = ctx.panel();
|
|
118
108
|
if (!local.anchor || !el) return;
|
|
119
109
|
setHeight(el.offsetHeight);
|
|
120
110
|
const observer = new ResizeObserver(() => setHeight(el.offsetHeight));
|
|
121
111
|
observer.observe(el);
|
|
122
112
|
onCleanup(() => observer.disconnect());
|
|
123
113
|
});
|
|
124
|
-
const placement = () => {
|
|
114
|
+
const placement = createMemo<JSX.CSSProperties | undefined>((last) => {
|
|
115
|
+
if (!ctx.isOpen()) return last;
|
|
125
116
|
viewport();
|
|
126
117
|
const a = local.anchor;
|
|
127
118
|
return a ? overAnchor(a, ANCHORED_WIDTH[local.size ?? "lg"], height()) : undefined;
|
|
128
|
-
};
|
|
119
|
+
});
|
|
129
120
|
return (
|
|
130
|
-
|
|
131
|
-
<
|
|
132
|
-
<
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
data-slot="dialog-content"
|
|
139
|
-
role="dialog"
|
|
140
|
-
aria-label={context.titleId() ? undefined : local.ariaLabel}
|
|
141
|
-
class={cn(
|
|
121
|
+
<>
|
|
122
|
+
<ModalCover panel={ctx.panel} open={ctx.isOpen} dormant={ctx.dormant} />
|
|
123
|
+
<ModalFrame
|
|
124
|
+
slot="dialog"
|
|
125
|
+
mount={usePortalMount()}
|
|
126
|
+
exitMs={local.anchor ? MOTION_EXIT_MS.anchored : MOTION_EXIT_MS.modal}
|
|
127
|
+
scrimClass={MODAL_SCRIM}
|
|
128
|
+
panelClass={cn(
|
|
142
129
|
local.anchor ? ANCHORED_PANEL : MODAL_PANEL,
|
|
143
130
|
!local.anchor && MODAL_WIDTH[local.size ?? "lg"],
|
|
144
131
|
!local.anchor && MODAL_ANCHOR[local.size ?? "lg"],
|
|
145
132
|
local.class,
|
|
146
133
|
)}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
134
|
+
panelStyle={{ ...(typeof local.style === "object" ? local.style : {}), ...placement() }}
|
|
135
|
+
ariaLabel={local.ariaLabel}
|
|
136
|
+
ref={(el: HTMLElement) => {
|
|
137
|
+
if (typeof local.ref === "function") local.ref(el as HTMLDivElement);
|
|
138
|
+
}}
|
|
151
139
|
{...others}
|
|
152
140
|
>
|
|
153
141
|
{local.children}
|
|
154
|
-
</
|
|
155
|
-
|
|
142
|
+
</ModalFrame>
|
|
143
|
+
</>
|
|
156
144
|
);
|
|
157
145
|
};
|
|
158
146
|
|
|
159
147
|
const { Header: DialogHeader, Body: DialogBody, Footer: DialogFooter } = createModalParts("dialog");
|
|
160
148
|
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
class={cn(MODAL_TITLE, local.class)}
|
|
167
|
-
{...others}
|
|
168
|
-
/>
|
|
169
|
-
);
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
const DialogDescription: Component<ComponentProps<typeof DialogPrimitive.Description>> = (
|
|
173
|
-
props,
|
|
174
|
-
) => {
|
|
175
|
-
const [local, others] = splitProps(props, ["class"]);
|
|
176
|
-
return (
|
|
177
|
-
<DialogPrimitive.Description
|
|
178
|
-
data-slot="dialog-description"
|
|
179
|
-
class={cn(MODAL_DESCRIPTION, local.class)}
|
|
180
|
-
{...others}
|
|
181
|
-
/>
|
|
182
|
-
);
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
const DialogHead = createModalHead(DialogHeader, DialogTitle, DialogDescription);
|
|
149
|
+
const DialogHead = createModalHead(
|
|
150
|
+
DialogHeader,
|
|
151
|
+
DialogTitle as Component<ComponentProps<"h2">>,
|
|
152
|
+
DialogDescription as Component<ComponentProps<"p">>,
|
|
153
|
+
);
|
|
186
154
|
|
|
187
155
|
export {
|
|
188
156
|
Dialog,
|
package/src/solid/dock-edit.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createSignal, For, onCleanup, Show } from "solid-js";
|
|
2
2
|
import { Portal } from "solid-js/web";
|
|
3
|
+
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
3
4
|
import { Z_CLASS } from "../lib/layers.js";
|
|
4
5
|
import { cn } from "../lib/utils.js";
|
|
5
6
|
import { type EdgeZone, edgeZone, moveId, slotAt } from "./dock-paging.js";
|
|
@@ -136,10 +137,10 @@ export function createDockReorder(options: ReorderOptions) {
|
|
|
136
137
|
if (ids.indexOf(id) < 0 || to < 0 || to >= ids.length) return;
|
|
137
138
|
options.onReorder(moveId(ids, id, to));
|
|
138
139
|
requestAnimationFrame(() =>
|
|
139
|
-
|
|
140
|
-
.bar()
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
focusWithoutTracking(
|
|
141
|
+
options.bar()?.querySelector<HTMLElement>(`[data-dock-id="${CSS.escape(id)}"]`),
|
|
142
|
+
{ preventScroll: false },
|
|
143
|
+
),
|
|
143
144
|
);
|
|
144
145
|
}
|
|
145
146
|
|
package/src/solid/dock.tsx
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
Show,
|
|
14
14
|
splitProps,
|
|
15
15
|
} from "solid-js";
|
|
16
|
-
import {
|
|
16
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
17
17
|
import { CARD_SURFACE } from "../lib/card-classes.js";
|
|
18
18
|
import { DOCK_SLOT_SHAPE } from "../lib/dock-slot-classes.js";
|
|
19
19
|
import {
|
|
@@ -133,8 +133,8 @@ const DockIconButton: Component<DockIconButtonProps> = (props) => {
|
|
|
133
133
|
{isElement() ? (
|
|
134
134
|
(local.icon as JSX.Element)
|
|
135
135
|
) : (
|
|
136
|
-
<
|
|
137
|
-
|
|
136
|
+
<Polymorphic
|
|
137
|
+
defaultAs={local.icon as Component<{ class?: string }>}
|
|
138
138
|
class="h-5 w-5 sm:h-6 sm:w-6"
|
|
139
139
|
/>
|
|
140
140
|
)}
|
|
@@ -9,7 +9,12 @@ import {
|
|
|
9
9
|
splitProps,
|
|
10
10
|
} from "solid-js";
|
|
11
11
|
import { MORPH_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 { anchorToTriggerTop } from "../lib/overlay-classes.js";
|
|
14
19
|
import { cn } from "../lib/utils.js";
|
|
15
20
|
import {
|
|
@@ -29,13 +34,16 @@ import {
|
|
|
29
34
|
const DropdownMenuRoot: Component<ComponentProps<typeof DropdownMenuPrimitive>> = (props) => {
|
|
30
35
|
// Modal in a shadow root, Kobalte would aria-hide the realm's host, menu included.
|
|
31
36
|
const inShadow = inShadowRoot(usePortalMount());
|
|
37
|
+
const cover = createCoveredRoot();
|
|
32
38
|
return (
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
<ReportCovered.Provider value={cover.report}>
|
|
40
|
+
<DropdownMenuPrimitive
|
|
41
|
+
gutter={0}
|
|
42
|
+
getAnchorRect={anchorToTriggerTop}
|
|
43
|
+
{...props}
|
|
44
|
+
modal={inShadow || cover.covered() ? false : props.modal}
|
|
45
|
+
/>
|
|
46
|
+
</ReportCovered.Provider>
|
|
39
47
|
);
|
|
40
48
|
};
|
|
41
49
|
const DropdownMenu = Object.assign(DropdownMenuRoot, DropdownMenuPrimitive) as Component<
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type ParentComponent,
|
|
10
10
|
Show,
|
|
11
11
|
} from "solid-js";
|
|
12
|
+
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
12
13
|
import { MENU_LABEL } from "../lib/menu-classes.js";
|
|
13
14
|
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
14
15
|
import { createIsMobile } from "../lib/use-is-mobile.js";
|
|
@@ -627,7 +628,7 @@ export function EntitySelector(props: EntitySelectorProps) {
|
|
|
627
628
|
e.preventDefault();
|
|
628
629
|
// preventScroll: the panel is portalled at (0,0) until the popper places it,
|
|
629
630
|
// so a plain focus() scrolls the page to the top.
|
|
630
|
-
inputRef
|
|
631
|
+
focusWithoutTracking(inputRef);
|
|
631
632
|
}}
|
|
632
633
|
onInteractOutside={() => closePicker()}
|
|
633
634
|
>
|
package/src/solid/form.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
useContext,
|
|
17
17
|
type ValidComponent,
|
|
18
18
|
} from "solid-js";
|
|
19
|
-
import {
|
|
19
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
20
20
|
import { cn } from "../lib/utils.js";
|
|
21
21
|
import { Field, FieldDescription, FieldError, FieldLabel } from "./field.js";
|
|
22
22
|
import { Input } from "./input.js";
|
|
@@ -174,8 +174,9 @@ const FormControl = <T extends ValidComponent = typeof Input>(
|
|
|
174
174
|
<Show
|
|
175
175
|
when={wrapped()}
|
|
176
176
|
fallback={
|
|
177
|
-
<
|
|
178
|
-
|
|
177
|
+
<Polymorphic
|
|
178
|
+
defaultAs={Input}
|
|
179
|
+
as={local.as}
|
|
179
180
|
id={formItemId()}
|
|
180
181
|
aria-describedby={describedBy()}
|
|
181
182
|
aria-invalid={error() ? true : undefined}
|
package/src/solid/hover-card.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HoverCard as HoverCardPrimitive } from "@kobalte/core/hover-card";
|
|
1
|
+
import { HoverCard as HoverCardPrimitive, useHoverCardContext } from "@kobalte/core/hover-card";
|
|
2
2
|
import { usePortalMount } from "./portal-mount.js";
|
|
3
3
|
import { type Component, type ComponentProps, createSignal, splitProps } from "solid-js";
|
|
4
4
|
import { OVERLAY_MOTION } from "../lib/motion-classes.js";
|
|
@@ -16,7 +16,12 @@ const HoverCardContent: Component<ComponentProps<typeof HoverCardPrimitive.Conte
|
|
|
16
16
|
const [local, rest] = splitProps(props, ["class", "ref", "onInteractOutside"]);
|
|
17
17
|
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
18
18
|
// A hover card closes as the pointer leaves; inside a shadow root it only must not close on its own presses.
|
|
19
|
-
const
|
|
19
|
+
const card = useHoverCardContext();
|
|
20
|
+
const { onInteractOutside } = shadowLayer({
|
|
21
|
+
content: panel,
|
|
22
|
+
open: () => card.isOpen(),
|
|
23
|
+
consumer: local,
|
|
24
|
+
});
|
|
20
25
|
return (
|
|
21
26
|
<HoverCardPrimitive.Portal data-slot="hover-card-portal" mount={usePortalMount()}>
|
|
22
27
|
<HoverCardPrimitive.Content
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createMemo, createSignal, For, Show } from "solid-js";
|
|
2
|
+
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
2
3
|
import { STAGGER } from "../lib/motion-classes.js";
|
|
3
4
|
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
4
5
|
import { CHIP, ICON_PILL_TINT } from "../lib/pill-classes.js";
|
|
@@ -381,7 +382,7 @@ export function IconPicker(props: IconPickerProps) {
|
|
|
381
382
|
e.preventDefault();
|
|
382
383
|
// preventScroll: the panel is portalled at (0,0) until the popper places it,
|
|
383
384
|
// so a plain focus() scrolls the page to the top.
|
|
384
|
-
searchRef
|
|
385
|
+
focusWithoutTracking(searchRef);
|
|
385
386
|
}}
|
|
386
387
|
onInteractOutside={() => setOpen(false)}
|
|
387
388
|
>
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Show,
|
|
9
9
|
Switch,
|
|
10
10
|
} from "solid-js";
|
|
11
|
+
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
11
12
|
import { FIELD_CHROME } from "../lib/input-classes.js";
|
|
12
13
|
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
13
14
|
import { SECTION_INNER_RADIUS } from "../lib/section-tokens.js";
|
|
@@ -218,7 +219,7 @@ function ImageGallery(
|
|
|
218
219
|
const fail = (cause: unknown) => setError(toMediaStoreError(cause));
|
|
219
220
|
|
|
220
221
|
// A control that disables or leaves drops focus to the page, which a sealed dialog's trap moves outside, closing the gallery.
|
|
221
|
-
const holdFocus = () => panel
|
|
222
|
+
const holdFocus = () => focusWithoutTracking(panel);
|
|
222
223
|
const focused = () => (panel?.getRootNode() as Document | ShadowRoot | undefined)?.activeElement;
|
|
223
224
|
const focusLost = () => {
|
|
224
225
|
const at = focused();
|
|
@@ -313,7 +314,7 @@ function ImageGallery(
|
|
|
313
314
|
// A key pressed as the gallery opens lands on the panel, never on a tile it would pick.
|
|
314
315
|
onOpenAutoFocus={(event: Event) => {
|
|
315
316
|
event.preventDefault();
|
|
316
|
-
panel
|
|
317
|
+
focusWithoutTracking(panel);
|
|
317
318
|
}}
|
|
318
319
|
onInteractOutside={(event) => {
|
|
319
320
|
// The delete confirmation takes focus; the gallery stays open to show the result.
|
|
@@ -353,7 +354,7 @@ function ImageGallery(
|
|
|
353
354
|
const again = panel?.querySelector<HTMLElement>(
|
|
354
355
|
'[data-slot="image-picker-retry"]',
|
|
355
356
|
);
|
|
356
|
-
if (focused() === panel) again
|
|
357
|
+
if (focused() === panel) focusWithoutTracking(again);
|
|
357
358
|
}}
|
|
358
359
|
>
|
|
359
360
|
Try again
|
|
@@ -510,7 +511,7 @@ function ImageGallery(
|
|
|
510
511
|
// The confirmation has no trigger to return to; the page would get focus and the gallery would close.
|
|
511
512
|
event.preventDefault();
|
|
512
513
|
if (!deleteConfirmed && deleteFrom instanceof HTMLElement && deleteFrom.isConnected) {
|
|
513
|
-
deleteFrom
|
|
514
|
+
focusWithoutTracking(deleteFrom);
|
|
514
515
|
} else holdFocus();
|
|
515
516
|
}}
|
|
516
517
|
>
|