@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
|
@@ -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}
|
|
@@ -532,6 +532,7 @@ export function EntitySelector(props: EntitySelectorProps) {
|
|
|
532
532
|
>
|
|
533
533
|
<SelectionScope
|
|
534
534
|
marker="highlighted"
|
|
535
|
+
radius={MENU_ITEM_RADIUS}
|
|
535
536
|
role="presentation"
|
|
536
537
|
style={{ height: `${totalHeight()}px` }}
|
|
537
538
|
>
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createContext, createMemo, createSignal, type JSX, Show, useContext } from "solid-js";
|
|
2
|
+
import { createToggleItem, createToggleSet, type ToggleSet } from "../lib/toggle-set.js";
|
|
3
3
|
import { cn } from "../lib/utils.js";
|
|
4
4
|
import { Avatar, AvatarFallback } from "./avatar.js";
|
|
5
5
|
import { Icon } from "./icon.js";
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const FaceContext = createContext<{ locked: () => ReadonlySet<string>; set: ToggleSet }>();
|
|
8
|
+
|
|
9
|
+
const sameList = (a: readonly string[], b: readonly string[]) =>
|
|
10
|
+
a.length === b.length && a.every((v, i) => v === b[i]);
|
|
8
11
|
|
|
9
12
|
/** People and screens to turn on or off. Faces in `lockedIds` always count: shown on, never reported in `onChange`. */
|
|
10
13
|
export function FaceToggleGroup(props: {
|
|
@@ -18,19 +21,33 @@ export function FaceToggleGroup(props: {
|
|
|
18
21
|
}) {
|
|
19
22
|
const locked = createMemo(() => new Set(props.lockedIds ?? []));
|
|
20
23
|
const pressed = () => [...new Set([...props.value, ...locked()])];
|
|
24
|
+
const [root, setRoot] = createSignal<HTMLElement>();
|
|
25
|
+
const set = createToggleSet({
|
|
26
|
+
root,
|
|
27
|
+
itemSelector: '[data-slot="face-toggle"][data-key]',
|
|
28
|
+
values: pressed,
|
|
29
|
+
setValues: (next) => {
|
|
30
|
+
const chosen = next.filter((id) => !locked().has(id));
|
|
31
|
+
if (!sameList(chosen, props.value)) props.onChange(chosen);
|
|
32
|
+
},
|
|
33
|
+
multiple: () => true,
|
|
34
|
+
disabledFocusable: true,
|
|
35
|
+
});
|
|
21
36
|
return (
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
|
|
37
|
+
<FaceContext.Provider value={{ locked, set }}>
|
|
38
|
+
<div
|
|
39
|
+
ref={setRoot}
|
|
40
|
+
role="group"
|
|
41
|
+
id={set.id()}
|
|
42
|
+
data-orientation={set.orientation()}
|
|
25
43
|
data-slot="face-toggle-group"
|
|
26
44
|
aria-label={props["aria-label"]}
|
|
27
|
-
value={pressed()}
|
|
28
|
-
onChange={(next: string[]) => props.onChange(next.filter((id) => !locked().has(id)))}
|
|
29
45
|
class={cn("flex flex-wrap gap-x-3 gap-y-2", props.class)}
|
|
46
|
+
on:keydown={(event) => set.collection.onKeyDown(event)}
|
|
30
47
|
>
|
|
31
48
|
{props.children}
|
|
32
|
-
</
|
|
33
|
-
</
|
|
49
|
+
</div>
|
|
50
|
+
</FaceContext.Provider>
|
|
34
51
|
);
|
|
35
52
|
}
|
|
36
53
|
|
|
@@ -40,11 +57,19 @@ export function FaceToggle(props: {
|
|
|
40
57
|
kind: "person" | "screen";
|
|
41
58
|
class?: string;
|
|
42
59
|
}) {
|
|
43
|
-
const
|
|
44
|
-
|
|
60
|
+
const group = useContext(FaceContext);
|
|
61
|
+
if (!group) throw new Error("FaceToggle renders inside a FaceToggleGroup");
|
|
62
|
+
const isLocked = () => group.locked().has(props.id);
|
|
63
|
+
const item = createToggleItem(group.set, {
|
|
64
|
+
value: () => props.id,
|
|
65
|
+
disabled: () => false,
|
|
66
|
+
locked: isLocked,
|
|
67
|
+
});
|
|
45
68
|
return (
|
|
46
|
-
<
|
|
47
|
-
|
|
69
|
+
<button
|
|
70
|
+
ref={item.ref}
|
|
71
|
+
type="button"
|
|
72
|
+
{...item.props}
|
|
48
73
|
data-slot="face-toggle"
|
|
49
74
|
aria-disabled={isLocked() ? "true" : undefined}
|
|
50
75
|
class={cn(
|
|
@@ -53,7 +78,7 @@ export function FaceToggle(props: {
|
|
|
53
78
|
)}
|
|
54
79
|
>
|
|
55
80
|
<span aria-hidden="true" class="relative">
|
|
56
|
-
<Avatar class="group-data-[pressed]/face-toggle:ring-primary group-data-[pressed]/face-toggle:ring-offset-background size-11 opacity-50 transition-opacity duration-
|
|
81
|
+
<Avatar class="group-data-[pressed]/face-toggle:ring-primary group-data-[pressed]/face-toggle:ring-offset-background size-11 opacity-50 transition-opacity duration-(--duration-expand) group-active/face-toggle:scale-[0.97] group-data-[pressed]/face-toggle:opacity-100 group-data-[pressed]/face-toggle:ring-2 group-data-[pressed]/face-toggle:ring-offset-2">
|
|
57
82
|
<AvatarFallback>
|
|
58
83
|
<Show when={props.kind === "screen"} fallback={props.name.slice(0, 1)}>
|
|
59
84
|
<Icon icon="lucide:monitor-smartphone" width={18} height={18} />
|
|
@@ -81,13 +106,13 @@ export function FaceToggle(props: {
|
|
|
81
106
|
</span>
|
|
82
107
|
<span
|
|
83
108
|
data-slot="face-toggle-name"
|
|
84
|
-
class="text-muted-foreground group-data-[pressed]/face-toggle:text-foreground max-w-full truncate transition-colors duration-
|
|
109
|
+
class="text-muted-foreground group-data-[pressed]/face-toggle:text-foreground max-w-full truncate transition-colors duration-(--duration-expand)"
|
|
85
110
|
>
|
|
86
111
|
{props.name}
|
|
87
112
|
</span>
|
|
88
113
|
<Show when={isLocked()}>
|
|
89
|
-
<span class="sr-only">always sees it</span>
|
|
114
|
+
<span class="sr-only">{" always sees it"}</span>
|
|
90
115
|
</Show>
|
|
91
|
-
</
|
|
116
|
+
</button>
|
|
92
117
|
);
|
|
93
118
|
}
|
package/src/solid/form.tsx
CHANGED
|
@@ -95,7 +95,7 @@ const FormField: ParentComponent<{ name: string }> = (props) => {
|
|
|
95
95
|
);
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
-
/** @deprecated
|
|
98
|
+
/** @deprecated `Field`; removed in 2.0.0. */
|
|
99
99
|
const FormItem: ParentComponent<ComponentProps<typeof Field>> = (props) => {
|
|
100
100
|
const id = createUniqueId();
|
|
101
101
|
const [hasDescription, setHasDescription] = createSignal(false);
|
|
@@ -107,7 +107,7 @@ const FormItem: ParentComponent<ComponentProps<typeof Field>> = (props) => {
|
|
|
107
107
|
);
|
|
108
108
|
};
|
|
109
109
|
|
|
110
|
-
/** @deprecated
|
|
110
|
+
/** @deprecated `FieldLabel`; removed in 2.0.0. */
|
|
111
111
|
const FormLabel: Component<ComponentProps<typeof FieldLabel>> = (props) => {
|
|
112
112
|
const [local, rest] = splitProps(props, ["class"]);
|
|
113
113
|
const { error, formItemId } = useFormField();
|
|
@@ -145,8 +145,7 @@ function warnFormControlWrapper() {
|
|
|
145
145
|
* Passing children keeps the old wrapper shape working: a `div` carrying the
|
|
146
146
|
* same id and aria, with the children inside.
|
|
147
147
|
*
|
|
148
|
-
* @deprecated
|
|
149
|
-
* describedby land on the element a screen reader announces.
|
|
148
|
+
* @deprecated With `children`, render the control itself; removed in 2.0.0.
|
|
150
149
|
*/
|
|
151
150
|
const FormControl = <T extends ValidComponent = typeof Input>(
|
|
152
151
|
props: { as?: T } & ComponentProps<T>,
|
|
@@ -197,7 +196,7 @@ const FormControl = <T extends ValidComponent = typeof Input>(
|
|
|
197
196
|
);
|
|
198
197
|
};
|
|
199
198
|
|
|
200
|
-
/** @deprecated
|
|
199
|
+
/** @deprecated `FieldDescription`; removed in 2.0.0. */
|
|
201
200
|
const FormDescription: Component<ComponentProps<typeof FieldDescription>> = (props) => {
|
|
202
201
|
const itemContext = useContext(FormItemContext);
|
|
203
202
|
const { formDescriptionId } = useFormField();
|
|
@@ -208,7 +207,7 @@ const FormDescription: Component<ComponentProps<typeof FieldDescription>> = (pro
|
|
|
208
207
|
return <FieldDescription id={formDescriptionId()} {...props} />;
|
|
209
208
|
};
|
|
210
209
|
|
|
211
|
-
/** @deprecated
|
|
210
|
+
/** @deprecated `FieldError`; removed in 2.0.0. */
|
|
212
211
|
const FormMessage: ParentComponent<ComponentProps<typeof FieldError>> = (props) => {
|
|
213
212
|
const [local, rest] = splitProps(props, ["children"]);
|
|
214
213
|
const { error, formMessageId } = useFormField();
|