@glasshome/ui 1.42.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/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 -2
- 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 +7 -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 +59 -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 +1 -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/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 +7725 -13458
- 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-3Codx-NZ.js} +527 -489
- 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 +26 -8
- package/src/lib/behavior/button-root.tsx +103 -0
- package/src/lib/behavior/collection.ts +66 -29
- package/src/lib/behavior/dismiss.ts +61 -21
- package/src/lib/behavior/focus-scope.ts +31 -6
- package/src/lib/behavior/hide-outside.ts +2 -2
- package/src/lib/behavior/layer-stack.ts +33 -8
- package/src/lib/behavior/menu.ts +470 -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 +7 -7
- 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 +3 -2
- package/src/solid/avatar.tsx +98 -24
- package/src/solid/bottom-sheet/bottom-sheet.tsx +1 -1
- 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/dialog-parts.tsx +9 -9
- package/src/solid/dock.tsx +3 -2
- package/src/solid/dropdown-menu.tsx +252 -115
- package/src/solid/empty.tsx +1 -1
- package/src/solid/entity-selector.tsx +3 -2
- 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/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 +619 -145
- package/src/solid/option-card.tsx +6 -10
- package/src/solid/picker-row.tsx +5 -1
- package/src/solid/popover.tsx +424 -79
- 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 +950 -95
- package/src/solid/selection.tsx +142 -66
- package/src/solid/sheet.tsx +1 -1
- 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/tabs.tsx +12 -6
- package/src/solid/term.tsx +3 -4
- package/src/solid/toggle-group.tsx +29 -99
- package/src/solid/toggle.tsx +43 -9
- package/src/solid/tooltip.tsx +24 -24
- package/src/styles/globals.css +61 -7
- package/src/styles/theme.css +7 -4
- package/src/tokens/material.ts +11 -2
package/src/solid/glyph-tile.tsx
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
createSignal,
|
|
4
|
+
type JSX,
|
|
5
|
+
onCleanup,
|
|
6
|
+
onMount,
|
|
7
|
+
Show,
|
|
8
|
+
useContext,
|
|
9
|
+
} from "solid-js";
|
|
3
10
|
import { FIELD_CHROME } from "../lib/input-classes.js";
|
|
4
11
|
import { SCROLL_TRACK_FADE, trackScroll } from "../lib/scroll-track.js";
|
|
12
|
+
import { createToggleItem, createToggleSet, type ToggleSet } from "../lib/toggle-set.js";
|
|
5
13
|
import { cn } from "../lib/utils.js";
|
|
6
14
|
import { Icon } from "./icon.js";
|
|
7
15
|
|
|
16
|
+
const GlyphContext = createContext<ToggleSet>();
|
|
17
|
+
|
|
8
18
|
/** Tiles that scroll sideways below `sm` and wrap from `sm` up. Tapping the picked tile again clears the pick. */
|
|
9
19
|
export function GlyphTileGroup(props: {
|
|
10
20
|
value: string | null;
|
|
@@ -13,24 +23,36 @@ export function GlyphTileGroup(props: {
|
|
|
13
23
|
class?: string;
|
|
14
24
|
children: JSX.Element;
|
|
15
25
|
}) {
|
|
16
|
-
|
|
26
|
+
const [root, setRoot] = createSignal<HTMLDivElement>();
|
|
27
|
+
const set = createToggleSet({
|
|
28
|
+
root,
|
|
29
|
+
itemSelector: '[data-slot="glyph-tile"][data-key]',
|
|
30
|
+
values: () => (props.value === null ? [] : [props.value]),
|
|
31
|
+
setValues: (next) => props.onChange(next[0] ?? null),
|
|
32
|
+
multiple: () => false,
|
|
33
|
+
});
|
|
17
34
|
onMount(() => {
|
|
18
|
-
|
|
35
|
+
const group = root();
|
|
36
|
+
if (group) onCleanup(trackScroll(group, "[data-pressed]", () => props.value));
|
|
19
37
|
});
|
|
20
38
|
return (
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
39
|
+
<GlyphContext.Provider value={set}>
|
|
40
|
+
<div
|
|
41
|
+
ref={setRoot}
|
|
42
|
+
role="group"
|
|
43
|
+
id={set.id()}
|
|
44
|
+
data-orientation={set.orientation()}
|
|
45
|
+
data-slot="glyph-tile-group"
|
|
46
|
+
aria-label={props["aria-label"]}
|
|
47
|
+
class={cn(
|
|
48
|
+
`flex snap-x snap-proximity [scrollbar-width:none] gap-2 overflow-x-auto overscroll-x-contain py-0.5 [&::-webkit-scrollbar]:hidden ${SCROLL_TRACK_FADE} sm:flex-wrap sm:overflow-visible`,
|
|
49
|
+
props.class,
|
|
50
|
+
)}
|
|
51
|
+
on:keydown={(event) => set.collection.onKeyDown(event)}
|
|
52
|
+
>
|
|
53
|
+
{props.children}
|
|
54
|
+
</div>
|
|
55
|
+
</GlyphContext.Provider>
|
|
34
56
|
);
|
|
35
57
|
}
|
|
36
58
|
|
|
@@ -43,13 +65,18 @@ export function GlyphTile(props: {
|
|
|
43
65
|
badge?: string;
|
|
44
66
|
class?: string;
|
|
45
67
|
}) {
|
|
68
|
+
const set = useContext(GlyphContext);
|
|
69
|
+
if (!set) throw new Error("GlyphTile renders inside a GlyphTileGroup");
|
|
70
|
+
const item = createToggleItem(set, { value: () => props.value, disabled: () => false });
|
|
46
71
|
return (
|
|
47
|
-
<
|
|
48
|
-
|
|
72
|
+
<button
|
|
73
|
+
ref={item.ref}
|
|
74
|
+
type="button"
|
|
75
|
+
{...item.props}
|
|
49
76
|
data-slot="glyph-tile"
|
|
50
77
|
class={cn(
|
|
51
78
|
FIELD_CHROME,
|
|
52
|
-
"transition-glass group/glyph-tile focus-visible:ring-ring/50 relative flex h-17 w-22 shrink-0 touch-manipulation snap-start flex-col items-center justify-center gap-1.5 rounded-2xl px-1 text-xs font-medium duration-
|
|
79
|
+
"transition-glass group/glyph-tile focus-visible:ring-ring/50 relative flex h-17 w-22 shrink-0 touch-manipulation snap-start flex-col items-center justify-center gap-1.5 rounded-2xl px-1 text-xs font-medium duration-(--duration-expand) outline-none focus-visible:ring-[3px] active:scale-[0.97] data-[pressed]:[--glass-base:color-mix(in_oklab,var(--primary)_16%,var(--input))] data-[pressed]:[--glass-edge:var(--primary)]",
|
|
53
80
|
props.class,
|
|
54
81
|
)}
|
|
55
82
|
>
|
|
@@ -72,6 +99,6 @@ export function GlyphTile(props: {
|
|
|
72
99
|
</span>
|
|
73
100
|
)}
|
|
74
101
|
</Show>
|
|
75
|
-
</
|
|
102
|
+
</button>
|
|
76
103
|
);
|
|
77
104
|
}
|
package/src/solid/hover-card.tsx
CHANGED
|
@@ -1,41 +1,303 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import {
|
|
2
|
+
type Accessor,
|
|
3
|
+
type Component,
|
|
4
|
+
type ComponentProps,
|
|
5
|
+
createContext,
|
|
6
|
+
createSignal,
|
|
7
|
+
type JSX,
|
|
8
|
+
onCleanup,
|
|
9
|
+
Show,
|
|
10
|
+
splitProps,
|
|
11
|
+
untrack,
|
|
12
|
+
useContext,
|
|
13
|
+
type ValidComponent,
|
|
14
|
+
} from "solid-js";
|
|
15
|
+
import { Portal } from "solid-js/web";
|
|
16
|
+
import type { Align, Side } from "../lib/anchor-placement.js";
|
|
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 { MOTION_EXIT_MS, OVERLAY_MOTION } from "../lib/motion-classes.js";
|
|
6
25
|
import { FLOATING_PANEL } from "../lib/overlay-classes.js";
|
|
7
26
|
import { cn } from "../lib/utils.js";
|
|
27
|
+
import { usePortalMount } from "./portal-mount.js";
|
|
28
|
+
|
|
29
|
+
type Placement = Side | `${Side}-${Exclude<Align, "center">}`;
|
|
30
|
+
|
|
31
|
+
interface HoverCardProps {
|
|
32
|
+
open?: boolean;
|
|
33
|
+
defaultOpen?: boolean;
|
|
34
|
+
onOpenChange?: (open: boolean) => void;
|
|
35
|
+
openDelay?: number;
|
|
36
|
+
closeDelay?: number;
|
|
37
|
+
placement?: Placement;
|
|
38
|
+
gutter?: number;
|
|
39
|
+
children?: JSX.Element;
|
|
40
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
41
|
+
id?: string;
|
|
42
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
43
|
+
ignoreSafeArea?: boolean;
|
|
44
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
45
|
+
forceMount?: boolean;
|
|
46
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
47
|
+
getAnchorRect?: (anchor?: HTMLElement) => unknown;
|
|
48
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
49
|
+
shift?: number;
|
|
50
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
51
|
+
flip?: boolean | string;
|
|
52
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
53
|
+
slide?: boolean;
|
|
54
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
55
|
+
overlap?: boolean;
|
|
56
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
57
|
+
sameWidth?: boolean;
|
|
58
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
59
|
+
fitViewport?: boolean;
|
|
60
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
61
|
+
hideWhenDetached?: boolean;
|
|
62
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
63
|
+
detachedPadding?: number;
|
|
64
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
65
|
+
arrowPadding?: number;
|
|
66
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
67
|
+
overflowPadding?: number;
|
|
68
|
+
}
|
|
8
69
|
|
|
9
|
-
|
|
70
|
+
interface HoverCardContextValue {
|
|
71
|
+
open: Accessor<boolean>;
|
|
72
|
+
trigger: Accessor<HTMLElement | undefined>;
|
|
73
|
+
setTrigger: (el: HTMLElement | undefined) => void;
|
|
74
|
+
card: Accessor<HTMLElement | undefined>;
|
|
75
|
+
setCard: (el: HTMLElement | undefined) => void;
|
|
76
|
+
side: Accessor<Side>;
|
|
77
|
+
align: Accessor<Align>;
|
|
78
|
+
gutter: number;
|
|
79
|
+
show: () => void;
|
|
80
|
+
hide: (delayed: boolean) => void;
|
|
81
|
+
hold: () => void;
|
|
82
|
+
}
|
|
10
83
|
|
|
11
|
-
const
|
|
12
|
-
|
|
84
|
+
const HoverCardContext = createContext<HoverCardContextValue | null>(null);
|
|
85
|
+
|
|
86
|
+
const useHoverCard = (): HoverCardContextValue => {
|
|
87
|
+
const ctx = useContext(HoverCardContext);
|
|
88
|
+
if (!ctx) throw new Error("HoverCard parts render inside a HoverCard");
|
|
89
|
+
return ctx;
|
|
13
90
|
};
|
|
14
91
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
92
|
+
const OPEN_DELAY_MS = 700;
|
|
93
|
+
const CLOSE_DELAY_MS = 300;
|
|
94
|
+
|
|
95
|
+
const ORIGIN_BY_SIDE =
|
|
96
|
+
"data-[side=bottom]:origin-top data-[side=top]:origin-bottom data-[side=left]:origin-right data-[side=right]:origin-left";
|
|
97
|
+
|
|
98
|
+
const HoverCardRoot: Component<HoverCardProps> = (props) => {
|
|
99
|
+
const [open, setOpen] = createControllableSignal<boolean>({
|
|
100
|
+
value: () => props.open,
|
|
101
|
+
defaultValue: () => props.defaultOpen ?? false,
|
|
102
|
+
onChange: (next) => props.onOpenChange?.(next),
|
|
103
|
+
});
|
|
104
|
+
const [trigger, setTrigger] = createSignal<HTMLElement>();
|
|
105
|
+
const [card, setCard] = createSignal<HTMLElement>();
|
|
106
|
+
const placement = () => (props.placement ?? "bottom").split("-") as [Side, Align?];
|
|
107
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
108
|
+
const hold = () => clearTimeout(timer);
|
|
109
|
+
const schedule = (next: boolean, delay: number) => {
|
|
110
|
+
hold();
|
|
111
|
+
if (delay <= 0) setOpen(next);
|
|
112
|
+
else timer = setTimeout(() => setOpen(next), delay);
|
|
113
|
+
};
|
|
114
|
+
onCleanup(hold);
|
|
115
|
+
|
|
116
|
+
const value: HoverCardContextValue = {
|
|
117
|
+
open,
|
|
118
|
+
trigger,
|
|
119
|
+
setTrigger: (el) => setTrigger(el),
|
|
120
|
+
card,
|
|
121
|
+
setCard: (el) => setCard(el),
|
|
122
|
+
side: () => placement()[0],
|
|
123
|
+
align: () => placement()[1] ?? "center",
|
|
124
|
+
gutter: untrack(() => props.gutter ?? 0),
|
|
125
|
+
show: () => {
|
|
126
|
+
if (untrack(open)) hold();
|
|
127
|
+
else schedule(true, props.openDelay ?? OPEN_DELAY_MS);
|
|
128
|
+
},
|
|
129
|
+
hide: (delayed) => schedule(false, delayed ? (props.closeDelay ?? CLOSE_DELAY_MS) : 0),
|
|
130
|
+
hold,
|
|
131
|
+
};
|
|
132
|
+
return <HoverCardContext.Provider value={value}>{props.children}</HoverCardContext.Provider>;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
type HoverCardTriggerProps<T extends ValidComponent> = { as?: T } & Omit<ComponentProps<T>, "as">;
|
|
136
|
+
|
|
137
|
+
function HoverCardTrigger<T extends ValidComponent = "a">(
|
|
138
|
+
props: HoverCardTriggerProps<T>,
|
|
139
|
+
): JSX.Element {
|
|
140
|
+
const ctx = useHoverCard();
|
|
141
|
+
const [local, rest] = splitProps(props as HoverCardTriggerProps<ValidComponent>, ["as", "ref"]);
|
|
142
|
+
const [own, setOwn] = createSignal<HTMLElement>();
|
|
143
|
+
const nativeLink = () => local.as === undefined || local.as === "a";
|
|
144
|
+
|
|
145
|
+
onCleanup(() => {
|
|
146
|
+
if (untrack(ctx.trigger) === untrack(own)) ctx.setTrigger(undefined);
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
effect(own, (el) => {
|
|
150
|
+
if (!el) return;
|
|
151
|
+
let touched = false;
|
|
152
|
+
const mouseLike = (e: PointerEvent) => e.pointerType !== "touch";
|
|
153
|
+
const enter = (e: PointerEvent) => mouseLike(e) && ctx.show();
|
|
154
|
+
const leave = (e: PointerEvent) => mouseLike(e) && ctx.hide(true);
|
|
155
|
+
const down = (e: PointerEvent) => {
|
|
156
|
+
touched = !mouseLike(e);
|
|
157
|
+
};
|
|
158
|
+
const focus = () => {
|
|
159
|
+
if (!touched) ctx.show();
|
|
160
|
+
};
|
|
161
|
+
const blur = (e: FocusEvent) => {
|
|
162
|
+
touched = false;
|
|
163
|
+
const next = e.relatedTarget;
|
|
164
|
+
if (next instanceof Node && untrack(ctx.card)?.contains(next)) return;
|
|
165
|
+
ctx.hide(true);
|
|
166
|
+
};
|
|
167
|
+
el.addEventListener("pointerenter", enter);
|
|
168
|
+
el.addEventListener("pointerleave", leave);
|
|
169
|
+
el.addEventListener("pointerdown", down);
|
|
170
|
+
el.addEventListener("focus", focus);
|
|
171
|
+
el.addEventListener("blur", blur);
|
|
172
|
+
return () => {
|
|
173
|
+
el.removeEventListener("pointerenter", enter);
|
|
174
|
+
el.removeEventListener("pointerleave", leave);
|
|
175
|
+
el.removeEventListener("pointerdown", down);
|
|
176
|
+
el.removeEventListener("focus", focus);
|
|
177
|
+
el.removeEventListener("blur", blur);
|
|
178
|
+
};
|
|
24
179
|
});
|
|
180
|
+
|
|
25
181
|
return (
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
182
|
+
<Polymorphic
|
|
183
|
+
{...merge(
|
|
184
|
+
{
|
|
185
|
+
"data-slot": "hover-card-trigger",
|
|
186
|
+
get role() {
|
|
187
|
+
return nativeLink() ? undefined : "link";
|
|
188
|
+
},
|
|
189
|
+
get tabIndex() {
|
|
190
|
+
return nativeLink() ? undefined : 0;
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
rest,
|
|
194
|
+
{
|
|
195
|
+
as: local.as,
|
|
196
|
+
defaultAs: "a" as ValidComponent,
|
|
197
|
+
ref: (el: HTMLElement) => {
|
|
198
|
+
setOwn(el);
|
|
199
|
+
ctx.setTrigger(el);
|
|
200
|
+
if (typeof local.ref === "function") local.ref(el);
|
|
201
|
+
},
|
|
202
|
+
get "data-expanded"() {
|
|
203
|
+
return ctx.open() ? "" : undefined;
|
|
204
|
+
},
|
|
205
|
+
get "data-closed"() {
|
|
206
|
+
return ctx.open() ? undefined : "";
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
)}
|
|
210
|
+
/>
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
interface HoverCardContentProps extends ComponentProps<"div"> {
|
|
215
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
216
|
+
forceMount?: boolean;
|
|
217
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
218
|
+
onEscapeKeyDown?: (event: Event) => void;
|
|
219
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
220
|
+
onPointerDownOutside?: (event: Event) => void;
|
|
221
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
222
|
+
onFocusOutside?: (event: Event) => void;
|
|
223
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
224
|
+
onInteractOutside?: (event: Event) => void;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const HoverCardContent: Component<HoverCardContentProps> = (props) => {
|
|
228
|
+
const ctx = useHoverCard();
|
|
229
|
+
const [local, others] = splitProps(props, [
|
|
230
|
+
"class",
|
|
231
|
+
"ref",
|
|
232
|
+
"forceMount",
|
|
233
|
+
"onEscapeKeyDown",
|
|
234
|
+
"onPointerDownOutside",
|
|
235
|
+
"onFocusOutside",
|
|
236
|
+
"onInteractOutside",
|
|
237
|
+
]);
|
|
238
|
+
const presence = createPresence({
|
|
239
|
+
present: ctx.open,
|
|
240
|
+
element: ctx.card,
|
|
241
|
+
exitMs: MOTION_EXIT_MS.overlay,
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
const layer = registerLayer({
|
|
245
|
+
element: ctx.card,
|
|
246
|
+
open: ctx.open,
|
|
247
|
+
kind: "popover",
|
|
248
|
+
escape: () => true,
|
|
249
|
+
dismiss: () => ctx.hide(false),
|
|
250
|
+
trigger: ctx.trigger,
|
|
251
|
+
});
|
|
252
|
+
createDismiss({ layer, escapeFrom: "document", onDismiss: () => ctx.hide(false) });
|
|
253
|
+
createAnchored({
|
|
254
|
+
anchor: ctx.trigger,
|
|
255
|
+
floating: ctx.card,
|
|
256
|
+
open: ctx.open,
|
|
257
|
+
side: ctx.side,
|
|
258
|
+
align: ctx.align,
|
|
259
|
+
offset: ctx.gutter,
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
const Card: Component = () => {
|
|
263
|
+
onCleanup(() => ctx.setCard(undefined));
|
|
264
|
+
return (
|
|
265
|
+
<div
|
|
266
|
+
{...others}
|
|
267
|
+
ref={(el) => {
|
|
268
|
+
ctx.setCard(el);
|
|
30
269
|
if (typeof local.ref === "function") local.ref(el);
|
|
31
270
|
}}
|
|
32
|
-
onInteractOutside={onInteractOutside}
|
|
33
271
|
data-slot="hover-card-content"
|
|
34
|
-
|
|
35
|
-
{
|
|
272
|
+
data-expanded={ctx.open() ? "" : undefined}
|
|
273
|
+
data-closed={ctx.open() ? undefined : ""}
|
|
274
|
+
on:pointerenter={ctx.hold}
|
|
275
|
+
on:pointerleave={() => ctx.hide(true)}
|
|
276
|
+
class={cn(FLOATING_PANEL, OVERLAY_MOTION, ORIGIN_BY_SIDE, "w-64 p-4", local.class)}
|
|
36
277
|
/>
|
|
37
|
-
|
|
278
|
+
);
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<Show when={presence.mounted()}>
|
|
283
|
+
<Portal mount={usePortalMount()}>
|
|
284
|
+
<Card />
|
|
285
|
+
</Portal>
|
|
286
|
+
</Show>
|
|
38
287
|
);
|
|
39
288
|
};
|
|
40
289
|
|
|
290
|
+
/** @deprecated Drop the wrapper; the content portals itself; removed in 2.0.0. */
|
|
291
|
+
const HoverCardPortal: Component<{ children?: JSX.Element }> = (props) => <>{props.children}</>;
|
|
292
|
+
|
|
293
|
+
/** @deprecated Ignored; removed in 2.0.0. */
|
|
294
|
+
const HoverCardArrow: Component = () => null;
|
|
295
|
+
|
|
296
|
+
const HoverCard = Object.assign(HoverCardRoot, {
|
|
297
|
+
Trigger: HoverCardTrigger,
|
|
298
|
+
Content: HoverCardContent,
|
|
299
|
+
Portal: HoverCardPortal,
|
|
300
|
+
Arrow: HoverCardArrow,
|
|
301
|
+
});
|
|
302
|
+
|
|
41
303
|
export { HoverCard, HoverCardContent, HoverCardTrigger };
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
Show,
|
|
9
9
|
Switch,
|
|
10
10
|
} from "solid-js";
|
|
11
|
-
import { focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
11
|
+
import { activeOf, focusWithoutTracking } from "../lib/behavior/focus-scope.js";
|
|
12
12
|
import { FIELD_CHROME } from "../lib/input-classes.js";
|
|
13
13
|
import { PICKER_LIST } from "../lib/picker-classes.js";
|
|
14
14
|
import { SECTION_INNER_RADIUS } from "../lib/section-tokens.js";
|
|
@@ -220,7 +220,7 @@ function ImageGallery(
|
|
|
220
220
|
|
|
221
221
|
// A control that disables or leaves drops focus to the page, which a sealed dialog's trap moves outside, closing the gallery.
|
|
222
222
|
const holdFocus = () => focusWithoutTracking(panel);
|
|
223
|
-
const focused = () => (panel
|
|
223
|
+
const focused = () => (panel ? activeOf(panel) : null);
|
|
224
224
|
const focusLost = () => {
|
|
225
225
|
const at = focused();
|
|
226
226
|
return !at || at === document.body;
|
package/src/solid/index.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
// Original components
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
// don't need a direct @kobalte/core dependency.
|
|
5
|
-
export { type Color, parseColor } from "@kobalte/core/colors";
|
|
3
|
+
export { type Color, parseColor } from "../lib/color/index.js";
|
|
6
4
|
// Floating glass panel + its shared surface token.
|
|
7
5
|
export { SECTION_ROW_SURFACE } from "../lib/card-classes.js";
|
|
8
6
|
export { copyImage, copyText } from "../lib/clipboard.js";
|
|
@@ -83,11 +83,11 @@ const inputGroupButtonVariants = cva({
|
|
|
83
83
|
base: "flex items-center gap-2 rounded-sm text-sm shadow-none",
|
|
84
84
|
variants: {
|
|
85
85
|
size: {
|
|
86
|
-
/** @deprecated
|
|
86
|
+
/** @deprecated `"sm"`; removed in 2.0.0. */
|
|
87
87
|
xs: GROUP_BUTTON_SM,
|
|
88
88
|
sm: GROUP_BUTTON_SM,
|
|
89
89
|
default: `${CONTROL_H.default} px-3 has-[>svg]:px-3`,
|
|
90
|
-
/** @deprecated
|
|
90
|
+
/** @deprecated `"icon-sm"`; removed in 2.0.0. */
|
|
91
91
|
"icon-xs": GROUP_BUTTON_ICON_SM,
|
|
92
92
|
"icon-sm": GROUP_BUTTON_ICON_SM,
|
|
93
93
|
"icon-default": "size-9 p-0 has-[>svg]:p-0",
|
package/src/solid/item.tsx
CHANGED
|
@@ -78,7 +78,7 @@ const ItemMedia: Component<
|
|
|
78
78
|
ComponentProps<"div"> & {
|
|
79
79
|
/** The well the media sits in. Omit for bare content. */
|
|
80
80
|
media?: ItemMediaKind;
|
|
81
|
-
/** @deprecated `media
|
|
81
|
+
/** @deprecated `media`; removed in 2.0.0. */
|
|
82
82
|
variant?: ItemMediaKind | "default";
|
|
83
83
|
}
|
|
84
84
|
> = (props) => {
|