@glasshome/ui 1.42.0 → 1.44.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 +8 -5
- package/dist/index.js +2 -2
- package/dist/lib/anchor-placement.d.ts +4 -0
- package/dist/lib/balance-rows.d.ts +10 -4
- package/dist/lib/behavior/anchored.d.ts +16 -3
- package/dist/lib/behavior/button-root.d.ts +7 -0
- package/dist/lib/behavior/collection.d.ts +8 -0
- package/dist/lib/behavior/dismiss.d.ts +6 -4
- package/dist/lib/behavior/focus-scope.d.ts +9 -1
- package/dist/lib/behavior/hide-outside.d.ts +1 -1
- package/dist/lib/behavior/layer-stack.d.ts +3 -2
- package/dist/lib/behavior/menu.d.ts +62 -0
- package/dist/lib/behavior/modal-root.d.ts +2 -0
- package/dist/lib/behavior/range.d.ts +44 -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 +2 -1
- package/dist/lib/overlay-classes.d.ts +1 -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 -45
- 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/avatar.d.ts +8 -4
- package/dist/solid/bottom-sheet/bottom-sheet.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/data-table.d.ts +4 -2
- package/dist/solid/dialog-parts.d.ts +8 -8
- 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 +1 -1
- package/dist/solid/index.js +7752 -13493
- 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 +1 -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 +1 -1
- package/dist/solid/sliding-indicator.d.ts +1 -1
- package/dist/solid/sonner.d.ts +1 -1
- package/dist/solid/toggle.d.ts +11 -3
- package/dist/solid/tooltip.d.ts +22 -22
- package/dist/tokens/index.js +54 -51
- package/dist/{utils-CxAii-e9.js → utils-BbIeGt7o.js} +376 -314
- package/package.json +3 -6
- package/src/lib/anchor-placement.ts +10 -3
- package/src/lib/balance-rows.ts +115 -40
- package/src/lib/behavior/anchored.ts +41 -9
- package/src/lib/behavior/button-root.tsx +103 -0
- package/src/lib/behavior/collection.ts +56 -28
- package/src/lib/behavior/dismiss.ts +61 -21
- package/src/lib/behavior/focus-scope.ts +75 -9
- package/src/lib/behavior/hide-outside.ts +2 -2
- package/src/lib/behavior/layer-stack.ts +33 -8
- package/src/lib/behavior/menu.ts +462 -0
- package/src/lib/behavior/modal-root.tsx +24 -18
- package/src/lib/behavior/polymorphic.tsx +1 -1
- package/src/lib/behavior/presence.ts +1 -1
- package/src/lib/behavior/range.ts +212 -0
- package/src/lib/clipboard.ts +2 -3
- 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 +8 -9
- package/src/lib/overlay-classes.ts +1 -3
- 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 -118
- 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/area-picker.tsx +4 -4
- package/src/solid/avatar.tsx +98 -24
- package/src/solid/bottom-sheet/arbitration.ts +4 -11
- package/src/solid/bottom-sheet/bottom-sheet.tsx +4 -5
- package/src/solid/bottom-sheet/drag-controller.ts +7 -20
- package/src/solid/button.tsx +12 -6
- 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 +285 -94
- package/src/solid/data-table.tsx +48 -22
- package/src/solid/dialog-parts.tsx +39 -17
- package/src/solid/dock.tsx +44 -43
- package/src/solid/dropdown-menu.tsx +252 -115
- package/src/solid/empty.tsx +1 -1
- package/src/solid/entity-selector.tsx +3 -3
- package/src/solid/face-toggle.tsx +43 -18
- package/src/solid/form.tsx +5 -6
- package/src/solid/glyph-tile.tsx +48 -21
- package/src/solid/hover-card.tsx +287 -25
- package/src/solid/icon-picker.tsx +1 -2
- package/src/solid/image-picker.tsx +2 -2
- package/src/solid/index.ts +1 -3
- package/src/solid/input-group.tsx +2 -2
- package/src/solid/item.tsx +1 -1
- package/src/solid/menu-parts.tsx +610 -155
- package/src/solid/option-card.tsx +7 -13
- package/src/solid/picker-row.tsx +5 -1
- package/src/solid/popover.tsx +423 -80
- 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 +1 -1
- 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 +939 -95
- package/src/solid/selection.tsx +165 -74
- package/src/solid/sheet.tsx +1 -1
- package/src/solid/slider.tsx +115 -65
- package/src/solid/sliding-indicator.tsx +4 -16
- package/src/solid/sonner.tsx +1 -1
- package/src/solid/tabs.tsx +12 -6
- package/src/solid/term.tsx +3 -4
- package/src/solid/toggle-group.tsx +34 -101
- package/src/solid/toggle.tsx +43 -9
- package/src/solid/tooltip.tsx +24 -24
- package/src/styles/globals.css +61 -50
- package/src/styles/theme.css +12 -6
- package/src/tokens/material.ts +11 -2
package/src/solid/dock.tsx
CHANGED
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
} from "solid-js";
|
|
16
16
|
import { Polymorphic } from "../lib/behavior/polymorphic.js";
|
|
17
17
|
import { CARD_SURFACE } from "../lib/card-classes.js";
|
|
18
|
-
import { DOCK_SLOT_SHAPE } from "../lib/dock-slot-classes.js";
|
|
18
|
+
import { DOCK_SLOT_RADIUS, DOCK_SLOT_SHAPE } from "../lib/dock-slot-classes.js";
|
|
19
19
|
import {
|
|
20
20
|
DOCK_ARRIVE_MOTION,
|
|
21
21
|
DOCK_EDIT_MOTION,
|
|
@@ -119,7 +119,7 @@ const DockIconButton: Component<DockIconButtonProps> = (props) => {
|
|
|
119
119
|
data-arrived={local.arrived ? "" : undefined}
|
|
120
120
|
{...rest}
|
|
121
121
|
>
|
|
122
|
-
<SelectionHighlight />
|
|
122
|
+
<SelectionHighlight active={local.lit ?? false} />
|
|
123
123
|
<Show when={local.arrived}>
|
|
124
124
|
<span data-slot="dock-item-arrival" aria-hidden="true" class={DOCK_ARRIVE_MOTION} />
|
|
125
125
|
</Show>
|
|
@@ -246,33 +246,31 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
246
246
|
const scrollPos = (el: HTMLElement) => (vertical() ? el.scrollTop : el.scrollLeft);
|
|
247
247
|
const edgeStart = (rect: DOMRect) => (vertical() ? rect.top : rect.left);
|
|
248
248
|
|
|
249
|
-
const gapSize = () => {
|
|
250
|
-
if (!containerRef) return 0;
|
|
251
|
-
const style = getComputedStyle(containerRef);
|
|
252
|
-
return Number.parseFloat(vertical() ? style.rowGap : style.columnGap) || 0;
|
|
253
|
-
};
|
|
254
249
|
const itemSize = () => {
|
|
255
250
|
const rect = containerRef?.querySelector('[data-slot="dock-item"]')?.getBoundingClientRect();
|
|
256
251
|
return (vertical() ? rect?.height : rect?.width) ?? 0;
|
|
257
252
|
};
|
|
258
|
-
|
|
259
|
-
const
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
? [style.paddingTop, style.paddingBottom]
|
|
263
|
-
: [style.paddingLeft, style.paddingRight];
|
|
264
|
-
return (Number.parseFloat(a) || 0) + (Number.parseFloat(b) || 0);
|
|
253
|
+
// Slots sit evenly, so the strip's length gives the gap without a style read.
|
|
254
|
+
const gapSize = (scroll: number, item: number) => {
|
|
255
|
+
const slots = local.items.length + (local.editing && local.onAdd ? 1 : 0);
|
|
256
|
+
return slots > 1 ? Math.max(0, (scroll - slots * item) / (slots - 1)) : 0;
|
|
265
257
|
};
|
|
266
258
|
|
|
259
|
+
let room: ResizeObserverSize | undefined;
|
|
260
|
+
let surfaceSize: { content: ResizeObserverSize; border: ResizeObserverSize } | undefined;
|
|
261
|
+
let companionSize: ResizeObserverSize | undefined;
|
|
262
|
+
const along = (size: ResizeObserverSize | undefined) =>
|
|
263
|
+
(vertical() ? size?.blockSize : size?.inlineSize) ?? 0;
|
|
264
|
+
|
|
267
265
|
// The room the app gave the dock. Never the surface: it shrink-wraps this strip,
|
|
268
266
|
// so measuring it asks the strip how big the strip is.
|
|
269
267
|
const availableSpan = () => {
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
if (!room || !surfaceSize) return 0;
|
|
269
|
+
const chrome = along(surfaceSize.border) - along(surfaceSize.content);
|
|
272
270
|
const lead = leadRef ? (vertical() ? leadRef.offsetHeight : leadRef.offsetWidth) : 0;
|
|
273
271
|
// A side dock's companion stacks along the edge, so the strip gives up its height.
|
|
274
|
-
const companion = vertical() && local.companionOpen ? (
|
|
275
|
-
return
|
|
272
|
+
const companion = vertical() && local.companionOpen ? along(companionSize) : 0;
|
|
273
|
+
return along(room) - chrome - lead - companion;
|
|
276
274
|
};
|
|
277
275
|
|
|
278
276
|
const checkOverflow = () => {
|
|
@@ -281,9 +279,11 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
281
279
|
const other = vertical() ? "width" : "height";
|
|
282
280
|
containerRef.style.removeProperty(other);
|
|
283
281
|
const available = availableSpan();
|
|
284
|
-
const
|
|
282
|
+
const scroll = scrollSize(containerRef);
|
|
283
|
+
const overflowing = available > 0 && scroll > available + 1;
|
|
285
284
|
if (overflowing) {
|
|
286
|
-
const
|
|
285
|
+
const item = itemSize();
|
|
286
|
+
const trimmed = stripWidth(available, item, gapSize(scroll, item));
|
|
287
287
|
if (trimmed > 0) containerRef.style[side] = `${trimmed}px`;
|
|
288
288
|
} else if (containerRef.style[side]) {
|
|
289
289
|
containerRef.style[side] = "";
|
|
@@ -298,9 +298,9 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
298
298
|
const goToPage = (next: number) => {
|
|
299
299
|
if (!containerRef) return;
|
|
300
300
|
const to = pageOffset(next, viewportSpan(), scrollSize(containerRef));
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
301
|
+
// The strip's scroll-smooth class carries the motion.
|
|
302
|
+
if (vertical()) containerRef.scrollTop = to;
|
|
303
|
+
else containerRef.scrollLeft = to;
|
|
304
304
|
};
|
|
305
305
|
|
|
306
306
|
const turnToItem = (index: number) => {
|
|
@@ -360,31 +360,31 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
360
360
|
),
|
|
361
361
|
);
|
|
362
362
|
|
|
363
|
-
// Measured in the next frame's callbacks, which run before it paints: the first
|
|
364
|
-
// dock anyone sees already has its pages, so the dot row never shifts it later.
|
|
365
|
-
onMount(() => {
|
|
366
|
-
let resizeFrame = 0;
|
|
367
|
-
const onResize = () => {
|
|
368
|
-
cancelAnimationFrame(resizeFrame);
|
|
369
|
-
resizeFrame = requestAnimationFrame(checkOverflow);
|
|
370
|
-
};
|
|
371
|
-
window.addEventListener("resize", onResize);
|
|
372
|
-
onCleanup(() => {
|
|
373
|
-
cancelAnimationFrame(resizeFrame);
|
|
374
|
-
window.removeEventListener("resize", onResize);
|
|
375
|
-
});
|
|
376
|
-
});
|
|
377
|
-
|
|
378
|
-
// The companion's own content can change height while open, under a side dock that is the strip's room.
|
|
379
363
|
onMount(() => {
|
|
380
|
-
|
|
364
|
+
const box = containerRef.closest('[data-slot="dock"]');
|
|
365
|
+
if (!box || !surfaceRef) return;
|
|
366
|
+
const surface = surfaceRef;
|
|
381
367
|
let frame = 0;
|
|
382
|
-
const
|
|
383
|
-
|
|
368
|
+
const measured = () =>
|
|
369
|
+
`${along(room)} ${along(surfaceSize?.border) - along(surfaceSize?.content)} ${along(companionSize)}`;
|
|
370
|
+
const observer = new ResizeObserver((entries) => {
|
|
371
|
+
const before = measured();
|
|
372
|
+
for (const entry of entries) {
|
|
373
|
+
const [content] = entry.contentBoxSize;
|
|
374
|
+
const [border] = entry.borderBoxSize;
|
|
375
|
+
if (!content || !border) continue;
|
|
376
|
+
if (entry.target === box) room = content;
|
|
377
|
+
else if (entry.target === surface) surfaceSize = { content, border };
|
|
378
|
+
else companionSize = border;
|
|
379
|
+
}
|
|
380
|
+
if (measured() === before) return;
|
|
381
|
+
// Paging resizes what other observers on the page watch; inside this callback that is a resize loop.
|
|
384
382
|
cancelAnimationFrame(frame);
|
|
385
383
|
frame = requestAnimationFrame(checkOverflow);
|
|
386
384
|
});
|
|
387
|
-
observer.observe(
|
|
385
|
+
observer.observe(box);
|
|
386
|
+
observer.observe(surface, { box: "border-box" });
|
|
387
|
+
if (companionRef) observer.observe(companionRef, { box: "border-box" });
|
|
388
388
|
onCleanup(() => {
|
|
389
389
|
cancelAnimationFrame(frame);
|
|
390
390
|
observer.disconnect();
|
|
@@ -511,6 +511,7 @@ const Dock: Component<DockProps> = (props) => {
|
|
|
511
511
|
>
|
|
512
512
|
<SelectionScope
|
|
513
513
|
marker="lit"
|
|
514
|
+
radius={DOCK_SLOT_RADIUS}
|
|
514
515
|
class={cn("flex items-center gap-0.5 sm:gap-1", vertical() && "flex-col")}
|
|
515
516
|
>
|
|
516
517
|
<Index each={local.items}>
|
|
@@ -1,151 +1,262 @@
|
|
|
1
|
-
import { DropdownMenu as DropdownMenuPrimitive } from "@kobalte/core/dropdown-menu";
|
|
2
|
-
import { usePortalMount } from "./portal-mount.js";
|
|
3
|
-
import { useMenuContext } from "@kobalte/core/menu";
|
|
4
1
|
import {
|
|
5
2
|
type Component,
|
|
6
3
|
type ComponentProps,
|
|
7
4
|
createSignal,
|
|
8
|
-
|
|
5
|
+
createUniqueId,
|
|
6
|
+
type JSX,
|
|
9
7
|
splitProps,
|
|
8
|
+
untrack,
|
|
9
|
+
type ValidComponent,
|
|
10
10
|
} from "solid-js";
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "../lib/shadow-layer.js";
|
|
18
|
-
import { anchorToTriggerTop } from "../lib/overlay-classes.js";
|
|
11
|
+
import type { AnchorLike } from "../lib/behavior/anchored.js";
|
|
12
|
+
import { ButtonRoot, type ButtonRootProps } from "../lib/behavior/button-root.js";
|
|
13
|
+
import { createControllableSignal } from "../lib/behavior/controllable.js";
|
|
14
|
+
import { createMenuButton } from "../lib/behavior/menu.js";
|
|
15
|
+
import { callEventHandler, effect, merge } from "../lib/behavior/solid.js";
|
|
16
|
+
import { MORPH_MOTION, MOTION_EXIT_MS } from "../lib/motion-classes.js";
|
|
19
17
|
import { cn } from "../lib/utils.js";
|
|
20
18
|
import {
|
|
21
|
-
|
|
19
|
+
createMenuLevel,
|
|
20
|
+
type DeprecatedMenuRootProps,
|
|
21
|
+
MenuArrow,
|
|
22
|
+
type MenuCheckboxItemProps,
|
|
22
23
|
MenuCheckboxItemPart,
|
|
23
|
-
|
|
24
|
+
MenuContentPart,
|
|
25
|
+
type MenuContentProps,
|
|
26
|
+
MenuGroup,
|
|
27
|
+
MenuItemIndicator,
|
|
28
|
+
type MenuItemProps,
|
|
24
29
|
MenuItemPart,
|
|
30
|
+
type MenuLabelProps,
|
|
25
31
|
MenuLabelPart,
|
|
32
|
+
MenuLevelProvider,
|
|
33
|
+
type MenuPlacement,
|
|
34
|
+
MenuPortal,
|
|
35
|
+
MenuRadioGroup,
|
|
36
|
+
type MenuRadioItemProps,
|
|
26
37
|
MenuRadioItemPart,
|
|
27
38
|
MenuSeparatorPart,
|
|
39
|
+
MenuSub,
|
|
28
40
|
MenuSubContentPart,
|
|
41
|
+
type MenuSubTriggerProps,
|
|
29
42
|
MenuSubTriggerPart,
|
|
43
|
+
MenuTextPart,
|
|
44
|
+
parsePlacement,
|
|
45
|
+
useMenuLevel,
|
|
30
46
|
} from "./menu-parts.js";
|
|
47
|
+
import { controlRadius } from "../lib/anchor-placement.js";
|
|
31
48
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
49
|
+
type AnchorRect = { x?: number; y?: number; width?: number; height?: number };
|
|
50
|
+
|
|
51
|
+
interface DropdownMenuRootProps extends DeprecatedMenuRootProps {
|
|
52
|
+
open?: boolean;
|
|
53
|
+
defaultOpen?: boolean;
|
|
54
|
+
onOpenChange?: (open: boolean) => void;
|
|
55
|
+
placement?: MenuPlacement;
|
|
56
|
+
gutter?: number;
|
|
57
|
+
/** The box the panel sits beside, read from the trigger; unset, the panel covers the trigger. */
|
|
58
|
+
getAnchorRect?: (anchor?: HTMLElement) => AnchorRect | undefined;
|
|
59
|
+
children?: JSX.Element;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function rectOf(trigger: HTMLElement, read: (el?: HTMLElement) => AnchorRect | undefined) {
|
|
63
|
+
const anchor: AnchorLike = {
|
|
64
|
+
getBoundingClientRect: () => {
|
|
65
|
+
const rect = read(trigger) ?? {};
|
|
66
|
+
return {
|
|
67
|
+
left: rect.x ?? 0,
|
|
68
|
+
top: rect.y ?? 0,
|
|
69
|
+
width: rect.width ?? 0,
|
|
70
|
+
height: rect.height ?? 0,
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
getRootNode: () => trigger.getRootNode(),
|
|
74
|
+
};
|
|
75
|
+
return anchor;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const DropdownMenuRoot: Component<DropdownMenuRootProps> = (props) => {
|
|
79
|
+
const [open, setOpen] = createControllableSignal<boolean>({
|
|
80
|
+
value: () => props.open,
|
|
81
|
+
defaultValue: () => props.defaultOpen ?? false,
|
|
82
|
+
onChange: (next) => props.onOpenChange?.(next),
|
|
83
|
+
});
|
|
84
|
+
const placement = () => parsePlacement(props.placement ?? "bottom-start");
|
|
85
|
+
const level = createMenuLevel({
|
|
86
|
+
open,
|
|
87
|
+
onOpenChange: setOpen,
|
|
88
|
+
anchor: (trigger) => {
|
|
89
|
+
const read = props.getAnchorRect;
|
|
90
|
+
return read && trigger ? rectOf(trigger, read) : trigger;
|
|
91
|
+
},
|
|
92
|
+
coverAnchor: !props.getAnchorRect,
|
|
93
|
+
side: () => placement()[0],
|
|
94
|
+
align: () => placement()[1],
|
|
95
|
+
offset: untrack(() => props.gutter ?? 0),
|
|
96
|
+
});
|
|
97
|
+
return <MenuLevelProvider value={level}>{props.children}</MenuLevelProvider>;
|
|
48
98
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const DropdownMenuTrigger: Component<ComponentProps<typeof DropdownMenuPrimitive.Trigger>> = (
|
|
58
|
-
props,
|
|
59
|
-
) => {
|
|
60
|
-
return <DropdownMenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />;
|
|
99
|
+
|
|
100
|
+
type TriggerHandlers = {
|
|
101
|
+
id?: string;
|
|
102
|
+
ref?: unknown;
|
|
103
|
+
onPointerDown?: JSX.EventHandlerUnion<HTMLElement, PointerEvent>;
|
|
104
|
+
onKeyDown?: JSX.EventHandlerUnion<HTMLElement, KeyboardEvent>;
|
|
105
|
+
onClick?: JSX.EventHandlerUnion<HTMLElement, MouseEvent>;
|
|
61
106
|
};
|
|
62
107
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
108
|
+
type Bound<E extends Event> = E & { currentTarget: HTMLElement; target: Element };
|
|
109
|
+
|
|
110
|
+
function DropdownMenuTrigger<T extends ValidComponent = "button">(
|
|
111
|
+
props: ButtonRootProps<T>,
|
|
112
|
+
): JSX.Element {
|
|
113
|
+
const level = useMenuLevel();
|
|
114
|
+
const menu = level.menu;
|
|
115
|
+
const [local, rest] = splitProps(props as ButtonRootProps<ValidComponent> & TriggerHandlers, [
|
|
116
|
+
"id",
|
|
69
117
|
"ref",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
118
|
+
"disabled",
|
|
119
|
+
"onPointerDown",
|
|
120
|
+
"onKeyDown",
|
|
121
|
+
"onClick",
|
|
72
122
|
]);
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
dismiss: () => menu.close(true),
|
|
79
|
-
trigger: () => menu.triggerRef(),
|
|
80
|
-
tree: true,
|
|
81
|
-
consumer: local,
|
|
123
|
+
const fallback = createUniqueId();
|
|
124
|
+
const id = (): string => local.id ?? fallback;
|
|
125
|
+
effect(id, (value) => {
|
|
126
|
+
level.setTriggerId(value);
|
|
127
|
+
return () => level.setTriggerId(undefined);
|
|
82
128
|
});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
)
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
129
|
+
const button = createMenuButton(menu, () => local.disabled ?? false);
|
|
130
|
+
const [el, setEl] = createSignal<HTMLElement>();
|
|
131
|
+
|
|
132
|
+
// Bound on the element, since Solid's delegated handlers never reach inside a closed shadow root.
|
|
133
|
+
effect(el, (node) => {
|
|
134
|
+
if (!node) return;
|
|
135
|
+
const down = (event: PointerEvent) => {
|
|
136
|
+
callEventHandler(event as Bound<PointerEvent>, local.onPointerDown);
|
|
137
|
+
button.onPointerDown(event);
|
|
138
|
+
};
|
|
139
|
+
const key = (event: KeyboardEvent) => {
|
|
140
|
+
callEventHandler(event as Bound<KeyboardEvent>, local.onKeyDown);
|
|
141
|
+
button.onKeyDown(event);
|
|
142
|
+
};
|
|
143
|
+
node.addEventListener("pointerdown", down);
|
|
144
|
+
node.addEventListener("keydown", key);
|
|
145
|
+
return () => {
|
|
146
|
+
node.removeEventListener("pointerdown", down);
|
|
147
|
+
node.removeEventListener("keydown", key);
|
|
148
|
+
if (untrack(menu.trigger) === node) menu.setTrigger(undefined);
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<ButtonRoot
|
|
154
|
+
{...merge({ "data-slot": "dropdown-menu-trigger" }, rest, {
|
|
155
|
+
get disabled() {
|
|
156
|
+
return local.disabled;
|
|
157
|
+
},
|
|
158
|
+
get id() {
|
|
159
|
+
return id();
|
|
160
|
+
},
|
|
161
|
+
ref: (node: HTMLElement) => {
|
|
162
|
+
setEl(node);
|
|
163
|
+
menu.setTrigger(node);
|
|
164
|
+
if (typeof local.ref === "function") local.ref(node);
|
|
165
|
+
},
|
|
166
|
+
"aria-haspopup": "true",
|
|
167
|
+
get "aria-expanded"() {
|
|
168
|
+
return menu.open();
|
|
169
|
+
},
|
|
170
|
+
get "aria-controls"() {
|
|
171
|
+
return menu.open() ? level.contentId() : undefined;
|
|
172
|
+
},
|
|
173
|
+
get "data-expanded"() {
|
|
174
|
+
return menu.open() ? "" : undefined;
|
|
175
|
+
},
|
|
176
|
+
get "data-closed"() {
|
|
177
|
+
return menu.open() ? undefined : "";
|
|
178
|
+
},
|
|
179
|
+
onClick: (event: Bound<MouseEvent>) => {
|
|
180
|
+
callEventHandler(event, local.onClick);
|
|
181
|
+
button.onClick();
|
|
182
|
+
},
|
|
183
|
+
})}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* The panel opens as its trigger's box. */
|
|
189
|
+
function writeMorphStart(trigger: HTMLElement | undefined, el: HTMLElement) {
|
|
190
|
+
if (!trigger) return;
|
|
191
|
+
const box = trigger.getBoundingClientRect();
|
|
192
|
+
el.style.setProperty("--kb-popper-anchor-width", `${box.width}px`);
|
|
193
|
+
el.style.setProperty("--morph-h", `${box.height}px`);
|
|
194
|
+
el.style.setProperty("--morph-radius", controlRadius(box.height));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const DropdownMenuContent: Component<MenuContentProps> = (props) => {
|
|
198
|
+
const level = useMenuLevel();
|
|
97
199
|
return (
|
|
98
|
-
<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
onInteractOutside={layer.onInteractOutside}
|
|
106
|
-
onCloseAutoFocus={layer.onCloseAutoFocus}
|
|
107
|
-
data-slot="dropdown-menu-content"
|
|
108
|
-
class={cn(MENU_CONTENT_CLASS, MORPH_MOTION, local.class)}
|
|
109
|
-
{...others}
|
|
110
|
-
>
|
|
111
|
-
<MenuContentIndicator>{local.children}</MenuContentIndicator>
|
|
112
|
-
</DropdownMenuPrimitive.Content>
|
|
113
|
-
</DropdownMenuPrimitive.Portal>
|
|
200
|
+
<MenuContentPart
|
|
201
|
+
slotName="dropdown-menu-content"
|
|
202
|
+
motionClass={MORPH_MOTION}
|
|
203
|
+
exitMs={MOTION_EXIT_MS.anchored}
|
|
204
|
+
onPanel={(el) => writeMorphStart(untrack(level.menu.trigger), el)}
|
|
205
|
+
{...props}
|
|
206
|
+
/>
|
|
114
207
|
);
|
|
115
208
|
};
|
|
116
209
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
variant?: "default" | "destructive";
|
|
123
|
-
}
|
|
124
|
-
> = (props) => <MenuItemPart slotName="dropdown-menu-item" {...props} />;
|
|
210
|
+
function DropdownMenuItem<T extends ValidComponent = "div">(props: MenuItemProps<T>): JSX.Element {
|
|
211
|
+
return (
|
|
212
|
+
<MenuItemPart slotName="dropdown-menu-item" {...(props as MenuItemProps<ValidComponent>)} />
|
|
213
|
+
);
|
|
214
|
+
}
|
|
125
215
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
216
|
+
function DropdownMenuSubTrigger<T extends ValidComponent = "div">(
|
|
217
|
+
props: MenuSubTriggerProps<T>,
|
|
218
|
+
): JSX.Element {
|
|
219
|
+
return (
|
|
220
|
+
<MenuSubTriggerPart
|
|
221
|
+
slotName="dropdown-menu-sub-trigger"
|
|
222
|
+
{...(props as MenuSubTriggerProps<ValidComponent>)}
|
|
223
|
+
/>
|
|
224
|
+
);
|
|
225
|
+
}
|
|
129
226
|
|
|
130
|
-
const DropdownMenuSubContent:
|
|
131
|
-
|
|
132
|
-
|
|
227
|
+
const DropdownMenuSubContent: Component<MenuContentProps> = (props) => (
|
|
228
|
+
<MenuSubContentPart slotName="dropdown-menu-sub-content" {...props} />
|
|
229
|
+
);
|
|
133
230
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
231
|
+
function DropdownMenuCheckboxItem<T extends ValidComponent = "div">(
|
|
232
|
+
props: MenuCheckboxItemProps<T>,
|
|
233
|
+
): JSX.Element {
|
|
234
|
+
return (
|
|
235
|
+
<MenuCheckboxItemPart
|
|
236
|
+
slotName="dropdown-menu-checkbox-item"
|
|
237
|
+
{...(props as MenuCheckboxItemProps<ValidComponent>)}
|
|
238
|
+
/>
|
|
239
|
+
);
|
|
240
|
+
}
|
|
137
241
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
242
|
+
function DropdownMenuRadioItem<T extends ValidComponent = "div">(
|
|
243
|
+
props: MenuRadioItemProps<T>,
|
|
244
|
+
): JSX.Element {
|
|
245
|
+
return (
|
|
246
|
+
<MenuRadioItemPart
|
|
247
|
+
slotName="dropdown-menu-radio-item"
|
|
248
|
+
{...(props as MenuRadioItemProps<ValidComponent>)}
|
|
249
|
+
/>
|
|
250
|
+
);
|
|
251
|
+
}
|
|
141
252
|
|
|
142
|
-
const DropdownMenuSeparator: Component<ComponentProps<
|
|
143
|
-
props
|
|
144
|
-
)
|
|
253
|
+
const DropdownMenuSeparator: Component<ComponentProps<"hr">> = (props) => (
|
|
254
|
+
<MenuSeparatorPart slotName="dropdown-menu-separator" {...props} />
|
|
255
|
+
);
|
|
145
256
|
|
|
146
|
-
const DropdownMenuLabel: Component<
|
|
147
|
-
|
|
148
|
-
|
|
257
|
+
const DropdownMenuLabel: Component<MenuLabelProps> = (props) => (
|
|
258
|
+
<MenuLabelPart slotName="dropdown-menu-label" {...props} />
|
|
259
|
+
);
|
|
149
260
|
|
|
150
261
|
const DropdownMenuShortcut: Component<ComponentProps<"span">> = (props) => {
|
|
151
262
|
const [local, others] = splitProps(props, ["class"]);
|
|
@@ -158,6 +269,32 @@ const DropdownMenuShortcut: Component<ComponentProps<"span">> = (props) => {
|
|
|
158
269
|
);
|
|
159
270
|
};
|
|
160
271
|
|
|
272
|
+
const DropdownMenuGroup = MenuGroup;
|
|
273
|
+
const DropdownMenuSub = MenuSub;
|
|
274
|
+
const DropdownMenuRadioGroup = MenuRadioGroup;
|
|
275
|
+
|
|
276
|
+
const DropdownMenu = Object.assign(DropdownMenuRoot, {
|
|
277
|
+
Root: DropdownMenuRoot,
|
|
278
|
+
Trigger: DropdownMenuTrigger,
|
|
279
|
+
Portal: MenuPortal,
|
|
280
|
+
Content: DropdownMenuContent,
|
|
281
|
+
Arrow: MenuArrow,
|
|
282
|
+
Item: DropdownMenuItem,
|
|
283
|
+
CheckboxItem: DropdownMenuCheckboxItem,
|
|
284
|
+
RadioGroup: DropdownMenuRadioGroup,
|
|
285
|
+
RadioItem: DropdownMenuRadioItem,
|
|
286
|
+
Group: DropdownMenuGroup,
|
|
287
|
+
GroupLabel: DropdownMenuLabel,
|
|
288
|
+
Separator: DropdownMenuSeparator,
|
|
289
|
+
Sub: DropdownMenuSub,
|
|
290
|
+
SubTrigger: DropdownMenuSubTrigger,
|
|
291
|
+
SubContent: DropdownMenuSubContent,
|
|
292
|
+
ItemIndicator: MenuItemIndicator,
|
|
293
|
+
Icon: MenuTextPart,
|
|
294
|
+
ItemLabel: MenuTextPart,
|
|
295
|
+
ItemDescription: MenuTextPart,
|
|
296
|
+
});
|
|
297
|
+
|
|
161
298
|
export {
|
|
162
299
|
DropdownMenu,
|
|
163
300
|
DropdownMenuCheckboxItem,
|
package/src/solid/empty.tsx
CHANGED
|
@@ -36,7 +36,7 @@ const EMPTY_MEDIA: Record<EmptyMediaKind, string> = {
|
|
|
36
36
|
const EmptyMedia: Component<
|
|
37
37
|
ComponentProps<"div"> & {
|
|
38
38
|
media?: EmptyMediaKind;
|
|
39
|
-
/** @deprecated `media
|
|
39
|
+
/** @deprecated `media`; removed in 2.0.0. */
|
|
40
40
|
variant?: EmptyMediaKind | "default";
|
|
41
41
|
}
|
|
42
42
|
> = (props) => {
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
Show,
|
|
11
11
|
} from "solid-js";
|
|
12
12
|
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
13
|
-
import { MENU_LABEL } from "../lib/menu-classes.js";
|
|
13
|
+
import { MENU_ITEM_RADIUS, MENU_LABEL } from "../lib/menu-classes.js";
|
|
14
14
|
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
15
15
|
import { createIsMobile } from "../lib/use-is-mobile.js";
|
|
16
16
|
import { cn } from "../lib/utils.js";
|
|
@@ -431,7 +431,7 @@ export function EntitySelector(props: EntitySelectorProps) {
|
|
|
431
431
|
id={optionId(p.entityIndex)}
|
|
432
432
|
data-slot="entity-selector-row"
|
|
433
433
|
aria-selected={selected()}
|
|
434
|
-
|
|
434
|
+
highlighted={!isMobile() && activeIndex() === p.entityIndex}
|
|
435
435
|
class="absolute inset-x-0"
|
|
436
436
|
style={{ top: `${p.top}px`, height: `${ROW_HEIGHT}px` }}
|
|
437
437
|
icon={view()?.icon ?? FALLBACK_ICON}
|
|
@@ -473,7 +473,6 @@ export function EntitySelector(props: EntitySelectorProps) {
|
|
|
473
473
|
role="listbox"
|
|
474
474
|
aria-multiselectable={!isSingle()}
|
|
475
475
|
aria-label={`${props.domain} entities`}
|
|
476
|
-
data-sheet-scroll=""
|
|
477
476
|
class={cn(
|
|
478
477
|
"min-h-0 flex-1 touch-pan-y overscroll-contain px-1 py-1",
|
|
479
478
|
PICKER_LIST,
|
|
@@ -532,6 +531,7 @@ export function EntitySelector(props: EntitySelectorProps) {
|
|
|
532
531
|
>
|
|
533
532
|
<SelectionScope
|
|
534
533
|
marker="highlighted"
|
|
534
|
+
radius={MENU_ITEM_RADIUS}
|
|
535
535
|
role="presentation"
|
|
536
536
|
style={{ height: `${totalHeight()}px` }}
|
|
537
537
|
>
|