@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
package/src/solid/index.ts
CHANGED
|
@@ -8,7 +8,8 @@ export { SECTION_ROW_SURFACE } from "../lib/card-classes.js";
|
|
|
8
8
|
export { copyImage, copyText } from "../lib/clipboard.js";
|
|
9
9
|
export { createHold, HOLD_GRACE_MS, HOLD_MS, spendLongPress } from "../lib/hold.js";
|
|
10
10
|
export type { Hold, HoldOptions, HoldPress } from "../lib/hold.js";
|
|
11
|
-
export { RISE_MOTION, SETTLE_MOTION, TRAVEL_MOTION } from "../lib/motion-classes.js";
|
|
11
|
+
export { RISE_MOTION, SETTLE_MOTION, STALE_CONTENT, TRAVEL_MOTION } from "../lib/motion-classes.js";
|
|
12
|
+
export { COVERING_ATTR, coverPage } from "../lib/page-cover.js";
|
|
12
13
|
export { OVERLAY_SURFACE } from "../lib/overlay-classes.js";
|
|
13
14
|
// Section tokens re-exported from the Solid entry for convenience.
|
|
14
15
|
export {
|
|
@@ -154,6 +155,7 @@ export {
|
|
|
154
155
|
DialogTitle,
|
|
155
156
|
DialogTrigger,
|
|
156
157
|
} from "./dialog.js";
|
|
158
|
+
export { useDialogDormant } from "../lib/behavior/modal-root.js";
|
|
157
159
|
export { ConfirmDialog, type ConfirmDialogProps } from "./confirm-dialog.js";
|
|
158
160
|
export type { ModalHeadProps, ModalMedia, ModalSize } from "./dialog-parts.js";
|
|
159
161
|
export type { DockIconButtonProps, DockItem, DockPlacement, DockProps } from "./dock.js";
|
|
@@ -385,6 +387,7 @@ export { FaceToggle, FaceToggleGroup } from "./face-toggle.js";
|
|
|
385
387
|
export { GlyphTile, GlyphTileGroup } from "./glyph-tile.js";
|
|
386
388
|
export { Spinner } from "./spinner.js";
|
|
387
389
|
export { Spotlight } from "./spotlight.js";
|
|
390
|
+
export { StaleVeil } from "./stale-veil.js";
|
|
388
391
|
export { StepIndicator } from "./step-indicator.js";
|
|
389
392
|
export { SwatchPicker } from "./swatch-picker.js";
|
|
390
393
|
export { Switch } from "./switch.js";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { cva, type VariantProps } from "cva";
|
|
2
2
|
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
3
|
+
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
3
4
|
import { CONTROL_H, FIELD_TEXT, INPUT_SURFACE } from "../lib/input-classes.js";
|
|
4
5
|
import { cn } from "../lib/utils.js";
|
|
5
6
|
import { Button } from "./button.js";
|
|
@@ -63,9 +64,10 @@ const InputGroupAddon: Component<
|
|
|
63
64
|
if ((e.target as HTMLElement).closest("button")) {
|
|
64
65
|
return;
|
|
65
66
|
}
|
|
66
|
-
(
|
|
67
|
-
?.querySelector<HTMLInputElement>("input")
|
|
68
|
-
|
|
67
|
+
focusWithoutTracking(
|
|
68
|
+
(e.currentTarget as HTMLElement).parentElement?.querySelector<HTMLInputElement>("input"),
|
|
69
|
+
{ preventScroll: false },
|
|
70
|
+
);
|
|
69
71
|
}}
|
|
70
72
|
{...rest}
|
|
71
73
|
/>
|
package/src/solid/input-otp.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
splitProps,
|
|
9
9
|
useContext,
|
|
10
10
|
} from "solid-js";
|
|
11
|
+
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
11
12
|
import { CONTROL_H, FOCUS_RING, INPUT_SURFACE } from "../lib/input-classes.js";
|
|
12
13
|
import { cn } from "../lib/utils.js";
|
|
13
14
|
import { Icon } from "./icon.js";
|
|
@@ -96,7 +97,7 @@ const InputOTP: ParentComponent<
|
|
|
96
97
|
<div
|
|
97
98
|
data-slot="input-otp"
|
|
98
99
|
class={cn("flex items-center gap-2 has-[:disabled]:opacity-50", local.containerClass)}
|
|
99
|
-
onClick={() => inputRef
|
|
100
|
+
onClick={() => focusWithoutTracking(inputRef, { preventScroll: false })}
|
|
100
101
|
{...rest}
|
|
101
102
|
>
|
|
102
103
|
<input
|
package/src/solid/item.tsx
CHANGED
|
@@ -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 { ICON_PILL } from "../lib/pill-classes.js";
|
|
5
5
|
import { cn } from "../lib/utils.js";
|
|
6
6
|
import { Separator } from "./separator.js";
|
|
@@ -54,10 +54,10 @@ const Item: Component<
|
|
|
54
54
|
const [local, rest] = splitProps(props, ["class", "variant", "size", "as"] as const);
|
|
55
55
|
const variant = () => local.variant ?? "default";
|
|
56
56
|
const size = () => local.size ?? "default";
|
|
57
|
-
const Comp = () => local.as || "div";
|
|
58
57
|
return (
|
|
59
|
-
<
|
|
60
|
-
|
|
58
|
+
<Polymorphic
|
|
59
|
+
defaultAs="div"
|
|
60
|
+
as={local.as}
|
|
61
61
|
data-slot="item"
|
|
62
62
|
data-variant={variant()}
|
|
63
63
|
data-size={size()}
|
package/src/solid/logo.tsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Component, type ComponentProps, type JSX, splitProps } from "solid-js";
|
|
2
|
-
import {
|
|
2
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
3
3
|
import {
|
|
4
4
|
LOGO_DEFAULT_SIZE,
|
|
5
5
|
LOGO_DEFAULT_SRC,
|
|
@@ -48,8 +48,9 @@ const Logo: Component<LogoProps> = (props) => {
|
|
|
48
48
|
const size = () => local.size ?? LOGO_DEFAULT_SIZE;
|
|
49
49
|
const s = () => LOGO_SIZES[size()];
|
|
50
50
|
return (
|
|
51
|
-
<
|
|
52
|
-
|
|
51
|
+
<Polymorphic
|
|
52
|
+
defaultAs="div"
|
|
53
|
+
as={local.href ? "a" : undefined}
|
|
53
54
|
data-slot="logo"
|
|
54
55
|
class={cn(LOGO_ROOT_CLASS, s().gap, local.class)}
|
|
55
56
|
href={local.href}
|
|
@@ -72,7 +73,7 @@ const Logo: Component<LogoProps> = (props) => {
|
|
|
72
73
|
</span>
|
|
73
74
|
)}
|
|
74
75
|
</span>
|
|
75
|
-
</
|
|
76
|
+
</Polymorphic>
|
|
76
77
|
);
|
|
77
78
|
};
|
|
78
79
|
|
package/src/solid/picker-row.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
splitProps,
|
|
7
7
|
type ValidComponent,
|
|
8
8
|
} from "solid-js";
|
|
9
|
-
import {
|
|
9
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
10
10
|
import { MENU_ITEM } from "../lib/menu-classes.js";
|
|
11
11
|
import { ICON_PILL, ICON_PILL_TINT } from "../lib/pill-classes.js";
|
|
12
12
|
import { cn } from "../lib/utils.js";
|
|
@@ -46,8 +46,9 @@ export function PickerRow(props: PickerRowProps) {
|
|
|
46
46
|
const subtitle = children(() => local.subtitle);
|
|
47
47
|
const meta = children(() => local.meta);
|
|
48
48
|
return (
|
|
49
|
-
<
|
|
50
|
-
|
|
49
|
+
<Polymorphic
|
|
50
|
+
defaultAs="div"
|
|
51
|
+
as={local.as}
|
|
51
52
|
class={cn(
|
|
52
53
|
MENU_ITEM,
|
|
53
54
|
"w-full cursor-pointer gap-3 py-0 text-left",
|
|
@@ -108,6 +109,6 @@ export function PickerRow(props: PickerRowProps) {
|
|
|
108
109
|
/>
|
|
109
110
|
</div>
|
|
110
111
|
</Show>
|
|
111
|
-
</
|
|
112
|
+
</Polymorphic>
|
|
112
113
|
);
|
|
113
114
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type JSX, Show, splitProps } from "solid-js";
|
|
2
|
+
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
2
3
|
import { CONTROL_H, FIELD_TEXT } from "../lib/input-classes.js";
|
|
3
4
|
import { CONTROL_H_TOUCH } from "../lib/picker-classes.js";
|
|
4
5
|
import { cn } from "../lib/utils.js";
|
|
@@ -76,7 +77,7 @@ export function PickerSearch(props: PickerSearchProps) {
|
|
|
76
77
|
class="text-muted-foreground hover:text-foreground shrink-0 rounded-sm p-1 transition-colors"
|
|
77
78
|
onClick={() => {
|
|
78
79
|
local.onValueChange?.("");
|
|
79
|
-
input
|
|
80
|
+
focusWithoutTracking(input, { preventScroll: false });
|
|
80
81
|
}}
|
|
81
82
|
>
|
|
82
83
|
<Icon icon="mdi:close-circle" width={16} height={16} />
|
package/src/solid/popover.tsx
CHANGED
|
@@ -9,7 +9,12 @@ import {
|
|
|
9
9
|
useContext,
|
|
10
10
|
} from "solid-js";
|
|
11
11
|
import { INPUT_SURFACE } from "../lib/input-classes.js";
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
createCoveredRoot,
|
|
14
|
+
inShadowRoot,
|
|
15
|
+
ReportCovered,
|
|
16
|
+
shadowLayer,
|
|
17
|
+
} from "../lib/shadow-layer.js";
|
|
13
18
|
import { nestedLayerAttrs, Z_CLASS } from "../lib/layers.js";
|
|
14
19
|
import { FIELD_MOTION, MORPH_MOTION, STAGGER } from "../lib/motion-classes.js";
|
|
15
20
|
import { anchorToTriggerTop, FLOATING_PANEL } from "../lib/overlay-classes.js";
|
|
@@ -39,16 +44,19 @@ const PopoverRoot: Component<PopoverProps> = (props) => {
|
|
|
39
44
|
const surface = () => local.surface ?? "overlay";
|
|
40
45
|
// Modal in a shadow root, Kobalte would aria-hide the realm's host, popover included.
|
|
41
46
|
const inShadow = inShadowRoot(usePortalMount());
|
|
47
|
+
const cover = createCoveredRoot();
|
|
42
48
|
return (
|
|
43
49
|
<PopoverSurfaceContext.Provider value={surface}>
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
<ReportCovered.Provider value={cover.report}>
|
|
51
|
+
<PopoverPrimitive
|
|
52
|
+
gutter={local.gutter ?? 0}
|
|
53
|
+
getAnchorRect={local.getAnchorRect ?? anchorToTriggerTop}
|
|
54
|
+
flip={false}
|
|
55
|
+
overlap
|
|
56
|
+
{...rest}
|
|
57
|
+
modal={inShadow || cover.covered() ? false : rest.modal}
|
|
58
|
+
/>
|
|
59
|
+
</ReportCovered.Provider>
|
|
52
60
|
</PopoverSurfaceContext.Provider>
|
|
53
61
|
);
|
|
54
62
|
};
|
|
@@ -115,7 +123,7 @@ const PopoverContent: Component<PopoverContentProps> = (props) => {
|
|
|
115
123
|
onCloseAutoFocus={layer.onCloseAutoFocus}
|
|
116
124
|
data-slot="popover-content"
|
|
117
125
|
data-surface={surface()}
|
|
118
|
-
{...nestedLayerAttrs(popover.isModal())}
|
|
126
|
+
{...nestedLayerAttrs(popover.isModal() || layer.covered())}
|
|
119
127
|
class={cn(surface() === "field" ? FIELD_PANEL : OVERLAY_PANEL, local.class)}
|
|
120
128
|
{...rest}
|
|
121
129
|
/>
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
type Component,
|
|
4
4
|
type ComponentProps,
|
|
5
5
|
createContext,
|
|
6
|
-
createSignal,
|
|
7
6
|
type JSX,
|
|
8
7
|
type ParentComponent,
|
|
9
8
|
Show,
|
|
@@ -12,6 +11,7 @@ import {
|
|
|
12
11
|
type ValidComponent,
|
|
13
12
|
} from "solid-js";
|
|
14
13
|
import type { buttonVariants } from "../lib/button-variants.js";
|
|
14
|
+
import { createControllableSignal } from "../lib/behavior/controllable.js";
|
|
15
15
|
import { createIsMobile } from "../lib/use-is-mobile.js";
|
|
16
16
|
import {
|
|
17
17
|
BottomSheet,
|
|
@@ -46,27 +46,27 @@ interface ResponsiveDialogProps {
|
|
|
46
46
|
open?: boolean;
|
|
47
47
|
onOpenChange?: (open: boolean) => void;
|
|
48
48
|
defaultOpen?: boolean;
|
|
49
|
+
/** The centred dialog stays mounted and dormant between opens; the bottom sheet ignores it. */
|
|
50
|
+
keep?: boolean;
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
/** Centred kobalte dialog from `sm` up, drag-to-dismiss bottom sheet below it.
|
|
52
54
|
* Both branches render the same parts, so a call site never branches. */
|
|
53
55
|
const ResponsiveDialog: ParentComponent<ResponsiveDialogProps> = (props) => {
|
|
54
|
-
const [
|
|
56
|
+
const [open, setOpen] = createControllableSignal<boolean>({
|
|
57
|
+
value: () => props.open,
|
|
58
|
+
defaultValue: () => props.defaultOpen ?? false,
|
|
59
|
+
onChange: (next) => props.onOpenChange?.(next),
|
|
60
|
+
});
|
|
55
61
|
const mobile = createIsMobile();
|
|
56
62
|
const isMobile = () => mobile() === true;
|
|
57
63
|
|
|
58
|
-
const open = () => (props.open !== undefined ? props.open === true : uncontrolledOpen());
|
|
59
|
-
const setOpen = (next: boolean) => {
|
|
60
|
-
if (props.open === undefined) setUncontrolledOpen(next);
|
|
61
|
-
props.onOpenChange?.(next);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
64
|
return (
|
|
65
65
|
<ResponsiveDialogContext.Provider value={{ open, setOpen, isMobile }}>
|
|
66
66
|
<Show
|
|
67
67
|
when={isMobile()}
|
|
68
68
|
fallback={
|
|
69
|
-
<Dialog open={open()} onOpenChange={setOpen}>
|
|
69
|
+
<Dialog open={open()} onOpenChange={setOpen} keep={props.keep}>
|
|
70
70
|
{props.children}
|
|
71
71
|
</Dialog>
|
|
72
72
|
}
|
package/src/solid/sheet.tsx
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
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
|
children,
|
|
6
5
|
type Component,
|
|
7
|
-
type ComponentProps,
|
|
8
6
|
type JSX,
|
|
9
7
|
type ParentComponent,
|
|
10
8
|
Show,
|
|
11
|
-
createSignal,
|
|
12
9
|
splitProps,
|
|
13
10
|
} from "solid-js";
|
|
11
|
+
import { ModalFrame, useDialogContext } from "../lib/behavior/modal-root.js";
|
|
14
12
|
import { buttonVariants } from "../lib/button-variants.js";
|
|
15
|
-
import { inShadowRoot, shadowLayer } from "../lib/shadow-layer.js";
|
|
16
13
|
import { Z_CLASS } from "../lib/layers.js";
|
|
17
14
|
import { SCRIM_MOTION } from "../lib/motion-classes.js";
|
|
18
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
OVERLAY_SURFACE,
|
|
17
|
+
SCRIM_CLASS,
|
|
18
|
+
SCRIM_CONTAIN,
|
|
19
|
+
SCROLL_CONTAIN,
|
|
20
|
+
} from "../lib/overlay-classes.js";
|
|
19
21
|
import { cn } from "../lib/utils.js";
|
|
20
22
|
import {
|
|
21
23
|
createModalDismiss,
|
|
22
24
|
createModalParts,
|
|
23
|
-
|
|
25
|
+
createModalRootSkin,
|
|
26
|
+
createModalTextParts,
|
|
24
27
|
MODAL_MAX_H,
|
|
25
|
-
|
|
28
|
+
type ModalContentProps,
|
|
26
29
|
type ModalDismissProps,
|
|
27
|
-
|
|
30
|
+
ModalCover,
|
|
28
31
|
} from "./dialog-parts.js";
|
|
29
32
|
|
|
30
|
-
|
|
31
|
-
* refcounted page lock every modal family shares. */
|
|
32
|
-
const Sheet: ParentComponent<ComponentProps<typeof DialogPrimitive>> = (props) => {
|
|
33
|
-
const mount = usePortalMount();
|
|
34
|
-
return <DialogPrimitive modal={!inShadowRoot(mount)} {...props} preventScroll={false} />;
|
|
35
|
-
};
|
|
33
|
+
const Sheet = createModalRootSkin("dialog");
|
|
36
34
|
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
const {
|
|
36
|
+
Trigger: SheetTrigger,
|
|
37
|
+
Title: SheetTitle,
|
|
38
|
+
Description: SheetDescription,
|
|
39
|
+
} = createModalTextParts("sheet");
|
|
40
40
|
|
|
41
41
|
type SheetCloseProps = ModalDismissProps &
|
|
42
42
|
Partial<Pick<VariantProps<typeof buttonVariants>, "variant" | "size">>;
|
|
43
43
|
|
|
44
|
-
const SheetDismiss = createModalDismiss("sheet-close");
|
|
44
|
+
const SheetDismiss = createModalDismiss("sheet-close", useDialogContext);
|
|
45
45
|
|
|
46
46
|
/** Already the outline button; see DialogClose on why `as={Button}` is wrong. */
|
|
47
47
|
const SheetClose: ParentComponent<SheetCloseProps> = (props) => {
|
|
@@ -59,25 +59,16 @@ const SheetClose: ParentComponent<SheetCloseProps> = (props) => {
|
|
|
59
59
|
);
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
const
|
|
63
|
-
const [local, rest] = splitProps(props, ["class"]);
|
|
64
|
-
return (
|
|
65
|
-
<DialogPrimitive.Overlay
|
|
66
|
-
data-slot="sheet-overlay"
|
|
67
|
-
class={cn(
|
|
68
|
-
`${SCRIM_MOTION} pointer-events-auto fixed inset-0 select-none ${Z_CLASS.overlay} ${SCRIM_CLASS}`,
|
|
69
|
-
local.class,
|
|
70
|
-
)}
|
|
71
|
-
{...rest}
|
|
72
|
-
/>
|
|
73
|
-
);
|
|
74
|
-
};
|
|
62
|
+
const SHEET_SCRIM = `${SCRIM_MOTION} pointer-events-auto fixed inset-0 select-none ${Z_CLASS.overlay} ${SCRIM_CLASS} ${SCRIM_CONTAIN}`;
|
|
75
63
|
|
|
76
64
|
/* A viewport-tall panel would stretch the percentage-sized sheen into a small
|
|
77
65
|
* blob over a flat field; pinned lengths match the ellipse a dialog gets. */
|
|
78
66
|
const SHEET_SURFACE = `${OVERLAY_SURFACE} [--glass-sheen:600px_300px]`;
|
|
79
67
|
|
|
80
|
-
const SHEET_PANEL = `fixed ${Z_CLASS.overlay} flex flex-col overflow-hidden rounded-lg ${SHEET_SURFACE} transition ease-in-out focus:outline-none focus-visible:outline-none data-[closed]:animate-out data-[expanded]:animate-in data-[closed]:duration-300 data-[expanded]:duration-500`;
|
|
68
|
+
const SHEET_PANEL = `fixed ${Z_CLASS.overlay} flex flex-col overflow-hidden ${SCROLL_CONTAIN} rounded-lg ${SHEET_SURFACE} transition ease-in-out focus:outline-none focus-visible:outline-none data-[closed]:animate-out data-[expanded]:animate-in data-[closed]:duration-300 data-[expanded]:duration-500`;
|
|
69
|
+
|
|
70
|
+
/* The data-[closed] duration in SHEET_PANEL. */
|
|
71
|
+
const SHEET_EXIT_MS = 300;
|
|
81
72
|
|
|
82
73
|
const SHEET_SIDE = {
|
|
83
74
|
right:
|
|
@@ -90,7 +81,7 @@ const SHEET_SIDE = {
|
|
|
90
81
|
|
|
91
82
|
type SheetSide = keyof typeof SHEET_SIDE;
|
|
92
83
|
|
|
93
|
-
type SheetContentProps =
|
|
84
|
+
type SheetContentProps = ModalContentProps & {
|
|
94
85
|
/** A modal belongs in `ResponsiveDialog`; this family slides from an edge. */
|
|
95
86
|
side?: SheetSide;
|
|
96
87
|
above?: JSX.Element;
|
|
@@ -116,66 +107,43 @@ const SheetContent: ParentComponent<SheetContentProps> = (props) => {
|
|
|
116
107
|
"side",
|
|
117
108
|
"above",
|
|
118
109
|
"ariaLabel",
|
|
110
|
+
"style",
|
|
119
111
|
"ref",
|
|
120
|
-
"
|
|
121
|
-
"
|
|
112
|
+
"onOpenAutoFocus",
|
|
113
|
+
"onFocusOutside",
|
|
114
|
+
"forceMount",
|
|
122
115
|
]);
|
|
123
|
-
const
|
|
124
|
-
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
125
|
-
const layer = shadowLayer({
|
|
126
|
-
content: panel,
|
|
127
|
-
open: () => context.isOpen(),
|
|
128
|
-
dismiss: () => context.close(),
|
|
129
|
-
trapsFocus: true,
|
|
130
|
-
initialFocus: "container",
|
|
131
|
-
consumer: local,
|
|
132
|
-
});
|
|
133
|
-
|
|
116
|
+
const ctx = useDialogContext();
|
|
134
117
|
return (
|
|
135
|
-
|
|
136
|
-
<
|
|
137
|
-
<
|
|
138
|
-
|
|
118
|
+
<>
|
|
119
|
+
<ModalCover panel={ctx.panel} open={ctx.isOpen} dormant={ctx.dormant} />
|
|
120
|
+
<ModalFrame
|
|
121
|
+
slot="sheet"
|
|
122
|
+
mount={usePortalMount()}
|
|
123
|
+
exitMs={SHEET_EXIT_MS}
|
|
124
|
+
scrimClass={SHEET_SCRIM}
|
|
125
|
+
panelClass={cn(SHEET_PANEL, SHEET_SIDE[local.side ?? "right"], local.class)}
|
|
126
|
+
panelStyle={typeof local.style === "object" ? local.style : undefined}
|
|
127
|
+
ariaLabel={local.ariaLabel}
|
|
139
128
|
ref={(el: HTMLElement) => {
|
|
140
|
-
|
|
141
|
-
|
|
129
|
+
if (typeof local.ref === "function") local.ref(el as HTMLDivElement);
|
|
130
|
+
}}
|
|
131
|
+
onOpenAutoFocus={(event: Event) => {
|
|
132
|
+
// The panel takes focus itself, not its first control.
|
|
133
|
+
if (local.onOpenAutoFocus) local.onOpenAutoFocus(event);
|
|
134
|
+
else event.preventDefault();
|
|
142
135
|
}}
|
|
143
|
-
onInteractOutside={layer.onInteractOutside}
|
|
144
|
-
onCloseAutoFocus={layer.onCloseAutoFocus}
|
|
145
|
-
data-slot="sheet-content"
|
|
146
|
-
role="dialog"
|
|
147
|
-
aria-label={context.titleId() ? undefined : local.ariaLabel}
|
|
148
|
-
class={cn(SHEET_PANEL, SHEET_SIDE[local.side ?? "right"], local.class)}
|
|
149
|
-
onOpenAutoFocus={(e: Event) => e.preventDefault()}
|
|
150
136
|
{...rest}
|
|
151
137
|
>
|
|
152
138
|
<SheetAbove above={local.above} />
|
|
153
139
|
{local.children}
|
|
154
|
-
</
|
|
155
|
-
|
|
140
|
+
</ModalFrame>
|
|
141
|
+
</>
|
|
156
142
|
);
|
|
157
143
|
};
|
|
158
144
|
|
|
159
145
|
const { Header: SheetHeader, Body: SheetBody, Footer: SheetFooter } = createModalParts("sheet");
|
|
160
146
|
|
|
161
|
-
const SheetTitle: Component<ComponentProps<typeof DialogPrimitive.Title>> = (props) => {
|
|
162
|
-
const [local, rest] = splitProps(props, ["class"]);
|
|
163
|
-
return (
|
|
164
|
-
<DialogPrimitive.Title data-slot="sheet-title" class={cn(MODAL_TITLE, local.class)} {...rest} />
|
|
165
|
-
);
|
|
166
|
-
};
|
|
167
|
-
|
|
168
|
-
const SheetDescription: Component<ComponentProps<typeof DialogPrimitive.Description>> = (props) => {
|
|
169
|
-
const [local, rest] = splitProps(props, ["class"]);
|
|
170
|
-
return (
|
|
171
|
-
<DialogPrimitive.Description
|
|
172
|
-
data-slot="sheet-description"
|
|
173
|
-
class={cn(MODAL_DESCRIPTION, local.class)}
|
|
174
|
-
{...rest}
|
|
175
|
-
/>
|
|
176
|
-
);
|
|
177
|
-
};
|
|
178
|
-
|
|
179
147
|
export {
|
|
180
148
|
Sheet,
|
|
181
149
|
SheetBody,
|
package/src/solid/spotlight.tsx
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
} from "solid-js";
|
|
10
10
|
import { Portal } from "solid-js/web";
|
|
11
11
|
import { usePortalMount } from "./portal-mount.js";
|
|
12
|
+
import { createDismiss } from "../lib/behavior/dismiss.js";
|
|
13
|
+
import { registerLayer } from "../lib/behavior/layer-stack.js";
|
|
12
14
|
import { Z_CLASS } from "../lib/layers.js";
|
|
13
15
|
import { SCRIM_MOTION, TRAVEL_MOTION } from "../lib/motion-classes.js";
|
|
14
16
|
import { OVERLAY_SURFACE_OPAQUE, PANEL_TAIL, SCRIM_CLASS } from "../lib/overlay-classes.js";
|
|
@@ -54,7 +56,20 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
54
56
|
{ width: BUBBLE_DEFAULT_WIDTH, height: 96 },
|
|
55
57
|
{ equals: sameFields },
|
|
56
58
|
);
|
|
57
|
-
|
|
59
|
+
const [bubble, setBubble] = createSignal<HTMLDivElement>();
|
|
60
|
+
const handle = registerLayer({
|
|
61
|
+
element: bubble,
|
|
62
|
+
open: () => true,
|
|
63
|
+
kind: "tour",
|
|
64
|
+
escape: () => props.onSkip !== undefined,
|
|
65
|
+
dismiss: () => props.onSkip?.(),
|
|
66
|
+
});
|
|
67
|
+
createDismiss({
|
|
68
|
+
layer: handle,
|
|
69
|
+
outsidePress: () => false,
|
|
70
|
+
escapeFrom: "document",
|
|
71
|
+
onDismiss: () => props.onSkip?.(),
|
|
72
|
+
});
|
|
58
73
|
|
|
59
74
|
const anchorEl = () => props.anchor ?? props.target;
|
|
60
75
|
|
|
@@ -70,10 +85,11 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
70
85
|
const anchor = anchorEl();
|
|
71
86
|
/* Same element as target: reuse its box instead of measuring it twice a tick. */
|
|
72
87
|
setAnchorBox(anchor === props.target ? targetBox : rectToBox(anchor));
|
|
73
|
-
|
|
88
|
+
const node = bubble();
|
|
89
|
+
if (node)
|
|
74
90
|
setBubbleSize({
|
|
75
|
-
width:
|
|
76
|
-
height:
|
|
91
|
+
width: node.offsetWidth || BUBBLE_DEFAULT_WIDTH,
|
|
92
|
+
height: node.offsetHeight || 96,
|
|
77
93
|
});
|
|
78
94
|
};
|
|
79
95
|
|
|
@@ -97,7 +113,8 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
97
113
|
const observer = new ResizeObserver(measure);
|
|
98
114
|
if (target) observer.observe(target);
|
|
99
115
|
if (anchor && anchor !== target) observer.observe(anchor);
|
|
100
|
-
|
|
116
|
+
const node = bubble();
|
|
117
|
+
if (node) observer.observe(node);
|
|
101
118
|
onCleanup(() => {
|
|
102
119
|
cancelAnimationFrame(raf);
|
|
103
120
|
observer.disconnect();
|
|
@@ -105,16 +122,11 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
105
122
|
});
|
|
106
123
|
|
|
107
124
|
onMount(() => {
|
|
108
|
-
const onKey = (e: KeyboardEvent) => {
|
|
109
|
-
if (e.key === "Escape") props.onSkip?.();
|
|
110
|
-
};
|
|
111
125
|
window.addEventListener("resize", measure);
|
|
112
126
|
window.addEventListener("scroll", measure, { capture: true, passive: true });
|
|
113
|
-
document.addEventListener("keydown", onKey);
|
|
114
127
|
onCleanup(() => {
|
|
115
128
|
window.removeEventListener("resize", measure);
|
|
116
129
|
window.removeEventListener("scroll", measure, { capture: true });
|
|
117
|
-
document.removeEventListener("keydown", onKey);
|
|
118
130
|
});
|
|
119
131
|
});
|
|
120
132
|
|
|
@@ -142,7 +154,7 @@ const Spotlight: Component<SpotlightProps> = (props) => {
|
|
|
142
154
|
/>
|
|
143
155
|
</Show>
|
|
144
156
|
<div
|
|
145
|
-
ref={
|
|
157
|
+
ref={setBubble}
|
|
146
158
|
data-slot="spotlight-bubble"
|
|
147
159
|
data-side={place().side}
|
|
148
160
|
class={cn(TRAVEL_MOTION, Z_CLASS.overlay, "fixed top-0 left-0 w-96", props.class)}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Component, Show } from "solid-js";
|
|
2
|
+
import { VEIL_MOTION } from "../lib/motion-classes.js";
|
|
3
|
+
import { cn } from "../lib/utils.js";
|
|
4
|
+
|
|
5
|
+
/** Fills its positioned parent; no z-index, so it paints over earlier siblings: render it last. */
|
|
6
|
+
const StaleVeil: Component<{ shown: boolean; class?: string }> = (props) => (
|
|
7
|
+
<Show when={props.shown}>
|
|
8
|
+
<div
|
|
9
|
+
data-slot="stale-veil"
|
|
10
|
+
aria-hidden="true"
|
|
11
|
+
class={cn(
|
|
12
|
+
"bg-background/40 pointer-events-none absolute inset-0 rounded-[inherit]",
|
|
13
|
+
VEIL_MOTION,
|
|
14
|
+
props.class,
|
|
15
|
+
)}
|
|
16
|
+
/>
|
|
17
|
+
</Show>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export { StaleVeil };
|
package/src/solid/switch.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { type Component, type ComponentProps,
|
|
1
|
+
import { type Component, type ComponentProps, splitProps } from "solid-js";
|
|
2
|
+
import { createControllableSignal } from "../lib/behavior/controllable.js";
|
|
2
3
|
import { CONTROL_ON, FIELD_CHROME, FOCUS_RING } from "../lib/input-classes.js";
|
|
3
4
|
import { THUMB_CLASS } from "../lib/thumb-classes.js";
|
|
4
5
|
import { cn } from "../lib/utils.js";
|
|
@@ -20,8 +21,11 @@ const Switch: Component<SwitchProps> = (props) => {
|
|
|
20
21
|
"name",
|
|
21
22
|
"busy",
|
|
22
23
|
]);
|
|
23
|
-
const [
|
|
24
|
-
|
|
24
|
+
const [checked, setChecked] = createControllableSignal<boolean>({
|
|
25
|
+
value: () => local.checked,
|
|
26
|
+
defaultValue: () => props.defaultChecked ?? false,
|
|
27
|
+
onChange: (next) => local.onChange?.(next),
|
|
28
|
+
});
|
|
25
29
|
|
|
26
30
|
return (
|
|
27
31
|
<button
|
|
@@ -44,9 +48,7 @@ const Switch: Component<SwitchProps> = (props) => {
|
|
|
44
48
|
)}
|
|
45
49
|
onClick={() => {
|
|
46
50
|
if (local.busy) return;
|
|
47
|
-
|
|
48
|
-
setUncontrolled(next);
|
|
49
|
-
local.onChange?.(next);
|
|
51
|
+
setChecked(!checked());
|
|
50
52
|
}}
|
|
51
53
|
>
|
|
52
54
|
<span
|