@glasshome/ui 1.40.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 +25 -2
- 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 +4 -1
- 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 +13 -15
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +2 -6
- package/dist/solid/bottom-sheet/constants.d.ts +1 -1
- package/dist/solid/confirm-dialog.d.ts +22 -0
- package/dist/solid/dialog-parts.d.ts +78 -15
- package/dist/solid/dialog.d.ts +9 -15
- package/dist/solid/docked-panel.d.ts +1 -5
- package/dist/solid/icon-nodes.d.ts +13 -0
- package/dist/solid/index.d.ts +9 -5
- package/dist/solid/index.js +8211 -7974
- package/dist/solid/responsive-dialog.d.ts +5 -6
- package/dist/solid/sheet.d.ts +6 -13
- package/dist/solid/stale-veil.d.ts +7 -0
- package/dist/solid/tabs.d.ts +29 -8
- package/dist/solid/toggle-group.d.ts +30 -5
- package/dist/solid/tooltip.d.ts +71 -9
- package/dist/{utils-DXEj_oXa.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 +9 -4
- package/src/lib/page-cover.ts +47 -0
- package/src/lib/shadow-layer.ts +48 -66
- package/src/solid/alert-dialog.tsx +45 -81
- package/src/solid/alert.tsx +1 -1
- 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/confirm-dialog.tsx +62 -0
- package/src/solid/context-menu.tsx +12 -2
- package/src/solid/dialog-parts.tsx +181 -42
- package/src/solid/dialog.tsx +46 -74
- 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-nodes.ts +71 -0
- package/src/solid/icon-picker.tsx +2 -1
- package/src/solid/icon.tsx +42 -39
- package/src/solid/image-picker.tsx +14 -13
- package/src/solid/index.ts +9 -2
- 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 +17 -10
- 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 +373 -53
- package/src/solid/toggle-group.tsx +305 -93
- package/src/solid/tooltip.tsx +285 -26
- package/src/styles/globals.css +6 -2
- package/src/styles/theme.css +10 -5
- 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
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { watchMotion } from "./behavior/presence.js";
|
|
2
|
+
import { MOTION_EXIT_MS } from "./motion-classes.js";
|
|
3
|
+
|
|
4
|
+
/** On a modal's panel from the end of its open animation; the widget realm carries it out of a sealed widget. */
|
|
5
|
+
export const COVERING_ATTR = "data-covering";
|
|
6
|
+
|
|
7
|
+
let covers = 0;
|
|
8
|
+
const pageRoot = () => document.querySelector("[data-page]");
|
|
9
|
+
|
|
10
|
+
/** Pauses the page's ambient loops while a modal covers it: one attribute on the app's [data-page] root, never on html. Returns the release. */
|
|
11
|
+
export function coverPage(): () => void {
|
|
12
|
+
covers++;
|
|
13
|
+
if (covers === 1) pageRoot()?.setAttribute("data-covered", "");
|
|
14
|
+
let released = false;
|
|
15
|
+
return () => {
|
|
16
|
+
if (released) return;
|
|
17
|
+
released = true;
|
|
18
|
+
covers--;
|
|
19
|
+
if (covers === 0) pageRoot()?.removeAttribute("data-covered");
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** A modal panel covers the page from now until the returned release runs. */
|
|
24
|
+
export function coverNow(panel: Element): () => void {
|
|
25
|
+
panel.setAttribute(COVERING_ATTR, "");
|
|
26
|
+
const release = coverPage();
|
|
27
|
+
return () => {
|
|
28
|
+
panel.removeAttribute(COVERING_ATTR);
|
|
29
|
+
release();
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** A modal panel covers the page once its open animation ends, if it is still open then, until the returned release runs. */
|
|
34
|
+
export function coverOnceOpen(panel: Element, open: () => boolean): () => void {
|
|
35
|
+
let release: (() => void) | undefined;
|
|
36
|
+
let done = false;
|
|
37
|
+
const stop = watchMotion(panel, MOTION_EXIT_MS.sheet, () => {
|
|
38
|
+
if (done || !open()) return;
|
|
39
|
+
release = coverNow(panel);
|
|
40
|
+
});
|
|
41
|
+
return () => {
|
|
42
|
+
if (done) return;
|
|
43
|
+
done = true;
|
|
44
|
+
stop();
|
|
45
|
+
release?.();
|
|
46
|
+
};
|
|
47
|
+
}
|
package/src/lib/shadow-layer.ts
CHANGED
|
@@ -1,12 +1,29 @@
|
|
|
1
|
-
import { type Accessor,
|
|
2
|
-
import {
|
|
1
|
+
import { type Accessor, createContext, createSignal, onCleanup, useContext } from "solid-js";
|
|
2
|
+
import { createDismiss } from "./behavior/dismiss.js";
|
|
3
|
+
import { effect } from "./behavior/solid.js";
|
|
4
|
+
import { focusWithoutTracking } from "./behavior/focus-scope.js";
|
|
5
|
+
import { registerLayer } from "./behavior/layer-stack.js";
|
|
3
6
|
|
|
4
7
|
/** True for a node inside a shadow root, where page-level layer logic sees only the root's host. */
|
|
5
8
|
export const inShadowRoot = (node: Node | undefined): boolean =>
|
|
6
9
|
typeof ShadowRoot !== "undefined" && node?.getRootNode() instanceof ShadowRoot;
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
export const ReportCovered = createContext<(covered: Accessor<boolean>) => void>();
|
|
12
|
+
|
|
13
|
+
/** True while a layer of this Kobalte root sits under an owned modal; the root drops `modal` then. */
|
|
14
|
+
export function createCoveredRoot(): {
|
|
15
|
+
covered: Accessor<boolean>;
|
|
16
|
+
report: (covered: Accessor<boolean>) => void;
|
|
17
|
+
} {
|
|
18
|
+
const [reporters, setReporters] = createSignal<readonly Accessor<boolean>[]>([]);
|
|
19
|
+
return {
|
|
20
|
+
covered: () => reporters().some((covered) => covered()),
|
|
21
|
+
report: (covered) => {
|
|
22
|
+
setReporters((list) => [...list, covered]);
|
|
23
|
+
onCleanup(() => setReporters((list) => list.filter((other) => other !== covered)));
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
10
27
|
|
|
11
28
|
type OutsideEvent = { target: EventTarget | null; preventDefault(): void };
|
|
12
29
|
type AutoFocusEvent = { preventDefault(): void };
|
|
@@ -14,9 +31,10 @@ type AutoFocusEvent = { preventDefault(): void };
|
|
|
14
31
|
export interface LayerHandlers {
|
|
15
32
|
onInteractOutside: (e: OutsideEvent) => void;
|
|
16
33
|
onCloseAutoFocus: (e: AutoFocusEvent) => void;
|
|
17
|
-
onOpenAutoFocus: (e: AutoFocusEvent) => void;
|
|
18
34
|
/** The shadow root's host while the layer is in one: what the page sees as the target of anything inside. */
|
|
19
35
|
host: () => Element | undefined;
|
|
36
|
+
/** An owned modal sits above the layer: the modal owns every press and focus until it closes. */
|
|
37
|
+
covered: Accessor<boolean>;
|
|
20
38
|
}
|
|
21
39
|
|
|
22
40
|
interface ShadowLayerOptions {
|
|
@@ -28,13 +46,9 @@ interface ShadowLayerOptions {
|
|
|
28
46
|
trigger?: Accessor<Element | undefined>;
|
|
29
47
|
/** Menus: any press outside the layer and the layers above it dismisses it, newest or not, as Kobalte's menus do. */
|
|
30
48
|
tree?: boolean;
|
|
31
|
-
/** The layer keeps Tab inside itself (dialogs); its initial focus is then ui's, not Kobalte's. */
|
|
32
|
-
trapsFocus?: boolean;
|
|
33
|
-
initialFocus?: InitialFocus;
|
|
34
49
|
consumer: {
|
|
35
50
|
onInteractOutside?: (e: never) => void;
|
|
36
51
|
onCloseAutoFocus?: (e: never) => void;
|
|
37
|
-
onOpenAutoFocus?: (e: never) => void;
|
|
38
52
|
};
|
|
39
53
|
}
|
|
40
54
|
|
|
@@ -47,59 +61,30 @@ interface ShadowLayerOptions {
|
|
|
47
61
|
*/
|
|
48
62
|
export function shadowLayer(options: ShadowLayerOptions): LayerHandlers {
|
|
49
63
|
let dismissedIn: ShadowRoot | undefined;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
const handle = registerLayer({
|
|
65
|
+
element: options.content,
|
|
66
|
+
open: options.open,
|
|
67
|
+
kind: !options.dismiss ? "tooltip" : options.tree ? "menu" : "popover",
|
|
68
|
+
escape: () => false,
|
|
69
|
+
readsOwnEscape: true,
|
|
70
|
+
dismiss: options.dismiss,
|
|
71
|
+
trigger: options.trigger,
|
|
72
|
+
});
|
|
73
|
+
effect(options.open, (open) => {
|
|
74
|
+
if (open) dismissedIn = undefined;
|
|
75
|
+
});
|
|
76
|
+
const covered = () => options.open() && handle.above().some((layer) => layer.kind === "modal");
|
|
77
|
+
useContext(ReportCovered)?.(covered);
|
|
78
|
+
createDismiss({
|
|
79
|
+
layer: handle,
|
|
80
|
+
outsidePress: () => !!options.dismiss && inShadowRoot(options.content()),
|
|
81
|
+
onDismiss: () => {
|
|
82
|
+
const root = options.content()?.getRootNode();
|
|
83
|
+
dismissedIn = root instanceof ShadowRoot ? root : undefined;
|
|
84
|
+
options.dismiss?.();
|
|
69
85
|
// The caller refused the close (a controlled `open`): the next close is not this one.
|
|
70
86
|
if (options.open()) dismissedIn = undefined;
|
|
71
|
-
}
|
|
72
|
-
let pendingClick: ((e: Event) => void) | undefined;
|
|
73
|
-
const dropPendingClick = () => {
|
|
74
|
-
if (pendingClick) root.removeEventListener("click", pendingClick);
|
|
75
|
-
pendingClick = undefined;
|
|
76
|
-
};
|
|
77
|
-
const onDown = (e: Event) => {
|
|
78
|
-
dropPendingClick();
|
|
79
|
-
if (!dismisses(e)) return;
|
|
80
|
-
// A touch dismisses on its own click, judged again then: a scroll never clicks.
|
|
81
|
-
if ((e as PointerEvent).pointerType === "touch") {
|
|
82
|
-
pendingClick = (click) => {
|
|
83
|
-
pendingClick = undefined;
|
|
84
|
-
if (dismisses(click)) close();
|
|
85
|
-
};
|
|
86
|
-
root.addEventListener("click", pendingClick, { once: true });
|
|
87
|
-
} else {
|
|
88
|
-
close();
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
// Listening only after the opening press has finished, as Kobalte's own layers do.
|
|
92
|
-
const timer = setTimeout(() => root.addEventListener("pointerdown", onDown, true), 0);
|
|
93
|
-
if (options.trapsFocus) {
|
|
94
|
-
const trap = trapFocus(el, options.initialFocus ?? "first");
|
|
95
|
-
onCleanup(() => trap.release());
|
|
96
|
-
}
|
|
97
|
-
onCleanup(() => {
|
|
98
|
-
clearTimeout(timer);
|
|
99
|
-
root.removeEventListener("pointerdown", onDown, true);
|
|
100
|
-
dropPendingClick();
|
|
101
|
-
stack.splice(stack.indexOf(el), 1);
|
|
102
|
-
});
|
|
87
|
+
},
|
|
103
88
|
});
|
|
104
89
|
const shadowHost = () => {
|
|
105
90
|
const root = options.content()?.getRootNode();
|
|
@@ -107,9 +92,10 @@ export function shadowLayer(options: ShadowLayerOptions): LayerHandlers {
|
|
|
107
92
|
};
|
|
108
93
|
return {
|
|
109
94
|
host: shadowHost,
|
|
95
|
+
covered,
|
|
110
96
|
onInteractOutside: (e) => {
|
|
111
97
|
const host = shadowHost();
|
|
112
|
-
if (host && e.target === host) {
|
|
98
|
+
if (covered() || (host && e.target === host)) {
|
|
113
99
|
e.preventDefault();
|
|
114
100
|
return;
|
|
115
101
|
}
|
|
@@ -125,15 +111,11 @@ export function shadowLayer(options: ShadowLayerOptions): LayerHandlers {
|
|
|
125
111
|
const kept = root.activeElement;
|
|
126
112
|
queueMicrotask(() => {
|
|
127
113
|
if (kept instanceof HTMLElement && kept.isConnected && root.activeElement !== kept) {
|
|
128
|
-
kept
|
|
114
|
+
focusWithoutTracking(kept);
|
|
129
115
|
}
|
|
130
116
|
});
|
|
131
117
|
}
|
|
132
118
|
options.consumer.onCloseAutoFocus?.(e as never);
|
|
133
119
|
},
|
|
134
|
-
onOpenAutoFocus: (e) => {
|
|
135
|
-
if (options.trapsFocus && shadowHost()) e.preventDefault();
|
|
136
|
-
options.consumer.onOpenAutoFocus?.(e as never);
|
|
137
|
-
},
|
|
138
120
|
};
|
|
139
121
|
}
|
|
@@ -1,54 +1,42 @@
|
|
|
1
|
-
import { AlertDialog as AlertDialogPrimitive } from "@kobalte/core/alert-dialog";
|
|
2
1
|
import { usePortalMount } from "./portal-mount.js";
|
|
3
|
-
import { useDialogContext } from "@kobalte/core/dialog";
|
|
4
2
|
import type { VariantProps } from "cva";
|
|
5
3
|
import {
|
|
6
4
|
type Component,
|
|
7
5
|
type ComponentProps,
|
|
8
|
-
|
|
6
|
+
type JSX,
|
|
9
7
|
type ParentComponent,
|
|
10
8
|
splitProps,
|
|
11
9
|
} from "solid-js";
|
|
12
|
-
import {
|
|
10
|
+
import { ModalFrame, useDialogContext } from "../lib/behavior/modal-root.js";
|
|
11
|
+
import { MOTION_EXIT_MS } from "../lib/motion-classes.js";
|
|
13
12
|
import { buttonVariants } from "../lib/button-variants.js";
|
|
14
13
|
import { cn } from "../lib/utils.js";
|
|
15
14
|
import {
|
|
16
15
|
createModalDismiss,
|
|
16
|
+
createModalHead,
|
|
17
17
|
createModalParts,
|
|
18
|
+
createModalRootSkin,
|
|
19
|
+
createModalTextParts,
|
|
20
|
+
type ModalHeadProps,
|
|
18
21
|
MODAL_ANCHOR,
|
|
19
|
-
MODAL_DESCRIPTION,
|
|
20
22
|
MODAL_PANEL,
|
|
21
23
|
MODAL_SCRIM,
|
|
22
|
-
MODAL_TITLE,
|
|
23
24
|
MODAL_WIDTH,
|
|
25
|
+
type ModalContentProps,
|
|
24
26
|
type ModalDismissProps,
|
|
25
|
-
|
|
27
|
+
ModalCover,
|
|
26
28
|
type ModalSize,
|
|
27
29
|
} from "./dialog-parts.js";
|
|
28
30
|
|
|
29
|
-
const AlertDialog
|
|
30
|
-
const mount = usePortalMount();
|
|
31
|
-
return <AlertDialogPrimitive modal={!inShadowRoot(mount)} {...props} preventScroll={false} />;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const AlertDialogTrigger: Component<ComponentProps<typeof AlertDialogPrimitive.Trigger>> = (
|
|
35
|
-
props,
|
|
36
|
-
) => <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
|
|
31
|
+
const AlertDialog = createModalRootSkin("alertdialog");
|
|
37
32
|
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
<AlertDialogPrimitive.Overlay
|
|
44
|
-
data-slot="alert-dialog-overlay"
|
|
45
|
-
class={cn(MODAL_SCRIM, local.class)}
|
|
46
|
-
{...rest}
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
33
|
+
const {
|
|
34
|
+
Trigger: AlertDialogTrigger,
|
|
35
|
+
Title: AlertDialogTitle,
|
|
36
|
+
Description: AlertDialogDescription,
|
|
37
|
+
} = createModalTextParts("alert-dialog");
|
|
50
38
|
|
|
51
|
-
type AlertDialogContentProps =
|
|
39
|
+
type AlertDialogContentProps = ModalContentProps & {
|
|
52
40
|
size?: ModalSize;
|
|
53
41
|
/** Names a panel that has no `AlertDialogTitle`. A registered Title wins. */
|
|
54
42
|
ariaLabel?: string;
|
|
@@ -60,46 +48,36 @@ const AlertDialogContent: ParentComponent<AlertDialogContentProps> = (props) =>
|
|
|
60
48
|
"children",
|
|
61
49
|
"size",
|
|
62
50
|
"ariaLabel",
|
|
51
|
+
"style",
|
|
63
52
|
"ref",
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"onOpenAutoFocus",
|
|
53
|
+
"onFocusOutside",
|
|
54
|
+
"forceMount",
|
|
67
55
|
]);
|
|
68
|
-
const
|
|
69
|
-
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
70
|
-
const layer = shadowLayer({
|
|
71
|
-
content: panel,
|
|
72
|
-
open: () => context.isOpen(),
|
|
73
|
-
dismiss: () => context.close(),
|
|
74
|
-
trapsFocus: true,
|
|
75
|
-
consumer: local,
|
|
76
|
-
});
|
|
56
|
+
const ctx = useDialogContext();
|
|
77
57
|
return (
|
|
78
|
-
|
|
79
|
-
<
|
|
80
|
-
<
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
onInteractOutside={layer.onInteractOutside}
|
|
87
|
-
onCloseAutoFocus={layer.onCloseAutoFocus}
|
|
88
|
-
onOpenAutoFocus={layer.onOpenAutoFocus}
|
|
89
|
-
data-slot="alert-dialog-content"
|
|
90
|
-
role="alertdialog"
|
|
91
|
-
aria-label={context.titleId() ? undefined : local.ariaLabel}
|
|
92
|
-
class={cn(
|
|
58
|
+
<>
|
|
59
|
+
<ModalCover panel={ctx.panel} open={ctx.isOpen} dormant={ctx.dormant} />
|
|
60
|
+
<ModalFrame
|
|
61
|
+
slot="alert-dialog"
|
|
62
|
+
mount={usePortalMount()}
|
|
63
|
+
exitMs={MOTION_EXIT_MS.modal}
|
|
64
|
+
scrimClass={MODAL_SCRIM}
|
|
65
|
+
panelClass={cn(
|
|
93
66
|
MODAL_PANEL,
|
|
94
67
|
MODAL_WIDTH[local.size ?? "md"],
|
|
95
68
|
MODAL_ANCHOR[local.size ?? "md"],
|
|
96
69
|
local.class,
|
|
97
70
|
)}
|
|
71
|
+
panelStyle={typeof local.style === "object" ? local.style : undefined}
|
|
72
|
+
ariaLabel={local.ariaLabel}
|
|
73
|
+
ref={(el: HTMLElement) => {
|
|
74
|
+
if (typeof local.ref === "function") local.ref(el as HTMLDivElement);
|
|
75
|
+
}}
|
|
98
76
|
{...rest}
|
|
99
77
|
>
|
|
100
78
|
{local.children}
|
|
101
|
-
</
|
|
102
|
-
|
|
79
|
+
</ModalFrame>
|
|
80
|
+
</>
|
|
103
81
|
);
|
|
104
82
|
};
|
|
105
83
|
|
|
@@ -109,35 +87,20 @@ const {
|
|
|
109
87
|
Footer: AlertDialogFooter,
|
|
110
88
|
} = createModalParts("alert-dialog");
|
|
111
89
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<AlertDialogPrimitive.Title
|
|
116
|
-
data-slot="alert-dialog-title"
|
|
117
|
-
class={cn(MODAL_TITLE, local.class)}
|
|
118
|
-
{...rest}
|
|
119
|
-
/>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
90
|
+
/** An alert dialog is read aloud as a description, and the line carries the consequence. */
|
|
91
|
+
type AlertDialogHeadProps = ModalHeadProps & { line: JSX.Element };
|
|
122
92
|
|
|
123
|
-
const
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
<AlertDialogPrimitive.Description
|
|
129
|
-
data-slot="alert-dialog-description"
|
|
130
|
-
class={cn(MODAL_DESCRIPTION, local.class)}
|
|
131
|
-
{...rest}
|
|
132
|
-
/>
|
|
133
|
-
);
|
|
134
|
-
};
|
|
93
|
+
const AlertDialogHead = createModalHead<AlertDialogHeadProps>(
|
|
94
|
+
AlertDialogHeader,
|
|
95
|
+
AlertDialogTitle as Component<ComponentProps<"h2">>,
|
|
96
|
+
AlertDialogDescription as Component<ComponentProps<"p">>,
|
|
97
|
+
);
|
|
135
98
|
|
|
136
99
|
type AlertDialogButtonProps = ModalDismissProps &
|
|
137
100
|
Partial<Pick<VariantProps<typeof buttonVariants>, "variant" | "size">>;
|
|
138
101
|
|
|
139
|
-
const ActionDismiss = createModalDismiss("alert-dialog-action");
|
|
140
|
-
const CancelDismiss = createModalDismiss("alert-dialog-cancel");
|
|
102
|
+
const ActionDismiss = createModalDismiss("alert-dialog-action", useDialogContext);
|
|
103
|
+
const CancelDismiss = createModalDismiss("alert-dialog-cancel", useDialogContext);
|
|
141
104
|
|
|
142
105
|
/** Confirming action. Pass `variant` (e.g. "destructive"); layering a second
|
|
143
106
|
* buttonVariants() call through `class` cannot work, because the variants
|
|
@@ -175,6 +138,7 @@ export {
|
|
|
175
138
|
AlertDialogContent,
|
|
176
139
|
AlertDialogDescription,
|
|
177
140
|
AlertDialogFooter,
|
|
141
|
+
AlertDialogHead,
|
|
178
142
|
AlertDialogHeader,
|
|
179
143
|
AlertDialogTitle,
|
|
180
144
|
AlertDialogTrigger,
|
package/src/solid/alert.tsx
CHANGED
|
@@ -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 { MENU_ITEM } from "../lib/menu-classes.js";
|
|
3
4
|
import { STAGGER } from "../lib/motion-classes.js";
|
|
4
5
|
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
@@ -175,7 +176,7 @@ export function AreaPicker(props: AreaPickerProps) {
|
|
|
175
176
|
onOpenAutoFocus={(e) => {
|
|
176
177
|
e.preventDefault();
|
|
177
178
|
// preventScroll: the panel is portalled at (0,0) until the popper places it.
|
|
178
|
-
searchRef
|
|
179
|
+
focusWithoutTracking(searchRef);
|
|
179
180
|
}}
|
|
180
181
|
onInteractOutside={() => setOpen(false)}
|
|
181
182
|
>
|
package/src/solid/badge.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Component, type ComponentProps, splitProps, type ValidComponent } from "solid-js";
|
|
2
|
-
import {
|
|
2
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
3
3
|
import { BADGE_DEFAULT_TONE, BADGE_NEUTRAL_KNOBS } from "../lib/badge-tone.js";
|
|
4
4
|
import { isNeutralTone } from "../lib/glass-tone.js";
|
|
5
5
|
import { CHIP } from "../lib/pill-classes.js";
|
|
@@ -15,18 +15,18 @@ type BadgeProps = ComponentProps<"span"> &
|
|
|
15
15
|
|
|
16
16
|
const Badge: Component<BadgeProps> = (props) => {
|
|
17
17
|
const [local, others] = splitProps(props, ["class", "as", "tone", "children", "style"]);
|
|
18
|
-
const Comp = () => local.as || "span";
|
|
19
18
|
const c = () => local.tone ?? BADGE_DEFAULT_TONE;
|
|
20
19
|
return (
|
|
21
|
-
<
|
|
22
|
-
|
|
20
|
+
<Polymorphic
|
|
21
|
+
defaultAs="span"
|
|
22
|
+
as={local.as}
|
|
23
23
|
data-slot="badge"
|
|
24
24
|
class={cn(CHIP, isNeutralTone(c()) && BADGE_NEUTRAL_KNOBS, local.class)}
|
|
25
25
|
style={{ "--glass-tone": c(), ...(local.style as Record<string, string>) }}
|
|
26
26
|
{...others}
|
|
27
27
|
>
|
|
28
28
|
{local.children}
|
|
29
|
-
</
|
|
29
|
+
</Polymorphic>
|
|
30
30
|
);
|
|
31
31
|
};
|
|
32
32
|
|