@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
|
@@ -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,57 +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
|
-
createSignal,
|
|
9
6
|
type JSX,
|
|
10
7
|
type ParentComponent,
|
|
11
8
|
splitProps,
|
|
12
9
|
} from "solid-js";
|
|
13
|
-
import {
|
|
10
|
+
import { ModalFrame, useDialogContext } from "../lib/behavior/modal-root.js";
|
|
11
|
+
import { MOTION_EXIT_MS } from "../lib/motion-classes.js";
|
|
14
12
|
import { buttonVariants } from "../lib/button-variants.js";
|
|
15
13
|
import { cn } from "../lib/utils.js";
|
|
16
14
|
import {
|
|
17
15
|
createModalDismiss,
|
|
18
16
|
createModalHead,
|
|
19
17
|
createModalParts,
|
|
18
|
+
createModalRootSkin,
|
|
19
|
+
createModalTextParts,
|
|
20
20
|
type ModalHeadProps,
|
|
21
21
|
MODAL_ANCHOR,
|
|
22
|
-
MODAL_DESCRIPTION,
|
|
23
22
|
MODAL_PANEL,
|
|
24
23
|
MODAL_SCRIM,
|
|
25
|
-
MODAL_TITLE,
|
|
26
24
|
MODAL_WIDTH,
|
|
25
|
+
type ModalContentProps,
|
|
27
26
|
type ModalDismissProps,
|
|
28
|
-
|
|
27
|
+
ModalCover,
|
|
29
28
|
type ModalSize,
|
|
30
29
|
} from "./dialog-parts.js";
|
|
31
30
|
|
|
32
|
-
const AlertDialog
|
|
33
|
-
const mount = usePortalMount();
|
|
34
|
-
return <AlertDialogPrimitive modal={!inShadowRoot(mount)} {...props} preventScroll={false} />;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
const AlertDialogTrigger: Component<ComponentProps<typeof AlertDialogPrimitive.Trigger>> = (
|
|
38
|
-
props,
|
|
39
|
-
) => <AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />;
|
|
31
|
+
const AlertDialog = createModalRootSkin("alertdialog");
|
|
40
32
|
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
<AlertDialogPrimitive.Overlay
|
|
47
|
-
data-slot="alert-dialog-overlay"
|
|
48
|
-
class={cn(MODAL_SCRIM, local.class)}
|
|
49
|
-
{...rest}
|
|
50
|
-
/>
|
|
51
|
-
);
|
|
52
|
-
};
|
|
33
|
+
const {
|
|
34
|
+
Trigger: AlertDialogTrigger,
|
|
35
|
+
Title: AlertDialogTitle,
|
|
36
|
+
Description: AlertDialogDescription,
|
|
37
|
+
} = createModalTextParts("alert-dialog");
|
|
53
38
|
|
|
54
|
-
type AlertDialogContentProps =
|
|
39
|
+
type AlertDialogContentProps = ModalContentProps & {
|
|
55
40
|
size?: ModalSize;
|
|
56
41
|
/** Names a panel that has no `AlertDialogTitle`. A registered Title wins. */
|
|
57
42
|
ariaLabel?: string;
|
|
@@ -63,46 +48,36 @@ const AlertDialogContent: ParentComponent<AlertDialogContentProps> = (props) =>
|
|
|
63
48
|
"children",
|
|
64
49
|
"size",
|
|
65
50
|
"ariaLabel",
|
|
51
|
+
"style",
|
|
66
52
|
"ref",
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"onOpenAutoFocus",
|
|
53
|
+
"onFocusOutside",
|
|
54
|
+
"forceMount",
|
|
70
55
|
]);
|
|
71
|
-
const
|
|
72
|
-
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
73
|
-
const layer = shadowLayer({
|
|
74
|
-
content: panel,
|
|
75
|
-
open: () => context.isOpen(),
|
|
76
|
-
dismiss: () => context.close(),
|
|
77
|
-
trapsFocus: true,
|
|
78
|
-
consumer: local,
|
|
79
|
-
});
|
|
56
|
+
const ctx = useDialogContext();
|
|
80
57
|
return (
|
|
81
|
-
|
|
82
|
-
<
|
|
83
|
-
<
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
onInteractOutside={layer.onInteractOutside}
|
|
90
|
-
onCloseAutoFocus={layer.onCloseAutoFocus}
|
|
91
|
-
onOpenAutoFocus={layer.onOpenAutoFocus}
|
|
92
|
-
data-slot="alert-dialog-content"
|
|
93
|
-
role="alertdialog"
|
|
94
|
-
aria-label={context.titleId() ? undefined : local.ariaLabel}
|
|
95
|
-
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(
|
|
96
66
|
MODAL_PANEL,
|
|
97
67
|
MODAL_WIDTH[local.size ?? "md"],
|
|
98
68
|
MODAL_ANCHOR[local.size ?? "md"],
|
|
99
69
|
local.class,
|
|
100
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
|
+
}}
|
|
101
76
|
{...rest}
|
|
102
77
|
>
|
|
103
78
|
{local.children}
|
|
104
|
-
</
|
|
105
|
-
|
|
79
|
+
</ModalFrame>
|
|
80
|
+
</>
|
|
106
81
|
);
|
|
107
82
|
};
|
|
108
83
|
|
|
@@ -112,44 +87,20 @@ const {
|
|
|
112
87
|
Footer: AlertDialogFooter,
|
|
113
88
|
} = createModalParts("alert-dialog");
|
|
114
89
|
|
|
115
|
-
const AlertDialogTitle: Component<ComponentProps<typeof AlertDialogPrimitive.Title>> = (props) => {
|
|
116
|
-
const [local, rest] = splitProps(props, ["class"]);
|
|
117
|
-
return (
|
|
118
|
-
<AlertDialogPrimitive.Title
|
|
119
|
-
data-slot="alert-dialog-title"
|
|
120
|
-
class={cn(MODAL_TITLE, local.class)}
|
|
121
|
-
{...rest}
|
|
122
|
-
/>
|
|
123
|
-
);
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
const AlertDialogDescription: Component<ComponentProps<typeof AlertDialogPrimitive.Description>> = (
|
|
127
|
-
props,
|
|
128
|
-
) => {
|
|
129
|
-
const [local, rest] = splitProps(props, ["class"]);
|
|
130
|
-
return (
|
|
131
|
-
<AlertDialogPrimitive.Description
|
|
132
|
-
data-slot="alert-dialog-description"
|
|
133
|
-
class={cn(MODAL_DESCRIPTION, local.class)}
|
|
134
|
-
{...rest}
|
|
135
|
-
/>
|
|
136
|
-
);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
90
|
/** An alert dialog is read aloud as a description, and the line carries the consequence. */
|
|
140
91
|
type AlertDialogHeadProps = ModalHeadProps & { line: JSX.Element };
|
|
141
92
|
|
|
142
93
|
const AlertDialogHead = createModalHead<AlertDialogHeadProps>(
|
|
143
94
|
AlertDialogHeader,
|
|
144
|
-
AlertDialogTitle
|
|
145
|
-
AlertDialogDescription
|
|
95
|
+
AlertDialogTitle as Component<ComponentProps<"h2">>,
|
|
96
|
+
AlertDialogDescription as Component<ComponentProps<"p">>,
|
|
146
97
|
);
|
|
147
98
|
|
|
148
99
|
type AlertDialogButtonProps = ModalDismissProps &
|
|
149
100
|
Partial<Pick<VariantProps<typeof buttonVariants>, "variant" | "size">>;
|
|
150
101
|
|
|
151
|
-
const ActionDismiss = createModalDismiss("alert-dialog-action");
|
|
152
|
-
const CancelDismiss = createModalDismiss("alert-dialog-cancel");
|
|
102
|
+
const ActionDismiss = createModalDismiss("alert-dialog-action", useDialogContext);
|
|
103
|
+
const CancelDismiss = createModalDismiss("alert-dialog-cancel", useDialogContext);
|
|
153
104
|
|
|
154
105
|
/** Confirming action. Pass `variant` (e.g. "destructive"); layering a second
|
|
155
106
|
* buttonVariants() call through `class` cannot work, because the variants
|
|
@@ -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
|
|