@plexui/vue 0.11.0 → 0.12.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/es/components/Menu/Menu.js +44 -22
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/composables/usePhoneSubmenu.js +3 -2
- package/dist/es/composables/usePhoneSubmenu.js.map +1 -1
- package/dist/es/lib/menuInitialFocus.js +5 -3
- package/dist/es/lib/menuInitialFocus.js.map +1 -1
- package/dist/es/lib/menuSubmenuPlacement.js +129 -5
- package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
- package/dist/es/lib/menuTriggerCover.js +10 -4
- package/dist/es/lib/menuTriggerCover.js.map +1 -1
- package/dist/types/composables/usePhoneSubmenu.d.ts +2 -1
- package/dist/types/lib/menuSubmenuPlacement.d.ts +9 -2
- package/package.json +2 -2
|
@@ -13,6 +13,7 @@ import { TransitionGroup } from "../Transition/index.js";
|
|
|
13
13
|
import { createExitGuard, overlayTiming, overlayTimingQuick } from "../Transition/shared.js";
|
|
14
14
|
import { MenuLevelKey, MenuRootInternalsKey, MenuSubInternalsKey, SUB_CLOSE_KEYS, SUB_OPEN_KEYS, box, compose, getCheckedState, getOpenState, isIndeterminate, provideMenuContentContext, selectableItemListeners, splitListeners, trackKeyboardUse, useMenuItemImpl, useMenuItemSelect, useMenuLevel, useMenuRootInternals, useMenuSubInternals, whenMouse, } from "./internal.js";
|
|
15
15
|
import { useFloatingBoundary } from "../../composables/useFloatingBoundary.js";
|
|
16
|
+
import { PHONE_LAYOUT } from "../PhoneLayout/PhoneLayout.js";
|
|
16
17
|
import { usePhoneSubmenu } from "../../composables/usePhoneSubmenu.js";
|
|
17
18
|
import { focusPhoneSubmenuEntry } from "../../lib/menuSubmenuPlacement.js";
|
|
18
19
|
import { ignoreReleaseOverTrigger, observeMenuTriggerCover } from "../../lib/menuTriggerCover.js";
|
|
@@ -306,6 +307,31 @@ export const MenuTrigger = defineComponent({
|
|
|
306
307
|
// ---------------------------------------------------------------------------
|
|
307
308
|
// Content
|
|
308
309
|
const COLLISION_PADDING = { bottom: 30, top: 30, left: 12, right: 12 };
|
|
310
|
+
// Inside a PhoneLayout a menu opens in its box, laid out as on a phone and kept within it; in a Dialog laid out as on a
|
|
311
|
+
// phone outside one it opens over the window, in a phone scope of its own (plan 176)
|
|
312
|
+
const useMenuPhoneLayout = () => {
|
|
313
|
+
const phoneLayout = inject(PHONE_LAYOUT, null);
|
|
314
|
+
const container = computed(() => phoneLayout?.container.value ?? null);
|
|
315
|
+
return {
|
|
316
|
+
container,
|
|
317
|
+
scoped: computed(() => !!phoneLayout?.phone.value && !container.value),
|
|
318
|
+
};
|
|
319
|
+
};
|
|
320
|
+
const useMenuBoundary = (active) => {
|
|
321
|
+
const footerBoundary = useFloatingBoundary(active, COLLISION_PADDING);
|
|
322
|
+
const { container } = useMenuPhoneLayout();
|
|
323
|
+
return computed(() => {
|
|
324
|
+
const box = container.value;
|
|
325
|
+
const footer = footerBoundary.value.collisionBoundary;
|
|
326
|
+
// The footer of a Page or Dialog in the box keeps the menu clear of it; one around the box does not hold it, and
|
|
327
|
+
// the box clips what passes its edges
|
|
328
|
+
return box && !(footer && box.contains(footer)) ? { collisionBoundary: box, collisionPadding: COLLISION_PADDING } : footerBoundary.value;
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
// The portal of a menu panel: into the PhoneLayout box, or a phone scope of its own around the transition
|
|
332
|
+
const menuPortal = (phoneLayout, group) => h(RekaDropdownMenuPortal, { to: phoneLayout.container.value ?? undefined }, {
|
|
333
|
+
default: () => [phoneLayout.scoped.value ? h("div", { "class": s.PhoneScope, "data-plex-layout": "phone" }, [group()]) : group()],
|
|
334
|
+
});
|
|
309
335
|
const AUTOFOCUS_ON_UNMOUNT = "focusScope.autoFocusOnUnmount";
|
|
310
336
|
// Radix's names for the content custom properties (read by the shared CSS),
|
|
311
337
|
// in place of Reka's
|
|
@@ -358,7 +384,7 @@ const MenuRootContentImpl = defineComponent({
|
|
|
358
384
|
const rootContext = injectDropdownMenuRootContext();
|
|
359
385
|
const internals = useMenuRootInternals();
|
|
360
386
|
const level = useMenuLevel();
|
|
361
|
-
const floatingBoundary =
|
|
387
|
+
const floatingBoundary = useMenuBoundary(level.open);
|
|
362
388
|
const { prepareFocusRestore } = useMenuContext();
|
|
363
389
|
rootContext.contentId ||= useId(undefined, "reka-dropdown-menu-content");
|
|
364
390
|
const { contentHandlers, resetSearch } = provideMenuContentContext(() => level.content.value);
|
|
@@ -539,17 +565,14 @@ export const MenuContent = defineComponent({
|
|
|
539
565
|
const onCloseAutoFocus = (event) => emit("closeAutoFocus", event);
|
|
540
566
|
const onOpenAutoFocus = (event) => emit("openAutoFocus", event);
|
|
541
567
|
const exitGuard = createExitGuard();
|
|
542
|
-
|
|
568
|
+
const phoneLayout = useMenuPhoneLayout();
|
|
569
|
+
return () => menuPortal(phoneLayout, () => h(TransitionGroup, { class: s.Menu, ...overlayTiming, ...exitGuard.transition, overlay: true }, {
|
|
543
570
|
default: () => [
|
|
544
|
-
|
|
545
|
-
default: () =>
|
|
546
|
-
|
|
547
|
-
? h(MenuRootContentImpl, { key: "dropdown", ...props, onCloseAutoFocus, onOpenAutoFocus, exitGuard }, { default: () => slots.default?.() })
|
|
548
|
-
: createCommentVNode(),
|
|
549
|
-
],
|
|
550
|
-
}),
|
|
571
|
+
open.value
|
|
572
|
+
? h(MenuRootContentImpl, { key: "dropdown", ...props, onCloseAutoFocus, onOpenAutoFocus, exitGuard }, { default: () => slots.default?.() })
|
|
573
|
+
: createCommentVNode(),
|
|
551
574
|
],
|
|
552
|
-
});
|
|
575
|
+
}));
|
|
553
576
|
},
|
|
554
577
|
});
|
|
555
578
|
// ---------------------------------------------------------------------------
|
|
@@ -1066,8 +1089,9 @@ const MenuSubContentImpl = defineComponent({
|
|
|
1066
1089
|
const subRoot = injectDropdownMenuRootContext();
|
|
1067
1090
|
const subInternals = useMenuSubInternals();
|
|
1068
1091
|
const subLevel = useMenuLevel();
|
|
1069
|
-
const floatingBoundary =
|
|
1070
|
-
|
|
1092
|
+
const floatingBoundary = useMenuBoundary(subLevel.open);
|
|
1093
|
+
// A press on the parent it stands over collapses a phone submenu
|
|
1094
|
+
const phone = usePhoneSubmenu(subLevel.open, subInternals.trigger, subLevel.content, floatingBoundary, () => requestCollapse());
|
|
1071
1095
|
const internals = useMenuRootInternals();
|
|
1072
1096
|
const parentContent = inject(ParentContentKey, null);
|
|
1073
1097
|
subRoot.triggerId = subInternals.triggerId;
|
|
@@ -1210,7 +1234,8 @@ const MenuSubContentImpl = defineComponent({
|
|
|
1210
1234
|
] }) : null,
|
|
1211
1235
|
// A separator under the row that heads it, as iOS 26 submenus (iOS-menu IMG_5677, IMG_5682)
|
|
1212
1236
|
phone.value.mobile ? h("div", { "role": "separator", "aria-orientation": "horizontal", "class": s.Separator }) : null,
|
|
1213
|
-
|
|
1237
|
+
// The items, which scroll under that heading on a phone; on a desktop they lie in the panel itself
|
|
1238
|
+
h("div", { class: s.SubmenuItems }, slots.default?.()),
|
|
1214
1239
|
] });
|
|
1215
1240
|
},
|
|
1216
1241
|
});
|
|
@@ -1241,17 +1266,14 @@ export const MenuSubContent = defineComponent({
|
|
|
1241
1266
|
setup(props, { slots }) {
|
|
1242
1267
|
const { open } = useSubmenuContext();
|
|
1243
1268
|
const exitGuard = createExitGuard();
|
|
1244
|
-
|
|
1269
|
+
const phoneLayout = useMenuPhoneLayout();
|
|
1270
|
+
return () => menuPortal(phoneLayout, () => h(TransitionGroup, { class: s.Menu, ...overlayTimingQuick, ...exitGuard.transition, overlay: true }, {
|
|
1245
1271
|
default: () => [
|
|
1246
|
-
|
|
1247
|
-
default: () =>
|
|
1248
|
-
|
|
1249
|
-
? h(MenuSubContentImpl, { key: "submenu", ...props, exitGuard }, { default: () => slots.default?.() })
|
|
1250
|
-
: createCommentVNode(),
|
|
1251
|
-
],
|
|
1252
|
-
}),
|
|
1272
|
+
open.value
|
|
1273
|
+
? h(MenuSubContentImpl, { key: "submenu", ...props, exitGuard }, { default: () => slots.default?.() })
|
|
1274
|
+
: createCommentVNode(),
|
|
1253
1275
|
],
|
|
1254
|
-
});
|
|
1276
|
+
}));
|
|
1255
1277
|
},
|
|
1256
1278
|
});
|
|
1257
1279
|
// ---------------------------------------------------------------------------
|