@plexui/vue 0.9.0 → 0.11.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/Alert/Alert.js +6 -2
- package/dist/es/components/Alert/Alert.js.map +1 -1
- package/dist/es/components/Avatar/Avatar.js +3 -1
- package/dist/es/components/Avatar/Avatar.js.map +1 -1
- package/dist/es/components/ButtonGroup/ButtonGroup.js +7 -0
- package/dist/es/components/ButtonGroup/ButtonGroup.js.map +1 -1
- package/dist/es/components/ButtonGroup/index.js.map +1 -1
- package/dist/es/components/Checkbox/Checkbox.js +5 -6
- package/dist/es/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/es/components/ColorPicker/ColorPicker.js +476 -0
- package/dist/es/components/ColorPicker/ColorPicker.js.map +1 -0
- package/dist/es/components/ColorPicker/ColorWell.js +186 -0
- package/dist/es/components/ColorPicker/ColorWell.js.map +1 -0
- package/dist/es/components/ColorPicker/index.js +3 -0
- package/dist/es/components/ColorPicker/index.js.map +1 -0
- package/dist/es/components/ColorPicker/shared.js +132 -0
- package/dist/es/components/ColorPicker/shared.js.map +1 -0
- package/dist/es/components/ContextMenu/ContextMenu.js +223 -0
- package/dist/es/components/ContextMenu/ContextMenu.js.map +1 -0
- package/dist/es/components/ContextMenu/index.js +2 -0
- package/dist/es/components/ContextMenu/index.js.map +1 -0
- package/dist/es/components/ContextMenu/shared.js +58 -0
- package/dist/es/components/ContextMenu/shared.js.map +1 -0
- package/dist/es/components/DatePicker/DatePicker.js +19 -3
- package/dist/es/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js +1 -1
- package/dist/es/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/es/components/Dialog/Dialog.js +245 -25
- package/dist/es/components/Dialog/Dialog.js.map +1 -1
- package/dist/es/components/Dialog/dialogSteps.js +85 -0
- package/dist/es/components/Dialog/dialogSteps.js.map +1 -0
- package/dist/es/components/Dialog/dialogViewport.js +74 -0
- package/dist/es/components/Dialog/dialogViewport.js.map +1 -0
- package/dist/es/components/Dialog/index.js +1 -1
- package/dist/es/components/Dialog/index.js.map +1 -1
- package/dist/es/components/Dialog/sheetDrag.js +2 -1
- package/dist/es/components/Dialog/sheetDrag.js.map +1 -1
- package/dist/es/components/Field/Field.js +11 -3
- package/dist/es/components/Field/Field.js.map +1 -1
- package/dist/es/components/FieldGroup/FieldGroup.js +12 -1
- package/dist/es/components/FieldGroup/FieldGroup.js.map +1 -1
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js +2 -2
- package/dist/es/components/FloatingLabelInput/FloatingLabelInput.js.map +1 -1
- package/dist/es/components/Icon/index.js +1 -0
- package/dist/es/components/Icon/index.js.map +1 -1
- package/dist/es/components/Icon/svg/Eyedropper.js +10 -0
- package/dist/es/components/Icon/svg/Eyedropper.js.map +1 -0
- package/dist/es/components/IndexBar/IndexBar.js +215 -0
- package/dist/es/components/IndexBar/IndexBar.js.map +1 -0
- package/dist/es/components/IndexBar/index.js +2 -0
- package/dist/es/components/IndexBar/index.js.map +1 -0
- package/dist/es/components/Indicator/LoadingIndicator.js +1 -1
- package/dist/es/components/Indicator/LoadingIndicator.js.map +1 -1
- package/dist/es/components/Input/Input.js +3 -2
- package/dist/es/components/Input/Input.js.map +1 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js +149 -1
- package/dist/es/components/MarkdownEditor/MarkdownEditor.js.map +1 -1
- package/dist/es/components/Menu/Menu.js +206 -33
- package/dist/es/components/Menu/Menu.js.map +1 -1
- package/dist/es/components/Menu/index.js +1 -1
- package/dist/es/components/Menu/index.js.map +1 -1
- package/dist/es/components/Page/Page.js +43 -11
- package/dist/es/components/Page/Page.js.map +1 -1
- package/dist/es/components/PageControl/PageControl.js +210 -0
- package/dist/es/components/PageControl/PageControl.js.map +1 -0
- package/dist/es/components/PageControl/index.js +2 -0
- package/dist/es/components/PageControl/index.js.map +1 -0
- package/dist/es/components/PhoneLayout/PhoneLayout.js +50 -0
- package/dist/es/components/PhoneLayout/PhoneLayout.js.map +1 -0
- package/dist/es/components/PhoneLayout/index.js +2 -0
- package/dist/es/components/PhoneLayout/index.js.map +1 -0
- package/dist/es/components/Popover/Popover.js +5 -1
- package/dist/es/components/Popover/Popover.js.map +1 -1
- package/dist/es/components/Popover/deferredPointerDownOutside.js +59 -4
- package/dist/es/components/Popover/deferredPointerDownOutside.js.map +1 -1
- package/dist/es/components/Select/Select.js +18 -11
- package/dist/es/components/Select/Select.js.map +1 -1
- package/dist/es/components/SelectControl/SelectControl.js +1 -0
- package/dist/es/components/SelectControl/SelectControl.js.map +1 -1
- package/dist/es/components/Sidebar/Sidebar.js +21 -6
- package/dist/es/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/es/components/Slider/Slider.js +44 -9
- package/dist/es/components/Slider/Slider.js.map +1 -1
- package/dist/es/components/Stepper/Stepper.js +195 -0
- package/dist/es/components/Stepper/Stepper.js.map +1 -0
- package/dist/es/components/Stepper/index.js +2 -0
- package/dist/es/components/Stepper/index.js.map +1 -0
- package/dist/es/components/SwipeActions/SwipeActions.js +374 -0
- package/dist/es/components/SwipeActions/SwipeActions.js.map +1 -0
- package/dist/es/components/SwipeActions/index.js +2 -0
- package/dist/es/components/SwipeActions/index.js.map +1 -0
- package/dist/es/components/Switch/Switch.js +3 -1
- package/dist/es/components/Switch/Switch.js.map +1 -1
- package/dist/es/components/TabBar/TabBar.js +205 -0
- package/dist/es/components/TabBar/TabBar.js.map +1 -0
- package/dist/es/components/TabBar/index.js +2 -0
- package/dist/es/components/TabBar/index.js.map +1 -0
- package/dist/es/components/Tabs/Tabs.js +10 -2
- package/dist/es/components/Tabs/Tabs.js.map +1 -1
- package/dist/es/components/TagInput/TagInput.js +3 -46
- package/dist/es/components/TagInput/TagInput.js.map +1 -1
- package/dist/es/components/Textarea/Textarea.js +2 -0
- package/dist/es/components/Textarea/Textarea.js.map +1 -1
- package/dist/es/components/Tip/Tip.js +276 -0
- package/dist/es/components/Tip/Tip.js.map +1 -0
- package/dist/es/components/Tip/index.js +2 -0
- package/dist/es/components/Tip/index.js.map +1 -0
- package/dist/es/components/Toast/ToastRenderer.js +30 -13
- package/dist/es/components/Toast/ToastRenderer.js.map +1 -1
- package/dist/es/components/Toast/Toaster.js +17 -6
- package/dist/es/components/Toast/Toaster.js.map +1 -1
- package/dist/es/components/Toast/toastLifecycle.js +113 -1
- package/dist/es/components/Toast/toastLifecycle.js.map +1 -1
- package/dist/es/components/Toolbar/Toolbar.js +37 -6
- package/dist/es/components/Toolbar/Toolbar.js.map +1 -1
- package/dist/es/components/Toolbar/index.js.map +1 -1
- package/dist/es/components/Tooltip/slot.js +3 -3
- package/dist/es/components/Tooltip/slot.js.map +1 -1
- package/dist/es/composables/useEscCloseStack.js +8 -4
- package/dist/es/composables/useEscCloseStack.js.map +1 -1
- package/dist/es/lib/fieldRow.js +15 -2
- package/dist/es/lib/fieldRow.js.map +1 -1
- package/dist/es/lib/floatingBoundary.js +3 -1
- package/dist/es/lib/floatingBoundary.js.map +1 -1
- package/dist/es/lib/helpers.js +21 -0
- package/dist/es/lib/helpers.js.map +1 -1
- package/dist/es/lib/menuSubmenuPlacement.js +51 -6
- package/dist/es/lib/menuSubmenuPlacement.js.map +1 -1
- package/dist/es/lib/menuTriggerCover.js +70 -0
- package/dist/es/lib/menuTriggerCover.js.map +1 -0
- package/dist/es/lib/phoneLayout.js +16 -0
- package/dist/es/lib/phoneLayout.js.map +1 -0
- package/dist/es/lib/scrollEdges.js +34 -0
- package/dist/es/lib/scrollEdges.js.map +1 -0
- package/dist/es/lib/toastRegion.js +6 -0
- package/dist/es/lib/toastRegion.js.map +1 -0
- package/dist/types/components/ButtonGroup/ButtonGroup.d.ts +13 -0
- package/dist/types/components/ButtonGroup/index.d.ts +1 -1
- package/dist/types/components/ColorPicker/ColorPicker.d.ts +244 -0
- package/dist/types/components/ColorPicker/ColorWell.d.ts +334 -0
- package/dist/types/components/ColorPicker/index.d.ts +3 -0
- package/dist/types/components/ColorPicker/shared.d.ts +69 -0
- package/dist/types/components/ContextMenu/ContextMenu.d.ts +128 -0
- package/dist/types/components/ContextMenu/index.d.ts +1 -0
- package/dist/types/components/ContextMenu/shared.d.ts +51 -0
- package/dist/types/components/DatePicker/DatePicker.d.ts +24 -4
- package/dist/types/components/DateRangePicker/DateRangePicker.d.ts +4 -4
- package/dist/types/components/Dialog/Dialog.d.ts +100 -4
- package/dist/types/components/Dialog/dialogSteps.d.ts +10 -0
- package/dist/types/components/Dialog/dialogViewport.d.ts +1 -0
- package/dist/types/components/Dialog/index.d.ts +1 -1
- package/dist/types/components/Field/Field.d.ts +21 -2
- package/dist/types/components/FieldGroup/FieldGroup.d.ts +18 -1
- package/dist/types/components/Icon/index.d.ts +1 -0
- package/dist/types/components/Icon/svg/Eyedropper.d.ts +3 -0
- package/dist/types/components/IndexBar/IndexBar.d.ts +112 -0
- package/dist/types/components/IndexBar/index.d.ts +1 -0
- package/dist/types/components/Indicator/LoadingIndicator.d.ts +2 -2
- package/dist/types/components/Menu/Menu.d.ts +153 -40
- package/dist/types/components/Menu/index.d.ts +1 -1
- package/dist/types/components/Page/Page.d.ts +13 -5
- package/dist/types/components/PageControl/PageControl.d.ts +216 -0
- package/dist/types/components/PageControl/index.d.ts +1 -0
- package/dist/types/components/PhoneLayout/PhoneLayout.d.ts +21 -0
- package/dist/types/components/PhoneLayout/index.d.ts +1 -0
- package/dist/types/components/Popover/deferredPointerDownOutside.d.ts +1 -1
- package/dist/types/components/Select/Select.d.ts +6 -6
- package/dist/types/components/Stepper/Stepper.d.ts +338 -0
- package/dist/types/components/Stepper/index.d.ts +1 -0
- package/dist/types/components/SwipeActions/SwipeActions.d.ts +135 -0
- package/dist/types/components/SwipeActions/index.d.ts +1 -0
- package/dist/types/components/TabBar/TabBar.d.ts +405 -0
- package/dist/types/components/TabBar/index.d.ts +1 -0
- package/dist/types/components/Tip/Tip.d.ts +146 -0
- package/dist/types/components/Tip/index.d.ts +1 -0
- package/dist/types/components/Toast/toastLifecycle.d.ts +34 -0
- package/dist/types/components/Toolbar/Toolbar.d.ts +26 -9
- package/dist/types/components/Toolbar/index.d.ts +1 -1
- package/dist/types/components/Tooltip/CopyTooltip.d.ts +1 -1
- package/dist/types/composables/useEscCloseStack.d.ts +2 -2
- package/dist/types/lib/fieldRow.d.ts +5 -0
- package/dist/types/lib/helpers.d.ts +6 -0
- package/dist/types/lib/menuSubmenuPlacement.d.ts +14 -1
- package/dist/types/lib/menuTriggerCover.d.ts +23 -0
- package/dist/types/lib/phoneLayout.d.ts +11 -0
- package/dist/types/lib/scrollEdges.d.ts +16 -0
- package/dist/types/lib/toastRegion.d.ts +5 -0
- package/package.json +2 -2
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { cloneVNode, computed, createCommentVNode, defineComponent, h, inject, markRaw, onBeforeUnmount, onMounted, provide, ref, shallowRef, watch, withCtx, } from "vue";
|
|
1
|
+
import { cloneVNode, Comment as CommentVNode, computed, createCommentVNode, defineComponent, Fragment as FragmentVNode, h, inject, isVNode, markRaw, onBeforeUnmount, onMounted, provide, ref, shallowRef, watch, watchEffect, withCtx, } from "vue";
|
|
2
2
|
import { DropdownMenuContent as RekaDropdownMenuContent, DropdownMenuPortal as RekaDropdownMenuPortal, DropdownMenuRoot as RekaDropdownMenuRoot, Presence, injectDropdownMenuRootContext, useDirection, useId, } from "reka-ui";
|
|
3
3
|
import { useEscCloseStack } from "../../composables/useEscCloseStack.js";
|
|
4
4
|
import { isHoverPointer } from "../../lib/inputMode.js";
|
|
5
|
+
import { hasContent } from "../../lib/slotContent.js";
|
|
5
6
|
import { firstElementChild } from "../Tooltip/slot.js";
|
|
6
7
|
import { keepMovedFocus, preventDefaultHandler, toCssVariables } from "../../lib/helpers.js";
|
|
7
8
|
import { Button } from "../Button/index.js";
|
|
@@ -14,8 +15,12 @@ import { MenuLevelKey, MenuRootInternalsKey, MenuSubInternalsKey, SUB_CLOSE_KEYS
|
|
|
14
15
|
import { useFloatingBoundary } from "../../composables/useFloatingBoundary.js";
|
|
15
16
|
import { usePhoneSubmenu } from "../../composables/usePhoneSubmenu.js";
|
|
16
17
|
import { focusPhoneSubmenuEntry } from "../../lib/menuSubmenuPlacement.js";
|
|
18
|
+
import { ignoreReleaseOverTrigger, observeMenuTriggerCover } from "../../lib/menuTriggerCover.js";
|
|
17
19
|
import { completeInitialPhoneSubmenuFocus, deferInitialPhoneSubmenuFocus, delegateInitialPhoneSubmenuFocus } from "../../lib/menuInitialFocus.js";
|
|
18
20
|
import s from "@plexui/styles/components/Menu/Menu.module.css";
|
|
21
|
+
// A touch listener lets iOS Safari apply :active, which draws the pressed capsule of a phone row (Menu.module.css).
|
|
22
|
+
// React listens for touchstart at its root already.
|
|
23
|
+
const pressListeners = { onTouchstartPassive: () => { } };
|
|
19
24
|
// Vue port of packages/ui/src/components/Menu/Menu.tsx. Exports are flat
|
|
20
25
|
// (`Menu`, `MenuTrigger`, `MenuContent`, ...) because runtime-compiled
|
|
21
26
|
// templates cannot resolve `Menu.Trigger` from the `components` option.
|
|
@@ -73,7 +78,8 @@ const markPointerFocusRestore = (trigger) => {
|
|
|
73
78
|
return clear;
|
|
74
79
|
};
|
|
75
80
|
const MenuContextKey = Symbol("PlexUIMenu");
|
|
76
|
-
|
|
81
|
+
/** @internal The open state of the enclosing Menu, for ContextMenu. Not exported from the package index. */
|
|
82
|
+
export const useMenuContext = () => {
|
|
77
83
|
const context = inject(MenuContextKey, null);
|
|
78
84
|
if (!context)
|
|
79
85
|
throw new Error("Menu components must be wrapped in <Menu />");
|
|
@@ -146,12 +152,26 @@ export const Menu = defineComponent({
|
|
|
146
152
|
}
|
|
147
153
|
};
|
|
148
154
|
provide(MenuContextKey, { open: isOpen, setOpen: handleOpenChange, prepareFocusRestore });
|
|
155
|
+
// Radix's Menu root: an open menu closes when the window loses focus, to another app or another frame of the page.
|
|
156
|
+
let stopBlur;
|
|
157
|
+
const closeOnBlur = (nextOpen) => {
|
|
158
|
+
stopBlur?.();
|
|
159
|
+
stopBlur = undefined;
|
|
160
|
+
if (!nextOpen)
|
|
161
|
+
return;
|
|
162
|
+
const handleBlur = () => setOpen(false);
|
|
163
|
+
window.addEventListener("blur", handleBlur);
|
|
164
|
+
stopBlur = () => window.removeEventListener("blur", handleBlur);
|
|
165
|
+
};
|
|
166
|
+
watch(isOpen, closeOnBlur, { flush: "post" });
|
|
149
167
|
let stopTracking;
|
|
150
168
|
onMounted(() => {
|
|
151
169
|
stopTracking = trackKeyboardUse(isUsingKeyboard);
|
|
170
|
+
closeOnBlur(isOpen.value);
|
|
152
171
|
});
|
|
153
172
|
onBeforeUnmount(() => {
|
|
154
173
|
stopTracking?.();
|
|
174
|
+
stopBlur?.();
|
|
155
175
|
clearPointerFocus?.();
|
|
156
176
|
});
|
|
157
177
|
const level = { open: () => isOpen.value, onOpenChange: setOpen, content: shallowRef(null) };
|
|
@@ -213,8 +233,10 @@ export const MenuTrigger = defineComponent({
|
|
|
213
233
|
level.onOpenChange(!wasOpen);
|
|
214
234
|
// prevent trigger focusing when opening
|
|
215
235
|
// this allows the content to be given focus without competition
|
|
216
|
-
if (
|
|
217
|
-
|
|
236
|
+
if (wasOpen)
|
|
237
|
+
return;
|
|
238
|
+
event.preventDefault();
|
|
239
|
+
ignoreReleaseOverTrigger(event.currentTarget, event.pointerId);
|
|
218
240
|
}
|
|
219
241
|
};
|
|
220
242
|
const onClick = (event) => {
|
|
@@ -257,7 +279,9 @@ export const MenuTrigger = defineComponent({
|
|
|
257
279
|
"aria-controls": open ? rootContext.contentId : undefined,
|
|
258
280
|
"data-state": getOpenState(open),
|
|
259
281
|
"data-disabled": props.disabled ? "" : undefined,
|
|
260
|
-
|
|
282
|
+
// React leaves `disabled={false}` off an element, so an element that is not a button gets no attribute; a
|
|
283
|
+
// component child still receives false, as Radix passes it.
|
|
284
|
+
"disabled": typeof child.type === "string" ? props.disabled || undefined : props.disabled,
|
|
261
285
|
...restAttrs,
|
|
262
286
|
"onPointerdown": (event) => {
|
|
263
287
|
handledClick = false;
|
|
@@ -317,7 +341,7 @@ const MenuRootContentImpl = defineComponent({
|
|
|
317
341
|
name: "MenuRootContentImpl",
|
|
318
342
|
props: {
|
|
319
343
|
side: String,
|
|
320
|
-
sideOffset:
|
|
344
|
+
sideOffset: Number,
|
|
321
345
|
align: String,
|
|
322
346
|
alignOffset: Number,
|
|
323
347
|
width: sizeProp,
|
|
@@ -327,6 +351,7 @@ const MenuRootContentImpl = defineComponent({
|
|
|
327
351
|
size: String,
|
|
328
352
|
pill: Boolean,
|
|
329
353
|
onCloseAutoFocus: { type: Function, required: true },
|
|
354
|
+
onOpenAutoFocus: { type: Function, required: true },
|
|
330
355
|
exitGuard: { type: Object, required: true },
|
|
331
356
|
},
|
|
332
357
|
setup(props, { slots }) {
|
|
@@ -338,6 +363,16 @@ const MenuRootContentImpl = defineComponent({
|
|
|
338
363
|
rootContext.contentId ||= useId(undefined, "reka-dropdown-menu-content");
|
|
339
364
|
const { contentHandlers, resetSearch } = provideMenuContentContext(() => level.content.value);
|
|
340
365
|
provide(ParentContentKey, { resetSearch });
|
|
366
|
+
// On a phone a menu without its own offset grows out of its trigger, covers it and opens toward the larger part
|
|
367
|
+
// of the screen (menuTriggerCover.ts); one that opens to a side keeps its gap
|
|
368
|
+
const coversTrigger = () => props.sideOffset === undefined && props.side !== "left" && props.side !== "right";
|
|
369
|
+
const triggerCover = shallowRef(null);
|
|
370
|
+
watchEffect((onCleanup) => {
|
|
371
|
+
const trigger = internals.trigger.value;
|
|
372
|
+
if (!coversTrigger() || !trigger)
|
|
373
|
+
return;
|
|
374
|
+
onCleanup(observeMenuTriggerCover(trigger, (value) => { triggerCover.value = value; }));
|
|
375
|
+
});
|
|
341
376
|
onMounted(() => {
|
|
342
377
|
level.content.value = document.getElementById(rootContext.contentId);
|
|
343
378
|
});
|
|
@@ -361,7 +396,9 @@ const MenuRootContentImpl = defineComponent({
|
|
|
361
396
|
const trigger = internals.trigger.value;
|
|
362
397
|
if (!hasInteractedOutside && trigger) {
|
|
363
398
|
prepareFocusRestore(trigger);
|
|
364
|
-
|
|
399
|
+
// Without scrolling: a plain focus() scrolls every scrolling ancestor to the trigger, the page around a
|
|
400
|
+
// frame that holds the menu too
|
|
401
|
+
trigger.focus({ preventScroll: true });
|
|
365
402
|
}
|
|
366
403
|
hasInteractedOutside = false;
|
|
367
404
|
// Always prevent auto focus because we either focus manually or want user agent focus
|
|
@@ -392,17 +429,19 @@ const MenuRootContentImpl = defineComponent({
|
|
|
392
429
|
const handlers = contentHandlers(internals.isUsingKeyboard);
|
|
393
430
|
return () => {
|
|
394
431
|
const isHorizontal = props.layout === "horizontal";
|
|
432
|
+
const cover = coversTrigger() ? triggerCover.value : null;
|
|
395
433
|
return h(RekaDropdownMenuContent, {
|
|
396
434
|
"forceMount": true,
|
|
397
435
|
"as": MenuContentElement,
|
|
398
|
-
"side": props.side,
|
|
399
|
-
"sideOffset": props.sideOffset,
|
|
436
|
+
"side": props.side ?? cover?.side,
|
|
437
|
+
"sideOffset": cover ? cover.sideOffset : props.sideOffset ?? 5,
|
|
400
438
|
"align": props.align,
|
|
401
|
-
"alignOffset": props.alignOffset ?? (props.align === "center" ? 0 : -5),
|
|
439
|
+
"alignOffset": props.alignOffset ?? (cover || props.align === "center" ? 0 : -5),
|
|
402
440
|
"avoidCollisions": true,
|
|
403
441
|
...floatingBoundary.value,
|
|
404
442
|
"reference": internals.trigger.value ?? undefined,
|
|
405
443
|
"class": s.MenuList,
|
|
444
|
+
...pressListeners,
|
|
406
445
|
"data-pill": props.pill ? "" : undefined,
|
|
407
446
|
"data-layout": isHorizontal ? "horizontal" : undefined,
|
|
408
447
|
"data-size": isHorizontal && props.size ? props.size : undefined,
|
|
@@ -415,7 +454,10 @@ const MenuRootContentImpl = defineComponent({
|
|
|
415
454
|
...contentVariables,
|
|
416
455
|
},
|
|
417
456
|
"onEscapeKeyDown": preventDefaultHandler,
|
|
418
|
-
"onOpenAutoFocus": (event) =>
|
|
457
|
+
"onOpenAutoFocus": (event) => {
|
|
458
|
+
props.onOpenAutoFocus(event);
|
|
459
|
+
delegateInitialPhoneSubmenuFocus(event, level.content.value);
|
|
460
|
+
},
|
|
419
461
|
onCloseAutoFocus,
|
|
420
462
|
onInteractOutside,
|
|
421
463
|
...handlers,
|
|
@@ -429,25 +471,31 @@ export const MenuContent = defineComponent({
|
|
|
429
471
|
inheritAttrs: false,
|
|
430
472
|
props: {
|
|
431
473
|
/**
|
|
432
|
-
* The preferred side of the trigger to render against when open. Will be reversed when collisions occur.
|
|
474
|
+
* The preferred side of the trigger to render against when open. Will be reversed when collisions occur. Without
|
|
475
|
+
* it a menu on a phone opens toward the larger part of the screen: upward from a trigger in the lower half.
|
|
433
476
|
* @default bottom
|
|
434
477
|
*/
|
|
435
478
|
side: String,
|
|
436
479
|
/**
|
|
437
|
-
* The distance in pixels from the trigger.
|
|
480
|
+
* The distance in pixels from the trigger. Without it a menu on a phone covers its trigger, as iOS menus grow out
|
|
481
|
+
* of the control that opens them.
|
|
438
482
|
* @default 5
|
|
439
483
|
*/
|
|
440
|
-
sideOffset: { type: Number, default:
|
|
484
|
+
sideOffset: { type: Number, default: undefined },
|
|
441
485
|
/**
|
|
442
486
|
* The preferred alignment against the trigger. May change when collisions occur.
|
|
443
487
|
* @default center
|
|
444
488
|
*/
|
|
445
489
|
align: String,
|
|
446
|
-
/**
|
|
490
|
+
/**
|
|
491
|
+
* An offset in pixels from the "start" or "end" alignment options. Without it a menu on a phone that covers its
|
|
492
|
+
* trigger keeps the trigger's edge.
|
|
493
|
+
* @default -5 with "start" or "end", 0 with "center"
|
|
494
|
+
*/
|
|
447
495
|
alignOffset: Number,
|
|
448
496
|
/**
|
|
449
|
-
* Defines the `width` property of the content
|
|
450
|
-
*
|
|
497
|
+
* Defines the `width` property of the content. Without it the menu fits its content, or with `touch.css` on a phone
|
|
498
|
+
* is the 250px panel of an iOS menu; `"auto"` fits its content there too.
|
|
451
499
|
*/
|
|
452
500
|
width: sizeProp,
|
|
453
501
|
/**
|
|
@@ -480,17 +528,23 @@ export const MenuContent = defineComponent({
|
|
|
480
528
|
* its focus-visible ring).
|
|
481
529
|
*/
|
|
482
530
|
closeAutoFocus: (event) => typeof event.type === "string",
|
|
531
|
+
/**
|
|
532
|
+
* Focus is about to move into the menu as it opens. Call `event.preventDefault()` to leave focus where it is, as
|
|
533
|
+
* for a menu that stands open when its screen appears.
|
|
534
|
+
*/
|
|
535
|
+
openAutoFocus: (event) => typeof event.type === "string",
|
|
483
536
|
},
|
|
484
537
|
setup(props, { slots, emit }) {
|
|
485
538
|
const { open } = useMenuContext();
|
|
486
539
|
const onCloseAutoFocus = (event) => emit("closeAutoFocus", event);
|
|
540
|
+
const onOpenAutoFocus = (event) => emit("openAutoFocus", event);
|
|
487
541
|
const exitGuard = createExitGuard();
|
|
488
542
|
return () => h(RekaDropdownMenuPortal, null, {
|
|
489
543
|
default: () => [
|
|
490
544
|
h(TransitionGroup, { class: s.Menu, ...overlayTiming, ...exitGuard.transition, overlay: true }, {
|
|
491
545
|
default: () => [
|
|
492
546
|
open.value
|
|
493
|
-
? h(MenuRootContentImpl, { key: "dropdown", ...props, onCloseAutoFocus, exitGuard }, { default: () => slots.default?.() })
|
|
547
|
+
? h(MenuRootContentImpl, { key: "dropdown", ...props, onCloseAutoFocus, onOpenAutoFocus, exitGuard }, { default: () => slots.default?.() })
|
|
494
548
|
: createCommentVNode(),
|
|
495
549
|
],
|
|
496
550
|
}),
|
|
@@ -531,6 +585,33 @@ const MenuItemInteractive = defineComponent({
|
|
|
531
585
|
}, [h("div", { class: s.PressableInner }, slots.default?.())]);
|
|
532
586
|
},
|
|
533
587
|
});
|
|
588
|
+
// A row's own children, with the fragments of a passed-through slot opened up, as React's Children.toArray does.
|
|
589
|
+
const flattenRow = (nodes) => nodes.flatMap((node) => Array.isArray(node) ? flattenRow(node)
|
|
590
|
+
: isVNode(node) && node.type === FragmentVNode && Array.isArray(node.children) ? flattenRow(node.children)
|
|
591
|
+
: [node]);
|
|
592
|
+
// An icon is a component, an svg or an img; text and text elements (strong, kbd) belong to the label. A v-if
|
|
593
|
+
// placeholder is neither.
|
|
594
|
+
const isLeadingIcon = (part) => isVNode(part) && (typeof part.type === "object" || typeof part.type === "function" || part.type === "svg" || part.type === "img");
|
|
595
|
+
const isPlaceholder = (part) => part == null || typeof part === "boolean" || (isVNode(part) && part.type === CommentVNode);
|
|
596
|
+
// A description counts when it renders something: a non-empty string, or a slot with content.
|
|
597
|
+
const describes = (description) => Array.isArray(description) ? hasContent(description) : description != null && description !== "";
|
|
598
|
+
/**
|
|
599
|
+
* A described row: the label over its description. Icons that lead the label stay beside the two lines, centred on
|
|
600
|
+
* both, as iOS draws Sort By with its order under it (Reminders); a row of icons alone stacks whole.
|
|
601
|
+
*/
|
|
602
|
+
const describedRow = (children, description) => {
|
|
603
|
+
const parts = flattenRow(children ?? []);
|
|
604
|
+
const label = parts.findIndex((part) => !isLeadingIcon(part) && !isPlaceholder(part));
|
|
605
|
+
const lead = label > 0 && parts.slice(0, label).some(isLeadingIcon) ? parts.slice(0, label) : [];
|
|
606
|
+
return [
|
|
607
|
+
...lead,
|
|
608
|
+
h("div", { class: s.ItemLeading }, [
|
|
609
|
+
h("div", null, lead.length > 0 ? parts.slice(label) : children),
|
|
610
|
+
// Not part of the label a phone submenu heads itself with
|
|
611
|
+
h("div", { class: s.ItemDescription, "data-menu-description": "" }, description),
|
|
612
|
+
]),
|
|
613
|
+
];
|
|
614
|
+
};
|
|
534
615
|
/**
|
|
535
616
|
* A menu item. Interactive (focusable, selectable) when it has a `@select` or
|
|
536
617
|
* a `@click` handler; read-only content otherwise.
|
|
@@ -567,14 +648,7 @@ export const MenuItem = defineComponent({
|
|
|
567
648
|
const description = slots.description ? slots.description() : props.description;
|
|
568
649
|
// A described item stacks its two lines; without a description the item
|
|
569
650
|
// keeps the plain flex row that icons and ItemActions rely on.
|
|
570
|
-
const content = description
|
|
571
|
-
? slots.default?.()
|
|
572
|
-
: [
|
|
573
|
-
h("div", { class: s.ItemLeading }, [
|
|
574
|
-
h("div", null, slots.default?.()),
|
|
575
|
-
h("div", { class: s.ItemDescription }, description),
|
|
576
|
-
]),
|
|
577
|
-
];
|
|
651
|
+
const content = describes(description) ? describedRow(slots.default?.(), description) : slots.default?.();
|
|
578
652
|
// Custom click handlers: either callback makes the item interactive
|
|
579
653
|
if (props.onSelect || props.onClick) {
|
|
580
654
|
return h(MenuItemInteractive, { className: attrs.class, disabled: props.disabled, danger: props.danger, onSelect: props.onSelect, onItemClick }, { default: () => content });
|
|
@@ -711,6 +785,72 @@ export const MenuGroup = defineComponent({
|
|
|
711
785
|
return () => h("div", { role: "group", class: attrs.class }, slots.default?.());
|
|
712
786
|
},
|
|
713
787
|
});
|
|
788
|
+
/**
|
|
789
|
+
* Names what the menu acts on, above its items: the picture, name and kind of a file in the iOS Files menu, with a
|
|
790
|
+
* round action at its end. Not an item itself; its action is. The default slot is the title; `media` is a picture
|
|
791
|
+
* before it (a thumbnail image, an icon or an Avatar, in a square of 32px, 40px on a phone: an image or icon fills
|
|
792
|
+
* the square, an image gets small rounded corners), and `action` a `MenuHeaderAction` at the end.
|
|
793
|
+
*/
|
|
794
|
+
export const MenuHeader = defineComponent({
|
|
795
|
+
name: "MenuHeader",
|
|
796
|
+
inheritAttrs: false,
|
|
797
|
+
props: {
|
|
798
|
+
/** A line under the title: what it is, such as its kind and size ("Folder · 382 KB"). Also a `description` slot. */
|
|
799
|
+
description: String,
|
|
800
|
+
},
|
|
801
|
+
setup(props, { slots, attrs }) {
|
|
802
|
+
return () => {
|
|
803
|
+
// A slot that renders nothing (a v-if placeholder) leaves no box, as a null or false node does in React
|
|
804
|
+
const media = slots.media?.();
|
|
805
|
+
const description = slots.description ? slots.description() : props.description;
|
|
806
|
+
return h("div", { "class": [s.MenuHeader, attrs.class], "data-menu-header": "" }, [
|
|
807
|
+
hasContent(media) ? h("div", { class: s.MenuHeaderMedia }, media) : null,
|
|
808
|
+
h("div", { class: s.MenuHeaderText }, [
|
|
809
|
+
h("div", { class: s.MenuHeaderTitle }, slots.default?.()),
|
|
810
|
+
hasContent([description]) ? h("div", { class: s.MenuHeaderDescription }, description) : null,
|
|
811
|
+
]),
|
|
812
|
+
slots.action?.(),
|
|
813
|
+
]);
|
|
814
|
+
};
|
|
815
|
+
},
|
|
816
|
+
});
|
|
817
|
+
/** The round action at the end of a `MenuHeader`, such as Share: a menu item, reached with the arrow keys too. */
|
|
818
|
+
export const MenuHeaderAction = defineComponent({
|
|
819
|
+
name: "MenuHeaderAction",
|
|
820
|
+
inheritAttrs: false,
|
|
821
|
+
props: {
|
|
822
|
+
/** Accessible name; the action is an icon-only button */
|
|
823
|
+
ariaLabel: { type: String, required: true },
|
|
824
|
+
/** Disables the action */
|
|
825
|
+
disabled: { type: Boolean, default: false },
|
|
826
|
+
},
|
|
827
|
+
emits: {
|
|
828
|
+
/** The action was pressed; the menu then closes. `event.preventDefault()` keeps it open. */
|
|
829
|
+
select: (event) => typeof event.type === "string",
|
|
830
|
+
},
|
|
831
|
+
setup(props, { slots, attrs, emit }) {
|
|
832
|
+
const impl = useMenuItemImpl(() => props.disabled);
|
|
833
|
+
const select = useMenuItemSelect(impl, () => props.disabled, () => (event) => emit("select", event));
|
|
834
|
+
return () => {
|
|
835
|
+
const { listeners, rest } = splitListeners(attrs);
|
|
836
|
+
const { class: className, ...restProps } = rest;
|
|
837
|
+
return h(Button, {
|
|
838
|
+
...impl.attrs(),
|
|
839
|
+
...restProps,
|
|
840
|
+
"class": [s.MenuHeaderAction, className],
|
|
841
|
+
"color": "secondary",
|
|
842
|
+
"variant": "soft",
|
|
843
|
+
"size": "md",
|
|
844
|
+
"uniform": true,
|
|
845
|
+
"pill": true,
|
|
846
|
+
"aria-label": props.ariaLabel,
|
|
847
|
+
"disabled": props.disabled,
|
|
848
|
+
"ref": impl.setElement,
|
|
849
|
+
...selectableItemListeners(impl, select, listeners),
|
|
850
|
+
}, { default: () => slots.default?.() });
|
|
851
|
+
};
|
|
852
|
+
},
|
|
853
|
+
});
|
|
714
854
|
// ---------------------------------------------------------------------------
|
|
715
855
|
// Submenus
|
|
716
856
|
/** A nested menu: `MenuSubTrigger` plus `MenuSubContent`. */
|
|
@@ -778,6 +918,11 @@ export const MenuSubTrigger = defineComponent({
|
|
|
778
918
|
props: {
|
|
779
919
|
/** Disables the trigger */
|
|
780
920
|
disabled: { type: Boolean, default: false },
|
|
921
|
+
/**
|
|
922
|
+
* Second line under the label: what the submenu has chosen, as Reminders shows "Manual" under Sort By. It stacks
|
|
923
|
+
* as an item's description does; icons before the label stay beside both lines. Also a `description` slot.
|
|
924
|
+
*/
|
|
925
|
+
description: String,
|
|
781
926
|
},
|
|
782
927
|
setup(props, { slots, attrs }) {
|
|
783
928
|
const { open: menuOpen } = useMenuContext();
|
|
@@ -883,6 +1028,7 @@ export const MenuSubTrigger = defineComponent({
|
|
|
883
1028
|
};
|
|
884
1029
|
return () => {
|
|
885
1030
|
const open = subLevel.open();
|
|
1031
|
+
const description = slots.description ? slots.description() : props.description;
|
|
886
1032
|
return h("div", {
|
|
887
1033
|
...impl.attrs(),
|
|
888
1034
|
"id": subInternals.triggerId,
|
|
@@ -896,7 +1042,7 @@ export const MenuSubTrigger = defineComponent({
|
|
|
896
1042
|
...impl.handlers(subTriggerHandlers),
|
|
897
1043
|
}, [
|
|
898
1044
|
h("div", { class: s.PressableInner }, [
|
|
899
|
-
slots.default?.(),
|
|
1045
|
+
...(describes(description) ? describedRow(slots.default?.(), description) : [slots.default?.()]),
|
|
900
1046
|
h(ChevronRight, { width: "16", height: "16", class: s.SubTriggerIcon }),
|
|
901
1047
|
]),
|
|
902
1048
|
]);
|
|
@@ -909,7 +1055,7 @@ const MenuSubContentImpl = defineComponent({
|
|
|
909
1055
|
props: {
|
|
910
1056
|
sideOffset: { type: Number, required: true },
|
|
911
1057
|
alignOffset: { type: Number, required: true },
|
|
912
|
-
width:
|
|
1058
|
+
width: sizeProp,
|
|
913
1059
|
minWidth: sizeProp,
|
|
914
1060
|
maxHeight: Number,
|
|
915
1061
|
pill: Boolean,
|
|
@@ -995,6 +1141,7 @@ const MenuSubContentImpl = defineComponent({
|
|
|
995
1141
|
...floatingBoundary.value,
|
|
996
1142
|
"reference": subInternals.trigger.value ?? undefined,
|
|
997
1143
|
"class": s.MenuList,
|
|
1144
|
+
...pressListeners,
|
|
998
1145
|
"data-submenu": "",
|
|
999
1146
|
"data-pill": props.pill ? "" : undefined,
|
|
1000
1147
|
"style": {
|
|
@@ -1002,7 +1149,8 @@ const MenuSubContentImpl = defineComponent({
|
|
|
1002
1149
|
"menu-width": props.width,
|
|
1003
1150
|
"menu-min-width": props.minWidth ?? "auto",
|
|
1004
1151
|
"menu-max-height": props.maxHeight,
|
|
1005
|
-
"
|
|
1152
|
+
// A submenu of "auto" width fits its content on a phone too; without one it takes the menu's 250px (touch.css)
|
|
1153
|
+
"menu-phone-width": phone.value.mobile ? (props.width === "auto" ? "max-content" : props.width) : undefined,
|
|
1006
1154
|
"menu-phone-min-width": phone.value.mobile ? (props.minWidth === "auto" ? 0 : props.minWidth) : undefined,
|
|
1007
1155
|
}),
|
|
1008
1156
|
...contentVariables,
|
|
@@ -1060,6 +1208,8 @@ const MenuSubContentImpl = defineComponent({
|
|
|
1060
1208
|
phone.value.mobile ? phone.value.label : "",
|
|
1061
1209
|
h(ChevronDown, { width: "16", height: "16", class: s.SubTriggerIcon }),
|
|
1062
1210
|
] }) : null,
|
|
1211
|
+
// A separator under the row that heads it, as iOS 26 submenus (iOS-menu IMG_5677, IMG_5682)
|
|
1212
|
+
phone.value.mobile ? h("div", { "role": "separator", "aria-orientation": "horizontal", "class": s.Separator }) : null,
|
|
1063
1213
|
slots.default?.(),
|
|
1064
1214
|
] });
|
|
1065
1215
|
},
|
|
@@ -1073,8 +1223,11 @@ export const MenuSubContent = defineComponent({
|
|
|
1073
1223
|
sideOffset: { type: Number, default: 4 },
|
|
1074
1224
|
/** An offset in pixels along the trigger. @default -6 */
|
|
1075
1225
|
alignOffset: { type: Number, default: -6 },
|
|
1076
|
-
/**
|
|
1077
|
-
|
|
1226
|
+
/**
|
|
1227
|
+
* The width of the submenu. Without it the submenu fits its content, or with `touch.css` on a phone is the 250px
|
|
1228
|
+
* of a menu; `"auto"` fits its content there too.
|
|
1229
|
+
*/
|
|
1230
|
+
width: sizeProp,
|
|
1078
1231
|
/** Defines the `min-width` property of the content. @default "auto" */
|
|
1079
1232
|
minWidth: sizeProp,
|
|
1080
1233
|
/** Defines the `max-height` property of the content, in pixels. */
|
|
@@ -1131,6 +1284,12 @@ export const MenuRadioGroup = defineComponent({
|
|
|
1131
1284
|
* @default end
|
|
1132
1285
|
*/
|
|
1133
1286
|
indicatorPosition: { type: String, default: "end" },
|
|
1287
|
+
/**
|
|
1288
|
+
* `horizontal` sets the options side by side, each an icon over its label and the chosen one on a fill: a mode at
|
|
1289
|
+
* the top of an iOS menu, above its list, as Photos orders by Added or by Captured. No radio indicator is drawn;
|
|
1290
|
+
* choosing one closes the menu, as any item does.
|
|
1291
|
+
*/
|
|
1292
|
+
layout: { type: String, default: "vertical" },
|
|
1134
1293
|
},
|
|
1135
1294
|
emits: {
|
|
1136
1295
|
"update:value": (value) => typeof value === "string",
|
|
@@ -1145,7 +1304,15 @@ export const MenuRadioGroup = defineComponent({
|
|
|
1145
1304
|
emit("change", value);
|
|
1146
1305
|
},
|
|
1147
1306
|
});
|
|
1148
|
-
return () =>
|
|
1307
|
+
return () => {
|
|
1308
|
+
const horizontal = props.layout === "horizontal";
|
|
1309
|
+
return h("div", {
|
|
1310
|
+
"role": "group",
|
|
1311
|
+
"class": s.RadioGroup,
|
|
1312
|
+
"data-layout": horizontal ? "horizontal" : undefined,
|
|
1313
|
+
"data-indicator-position": horizontal ? undefined : props.indicatorPosition,
|
|
1314
|
+
}, slots.default?.());
|
|
1315
|
+
};
|
|
1149
1316
|
},
|
|
1150
1317
|
});
|
|
1151
1318
|
/** One option of a `MenuRadioGroup`. */
|
|
@@ -1154,6 +1321,11 @@ export const MenuRadioItem = defineComponent({
|
|
|
1154
1321
|
inheritAttrs: false,
|
|
1155
1322
|
props: {
|
|
1156
1323
|
value: { type: String, required: true },
|
|
1324
|
+
/**
|
|
1325
|
+
* Second line under the label, as iOS shows the order of the chosen sort (Files: "Newest to Oldest" under Date). It
|
|
1326
|
+
* stacks as a MenuItem's description does. Also a `description` slot.
|
|
1327
|
+
*/
|
|
1328
|
+
description: String,
|
|
1157
1329
|
/** Disables the radio item */
|
|
1158
1330
|
disabled: { type: Boolean, default: false },
|
|
1159
1331
|
},
|
|
@@ -1173,6 +1345,7 @@ export const MenuRadioItem = defineComponent({
|
|
|
1173
1345
|
return () => {
|
|
1174
1346
|
const { listeners, rest } = splitListeners(attrs);
|
|
1175
1347
|
const { class: className, ...restProps } = rest;
|
|
1348
|
+
const description = slots.description ? slots.description() : props.description;
|
|
1176
1349
|
return h("div", {
|
|
1177
1350
|
...impl.attrs(),
|
|
1178
1351
|
"role": "menuitemradio",
|
|
@@ -1189,7 +1362,7 @@ export const MenuRadioItem = defineComponent({
|
|
|
1189
1362
|
default: () => [h(Check, { class: s.SelectionCheck })],
|
|
1190
1363
|
}),
|
|
1191
1364
|
]),
|
|
1192
|
-
slots.default?.(),
|
|
1365
|
+
...(describes(description) ? describedRow(slots.default?.(), description) : [slots.default?.()]),
|
|
1193
1366
|
]),
|
|
1194
1367
|
]);
|
|
1195
1368
|
};
|