@c9up/nebula 0.1.9 → 0.2.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/atoms/Avatar.d.ts +36 -9
- package/dist/atoms/Avatar.js +66 -27
- package/dist/atoms/index.d.ts +1 -1
- package/dist/atoms/index.js +1 -1
- package/dist/lib/children.d.ts +30 -0
- package/dist/lib/motion.d.ts +10 -0
- package/dist/lib/motion.js +10 -0
- package/dist/molecules/Accordion.d.ts +36 -15
- package/dist/molecules/Accordion.js +68 -45
- package/dist/molecules/Breadcrumb.d.ts +29 -11
- package/dist/molecules/Breadcrumb.js +52 -52
- package/dist/molecules/Collapsible.d.ts +18 -17
- package/dist/molecules/Collapsible.js +42 -34
- package/dist/molecules/Field.d.ts +66 -30
- package/dist/molecules/Field.js +106 -55
- package/dist/molecules/InputGroup.d.ts +39 -21
- package/dist/molecules/InputGroup.js +43 -27
- package/dist/molecules/InputOTP.d.ts +26 -3
- package/dist/molecules/InputOTP.js +109 -76
- package/dist/molecules/Message.js +5 -4
- package/dist/molecules/Pagination.d.ts +36 -11
- package/dist/molecules/Pagination.js +58 -74
- package/dist/molecules/RadioGroup.d.ts +25 -17
- package/dist/molecules/RadioGroup.js +47 -43
- package/dist/molecules/Resizable.d.ts +32 -7
- package/dist/molecules/Resizable.js +76 -49
- package/dist/molecules/Tabs.d.ts +49 -11
- package/dist/molecules/Tabs.js +107 -51
- package/dist/molecules/ToggleGroup.d.ts +16 -10
- package/dist/molecules/ToggleGroup.js +37 -21
- package/dist/molecules/index.d.ts +11 -11
- package/dist/molecules/index.js +11 -11
- package/dist/organisms/AlertDialog.d.ts +80 -28
- package/dist/organisms/AlertDialog.js +192 -67
- package/dist/organisms/Carousel.d.ts +25 -3
- package/dist/organisms/Carousel.js +75 -43
- package/dist/organisms/Combobox.d.ts +2 -1
- package/dist/organisms/Combobox.js +46 -16
- package/dist/organisms/Command.d.ts +73 -32
- package/dist/organisms/Command.js +209 -131
- package/dist/organisms/CommandDialog.js +5 -5
- package/dist/organisms/ContextMenu.d.ts +41 -19
- package/dist/organisms/ContextMenu.js +112 -71
- package/dist/organisms/DataTable.js +42 -8
- package/dist/organisms/Dialog.d.ts +97 -31
- package/dist/organisms/Dialog.js +193 -68
- package/dist/organisms/Drawer.d.ts +33 -10
- package/dist/organisms/Drawer.js +130 -52
- package/dist/organisms/DropdownMenu.d.ts +58 -11
- package/dist/organisms/DropdownMenu.js +137 -50
- package/dist/organisms/Form.js +9 -11
- package/dist/organisms/HoverCard.d.ts +39 -19
- package/dist/organisms/HoverCard.js +116 -40
- package/dist/organisms/Menubar.d.ts +55 -19
- package/dist/organisms/Menubar.js +166 -82
- package/dist/organisms/NavigationMenu.d.ts +77 -31
- package/dist/organisms/NavigationMenu.js +169 -98
- package/dist/organisms/Popover.d.ts +72 -12
- package/dist/organisms/Popover.js +132 -25
- package/dist/organisms/Questionnaire.js +5 -5
- package/dist/organisms/Select.d.ts +99 -18
- package/dist/organisms/Select.js +253 -111
- package/dist/organisms/Sheet.d.ts +57 -13
- package/dist/organisms/Sheet.js +141 -54
- package/dist/organisms/Sidebar.d.ts +146 -56
- package/dist/organisms/Sidebar.js +236 -128
- package/dist/organisms/Tooltip.d.ts +88 -14
- package/dist/organisms/Tooltip.js +210 -47
- package/dist/organisms/index.d.ts +15 -15
- package/dist/organisms/index.js +15 -15
- package/dist/primitives/floating.js +25 -0
- package/dist/primitives/floatingSurface.d.ts +11 -0
- package/dist/primitives/floatingSurface.js +8 -0
- package/dist/primitives/menu.d.ts +45 -1
- package/dist/primitives/menu.js +45 -14
- package/dist/primitives/menuParts.d.ts +113 -0
- package/dist/primitives/menuParts.js +207 -0
- package/nebula.css +1 -1
- package/package.json +3 -3
- package/registry.json +18 -6
- package/src/atoms/Avatar.ts +141 -37
- package/src/atoms/index.ts +13 -1
- package/src/lib/children.ts +31 -0
- package/src/lib/motion.ts +12 -0
- package/src/molecules/Accordion.ts +120 -60
- package/src/molecules/Breadcrumb.ts +77 -76
- package/src/molecules/Collapsible.ts +77 -41
- package/src/molecules/Field.ts +187 -72
- package/src/molecules/InputGroup.ts +88 -35
- package/src/molecules/InputOTP.ts +150 -86
- package/src/molecules/Message.ts +6 -4
- package/src/molecules/Pagination.ts +96 -101
- package/src/molecules/RadioGroup.ts +70 -59
- package/src/molecules/Resizable.ts +138 -75
- package/src/molecules/Tabs.ts +187 -74
- package/src/molecules/ToggleGroup.ts +77 -38
- package/src/molecules/index.ts +85 -8
- package/src/organisms/AlertDialog.ts +319 -82
- package/src/organisms/Carousel.ts +129 -52
- package/src/organisms/Combobox.ts +64 -19
- package/src/organisms/Command.ts +342 -159
- package/src/organisms/CommandDialog.ts +6 -6
- package/src/organisms/ContextMenu.ts +185 -83
- package/src/organisms/DataTable.ts +56 -10
- package/src/organisms/Dialog.ts +312 -102
- package/src/organisms/Drawer.ts +219 -71
- package/src/organisms/DropdownMenu.ts +219 -61
- package/src/organisms/Form.ts +48 -34
- package/src/organisms/HoverCard.ts +187 -53
- package/src/organisms/Menubar.ts +247 -87
- package/src/organisms/NavigationMenu.ts +306 -128
- package/src/organisms/Popover.ts +215 -39
- package/src/organisms/Questionnaire.ts +9 -6
- package/src/organisms/Select.ts +397 -130
- package/src/organisms/Sheet.ts +252 -83
- package/src/organisms/Sidebar.ts +438 -185
- package/src/organisms/Tooltip.ts +315 -65
- package/src/organisms/index.ts +284 -14
- package/src/primitives/floating.ts +33 -0
- package/src/primitives/floatingSurface.ts +19 -0
- package/src/primitives/menu.ts +79 -18
- package/src/primitives/menuParts.ts +371 -0
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The rows every menu is made of.
|
|
3
|
+
*
|
|
4
|
+
* DropdownMenu, ContextMenu and Menubar are the same menu with three different
|
|
5
|
+
* opening gestures: a button, a right-click, a bar. Upstream repeats all
|
|
6
|
+
* fifteen row components in each of the three files, because each file is
|
|
7
|
+
* copied on its own and has to stand alone. Here the three already share
|
|
8
|
+
* `menu.ts` — its class strings, its keyboard model, its submenu registry —
|
|
9
|
+
* and the registry copies it with them, so repeating the rows would only be
|
|
10
|
+
* three places to fix when one of them is wrong.
|
|
11
|
+
*
|
|
12
|
+
* const parts = createMenuParts("context-menu", ContextMenuContext);
|
|
13
|
+
* export const ContextMenuItem = parts.Item;
|
|
14
|
+
*
|
|
15
|
+
* What differs between the three is exactly two things: the `data-slot`
|
|
16
|
+
* prefix, and which context tells a row how to close the menu it is in. Both
|
|
17
|
+
* are arguments.
|
|
18
|
+
*
|
|
19
|
+
* The rows carry `data-nebula-item` and a `role`, which is the whole of the
|
|
20
|
+
* contract `wireMenu` reads — roving focus, type-ahead, arrows and submenu
|
|
21
|
+
* traversal all work on the rendered DOM, so a row built here behaves the same
|
|
22
|
+
* as one written by hand.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import {
|
|
26
|
+
type Context,
|
|
27
|
+
component,
|
|
28
|
+
createContext,
|
|
29
|
+
html,
|
|
30
|
+
inject,
|
|
31
|
+
provide,
|
|
32
|
+
type TemplateResult,
|
|
33
|
+
} from "@c9up/aurora";
|
|
34
|
+
import type { Child, Parts, Slot } from "../lib/children.js";
|
|
35
|
+
import { slot } from "../lib/children.js";
|
|
36
|
+
import { cn } from "../lib/cn.js";
|
|
37
|
+
import { CheckIcon, ChevronRightIcon, CircleIcon } from "../lib/icons.js";
|
|
38
|
+
import { uid } from "../lib/id.js";
|
|
39
|
+
import { slideInFromSide, zoomInOut } from "../lib/motion.js";
|
|
40
|
+
import { type Reactive, read } from "../lib/props.js";
|
|
41
|
+
import {
|
|
42
|
+
menuCheckItemClasses,
|
|
43
|
+
menuIndicatorClasses,
|
|
44
|
+
menuItemClasses,
|
|
45
|
+
menuLabelClasses,
|
|
46
|
+
menuSeparatorClasses,
|
|
47
|
+
menuShortcutClasses,
|
|
48
|
+
menuSubPanelClasses,
|
|
49
|
+
menuSubTriggerClasses,
|
|
50
|
+
registerSubmenu,
|
|
51
|
+
} from "./menu.js";
|
|
52
|
+
import { portal } from "./portal.js";
|
|
53
|
+
|
|
54
|
+
/** What a row needs from the menu it is in. */
|
|
55
|
+
export interface MenuOwner {
|
|
56
|
+
/** A row was chosen: the whole stack closes. */
|
|
57
|
+
closeAll(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface MenuGroupProps {
|
|
61
|
+
children?: Slot;
|
|
62
|
+
class?: Reactive<string>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface MenuItemProps {
|
|
66
|
+
children?: Slot;
|
|
67
|
+
/** Indent to line up with the checkbox and radio rows. */
|
|
68
|
+
inset?: boolean;
|
|
69
|
+
variant?: "default" | "destructive";
|
|
70
|
+
disabled?: boolean;
|
|
71
|
+
onSelect?: () => void;
|
|
72
|
+
class?: Reactive<string>;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface MenuCheckboxItemProps {
|
|
76
|
+
children?: Slot;
|
|
77
|
+
checked?: Reactive<boolean>;
|
|
78
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
79
|
+
disabled?: boolean;
|
|
80
|
+
class?: Reactive<string>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface MenuRadioGroupProps {
|
|
84
|
+
children?: Parts;
|
|
85
|
+
value?: Reactive<string | undefined>;
|
|
86
|
+
onValueChange?: (value: string) => void;
|
|
87
|
+
class?: Reactive<string>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface MenuRadioItemProps {
|
|
91
|
+
children?: Slot;
|
|
92
|
+
value: string;
|
|
93
|
+
disabled?: boolean;
|
|
94
|
+
class?: Reactive<string>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface MenuLabelProps {
|
|
98
|
+
children?: Slot;
|
|
99
|
+
inset?: boolean;
|
|
100
|
+
class?: Reactive<string>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface MenuSeparatorProps {
|
|
104
|
+
class?: Reactive<string>;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface MenuShortcutProps {
|
|
108
|
+
children?: Slot;
|
|
109
|
+
class?: Reactive<string>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface MenuSubProps {
|
|
113
|
+
children?: Parts;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export interface MenuSubTriggerProps {
|
|
117
|
+
children?: Slot;
|
|
118
|
+
inset?: boolean;
|
|
119
|
+
disabled?: boolean;
|
|
120
|
+
class?: Reactive<string>;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface MenuSubContentProps {
|
|
124
|
+
children?: Parts;
|
|
125
|
+
class?: Reactive<string>;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export interface MenuPortalProps {
|
|
129
|
+
children?: Slot;
|
|
130
|
+
container?: () => Element | null;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export interface MenuParts {
|
|
134
|
+
Group: (props?: MenuGroupProps) => TemplateResult;
|
|
135
|
+
Item: (props?: MenuItemProps) => TemplateResult;
|
|
136
|
+
CheckboxItem: (props?: MenuCheckboxItemProps) => TemplateResult;
|
|
137
|
+
RadioGroup: (props?: MenuRadioGroupProps) => TemplateResult;
|
|
138
|
+
RadioItem: (props: MenuRadioItemProps) => TemplateResult;
|
|
139
|
+
Label: (props?: MenuLabelProps) => TemplateResult;
|
|
140
|
+
Separator: (props?: MenuSeparatorProps) => TemplateResult;
|
|
141
|
+
Shortcut: (props?: MenuShortcutProps) => TemplateResult;
|
|
142
|
+
Sub: (props?: MenuSubProps) => TemplateResult;
|
|
143
|
+
SubTrigger: (props?: MenuSubTriggerProps) => TemplateResult;
|
|
144
|
+
SubContent: (props?: MenuSubContentProps) => TemplateResult;
|
|
145
|
+
Portal: (props?: MenuPortalProps) => TemplateResult;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
interface RadioGroupApi {
|
|
149
|
+
readonly value: () => string | undefined;
|
|
150
|
+
select(value: string): void;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
interface SubmenuApi {
|
|
154
|
+
readonly triggerId: string;
|
|
155
|
+
register(body: Child, className: Reactive<string> | undefined): void;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Build one menu's fifteen rows.
|
|
160
|
+
*
|
|
161
|
+
* @param prefix The `data-slot` prefix, e.g. `"dropdown-menu"`.
|
|
162
|
+
* @param owner The context carrying that menu's `closeAll`.
|
|
163
|
+
*/
|
|
164
|
+
export function createMenuParts(
|
|
165
|
+
prefix: string,
|
|
166
|
+
owner: Context<MenuOwner>,
|
|
167
|
+
): MenuParts {
|
|
168
|
+
const RadioGroupContext = createContext<RadioGroupApi>(
|
|
169
|
+
`${prefix}-radio-group`,
|
|
170
|
+
);
|
|
171
|
+
const SubContext = createContext<SubmenuApi>(`${prefix}-sub`);
|
|
172
|
+
|
|
173
|
+
const Group = component<MenuGroupProps>(
|
|
174
|
+
(props) => html`<div
|
|
175
|
+
data-slot="${`${prefix}-group`}"
|
|
176
|
+
role="group"
|
|
177
|
+
class="${() => cn(read(props.class))}"
|
|
178
|
+
>${slot(props.children)}</div>`,
|
|
179
|
+
);
|
|
180
|
+
|
|
181
|
+
const Item = component<MenuItemProps>((props) => {
|
|
182
|
+
const menu = inject(owner);
|
|
183
|
+
function activate(): void {
|
|
184
|
+
if (props.disabled === true) return;
|
|
185
|
+
props.onSelect?.();
|
|
186
|
+
menu.closeAll();
|
|
187
|
+
}
|
|
188
|
+
return html`<div
|
|
189
|
+
data-slot="${`${prefix}-item`}"
|
|
190
|
+
data-nebula-item
|
|
191
|
+
role="menuitem"
|
|
192
|
+
data-inset="${props.inset === true ? "" : undefined}"
|
|
193
|
+
data-variant="${props.variant ?? "default"}"
|
|
194
|
+
data-disabled="${props.disabled === true ? "" : undefined}"
|
|
195
|
+
aria-disabled="${props.disabled === true ? "true" : undefined}"
|
|
196
|
+
tabindex="-1"
|
|
197
|
+
class="${() => cn(menuItemClasses, read(props.class))}"
|
|
198
|
+
@click="${activate}"
|
|
199
|
+
>${slot(props.children)}</div>`;
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
const CheckboxItem = component<MenuCheckboxItemProps>((props) => {
|
|
203
|
+
const menu = inject(owner);
|
|
204
|
+
const checked = (): boolean => read(props.checked) === true;
|
|
205
|
+
function activate(): void {
|
|
206
|
+
if (props.disabled === true) return;
|
|
207
|
+
props.onCheckedChange?.(!checked());
|
|
208
|
+
menu.closeAll();
|
|
209
|
+
}
|
|
210
|
+
return html`<div
|
|
211
|
+
data-slot="${`${prefix}-checkbox-item`}"
|
|
212
|
+
data-nebula-item
|
|
213
|
+
role="menuitemcheckbox"
|
|
214
|
+
aria-checked="${() => (checked() ? "true" : "false")}"
|
|
215
|
+
data-disabled="${props.disabled === true ? "" : undefined}"
|
|
216
|
+
aria-disabled="${props.disabled === true ? "true" : undefined}"
|
|
217
|
+
tabindex="-1"
|
|
218
|
+
class="${() => cn(menuCheckItemClasses, read(props.class))}"
|
|
219
|
+
@click="${activate}"
|
|
220
|
+
><span class="${menuIndicatorClasses}">${() =>
|
|
221
|
+
checked() ? CheckIcon({ class: "size-4" }) : null}</span>${slot(
|
|
222
|
+
props.children,
|
|
223
|
+
)}</div>`;
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
const RadioGroup = component<MenuRadioGroupProps>((props) => {
|
|
227
|
+
const menu = inject(owner);
|
|
228
|
+
provide<RadioGroupApi>(RadioGroupContext, {
|
|
229
|
+
value: () => read(props.value),
|
|
230
|
+
select(next) {
|
|
231
|
+
props.onValueChange?.(next);
|
|
232
|
+
menu.closeAll();
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
const rows = props.children?.();
|
|
236
|
+
return html`<div
|
|
237
|
+
data-slot="${`${prefix}-radio-group`}"
|
|
238
|
+
role="group"
|
|
239
|
+
class="${() => cn(read(props.class))}"
|
|
240
|
+
>${rows}</div>`;
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const RadioItem = component<MenuRadioItemProps>((props) => {
|
|
244
|
+
const group = inject(RadioGroupContext);
|
|
245
|
+
const selected = (): boolean => group.value() === props.value;
|
|
246
|
+
function activate(): void {
|
|
247
|
+
if (props.disabled === true) return;
|
|
248
|
+
group.select(props.value);
|
|
249
|
+
}
|
|
250
|
+
return html`<div
|
|
251
|
+
data-slot="${`${prefix}-radio-item`}"
|
|
252
|
+
data-nebula-item
|
|
253
|
+
role="menuitemradio"
|
|
254
|
+
aria-checked="${() => (selected() ? "true" : "false")}"
|
|
255
|
+
data-disabled="${props.disabled === true ? "" : undefined}"
|
|
256
|
+
aria-disabled="${props.disabled === true ? "true" : undefined}"
|
|
257
|
+
tabindex="-1"
|
|
258
|
+
class="${() => cn(menuCheckItemClasses, read(props.class))}"
|
|
259
|
+
@click="${activate}"
|
|
260
|
+
><span class="${menuIndicatorClasses}">${() =>
|
|
261
|
+
selected()
|
|
262
|
+
? CircleIcon({ class: "size-2 fill-current" })
|
|
263
|
+
: null}</span>${slot(props.children)}</div>`;
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
const Label = component<MenuLabelProps>(
|
|
267
|
+
(props) => html`<div
|
|
268
|
+
data-slot="${`${prefix}-label`}"
|
|
269
|
+
data-inset="${props.inset === true ? "" : undefined}"
|
|
270
|
+
class="${() => cn(menuLabelClasses, read(props.class))}"
|
|
271
|
+
>${slot(props.children)}</div>`,
|
|
272
|
+
);
|
|
273
|
+
|
|
274
|
+
const Separator = component<MenuSeparatorProps>(
|
|
275
|
+
(props) => html`<div
|
|
276
|
+
data-slot="${`${prefix}-separator`}"
|
|
277
|
+
role="separator"
|
|
278
|
+
class="${() => cn(menuSeparatorClasses, read(props.class))}"
|
|
279
|
+
></div>`,
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
const Shortcut = component<MenuShortcutProps>(
|
|
283
|
+
(props) => html`<span
|
|
284
|
+
data-slot="${`${prefix}-shortcut`}"
|
|
285
|
+
class="${() => cn(menuShortcutClasses, read(props.class))}"
|
|
286
|
+
>${slot(props.children)}</span>`,
|
|
287
|
+
);
|
|
288
|
+
|
|
289
|
+
const Sub = component<MenuSubProps>((props) => {
|
|
290
|
+
const triggerId = uid(`${prefix}-sub-trigger`);
|
|
291
|
+
let body: Child;
|
|
292
|
+
let panelClass: Reactive<string> | undefined;
|
|
293
|
+
|
|
294
|
+
provide<SubmenuApi>(SubContext, {
|
|
295
|
+
triggerId,
|
|
296
|
+
register(registered, className) {
|
|
297
|
+
body = registered;
|
|
298
|
+
panelClass = className;
|
|
299
|
+
},
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
const parts = props.children?.();
|
|
303
|
+
|
|
304
|
+
// Registered AFTER the parts are built, so `body` is the panel the
|
|
305
|
+
// `SubContent` among them just handed over. A submenu is built fresh on
|
|
306
|
+
// each open, which is why this is a factory.
|
|
307
|
+
registerSubmenu(
|
|
308
|
+
triggerId,
|
|
309
|
+
({ id }) => html`<div
|
|
310
|
+
data-slot="${`${prefix}-sub-content`}"
|
|
311
|
+
id="${id}"
|
|
312
|
+
role="menu"
|
|
313
|
+
aria-orientation="vertical"
|
|
314
|
+
tabindex="-1"
|
|
315
|
+
class="${cn(
|
|
316
|
+
menuSubPanelClasses,
|
|
317
|
+
zoomInOut,
|
|
318
|
+
slideInFromSide,
|
|
319
|
+
read(panelClass),
|
|
320
|
+
)}"
|
|
321
|
+
>${body}</div>`,
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
return html`${parts}`;
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
const SubTrigger = component<MenuSubTriggerProps>((props) => {
|
|
328
|
+
const sub = inject(SubContext);
|
|
329
|
+
return html`<div
|
|
330
|
+
data-slot="${`${prefix}-sub-trigger`}"
|
|
331
|
+
data-nebula-item
|
|
332
|
+
data-submenu="${sub.triggerId}"
|
|
333
|
+
role="menuitem"
|
|
334
|
+
aria-haspopup="menu"
|
|
335
|
+
aria-expanded="false"
|
|
336
|
+
data-inset="${props.inset === true ? "" : undefined}"
|
|
337
|
+
data-disabled="${props.disabled === true ? "" : undefined}"
|
|
338
|
+
tabindex="-1"
|
|
339
|
+
class="${() => cn(menuSubTriggerClasses, read(props.class))}"
|
|
340
|
+
>${slot(props.children)}${ChevronRightIcon({ class: "ml-auto size-4" })}</div>`;
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
const SubContent = component<MenuSubContentProps>((props) => {
|
|
344
|
+
const sub = inject(SubContext);
|
|
345
|
+
sub.register(props.children?.(), props.class);
|
|
346
|
+
return html``;
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
const Portal = component<MenuPortalProps>((props) => {
|
|
350
|
+
const mounted = portal(html`${slot(props.children)}`, {
|
|
351
|
+
container: props.container,
|
|
352
|
+
});
|
|
353
|
+
mounted.host.setAttribute("data-slot", `${prefix}-portal`);
|
|
354
|
+
return html``;
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
return {
|
|
358
|
+
Group,
|
|
359
|
+
Item,
|
|
360
|
+
CheckboxItem,
|
|
361
|
+
RadioGroup,
|
|
362
|
+
RadioItem,
|
|
363
|
+
Label,
|
|
364
|
+
Separator,
|
|
365
|
+
Shortcut,
|
|
366
|
+
Sub,
|
|
367
|
+
SubTrigger,
|
|
368
|
+
SubContent,
|
|
369
|
+
Portal,
|
|
370
|
+
};
|
|
371
|
+
}
|