@glasshome/ui 1.41.0 → 1.43.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 +34 -0
- package/dist/lib/balance-rows.d.ts +10 -4
- package/dist/lib/behavior/anchored.d.ts +26 -0
- package/dist/lib/behavior/button-root.d.ts +7 -0
- package/dist/lib/behavior/collection.d.ts +32 -0
- package/dist/lib/behavior/controllable.d.ts +8 -0
- package/dist/lib/behavior/dismiss.d.ts +13 -0
- package/dist/lib/behavior/focus-scope.d.ts +24 -0
- package/dist/lib/behavior/hide-outside.d.ts +7 -0
- package/dist/lib/behavior/layer-stack.d.ts +34 -0
- package/dist/lib/behavior/menu.d.ts +59 -0
- package/dist/lib/behavior/modal-root.d.ts +68 -0
- package/dist/lib/behavior/polymorphic.d.ts +6 -0
- package/dist/lib/behavior/presence.d.ts +18 -0
- package/dist/lib/behavior/range.d.ts +44 -0
- package/dist/lib/behavior/solid.d.ts +13 -0
- package/dist/lib/color/color.d.ts +41 -0
- package/dist/lib/color/index.d.ts +2 -0
- package/dist/lib/color/intl.d.ts +40 -0
- package/dist/lib/dock-slot-classes.d.ts +2 -0
- package/dist/lib/hold.d.ts +1 -1
- package/dist/lib/locale.d.ts +3 -0
- package/dist/lib/menu-classes.d.ts +2 -0
- package/dist/lib/motion-classes.d.ts +5 -2
- package/dist/lib/overlay-classes.d.ts +4 -0
- package/dist/lib/page-cover.d.ts +8 -0
- package/dist/lib/scroll-track.d.ts +3 -2
- package/dist/lib/section-tokens.d.ts +1 -1
- package/dist/lib/segment-classes.d.ts +2 -0
- package/dist/lib/shadow-layer.d.ts +0 -43
- package/dist/lib/toggle-set.d.ts +44 -0
- package/dist/lib/visually-hidden.d.ts +3 -0
- package/dist/solid/accordion.d.ts +35 -11
- package/dist/solid/alert-dialog.d.ts +5 -8
- package/dist/solid/avatar.d.ts +8 -4
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +2 -2
- package/dist/solid/bottom-sheet/constants.d.ts +1 -1
- package/dist/solid/button.d.ts +5 -4
- package/dist/solid/charts.d.ts +1 -1
- package/dist/solid/checkbox.d.ts +14 -4
- package/dist/solid/collapsible.d.ts +33 -5
- package/dist/solid/color-disc.d.ts +1 -1
- package/dist/solid/color-slider.d.ts +1 -1
- package/dist/solid/color-wheel.d.ts +1 -1
- package/dist/solid/context-menu.d.ts +58 -24
- package/dist/solid/dialog-parts.d.ts +53 -16
- package/dist/solid/dialog.d.ts +7 -10
- package/dist/solid/dropdown-menu.d.ts +55 -24
- package/dist/solid/empty.d.ts +1 -1
- package/dist/solid/form.d.ts +5 -6
- package/dist/solid/hover-card.d.ts +65 -9
- package/dist/solid/index.d.ts +5 -2
- package/dist/solid/index.js +8671 -14317
- package/dist/solid/input-group.d.ts +6 -6
- package/dist/solid/item.d.ts +1 -1
- package/dist/solid/menu-parts.d.ts +175 -24
- package/dist/solid/option-card.d.ts +1 -4
- package/dist/solid/picker-row.d.ts +2 -0
- package/dist/solid/popover.d.ts +77 -12
- package/dist/solid/progress.d.ts +11 -3
- package/dist/solid/radio-group.d.ts +31 -6
- package/dist/solid/responsive-dialog.d.ts +3 -1
- package/dist/solid/scroll-area.d.ts +1 -1
- package/dist/solid/section-card.d.ts +2 -3
- package/dist/solid/select.d.ts +107 -10
- package/dist/solid/selection.d.ts +10 -1
- package/dist/solid/sheet.d.ts +6 -9
- package/dist/solid/sliding-indicator.d.ts +1 -1
- package/dist/solid/sonner.d.ts +1 -1
- 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/toggle.d.ts +11 -3
- package/dist/solid/tooltip.d.ts +71 -9
- package/dist/tokens/index.js +54 -51
- package/dist/{utils-CGN4X-2O.js → utils-3Codx-NZ.js} +848 -618
- package/package.json +6 -7
- package/src/index.ts +1 -0
- package/src/lib/anchor-placement.ts +77 -4
- package/src/lib/balance-rows.ts +115 -40
- package/src/lib/behavior/anchored.ts +106 -0
- package/src/lib/behavior/button-root.tsx +103 -0
- package/src/lib/behavior/collection.ts +218 -0
- package/src/lib/behavior/controllable.ts +22 -0
- package/src/lib/behavior/dismiss.ts +185 -0
- package/src/lib/behavior/focus-scope.ts +227 -0
- package/src/lib/behavior/hide-outside.ts +85 -0
- package/src/lib/behavior/layer-stack.ts +150 -0
- package/src/lib/behavior/menu.ts +470 -0
- package/src/lib/behavior/modal-root.tsx +452 -0
- package/src/lib/behavior/polymorphic.tsx +30 -0
- package/src/lib/behavior/presence.ts +89 -0
- package/src/lib/behavior/range.ts +212 -0
- package/src/lib/behavior/solid.ts +30 -0
- package/src/lib/clipboard.ts +4 -4
- package/src/lib/color/color.ts +746 -0
- package/src/lib/color/index.ts +2 -0
- package/src/lib/color/intl.ts +60 -0
- package/src/lib/dock-slot-classes.ts +3 -0
- package/src/lib/hold.ts +1 -1
- package/src/lib/locale.ts +62 -0
- package/src/lib/menu-classes.ts +3 -0
- package/src/lib/motion-classes.ts +33 -8
- package/src/lib/overlay-classes.ts +8 -3
- package/src/lib/page-cover.ts +47 -0
- package/src/lib/scroll-track.ts +11 -6
- package/src/lib/section-tokens.ts +1 -1
- package/src/lib/segment-classes.ts +3 -0
- package/src/lib/shadow-layer.ts +0 -136
- package/src/lib/toggle-set.ts +133 -0
- package/src/lib/visually-hidden.ts +15 -0
- package/src/solid/accordion.tsx +294 -20
- package/src/solid/alert-dialog.tsx +36 -85
- package/src/solid/area-picker.tsx +5 -3
- package/src/solid/avatar.tsx +98 -24
- package/src/solid/badge.tsx +5 -5
- package/src/solid/bottom-sheet/bottom-sheet.tsx +73 -129
- 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/button.tsx +12 -6
- package/src/solid/card.tsx +5 -4
- package/src/solid/charts.tsx +1 -1
- package/src/solid/checkbox.tsx +167 -44
- package/src/solid/collapsible.tsx +260 -12
- package/src/solid/color-disc.tsx +11 -12
- package/src/solid/color-slider.tsx +114 -47
- package/src/solid/color-wheel.tsx +137 -39
- package/src/solid/context-menu.tsx +287 -86
- package/src/solid/dialog-parts.tsx +135 -46
- package/src/solid/dialog.tsx +44 -76
- package/src/solid/dock-edit.tsx +5 -4
- package/src/solid/dock.tsx +6 -5
- package/src/solid/dropdown-menu.tsx +252 -107
- package/src/solid/empty.tsx +1 -1
- package/src/solid/entity-selector.tsx +5 -3
- package/src/solid/face-toggle.tsx +43 -18
- package/src/solid/form.tsx +9 -9
- package/src/solid/glyph-tile.tsx +48 -21
- package/src/solid/hover-card.tsx +288 -21
- package/src/solid/icon-picker.tsx +2 -1
- package/src/solid/image-picker.tsx +6 -5
- package/src/solid/index.ts +5 -4
- package/src/solid/input-group.tsx +7 -5
- package/src/solid/input-otp.tsx +2 -1
- package/src/solid/item.tsx +5 -5
- package/src/solid/logo.tsx +5 -4
- package/src/solid/menu-parts.tsx +619 -145
- package/src/solid/option-card.tsx +6 -10
- package/src/solid/picker-row.tsx +10 -5
- package/src/solid/picker-search.tsx +2 -1
- package/src/solid/popover.tsx +424 -71
- package/src/solid/preview-tile.tsx +1 -1
- package/src/solid/progress.tsx +84 -15
- package/src/solid/radio-group.tsx +271 -34
- package/src/solid/responsive-dialog.tsx +10 -10
- package/src/solid/schema-form.tsx +1 -6
- package/src/solid/scroll-area.tsx +1 -1
- package/src/solid/section-card.tsx +3 -4
- package/src/solid/select.tsx +950 -95
- package/src/solid/selection.tsx +142 -66
- package/src/solid/sheet.tsx +48 -80
- package/src/solid/slider.tsx +115 -65
- package/src/solid/sliding-indicator.tsx +1 -1
- package/src/solid/sonner.tsx +1 -1
- 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 +377 -52
- package/src/solid/term.tsx +3 -4
- package/src/solid/toggle-group.tsx +237 -95
- package/src/solid/toggle.tsx +43 -9
- package/src/solid/tooltip.tsx +285 -26
- package/src/styles/globals.css +64 -10
- package/src/styles/theme.css +12 -4
- package/src/tokens/material.ts +11 -2
- 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/tooltip.tsx
CHANGED
|
@@ -1,48 +1,307 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
type Accessor,
|
|
3
|
+
type Component,
|
|
4
|
+
type ComponentProps,
|
|
5
|
+
createContext,
|
|
6
|
+
createSignal,
|
|
7
|
+
createUniqueId,
|
|
8
|
+
type JSX,
|
|
9
|
+
onCleanup,
|
|
10
|
+
Show,
|
|
11
|
+
splitProps,
|
|
12
|
+
untrack,
|
|
13
|
+
useContext,
|
|
14
|
+
type ValidComponent,
|
|
15
|
+
} from "solid-js";
|
|
16
|
+
import { Portal } from "solid-js/web";
|
|
17
|
+
import { createAnchored } from "../lib/behavior/anchored.js";
|
|
18
|
+
import { createControllableSignal } from "../lib/behavior/controllable.js";
|
|
19
|
+
import { createDismiss } from "../lib/behavior/dismiss.js";
|
|
20
|
+
import { registerLayer } from "../lib/behavior/layer-stack.js";
|
|
21
|
+
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
22
|
+
import { createPresence } from "../lib/behavior/presence.js";
|
|
23
|
+
import { effect, merge } from "../lib/behavior/solid.js";
|
|
24
|
+
import type { Align, Side } from "../lib/anchor-placement.js";
|
|
25
|
+
import { MOTION_EXIT_MS, OVERLAY_MOTION } from "../lib/motion-classes.js";
|
|
6
26
|
import { FLOATING_PANEL } from "../lib/overlay-classes.js";
|
|
7
27
|
import { cn } from "../lib/utils.js";
|
|
28
|
+
import { usePortalMount } from "./portal-mount.js";
|
|
8
29
|
|
|
9
|
-
|
|
10
|
-
* gutter that keeps the panel off its trigger has to default here. */
|
|
11
|
-
const TooltipRoot: Component<ComponentProps<typeof TooltipPrimitive>> = (props) => (
|
|
12
|
-
<TooltipPrimitive gutter={6} {...props} />
|
|
13
|
-
);
|
|
30
|
+
type Placement = Side | `${Side}-${Exclude<Align, "center">}`;
|
|
14
31
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
32
|
+
interface TooltipRootProps {
|
|
33
|
+
open?: boolean;
|
|
34
|
+
defaultOpen?: boolean;
|
|
35
|
+
onOpenChange?: (open: boolean) => void;
|
|
36
|
+
placement?: Placement;
|
|
37
|
+
gutter?: number;
|
|
38
|
+
openDelay?: number;
|
|
39
|
+
closeDelay?: number;
|
|
40
|
+
children?: JSX.Element;
|
|
41
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
42
|
+
id?: string;
|
|
43
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
44
|
+
disabled?: boolean;
|
|
45
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
46
|
+
skipDelayDuration?: number;
|
|
47
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
48
|
+
triggerOnFocusOnly?: boolean;
|
|
49
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
50
|
+
ignoreSafeArea?: boolean;
|
|
51
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
52
|
+
forceMount?: boolean;
|
|
53
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
54
|
+
getAnchorRect?: (anchor?: HTMLElement) => unknown;
|
|
55
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
56
|
+
shift?: number;
|
|
57
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
58
|
+
flip?: boolean | string;
|
|
59
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
60
|
+
slide?: boolean;
|
|
61
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
62
|
+
overlap?: boolean;
|
|
63
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
64
|
+
sameWidth?: boolean;
|
|
65
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
66
|
+
fitViewport?: boolean;
|
|
67
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
68
|
+
hideWhenDetached?: boolean;
|
|
69
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
70
|
+
detachedPadding?: number;
|
|
71
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
72
|
+
arrowPadding?: number;
|
|
73
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
74
|
+
overflowPadding?: number;
|
|
75
|
+
}
|
|
19
76
|
|
|
20
|
-
|
|
77
|
+
interface TooltipContentProps extends ComponentProps<"div"> {
|
|
78
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
79
|
+
forceMount?: boolean;
|
|
80
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
81
|
+
onEscapeKeyDown?: (event: Event) => void;
|
|
82
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
83
|
+
onPointerDownOutside?: (event: Event) => void;
|
|
84
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
85
|
+
onFocusOutside?: (event: Event) => void;
|
|
86
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
87
|
+
onInteractOutside?: (event: Event) => void;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
interface TooltipContextValue {
|
|
91
|
+
id: string;
|
|
92
|
+
open: Accessor<boolean>;
|
|
93
|
+
trigger: Accessor<HTMLElement | undefined>;
|
|
94
|
+
setTrigger: (el: HTMLElement | undefined) => void;
|
|
95
|
+
side: Accessor<Side>;
|
|
96
|
+
align: Accessor<Align>;
|
|
97
|
+
gutter: number;
|
|
98
|
+
show: (delayed: boolean) => void;
|
|
99
|
+
hide: (delayed: boolean) => void;
|
|
100
|
+
hold: () => void;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const TooltipContext = createContext<TooltipContextValue>();
|
|
104
|
+
|
|
105
|
+
const useTooltip = (): TooltipContextValue => {
|
|
106
|
+
const ctx = useContext(TooltipContext);
|
|
107
|
+
if (!ctx) throw new Error("Tooltip parts render inside a Tooltip");
|
|
108
|
+
return ctx;
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
const OPEN_DELAY_MS = 700;
|
|
112
|
+
const CLOSE_DELAY_MS = 100;
|
|
113
|
+
|
|
114
|
+
const ORIGIN_BY_SIDE =
|
|
115
|
+
"data-[side=bottom]:origin-top data-[side=top]:origin-bottom data-[side=left]:origin-right data-[side=right]:origin-left";
|
|
116
|
+
|
|
117
|
+
const TooltipRoot: Component<TooltipRootProps> = (props) => {
|
|
118
|
+
const [open, setOpen] = createControllableSignal<boolean>({
|
|
119
|
+
value: () => props.open,
|
|
120
|
+
defaultValue: () => props.defaultOpen ?? false,
|
|
121
|
+
onChange: (next) => props.onOpenChange?.(next),
|
|
122
|
+
});
|
|
123
|
+
const [trigger, setTrigger] = createSignal<HTMLElement>();
|
|
124
|
+
const placement = () => (props.placement ?? "bottom").split("-") as [Side, Align?];
|
|
125
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
126
|
+
const hold = () => clearTimeout(timer);
|
|
127
|
+
const schedule = (next: boolean, delay: number) => {
|
|
128
|
+
hold();
|
|
129
|
+
if (delay <= 0) setOpen(next);
|
|
130
|
+
else timer = setTimeout(() => setOpen(next), delay);
|
|
131
|
+
};
|
|
132
|
+
onCleanup(hold);
|
|
133
|
+
|
|
134
|
+
const value: TooltipContextValue = {
|
|
135
|
+
id: createUniqueId(),
|
|
136
|
+
open,
|
|
137
|
+
trigger,
|
|
138
|
+
setTrigger,
|
|
139
|
+
side: () => placement()[0],
|
|
140
|
+
align: () => placement()[1] ?? "center",
|
|
141
|
+
gutter: untrack(() => props.gutter ?? 6),
|
|
142
|
+
show: (delayed) => schedule(true, delayed ? (props.openDelay ?? OPEN_DELAY_MS) : 0),
|
|
143
|
+
hide: (delayed) => schedule(false, delayed ? (props.closeDelay ?? CLOSE_DELAY_MS) : 0),
|
|
144
|
+
hold,
|
|
145
|
+
};
|
|
146
|
+
return <TooltipContext.Provider value={value}>{props.children}</TooltipContext.Provider>;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
type TooltipTriggerProps<T extends ValidComponent> = { as?: T } & Omit<ComponentProps<T>, "as">;
|
|
150
|
+
|
|
151
|
+
function TooltipTrigger<T extends ValidComponent = "button">(
|
|
152
|
+
props: TooltipTriggerProps<T>,
|
|
153
|
+
): JSX.Element {
|
|
154
|
+
const ctx = useTooltip();
|
|
155
|
+
const [local, rest] = splitProps(props as TooltipTriggerProps<ValidComponent>, [
|
|
156
|
+
"as",
|
|
157
|
+
"ref",
|
|
158
|
+
"aria-describedby",
|
|
159
|
+
]);
|
|
160
|
+
let pressed = false;
|
|
161
|
+
|
|
162
|
+
onCleanup(() => {
|
|
163
|
+
ctx.setTrigger(undefined);
|
|
164
|
+
ctx.hide(false);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
effect(ctx.trigger, (el) => {
|
|
168
|
+
if (!el) return;
|
|
169
|
+
const mouseLike = (e: PointerEvent) => e.pointerType !== "touch";
|
|
170
|
+
const enter = (e: PointerEvent) => mouseLike(e) && ctx.show(true);
|
|
171
|
+
const leave = (e: PointerEvent) => mouseLike(e) && ctx.hide(true);
|
|
172
|
+
const press = () => {
|
|
173
|
+
pressed = true;
|
|
174
|
+
ctx.hide(false);
|
|
175
|
+
};
|
|
176
|
+
const focus = () => {
|
|
177
|
+
if (!pressed) ctx.show(false);
|
|
178
|
+
};
|
|
179
|
+
const blur = () => {
|
|
180
|
+
pressed = false;
|
|
181
|
+
ctx.hide(false);
|
|
182
|
+
};
|
|
183
|
+
const key = () => {
|
|
184
|
+
pressed = false;
|
|
185
|
+
};
|
|
186
|
+
el.addEventListener("pointerenter", enter);
|
|
187
|
+
el.addEventListener("pointerleave", leave);
|
|
188
|
+
el.addEventListener("pointerdown", press);
|
|
189
|
+
el.addEventListener("focus", focus);
|
|
190
|
+
el.addEventListener("blur", blur);
|
|
191
|
+
el.addEventListener("keydown", key);
|
|
192
|
+
return () => {
|
|
193
|
+
el.removeEventListener("pointerenter", enter);
|
|
194
|
+
el.removeEventListener("pointerleave", leave);
|
|
195
|
+
el.removeEventListener("pointerdown", press);
|
|
196
|
+
el.removeEventListener("focus", focus);
|
|
197
|
+
el.removeEventListener("blur", blur);
|
|
198
|
+
el.removeEventListener("keydown", key);
|
|
199
|
+
};
|
|
200
|
+
});
|
|
21
201
|
|
|
22
|
-
const TooltipContent: Component<ComponentProps<typeof TooltipPrimitive.Content>> = (props) => {
|
|
23
|
-
const [local, others] = splitProps(props, ["class", "ref", "onInteractOutside"]);
|
|
24
|
-
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
25
|
-
// A tooltip closes as the pointer leaves; inside a shadow root it only must not close on its own presses.
|
|
26
|
-
const { onInteractOutside } = shadowLayer({ content: panel, open: () => true, consumer: local });
|
|
27
202
|
return (
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
203
|
+
<Polymorphic
|
|
204
|
+
{...merge({ "data-slot": "tooltip-trigger" }, rest, {
|
|
205
|
+
as: local.as,
|
|
206
|
+
defaultAs: "button" as ValidComponent,
|
|
207
|
+
ref: (el: HTMLElement) => {
|
|
208
|
+
ctx.setTrigger(el);
|
|
209
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
210
|
+
},
|
|
211
|
+
get "aria-describedby"() {
|
|
212
|
+
return (
|
|
213
|
+
[local["aria-describedby"], ctx.open() ? ctx.id : undefined]
|
|
214
|
+
.filter(Boolean)
|
|
215
|
+
.join(" ") || undefined
|
|
216
|
+
);
|
|
217
|
+
},
|
|
218
|
+
})}
|
|
219
|
+
/>
|
|
220
|
+
);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const TooltipContent: Component<TooltipContentProps> = (props) => {
|
|
224
|
+
const ctx = useTooltip();
|
|
225
|
+
const [local, others] = splitProps(props, [
|
|
226
|
+
"class",
|
|
227
|
+
"ref",
|
|
228
|
+
"forceMount",
|
|
229
|
+
"onEscapeKeyDown",
|
|
230
|
+
"onPointerDownOutside",
|
|
231
|
+
"onFocusOutside",
|
|
232
|
+
"onInteractOutside",
|
|
233
|
+
]);
|
|
234
|
+
const [panel, setPanel] = createSignal<HTMLElement>();
|
|
235
|
+
const presence = createPresence({
|
|
236
|
+
present: ctx.open,
|
|
237
|
+
element: panel,
|
|
238
|
+
exitMs: MOTION_EXIT_MS.overlay,
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
const layer = registerLayer({
|
|
242
|
+
element: panel,
|
|
243
|
+
open: presence.mounted,
|
|
244
|
+
kind: "tooltip",
|
|
245
|
+
escape: () => true,
|
|
246
|
+
topLayer: "manual",
|
|
247
|
+
});
|
|
248
|
+
createDismiss({ layer, outsidePress: () => false, onDismiss: () => ctx.hide(false) });
|
|
249
|
+
createAnchored({
|
|
250
|
+
anchor: ctx.trigger,
|
|
251
|
+
floating: panel,
|
|
252
|
+
open: ctx.open,
|
|
253
|
+
side: ctx.side,
|
|
254
|
+
align: ctx.align,
|
|
255
|
+
offset: ctx.gutter,
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
const Panel: Component = () => {
|
|
259
|
+
onCleanup(() => setPanel(undefined));
|
|
260
|
+
return (
|
|
261
|
+
<div
|
|
262
|
+
{...others}
|
|
263
|
+
ref={(el) => {
|
|
31
264
|
setPanel(el);
|
|
32
265
|
if (typeof local.ref === "function") local.ref(el);
|
|
33
266
|
}}
|
|
34
|
-
|
|
267
|
+
id={ctx.id}
|
|
268
|
+
role="tooltip"
|
|
35
269
|
data-slot="tooltip-content"
|
|
270
|
+
data-expanded={ctx.open() ? "" : undefined}
|
|
271
|
+
data-closed={ctx.open() ? undefined : ""}
|
|
272
|
+
on:pointerenter={ctx.hold}
|
|
273
|
+
on:pointerleave={() => ctx.hide(true)}
|
|
36
274
|
class={cn(
|
|
37
275
|
FLOATING_PANEL,
|
|
38
276
|
OVERLAY_MOTION,
|
|
277
|
+
ORIGIN_BY_SIDE,
|
|
39
278
|
"overflow-hidden px-3 py-1.5 text-xs",
|
|
40
279
|
local.class,
|
|
41
280
|
)}
|
|
42
|
-
{...others}
|
|
43
281
|
/>
|
|
44
|
-
|
|
282
|
+
);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
<Show when={presence.mounted()}>
|
|
287
|
+
<Portal mount={usePortalMount()}>
|
|
288
|
+
<Panel />
|
|
289
|
+
</Portal>
|
|
290
|
+
</Show>
|
|
45
291
|
);
|
|
46
292
|
};
|
|
47
293
|
|
|
294
|
+
/** @deprecated Drop the wrapper; the content portals itself; removed in 2.0.0. */
|
|
295
|
+
const TooltipPortal: Component<{ children?: JSX.Element }> = (props) => <>{props.children}</>;
|
|
296
|
+
|
|
297
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
298
|
+
const TooltipArrow: Component = () => null;
|
|
299
|
+
|
|
300
|
+
const Tooltip = Object.assign(TooltipRoot, {
|
|
301
|
+
Trigger: TooltipTrigger,
|
|
302
|
+
Content: TooltipContent,
|
|
303
|
+
Portal: TooltipPortal,
|
|
304
|
+
Arrow: TooltipArrow,
|
|
305
|
+
});
|
|
306
|
+
|
|
48
307
|
export { Tooltip, TooltipContent, TooltipTrigger };
|
package/src/styles/globals.css
CHANGED
|
@@ -418,21 +418,17 @@
|
|
|
418
418
|
background:
|
|
419
419
|
var(--glass-grain, none),
|
|
420
420
|
radial-gradient(
|
|
421
|
-
var(--glass-sheen, 120% 120%) at
|
|
422
|
-
calc(50% + (-28% * var(--_material-light-cos) + 42% * var(--_material-light-sin)))
|
|
423
|
-
calc(50% + (-28% * var(--_material-light-sin) - 42% * var(--_material-light-cos))),
|
|
421
|
+
var(--glass-sheen, 120% 120%) at var(--_material-sheen-at),
|
|
424
422
|
oklch(1 0 0 / calc(var(--glass-light) * var(--_material-sheen))),
|
|
425
423
|
transparent 58%
|
|
426
424
|
),
|
|
427
425
|
radial-gradient(
|
|
428
|
-
120% 120% at
|
|
429
|
-
calc(50% + (32% * var(--_material-light-sin) + 50% * var(--_material-light-cos))),
|
|
426
|
+
120% 120% at var(--_material-shade-at),
|
|
430
427
|
oklch(0 0 0 / calc(var(--glass-shade) * var(--_material-sheen))),
|
|
431
428
|
transparent 58%
|
|
432
429
|
),
|
|
433
430
|
radial-gradient(
|
|
434
|
-
circle at
|
|
435
|
-
calc(50% - 12% * var(--_material-light-cos)),
|
|
431
|
+
circle at var(--_material-relief-at),
|
|
436
432
|
oklch(1 0 0 / calc(0.07 * var(--_material-face-raised) * var(--_material-relief))),
|
|
437
433
|
transparent 70%
|
|
438
434
|
),
|
|
@@ -671,11 +667,11 @@
|
|
|
671
667
|
animation: none;
|
|
672
668
|
}
|
|
673
669
|
}
|
|
674
|
-
/* Ambient loops under
|
|
675
|
-
|
|
670
|
+
/* Ambient loops under an open modal re-blur its glass every frame (page-cover.ts); each selector ends in a class or attribute, as a trailing * restyles the whole page. */
|
|
671
|
+
[data-page][data-covered] .glass-edge-orbit {
|
|
676
672
|
--_orbit-play: paused;
|
|
677
673
|
}
|
|
678
|
-
|
|
674
|
+
[data-page][data-covered] :is(.animate-spin-slow, .animate-float) {
|
|
679
675
|
animation-play-state: paused;
|
|
680
676
|
}
|
|
681
677
|
|
|
@@ -862,6 +858,25 @@
|
|
|
862
858
|
[data-on][data-selection-highlight][data-landing] {
|
|
863
859
|
visibility: hidden;
|
|
864
860
|
}
|
|
861
|
+
/* Balanced rows (lib/balance-rows.ts): a wrapping row until the column count is known. */
|
|
862
|
+
@layer base {
|
|
863
|
+
[data-balanced-rows] {
|
|
864
|
+
display: flex;
|
|
865
|
+
flex-wrap: wrap;
|
|
866
|
+
}
|
|
867
|
+
[data-balanced-rows][data-balanced] {
|
|
868
|
+
display: grid;
|
|
869
|
+
grid-auto-flow: row;
|
|
870
|
+
grid-template-columns: repeat(var(--balance-columns), minmax(max-content, 1fr));
|
|
871
|
+
}
|
|
872
|
+
[data-balance-content] {
|
|
873
|
+
display: inline-flex;
|
|
874
|
+
width: max-content;
|
|
875
|
+
align-items: center;
|
|
876
|
+
justify-content: center;
|
|
877
|
+
gap: inherit;
|
|
878
|
+
}
|
|
879
|
+
}
|
|
865
880
|
/* Its transparent border is part of the segment the old indicator covered. */
|
|
866
881
|
[data-slot="toggle-group-item"] {
|
|
867
882
|
--selection-inset: -1px;
|
|
@@ -875,6 +890,45 @@
|
|
|
875
890
|
}
|
|
876
891
|
[data-selection-flyer][data-flying] {
|
|
877
892
|
display: block;
|
|
893
|
+
animation-name: selection-glide-a, selection-squash-a;
|
|
894
|
+
animation-duration: var(--duration-slide);
|
|
895
|
+
animation-timing-function: ease-in-out;
|
|
896
|
+
}
|
|
897
|
+
/* A second name per flight restarts the keyframes when a flight redirects mid-air. */
|
|
898
|
+
[data-selection-flyer][data-flying="b"] {
|
|
899
|
+
animation-name: selection-glide-b, selection-squash-b;
|
|
900
|
+
}
|
|
901
|
+
@keyframes selection-glide-a {
|
|
902
|
+
from {
|
|
903
|
+
translate: var(--selection-from);
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
@keyframes selection-glide-b {
|
|
907
|
+
from {
|
|
908
|
+
translate: var(--selection-from);
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
@keyframes selection-squash-a {
|
|
912
|
+
from {
|
|
913
|
+
scale: var(--selection-scale-from);
|
|
914
|
+
}
|
|
915
|
+
50% {
|
|
916
|
+
scale: var(--selection-scale-peak);
|
|
917
|
+
}
|
|
918
|
+
to {
|
|
919
|
+
scale: 1 1;
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
@keyframes selection-squash-b {
|
|
923
|
+
from {
|
|
924
|
+
scale: var(--selection-scale-from);
|
|
925
|
+
}
|
|
926
|
+
50% {
|
|
927
|
+
scale: var(--selection-scale-peak);
|
|
928
|
+
}
|
|
929
|
+
to {
|
|
930
|
+
scale: 1 1;
|
|
931
|
+
}
|
|
878
932
|
}
|
|
879
933
|
|
|
880
934
|
/* Icon: the box a glyph sits in, sized by its width/height attributes. */
|
package/src/styles/theme.css
CHANGED
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
--shadow-xl: var(--shadow-xl);
|
|
64
64
|
--shadow-2xl: var(--shadow-2xl);
|
|
65
65
|
|
|
66
|
-
--animate-collapsible-down: collapsible-down
|
|
67
|
-
--animate-collapsible-up: collapsible-up
|
|
66
|
+
--animate-collapsible-down: collapsible-down var(--duration-expand) ease-out;
|
|
67
|
+
--animate-collapsible-up: collapsible-up var(--duration-expand) ease-out;
|
|
68
68
|
|
|
69
69
|
/* Select "native expand": the panel unfolds out of the trigger edge. Kobalte
|
|
70
70
|
* exposes no data-side, only --kb-select-content-transform-origin (set to the
|
|
@@ -112,13 +112,13 @@
|
|
|
112
112
|
height: 0;
|
|
113
113
|
}
|
|
114
114
|
to {
|
|
115
|
-
height: var(--
|
|
115
|
+
height: var(--collapsible-content-height);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
@keyframes collapsible-up {
|
|
120
120
|
from {
|
|
121
|
-
height: var(--
|
|
121
|
+
height: var(--collapsible-content-height);
|
|
122
122
|
}
|
|
123
123
|
to {
|
|
124
124
|
height: 0;
|
|
@@ -265,6 +265,9 @@
|
|
|
265
265
|
--_material-inset: 0;
|
|
266
266
|
--_material-light-cos: 1;
|
|
267
267
|
--_material-light-sin: 0;
|
|
268
|
+
--_material-sheen-at: 22% 8%;
|
|
269
|
+
--_material-shade-at: 82% 100%;
|
|
270
|
+
--_material-relief-at: 50% 38%;
|
|
268
271
|
--_material-rim-bottom: 0;
|
|
269
272
|
--_material-rim-around: 0;
|
|
270
273
|
--_material-glow-out: 1;
|
|
@@ -334,6 +337,11 @@ html[data-motion="live"] [data-motion-reader] {
|
|
|
334
337
|
--motion-play: running;
|
|
335
338
|
}
|
|
336
339
|
|
|
340
|
+
[data-page][data-covered] [data-motion-reader] {
|
|
341
|
+
--motion-ambient: 0;
|
|
342
|
+
--motion-play: paused;
|
|
343
|
+
}
|
|
344
|
+
|
|
337
345
|
.dark {
|
|
338
346
|
--background: oklch(0.12 0.01 250);
|
|
339
347
|
--foreground: oklch(0.9551 0 0);
|
package/src/tokens/material.ts
CHANGED
|
@@ -220,6 +220,10 @@ const frostTile = (strength: number) =>
|
|
|
220
220
|
);
|
|
221
221
|
|
|
222
222
|
const WASH_SPLIT: Record<WashStyle, number> = { flat: 1, fade: 3, "two-tone": 1 };
|
|
223
|
+
/** A point of the glass face, as percentages, offset by (along, across) the light and turned with it. */
|
|
224
|
+
const lightAt = (cos: number, sin: number, along: number, across: number) =>
|
|
225
|
+
`${round(50 + along * cos + across * sin)}% ${round(50 + along * sin - across * cos)}%`;
|
|
226
|
+
|
|
223
227
|
const RIM: Record<RimPosition, [bottom: number, around: number]> = {
|
|
224
228
|
top: [0, 0],
|
|
225
229
|
"top-bottom": [1, 0],
|
|
@@ -252,6 +256,8 @@ export function resolveMaterial(
|
|
|
252
256
|
const clarity = blurMode === "none" ? Math.max(t.clarity, NO_BLUR_CLARITY_FLOOR) : t.clarity;
|
|
253
257
|
const dim = mode === "dark" ? t.darkScale : 1;
|
|
254
258
|
const turn = ((t.lightFrom - LIGHT_HOME) * Math.PI) / 180;
|
|
259
|
+
const cos = round(Math.cos(turn));
|
|
260
|
+
const sin = round(Math.sin(turn));
|
|
255
261
|
const [rimBottom, rimAround] = RIM[t.rim];
|
|
256
262
|
return {
|
|
257
263
|
"--material-blur": `${blur}px`,
|
|
@@ -269,8 +275,11 @@ export function resolveMaterial(
|
|
|
269
275
|
"--_material-sheen": `${round(t.sheen * dim)}`,
|
|
270
276
|
"--_material-shadow": `${t.shadow}`,
|
|
271
277
|
"--_material-inset": `${round(t.inset * dim)}`,
|
|
272
|
-
"--_material-light-cos": `${
|
|
273
|
-
"--_material-light-sin": `${
|
|
278
|
+
"--_material-light-cos": `${cos}`,
|
|
279
|
+
"--_material-light-sin": `${sin}`,
|
|
280
|
+
"--_material-sheen-at": lightAt(cos, sin, -28, 42),
|
|
281
|
+
"--_material-shade-at": lightAt(cos, sin, 32, -50),
|
|
282
|
+
"--_material-relief-at": lightAt(cos, sin, 0, 12),
|
|
274
283
|
"--_material-rim-bottom": `${rimBottom}`,
|
|
275
284
|
"--_material-rim-around": `${rimAround}`,
|
|
276
285
|
"--_material-glow-out": t.glowAt === "outside" ? "1" : "0",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isSheetMotion: (a: Animation) => boolean;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export async function whenAnimationsSettle(
|
|
2
|
-
el: Element,
|
|
3
|
-
options: { subtree?: boolean; filter?: (animation: Animation) => boolean } = {},
|
|
4
|
-
): Promise<void> {
|
|
5
|
-
// One microtask so styles written in the same tick start their animations first.
|
|
6
|
-
await Promise.resolve();
|
|
7
|
-
if (typeof el.getAnimations !== "function") return;
|
|
8
|
-
const all = el.getAnimations({ subtree: options.subtree ?? false });
|
|
9
|
-
const running = options.filter ? all.filter(options.filter) : all;
|
|
10
|
-
if (running.length === 0) return;
|
|
11
|
-
await Promise.allSettled(running.map((animation) => animation.finished));
|
|
12
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { untrack } from "solid-js";
|
|
2
|
-
|
|
3
|
-
const FOCUSABLE_SELECTOR =
|
|
4
|
-
'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
5
|
-
|
|
6
|
-
export type InitialFocus = "container" | "first" | ((root: HTMLElement) => HTMLElement | null);
|
|
7
|
-
|
|
8
|
-
interface TrapHandle {
|
|
9
|
-
release: () => void;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function trapFocus(root: HTMLElement, initial: InitialFocus = "container"): TrapHandle {
|
|
13
|
-
// Inside a shadow root the document's active element is the root's host; the root knows which node has focus.
|
|
14
|
-
const scope = root.getRootNode() as Document | ShadowRoot;
|
|
15
|
-
const previouslyFocused = (scope.activeElement as HTMLElement | null) ?? null;
|
|
16
|
-
|
|
17
|
-
// focus() runs focus and blur handlers synchronously; a caller's effect must not track their reads.
|
|
18
|
-
untrack(() => {
|
|
19
|
-
const focusTarget: HTMLElement | null =
|
|
20
|
-
initial === "container"
|
|
21
|
-
? root
|
|
22
|
-
: initial === "first"
|
|
23
|
-
? (root.querySelector<HTMLElement>(FOCUSABLE_SELECTOR) ?? root)
|
|
24
|
-
: initial(root);
|
|
25
|
-
focusTarget?.focus({ preventScroll: true });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const onKeyDown = (event: Event) => {
|
|
29
|
-
const e = event as KeyboardEvent;
|
|
30
|
-
if (e.key !== "Tab") return;
|
|
31
|
-
const focusable = Array.from(root.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR)).filter(
|
|
32
|
-
(el) => !el.hasAttribute("disabled") && el.offsetParent !== null,
|
|
33
|
-
);
|
|
34
|
-
if (focusable.length === 0) {
|
|
35
|
-
e.preventDefault();
|
|
36
|
-
root.focus({ preventScroll: true });
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const first = focusable[0];
|
|
40
|
-
const last = focusable[focusable.length - 1];
|
|
41
|
-
const active = scope.activeElement as HTMLElement | null;
|
|
42
|
-
if (e.shiftKey) {
|
|
43
|
-
if (active === first || active === root || !root.contains(active)) {
|
|
44
|
-
e.preventDefault();
|
|
45
|
-
last?.focus({ preventScroll: true });
|
|
46
|
-
}
|
|
47
|
-
} else {
|
|
48
|
-
if (active === last) {
|
|
49
|
-
e.preventDefault();
|
|
50
|
-
first?.focus({ preventScroll: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
scope.addEventListener("keydown", onKeyDown);
|
|
56
|
-
|
|
57
|
-
return {
|
|
58
|
-
release() {
|
|
59
|
-
scope.removeEventListener("keydown", onKeyDown);
|
|
60
|
-
untrack(() => previouslyFocused?.focus?.({ preventScroll: true }));
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
let refcount = 0;
|
|
2
|
-
let savedScrollY = 0;
|
|
3
|
-
let savedBodyStyles: {
|
|
4
|
-
position: string;
|
|
5
|
-
top: string;
|
|
6
|
-
left: string;
|
|
7
|
-
right: string;
|
|
8
|
-
width: string;
|
|
9
|
-
overflow: string;
|
|
10
|
-
} | null = null;
|
|
11
|
-
|
|
12
|
-
function isIOS(): boolean {
|
|
13
|
-
if (typeof navigator === "undefined") return false;
|
|
14
|
-
const ua = navigator.userAgent;
|
|
15
|
-
return /iP(ad|hone|od)/.test(ua) || (ua.includes("Mac") && "ontouchend" in document);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export function acquireScrollLock(): void {
|
|
19
|
-
refcount++;
|
|
20
|
-
if (refcount > 1) return;
|
|
21
|
-
if (typeof document === "undefined") return;
|
|
22
|
-
|
|
23
|
-
document.documentElement.setAttribute("data-page-covered", "");
|
|
24
|
-
const body = document.body;
|
|
25
|
-
savedBodyStyles = {
|
|
26
|
-
position: body.style.position,
|
|
27
|
-
top: body.style.top,
|
|
28
|
-
left: body.style.left,
|
|
29
|
-
right: body.style.right,
|
|
30
|
-
width: body.style.width,
|
|
31
|
-
overflow: body.style.overflow,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
if (isIOS()) {
|
|
35
|
-
savedScrollY = window.scrollY;
|
|
36
|
-
body.style.position = "fixed";
|
|
37
|
-
body.style.top = `-${savedScrollY}px`;
|
|
38
|
-
body.style.left = "0";
|
|
39
|
-
body.style.right = "0";
|
|
40
|
-
body.style.width = "100%";
|
|
41
|
-
} else {
|
|
42
|
-
body.style.overflow = "hidden";
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function releaseScrollLock(): void {
|
|
47
|
-
refcount = Math.max(0, refcount - 1);
|
|
48
|
-
if (refcount > 0) return;
|
|
49
|
-
if (typeof document === "undefined" || !savedBodyStyles) return;
|
|
50
|
-
|
|
51
|
-
document.documentElement.removeAttribute("data-page-covered");
|
|
52
|
-
const body = document.body;
|
|
53
|
-
const wasIOS = body.style.position === "fixed";
|
|
54
|
-
|
|
55
|
-
body.style.position = savedBodyStyles.position;
|
|
56
|
-
body.style.top = savedBodyStyles.top;
|
|
57
|
-
body.style.left = savedBodyStyles.left;
|
|
58
|
-
body.style.right = savedBodyStyles.right;
|
|
59
|
-
body.style.width = savedBodyStyles.width;
|
|
60
|
-
body.style.overflow = savedBodyStyles.overflow;
|
|
61
|
-
savedBodyStyles = null;
|
|
62
|
-
|
|
63
|
-
if (wasIOS) {
|
|
64
|
-
window.scrollTo(0, savedScrollY);
|
|
65
|
-
}
|
|
66
|
-
}
|